{"question_id": 787, "task_id": "cheapest-flights-within-k-stops", "difficulty": "Medium", "problem_description": "There are n cities connected by some number of flights. You are given an array flights where flights[i] = [from_i, to_i, price_i] indicates that there is a flight from city from_i to city to_i with cost price_i.\n\nYou are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops. If there is no such route, return -1.\n\nExample 1:\n\nInput: n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1\nOutput: 700\nExplanation:\nThe graph is shown above.\nThe optimal path with at most 1 stop from city 0 to 3 is marked in red and has cost 100 + 600 = 700.\nNote that the path through cities [0,1,2,3] is cheaper but is invalid because it uses 2 stops.\n\nExample 2:\n\nInput: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1\nOutput: 200\nExplanation:\nThe graph is shown above.\nThe optimal path with at most 1 stop from city 0 to 2 is marked in red and has cost 100 + 100 = 200.\n\nExample 3:\n\nInput: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0\nOutput: 500\nExplanation:\nThe graph is shown above.\nThe optimal path with no stops from city 0 to 2 is marked in red and has cost 500.\n\nConstraints:\n\n- 2 <= n <= 100\n- 0 <= flights.length <= (n * (n - 1) / 2)\n- flights[i].length == 3\n- 0 <= from_i, to_i < n\n- from_i != to_i\n- 1 <= price_i <= 10^4\n- There will not be any multiple flights between two cities.\n- 0 <= src, dst, k < n\n- src != dst\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 20], [2, 3, 10], [3, 4, 10], [4, 5, 10]],src = 0,dst = 5,k = 2) == -1\n assert candidate(n = 3,flights = [[0, 1, 100], [1, 2, 100]],src = 0,dst = 2,k = 2) == 200\n assert candidate(n = 3,flights = [[0, 1, 100], [1, 2, 100], [0, 2, 500]],src = 0,dst = 2,k = 1) == 200\n assert candidate(n = 6,flights = [[0, 1, 10], [1, 2, 20], [0, 3, 40], [3, 4, 20], [4, 2, 10], [2, 5, 25]],src = 0,dst = 5,k = 2) == 55\n assert candidate(n = 3,flights = [[0, 1, 100], [1, 2, 100]],src = 0,dst = 2,k = 0) == -1\n assert candidate(n = 4,flights = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [2, 3, 1]],src = 0,dst = 3,k = 1) == 6\n assert candidate(n = 4,flights = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [2, 3, 1], [1, 3, 4]],src = 0,dst = 3,k = 1) == 5\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 15], [1, 3, 20], [2, 4, 50], [3, 4, 10], [4, 5, 10]],src = 0,dst = 5,k = 1) == -1\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 30], [1, 3, 50], [2, 3, 20], [3, 4, 10], [4, 5, 60]],src = 0,dst = 5,k = 2) == -1\n assert candidate(n = 4,flights = [[0, 1, 100], [1, 2, 100], [2, 0, 100], [1, 3, 600], [2, 3, 200]],src = 0,dst = 3,k = 1) == 700\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 30], [1, 2, 10], [1, 3, 40], [2, 3, 10], [2, 4, 10], [3, 4, 10], [4, 5, 10]],src = 0,dst = 5,k = 1) == -1\n assert candidate(n = 3,flights = [[0, 1, 100], [1, 2, 100], [0, 2, 500]],src = 0,dst = 2,k = 0) == 500\n assert candidate(n = 2,flights = [[0, 1, 100]],src = 0,dst = 1,k = 0) == 100\n assert candidate(n = 5,flights = [[0, 1, 5], [1, 2, 5], [0, 3, 2], [3, 1, 2], [1, 4, 1], [4, 2, 1]],src = 0,dst = 2,k = 2) == 7\n assert candidate(n = 9,flights = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 4, 40], [1, 5, 50], [2, 5, 60], [2, 6, 70], [3, 4, 80], [3, 6, 90], [4, 7, 100], [5, 7, 110], [5, 8, 120], [6, 8, 130], [7, 8, 140]],src = 0,dst = 8,k = 7) == 180\n assert candidate(n = 8,flights = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [0, 7, 250], [7, 0, 250], [1, 3, 50], [3, 1, 50], [2, 4, 70], [4, 2, 70], [5, 7, 90], [7, 5, 90]],src = 0,dst = 7,k = 2) == 250\n assert candidate(n = 5,flights = [[0, 1, 500], [0, 2, 100], [2, 3, 300], [1, 4, 200], [3, 4, 50], [4, 2, 100], [2, 0, 200]],src = 0,dst = 4,k = 2) == 450\n assert candidate(n = 8,flights = [[0, 1, 100], [0, 2, 150], [1, 3, 100], [1, 4, 200], [2, 3, 150], [2, 5, 200], [3, 4, 100], [3, 6, 150], [4, 7, 200], [5, 6, 100], [5, 7, 150], [6, 7, 100]],src = 0,dst = 7,k = 3) == 450\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 150], [1, 3, 100], [1, 4, 200], [2, 3, 200], [2, 5, 300], [3, 4, 50], [3, 6, 200], [4, 6, 150], [5, 6, 100]],src = 0,dst = 6,k = 4) == 400\n assert candidate(n = 12,flights = [[0, 1, 5], [1, 2, 10], [2, 3, 5], [3, 4, 10], [4, 5, 5], [5, 6, 10], [6, 7, 5], [7, 8, 10], [8, 9, 5], [9, 10, 10], [10, 11, 5], [0, 11, 100]],src = 0,dst = 11,k = 6) == 100\n assert candidate(n = 7,flights = [[0, 1, 200], [0, 2, 300], [1, 2, 100], [1, 3, 150], [2, 3, 200], [2, 4, 100], [3, 4, 50], [3, 5, 100], [4, 5, 150], [4, 6, 100], [5, 6, 200]],src = 0,dst = 6,k = 5) == 500\n assert candidate(n = 9,flights = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 20], [2, 3, 10], [2, 4, 15], [3, 4, 5], [3, 5, 25], [4, 5, 10], [4, 6, 20], [5, 6, 15], [5, 7, 25], [6, 7, 10], [6, 8, 15], [7, 8, 5]],src = 0,dst = 8,k = 5) == 65\n assert candidate(n = 12,flights = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 10], [2, 3, 20], [3, 4, 50], [4, 5, 20], [5, 6, 10], [6, 7, 15], [7, 8, 30], [8, 9, 50], [9, 10, 70], [10, 11, 90], [11, 3, 110]],src = 0,dst = 11,k = 6) == -1\n assert candidate(n = 9,flights = [[0, 1, 50], [0, 2, 30], [1, 3, 100], [1, 4, 10], [2, 5, 50], [2, 6, 100], [3, 7, 10], [4, 8, 100], [5, 8, 50], [6, 8, 5], [7, 8, 50]],src = 0,dst = 8,k = 2) == 130\n assert candidate(n = 10,flights = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 0, 100]],src = 0,dst = 9,k = 9) == 450\n assert candidate(n = 5,flights = [[0, 1, 10], [0, 2, 5], [1, 2, 2], [1, 3, 20], [2, 3, 10], [2, 4, 15], [3, 4, 10]],src = 0,dst = 4,k = 2) == 20\n assert candidate(n = 12,flights = [[0, 1, 200], [0, 2, 300], [1, 3, 100], [1, 4, 200], [2, 3, 400], [2, 4, 500], [3, 4, 100], [3, 5, 200], [4, 5, 150], [4, 6, 300], [5, 6, 250], [6, 7, 400], [6, 8, 500], [7, 8, 100], [7, 9, 300], [8, 9, 200], [8, 10, 100], [9, 10, 250], [9, 11, 400], [10, 11, 300]],src = 0,dst = 11,k = 2) == -1\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 100], [1, 2, 50], [1, 3, 150], [1, 4, 120], [2, 4, 50], [3, 4, 10], [3, 5, 60], [4, 5, 30], [4, 6, 100], [5, 6, 50], [6, 7, 80], [6, 8, 100], [7, 8, 20], [7, 9, 60], [8, 9, 30]],src = 0,dst = 9,k = 3) == -1\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 30], [1, 2, 5], [1, 3, 40], [2, 3, 10], [2, 4, 10], [3, 4, 20], [4, 5, 10], [5, 6, 15], [6, 7, 25], [7, 8, 30], [8, 9, 10]],src = 0,dst = 9,k = 4) == -1\n assert candidate(n = 10,flights = [[0, 1, 100], [0, 2, 300], [1, 2, 150], [1, 3, 400], [2, 4, 100], [3, 4, 200], [3, 5, 500], [4, 5, 250], [4, 6, 350], [5, 6, 100], [6, 7, 200], [7, 8, 100], [8, 9, 150]],src = 0,dst = 9,k = 3) == -1\n assert candidate(n = 7,flights = [[0, 1, 5], [1, 2, 3], [2, 3, 8], [0, 3, 10], [3, 4, 4], [4, 5, 6], [5, 6, 2], [6, 3, 7], [0, 4, 20], [1, 5, 12], [2, 6, 9]],src = 0,dst = 6,k = 3) == 17\n assert candidate(n = 15,flights = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 50], [2, 3, 10], [2, 4, 50], [3, 4, 10], [3, 5, 60], [4, 5, 30], [4, 6, 100], [5, 6, 50], [6, 7, 80], [6, 8, 100], [7, 8, 20], [7, 9, 60], [8, 9, 30], [8, 10, 50], [9, 10, 10], [9, 11, 60], [10, 11, 30], [11, 12, 50], [12, 13, 80], [13, 14, 100]],src = 0,dst = 14,k = 5) == -1\n assert candidate(n = 15,flights = [[0, 1, 10], [0, 2, 20], [1, 3, 5], [1, 4, 15], [2, 5, 6], [2, 6, 12], [3, 7, 8], [3, 8, 15], [4, 9, 15], [4, 10, 25], [5, 10, 7], [5, 11, 12], [6, 11, 6], [7, 8, 5], [8, 9, 5], [9, 10, 5], [10, 11, 5], [10, 12, 15], [11, 12, 10], [11, 13, 25], [12, 13, 15], [12, 14, 10], [13, 14, 5]],src = 0,dst = 14,k = 5) == 58\n assert candidate(n = 8,flights = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 30], [2, 3, 25], [3, 4, 50], [4, 5, 20], [5, 6, 10], [6, 7, 15]],src = 0,dst = 7,k = 3) == -1\n assert candidate(n = 12,flights = [[0, 1, 5], [0, 2, 10], [1, 3, 15], [1, 4, 20], [2, 5, 25], [2, 6, 30], [3, 7, 35], [3, 8, 40], [4, 8, 45], [4, 9, 50], [5, 9, 55], [5, 10, 60], [6, 10, 65], [7, 11, 70], [8, 11, 75], [9, 11, 80]],src = 0,dst = 11,k = 4) == 125\n assert candidate(n = 10,flights = [[0, 1, 50], [1, 2, 30], [2, 3, 20], [3, 4, 10], [4, 5, 15], [5, 6, 25], [6, 7, 10], [7, 8, 5], [8, 9, 10]],src = 0,dst = 9,k = 3) == -1\n assert candidate(n = 7,flights = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 8], [1, 4, 15], [2, 3, 4], [2, 4, 9], [3, 5, 20], [4, 5, 10], [4, 6, 25], [5, 6, 5]],src = 0,dst = 6,k = 4) == 32\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 150], [1, 2, 50], [1, 3, 200], [2, 4, 100], [3, 4, 200], [3, 5, 150], [4, 5, 100], [5, 6, 200]],src = 0,dst = 6,k = 3) == 550\n assert candidate(n = 11,flights = [[0, 1, 100], [0, 2, 200], [1, 2, 100], [1, 3, 150], [2, 3, 50], [2, 4, 50], [3, 4, 100], [3, 5, 150], [4, 5, 200], [4, 6, 100], [5, 6, 50], [6, 7, 100], [6, 8, 100], [7, 8, 50], [7, 9, 150], [8, 9, 200], [8, 10, 100], [9, 10, 150]],src = 0,dst = 10,k = 4) == 550\n assert candidate(n = 10,flights = [[0, 1, 5], [0, 2, 10], [0, 3, 15], [0, 4, 20], [0, 5, 25], [0, 6, 30], [0, 7, 35], [0, 8, 40], [0, 9, 45], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [1, 9, 95], [9, 1, 95], [2, 8, 80], [8, 2, 80], [3, 7, 70], [7, 3, 70], [4, 6, 60], [6, 4, 60]],src = 0,dst = 9,k = 5) == 45\n assert candidate(n = 9,flights = [[0, 1, 100], [0, 2, 200], [1, 3, 100], [1, 4, 200], [2, 3, 150], [2, 4, 250], [3, 4, 50], [3, 5, 300], [4, 5, 200], [4, 6, 100], [5, 6, 150], [5, 7, 350], [6, 7, 100], [6, 8, 250], [7, 8, 200]],src = 0,dst = 8,k = 2) == -1\n assert candidate(n = 8,flights = [[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]],src = 0,dst = 7,k = 6) == 22\n assert candidate(n = 8,flights = [[0, 1, 10], [0, 2, 100], [1, 3, 150], [1, 4, 200], [2, 4, 50], [2, 5, 100], [3, 6, 10], [4, 6, 300], [5, 6, 50], [6, 7, 100]],src = 0,dst = 7,k = 3) == 270\n assert candidate(n = 7,flights = [[0, 1, 50], [0, 2, 100], [1, 2, 10], [1, 3, 20], [2, 3, 5], [3, 4, 100], [4, 5, 10], [5, 6, 50], [4, 6, 200]],src = 0,dst = 6,k = 2) == -1\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 8, 10], [4, 9, 10], [5, 9, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],src = 0,dst = 9,k = 5) == 30\n assert candidate(n = 6,flights = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 2, 150], [1, 3, 150], [2, 4, 150], [3, 5, 150], [0, 3, 200], [1, 4, 200], [2, 5, 200]],src = 0,dst = 5,k = 2) == 350\n assert candidate(n = 8,flights = [[0, 1, 50], [0, 2, 25], [1, 2, 10], [1, 3, 75], [2, 3, 60], [2, 4, 80], [3, 4, 40], [3, 5, 65], [4, 5, 30], [4, 6, 90], [5, 6, 50], [5, 7, 70], [6, 7, 20]],src = 0,dst = 7,k = 4) == 205\n assert candidate(n = 9,flights = [[0, 1, 10], [0, 2, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [0, 8, 80]],src = 0,dst = 8,k = 2) == 80\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 50], [1, 2, 10], [1, 3, 40], [2, 3, 10], [3, 4, 10], [4, 5, 10], [2, 5, 50]],src = 0,dst = 5,k = 2) == 70\n assert candidate(n = 6,flights = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 0, 60]],src = 0,dst = 5,k = 5) == 150\n assert candidate(n = 8,flights = [[0, 1, 100], [0, 4, 10], [0, 2, 100], [1, 2, 10], [1, 3, 50], [2, 3, 20], [3, 4, 20], [4, 5, 10], [5, 6, 50], [6, 7, 10]],src = 0,dst = 7,k = 3) == 80\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 5], [1, 2, 1], [1, 3, 4], [2, 4, 10], [2, 5, 15], [3, 5, 25], [4, 6, 5], [5, 7, 10], [6, 8, 20], [7, 9, 15]],src = 0,dst = 9,k = 5) == 45\n assert candidate(n = 8,flights = [[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]],src = 0,dst = 7,k = 4) == 110\n assert candidate(n = 7,flights = [[0, 1, 10], [0, 2, 10], [1, 2, 5], [1, 3, 50], [2, 3, 10], [3, 4, 20], [4, 5, 10], [5, 6, 10], [6, 0, 50]],src = 0,dst = 6,k = 3) == -1\n assert candidate(n = 6,flights = [[0, 1, 100], [0, 2, 200], [0, 3, 300], [1, 4, 400], [2, 4, 300], [3, 5, 200], [4, 5, 100]],src = 0,dst = 5,k = 2) == 500\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 200], [0, 3, 300], [1, 4, 100], [2, 4, 200], [3, 4, 300], [4, 5, 100], [4, 6, 200], [5, 6, 100]],src = 0,dst = 6,k = 3) == 400\n assert candidate(n = 6,flights = [[0, 1, 100], [0, 2, 100], [1, 3, 100], [1, 4, 100], [2, 4, 100], [2, 5, 100], [3, 4, 50], [4, 5, 50]],src = 0,dst = 5,k = 2) == 200\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 5], [0, 3, 15], [1, 2, 20], [1, 4, 50], [1, 5, 10], [2, 3, 10], [3, 4, 20], [4, 5, 10], [5, 6, 10], [6, 7, 5], [7, 8, 10], [8, 9, 10]],src = 0,dst = 9,k = 4) == -1\n assert candidate(n = 7,flights = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 4, 40], [1, 5, 50], [2, 5, 60], [2, 6, 70], [3, 4, 80], [4, 6, 90], [5, 6, 100]],src = 0,dst = 6,k = 5) == 90\n assert candidate(n = 8,flights = [[0, 1, 10], [1, 2, 20], [2, 3, 10], [3, 4, 20], [4, 5, 10], [5, 6, 20], [6, 7, 10], [0, 7, 100], [7, 3, 10], [3, 6, 50]],src = 0,dst = 7,k = 2) == 100\n assert candidate(n = 9,flights = [[0, 1, 50], [0, 2, 70], [1, 3, 100], [1, 4, 200], [2, 4, 120], [2, 5, 140], [3, 6, 90], [4, 6, 130], [4, 7, 150], [5, 7, 110], [6, 8, 80], [7, 8, 70]],src = 0,dst = 8,k = 4) == 320\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 20], [1, 3, 10], [1, 4, 20], [2, 4, 15], [2, 5, 30], [3, 5, 10], [4, 5, 5], [0, 5, 100]],src = 0,dst = 5,k = 1) == 50\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 300], [1, 2, 50], [1, 3, 200], [2, 3, 150], [2, 4, 250], [3, 4, 100], [3, 5, 200], [4, 5, 50], [4, 6, 100], [5, 6, 200]],src = 0,dst = 6,k = 2) == 650\n assert candidate(n = 6,flights = [[0, 1, 100], [0, 2, 150], [1, 2, 50], [1, 3, 200], [2, 3, 100], [2, 4, 150], [3, 4, 50], [3, 5, 250], [4, 5, 100]],src = 0,dst = 5,k = 2) == 400\n assert candidate(n = 12,flights = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 0, 10]],src = 0,dst = 11,k = 5) == -1\n assert candidate(n = 5,flights = [[0, 1, 100], [0, 2, 200], [1, 3, 300], [1, 4, 400], [2, 3, 150], [2, 4, 250], [3, 4, 100]],src = 0,dst = 4,k = 1) == 450\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 20], [1, 3, 100], [1, 4, 300], [2, 5, 50], [2, 6, 100], [3, 7, 10], [4, 7, 300], [5, 8, 50], [6, 8, 100], [7, 9, 10], [8, 9, 50]],src = 0,dst = 9,k = 4) == 130\n assert candidate(n = 8,flights = [[0, 1, 10], [1, 7, 50], [0, 7, 100], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 10], [7, 3, 20]],src = 0,dst = 7,k = 2) == 60\n assert candidate(n = 7,flights = [[0, 1, 50], [1, 2, 100], [2, 3, 50], [3, 4, 100], [4, 5, 50], [5, 6, 100], [0, 3, 200], [3, 5, 200], [0, 4, 300], [4, 6, 100], [1, 5, 200], [5, 1, 200], [2, 6, 250], [6, 2, 250], [0, 6, 350], [6, 0, 350]],src = 0,dst = 6,k = 4) == 350\n assert candidate(n = 10,flights = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1], [1, 9, 1], [2, 9, 1], [3, 9, 1], [4, 9, 1], [5, 9, 1], [6, 9, 1], [7, 9, 1], [8, 9, 1]],src = 0,dst = 9,k = 0) == 1\n assert candidate(n = 10,flights = [[0, 1, 5], [0, 2, 10], [1, 3, 15], [1, 4, 20], [2, 5, 25], [2, 6, 30], [3, 7, 35], [3, 8, 40], [4, 9, 45], [5, 9, 50], [6, 9, 55], [7, 9, 60], [8, 9, 65]],src = 0,dst = 9,k = 5) == 70\n assert candidate(n = 8,flights = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [0, 7, 400]],src = 0,dst = 7,k = 3) == 400\n assert candidate(n = 6,flights = [[0, 1, 100], [0, 2, 200], [1, 2, 100], [1, 3, 150], [2, 3, 150], [2, 4, 200], [3, 4, 50], [3, 5, 100], [4, 5, 50]],src = 0,dst = 5,k = 2) == 350\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 200], [1, 2, 50], [1, 3, 150], [2, 3, 100], [2, 4, 100], [3, 4, 50], [3, 5, 100], [4, 5, 150], [4, 6, 100], [5, 6, 50]],src = 0,dst = 6,k = 3) == 350\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 20], [2, 3, 10], [2, 4, 15], [3, 4, 5], [3, 5, 25], [4, 5, 10], [4, 6, 20], [5, 6, 15], [5, 7, 25], [6, 7, 10], [6, 8, 15], [7, 8, 5], [7, 9, 25], [8, 9, 10]],src = 0,dst = 9,k = 4) == 80\n assert candidate(n = 12,flights = [[0, 1, 5], [0, 2, 10], [1, 3, 20], [1, 4, 30], [2, 5, 20], [2, 6, 30], [3, 7, 40], [3, 8, 50], [4, 9, 40], [4, 10, 50], [5, 10, 20], [5, 11, 30], [6, 11, 20], [7, 8, 5], [8, 9, 5], [9, 10, 5], [10, 11, 5]],src = 0,dst = 11,k = 4) == 55\n assert candidate(n = 10,flights = [[0, 1, 100], [0, 2, 300], [1, 3, 200], [1, 4, 250], [2, 3, 50], [2, 5, 150], [3, 6, 50], [3, 7, 200], [4, 6, 150], [4, 7, 250], [5, 8, 50], [5, 9, 200], [6, 9, 150], [7, 8, 50], [8, 9, 50]],src = 0,dst = 9,k = 3) == 500\n assert candidate(n = 5,flights = [[0, 1, 10], [0, 2, 5], [0, 3, 15], [1, 2, 20], [1, 4, 50], [1, 3, 10], [2, 4, 10], [3, 4, 5]],src = 0,dst = 4,k = 2) == 15\n assert candidate(n = 10,flights = [[0, 1, 100], [1, 2, 200], [2, 3, 150], [3, 4, 200], [4, 5, 100], [5, 6, 250], [6, 7, 100], [7, 8, 300], [8, 9, 50]],src = 0,dst = 9,k = 0) == -1\n assert candidate(n = 12,flights = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 4, 40], [1, 5, 50], [2, 6, 60], [3, 7, 70], [4, 8, 80], [5, 9, 90], [6, 10, 100], [7, 11, 110], [8, 11, 120], [9, 11, 130]],src = 0,dst = 11,k = 5) == 210\n assert candidate(n = 9,flights = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 0, 10], [0, 8, 10], [1, 8, 10], [2, 8, 10], [3, 8, 10], [4, 8, 10], [5, 8, 10], [6, 8, 10], [7, 8, 10]],src = 0,dst = 4,k = 4) == 40\n assert candidate(n = 6,flights = [[0, 1, 100], [0, 2, 500], [1, 2, 100], [2, 3, 200], [3, 4, 100], [4, 5, 300], [5, 2, 200], [2, 5, 200], [1, 3, 300], [3, 5, 100]],src = 0,dst = 5,k = 3) == 400\n assert candidate(n = 10,flights = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 10], [2, 3, 20], [3, 4, 50], [4, 5, 20], [5, 6, 10], [6, 7, 15], [7, 8, 30], [8, 9, 50]],src = 0,dst = 9,k = 5) == -1\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 50], [0, 3, 100], [1, 4, 100], [1, 5, 50], [2, 4, 50], [2, 5, 100], [3, 4, 50], [4, 5, 25], [4, 6, 50], [5, 6, 100]],src = 0,dst = 6,k = 3) == 150\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 30], [2, 3, 25], [3, 4, 50], [4, 5, 20], [5, 0, 10]],src = 0,dst = 5,k = 2) == -1\n assert candidate(n = 7,flights = [[0, 1, 100], [0, 2, 200], [1, 3, 100], [1, 4, 150], [2, 3, 200], [2, 5, 300], [3, 4, 50], [3, 6, 200], [4, 6, 150], [5, 6, 100]],src = 0,dst = 6,k = 3) == 400\n assert candidate(n = 10,flights = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [8, 9, 100], [9, 0, 100], [0, 9, 10], [1, 8, 10], [2, 7, 10], [3, 6, 10], [4, 5, 10], [5, 4, 10], [6, 3, 10], [7, 2, 10], [8, 1, 10], [9, 0, 10]],src = 0,dst = 9,k = 4) == 10\n assert candidate(n = 15,flights = [[0, 1, 10], [0, 2, 20], [1, 3, 10], [2, 4, 20], [3, 5, 10], [4, 6, 20], [5, 7, 10], [6, 8, 20], [7, 9, 10], [8, 10, 20], [9, 11, 10], [10, 12, 20], [11, 13, 10], [12, 14, 20], [13, 14, 10]],src = 0,dst = 14,k = 7) == 80\n assert candidate(n = 9,flights = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [8, 0, 100], [0, 2, 150], [2, 4, 150], [4, 6, 150], [6, 8, 150], [1, 3, 150], [3, 5, 150], [5, 7, 150], [7, 0, 150]],src = 0,dst = 8,k = 4) == 600\n assert candidate(n = 8,flights = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 7, 10], [1, 4, 5], [2, 5, 5], [3, 6, 5], [4, 7, 5]],src = 0,dst = 7,k = 3) == 20\n assert candidate(n = 9,flights = [[0, 1, 100], [0, 2, 150], [1, 3, 50], [1, 4, 200], [2, 5, 100], [3, 6, 50], [4, 7, 200], [5, 8, 100], [6, 8, 100], [7, 8, 50]],src = 0,dst = 8,k = 4) == 300\n", "comparison": "exact"}, "public_tests": ["4\n[[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]]\n0\n3\n1", "3\n[[0,1,100],[1,2,100],[0,2,500]]\n0\n2\n1", "3\n[[0,1,100],[1,2,100],[0,2,500]]\n0\n2\n0"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "flights", "src", "dst", "k"], "leetcode_dataset_entry_point": "Solution().findCheapestPrice", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:37+00:00", "tests_total": 94, "tests_dropped": 3, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming", "depth-first-search", "breadth-first-search", "graph", "heap-priority-queue", "shortest-path"]}, "language": "python", "interface": {"raw_signature": "def findCheapestPrice(self, n: int, flights: list[list[int]], src: int, dst: int, k: int) -> int:", "container": "Solution", "callable": "findCheapestPrice", "parameters": [{"name": "n", "type": "int"}, {"name": "flights", "type": "list[list[int]]"}, {"name": "src", "type": "int"}, {"name": "dst", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 788, "task_id": "rotated-digits", "difficulty": "Medium", "problem_description": "An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone.\n\nA number is valid if each digit remains a digit after rotation. For example:\n\n- 0, 1, and 8 rotate to themselves,\n- 2 and 5 rotate to each other (in this case they are rotated in a different direction, in other words, 2 or 5 gets mirrored),\n- 6 and 9 rotate to each other, and\n- the rest of the numbers do not rotate to any other number and become invalid.\n\nGiven an integer n, return the number of good integers in the range [1, n].\n\nExample 1:\n\nInput: n = 10\nOutput: 4\nExplanation: There are four good numbers in the range [1, 10] : 2, 5, 6, 9.\nNote that 1 and 10 are not good numbers, since they remain unchanged after rotating.\n\nExample 2:\n\nInput: n = 1\nOutput: 0\n\nExample 3:\n\nInput: n = 2\nOutput: 1\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 100) == 40\n assert candidate(n = 10000) == 2320\n assert candidate(n = 104) == 41\n assert candidate(n = 20) == 9\n assert candidate(n = 2) == 1\n assert candidate(n = 1) == 0\n assert candidate(n = 1000) == 316\n assert candidate(n = 10) == 4\n assert candidate(n = 50) == 16\n assert candidate(n = 4000) == 975\n assert candidate(n = 1010) == 320\n assert candidate(n = 8765) == 1888\n assert candidate(n = 5678) == 1206\n assert candidate(n = 5959) == 1297\n assert candidate(n = 1111) == 360\n assert candidate(n = 7000) == 1661\n assert candidate(n = 6172) == 1402\n assert candidate(n = 2000) == 633\n assert candidate(n = 7500) == 1661\n assert candidate(n = 8888) == 1920\n assert candidate(n = 3333) == 975\n assert candidate(n = 2525) == 797\n assert candidate(n = 6969) == 1647\n assert candidate(n = 3500) == 975\n assert candidate(n = 300) == 129\n assert candidate(n = 3000) == 975\n assert candidate(n = 3456) == 975\n assert candidate(n = 6789) == 1563\n assert candidate(n = 6666) == 1547\n assert candidate(n = 9652) == 2197\n assert candidate(n = 1024) == 327\n assert candidate(n = 2020) == 647\n assert candidate(n = 789) == 227\n assert candidate(n = 999) == 316\n assert candidate(n = 5555) == 1147\n assert candidate(n = 8000) == 1661\n assert candidate(n = 5000) == 976\n assert candidate(n = 9999) == 2320\n assert candidate(n = 4444) == 975\n assert candidate(n = 7890) == 1661\n assert candidate(n = 6174) == 1402\n assert candidate(n = 4321) == 975\n assert candidate(n = 7654) == 1661\n assert candidate(n = 7777) == 1661\n assert candidate(n = 2222) == 747\n assert candidate(n = 8080) == 1690\n assert candidate(n = 9265) == 2107\n assert candidate(n = 2500) == 780\n assert candidate(n = 9000) == 1978\n assert candidate(n = 1234) == 417\n assert candidate(n = 750) == 227\n assert candidate(n = 6000) == 1319\n assert candidate(n = 2569) == 814\n assert candidate(n = 500) == 130\n assert candidate(n = 9090) == 2020\n", "comparison": "exact"}, "public_tests": ["10", "1", "2"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().rotatedDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:39+00:00", "tests_total": 55, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def rotatedDigits(self, n: int) -> int:", "container": "Solution", "callable": "rotatedDigits", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 789, "task_id": "escape-the-ghosts", "difficulty": "Medium", "problem_description": "You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [x_target, y_target] that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array ghosts, where ghosts[i] = [x_i, y_i] represents the starting position of the i^th ghost. All inputs are integral coordinates.\n\nEach turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west, or stay still. All actions happen simultaneously.\n\nYou escape if and only if you can reach the target before any ghost reaches you. If you reach any square (including the target) at the same time as a ghost, it does not count as an escape.\n\nReturn true if it is possible to escape regardless of how the ghosts move, otherwise return false.\n\nExample 1:\n\nInput: ghosts = [[1,0],[0,3]], target = [0,1]\nOutput: true\nExplanation: You can reach the destination (0, 1) after 1 turn, while the ghosts located at (1, 0) and (0, 3) cannot catch up with you.\n\nExample 2:\n\nInput: ghosts = [[1,0]], target = [2,0]\nOutput: false\nExplanation: You need to reach the destination (2, 0), but the ghost at (1, 0) lies between you and the destination.\n\nExample 3:\n\nInput: ghosts = [[2,0]], target = [1,0]\nOutput: false\nExplanation: The ghost can reach the target at the same time as you.\n\nConstraints:\n\n- 1 <= ghosts.length <= 100\n- ghosts[i].length == 2\n- -10^4 <= x_i, y_i <= 10^4\n- There can be multiple ghosts in the same location.\n- target.length == 2\n- -10^4 <= x_target, y_target <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ghosts = [[0, 0], [0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[-1, -1]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3]],target = [4, 4]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3], [4, 4]],target = [5, 5]) == False\n assert candidate(ghosts = [[1, 0], [0, 3]],target = [0, 1]) == True\n assert candidate(ghosts = [[-1, -1], [-2, -2]],target = [-3, -3]) == False\n assert candidate(ghosts = [[0, 0], [0, 0]],target = [0, 0]) == False\n assert candidate(ghosts = [[0, 1], [1, 0], [0, -1], [-1, 0]],target = [0, 0]) == True\n assert candidate(ghosts = [[-10000, -10000]],target = [-9999, -9999]) == False\n assert candidate(ghosts = [[100, 100]],target = [-100, -100]) == True\n assert candidate(ghosts = [[10000, 10000]],target = [-10000, -10000]) == True\n assert candidate(ghosts = [[10000, 10000], [-10000, -10000]],target = [5000, 5000]) == False\n assert candidate(ghosts = [[0, 1], [0, -1], [1, 0], [-1, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[0, 0]],target = [0, 0]) == False\n assert candidate(ghosts = [[100, 100], [99, 100], [100, 99]],target = [101, 101]) == False\n assert candidate(ghosts = [[5, 5], [5, 6], [6, 5], [6, 6]],target = [5, 5]) == False\n assert candidate(ghosts = [[0, 1], [1, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[2, 0]],target = [1, 0]) == False\n assert candidate(ghosts = [[0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 1], [2, 2]],target = [3, 3]) == False\n assert candidate(ghosts = [[-1, -1]],target = [-2, -2]) == False\n assert candidate(ghosts = [[1, 1], [1, 1]],target = [2, 2]) == False\n assert candidate(ghosts = [[10000, 10000]],target = [9999, 9999]) == False\n assert candidate(ghosts = [[-1, -1], [2, 2]],target = [0, 0]) == True\n assert candidate(ghosts = [[-2, -2], [-3, -3]],target = [-4, -4]) == False\n assert candidate(ghosts = [[-1, 0], [0, -1]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 0]],target = [2, 0]) == False\n assert candidate(ghosts = [[-1, 0], [0, -1], [1, 0], [0, 1]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 0], [0, 1], [1, 1]],target = [-1, -1]) == True\n assert candidate(ghosts = [[-5, 5], [5, -5], [0, 10]],target = [5, 5]) == False\n assert candidate(ghosts = [[0, 1], [0, -1], [1, 0], [-1, 0]],target = [0, 0]) == True\n assert candidate(ghosts = [[5, 5], [3, 3], [-1, -1]],target = [0, 0]) == True\n assert candidate(ghosts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000]],target = [1001, 1001]) == False\n assert candidate(ghosts = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7]],target = [-7, -8]) == False\n assert candidate(ghosts = [[1, 0], [0, 1]],target = [-1, -1]) == True\n assert candidate(ghosts = [[100, 0], [0, 100], [-100, 0], [0, -100]],target = [50, 50]) == False\n assert candidate(ghosts = [[0, 0], [0, 0], [0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[-100, 100], [100, -100], [50, 50]],target = [0, 0]) == True\n assert candidate(ghosts = [[10, 10], [10, -10], [-10, 10], [-10, -10]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],target = [2, 5]) == False\n assert candidate(ghosts = [[-1, -1], [1, 1]],target = [10000, 10000]) == False\n assert candidate(ghosts = [[10000, 0], [0, 10000], [-10000, 0], [0, -10000]],target = [5000, 5000]) == False\n assert candidate(ghosts = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]],target = [-1, -1]) == False\n assert candidate(ghosts = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]],target = [5, 5]) == True\n assert candidate(ghosts = [[1, 2], [3, 4], [5, 6], [7, 8]],target = [-1, -2]) == True\n assert candidate(ghosts = [[0, 1], [0, -1], [1, 0], [-1, 0], [1, 1], [-1, -1]],target = [2, 2]) == False\n assert candidate(ghosts = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],target = [9, 10]) == False\n assert candidate(ghosts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],target = [6, 7]) == False\n assert candidate(ghosts = [[-1, 0], [0, -1], [1, 0], [0, 1], [-2, 0], [0, -2], [2, 0], [0, 2]],target = [3, 3]) == False\n assert candidate(ghosts = [[-1, -1], [-1, 1], [1, -1], [1, 1]],target = [2, 2]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],target = [0, 0]) == True\n assert candidate(ghosts = [[10, 10], [20, 20], [30, 30]],target = [15, 15]) == False\n assert candidate(ghosts = [[-10, 10], [10, -10], [-10, -10]],target = [0, 0]) == True\n assert candidate(ghosts = [[0, 1], [0, -1], [1, 0], [-1, 0], [1, 1], [-1, -1]],target = [10, 10]) == False\n assert candidate(ghosts = [[5, 5], [5, -5], [-5, 5], [-5, -5]],target = [0, 0]) == True\n assert candidate(ghosts = [[-10, 0], [0, -10], [10, 0], [0, 10]],target = [3, 3]) == True\n assert candidate(ghosts = [[-10000, -10000], [-10000, 10000], [10000, -10000], [10000, 10000]],target = [0, 0]) == True\n assert candidate(ghosts = [[5, -5], [-5, 5], [0, 0]],target = [-3, 3]) == False\n assert candidate(ghosts = [[1, 2], [2, 1], [3, 3], [4, 4], [5, 5]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],target = [6, 6]) == False\n assert candidate(ghosts = [[1000, 1000], [1001, 1001], [999, 999], [998, 998]],target = [1002, 1002]) == False\n assert candidate(ghosts = [[-1000, -1000], [-2000, -2000], [-1500, -1500], [-500, -500]],target = [-1500, -1500]) == False\n assert candidate(ghosts = [[-5000, 5000], [5000, -5000], [0, 0], [1, 1]],target = [5000, 5000]) == False\n assert candidate(ghosts = [[1000, 1000], [2000, 2000], [3000, 3000]],target = [1500, 1500]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],target = [6, 6]) == False\n assert candidate(ghosts = [[-10, -20], [-30, -40], [-50, -60]],target = [-40, -50]) == False\n assert candidate(ghosts = [[-5, 5], [5, -5], [-10, 10], [10, -10]],target = [0, 0]) == True\n assert candidate(ghosts = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2]],target = [2, 2]) == False\n assert candidate(ghosts = [[-100, -100], [100, 100], [-50, 50], [50, -50]],target = [0, 0]) == True\n assert candidate(ghosts = [[10000, 10000], [-10000, -10000], [10000, -10000], [-10000, 10000]],target = [0, 0]) == True\n assert candidate(ghosts = [[-10000, -10000], [10000, 10000]],target = [0, 0]) == True\n assert candidate(ghosts = [[-1, 1], [-2, 2], [-3, 3], [-4, 4]],target = [0, 0]) == True\n assert candidate(ghosts = [[10, 10], [20, 20], [30, 30]],target = [15, 15]) == False\n assert candidate(ghosts = [[1, 2], [3, 4], [5, 6]],target = [7, 8]) == False\n assert candidate(ghosts = [[0, 0], [0, 0]],target = [0, 0]) == False\n assert candidate(ghosts = [[1000, 1000], [999, 1000], [1000, 999], [999, 999]],target = [1001, 1001]) == False\n assert candidate(ghosts = [[1, 1], [1, -1], [-1, 1], [-1, -1]],target = [2, 2]) == False\n assert candidate(ghosts = [[5, 5], [5, -5], [-5, 5], [-5, -5]],target = [0, 0]) == True\n assert candidate(ghosts = [[100, 0], [0, 100], [50, 50], [0, 0]],target = [50, 50]) == False\n assert candidate(ghosts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]],target = [0, 5]) == False\n assert candidate(ghosts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],target = [7, 8]) == False\n assert candidate(ghosts = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],target = [10, 10]) == False\n assert candidate(ghosts = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]],target = [-6, -6]) == False\n assert candidate(ghosts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],target = [5, 5]) == False\n assert candidate(ghosts = [[1000, -1000], [-1000, 1000]],target = [0, 0]) == True\n assert candidate(ghosts = [[0, 0], [0, 1], [1, 0], [1, 1]],target = [10, 10]) == False\n assert candidate(ghosts = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],target = [0, 0]) == True\n assert candidate(ghosts = [[2, 2], [3, 3], [4, 4], [5, 5]],target = [1, 1]) == False\n assert candidate(ghosts = [[0, 0], [0, 0], [0, 0], [0, 0]],target = [1000, 1000]) == False\n assert candidate(ghosts = [[-50, -50], [-49, -49], [-48, -48], [-47, -47]],target = [-45, -45]) == False\n assert candidate(ghosts = [[-1000, -1000], [-1001, -1001], [-1002, -1002]],target = [-1003, -1003]) == False\n assert candidate(ghosts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],target = [0, 0]) == True\n assert candidate(ghosts = [[-1, -1], [-2, -2], [-3, -3], [-4, -4]],target = [0, 0]) == True\n assert candidate(ghosts = [[0, 10000], [10000, 0], [-10000, 0], [0, -10000]],target = [5000, 5000]) == False\n assert candidate(ghosts = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]],target = [6, 0]) == False\n assert candidate(ghosts = [[-10000, 0], [0, -10000], [10000, 0], [0, 10000]],target = [1, 1]) == True\n assert candidate(ghosts = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],target = [2, 2]) == False\n assert candidate(ghosts = [[10, 10], [20, 20], [30, 30]],target = [0, 0]) == True\n assert candidate(ghosts = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],target = [5, 6]) == False\n assert candidate(ghosts = [[-10, 10], [10, -10]],target = [5, 5]) == True\n assert candidate(ghosts = [[5, 5], [5, -5], [-5, 5], [-5, -5]],target = [10, 10]) == False\n assert candidate(ghosts = [[1, 0], [0, 1], [0, 0], [0, 2], [2, 0]],target = [2, 2]) == False\n assert candidate(ghosts = [[0, 1], [1, 0], [0, -1], [-1, 0]],target = [2, 2]) == False\n assert candidate(ghosts = [[2, 3], [4, 5], [6, 7], [8, 9]],target = [10, 10]) == False\n assert candidate(ghosts = [[5, 5], [-5, -5], [5, -5], [-5, 5]],target = [0, 0]) == True\n assert candidate(ghosts = [[-100, -100], [100, 100]],target = [0, 0]) == True\n assert candidate(ghosts = [[-1, 0], [0, -1], [1, 0], [0, 1], [0, 0]],target = [0, 0]) == False\n assert candidate(ghosts = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],target = [60, 60]) == False\n assert candidate(ghosts = [[1, 2], [3, 4], [5, 6], [7, 8]],target = [4, 4]) == False\n assert candidate(ghosts = [[-100, 0], [0, -100], [100, 0], [0, 100]],target = [100, 100]) == False\n assert candidate(ghosts = [[100, 0], [100, 0], [100, 0]],target = [200, 0]) == False\n assert candidate(ghosts = [[-5, 0], [5, 0], [0, -5], [0, 5]],target = [3, 3]) == False\n assert candidate(ghosts = [[-1, 1], [1, -1], [-1, -1]],target = [1, 1]) == False\n assert candidate(ghosts = [[1000, 1000], [2000, 2000], [1500, 1500], [500, 500]],target = [1500, 1500]) == False\n assert candidate(ghosts = [[1, 2], [3, 4], [5, 6]],target = [3, 3]) == False\n assert candidate(ghosts = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3]],target = [3, 1]) == False\n assert candidate(ghosts = [[0, 0], [0, 0], [0, 0], [0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[100, 0], [0, 100], [-100, 0], [0, -100]],target = [50, 50]) == False\n assert candidate(ghosts = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],target = [0, 6]) == False\n assert candidate(ghosts = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]],target = [-6, -6]) == False\n assert candidate(ghosts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000]],target = [0, 0]) == True\n assert candidate(ghosts = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6]],target = [-5, -5]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],target = [5, 5]) == False\n assert candidate(ghosts = [[-100, -100], [-200, -200], [-300, -300]],target = [-150, -150]) == False\n assert candidate(ghosts = [[5, 5], [5, 5], [5, 5]],target = [10, 10]) == False\n assert candidate(ghosts = [[1, 0], [0, 1], [0, 0], [2, 2], [3, 3]],target = [2, 1]) == False\n assert candidate(ghosts = [[0, 0], [0, 0], [0, 0], [0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]],target = [-5, -5]) == False\n assert candidate(ghosts = [[1, 0], [0, 1], [1, 1], [2, 0], [0, 2]],target = [1, 1]) == False\n assert candidate(ghosts = [[0, 1], [1, 0], [0, -1], [-1, 0]],target = [10, 10]) == False\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],target = [1, 1]) == False\n assert candidate(ghosts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],target = [0, 0]) == True\n assert candidate(ghosts = [[-1, 0], [0, -1]],target = [-10000, -10000]) == False\n assert candidate(ghosts = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],target = [2, 2]) == False\n assert candidate(ghosts = [[1000, 1000], [1001, 1001], [1002, 1002]],target = [1003, 1003]) == False\n assert candidate(ghosts = [[-10, -10], [-20, -20], [-30, -30], [-40, -40]],target = [-15, -15]) == False\n", "comparison": "exact"}, "public_tests": ["[[1,0],[0,3]]\n[0,1]", "[[1,0]]\n[2,0]", "[[2,0]]\n[1,0]"], "hints": [], "metadata": {"canonical_parameter_names": ["ghosts", "target"], "leetcode_dataset_entry_point": "Solution().escapeGhosts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:41+00:00", "tests_total": 138, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def escapeGhosts(self, ghosts: list[list[int]], target: list[int]) -> bool:", "container": "Solution", "callable": "escapeGhosts", "parameters": [{"name": "ghosts", "type": "list[list[int]]"}, {"name": "target", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 790, "task_id": "domino-and-tromino-tiling", "difficulty": "Medium", "problem_description": "You have two types of tiles: a 2 x 1 domino shape and a tromino shape. You may rotate these shapes.\n\nGiven an integer n, return the number of ways to tile an 2 x n board. Since the answer may be very large, return it modulo 10^9 + 7.\n\nIn a tiling, every square must be covered by a tile. Two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of the tilings has both squares occupied by a tile.\n\nExample 1:\n\nInput: n = 3\nOutput: 5\nExplanation: The five different ways are shown above.\n\nExample 2:\n\nInput: n = 1\nOutput: 1\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 5\n assert candidate(n = 100) == 190242381\n assert candidate(n = 4) == 11\n assert candidate(n = 2) == 2\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 603582422\n assert candidate(n = 1000) == 979232805\n assert candidate(n = 10) == 1255\n assert candidate(n = 5) == 24\n assert candidate(n = 12) == 6105\n assert candidate(n = 125) == 562894970\n assert candidate(n = 50) == 451995198\n assert candidate(n = 650) == 5517492\n assert candidate(n = 300) == 768506587\n assert candidate(n = 123) == 215563687\n assert candidate(n = 550) == 727269359\n assert candidate(n = 600) == 771568221\n assert candidate(n = 450) == 795340037\n assert candidate(n = 501) == 210280741\n assert candidate(n = 700) == 637136622\n assert candidate(n = 250) == 872044590\n assert candidate(n = 999) == 326038248\n assert candidate(n = 89) == 469785861\n assert candidate(n = 20) == 3418626\n assert candidate(n = 150) == 773955023\n assert candidate(n = 800) == 177362789\n assert candidate(n = 200) == 627399438\n assert candidate(n = 400) == 517656200\n assert candidate(n = 750) == 533845494\n assert candidate(n = 6) == 53\n", "comparison": "exact"}, "public_tests": ["3", "1"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numTilings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:44+00:00", "tests_total": 30, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numTilings(self, n: int) -> int:", "container": "Solution", "callable": "numTilings", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 791, "task_id": "custom-sort-string", "difficulty": "Medium", "problem_description": "You are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously.\n\nPermute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the permuted string.\n\nReturn any permutation of s that satisfies this property.\n\nExample 1:\n\nInput: order = \"cba\", s = \"abcd\"\nOutput: \"cbad\"\nExplanation: \"a\", \"b\", \"c\" appear in order, so the order of \"a\", \"b\", \"c\" should be \"c\", \"b\", and \"a\".\nSince \"d\" does not appear in order, it can be at any position in the returned string. \"dcba\", \"cdba\", \"cbda\" are also valid outputs.\n\nExample 2:\n\nInput: order = \"bcafg\", s = \"abcd\"\nOutput: \"bcad\"\nExplanation: The characters \"b\", \"c\", and \"a\" from order dictate the order for the characters in s. The character \"d\" in s does not appear in order, so its position is flexible.\nFollowing the order of appearance in order, \"b\", \"c\", and \"a\" from s should be arranged as \"b\", \"c\", \"a\". \"d\" can be placed at any position since it's not in order. The output \"bcad\" correctly follows this rule. Other arrangements like \"dbca\" or \"bcda\" would also be valid, as long as \"b\", \"c\", \"a\" maintain their order.\n\nConstraints:\n\n- 1 <= order.length <= 26\n- 1 <= s.length <= 200\n- order and s consist of lowercase English letters.\n- All the characters of order are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(order = \"zyx\",s = \"zyxwvut\") == \"zwvutyx\"\n assert candidate(order = \"abcdefg\",s = \"gfedcba\") == \"abcdefg\"\n assert candidate(order = \"xyz\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(order = \"mnopqr\",s = \"abcdefghij\") == \"abcdefghij\"\n assert candidate(order = \"abcdef\",s = \"fedcba\") == \"abcdef\"\n assert candidate(order = \"zyx\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwzyx\"\n assert candidate(order = \"a\",s = \"b\") == \"b\"\n assert candidate(order = \"xyz\",s = \"aabbcc\") == \"aabbcc\"\n assert candidate(order = \"zyxwvutsrqponmlkjihgfedcba\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(order = \"abc\",s = \"abc\") == \"abc\"\n assert candidate(order = \"cba\",s = \"abcd\") == \"cdba\"\n assert candidate(order = \"zyx\",s = \"xyz\") == \"zyx\"\n assert candidate(order = \"abcd\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfeabcd\"\n assert candidate(order = \"qrstuv\",s = \"uvwxyz\") == \"wxyzuv\"\n assert candidate(order = \"a\",s = \"aabbcc\") == \"aabbcc\"\n assert candidate(order = \"xyz\",s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(order = \"abcdefghijklmnopqrstuvwxyz\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(order = \"mnopqr\",s = \"abcdefghijklzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"abcdefghijklzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(order = \"bcafg\",s = \"abcd\") == \"bdca\"\n assert candidate(order = \"xyz\",s = \"zyxzyxzyx\") == \"xxxyyyzzz\"\n assert candidate(order = \"poiuytrewqlkjhgfdsamnbvcxz\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"pooooiuuyttrreeewqlkjhhgfdsamnbvcxz\"\n assert candidate(order = \"acegikm\",s = \"fedcbahjilnmporqstuvwxyz\") == \"fdbahjlnporqstuvwxyzceim\"\n assert candidate(order = \"ghjklm\",s = \"abcdefghijklmnopqrstuvmnopqrstuvwxyz\") == \"abcdefginopqrstuvnopqrstuvwxyzhjklmm\"\n assert candidate(order = \"qrstuv\",s = \"qwertyuiopasdfghjklzxcvbnm\") == \"qweyiopadfghjklzxcbnmrstuv\"\n assert candidate(order = \"abcdef\",s = \"fedcbahgfedcba\") == \"ahgabbccddeeff\"\n assert candidate(order = \"pqrs\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutponmlkjihgfedcbaqrs\"\n assert candidate(order = \"ghijklmnop\",s = \"fedcbazxcvbnmopqrstuvw\") == \"fedcbazxcvbqrstuvwmnop\"\n assert candidate(order = \"abcdefghijklmnop\",s = \"abcdefghijklmnopabcdefghijklmnop\") == \"aabbccddeeffgghhiijjkkllmmnnoopp\"\n assert candidate(order = \"zyxwvutsrqponmlkjihgfedcba\",s = \"aaabbbcccddd\") == \"dddcccbbbaaa\"\n assert candidate(order = \"aeiouy\",s = \"aeiouyaeiouyaeiouyaeiouy\") == \"aaaaeeeeiiiioooouuuuyyyy\"\n assert candidate(order = \"acegikmoqsuwy\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abdfhjlnprtvxzcegikmoqsuwy\"\n assert candidate(order = \"abcdef\",s = \"ghijklmnopqrstuvwxyz\") == \"ghijklmnopqrstuvwxyz\"\n assert candidate(order = \"qweasdzxc\",s = \"sazxqwecvfr\") == \"qvfrweaszxc\"\n assert candidate(order = \"abcd\",s = \"aabbccddeeffaabbccddeeff\") == \"aaeeffaaeeffbbbbccccdddd\"\n assert candidate(order = \"fjlad\",s = \"flafjlajldalfajfladflajfl\") == \"ffffffjjjjlllllllaaaaaadd\"\n assert candidate(order = \"abcdefg\",s = \"zyxcba\") == \"zyxabc\"\n assert candidate(order = \"xyz\",s = \"xyzxyzxyzxyzxyz\") == \"xxxxxyyyyyzzzzz\"\n assert candidate(order = \"abcde\",s = \"edcbafghijklmnopqrstuvwxyz\") == \"afghijklmnopqrstuvwxyzbcde\"\n assert candidate(order = \"qrstuv\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"heqickbownfoxjmpoehelazydogrrsttuuv\"\n assert candidate(order = \"abcd\",s = \"dbcaabcd\") == \"aabbccdd\"\n assert candidate(order = \"qwertyuiopasdfghjklzxcvbnm\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"qweeerrttyuuioooopasdfghhjklzxcvbnm\"\n assert candidate(order = \"bac\",s = \"abcabcabc\") == \"bbbaaaccc\"\n assert candidate(order = \"abcdefghijklmnopqrstuvwxy\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"azbcdefghijklmnopqrstuvwxy\"\n assert candidate(order = \"jkl\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"thequicbrownfoxjumpsovertheazydogkl\"\n assert candidate(order = \"abc\",s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aaddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzbbcc\"\n assert candidate(order = \"bdfhjlnprtvxz\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcegikmoqsuwydfhjlnprtvxz\"\n assert candidate(order = \"xyz\",s = \"abcdef\") == \"abcdef\"\n assert candidate(order = \"qrstuvw\",s = \"vwutsrqponmlkjihgfedcba\") == \"qponmlkjihgfedcbarstuvw\"\n assert candidate(order = \"qrstuvw\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxqponmlkjihgfedcbarstuvw\"\n assert candidate(order = \"vwxyz\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(order = \"abc\",s = \"cccbbaaa\") == \"aaabbccc\"\n assert candidate(order = \"mnop\",s = \"wertyuiopasdfghjklzxcvbnm\") == \"wertyuiasdfghjklzxcvbmnop\"\n assert candidate(order = \"mnopqr\",s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzmnopqr\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzmnopqr\"\n assert candidate(order = \"abcdef\",s = \"fedcbafedcbafedcbafedcba\") == \"aaaabbbbccccddddeeeeffff\"\n assert candidate(order = \"xyzabc\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"xwvutsrqponmlkjihgfedyzabc\"\n assert candidate(order = \"bdfhjlnprtvxz\",s = \"aegikmoqsuwy\") == \"aegikmoqsuwy\"\n assert candidate(order = \"aeiou\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"thqckbrwnfxjmpsvrthlazydgeeeioooouu\"\n assert candidate(order = \"mnopqr\",s = \"rmqponlksjihgfedcba\") == \"mlksjihgfedcbanopqr\"\n assert candidate(order = \"qwer\",s = \"qwertyuiopasdfghjklzxcvbnm\") == \"qtyuiopasdfghjklzxcvbnmwer\"\n assert candidate(order = \"pqrs\",s = \"pqrspqrspqrspqrspqrs\") == \"pppppqqqqqrrrrrsssss\"\n assert candidate(order = \"xyz\",s = \"abcxyzdefxyz\") == \"abcxdefxyyzz\"\n assert candidate(order = \"abcdefghijklm\",s = \"nopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"nopqrstuvwxyzzyxwvutsrqponabcdefghijklm\"\n assert candidate(order = \"xyz\",s = \"aabbccxxzzyy\") == \"aabbccxxyyzz\"\n assert candidate(order = \"jihgfedcba\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"jklmnopqrstuvwxyzihgfedcba\"\n assert candidate(order = \"lmnop\",s = \"lkjhgfedcba\") == \"lkjhgfedcba\"\n assert candidate(order = \"qwertyuiopasdfghjklzxcvbnm\",s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"qqwweerrttyyuuiiooppaassddffgghhjjkkllzzxxccvvbbnnmm\"\n assert candidate(order = \"zxcvbnmlkjhgfdsapoiuytrewq\",s = \"qwertyuiopasdfghjklzxcvbnm\") == \"zxcvbnmlkjhgfdsapoiuytrewq\"\n assert candidate(order = \"a\",s = \"aaaaaaaa\") == \"aaaaaaaa\"\n assert candidate(order = \"qrstuv\",s = \"qoprtusvklmijnhgfeabcdxyz\") == \"qopklmijnhgfeabcdxyzrstuv\"\n assert candidate(order = \"acegikmoqsuwy\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zxvtrpnljhfdbacegikmoqsuwy\"\n assert candidate(order = \"abcdefg\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihabcdefg\"\n assert candidate(order = \"abcd\",s = \"ddcbaaabbccdddddd\") == \"aaabbbcccdddddddd\"\n assert candidate(order = \"mno\",s = \"lkjhgfdcbazyxwvutsrqponmlkjihgfedcba\") == \"lkjhgfdcbazyxwvutsrqpmlkjihgfedcbano\"\n assert candidate(order = \"pqrstuvwxyz\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(order = \"zyxwvutsrqponmlkjihgfedcba\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"zyxwvuuttsrrqpoooonmlkjihhgfeeedcba\"\n assert candidate(order = \"mnop\",s = \"pnmlkjoiehgfcdcba\") == \"mlkjiehgfcdcbanop\"\n assert candidate(order = \"ace\",s = \"aaabbbcccddd\") == \"aaabbbdddccc\"\n assert candidate(order = \"abcd\",s = \"dcbaedcba\") == \"aeabbccdd\"\n assert candidate(order = \"abcxyz\",s = \"xyzabczyxcba\") == \"aabbccxxyyzz\"\n assert candidate(order = \"mnopqr\",s = \"mnopqrabcdefghijklmnop\") == \"mabcdefghijklmnnooppqr\"\n assert candidate(order = \"abcdefghij\",s = \"zzzzzyyyxxxwwwwvvvuuuuttttssssrrrrqqqqppppooolllkkkkjjjjiijjhhhgggfffeeedddccccbbbaaaa\") == \"zzzzzyyyxxxwwwwvvvuuuuttttssssrrrrqqqqppppooolllkkkkaaaabbbccccdddeeefffggghhhiijjjjjj\"\n assert candidate(order = \"zyxwvutsrqponmlkjihgfedcba\",s = \"fedcba\") == \"fedcba\"\n assert candidate(order = \"qaz\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"bcdefghijklmnopqrstuvwxyaz\"\n assert candidate(order = \"aeiou\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdfghjklmnpqrstvwxyzeiou\"\n assert candidate(order = \"mnopqr\",s = \"rqponmlkjihgfedcba\") == \"mlkjihgfedcbanopqr\"\n assert candidate(order = \"xyzabc\",s = \"fedcba\") == \"fedabc\"\n assert candidate(order = \"abc\",s = \"ccccbaaabbbccc\") == \"aaabbbbccccccc\"\n assert candidate(order = \"abcdef\",s = \"fedcbafghijklmnopqrstuvwxyz\") == \"aghijklmnopqrstuvwxyzbcdeff\"\n assert candidate(order = \"a\",s = \"a\") == \"a\"\n assert candidate(order = \"bzdx\",s = \"abcdexyz\") == \"abceyzdx\"\n assert candidate(order = \"mnbvcxzlkjhgfdsapoiuytrewq\",s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"mmnnbbvvccxxzzllkkjjhhggffddssaappooiiuuyyttrreewwqq\"\n assert candidate(order = \"uvwxy\",s = \"uvwxyuvwxyuvwxyuvwxyuvwxyuvwxy\") == \"uuuuuuvvvvvvwwwwwwxxxxxxyyyyyy\"\n assert candidate(order = \"abcdefghij\",s = \"jihgfedcba\") == \"abcdefghij\"\n assert candidate(order = \"t\",s = \"tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\") == \"tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\"\n assert candidate(order = \"mnop\",s = \"mnopmnopmnopmnopmnopmnopmnop\") == \"mmmmmmmnnnnnnnoooooooppppppp\"\n assert candidate(order = \"abcdefgh\",s = \"hgfedcba\") == \"abcdefgh\"\n assert candidate(order = \"a\",s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(order = \"tuvwxyz\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"tsrqponmlkjihgfedcbauvwxyz\"\n assert candidate(order = \"abc\",s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(order = \"bdfhjlnprtvxz\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"ywusqomkigecbadfhjlnprtvxz\"\n assert candidate(order = \"fedcba\",s = \"abcdef\") == \"fedcba\"\n assert candidate(order = \"gfedcba\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(order = \"mnop\",s = \"abmncdopefqrsgthijkl\") == \"abmcdefqrsgthijklnop\"\n assert candidate(order = \"nvmb\",s = \"nvbnvmbvmbnnbmvmbnb\") == \"nnnnnvvvvmmmmbbbbbb\"\n assert candidate(order = \"mnopqr\",s = \"mnopqrstuvwxynmlkjihgfedcba\") == \"mstuvwxymlkjihgfedcbannopqr\"\n assert candidate(order = \"abcxyz\",s = \"zyxcba\") == \"abcxyz\"\n assert candidate(order = \"qrst\",s = \"trqs\") == \"qrst\"\n assert candidate(order = \"xyzuvw\",s = \"zzzzzyyyxxxwwwwvvvuuuuttttssssrrrrqqqqppppooolllkkkkjjjjiijjhhhgggfffeeedddccccbbbaaaa\") == \"xxxttttssssrrrrqqqqppppooolllkkkkjjjjiijjhhhgggfffeeedddccccbbbaaaayyyzzzzzuuuuvvvwwww\"\n assert candidate(order = \"z\",s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(order = \"qz\",s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(order = \"thq\",s = \"thequickbrownfoxjumpsoverthelazydog\") == \"teuickbrownfoxjumpsovertelazydoghhq\"\n assert candidate(order = \"zyxwvutsrqponmlkjihgfedcba\",s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n", "comparison": "exact"}, "public_tests": ["\"cba\"\n\"abcd\"", "\"bcafg\"\n\"abcd\""], "hints": [], "metadata": {"canonical_parameter_names": ["order", "s"], "leetcode_dataset_entry_point": "Solution().customSortString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:46+00:00", "tests_total": 117, "tests_dropped": 5, "flags": [], "topic_tags": ["hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def customSortString(self, order: str, s: str) -> str:", "container": "Solution", "callable": "customSortString", "parameters": [{"name": "order", "type": "str"}, {"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 792, "task_id": "number-of-matching-subsequences", "difficulty": "Medium", "problem_description": "Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s.\n\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\n- For example, \"ace\" is a subsequence of \"abcde\".\n\nExample 1:\n\nInput: s = \"abcde\", words = [\"a\",\"bb\",\"acd\",\"ace\"]\nOutput: 3\nExplanation: There are three strings in words that are a subsequence of s: \"a\", \"acd\", \"ace\".\n\nExample 2:\n\nInput: s = \"dsahjpjauf\", words = [\"ahjpjau\",\"ja\",\"ahbwzgqnuk\",\"tnmlanowax\"]\nOutput: 2\n\nConstraints:\n\n- 1 <= s.length <= 5 * 10^4\n- 1 <= words.length <= 5000\n- 1 <= words[i].length <= 50\n- s and words[i] consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"dsahjpjauf\",words = ['ahjpjau', 'ja', 'ahbwzgqnuk', 'tnmlanowax']) == 2\n assert candidate(s = \"abcde\",words = ['a', 'bb', 'acd', 'ace']) == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",words = ['qz', 'qp', 'qw', 'qr', 'qe', 'qt', 'qu', 'qi', 'qo', 'qp', 'qa', 'qs', 'qd', 'qf', 'qg', 'qh', 'qj', 'qk', 'ql', 'qm', 'zn', 'zm', 'zk', 'zj', 'zh', 'zg', 'zf', 'qe', 'qd', 'qc', 'qb', 'qa', 'zv', 'zu', 'zt', 'zs', 'zr', 'zp', 'zo', 'zn', 'zm', 'zk', 'zj', 'zh', 'zg', 'zf', 'ze', 'zd', 'zc', 'zb', 'za']) == 32\n assert candidate(s = \"mississippi\",words = ['miss', 'issi', 'ssip', 'ppis', 'isip', 'ippi', 'sipi', 'sspi', 'issp']) == 8\n assert candidate(s = \"longstringwithvariouscharacters\",words = ['long', 'string', 'with', 'various', 'characters', 'longstring', 'withvarious']) == 7\n assert candidate(s = \"aaaaabbbbbcccc\",words = ['aaabbb', 'bbcc', 'abac', 'aabb', 'accc', 'bbbc', 'cccc', 'bbbb', 'aabbcc']) == 8\n assert candidate(s = \"abacabadabacaba\",words = ['aba', 'abc', 'bac', 'bca', 'cab', 'acb', 'a', 'b', 'c', 'd', 'ab', 'ba', 'bc', 'cb', 'ac', 'ca']) == 16\n assert candidate(s = \"aaaaaaaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 10\n assert candidate(s = \"mississippi\",words = ['is', 'issi', 'miss', 'issip', 'ppi', 'ipi', 'mississippi']) == 7\n assert candidate(s = \"thefastbrownfoxjumpsoverthelazydog\",words = ['the', 'fast', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dog', 'thebrownfox', 'jumpsoverthelazy']) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'xyz', 'mnopqr', 'uvw', 'zabcdefghijklmnopqrst']) == 4\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",words = ['qwerty', 'asdfgh', 'zxcvbn', 'pol', 'lkjhg', 'mnbvcxz', 'yuiop', 'poiuyt', 'hgfdsa', 'xcvbnm', 'qwertyuiop', 'asdfghjklzxcvbnm']) == 7\n assert candidate(s = \"mississippi\",words = ['miss', 'issi', 'ssip', 'ssissipp', 'is', 'mp', 'ms', 's', 'i', 'p', 'pp', 'ip', 'mississippi', 'mississ', 'issipp']) == 15\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'aaa', 'bbb', 'ccc']) == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz']) == 21\n assert candidate(s = \"abcabcabcabc\",words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc', 'ab', 'bc', 'ca', 'a', 'b', 'c']) == 10\n assert candidate(s = \"ababababab\",words = ['ab', 'aba', 'aab', 'baba', 'babababababab']) == 4\n assert candidate(s = \"mississippi\",words = ['issi', 'miss', 'mip', 'issip', 'issipp', 'mpis', 'mississippi']) == 6\n assert candidate(s = \"thisisaverylongandrandomstring\",words = ['this', 'is', 'very', 'long', 'and', 'random', 'string', 'av', 'er', 'ry', 'on', 'nd', 'ra', 'nd', 'om', 'mi', 'st', 'in', 'ng']) == 19\n assert candidate(s = \"repeatedcharacters\",words = ['repe', 'peate', 'atedchar', 'char', 'acter', 'ters', 'repeatedcharacters']) == 7\n assert candidate(s = \"abcabcabcabc\",words = ['abc', 'cab', 'bac', 'aaa', 'bbb', 'ccc', 'abcabc', 'abcbca', 'bcbcab', 'cabcab', 'abcabcabc', 'bcabcabc', 'cabcabca', 'a', 'b', 'c']) == 16\n assert candidate(s = \"babcabcabcabcabc\",words = ['ba', 'ca', 'ab', 'bc', 'ac', 'abc', 'bac', 'bca', 'cab', 'cba', 'acb', 'bba', 'aaa', 'ccc']) == 14\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'xyz', 'def', 'uvw', 'mnopqr', 'st', 'ghijkl']) == 7\n assert candidate(s = \"hellohellohellohello\",words = ['he', 'lo', 'ell', 'hell', 'hello', 'heell', 'hellohe', 'helloell', 'helloello', 'hellohello', 'hellohelloh', 'hellohellohe', 'hellohelloell', 'hellohelloello', 'hellohellohello']) == 15\n assert candidate(s = \"abracadabra\",words = ['abra', 'rac', 'cad', 'bra', 'dabra', 'abra', 'acad', 'bracad', 'bracadabra', 'bracadabr', 'abracadabr', 'bracadabraa', 'bracadabrac']) == 11\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 9\n assert candidate(s = \"abacabadabacaba\",words = ['aba', 'abc', 'bac', 'bca', 'cab', 'cba']) == 6\n assert candidate(s = \"zzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == 10\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",words = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']) == 26\n assert candidate(s = \"abracadabra\",words = ['abr', 'rac', 'aca', 'dab', 'bra', 'cad', 'bra', 'abra', 'brac', 'acad', 'radab', 'cabra', 'rabrac', 'acadabra', 'adabra', 'bracadabra', 'acabracadabra']) == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['a', 'z', 'abc', 'xyz', 'abcdefghijklmnopqrstuvwxyzz']) == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'xyz', 'mnop', 'qrstuv', '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 = \"ababababababababababababababababababababababab\",words = ['aa', 'ab', 'ba', 'bb', 'aab', 'aba', 'abb', 'bba', 'bab', 'bbb', 'aaaa', 'abab', 'baba', 'abba', 'baab', 'abaa', 'bbaa', 'aabb', 'abbb', 'baaa', 'baab', 'baaa', 'bbab', 'bbba', 'bbbb', 'aaaaaaaa', 'abababab', 'babababa', 'ababababa', 'babababab']) == 30\n assert candidate(s = \"mississippi\",words = ['miss', 'issi', 'ippi', 'ssss', 'ppii', 'mississi', 'issippi', 'mississippi', 'mpis', 'ppis', 'ipis', 'mipp', 'ssip', 'piss', 'missippi', 'missisipp', 'ississippi', 'ssissippi', 'ippii', 'sippi', 'pissi', 'issis', 'missis', 'ssssip', 'pisssippi', 'issippis', 'pississi', 'sissippii', 'ppisssippi', 'mississippipp', 'ississipp', 'ppississippi', 'sippisippi', 'issississi', 'ppississippi', 'mississippippi', 'issississipp', 'ppissississi', 'sissississippi', 'issississippippi']) == 18\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz']) == 5\n assert candidate(s = \"leetcodeisacommunityforcoders\",words = ['leetcode', 'is', 'acommunity', 'of', 'coders', 'comm', 's', 't']) == 8\n assert candidate(s = \"abababababababababababababababababababababababababab\",words = ['aa', 'bb', 'ab', 'ba', 'aab', 'abb', 'bab', 'bba']) == 8\n assert candidate(s = \"bbaaaaabbbb\",words = ['bb', 'aaaa', 'bbb', 'baab', 'abba', 'aaaaa', 'bbbbb', 'bababa', 'bbbbba', 'ababab', 'bbabba']) == 6\n assert candidate(s = \"aaaaaaaabbbbbbbbccccccccdddddddd\",words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'abdc', 'dcba', 'abcd', 'dcba', 'aabb', 'bbcc', 'ccdd', 'dddd', 'ac', 'bd', 'ca', 'db']) == 11\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",words = ['zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz']) == 5\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",words = ['qaz', 'wsx', 'edc', 'rfv', 'tgb', 'yhn', 'ujm', 'ikl', 'opy', 'asdf', 'ghjkl', 'zxcvbnm', 'ertyui', 'poiuyt', 'lkjhgfdsa', 'nmolkjiuhgfedcba']) == 12\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",words = ['xyz', 'xy', 'yz', 'xz', 'xx', 'yy', 'zz', 'xzy', 'yzx', 'zxy', 'xyzxyz', 'xyxyxy', 'yzyzyz', 'xzxzxz', 'xxx', 'yyy', 'zzz', 'xzyxzyxzy', 'yzxyzxyz', 'zxzyzxzyz', 'xyzxyzxyzxyz']) == 21\n assert candidate(s = \"aaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 6\n assert candidate(s = \"lkjhgfdsapoiuytrewq\",words = ['poi', 'uyt', 'rew', 'qwe', 'lkj', 'hgf', 'dsa', 'lkjh', 'gfds', 'poiu', 'uytr', 'trew', 'qwe', 'lkjhg', 'gfdsa', 'poiu', 'uytrw', 'trewq']) == 16\n assert candidate(s = \"abacabadabacaba\",words = ['aba', 'abc', 'aca', 'ada', 'baa', 'bac', 'bda', 'cab', 'cad', 'cda', 'daa', 'dac', 'dba']) == 13\n assert candidate(s = \"aaaaaaaaaaaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'mnop', 'xyz', 'qrstuv', 'wxyz', 'defghijkl', 'nopqrstuv']) == 7\n assert candidate(s = \"aaaaaaaaaaaaaaa\",words = ['aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 9\n assert candidate(s = \"abababababababababababab\",words = ['aba', 'bab', 'aaa', 'bbb', 'aab', 'aba', 'aabbaa', 'bbbabb', 'ab', 'ba', 'aa', 'bb', 'abab', 'baba', 'ababa', 'babab', 'ababab', 'bababa']) == 18\n assert candidate(s = \"bcbabbbbaabaaabaababbbbbbaaabbbabbababbababba\",words = ['bb', 'ba', 'bbba', 'bab', 'bbab', 'aa', 'aaa', 'aaaa', 'aaaaa', 'a', 'b', 'ab', 'ba', 'aba', 'bab', 'bba', 'abb', 'aab', 'bbb', 'bbbba']) == 20\n assert candidate(s = \"thisisaverylongstringwithseveralrepetitions\",words = ['this', 'is', 'a', 'very', 'long', 'string', 'with', 'several', 'repetitions', 'verylong', 'stringwith', 'longstring', 'thisisavery', 'averylongstring', 'thisisaverylongstringwithseveralrepetitions']) == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'xyz', 'abcd', 'uvw', 'wxyz', 'mnopqr', 'def', 'ghi', 'jkl', 'stu']) == 10\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",words = ['zyx', 'wvut', 'srqp', 'onml', 'kjih', 'gfed', 'cba', 'abc']) == 7\n", "comparison": "exact"}, "public_tests": ["\"abcde\"\n[\"a\",\"bb\",\"acd\",\"ace\"]", "\"dsahjpjauf\"\n[\"ahjpjau\",\"ja\",\"ahbwzgqnuk\",\"tnmlanowax\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "words"], "leetcode_dataset_entry_point": "Solution().numMatchingSubseq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:48+00:00", "tests_total": 56, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "string", "binary-search", "dynamic-programming", "trie", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numMatchingSubseq(self, s: str, words: list[str]) -> int:", "container": "Solution", "callable": "numMatchingSubseq", "parameters": [{"name": "s", "type": "str"}, {"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 793, "task_id": "preimage-size-of-factorial-zeroes-function", "difficulty": "Hard", "problem_description": "Let f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 * 3 * ... * x and by convention, 0! = 1.\n\n- For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has two zeroes at the end.\n\nGiven an integer k, return the number of non-negative integers x have the property that f(x) = k.\n\nExample 1:\n\nInput: k = 0\nOutput: 5\nExplanation: 0!, 1!, 2!, 3!, and 4! end with k = 0 zeroes.\n\nExample 2:\n\nInput: k = 5\nOutput: 0\nExplanation: There is no x such that x! ends in k = 5 zeroes.\n\nExample 3:\n\nInput: k = 3\nOutput: 5\n\nConstraints:\n\n- 0 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 100) == 5\n assert candidate(k = 1) == 5\n assert candidate(k = 10000) == 5\n assert candidate(k = 1000000) == 5\n assert candidate(k = 3) == 5\n assert candidate(k = 0) == 5\n assert candidate(k = 1000) == 5\n assert candidate(k = 100000) == 5\n assert candidate(k = 5) == 0\n assert candidate(k = 25) == 5\n assert candidate(k = 10) == 5\n assert candidate(k = 48828125) == 5\n assert candidate(k = 1192092) == 5\n assert candidate(k = 9999) == 5\n assert candidate(k = 50) == 5\n assert candidate(k = 100000000) == 5\n assert candidate(k = 2384185) == 5\n assert candidate(k = 6) == 5\n assert candidate(k = 1000045) == 5\n assert candidate(k = 19073486) == 5\n assert candidate(k = 13) == 5\n assert candidate(k = 1000025) == 5\n assert candidate(k = 625) == 5\n assert candidate(k = 3125) == 5\n assert candidate(k = 1000035) == 0\n assert candidate(k = 5000) == 5\n assert candidate(k = 78125) == 5\n assert candidate(k = 1249) == 5\n assert candidate(k = 10000000) == 5\n assert candidate(k = 200000) == 5\n assert candidate(k = 1250) == 5\n assert candidate(k = 4768371) == 5\n assert candidate(k = 50000001) == 5\n assert candidate(k = 80000) == 5\n assert candidate(k = 750000) == 5\n assert candidate(k = 4096) == 5\n assert candidate(k = 627) == 5\n assert candidate(k = 1000050) == 5\n assert candidate(k = 536870912) == 5\n assert candidate(k = 2500000) == 5\n assert candidate(k = 2048) == 5\n assert candidate(k = 1000015) == 5\n assert candidate(k = 152587890) == 5\n assert candidate(k = 123456789) == 5\n assert candidate(k = 1000001) == 5\n assert candidate(k = 5000000) == 5\n assert candidate(k = 31250) == 5\n assert candidate(k = 1000000000) == 5\n assert candidate(k = 20000) == 5\n assert candidate(k = 1000005) == 5\n assert candidate(k = 2) == 5\n assert candidate(k = 1000020) == 5\n assert candidate(k = 99999) == 5\n assert candidate(k = 610351562) == 5\n assert candidate(k = 2499999) == 5\n assert candidate(k = 1000010) == 0\n assert candidate(k = 9) == 5\n assert candidate(k = 123456) == 5\n assert candidate(k = 987654321) == 5\n assert candidate(k = 258) == 5\n assert candidate(k = 500000) == 5\n assert candidate(k = 9765625) == 5\n assert candidate(k = 32) == 5\n assert candidate(k = 268435456) == 5\n assert candidate(k = 101) == 5\n assert candidate(k = 76293945) == 5\n assert candidate(k = 99999999) == 5\n assert candidate(k = 15625) == 5\n assert candidate(k = 999999) == 5\n assert candidate(k = 64) == 5\n assert candidate(k = 390625) == 5\n assert candidate(k = 38146972) == 5\n assert candidate(k = 1953125) == 5\n assert candidate(k = 31) == 5\n assert candidate(k = 50000000) == 5\n assert candidate(k = 250) == 5\n assert candidate(k = 125) == 5\n assert candidate(k = 16) == 5\n assert candidate(k = 999999999) == 5\n assert candidate(k = 256) == 5\n assert candidate(k = 1001) == 5\n assert candidate(k = 249) == 5\n assert candidate(k = 9536743) == 5\n assert candidate(k = 500000000) == 5\n assert candidate(k = 1000030) == 5\n assert candidate(k = 20) == 5\n assert candidate(k = 1024) == 5\n assert candidate(k = 39062) == 5\n assert candidate(k = 244140625) == 5\n assert candidate(k = 500) == 5\n assert candidate(k = 1000040) == 5\n assert candidate(k = 21) == 5\n assert candidate(k = 800000000) == 5\n assert candidate(k = 12345) == 5\n assert candidate(k = 4) == 5\n assert candidate(k = 129) == 0\n assert candidate(k = 305175781) == 5\n assert candidate(k = 8) == 5\n assert candidate(k = 512) == 5\n assert candidate(k = 11) == 0\n assert candidate(k = 128) == 5\n assert candidate(k = 50000) == 5\n", "comparison": "exact"}, "public_tests": ["0", "5", "3"], "hints": [], "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().preimageSizeFZF", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:50+00:00", "tests_total": 104, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def preimageSizeFZF(self, k: int) -> int:", "container": "Solution", "callable": "preimageSizeFZF", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 794, "task_id": "valid-tic-tac-toe-state", "difficulty": "Medium", "problem_description": "Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.\n\nThe board is a 3 x 3 array that consists of characters ' ', 'X', and 'O'. The ' ' character represents an empty square.\n\nHere are the rules of Tic-Tac-Toe:\n\n- Players take turns placing characters into empty squares ' '.\n- The first player always places 'X' characters, while the second player always places 'O' characters.\n- 'X' and 'O' characters are always placed into empty squares, never filled ones.\n- The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.\n- The game also ends if all squares are non-empty.\n- No more moves can be played if the game is over.\n\nExample 1:\n\nInput: board = [\"O \",\" \",\" \"]\nOutput: false\nExplanation: The first player always plays \"X\".\n\nExample 2:\n\nInput: board = [\"XOX\",\" X \",\" \"]\nOutput: false\nExplanation: Players take turns making moves.\n\nExample 3:\n\nInput: board = [\"XOX\",\"O O\",\"XOX\"]\nOutput: true\n\nConstraints:\n\n- board.length == 3\n- board[i].length == 3\n- board[i][j] is either 'X', 'O', or ' '.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = ['XOX', 'O O', 'XOX']) == True\n assert candidate(board = ['X ', 'X ', 'X ']) == False\n assert candidate(board = ['XOX', 'O O', 'XOX']) == True\n assert candidate(board = ['XXX', ' ', 'O O']) == True\n assert candidate(board = ['XOX', 'XOX', 'XOX']) == False\n assert candidate(board = ['OXX', 'XOX', 'OXO']) == False\n assert candidate(board = ['OOO', ' ', ' ']) == False\n assert candidate(board = ['XOX', 'OXO', ' ']) == True\n assert candidate(board = ['XOX', 'OXO', 'XOX']) == True\n assert candidate(board = ['XXO', 'OXO', 'XOX']) == True\n assert candidate(board = ['XXO', 'XOX', 'OXO']) == False\n assert candidate(board = ['XXX', ' ', ' ']) == False\n assert candidate(board = ['X ', ' X ', ' X']) == False\n assert candidate(board = ['XXO', 'OOX', 'OXO']) == False\n assert candidate(board = ['X ', 'XO ', ' X ']) == False\n assert candidate(board = ['XXX', ' ', 'OOO']) == False\n assert candidate(board = ['XOX', 'O O', 'XOX']) == True\n assert candidate(board = ['XOX', 'OOO', 'XOX']) == False\n assert candidate(board = ['XO ', 'OX ', 'OXO']) == False\n assert candidate(board = ['X ', ' O ', 'XOX']) == True\n assert candidate(board = ['XX ', 'OO ', ' ']) == True\n assert candidate(board = ['XOO', 'XOX', 'OOX']) == False\n assert candidate(board = ['XX ', 'OOX', 'XOX']) == False\n assert candidate(board = ['XXO', 'XOX', 'OOX']) == False\n assert candidate(board = ['OOO', 'XOX', 'XXO']) == False\n assert candidate(board = ['XOX', 'O O', ' ']) == False\n assert candidate(board = ['XOX', ' X ', ' ']) == False\n assert candidate(board = ['XOX', 'OOX', 'XOX']) == False\n assert candidate(board = ['OOO', 'OOO', 'OOO']) == False\n assert candidate(board = ['OXO', 'XOX', 'OXO']) == False\n assert candidate(board = ['XOO', 'XOX', 'OXO']) == False\n assert candidate(board = [' ', 'XOX', ' ']) == True\n assert candidate(board = ['X ', ' O ', ' O']) == False\n assert candidate(board = ['XOO', 'OXO', 'XOX']) == False\n assert candidate(board = ['XOX', 'XOX', 'OOO']) == False\n assert candidate(board = ['XXO', 'OXO', 'OXO']) == False\n assert candidate(board = ['XOO', 'XOX', 'XOX']) == False\n assert candidate(board = ['XXX', 'OOO', ' ']) == False\n assert candidate(board = ['XXX', 'OOO', ' ']) == False\n assert candidate(board = ['XOX', 'OXO', 'XO ']) == False\n assert candidate(board = ['OOO', 'X X', 'XOX']) == True\n assert candidate(board = ['XOX', 'OXO', 'XOX']) == True\n assert candidate(board = [' ', 'XXX', ' ']) == False\n assert candidate(board = ['O ', ' ', ' ']) == False\n assert candidate(board = ['XXO', 'OXO', 'XOX']) == True\n assert candidate(board = ['OOO', ' ', ' ']) == False\n assert candidate(board = ['X ', ' X ', ' X']) == False\n assert candidate(board = ['XOO', 'XOO', 'XOO']) == False\n assert candidate(board = ['X ', ' O ', ' X']) == True\n assert candidate(board = ['O ', ' ', ' ']) == False\n assert candidate(board = ['XXX', ' ', ' ']) == False\n assert candidate(board = ['OXX', 'OXO', 'XOX']) == True\n assert candidate(board = ['XXO', 'OXO', 'OXO']) == False\n assert candidate(board = ['XXX', 'OOO', 'XXX']) == False\n assert candidate(board = [' ', ' ', ' ']) == True\n assert candidate(board = ['XOX', ' X ', ' ']) == False\n assert candidate(board = ['XXO', 'OOX', 'XOX']) == True\n assert candidate(board = ['XXO', 'OXO', 'XOX']) == True\n assert candidate(board = ['X ', ' O ', ' O']) == False\n assert candidate(board = ['X ', ' O ', ' X ']) == True\n assert candidate(board = ['X ', 'OOO', 'X ']) == False\n assert candidate(board = ['XOX', 'OXX', 'OXO']) == True\n assert candidate(board = ['X ', ' O ', 'X ']) == True\n assert candidate(board = ['XOO', 'XOX', 'OXO']) == False\n assert candidate(board = ['X O', 'X O', 'X O']) == False\n assert candidate(board = ['XXX', ' ', ' ']) == False\n assert candidate(board = ['XXO', 'XOX', 'OOO']) == False\n assert candidate(board = ['XXO', 'XOX', 'OXO']) == False\n assert candidate(board = ['XOX', 'OXO', 'OOX']) == False\n assert candidate(board = ['O ', 'O ', 'O ']) == False\n assert candidate(board = ['XXO', 'OXO', 'OOX']) == False\n assert candidate(board = [' ', ' ', ' ']) == True\n assert candidate(board = ['XX ', 'OOX', 'X ']) == False\n assert candidate(board = [' ', ' ', 'XXX']) == False\n assert candidate(board = ['OOO', ' ', ' ']) == False\n assert candidate(board = ['X ', ' O ', ' X']) == True\n assert candidate(board = [' ', ' ', 'XXX']) == False\n assert candidate(board = ['O ', ' O ', ' O']) == False\n assert candidate(board = ['XO ', 'OX ', ' ']) == True\n assert candidate(board = ['XOX', 'OXO', 'XOX']) == True\n assert candidate(board = ['XO ', 'OXO', 'OXO']) == False\n assert candidate(board = ['X ', ' ', ' O']) == True\n assert candidate(board = ['O ', ' ', ' ']) == False\n assert candidate(board = ['XOX', ' X ', ' ']) == False\n assert candidate(board = ['XXX', 'XXX', 'XXX']) == False\n assert candidate(board = ['X ', 'X ', 'X ']) == False\n assert candidate(board = ['OOO', ' ', 'XXX']) == False\n assert candidate(board = ['O ', ' O ', ' O']) == False\n assert candidate(board = ['XOX', 'XOX', 'XOX']) == False\n assert candidate(board = [' ', ' ', ' ']) == True\n", "comparison": "exact"}, "public_tests": ["[\"O \",\" \",\" \"]", "[\"XOX\",\" X \",\" \"]", "[\"XOX\",\"O O\",\"XOX\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["board"], "leetcode_dataset_entry_point": "Solution().validTicTacToe", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:52+00:00", "tests_total": 91, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def validTicTacToe(self, board: list[str]) -> bool:", "container": "Solution", "callable": "validTicTacToe", "parameters": [{"name": "board", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 795, "task_id": "number-of-subarrays-with-bounded-maximum", "difficulty": "Medium", "problem_description": "Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray is in the range [left, right].\n\nThe test cases are generated so that the answer will fit in a 32-bit integer.\n\nExample 1:\n\nInput: nums = [2,1,4,3], left = 2, right = 3\nOutput: 3\nExplanation: There are three subarrays that meet the requirements: [2], [2, 1], [3].\n\nExample 2:\n\nInput: nums = [2,9,2,5,6], left = 2, right = 8\nOutput: 7\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^9\n- 0 <= left <= right <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 2, 1],left = 1,right = 5) == 6\n assert candidate(nums = [73, 55, 36, 5, 55, 14, 9, 7, 72, 52],left = 32,right = 69) == 22\n assert candidate(nums = [2, 1, 4, 3],left = 2,right = 3) == 3\n assert candidate(nums = [8, 2, 4, 4, 4, 6, 7, 7, 7, 8],left = 4,right = 6) == 14\n assert candidate(nums = [10, 20, 30, 40, 50],left = 15,right = 45) == 9\n assert candidate(nums = [5, 2, 4, 5, 5, 5, 6, 5, 5, 5],left = 4,right = 5) == 26\n assert candidate(nums = [2, 9, 2, 5, 6],left = 2,right = 8) == 7\n assert candidate(nums = [5, 5, 5, 5, 5],left = 5,right = 5) == 15\n assert candidate(nums = [10, 20, 30],left = 25,right = 25) == 0\n assert candidate(nums = [1, 2, 3],left = 1,right = 3) == 6\n assert candidate(nums = [10, 20, 30, 40, 50],left = 20,right = 40) == 9\n assert candidate(nums = [1, 2, 3, 4, 5],left = 2,right = 4) == 9\n assert candidate(nums = [5, 5, 5, 5, 5],left = 5,right = 5) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50],left = 30,right = 80) == 43\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, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5],left = 5,right = 10) == 2028\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],left = 10,right = 20) == 0\n assert candidate(nums = [10, 5, 3, 15, 7, 9, 20, 1],left = 5,right = 10) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],left = 1,right = 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],left = 0,right = 2) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],left = 5,right = 15) == 33\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],left = 4,right = 12) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],left = 4,right = 10) == 12\n assert candidate(nums = [8, 1, 6, 3, 5, 7, 2, 9, 4, 10],left = 3,right = 7) == 20\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],left = 3,right = 6) == 49\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],left = 3,right = 7) == 25\n assert candidate(nums = [2, 3, 2, 1, 2, 3, 4, 3, 2, 1],left = 2,right = 3) == 25\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],left = 50,right = 950) == 45\n assert candidate(nums = [3, 2, 1, 4, 3, 5, 4, 3, 2, 1],left = 2,right = 4) == 23\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],left = 4,right = 8) == 35\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],left = 1,right = 2) == 55\n assert candidate(nums = [100, 200, 300, 400, 500],left = 150,right = 350) == 5\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 1],left = 2,right = 2) == 53\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],left = 3,right = 8) == 21\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],left = 1,right = 5) == 120\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],left = 7,right = 7) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],left = 10,right = 100) == 55\n assert candidate(nums = [7, 4, 7, 2, 5, 3, 6],left = 4,right = 6) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],left = 6,right = 12) == 15\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],left = 5,right = 5) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],left = 6,right = 14) == 25\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4],left = 1,right = 3) == 27\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],left = 25,right = 75) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],left = 1,right = 1) == 55\n assert candidate(nums = [5, 4, 3, 2, 1],left = 2,right = 4) == 9\n assert candidate(nums = [3, 7, 2, 5, 4, 6, 1, 8, 9],left = 4,right = 7) == 25\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],left = 0,right = 0) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],left = 4,right = 8) == 30\n assert candidate(nums = [4, 2, 7, 3, 6, 5, 8, 1, 9, 0],left = 3,right = 7) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],left = 400,right = 800) == 30\n assert candidate(nums = [5, 10, 5, 10, 5, 10, 5, 10],left = 5,right = 10) == 36\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],left = 5,right = 10) == 12\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],left = 5,right = 15) == 66\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],left = 10,right = 15) == 27\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],left = 1,right = 3) == 55\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],left = 3,right = 8) == 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],left = 10,right = 20) == 165\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],left = 3,right = 6) == 18\n assert candidate(nums = [3, 2, 1, 2, 3, 2, 1, 2, 3],left = 2,right = 3) == 43\n assert candidate(nums = [7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],left = 5,right = 9) == 45\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],left = 4,right = 8) == 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],left = 5,right = 15) == 110\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],left = 5,right = 10) == 45\n assert candidate(nums = [1, 4, 2, 3, 5, 6, 7, 8, 9, 10],left = 3,right = 8) == 34\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],left = 1,right = 4) == 44\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],left = 5,right = 10) == 210\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],left = 3,right = 5) == 39\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],left = 2,right = 8) == 42\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],left = 8,right = 8) == 55\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7],left = 2,right = 6) == 20\n assert candidate(nums = [3, 4, 2, 2, 2, 2, 2, 4, 3, 1],left = 2,right = 3) == 18\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],left = 200,right = 800) == 35\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],left = 1,right = 1) == 120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],left = 15,right = 95) == 44\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],left = 5,right = 9) == 55\n assert candidate(nums = [100, 200, 300, 400, 500],left = 150,right = 450) == 9\n assert candidate(nums = [5, 4, 3, 2, 1],left = 1,right = 3) == 6\n assert candidate(nums = [5, 1, 4, 3, 2, 5, 6, 7, 8, 5],left = 3,right = 6) == 27\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],left = 250,right = 750) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],left = 3,right = 7) == 25\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],left = 2,right = 4) == 55\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],left = 10,right = 15) == 39\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],left = 2,right = 4) == 33\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],left = 4,right = 7) == 22\n assert candidate(nums = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],left = 5,right = 5) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],left = 3,right = 7) == 25\n assert candidate(nums = [3, 7, 2, 5, 9, 1, 6],left = 3,right = 7) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],left = 100,right = 1000) == 55\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],left = 5,right = 10) == 55\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],left = 5,right = 5) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],left = 4,right = 10) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],left = 2,right = 10) == 14\n assert candidate(nums = [10, 12, 8, 7, 5, 4, 3, 11, 6, 10],left = 5,right = 10) == 16\n assert candidate(nums = [7, 1, 8, 2, 3, 8, 4, 5, 6, 8, 7, 1, 2],left = 3,right = 7) == 13\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],left = 50,right = 150) == 50\n assert candidate(nums = [5, 8, 1, 4, 9, 7, 6, 3, 2, 10],left = 4,right = 7) == 10\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],left = 5,right = 10) == 45\n assert candidate(nums = [10, 20, 30, 40, 50],left = 25,right = 45) == 7\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],left = 6,right = 8) == 55\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],left = 2,right = 2) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],left = 0,right = 1) == 120\n", "comparison": "exact"}, "public_tests": ["[2,1,4,3]\n2\n3", "[2,9,2,5,6]\n2\n8"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "left", "right"], "leetcode_dataset_entry_point": "Solution().numSubarrayBoundedMax", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:55+00:00", "tests_total": 101, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers"]}, "language": "python", "interface": {"raw_signature": "def numSubarrayBoundedMax(self, nums: list[int], left: int, right: int) -> int:", "container": "Solution", "callable": "numSubarrayBoundedMax", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 796, "task_id": "rotate-string", "difficulty": "Easy", "problem_description": "Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s.\n\nA shift on s consists of moving the leftmost character of s to the rightmost position.\n\n- For example, if s = \"abcde\", then it will be \"bcdea\" after one shift.\n\nExample 1:\n\nInput: s = \"abcde\", goal = \"cdeab\"\nOutput: true\n\nExample 2:\n\nInput: s = \"abcde\", goal = \"abced\"\nOutput: false\n\nConstraints:\n\n- 1 <= s.length, goal.length <= 100\n- s and goal consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaa\",goal = \"aaa\") == True\n assert candidate(s = \"abcdefg\",goal = \"efgabcd\") == True\n assert candidate(s = \"abab\",goal = \"abba\") == False\n assert candidate(s = \"abcd\",goal = \"dcba\") == False\n assert candidate(s = \"abcd\",goal = \"dabc\") == True\n assert candidate(s = \"hello\",goal = \"lohel\") == True\n assert candidate(s = \"aa\",goal = \"aa\") == True\n assert candidate(s = \"abcdef\",goal = \"defabc\") == True\n assert candidate(s = \"a\",goal = \"b\") == False\n assert candidate(s = \"aaaa\",goal = \"aaaa\") == True\n assert candidate(s = \"abab\",goal = \"abab\") == True\n assert candidate(s = \"aaa\",goal = \"aab\") == False\n assert candidate(s = \"xyz\",goal = \"zyx\") == False\n assert candidate(s = \"abcabcabc\",goal = \"abcabcabc\") == True\n assert candidate(s = \"whassup\",goal = \"psus\") == False\n assert candidate(s = \"abcde\",goal = \"abced\") == False\n assert candidate(s = \"a\",goal = \"a\") == True\n assert candidate(s = \"abcd\",goal = \"bcda\") == True\n assert candidate(s = \"abcd\",goal = \"abcd\") == True\n assert candidate(s = \"hello\",goal = \"llohe\") == True\n assert candidate(s = \"waterbottle\",goal = \"erbottlewat\") == True\n assert candidate(s = \"ab\",goal = \"ba\") == True\n assert candidate(s = \"abcd\",goal = \"cdab\") == True\n assert candidate(s = \"abcde\",goal = \"cdeab\") == True\n assert candidate(s = \"abcdef\",goal = \"ghijkl\") == False\n assert candidate(s = \"aabbccdd\",goal = \"ccddaabb\") == True\n assert candidate(s = \"abcdefgabcdefg\",goal = \"efgabcdefgabcd\") == True\n assert candidate(s = \"onetwothree\",goal = \"threeonetwo\") == True\n assert candidate(s = \"rotationexample\",goal = \"examplerotation\") == True\n assert candidate(s = \"abcdefabcdef\",goal = \"fabcdefabcde\") == True\n assert candidate(s = \"testtesttest\",goal = \"sttesttestte\") == True\n assert candidate(s = \"xyzxyz\",goal = \"xyzxyz\") == True\n assert candidate(s = \"pattern\",goal = \"ternpat\") == True\n assert candidate(s = \"algorithm\",goal = \"rithmalgo\") == True\n assert candidate(s = \"aaaaaaa\",goal = \"aaaaaaa\") == True\n assert candidate(s = \"identicalstring\",goal = \"identicalstring\") == True\n assert candidate(s = \"longerstringhere\",goal = \"stringhereelong\") == False\n assert candidate(s = \"mnopqr\",goal = \"nopqrm\") == True\n assert candidate(s = \"aabbccddeeff\",goal = \"ccddeeffaabb\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",goal = \"zzzzyyxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == False\n assert candidate(s = \"uniqueword\",goal = \"wordunique\") == True\n assert candidate(s = \"abcdefghij\",goal = \"ghijklmnopqr\") == False\n assert candidate(s = \"banana\",goal = \"ananab\") == True\n assert candidate(s = \"uniquestring\",goal = \"nguniquestri\") == True\n assert candidate(s = \"longstringfortesting\",goal = \"testinglongstringfor\") == True\n assert candidate(s = \"interview\",goal = \"erviewint\") == True\n assert candidate(s = \"xyzabcxyz\",goal = \"abcxyzxyz\") == True\n assert candidate(s = \"onesymbola\",goal = \"symbolaone\") == True\n assert candidate(s = \"repeatedrepeated\",goal = \"atedrepeatedrepe\") == True\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",goal = \"thelazydogaquickbrownfoxjumpsover\") == True\n assert candidate(s = \"xyzxyzxyz\",goal = \"xyzxyzxyz\") == True\n assert candidate(s = \"unique\",goal = \"queuni\") == True\n assert candidate(s = \"banana\",goal = \"anabna\") == False\n assert candidate(s = \"abcdefghijk\",goal = \"ghijkabcdef\") == True\n assert candidate(s = \"programming\",goal = \"ammingprogr\") == True\n assert candidate(s = \"quickbrownfox\",goal = \"oxquickbrownf\") == True\n assert candidate(s = \"xyzxyzxyz\",goal = \"yzxyzxyzx\") == True\n assert candidate(s = \"almostmatchingbutnotquite\",goal = \"almostmatchingbutnotquit\") == False\n assert candidate(s = \"abcdabcdabcd\",goal = \"cdabcdabcda\") == False\n assert candidate(s = \"rotatestring\",goal = \"stringrotate\") == True\n assert candidate(s = \"thisisaverylongstringthatshouldworkwell\",goal = \"wellthisisaverylongstringthatshoul\") == False\n assert candidate(s = \"aaaabbbbccccddddeeeeffff\",goal = \"ffffaaaabbbbccccddddeeee\") == True\n assert candidate(s = \"mississippi\",goal = \"pimississi\") == False\n assert candidate(s = \"interview\",goal = \"erviewin\") == False\n assert candidate(s = \"aabbccdd\",goal = \"ccddaabbaa\") == False\n assert candidate(s = \"xyzabc\",goal = \"abcxyz\") == True\n assert candidate(s = \"singleletter\",goal = \"singleletter\") == True\n assert candidate(s = \"repeated\",goal = \"atedrepe\") == True\n assert candidate(s = \"abcdefghij\",goal = \"ghijklabce\") == False\n assert candidate(s = \"xyzxyz\",goal = \"zxyzxy\") == True\n assert candidate(s = \"algorithms\",goal = \"msalgorith\") == True\n assert candidate(s = \"shiftthisstring\",goal = \"stringshiftthis\") == True\n assert candidate(s = \"abcdabcdabcd\",goal = \"dabcdabcda\") == False\n assert candidate(s = \"abcde\",goal = \"deabc\") == True\n assert candidate(s = \"stackoverflow\",goal = \"flowoversta\") == False\n assert candidate(s = \"shiftandrotate\",goal = \"androtateshift\") == True\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",goal = \"nineonetwothreefourfivesixseveneigh\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",goal = \"zabcdefghijklmnopqrstuvwxy\") == True\n assert candidate(s = \"xyxyxyxyxyxy\",goal = \"xyxyxyxyxyyx\") == False\n assert candidate(s = \"programming\",goal = \"mingprogram\") == True\n assert candidate(s = \"abcdefgh\",goal = \"efghabcd\") == True\n assert candidate(s = \"repeatedcharacterszzzz\",goal = \"zzzzrepeatedcharacters\") == True\n assert candidate(s = \"almostdone\",goal = \"nearlycom\") == False\n assert candidate(s = \"samestring\",goal = \"stringames\") == False\n assert candidate(s = \"complexproblem\",goal = \"lecomplexprobo\") == False\n assert candidate(s = \"abababab\",goal = \"babababa\") == True\n assert candidate(s = \"ababab\",goal = \"bababa\") == True\n assert candidate(s = \"algorithm\",goal = \"rithalgo\") == False\n assert candidate(s = \"aabbccddeeff\",goal = \"ddeeffaabbcc\") == True\n assert candidate(s = \"qwertyuiop\",goal = \"uiopqwerty\") == True\n assert candidate(s = \"uniquestring\",goal = \"stringunique\") == True\n assert candidate(s = \"longstringexample\",goal = \"examplelongstring\") == True\n assert candidate(s = \"abcdefg\",goal = \"abcdefg\") == True\n assert candidate(s = \"repeatedpatternabcabcabc\",goal = \"abcabcabcrepeatedpattern\") == True\n assert candidate(s = \"ababababababababababab\",goal = \"bababababababababababa\") == True\n assert candidate(s = \"uniquecharacters\",goal = \"charactersunique\") == True\n assert candidate(s = \"shiftmearound\",goal = \"roundshiftmea\") == True\n assert candidate(s = \"cryptography\",goal = \"graphycryp\") == False\n assert candidate(s = \"complexstring\",goal = \"stringcomplex\") == True\n assert candidate(s = \"thisisatest\",goal = \"stthisisa\") == False\n assert candidate(s = \"circularrotation\",goal = \"ircularrotationc\") == True\n assert candidate(s = \"longstringexample\",goal = \"plelongstringex\") == False\n assert candidate(s = \"shiftleft\",goal = \"ftleftshi\") == True\n assert candidate(s = \"abcdabcd\",goal = \"cdabcdab\") == True\n assert candidate(s = \"aninterestingcase\",goal = \"caseaninteresting\") == True\n assert candidate(s = \"question\",goal = \"uestionq\") == True\n assert candidate(s = \"almostsame\",goal = \"lmostsamea\") == True\n assert candidate(s = \"verylongstringthatneedstobeshifted\",goal = \"edverylongstringthatneedstobeshift\") == True\n assert candidate(s = \"rotation\",goal = \"tationro\") == True\n assert candidate(s = \"repeatedwordsrepeated\",goal = \"wordsrepeatedrepeated\") == True\n assert candidate(s = \"example\",goal = \"mpleexa\") == True\n", "comparison": "exact"}, "public_tests": ["\"m\"\n\"f\"", "\"c\"\n\"w\""], "hints": [], "metadata": {"canonical_parameter_names": ["s", "goal"], "leetcode_dataset_entry_point": "Solution().rotateString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:57+00:00", "tests_total": 113, "tests_dropped": 2, "flags": [], "topic_tags": ["string", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def rotateString(self, s: str, goal: str) -> bool:", "container": "Solution", "callable": "rotateString", "parameters": [{"name": "s", "type": "str"}, {"name": "goal", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 797, "task_id": "all-paths-from-source-to-target", "difficulty": "Medium", "problem_description": "Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.\n\nThe graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]).\n\nExample 1:\n\nInput: graph = [[1,2],[3],[3],[]]\nOutput: [[0,1,3],[0,2,3]]\nExplanation: There are two paths: 0 -> 1 -> 3 and 0 -> 2 -> 3.\n\nExample 2:\n\nInput: graph = [[4,3,1],[3,2,4],[3],[4],[]]\nOutput: [[0,4],[0,3,4],[0,1,3,4],[0,1,2,3,4],[0,1,4]]\n\nConstraints:\n\n- n == graph.length\n- 2 <= n <= 15\n- 0 <= graph[i][j] < n\n- graph[i][j] != i (i.e., there will be no self-loops).\n- All the elements of graph[i] are unique.\n- The input graph is guaranteed to be a DAG.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(graph=[[1, 3], [2], [3], []]), [[0, 3], [0, 1, 2, 3]])\n assert answers_match(candidate(graph=[[1], []]), [[0, 1]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10], [7, 8, 9, 10], [8, 9, 10], [9, 10], [10], []]), [[0, 10], [0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [0, 5, 10], [0, 6, 10], [0, 7, 10], [0, 8, 10], [0, 9, 10], [0, 1, 2, 10], [0, 1, 3, 10], [0, 1, 4, 10], [0, 1, 5, 10], [0, 1, 6, 10], [0, 1, 7, 10], [0, 1, 8, 10], [0, 1, 9, 10], [0, 2, 3, 10], [0, 2, 4, 10], [0, 2, 5, 10], [0, 2, 6, 10], [0, 2, 7, 10], [0, 2, 8, 10], [0, 2, 9, 10], [0, 3, 4, 10], [0, 3, 5, 10], [0, 3, 6, 10], [0, 3, 7, 10], [0, 3, 8, 10], [0, 3, 9, 10], [0, 4, 5, 10], [0, 4, 6, 10], [0, 4, 7, 10], [0, 4, 8, 10], [0, 4, 9, 10], [0, 5, 6, 10], [0, 5, 7, 10], [0, 5, 8, 10], [0, 5, 9, 10], [0, 6, 7, 10], [0, 6, 8, 10], [0, 6, 9, 10], [0, 7, 8, 10], [0, 7, 9, 10], [0, 8, 9, 10], [0, 1, 2, 3, 10], [0, 1, 2, 4, 10], [0, 1, 2, 5, 10], [0, 1, 2, 6, 10], [0, 1, 2, 7, 10], [0, 1, 2, 8, 10], [0, 1, 2, 9, 10], [0, 1, 3, 4, 10], [0, 1, 3, 5, 10], [0, 1, 3, 6, 10], [0, 1, 3, 7, 10], [0, 1, 3, 8, 10], [0, 1, 3, 9, 10], [0, 1, 4, 5, 10], [0, 1, 4, 6, 10], [0, 1, 4, 7, 10], [0, 1, 4, 8, 10], [0, 1, 4, 9, 10], [0, 1, 5, 6, 10], [0, 1, 5, 7, 10], [0, 1, 5, 8, 10], [0, 1, 5, 9, 10], [0, 1, 6, 7, 10], [0, 1, 6, 8, 10], [0, 1, 6, 9, 10], [0, 1, 7, 8, 10], [0, 1, 7, 9, 10], [0, 1, 8, 9, 10], [0, 2, 3, 4, 10], [0, 2, 3, 5, 10], [0, 2, 3, 6, 10], [0, 2, 3, 7, 10], [0, 2, 3, 8, 10], [0, 2, 3, 9, 10], [0, 2, 4, 5, 10], [0, 2, 4, 6, 10], [0, 2, 4, 7, 10], [0, 2, 4, 8, 10], [0, 2, 4, 9, 10], [0, 2, 5, 6, 10], [0, 2, 5, 7, 10], [0, 2, 5, 8, 10], [0, 2, 5, 9, 10], [0, 2, 6, 7, 10], [0, 2, 6, 8, 10], [0, 2, 6, 9, 10], [0, 2, 7, 8, 10], [0, 2, 7, 9, 10], [0, 2, 8, 9, 10], [0, 3, 4, 5, 10], [0, 3, 4, 6, 10], [0, 3, 4, 7, 10], [0, 3, 4, 8, 10], [0, 3, 4, 9, 10], [0, 3, 5, 6, 10], [0, 3, 5, 7, 10], [0, 3, 5, 8, 10], [0, 3, 5, 9, 10], [0, 3, 6, 7, 10], [0, 3, 6, 8, 10], [0, 3, 6, 9, 10], [0, 3, 7, 8, 10], [0, 3, 7, 9, 10], [0, 3, 8, 9, 10], [0, 4, 5, 6, 10], [0, 4, 5, 7, 10], [0, 4, 5, 8, 10], [0, 4, 5, 9, 10], [0, 4, 6, 7, 10], [0, 4, 6, 8, 10], [0, 4, 6, 9, 10], [0, 4, 7, 8, 10], [0, 4, 7, 9, 10], [0, 4, 8, 9, 10], [0, 5, 6, 7, 10], [0, 5, 6, 8, 10], [0, 5, 6, 9, 10], [0, 5, 7, 8, 10], [0, 5, 7, 9, 10], [0, 5, 8, 9, 10], [0, 6, 7, 8, 10], [0, 6, 7, 9, 10], [0, 6, 8, 9, 10], [0, 7, 8, 9, 10], [0, 1, 2, 3, 4, 10], [0, 1, 2, 3, 5, 10], [0, 1, 2, 3, 6, 10], [0, 1, 2, 3, 7, 10], [0, 1, 2, 3, 8, 10], [0, 1, 2, 3, 9, 10], [0, 1, 2, 4, 5, 10], [0, 1, 2, 4, 6, 10], [0, 1, 2, 4, 7, 10], [0, 1, 2, 4, 8, 10], [0, 1, 2, 4, 9, 10], [0, 1, 2, 5, 6, 10], [0, 1, 2, 5, 7, 10], [0, 1, 2, 5, 8, 10], [0, 1, 2, 5, 9, 10], [0, 1, 2, 6, 7, 10], [0, 1, 2, 6, 8, 10], [0, 1, 2, 6, 9, 10], [0, 1, 2, 7, 8, 10], [0, 1, 2, 7, 9, 10], [0, 1, 2, 8, 9, 10], [0, 1, 3, 4, 5, 10], [0, 1, 3, 4, 6, 10], [0, 1, 3, 4, 7, 10], [0, 1, 3, 4, 8, 10], [0, 1, 3, 4, 9, 10], [0, 1, 3, 5, 6, 10], [0, 1, 3, 5, 7, 10], [0, 1, 3, 5, 8, 10], [0, 1, 3, 5, 9, 10], [0, 1, 3, 6, 7, 10], [0, 1, 3, 6, 8, 10], [0, 1, 3, 6, 9, 10], [0, 1, 3, 7, 8, 10], [0, 1, 3, 7, 9, 10], [0, 1, 3, 8, 9, 10], [0, 1, 4, 5, 6, 10], [0, 1, 4, 5, 7, 10], [0, 1, 4, 5, 8, 10], [0, 1, 4, 5, 9, 10], [0, 1, 4, 6, 7, 10], [0, 1, 4, 6, 8, 10], [0, 1, 4, 6, 9, 10], [0, 1, 4, 7, 8, 10], [0, 1, 4, 7, 9, 10], [0, 1, 4, 8, 9, 10], [0, 1, 5, 6, 7, 10], [0, 1, 5, 6, 8, 10], [0, 1, 5, 6, 9, 10], [0, 1, 5, 7, 8, 10], [0, 1, 5, 7, 9, 10], [0, 1, 5, 8, 9, 10], [0, 1, 6, 7, 8, 10], [0, 1, 6, 7, 9, 10], [0, 1, 6, 8, 9, 10], [0, 1, 7, 8, 9, 10], [0, 2, 3, 4, 5, 10], [0, 2, 3, 4, 6, 10], [0, 2, 3, 4, 7, 10], [0, 2, 3, 4, 8, 10], [0, 2, 3, 4, 9, 10], [0, 2, 3, 5, 6, 10], [0, 2, 3, 5, 7, 10], [0, 2, 3, 5, 8, 10], [0, 2, 3, 5, 9, 10], [0, 2, 3, 6, 7, 10], [0, 2, 3, 6, 8, 10], [0, 2, 3, 6, 9, 10], [0, 2, 3, 7, 8, 10], [0, 2, 3, 7, 9, 10], [0, 2, 3, 8, 9, 10], [0, 2, 4, 5, 6, 10], [0, 2, 4, 5, 7, 10], [0, 2, 4, 5, 8, 10], [0, 2, 4, 5, 9, 10], [0, 2, 4, 6, 7, 10], [0, 2, 4, 6, 8, 10], [0, 2, 4, 6, 9, 10], [0, 2, 4, 7, 8, 10], [0, 2, 4, 7, 9, 10], [0, 2, 4, 8, 9, 10], [0, 2, 5, 6, 7, 10], [0, 2, 5, 6, 8, 10], [0, 2, 5, 6, 9, 10], [0, 2, 5, 7, 8, 10], [0, 2, 5, 7, 9, 10], [0, 2, 5, 8, 9, 10], [0, 2, 6, 7, 8, 10], [0, 2, 6, 7, 9, 10], [0, 2, 6, 8, 9, 10], [0, 2, 7, 8, 9, 10], [0, 3, 4, 5, 6, 10], [0, 3, 4, 5, 7, 10], [0, 3, 4, 5, 8, 10], [0, 3, 4, 5, 9, 10], [0, 3, 4, 6, 7, 10], [0, 3, 4, 6, 8, 10], [0, 3, 4, 6, 9, 10], [0, 3, 4, 7, 8, 10], [0, 3, 4, 7, 9, 10], [0, 3, 4, 8, 9, 10], [0, 3, 5, 6, 7, 10], [0, 3, 5, 6, 8, 10], [0, 3, 5, 6, 9, 10], [0, 3, 5, 7, 8, 10], [0, 3, 5, 7, 9, 10], [0, 3, 5, 8, 9, 10], [0, 3, 6, 7, 8, 10], [0, 3, 6, 7, 9, 10], [0, 3, 6, 8, 9, 10], [0, 3, 7, 8, 9, 10], [0, 4, 5, 6, 7, 10], [0, 4, 5, 6, 8, 10], [0, 4, 5, 6, 9, 10], [0, 4, 5, 7, 8, 10], [0, 4, 5, 7, 9, 10], [0, 4, 5, 8, 9, 10], [0, 4, 6, 7, 8, 10], [0, 4, 6, 7, 9, 10], [0, 4, 6, 8, 9, 10], [0, 4, 7, 8, 9, 10], [0, 5, 6, 7, 8, 10], [0, 5, 6, 7, 9, 10], [0, 5, 6, 8, 9, 10], [0, 5, 7, 8, 9, 10], [0, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 10], [0, 1, 2, 3, 4, 6, 10], [0, 1, 2, 3, 4, 7, 10], [0, 1, 2, 3, 4, 8, 10], [0, 1, 2, 3, 4, 9, 10], [0, 1, 2, 3, 5, 6, 10], [0, 1, 2, 3, 5, 7, 10], [0, 1, 2, 3, 5, 8, 10], [0, 1, 2, 3, 5, 9, 10], [0, 1, 2, 3, 6, 7, 10], [0, 1, 2, 3, 6, 8, 10], [0, 1, 2, 3, 6, 9, 10], [0, 1, 2, 3, 7, 8, 10], [0, 1, 2, 3, 7, 9, 10], [0, 1, 2, 3, 8, 9, 10], [0, 1, 2, 4, 5, 6, 10], [0, 1, 2, 4, 5, 7, 10], [0, 1, 2, 4, 5, 8, 10], [0, 1, 2, 4, 5, 9, 10], [0, 1, 2, 4, 6, 7, 10], [0, 1, 2, 4, 6, 8, 10], [0, 1, 2, 4, 6, 9, 10], [0, 1, 2, 4, 7, 8, 10], [0, 1, 2, 4, 7, 9, 10], [0, 1, 2, 4, 8, 9, 10], [0, 1, 2, 5, 6, 7, 10], [0, 1, 2, 5, 6, 8, 10], [0, 1, 2, 5, 6, 9, 10], [0, 1, 2, 5, 7, 8, 10], [0, 1, 2, 5, 7, 9, 10], [0, 1, 2, 5, 8, 9, 10], [0, 1, 2, 6, 7, 8, 10], [0, 1, 2, 6, 7, 9, 10], [0, 1, 2, 6, 8, 9, 10], [0, 1, 2, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 10], [0, 1, 3, 4, 5, 7, 10], [0, 1, 3, 4, 5, 8, 10], [0, 1, 3, 4, 5, 9, 10], [0, 1, 3, 4, 6, 7, 10], [0, 1, 3, 4, 6, 8, 10], [0, 1, 3, 4, 6, 9, 10], [0, 1, 3, 4, 7, 8, 10], [0, 1, 3, 4, 7, 9, 10], [0, 1, 3, 4, 8, 9, 10], [0, 1, 3, 5, 6, 7, 10], [0, 1, 3, 5, 6, 8, 10], [0, 1, 3, 5, 6, 9, 10], [0, 1, 3, 5, 7, 8, 10], [0, 1, 3, 5, 7, 9, 10], [0, 1, 3, 5, 8, 9, 10], [0, 1, 3, 6, 7, 8, 10], [0, 1, 3, 6, 7, 9, 10], [0, 1, 3, 6, 8, 9, 10], [0, 1, 3, 7, 8, 9, 10], [0, 1, 4, 5, 6, 7, 10], [0, 1, 4, 5, 6, 8, 10], [0, 1, 4, 5, 6, 9, 10], [0, 1, 4, 5, 7, 8, 10], [0, 1, 4, 5, 7, 9, 10], [0, 1, 4, 5, 8, 9, 10], [0, 1, 4, 6, 7, 8, 10], [0, 1, 4, 6, 7, 9, 10], [0, 1, 4, 6, 8, 9, 10], [0, 1, 4, 7, 8, 9, 10], [0, 1, 5, 6, 7, 8, 10], [0, 1, 5, 6, 7, 9, 10], [0, 1, 5, 6, 8, 9, 10], [0, 1, 5, 7, 8, 9, 10], [0, 1, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 10], [0, 2, 3, 4, 5, 7, 10], [0, 2, 3, 4, 5, 8, 10], [0, 2, 3, 4, 5, 9, 10], [0, 2, 3, 4, 6, 7, 10], [0, 2, 3, 4, 6, 8, 10], [0, 2, 3, 4, 6, 9, 10], [0, 2, 3, 4, 7, 8, 10], [0, 2, 3, 4, 7, 9, 10], [0, 2, 3, 4, 8, 9, 10], [0, 2, 3, 5, 6, 7, 10], [0, 2, 3, 5, 6, 8, 10], [0, 2, 3, 5, 6, 9, 10], [0, 2, 3, 5, 7, 8, 10], [0, 2, 3, 5, 7, 9, 10], [0, 2, 3, 5, 8, 9, 10], [0, 2, 3, 6, 7, 8, 10], [0, 2, 3, 6, 7, 9, 10], [0, 2, 3, 6, 8, 9, 10], [0, 2, 3, 7, 8, 9, 10], [0, 2, 4, 5, 6, 7, 10], [0, 2, 4, 5, 6, 8, 10], [0, 2, 4, 5, 6, 9, 10], [0, 2, 4, 5, 7, 8, 10], [0, 2, 4, 5, 7, 9, 10], [0, 2, 4, 5, 8, 9, 10], [0, 2, 4, 6, 7, 8, 10], [0, 2, 4, 6, 7, 9, 10], [0, 2, 4, 6, 8, 9, 10], [0, 2, 4, 7, 8, 9, 10], [0, 2, 5, 6, 7, 8, 10], [0, 2, 5, 6, 7, 9, 10], [0, 2, 5, 6, 8, 9, 10], [0, 2, 5, 7, 8, 9, 10], [0, 2, 6, 7, 8, 9, 10], [0, 3, 4, 5, 6, 7, 10], [0, 3, 4, 5, 6, 8, 10], [0, 3, 4, 5, 6, 9, 10], [0, 3, 4, 5, 7, 8, 10], [0, 3, 4, 5, 7, 9, 10], [0, 3, 4, 5, 8, 9, 10], [0, 3, 4, 6, 7, 8, 10], [0, 3, 4, 6, 7, 9, 10], [0, 3, 4, 6, 8, 9, 10], [0, 3, 4, 7, 8, 9, 10], [0, 3, 5, 6, 7, 8, 10], [0, 3, 5, 6, 7, 9, 10], [0, 3, 5, 6, 8, 9, 10], [0, 3, 5, 7, 8, 9, 10], [0, 3, 6, 7, 8, 9, 10], [0, 4, 5, 6, 7, 8, 10], [0, 4, 5, 6, 7, 9, 10], [0, 4, 5, 6, 8, 9, 10], [0, 4, 5, 7, 8, 9, 10], [0, 4, 6, 7, 8, 9, 10], [0, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 10], [0, 1, 2, 3, 4, 5, 7, 10], [0, 1, 2, 3, 4, 5, 8, 10], [0, 1, 2, 3, 4, 5, 9, 10], [0, 1, 2, 3, 4, 6, 7, 10], [0, 1, 2, 3, 4, 6, 8, 10], [0, 1, 2, 3, 4, 6, 9, 10], [0, 1, 2, 3, 4, 7, 8, 10], [0, 1, 2, 3, 4, 7, 9, 10], [0, 1, 2, 3, 4, 8, 9, 10], [0, 1, 2, 3, 5, 6, 7, 10], [0, 1, 2, 3, 5, 6, 8, 10], [0, 1, 2, 3, 5, 6, 9, 10], [0, 1, 2, 3, 5, 7, 8, 10], [0, 1, 2, 3, 5, 7, 9, 10], [0, 1, 2, 3, 5, 8, 9, 10], [0, 1, 2, 3, 6, 7, 8, 10], [0, 1, 2, 3, 6, 7, 9, 10], [0, 1, 2, 3, 6, 8, 9, 10], [0, 1, 2, 3, 7, 8, 9, 10], [0, 1, 2, 4, 5, 6, 7, 10], [0, 1, 2, 4, 5, 6, 8, 10], [0, 1, 2, 4, 5, 6, 9, 10], [0, 1, 2, 4, 5, 7, 8, 10], [0, 1, 2, 4, 5, 7, 9, 10], [0, 1, 2, 4, 5, 8, 9, 10], [0, 1, 2, 4, 6, 7, 8, 10], [0, 1, 2, 4, 6, 7, 9, 10], [0, 1, 2, 4, 6, 8, 9, 10], [0, 1, 2, 4, 7, 8, 9, 10], [0, 1, 2, 5, 6, 7, 8, 10], [0, 1, 2, 5, 6, 7, 9, 10], [0, 1, 2, 5, 6, 8, 9, 10], [0, 1, 2, 5, 7, 8, 9, 10], [0, 1, 2, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 10], [0, 1, 3, 4, 5, 6, 8, 10], [0, 1, 3, 4, 5, 6, 9, 10], [0, 1, 3, 4, 5, 7, 8, 10], [0, 1, 3, 4, 5, 7, 9, 10], [0, 1, 3, 4, 5, 8, 9, 10], [0, 1, 3, 4, 6, 7, 8, 10], [0, 1, 3, 4, 6, 7, 9, 10], [0, 1, 3, 4, 6, 8, 9, 10], [0, 1, 3, 4, 7, 8, 9, 10], [0, 1, 3, 5, 6, 7, 8, 10], [0, 1, 3, 5, 6, 7, 9, 10], [0, 1, 3, 5, 6, 8, 9, 10], [0, 1, 3, 5, 7, 8, 9, 10], [0, 1, 3, 6, 7, 8, 9, 10], [0, 1, 4, 5, 6, 7, 8, 10], [0, 1, 4, 5, 6, 7, 9, 10], [0, 1, 4, 5, 6, 8, 9, 10], [0, 1, 4, 5, 7, 8, 9, 10], [0, 1, 4, 6, 7, 8, 9, 10], [0, 1, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 10], [0, 2, 3, 4, 5, 6, 8, 10], [0, 2, 3, 4, 5, 6, 9, 10], [0, 2, 3, 4, 5, 7, 8, 10], [0, 2, 3, 4, 5, 7, 9, 10], [0, 2, 3, 4, 5, 8, 9, 10], [0, 2, 3, 4, 6, 7, 8, 10], [0, 2, 3, 4, 6, 7, 9, 10], [0, 2, 3, 4, 6, 8, 9, 10], [0, 2, 3, 4, 7, 8, 9, 10], [0, 2, 3, 5, 6, 7, 8, 10], [0, 2, 3, 5, 6, 7, 9, 10], [0, 2, 3, 5, 6, 8, 9, 10], [0, 2, 3, 5, 7, 8, 9, 10], [0, 2, 3, 6, 7, 8, 9, 10], [0, 2, 4, 5, 6, 7, 8, 10], [0, 2, 4, 5, 6, 7, 9, 10], [0, 2, 4, 5, 6, 8, 9, 10], [0, 2, 4, 5, 7, 8, 9, 10], [0, 2, 4, 6, 7, 8, 9, 10], [0, 2, 5, 6, 7, 8, 9, 10], [0, 3, 4, 5, 6, 7, 8, 10], [0, 3, 4, 5, 6, 7, 9, 10], [0, 3, 4, 5, 6, 8, 9, 10], [0, 3, 4, 5, 7, 8, 9, 10], [0, 3, 4, 6, 7, 8, 9, 10], [0, 3, 5, 6, 7, 8, 9, 10], [0, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 10], [0, 1, 2, 3, 4, 5, 6, 8, 10], [0, 1, 2, 3, 4, 5, 6, 9, 10], [0, 1, 2, 3, 4, 5, 7, 8, 10], [0, 1, 2, 3, 4, 5, 7, 9, 10], [0, 1, 2, 3, 4, 5, 8, 9, 10], [0, 1, 2, 3, 4, 6, 7, 8, 10], [0, 1, 2, 3, 4, 6, 7, 9, 10], [0, 1, 2, 3, 4, 6, 8, 9, 10], [0, 1, 2, 3, 4, 7, 8, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 10], [0, 1, 2, 3, 5, 6, 7, 9, 10], [0, 1, 2, 3, 5, 6, 8, 9, 10], [0, 1, 2, 3, 5, 7, 8, 9, 10], [0, 1, 2, 3, 6, 7, 8, 9, 10], [0, 1, 2, 4, 5, 6, 7, 8, 10], [0, 1, 2, 4, 5, 6, 7, 9, 10], [0, 1, 2, 4, 5, 6, 8, 9, 10], [0, 1, 2, 4, 5, 7, 8, 9, 10], [0, 1, 2, 4, 6, 7, 8, 9, 10], [0, 1, 2, 5, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 8, 10], [0, 1, 3, 4, 5, 6, 7, 9, 10], [0, 1, 3, 4, 5, 6, 8, 9, 10], [0, 1, 3, 4, 5, 7, 8, 9, 10], [0, 1, 3, 4, 6, 7, 8, 9, 10], [0, 1, 3, 5, 6, 7, 8, 9, 10], [0, 1, 4, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 8, 10], [0, 2, 3, 4, 5, 6, 7, 9, 10], [0, 2, 3, 4, 5, 6, 8, 9, 10], [0, 2, 3, 4, 5, 7, 8, 9, 10], [0, 2, 3, 4, 6, 7, 8, 9, 10], [0, 2, 3, 5, 6, 7, 8, 9, 10], [0, 2, 4, 5, 6, 7, 8, 9, 10], [0, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])\n assert answers_match(candidate(graph=[[1], [2], []]), [[0, 1, 2]])\n assert answers_match(candidate(graph=[[4, 3, 1], [3, 2, 4], [3], [4], []]), [[0, 4], [0, 3, 4], [0, 1, 4], [0, 1, 3, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2], [2, 3], [3], [4], []]), [[0, 1, 3, 4], [0, 2, 3, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1], [2, 3], [3], []]), [[0, 1, 3], [0, 1, 2, 3]])\n assert answers_match(candidate(graph=[[1, 2, 3], [2, 3], [3, 4], [4], []]), [[0, 2, 4], [0, 3, 4], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2], [3, 4], [3, 4], [5], [5], []]), [[0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 3, 5], [0, 2, 4, 5]])\n assert answers_match(candidate(graph=[[1], [2], [3], [4], [5], [6], [7], [8], [9], []]), [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])\n assert answers_match(candidate(graph=[[1, 2], [3], [3], []]), [[0, 1, 3], [0, 2, 3]])\n assert answers_match(candidate(graph=[[1, 2], [3], [3, 4], [4], []]), [[0, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2, 3], [2], [3], []]), [[0, 3], [0, 2, 3], [0, 1, 2, 3]])\n assert answers_match(candidate(graph=[[1], [[]]]), [[0, 1]])\n assert answers_match(candidate(graph=[[1], [2, 3], [3, 4], [4, 5], [5], []]), [[0, 1, 3, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1], [2], [3, 4], [4], []]), [[0, 1, 2, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2], [3], [], [4]]), [[0, 1, 3]])\n assert answers_match(candidate(graph=[[1, 3], [2, 4], [3, 4, 5], [5], [], []]), [[0, 3, 5], [0, 1, 2, 5], [0, 1, 2, 3, 5]])\n assert answers_match(candidate(graph=[[1, 2, 3, 5, 6], [3, 4], [3, 4], [4, 5, 6], [5, 6], [], []]), [[0, 6], [0, 3, 6], [0, 1, 3, 6], [0, 1, 4, 6], [0, 2, 3, 6], [0, 2, 4, 6], [0, 3, 4, 6], [0, 1, 3, 4, 6], [0, 2, 3, 4, 6]])\n assert answers_match(candidate(graph=[[1], [2, 3, 4], [3, 4], [4], [5], [6], [7], [8], []]), [[0, 1, 4, 5, 6, 7, 8], [0, 1, 2, 4, 5, 6, 7, 8], [0, 1, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8]])\n assert answers_match(candidate(graph=[[1, 2], [3, 4, 5], [4, 5], [5], [5], []]), [[0, 1, 5], [0, 2, 5], [0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 4, 5]])\n assert answers_match(candidate(graph=[[1, 3, 4], [2, 4], [3, 4], [5], [5], []]), [[0, 3, 5], [0, 4, 5], [0, 1, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3, 4], [3, 4], [4], []]), [[0, 4], [0, 1, 4], [0, 2, 4], [0, 3, 4], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2, 5], [2, 3], [3, 4, 5], [4, 5], [5], []]), [[0, 5], [0, 2, 5], [0, 1, 2, 5], [0, 1, 3, 5], [0, 2, 3, 5], [0, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1, 4], [2, 3, 4], [3, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8], [7, 8, 9], [8, 9], [9], []]), [[0, 4, 6, 9], [0, 4, 7, 9], [0, 4, 8, 9], [0, 1, 2, 6, 9], [0, 1, 3, 6, 9], [0, 1, 3, 7, 9], [0, 1, 4, 6, 9], [0, 1, 4, 7, 9], [0, 1, 4, 8, 9], [0, 4, 5, 6, 9], [0, 4, 5, 7, 9], [0, 4, 5, 8, 9], [0, 4, 6, 7, 9], [0, 4, 6, 8, 9], [0, 4, 7, 8, 9], [0, 1, 2, 3, 6, 9], [0, 1, 2, 3, 7, 9], [0, 1, 2, 5, 6, 9], [0, 1, 2, 5, 7, 9], [0, 1, 2, 5, 8, 9], [0, 1, 2, 6, 7, 9], [0, 1, 2, 6, 8, 9], [0, 1, 3, 4, 6, 9], [0, 1, 3, 4, 7, 9], [0, 1, 3, 4, 8, 9], [0, 1, 3, 5, 6, 9], [0, 1, 3, 5, 7, 9], [0, 1, 3, 5, 8, 9], [0, 1, 3, 6, 7, 9], [0, 1, 3, 6, 8, 9], [0, 1, 3, 7, 8, 9], [0, 1, 4, 5, 6, 9], [0, 1, 4, 5, 7, 9], [0, 1, 4, 5, 8, 9], [0, 1, 4, 6, 7, 9], [0, 1, 4, 6, 8, 9], [0, 1, 4, 7, 8, 9], [0, 4, 5, 6, 7, 9], [0, 4, 5, 6, 8, 9], [0, 4, 5, 7, 8, 9], [0, 4, 6, 7, 8, 9], [0, 1, 2, 3, 4, 6, 9], [0, 1, 2, 3, 4, 7, 9], [0, 1, 2, 3, 4, 8, 9], [0, 1, 2, 3, 5, 6, 9], [0, 1, 2, 3, 5, 7, 9], [0, 1, 2, 3, 5, 8, 9], [0, 1, 2, 3, 6, 7, 9], [0, 1, 2, 3, 6, 8, 9], [0, 1, 2, 3, 7, 8, 9], [0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 8, 9], [0, 1, 2, 5, 7, 8, 9], [0, 1, 2, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 9], [0, 1, 3, 4, 5, 7, 9], [0, 1, 3, 4, 5, 8, 9], [0, 1, 3, 4, 6, 7, 9], [0, 1, 3, 4, 6, 8, 9], [0, 1, 3, 4, 7, 8, 9], [0, 1, 3, 5, 6, 7, 9], [0, 1, 3, 5, 6, 8, 9], [0, 1, 3, 5, 7, 8, 9], [0, 1, 3, 6, 7, 8, 9], [0, 1, 4, 5, 6, 7, 9], [0, 1, 4, 5, 6, 8, 9], [0, 1, 4, 5, 7, 8, 9], [0, 1, 4, 6, 7, 8, 9], [0, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 9], [0, 1, 2, 3, 4, 5, 7, 9], [0, 1, 2, 3, 4, 5, 8, 9], [0, 1, 2, 3, 4, 6, 7, 9], [0, 1, 2, 3, 4, 6, 8, 9], [0, 1, 2, 3, 4, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 9], [0, 1, 2, 3, 5, 6, 8, 9], [0, 1, 2, 3, 5, 7, 8, 9], [0, 1, 2, 3, 6, 7, 8, 9], [0, 1, 2, 5, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 7, 9], [0, 1, 3, 4, 5, 6, 8, 9], [0, 1, 3, 4, 5, 7, 8, 9], [0, 1, 3, 4, 6, 7, 8, 9], [0, 1, 3, 5, 6, 7, 8, 9], [0, 1, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 9], [0, 1, 2, 3, 4, 5, 6, 8, 9], [0, 1, 2, 3, 4, 5, 7, 8, 9], [0, 1, 2, 3, 4, 6, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3, 5], [3, 5, 6], [4, 5, 6], [5, 6], [6], []]), [[0, 2, 6], [0, 3, 6], [0, 4, 6], [0, 1, 2, 6], [0, 1, 3, 6], [0, 1, 5, 6], [0, 2, 3, 6], [0, 2, 5, 6], [0, 3, 4, 6], [0, 3, 5, 6], [0, 4, 5, 6], [0, 1, 2, 3, 6], [0, 1, 2, 5, 6], [0, 1, 3, 4, 6], [0, 1, 3, 5, 6], [0, 2, 3, 4, 6], [0, 2, 3, 5, 6], [0, 3, 4, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 5, 6], [0, 1, 3, 4, 5, 6], [0, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])\n assert answers_match(candidate(graph=[[1, 2, 3], [4, 5], [4, 5], [4, 5], [6, 7], [6, 7], [], [], []]), [])\n assert answers_match(candidate(graph=[[1, 2], [3, 4, 5], [4, 5], [5], [6, 7], [6, 7], [8], [8], []]), [[0, 1, 4, 6, 8], [0, 1, 4, 7, 8], [0, 1, 5, 6, 8], [0, 1, 5, 7, 8], [0, 2, 4, 6, 8], [0, 2, 4, 7, 8], [0, 2, 5, 6, 8], [0, 2, 5, 7, 8], [0, 1, 3, 5, 6, 8], [0, 1, 3, 5, 7, 8]])\n assert answers_match(candidate(graph=[[1, 3, 4], [2], [3, 4], [4], []]), [[0, 4], [0, 3, 4], [0, 1, 2, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2, 5], [2, 3, 4], [3, 4, 5], [4, 5], [5], []]), [[0, 5], [0, 2, 5], [0, 1, 2, 5], [0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 3, 5], [0, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5], []]), [[0, 1, 5], [0, 2, 5], [0, 3, 5], [0, 4, 5], [0, 1, 2, 5], [0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 3, 5], [0, 2, 4, 5], [0, 3, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1, 2], [3, 4], [4], [], []]), [[0, 1, 4], [0, 2, 4]])\n assert answers_match(candidate(graph=[[1], [3, 4], [5], [5], [], [6], []]), [[0, 1, 3, 5, 6]])\n assert answers_match(candidate(graph=[[1, 3, 4], [2, 3, 4], [4], [], []]), [[0, 4], [0, 1, 4], [0, 1, 2, 4]])\n assert answers_match(candidate(graph=[[1, 2, 3], [3, 4, 5], [4, 5], [4, 5, 6], [5, 6], [6], []]), [[0, 3, 6], [0, 1, 3, 6], [0, 1, 4, 6], [0, 1, 5, 6], [0, 2, 4, 6], [0, 2, 5, 6], [0, 3, 4, 6], [0, 3, 5, 6], [0, 1, 3, 4, 6], [0, 1, 3, 5, 6], [0, 1, 4, 5, 6], [0, 2, 4, 5, 6], [0, 3, 4, 5, 6], [0, 1, 3, 4, 5, 6]])\n assert answers_match(candidate(graph=[[1, 2], [3, 4, 5, 6, 7], [3, 4, 5, 6, 7], [4, 5, 6, 7], [5, 6, 7], [6, 7], [7], [8], []]), [[0, 1, 7, 8], [0, 2, 7, 8], [0, 1, 3, 7, 8], [0, 1, 4, 7, 8], [0, 1, 5, 7, 8], [0, 1, 6, 7, 8], [0, 2, 3, 7, 8], [0, 2, 4, 7, 8], [0, 2, 5, 7, 8], [0, 2, 6, 7, 8], [0, 1, 3, 4, 7, 8], [0, 1, 3, 5, 7, 8], [0, 1, 3, 6, 7, 8], [0, 1, 4, 5, 7, 8], [0, 1, 4, 6, 7, 8], [0, 1, 5, 6, 7, 8], [0, 2, 3, 4, 7, 8], [0, 2, 3, 5, 7, 8], [0, 2, 3, 6, 7, 8], [0, 2, 4, 5, 7, 8], [0, 2, 4, 6, 7, 8], [0, 2, 5, 6, 7, 8], [0, 1, 3, 4, 5, 7, 8], [0, 1, 3, 4, 6, 7, 8], [0, 1, 3, 5, 6, 7, 8], [0, 1, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 7, 8], [0, 2, 3, 4, 6, 7, 8], [0, 2, 3, 5, 6, 7, 8], [0, 2, 4, 5, 6, 7, 8], [0, 1, 3, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 6, 7, 8]])\n assert answers_match(candidate(graph=[[1, 4], [2], [3], [4], []]), [[0, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5], [5], []]), [[0, 5], [0, 1, 5], [0, 2, 5], [0, 1, 2, 5], [0, 1, 3, 5], [0, 2, 3, 5], [0, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1], [2, 3], [3], [4], [5, 6], [6], [7], []]), [[0, 1, 3, 4, 6, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])\n assert answers_match(candidate(graph=[[1, 2, 3], [3, 4, 5, 6], [4, 5, 6], [4, 5, 6, 7], [5, 6, 7], [6, 7], [7], []]), [[0, 3, 7], [0, 1, 3, 7], [0, 1, 4, 7], [0, 1, 5, 7], [0, 1, 6, 7], [0, 2, 4, 7], [0, 2, 5, 7], [0, 2, 6, 7], [0, 3, 4, 7], [0, 3, 5, 7], [0, 3, 6, 7], [0, 1, 3, 4, 7], [0, 1, 3, 5, 7], [0, 1, 3, 6, 7], [0, 1, 4, 5, 7], [0, 1, 4, 6, 7], [0, 1, 5, 6, 7], [0, 2, 4, 5, 7], [0, 2, 4, 6, 7], [0, 2, 5, 6, 7], [0, 3, 4, 5, 7], [0, 3, 4, 6, 7], [0, 3, 5, 6, 7], [0, 1, 3, 4, 5, 7], [0, 1, 3, 4, 6, 7], [0, 1, 3, 5, 6, 7], [0, 1, 4, 5, 6, 7], [0, 2, 4, 5, 6, 7], [0, 3, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7]])\n assert answers_match(candidate(graph=[[1, 2], [2, 3], [3], [4, 5], [5], [6], []]), [[0, 1, 3, 5, 6], [0, 2, 3, 5, 6], [0, 1, 2, 3, 5, 6], [0, 1, 3, 4, 5, 6], [0, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])\n assert answers_match(candidate(graph=[[1, 2], [3], [3], [4], [5, 6], [6], [7, 8], [8], []]), [[0, 1, 3, 4, 6, 8], [0, 2, 3, 4, 6, 8], [0, 1, 3, 4, 5, 6, 8], [0, 1, 3, 4, 6, 7, 8], [0, 2, 3, 4, 5, 6, 8], [0, 2, 3, 4, 6, 7, 8], [0, 1, 3, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 6, 7, 8]])\n assert answers_match(candidate(graph=[[1, 2, 3], [2, 3, 4, 5], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9], [7, 8, 9], [8, 9], [9], []]), [[0, 1, 4, 9], [0, 1, 5, 9], [0, 2, 4, 9], [0, 2, 5, 9], [0, 2, 6, 9], [0, 2, 7, 9], [0, 3, 4, 9], [0, 3, 5, 9], [0, 3, 6, 9], [0, 3, 7, 9], [0, 3, 8, 9], [0, 1, 2, 4, 9], [0, 1, 2, 5, 9], [0, 1, 2, 6, 9], [0, 1, 2, 7, 9], [0, 1, 3, 4, 9], [0, 1, 3, 5, 9], [0, 1, 3, 6, 9], [0, 1, 3, 7, 9], [0, 1, 3, 8, 9], [0, 1, 4, 5, 9], [0, 1, 4, 6, 9], [0, 1, 4, 7, 9], [0, 1, 4, 8, 9], [0, 1, 5, 6, 9], [0, 1, 5, 7, 9], [0, 1, 5, 8, 9], [0, 2, 3, 4, 9], [0, 2, 3, 5, 9], [0, 2, 3, 6, 9], [0, 2, 3, 7, 9], [0, 2, 3, 8, 9], [0, 2, 4, 5, 9], [0, 2, 4, 6, 9], [0, 2, 4, 7, 9], [0, 2, 4, 8, 9], [0, 2, 5, 6, 9], [0, 2, 5, 7, 9], [0, 2, 5, 8, 9], [0, 2, 6, 7, 9], [0, 2, 6, 8, 9], [0, 2, 7, 8, 9], [0, 3, 4, 5, 9], [0, 3, 4, 6, 9], [0, 3, 4, 7, 9], [0, 3, 4, 8, 9], [0, 3, 5, 6, 9], [0, 3, 5, 7, 9], [0, 3, 5, 8, 9], [0, 3, 6, 7, 9], [0, 3, 6, 8, 9], [0, 3, 7, 8, 9], [0, 1, 2, 3, 4, 9], [0, 1, 2, 3, 5, 9], [0, 1, 2, 3, 6, 9], [0, 1, 2, 3, 7, 9], [0, 1, 2, 3, 8, 9], [0, 1, 2, 4, 5, 9], [0, 1, 2, 4, 6, 9], [0, 1, 2, 4, 7, 9], [0, 1, 2, 4, 8, 9], [0, 1, 2, 5, 6, 9], [0, 1, 2, 5, 7, 9], [0, 1, 2, 5, 8, 9], [0, 1, 2, 6, 7, 9], [0, 1, 2, 6, 8, 9], [0, 1, 2, 7, 8, 9], [0, 1, 3, 4, 5, 9], [0, 1, 3, 4, 6, 9], [0, 1, 3, 4, 7, 9], [0, 1, 3, 4, 8, 9], [0, 1, 3, 5, 6, 9], [0, 1, 3, 5, 7, 9], [0, 1, 3, 5, 8, 9], [0, 1, 3, 6, 7, 9], [0, 1, 3, 6, 8, 9], [0, 1, 3, 7, 8, 9], [0, 1, 4, 5, 6, 9], [0, 1, 4, 5, 7, 9], [0, 1, 4, 5, 8, 9], [0, 1, 4, 6, 7, 9], [0, 1, 4, 6, 8, 9], [0, 1, 4, 7, 8, 9], [0, 1, 5, 6, 7, 9], [0, 1, 5, 6, 8, 9], [0, 1, 5, 7, 8, 9], [0, 2, 3, 4, 5, 9], [0, 2, 3, 4, 6, 9], [0, 2, 3, 4, 7, 9], [0, 2, 3, 4, 8, 9], [0, 2, 3, 5, 6, 9], [0, 2, 3, 5, 7, 9], [0, 2, 3, 5, 8, 9], [0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 8, 9], [0, 2, 3, 7, 8, 9], [0, 2, 4, 5, 6, 9], [0, 2, 4, 5, 7, 9], [0, 2, 4, 5, 8, 9], [0, 2, 4, 6, 7, 9], [0, 2, 4, 6, 8, 9], [0, 2, 4, 7, 8, 9], [0, 2, 5, 6, 7, 9], [0, 2, 5, 6, 8, 9], [0, 2, 5, 7, 8, 9], [0, 2, 6, 7, 8, 9], [0, 3, 4, 5, 6, 9], [0, 3, 4, 5, 7, 9], [0, 3, 4, 5, 8, 9], [0, 3, 4, 6, 7, 9], [0, 3, 4, 6, 8, 9], [0, 3, 4, 7, 8, 9], [0, 3, 5, 6, 7, 9], [0, 3, 5, 6, 8, 9], [0, 3, 5, 7, 8, 9], [0, 3, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 9], [0, 1, 2, 3, 4, 6, 9], [0, 1, 2, 3, 4, 7, 9], [0, 1, 2, 3, 4, 8, 9], [0, 1, 2, 3, 5, 6, 9], [0, 1, 2, 3, 5, 7, 9], [0, 1, 2, 3, 5, 8, 9], [0, 1, 2, 3, 6, 7, 9], [0, 1, 2, 3, 6, 8, 9], [0, 1, 2, 3, 7, 8, 9], [0, 1, 2, 4, 5, 6, 9], [0, 1, 2, 4, 5, 7, 9], [0, 1, 2, 4, 5, 8, 9], [0, 1, 2, 4, 6, 7, 9], [0, 1, 2, 4, 6, 8, 9], [0, 1, 2, 4, 7, 8, 9], [0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 8, 9], [0, 1, 2, 5, 7, 8, 9], [0, 1, 2, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 9], [0, 1, 3, 4, 5, 7, 9], [0, 1, 3, 4, 5, 8, 9], [0, 1, 3, 4, 6, 7, 9], [0, 1, 3, 4, 6, 8, 9], [0, 1, 3, 4, 7, 8, 9], [0, 1, 3, 5, 6, 7, 9], [0, 1, 3, 5, 6, 8, 9], [0, 1, 3, 5, 7, 8, 9], [0, 1, 3, 6, 7, 8, 9], [0, 1, 4, 5, 6, 7, 9], [0, 1, 4, 5, 6, 8, 9], [0, 1, 4, 5, 7, 8, 9], [0, 1, 4, 6, 7, 8, 9], [0, 1, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 9], [0, 2, 3, 4, 5, 7, 9], [0, 2, 3, 4, 5, 8, 9], [0, 2, 3, 4, 6, 7, 9], [0, 2, 3, 4, 6, 8, 9], [0, 2, 3, 4, 7, 8, 9], [0, 2, 3, 5, 6, 7, 9], [0, 2, 3, 5, 6, 8, 9], [0, 2, 3, 5, 7, 8, 9], [0, 2, 3, 6, 7, 8, 9], [0, 2, 4, 5, 6, 7, 9], [0, 2, 4, 5, 6, 8, 9], [0, 2, 4, 5, 7, 8, 9], [0, 2, 4, 6, 7, 8, 9], [0, 2, 5, 6, 7, 8, 9], [0, 3, 4, 5, 6, 7, 9], [0, 3, 4, 5, 6, 8, 9], [0, 3, 4, 5, 7, 8, 9], [0, 3, 4, 6, 7, 8, 9], [0, 3, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 9], [0, 1, 2, 3, 4, 5, 7, 9], [0, 1, 2, 3, 4, 5, 8, 9], [0, 1, 2, 3, 4, 6, 7, 9], [0, 1, 2, 3, 4, 6, 8, 9], [0, 1, 2, 3, 4, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 9], [0, 1, 2, 3, 5, 6, 8, 9], [0, 1, 2, 3, 5, 7, 8, 9], [0, 1, 2, 3, 6, 7, 8, 9], [0, 1, 2, 4, 5, 6, 7, 9], [0, 1, 2, 4, 5, 6, 8, 9], [0, 1, 2, 4, 5, 7, 8, 9], [0, 1, 2, 4, 6, 7, 8, 9], [0, 1, 2, 5, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 7, 9], [0, 1, 3, 4, 5, 6, 8, 9], [0, 1, 3, 4, 5, 7, 8, 9], [0, 1, 3, 4, 6, 7, 8, 9], [0, 1, 3, 5, 6, 7, 8, 9], [0, 1, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 9], [0, 2, 3, 4, 5, 6, 8, 9], [0, 2, 3, 4, 5, 7, 8, 9], [0, 2, 3, 4, 6, 7, 8, 9], [0, 2, 3, 5, 6, 7, 8, 9], [0, 2, 4, 5, 6, 7, 8, 9], [0, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 9], [0, 1, 2, 3, 4, 5, 6, 8, 9], [0, 1, 2, 3, 4, 5, 7, 8, 9], [0, 1, 2, 3, 4, 6, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8, 9], [0, 1, 2, 4, 5, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])\n assert answers_match(candidate(graph=[[1, 3, 4], [2, 4], [3, 5], [4, 5], [5], []]), [[0, 3, 5], [0, 4, 5], [0, 1, 2, 5], [0, 1, 4, 5], [0, 3, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[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], []]), [[0, 8], [0, 1, 8], [0, 2, 8], [0, 3, 8], [0, 4, 8], [0, 5, 8], [0, 6, 8], [0, 7, 8], [0, 1, 2, 8], [0, 1, 3, 8], [0, 1, 4, 8], [0, 1, 5, 8], [0, 1, 6, 8], [0, 1, 7, 8], [0, 2, 3, 8], [0, 2, 4, 8], [0, 2, 5, 8], [0, 2, 6, 8], [0, 2, 7, 8], [0, 3, 4, 8], [0, 3, 5, 8], [0, 3, 6, 8], [0, 3, 7, 8], [0, 4, 5, 8], [0, 4, 6, 8], [0, 4, 7, 8], [0, 5, 6, 8], [0, 5, 7, 8], [0, 6, 7, 8], [0, 1, 2, 3, 8], [0, 1, 2, 4, 8], [0, 1, 2, 5, 8], [0, 1, 2, 6, 8], [0, 1, 2, 7, 8], [0, 1, 3, 4, 8], [0, 1, 3, 5, 8], [0, 1, 3, 6, 8], [0, 1, 3, 7, 8], [0, 1, 4, 5, 8], [0, 1, 4, 6, 8], [0, 1, 4, 7, 8], [0, 1, 5, 6, 8], [0, 1, 5, 7, 8], [0, 1, 6, 7, 8], [0, 2, 3, 4, 8], [0, 2, 3, 5, 8], [0, 2, 3, 6, 8], [0, 2, 3, 7, 8], [0, 2, 4, 5, 8], [0, 2, 4, 6, 8], [0, 2, 4, 7, 8], [0, 2, 5, 6, 8], [0, 2, 5, 7, 8], [0, 2, 6, 7, 8], [0, 3, 4, 5, 8], [0, 3, 4, 6, 8], [0, 3, 4, 7, 8], [0, 3, 5, 6, 8], [0, 3, 5, 7, 8], [0, 3, 6, 7, 8], [0, 4, 5, 6, 8], [0, 4, 5, 7, 8], [0, 4, 6, 7, 8], [0, 5, 6, 7, 8], [0, 1, 2, 3, 4, 8], [0, 1, 2, 3, 5, 8], [0, 1, 2, 3, 6, 8], [0, 1, 2, 3, 7, 8], [0, 1, 2, 4, 5, 8], [0, 1, 2, 4, 6, 8], [0, 1, 2, 4, 7, 8], [0, 1, 2, 5, 6, 8], [0, 1, 2, 5, 7, 8], [0, 1, 2, 6, 7, 8], [0, 1, 3, 4, 5, 8], [0, 1, 3, 4, 6, 8], [0, 1, 3, 4, 7, 8], [0, 1, 3, 5, 6, 8], [0, 1, 3, 5, 7, 8], [0, 1, 3, 6, 7, 8], [0, 1, 4, 5, 6, 8], [0, 1, 4, 5, 7, 8], [0, 1, 4, 6, 7, 8], [0, 1, 5, 6, 7, 8], [0, 2, 3, 4, 5, 8], [0, 2, 3, 4, 6, 8], [0, 2, 3, 4, 7, 8], [0, 2, 3, 5, 6, 8], [0, 2, 3, 5, 7, 8], [0, 2, 3, 6, 7, 8], [0, 2, 4, 5, 6, 8], [0, 2, 4, 5, 7, 8], [0, 2, 4, 6, 7, 8], [0, 2, 5, 6, 7, 8], [0, 3, 4, 5, 6, 8], [0, 3, 4, 5, 7, 8], [0, 3, 4, 6, 7, 8], [0, 3, 5, 6, 7, 8], [0, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 8], [0, 1, 2, 3, 4, 6, 8], [0, 1, 2, 3, 4, 7, 8], [0, 1, 2, 3, 5, 6, 8], [0, 1, 2, 3, 5, 7, 8], [0, 1, 2, 3, 6, 7, 8], [0, 1, 2, 4, 5, 6, 8], [0, 1, 2, 4, 5, 7, 8], [0, 1, 2, 4, 6, 7, 8], [0, 1, 2, 5, 6, 7, 8], [0, 1, 3, 4, 5, 6, 8], [0, 1, 3, 4, 5, 7, 8], [0, 1, 3, 4, 6, 7, 8], [0, 1, 3, 5, 6, 7, 8], [0, 1, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 6, 8], [0, 2, 3, 4, 5, 7, 8], [0, 2, 3, 4, 6, 7, 8], [0, 2, 3, 5, 6, 7, 8], [0, 2, 4, 5, 6, 7, 8], [0, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 8], [0, 1, 2, 3, 4, 5, 7, 8], [0, 1, 2, 3, 4, 6, 7, 8], [0, 1, 2, 3, 5, 6, 7, 8], [0, 1, 2, 4, 5, 6, 7, 8], [0, 1, 3, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8]])\n assert answers_match(candidate(graph=[[1], [2, 3, 4], [3, 4], [4], [], [6, 7], [7], []]), [])\n assert answers_match(candidate(graph=[[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7], [4, 5, 6, 7], [5, 6, 7], [6, 7], [7], []]), [[0, 7], [0, 1, 7], [0, 2, 7], [0, 3, 7], [0, 4, 7], [0, 5, 7], [0, 6, 7], [0, 1, 2, 7], [0, 1, 3, 7], [0, 1, 4, 7], [0, 1, 5, 7], [0, 1, 6, 7], [0, 2, 3, 7], [0, 2, 4, 7], [0, 2, 5, 7], [0, 2, 6, 7], [0, 3, 4, 7], [0, 3, 5, 7], [0, 3, 6, 7], [0, 4, 5, 7], [0, 4, 6, 7], [0, 5, 6, 7], [0, 1, 2, 3, 7], [0, 1, 2, 4, 7], [0, 1, 2, 5, 7], [0, 1, 2, 6, 7], [0, 1, 3, 4, 7], [0, 1, 3, 5, 7], [0, 1, 3, 6, 7], [0, 1, 4, 5, 7], [0, 1, 4, 6, 7], [0, 1, 5, 6, 7], [0, 2, 3, 4, 7], [0, 2, 3, 5, 7], [0, 2, 3, 6, 7], [0, 2, 4, 5, 7], [0, 2, 4, 6, 7], [0, 2, 5, 6, 7], [0, 3, 4, 5, 7], [0, 3, 4, 6, 7], [0, 3, 5, 6, 7], [0, 4, 5, 6, 7], [0, 1, 2, 3, 4, 7], [0, 1, 2, 3, 5, 7], [0, 1, 2, 3, 6, 7], [0, 1, 2, 4, 5, 7], [0, 1, 2, 4, 6, 7], [0, 1, 2, 5, 6, 7], [0, 1, 3, 4, 5, 7], [0, 1, 3, 4, 6, 7], [0, 1, 3, 5, 6, 7], [0, 1, 4, 5, 6, 7], [0, 2, 3, 4, 5, 7], [0, 2, 3, 4, 6, 7], [0, 2, 3, 5, 6, 7], [0, 2, 4, 5, 6, 7], [0, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])\n assert answers_match(candidate(graph=[[1, 3], [2], [3, 4], [4], []]), [[0, 3, 4], [0, 1, 2, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2, 5], [3, 4], [5], [4], [], []]), [[0, 5], [0, 2, 5]])\n assert answers_match(candidate(graph=[[1, 2], [3, 4, 5], [3, 4, 5], [6, 7], [6, 7], [6, 7], [8], [8], [9], []]), [[0, 1, 3, 6, 8, 9], [0, 1, 3, 7, 8, 9], [0, 1, 4, 6, 8, 9], [0, 1, 4, 7, 8, 9], [0, 1, 5, 6, 8, 9], [0, 1, 5, 7, 8, 9], [0, 2, 3, 6, 8, 9], [0, 2, 3, 7, 8, 9], [0, 2, 4, 6, 8, 9], [0, 2, 4, 7, 8, 9], [0, 2, 5, 6, 8, 9], [0, 2, 5, 7, 8, 9]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14]]), [[0, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3], [3, 4], [4], [5], []]), [[0, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3], [3, 4, 5, 6], [5, 6], [6], [], []]), [[0, 2, 6], [0, 3, 6], [0, 4, 6], [0, 1, 2, 6], [0, 1, 3, 6], [0, 2, 3, 6], [0, 2, 4, 6], [0, 1, 2, 3, 6], [0, 1, 2, 4, 6]])\n assert answers_match(candidate(graph=[[1], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5], []]), [[0, 1, 5], [0, 1, 2, 5], [0, 1, 3, 5], [0, 1, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1, 4, 5], [2, 3, 4], [3], [4], [], []]), [[0, 5]])\n assert answers_match(candidate(graph=[[1], [2, 3], [3, 4], [4], [], [6], [7], []]), [])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3, 4], [3, 4], [4], [5, 6, 7], [6, 7], [7], [], [], []]), [])\n assert answers_match(candidate(graph=[[1, 2], [3, 4], [5], [5], [5], []]), [[0, 2, 5], [0, 1, 3, 5], [0, 1, 4, 5]])\n assert answers_match(candidate(graph=[[1], [2], [3], [4], [5], [6], [7], []]), [[0, 1, 2, 3, 4, 5, 6, 7]])\n assert answers_match(candidate(graph=[[1, 2, 4], [2, 3], [3, 4], [], [5], []]), [[0, 4, 5], [0, 2, 4, 5], [0, 1, 2, 4, 5]])\n assert answers_match(candidate(graph=[[1, 2], [2, 3, 4, 5], [3, 5], [4, 5, 6], [5, 6], [6], []]), [[0, 1, 3, 6], [0, 1, 4, 6], [0, 1, 5, 6], [0, 2, 3, 6], [0, 2, 5, 6], [0, 1, 2, 3, 6], [0, 1, 2, 5, 6], [0, 1, 3, 4, 6], [0, 1, 3, 5, 6], [0, 1, 4, 5, 6], [0, 2, 3, 4, 6], [0, 2, 3, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 5, 6], [0, 1, 3, 4, 5, 6], [0, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])\n assert answers_match(candidate(graph=[[1, 2, 3, 4], [2, 3, 4], [3, 4], [4], [], [], [], [], []]), [])\n assert answers_match(candidate(graph=[[1, 2], [2, 3], [4], [4], []]), [[0, 2, 4], [0, 1, 2, 4], [0, 1, 3, 4]])\n assert answers_match(candidate(graph=[[1, 2, 3], [4, 5, 6, 7], [5, 6, 7], [5, 6, 7], [8], [8], [8], [8], []]), [[0, 1, 4, 8], [0, 1, 5, 8], [0, 1, 6, 8], [0, 1, 7, 8], [0, 2, 5, 8], [0, 2, 6, 8], [0, 2, 7, 8], [0, 3, 5, 8], [0, 3, 6, 8], [0, 3, 7, 8]])\n assert answers_match(candidate(graph=[[1, 2, 4], [3], [3, 4], [4], [5], []]), [[0, 4, 5], [0, 2, 4, 5], [0, 1, 3, 4, 5], [0, 2, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1], [2, 3, 4], [3, 4], [4], []]), [[0, 1, 4], [0, 1, 2, 4], [0, 1, 3, 4], [0, 1, 2, 3, 4]])\n assert answers_match(candidate(graph=[[1, 3, 5], [2, 4, 6], [3, 5], [4, 6, 7], [5, 7], [6, 7], [7], []]), [[0, 3, 7], [0, 5, 7], [0, 1, 4, 7], [0, 1, 6, 7], [0, 3, 4, 7], [0, 3, 6, 7], [0, 5, 6, 7], [0, 1, 2, 3, 7], [0, 1, 2, 5, 7], [0, 1, 4, 5, 7], [0, 3, 4, 5, 7], [0, 1, 2, 3, 4, 7], [0, 1, 2, 3, 6, 7], [0, 1, 2, 5, 6, 7], [0, 1, 4, 5, 6, 7], [0, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 7], [0, 1, 2, 3, 4, 5, 6, 7]])\n assert answers_match(candidate(graph=[[1, 2], [3], [3], [5, 6], [6], [7], [7], []]), [[0, 1, 3, 5, 7], [0, 1, 3, 6, 7], [0, 2, 3, 5, 7], [0, 2, 3, 6, 7]])\n assert answers_match(candidate(graph=[[1, 2], [2, 3], [3, 4, 5], [4, 5, 6], [5, 6], [6], [7], []]), [[0, 1, 3, 6, 7], [0, 2, 3, 6, 7], [0, 2, 4, 6, 7], [0, 2, 5, 6, 7], [0, 1, 2, 3, 6, 7], [0, 1, 2, 4, 6, 7], [0, 1, 2, 5, 6, 7], [0, 1, 3, 4, 6, 7], [0, 1, 3, 5, 6, 7], [0, 2, 3, 4, 6, 7], [0, 2, 3, 5, 6, 7], [0, 2, 4, 5, 6, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])\n assert answers_match(candidate(graph=[[1, 2], [3, 4], [3], [5], [5], []]), [[0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 3, 5]])\n assert answers_match(candidate(graph=[[1, 2, 3], [2, 3, 4], [4], [4, 5], [5], []]), [[0, 3, 5], [0, 1, 3, 5], [0, 1, 4, 5], [0, 2, 4, 5], [0, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 3, 4, 5]])\n assert answers_match(candidate(graph=[[1, 2, 3], [4, 5], [4, 5], [5], [], [], []]), [])\n", "comparison": "unordered"}, "public_tests": ["[[1,2],[3],[3],[]]", "[[4,3,1],[3,2,4],[3],[4],[]]"], "hints": [], "metadata": {"canonical_parameter_names": ["graph"], "leetcode_dataset_entry_point": "Solution().allPathsSourceTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:59+00:00", "tests_total": 72, "tests_dropped": 0, "flags": ["any_order", "has_images"], "topic_tags": ["backtracking", "depth-first-search", "breadth-first-search", "graph", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def allPathsSourceTarget(self, graph: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "allPathsSourceTarget", "parameters": [{"name": "graph", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 798, "task_id": "smallest-rotation-with-highest-score", "difficulty": "Hard", "problem_description": "You are given an array nums. You can rotate it by a non-negative integer k so that the array becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]. Afterward, any entries that are less than or equal to their index are worth one point.\n\n- For example, if we have nums = [2,4,1,3,0], and we rotate by k = 2, it becomes [1,3,0,2,4]. This is worth 3 points because 1 > 0 [no points], 3 > 1 [no points], 0 <= 2 [one point], 2 <= 3 [one point], 4 <= 4 [one point].\n\nReturn the rotation index k that corresponds to the highest score we can achieve if we rotated nums by it. If there are multiple answers, return the smallest such index k.\n\nExample 1:\n\nInput: nums = [2,3,1,4,0]\nOutput: 3\nExplanation: Scores for each k are listed below:\nk = 0, nums = [2,3,1,4,0], score 2\nk = 1, nums = [3,1,4,0,2], score 3\nk = 2, nums = [1,4,0,2,3], score 3\nk = 3, nums = [4,0,2,3,1], score 4\nk = 4, nums = [0,2,3,1,4], score 3\nSo we should choose k = 3, which has the highest score.\n\nExample 2:\n\nInput: nums = [1,3,0,2,4]\nOutput: 0\nExplanation: nums will always have 3 points no matter how it shifts.\nSo we will choose the smallest k, which is 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] < nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 0, 2, 4]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4]) == 0\n assert candidate(nums = [1, 0, 3, 4, 2]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [1, 0, 2, 3, 4]) == 0\n assert candidate(nums = [3, 2, 1, 0, 4]) == 0\n assert candidate(nums = [2, 3, 1, 4, 0]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [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 = [2, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [2, 1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 0\n assert candidate(nums = [2, 5, 1, 6, 3, 0, 4]) == 1\n assert candidate(nums = [10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 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]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [2, 3, 1, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 18\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3]) == 0\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 5, 4, 3, 2]) == 7\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 1\n assert candidate(nums = [5, 0, 4, 1, 3, 2, 2, 3, 1, 4, 0, 5]) == 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]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 2, 3, 4, 0, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [3, 0, 1, 2, 5, 4, 7, 6, 9, 8]) == 9\n assert candidate(nums = [9, 7, 5, 3, 1, 0, 8, 6, 4, 2]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]) == 0\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 5\n assert candidate(nums = [9, 7, 6, 5, 4, 3, 2, 1, 0, 8]) == 0\n assert candidate(nums = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 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]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 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, 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]) == 99\n assert candidate(nums = [2, 1, 4, 3, 0, 5, 6]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 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\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 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, 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]) == 0\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [5, 6, 1, 2, 3, 4, 0, 1, 2, 3]) == 1\n assert candidate(nums = [4, 3, 2, 1, 0, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 0\n assert candidate(nums = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == 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]) == 1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 2\n assert candidate(nums = [1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == 0\n assert candidate(nums = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8]) == 1\n assert candidate(nums = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 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\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [2, 0, 1, 0, 2, 1, 0, 2, 1, 0]) == 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]) == 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\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 = [5, 1, 3, 4, 2, 0, 7, 6, 8, 9]) == 9\n assert candidate(nums = [5, 3, 1, 2, 4, 0]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 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\n assert candidate(nums = [2, 6, 1, 5, 0, 4, 3]) == 1\n assert candidate(nums = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9]) == 9\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", "comparison": "exact"}, "public_tests": ["[2,3,1,4,0]", "[1,3,0,2,4]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().bestRotation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:01+00:00", "tests_total": 94, "tests_dropped": 11, "flags": ["multiple_answers"], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def bestRotation(self, nums: list[int]) -> int:", "container": "Solution", "callable": "bestRotation", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 799, "task_id": "champagne-tower", "difficulty": "Medium", "problem_description": "We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100^th row. Each glass holds one cup of champagne.\n\nThen, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to the glass immediately to the left and right of it. When those glasses become full, any excess champagne will fall equally to the left and right of those glasses, and so on. (A glass at the bottom row has its excess champagne fall on the floor.)\n\nFor example, after one cup of champagne is poured, the top most glass is full. After two cups of champagne are poured, the two glasses on the second row are half full. After three cups of champagne are poured, those two cups become full - there are 3 full glasses total now. After four cups of champagne are poured, the third row has the middle glass half full, and the two outside glasses are a quarter full, as pictured below.\n\nNow after pouring some non-negative integer cups of champagne, return how full the j^th glass in the i^th row is (both i and j are 0-indexed.)\n\nExample 1:\n\nInput: poured = 1, query_row = 1, query_glass = 1\nOutput: 0.00000\nExplanation: We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.\n\nExample 2:\n\nInput: poured = 2, query_row = 1, query_glass = 1\nOutput: 0.50000\nExplanation: We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.\n\nExample 3:\n\nInput: poured = 100000009, query_row = 33, query_glass = 17\nOutput: 1.00000\n\nConstraints:\n\n- 0 <= poured <= 10^9\n- 0 <= query_glass <= query_row < 100\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(poured=100, query_row=99, query_glass=50), 0)\n assert answers_match(candidate(poured=10, query_row=2, query_glass=1), 1)\n assert answers_match(candidate(poured=3, query_row=2, query_glass=0), 0)\n assert answers_match(candidate(poured=5, query_row=2, query_glass=2), 0.5)\n assert answers_match(candidate(poured=100, query_row=9, query_glass=4), 1)\n assert answers_match(candidate(poured=100000009, query_row=33, query_glass=17), 1)\n assert answers_match(candidate(poured=1, query_row=1, query_glass=1), 0)\n assert answers_match(candidate(poured=100, query_row=4, query_glass=2), 1)\n assert answers_match(candidate(poured=10, query_row=4, query_glass=2), 0.625)\n assert answers_match(candidate(poured=2, query_row=1, query_glass=1), 0.5)\n assert answers_match(candidate(poured=100, query_row=4, query_glass=3), 1)\n assert answers_match(candidate(poured=10, query_row=3, query_glass=2), 1)\n assert answers_match(candidate(poured=10, query_row=5, query_glass=2), 0)\n assert answers_match(candidate(poured=1000000000, query_row=99, query_glass=50), 1)\n assert answers_match(candidate(poured=0, query_row=0, query_glass=0), 0)\n assert answers_match(candidate(poured=5, query_row=2, query_glass=1), 1.0)\n assert answers_match(candidate(poured=600, query_row=40, query_glass=30), 0)\n assert answers_match(candidate(poured=500000000, query_row=65, query_glass=33), 1)\n assert answers_match(candidate(poured=20, query_row=7, query_glass=3), 0.21875)\n assert answers_match(candidate(poured=20000, query_row=40, query_glass=35), 0)\n assert answers_match(candidate(poured=50, query_row=7, query_glass=4), 1)\n assert answers_match(candidate(poured=300, query_row=25, query_glass=15), 1)\n assert answers_match(candidate(poured=20, query_row=7, query_glass=5), 0)\n assert answers_match(candidate(poured=2000, query_row=25, query_glass=20), 0)\n assert answers_match(candidate(poured=50000, query_row=45, query_glass=40), 0)\n assert answers_match(candidate(poured=100000, query_row=45, query_glass=23), 1)\n assert answers_match(candidate(poured=50000, query_row=30, query_glass=25), 1)\n assert answers_match(candidate(poured=350, query_row=50, query_glass=45), 0)\n assert answers_match(candidate(poured=50000, query_row=45, query_glass=23), 1)\n assert answers_match(candidate(poured=400, query_row=55, query_glass=50), 0)\n assert answers_match(candidate(poured=2000000, query_row=65, query_glass=33), 1)\n assert answers_match(candidate(poured=10000, query_row=40, query_glass=25), 1)\n assert answers_match(candidate(poured=5000, query_row=30, query_glass=18), 1)\n assert answers_match(candidate(poured=25, query_row=8, query_glass=6), 0)\n assert answers_match(candidate(poured=1200, query_row=70, query_glass=60), 0)\n assert answers_match(candidate(poured=100, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=500, query_row=65, query_glass=60), 0)\n assert answers_match(candidate(poured=50000000, query_row=55, query_glass=28), 1)\n assert answers_match(candidate(poured=200, query_row=25, query_glass=12), 1)\n assert answers_match(candidate(poured=5, query_row=3, query_glass=2), 0)\n assert answers_match(candidate(poured=400, query_row=10, query_glass=8), 1)\n assert answers_match(candidate(poured=250, query_row=20, query_glass=10), 1)\n assert answers_match(candidate(poured=10000, query_row=35, query_glass=30), 0)\n assert answers_match(candidate(poured=200, query_row=9, query_glass=7), 1)\n assert answers_match(candidate(poured=1000, query_row=99, query_glass=95), 0)\n assert answers_match(candidate(poured=15, query_row=4, query_glass=2), 1)\n assert answers_match(candidate(poured=20, query_row=4, query_glass=4), 0.3125)\n assert answers_match(candidate(poured=10000000, query_row=70, query_glass=35), 1)\n assert answers_match(candidate(poured=375, query_row=85, query_glass=80), 0)\n assert answers_match(candidate(poured=750, query_row=90, query_glass=85), 0)\n assert answers_match(candidate(poured=1000, query_row=9, query_glass=4), 1)\n assert answers_match(candidate(poured=1800, query_row=99, query_glass=99), 0)\n assert answers_match(candidate(poured=150, query_row=8, query_glass=4), 1)\n assert answers_match(candidate(poured=500, query_row=20, query_glass=10), 1)\n assert answers_match(candidate(poured=1000000, query_row=40, query_glass=20), 1)\n assert answers_match(candidate(poured=250, query_row=40, query_glass=35), 0)\n assert answers_match(candidate(poured=100000000, query_row=60, query_glass=30), 1)\n assert answers_match(candidate(poured=200000, query_row=40, query_glass=35), 0)\n assert answers_match(candidate(poured=500, query_row=35, query_glass=25), 0)\n assert answers_match(candidate(poured=450, query_row=60, query_glass=55), 0)\n assert answers_match(candidate(poured=50000000, query_row=80, query_glass=60), 1)\n assert answers_match(candidate(poured=150, query_row=20, query_glass=15), 0)\n assert answers_match(candidate(poured=5000000, query_row=45, query_glass=23), 1)\n assert answers_match(candidate(poured=10000000, query_row=70, query_glass=55), 0.6195281249608406)\n assert answers_match(candidate(poured=400, query_row=40, query_glass=35), 0)\n assert answers_match(candidate(poured=1000, query_row=20, query_glass=15), 1)\n assert answers_match(candidate(poured=300, query_row=45, query_glass=40), 0)\n assert answers_match(candidate(poured=10000, query_row=30, query_glass=15), 1)\n assert answers_match(candidate(poured=40, query_row=10, query_glass=8), 0)\n assert answers_match(candidate(poured=700, query_row=70, query_glass=65), 0)\n assert answers_match(candidate(poured=5000, query_row=20, query_glass=15), 1)\n assert answers_match(candidate(poured=1000, query_row=60, query_glass=50), 0)\n assert answers_match(candidate(poured=7, query_row=4, query_glass=2), 0)\n assert answers_match(candidate(poured=10000, query_row=25, query_glass=20), 1)\n assert answers_match(candidate(poured=100, query_row=7, query_glass=5), 1)\n assert answers_match(candidate(poured=200, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=500000, query_row=55, query_glass=28), 1)\n assert answers_match(candidate(poured=100000000, query_row=90, query_glass=65), 1)\n assert answers_match(candidate(poured=200000, query_row=80, query_glass=45), 1)\n assert answers_match(candidate(poured=425, query_row=95, query_glass=90), 0)\n assert answers_match(candidate(poured=1000, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=1024, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=600, query_row=75, query_glass=70), 0)\n assert answers_match(candidate(poured=200, query_row=35, query_glass=30), 0)\n assert answers_match(candidate(poured=25, query_row=15, query_glass=10), 0)\n assert answers_match(candidate(poured=1100, query_row=65, query_glass=55), 0)\n assert answers_match(candidate(poured=300, query_row=9, query_glass=6), 1)\n assert answers_match(candidate(poured=100000000, query_row=90, query_glass=45), 1)\n assert answers_match(candidate(poured=50, query_row=15, query_glass=10), 0)\n assert answers_match(candidate(poured=1400, query_row=80, query_glass=70), 0)\n assert answers_match(candidate(poured=50, query_row=4, query_glass=2), 1)\n assert answers_match(candidate(poured=175, query_row=45, query_glass=40), 0)\n assert answers_match(candidate(poured=5000, query_row=25, query_glass=12), 1)\n assert answers_match(candidate(poured=1700, query_row=95, query_glass=85), 0)\n assert answers_match(candidate(poured=1023, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=200000, query_row=50, query_glass=25), 1)\n assert answers_match(candidate(poured=50000, query_row=25, query_glass=12), 1)\n assert answers_match(candidate(poured=1000000000, query_row=70, query_glass=35), 1)\n assert answers_match(candidate(poured=10000, query_row=20, query_glass=10), 1)\n assert answers_match(candidate(poured=275, query_row=65, query_glass=60), 0)\n assert answers_match(candidate(poured=325, query_row=75, query_glass=70), 0)\n assert answers_match(candidate(poured=900, query_row=99, query_glass=98), 0)\n assert answers_match(candidate(poured=5, query_row=3, query_glass=1), 0)\n assert answers_match(candidate(poured=500, query_row=15, query_glass=7), 1)\n assert answers_match(candidate(poured=100000, query_row=35, query_glass=30), 0)\n assert answers_match(candidate(poured=1000000, query_row=50, query_glass=45), 0)\n assert answers_match(candidate(poured=10000, query_row=40, query_glass=20), 1)\n assert answers_match(candidate(poured=400, query_row=30, query_glass=20), 0.12409851141273975)\n assert answers_match(candidate(poured=5000000, query_row=70, query_glass=35), 1)\n assert answers_match(candidate(poured=999999999, query_row=99, query_glass=49), 1)\n assert answers_match(candidate(poured=950, query_row=99, query_glass=99), 0)\n assert answers_match(candidate(poured=50, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=150, query_row=30, query_glass=25), 0)\n assert answers_match(candidate(poured=100000, query_row=50, query_glass=45), 0)\n assert answers_match(candidate(poured=300, query_row=30, query_glass=25), 0)\n assert answers_match(candidate(poured=50, query_row=7, query_glass=5), 1)\n assert answers_match(candidate(poured=900, query_row=90, query_glass=85), 0)\n assert answers_match(candidate(poured=5000, query_row=15, query_glass=8), 1)\n assert answers_match(candidate(poured=500, query_row=30, query_glass=15), 1)\n assert answers_match(candidate(poured=60, query_row=20, query_glass=15), 0)\n assert answers_match(candidate(poured=800, query_row=80, query_glass=75), 0)\n assert answers_match(candidate(poured=500000, query_row=60, query_glass=55), 0)\n assert answers_match(candidate(poured=75, query_row=25, query_glass=20), 0)\n assert answers_match(candidate(poured=100000000, query_row=80, query_glass=40), 1)\n assert answers_match(candidate(poured=1000000, query_row=60, query_glass=30), 1)\n assert answers_match(candidate(poured=50000, query_row=40, query_glass=20), 1)\n assert answers_match(candidate(poured=15, query_row=5, query_glass=2), 0.875)\n assert answers_match(candidate(poured=20000, query_row=50, query_glass=30), 1)\n assert answers_match(candidate(poured=10000000, query_row=75, query_glass=38), 1)\n assert answers_match(candidate(poured=200, query_row=7, query_glass=3), 1)\n assert answers_match(candidate(poured=150, query_row=20, query_glass=10), 1)\n assert answers_match(candidate(poured=800, query_row=50, query_glass=40), 0)\n assert answers_match(candidate(poured=50, query_row=6, query_glass=2), 1)\n assert answers_match(candidate(poured=20000, query_row=35, query_glass=18), 1)\n assert answers_match(candidate(poured=20, query_row=5, query_glass=3), 1)\n assert answers_match(candidate(poured=100000, query_row=50, query_glass=25), 1)\n assert answers_match(candidate(poured=850, query_row=98, query_glass=95), 0)\n assert answers_match(candidate(poured=100000, query_row=70, query_glass=40), 1)\n assert answers_match(candidate(poured=100, query_row=5, query_glass=3), 1)\n assert answers_match(candidate(poured=1600, query_row=90, query_glass=80), 0)\n assert answers_match(candidate(poured=1000, query_row=35, query_glass=18), 1)\n assert answers_match(candidate(poured=15, query_row=6, query_glass=4), 0)\n assert answers_match(candidate(poured=500, query_row=50, query_glass=45), 0)\n assert answers_match(candidate(poured=30, query_row=9, query_glass=7), 0)\n assert answers_match(candidate(poured=2000, query_row=15, query_glass=10), 1)\n assert answers_match(candidate(poured=1000, query_row=25, query_glass=15), 1)\n assert answers_match(candidate(poured=200000, query_row=55, query_glass=50), 0)\n assert answers_match(candidate(poured=25, query_row=6, query_glass=4), 1)\n assert answers_match(candidate(poured=700, query_row=85, query_glass=80), 0)\n assert answers_match(candidate(poured=500, query_row=15, query_glass=10), 1)\n assert answers_match(candidate(poured=500000, query_row=90, query_glass=50), 1)\n assert answers_match(candidate(poured=550, query_row=70, query_glass=65), 0)\n assert answers_match(candidate(poured=800, query_row=95, query_glass=90), 0)\n assert answers_match(candidate(poured=1000, query_row=15, query_glass=7), 1)\n assert answers_match(candidate(poured=225, query_row=55, query_glass=50), 0)\n assert answers_match(candidate(poured=500, query_row=10, query_glass=5), 1)\n assert answers_match(candidate(poured=20000000, query_row=80, query_glass=40), 1)\n assert answers_match(candidate(poured=10000000, query_row=50, query_glass=25), 1)\n assert answers_match(candidate(poured=100000, query_row=30, query_glass=15), 1)\n assert answers_match(candidate(poured=2000, query_row=20, query_glass=10), 1)\n assert answers_match(candidate(poured=200, query_row=10, query_glass=6), 1)\n assert answers_match(candidate(poured=125, query_row=35, query_glass=30), 0)\n assert answers_match(candidate(poured=900, query_row=55, query_glass=45), 0)\n assert answers_match(candidate(poured=100, query_row=15, query_glass=7), 1)\n assert answers_match(candidate(poured=1500, query_row=85, query_glass=75), 0)\n assert answers_match(candidate(poured=100, query_row=25, query_glass=20), 0)\n assert answers_match(candidate(poured=500000, query_row=45, query_glass=40), 0)\n assert answers_match(candidate(poured=1300, query_row=75, query_glass=65), 0)\n assert answers_match(candidate(poured=650, query_row=80, query_glass=75), 0)\n assert answers_match(candidate(poured=100, query_row=5, query_glass=2), 1)\n assert answers_match(candidate(poured=7, query_row=2, query_glass=0), 1.0)\n assert answers_match(candidate(poured=50000000, query_row=85, query_glass=43), 1)\n assert answers_match(candidate(poured=1000, query_row=99, query_glass=99), 0)\n assert answers_match(candidate(poured=600, query_row=60, query_glass=55), 0)\n assert answers_match(candidate(poured=500000, query_row=35, query_glass=18), 1)\n assert answers_match(candidate(poured=700, query_row=45, query_glass=35), 0)\n assert answers_match(candidate(poured=50000, query_row=60, query_glass=35), 1)\n assert answers_match(candidate(poured=5000, query_row=30, query_glass=25), 0)\n assert answers_match(candidate(poured=200, query_row=15, query_glass=8), 1)\n assert answers_match(candidate(poured=100, query_row=8, query_glass=6), 1)\n assert answers_match(candidate(poured=1000000000, query_row=90, query_glass=45), 1)\n assert answers_match(candidate(poured=5000000, query_row=60, query_glass=50), 0)\n assert answers_match(candidate(poured=10, query_row=5, query_glass=3), 0)\n", "comparison": "float"}, "public_tests": ["0\n0\n0", "0\n1\n0", "0\n1\n1"], "hints": [], "metadata": {"canonical_parameter_names": ["poured", "query_row", "query_glass"], "leetcode_dataset_entry_point": "Solution().champagneTower", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:03+00:00", "tests_total": 183, "tests_dropped": 0, "flags": ["figure_reference", "decimal_answer", "has_images"], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def champagneTower(self, poured: int, query_row: int, query_glass: int) -> float:", "container": "Solution", "callable": "champagneTower", "parameters": [{"name": "poured", "type": "int"}, {"name": "query_row", "type": "int"}, {"name": "query_glass", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 801, "task_id": "minimum-swaps-to-make-sequences-increasing", "difficulty": "Hard", "problem_description": "You are given two integer arrays of the same length nums1 and nums2. In one operation, you are allowed to swap nums1[i] with nums2[i].\n\n- For example, if nums1 = [1,2,3,8], and nums2 = [5,6,7,4], you can swap the element at i = 3 to obtain nums1 = [1,2,3,4] and nums2 = [5,6,7,8].\n\nReturn the minimum number of needed operations to make nums1 and nums2 strictly increasing. The test cases are generated so that the given input always makes it possible.\n\nAn array arr is strictly increasing if and only if arr[0] < arr[1] < arr[2] < ... < arr[arr.length - 1].\n\nExample 1:\n\nInput: nums1 = [1,3,5,4], nums2 = [1,2,3,7]\nOutput: 1\nExplanation:\nSwap nums1[3] and nums2[3]. Then the sequences are:\nnums1 = [1, 3, 5, 7] and nums2 = [1, 2, 3, 4]\nwhich are both strictly increasing.\n\nExample 2:\n\nInput: nums1 = [0,3,5,8,9], nums2 = [2,1,4,6,9]\nOutput: 1\n\nConstraints:\n\n- 2 <= nums1.length <= 10^5\n- nums2.length == nums1.length\n- 0 <= nums1[i], nums2[i] <= 2 * 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 19, 14, 6, 7],nums2 = [6, 5, 8, 11, 10]) == 2\n assert candidate(nums1 = [0, 4, 4, 5, 9],nums2 = [0, 1, 6, 8, 10]) == 1\n assert candidate(nums1 = [10, 19, 18, 3],nums2 = [5, 5, 5, 4]) == 2\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]) == 2\n assert candidate(nums1 = [1, 3, 5, 4],nums2 = [1, 2, 3, 7]) == 1\n assert candidate(nums1 = [1, 100, 1, 100],nums2 = [2, 1, 2, 1]) == 2\n assert candidate(nums1 = [1, 100, 3, 100, 100],nums2 = [1, 101, 3, 101, 100]) == 2\n assert candidate(nums1 = [0, 3, 5, 8, 9],nums2 = [2, 1, 4, 6, 9]) == 1\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21],nums2 = [2, 6, 10, 14, 18, 22]) == 0\n assert candidate(nums1 = [1, 5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [0, 2, 3, 4, 5, 6, 7, 8, 9, 14]) == 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, 2, 1],nums2 = [6, 5, 4]) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],nums2 = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109]) == 0\n assert candidate(nums1 = [3, 20, 5, 9, 10, 11],nums2 = [1, 19, 4, 8, 12, 13]) == 1\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 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums1 = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],nums2 = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3]) == 5\n assert candidate(nums1 = [100, 200, 150, 300, 250],nums2 = [90, 180, 210, 270, 350]) == 2\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]) == 5\n assert candidate(nums1 = [3, 2, 1, 5, 6, 7, 8],nums2 = [4, 3, 2, 4, 5, 6, 7]) == 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, 21, 22, 23, 24, 25],nums2 = [2, 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(nums1 = [10, 30, 20, 50, 40, 70, 60],nums2 = [5, 25, 25, 45, 55, 65, 80]) == 3\n assert candidate(nums1 = [5, 3, 4, 4, 7, 8, 9],nums2 = [6, 4, 5, 5, 8, 7, 10]) == 3\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]) == 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, 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, 2]) == 16\n assert candidate(nums1 = [1, 5, 3, 9, 7, 11, 8],nums2 = [2, 4, 6, 8, 10, 9, 12]) == 3\n assert candidate(nums1 = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 5\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]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 5\n assert candidate(nums1 = [5, 7, 4, 8, 9, 10, 6, 11, 12, 13],nums2 = [6, 6, 5, 7, 10, 9, 7, 12, 11, 14]) == 3\n assert candidate(nums1 = [3, 9, 7, 11, 13, 15, 17, 19],nums2 = [2, 10, 8, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == 0\n assert candidate(nums1 = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15],nums2 = [4, 4, 7, 7, 10, 10, 13, 13, 16, 16]) == 5\n assert candidate(nums1 = [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],nums2 = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16]) == 7\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]) == 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]) == 5\n assert candidate(nums1 = [0, 2, 2, 3, 5, 6, 8, 9, 11],nums2 = [1, 1, 3, 4, 4, 7, 7, 10, 12]) == 3\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [99, 89, 79, 69, 59, 49, 39, 29, 19, 9]) == 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\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [11, 19, 31, 39, 51, 59, 71, 79, 91, 99]) == 0\n assert candidate(nums1 = [1, 3, 20, 4, 1, 5],nums2 = [1, 2, 5, 3, 7, 6]) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]) == 0\n assert candidate(nums1 = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 5\n assert candidate(nums1 = [4, 3, 2, 1],nums2 = [1, 2, 3, 4]) == 2\n assert candidate(nums1 = [1, 3, 2, 1, 4, 7, 8, 9, 10],nums2 = [2, 4, 1, 5, 5, 6, 7, 8, 9]) == 2\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]) == 5\n assert candidate(nums1 = [6, 8, 9, 2, 5],nums2 = [2, 7, 4, 8, 3]) == 2\n assert candidate(nums1 = [3, 12, 23, 45, 67, 89, 100],nums2 = [2, 13, 22, 46, 66, 90, 101]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40],nums2 = [6, 11, 14, 21, 24, 29, 36, 41]) == 0\n assert candidate(nums1 = [5, 3, 20, 15, 10, 25, 30],nums2 = [6, 7, 19, 14, 9, 24, 29]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 5\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]) == 0\n assert candidate(nums1 = [5, 2, 4, 6, 8, 10, 12],nums2 = [6, 1, 5, 7, 9, 11, 13]) == 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]) == 5\n assert candidate(nums1 = [1, 5, 3, 4, 2, 6, 7, 8, 9, 10],nums2 = [2, 4, 6, 5, 7, 8, 9, 10, 11, 12]) == 2\n assert candidate(nums1 = [1, 5, 3, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 1\n assert candidate(nums1 = [3, 2, 1, 4, 5, 6, 9, 8, 7, 10],nums2 = [1, 2, 3, 5, 4, 7, 6, 9, 8, 11]) == 4\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]) == 0\n assert candidate(nums1 = [1, 5, 4, 3, 2, 7, 8, 9, 10, 11],nums2 = [2, 4, 6, 7, 8, 9, 10, 11, 12, 13]) == 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]) == 5\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [11, 19, 29, 39, 49, 59, 69, 79, 89, 99]) == 0\n assert candidate(nums1 = [8, 4, 3, 6, 7, 5, 9],nums2 = [7, 5, 4, 9, 6, 8, 10]) == 2\n assert candidate(nums1 = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],nums2 = [1, 999, 1999, 2999, 3999, 4999, 5999, 6999, 7999, 8999]) == 0\n assert candidate(nums1 = [4, 5, 8, 11, 2, 10, 15],nums2 = [3, 7, 9, 10, 3, 9, 14]) == 1\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 5\n assert candidate(nums1 = [8, 10, 1, 11, 13, 15, 17],nums2 = [7, 9, 2, 12, 14, 16, 18]) == 1\n assert candidate(nums1 = [2, 5, 1, 10, 6],nums2 = [3, 4, 8, 9, 7]) == 2\n assert candidate(nums1 = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10],nums2 = [2, 4, 5, 3, 6, 5, 8, 7, 10, 9]) == 4\n assert candidate(nums1 = [2, 20, 18, 24, 22, 26, 24, 28, 26, 30],nums2 = [1, 19, 17, 23, 21, 25, 23, 27, 25, 29]) == 4\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]) == 0\n assert candidate(nums1 = [4, 9, 6, 5, 8],nums2 = [3, 8, 7, 4, 10]) == 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, 11]) == 0\n assert candidate(nums1 = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11],nums2 = [2, 4, 3, 6, 5, 8, 7, 10, 9, 12]) == 4\n assert candidate(nums1 = [1, 3, 2, 4, 5, 6, 8, 7, 9, 10],nums2 = [2, 1, 4, 3, 6, 5, 7, 8, 10, 9]) == 5\n assert candidate(nums1 = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],nums2 = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [1, 2, 3, 2, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10],nums2 = [11, 11, 11, 11, 11, 11]) == 3\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4],nums2 = [10, 9, 8, 7, 6, 5]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [2, 3, 1, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 7\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [5, 8, 3, 8, 9, 10, 12, 11, 14, 15],nums2 = [6, 7, 4, 7, 10, 9, 11, 12, 13, 16]) == 3\n assert candidate(nums1 = [8, 3, 9, 4, 6],nums2 = [5, 2, 7, 8, 1]) == 2\n assert candidate(nums1 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],nums2 = [11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 5\n assert candidate(nums1 = [8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8]) == 4\n assert candidate(nums1 = [3, 7, 5, 9, 12, 15],nums2 = [2, 8, 4, 11, 10, 16]) == 2\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [6, 14, 24, 34, 44, 54, 64, 74, 84, 94]) == 0\n assert candidate(nums1 = [6, 7, 8, 9, 10, 11, 12],nums2 = [5, 6, 7, 8, 9, 10, 11]) == 0\n assert candidate(nums1 = [1, 9, 4, 7, 8, 10],nums2 = [4, 3, 6, 5, 9, 11]) == 2\n assert candidate(nums1 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],nums2 = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 5\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]) == 5\n assert candidate(nums1 = [1, 3, 5, 4, 10, 12, 11, 15, 16],nums2 = [1, 2, 3, 7, 9, 11, 13, 14, 17]) == 2\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 0\n assert candidate(nums1 = [4, 3, 2, 1],nums2 = [1, 2, 3, 4]) == 2\n assert candidate(nums1 = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],nums2 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12]) == 5\n assert candidate(nums1 = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],nums2 = [6, 5, 4, 3, 2, 11, 10, 9, 8, 7]) == 4\n assert candidate(nums1 = [4, 5, 6, 7, 8, 9],nums2 = [3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums1 = [5, 2, 3, 8, 1],nums2 = [1, 3, 9, 2, 7]) == 2\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 5\n assert candidate(nums1 = [5, 6, 4, 9, 8, 11, 13],nums2 = [4, 7, 5, 8, 9, 12, 14]) == 2\n assert candidate(nums1 = [4, 10, 12, 15, 16, 20, 25, 30],nums2 = [3, 9, 11, 14, 17, 19, 24, 29]) == 0\n assert candidate(nums1 = [2, 1, 4, 6, 8, 10, 12],nums2 = [3, 2, 5, 7, 9, 11, 13]) == 1\n assert candidate(nums1 = [4, 3, 2, 1],nums2 = [8, 7, 6, 5]) == 2\n assert candidate(nums1 = [1, 9, 4, 8, 10, 7, 12, 6, 14],nums2 = [2, 8, 5, 9, 9, 8, 11, 7, 15]) == 3\n", "comparison": "exact"}, "public_tests": ["[1,3,5,4]\n[1,2,3,7]", "[0,3,5,8,9]\n[2,1,4,6,9]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minSwap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:08+00:00", "tests_total": 107, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minSwap(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "minSwap", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 802, "task_id": "find-eventual-safe-states", "difficulty": "Medium", "problem_description": "There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nodes adjacent to node i, meaning there is an edge from node i to each node in graph[i].\n\nA node is a terminal node if there are no outgoing edges. A node is a safe node if every possible path starting from that node leads to a terminal node (or another safe node).\n\nReturn an array containing all the safe nodes of the graph. The answer should be sorted in ascending order.\n\nExample 1:\n\nInput: graph = [[1,2],[2,3],[5],[0],[5],[],[]]\nOutput: [2,4,5,6]\nExplanation: The given graph is shown above.\nNodes 5 and 6 are terminal nodes as there are no outgoing edges from either of them.\nEvery path starting at nodes 2, 4, 5, and 6 all lead to either node 5 or 6.\n\nExample 2:\n\nInput: graph = [[1,2,3,4],[1,2],[3,4],[0,4],[]]\nOutput: [4]\nExplanation:\nOnly node 4 is a terminal node, and every path starting at node 4 leads to node 4.\n\nConstraints:\n\n- n == graph.length\n- 1 <= n <= 10^4\n- 0 <= graph[i].length <= n\n- 0 <= graph[i][j] <= n - 1\n- graph[i] is sorted in a strictly increasing order.\n- The graph may contain self-loops.\n- The number of edges in the graph will be in the range [1, 4 * 10^4].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(graph = [[1, 2, 3, 4], [1, 2], [3, 4], [0, 4], []]) == [4]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [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(graph = [[], [0, 2, 3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9], [7, 8, 9], [7, 8, 9], [7, 8, 9], [8, 9], [9], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(graph = [[], [0, 2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6], [5, 6], [6], []]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(graph = [[], [1], [2], [3], [4], [5], [6], [7], [8], [9], []]) == [0, 10]\n assert candidate(graph = [[], [0]]) == [0, 1]\n assert candidate(graph = [[1, 2], [2, 3], [3], [4], []]) == [0, 1, 2, 3, 4]\n assert candidate(graph = [[0], [2, 3, 4], [3, 4], [0, 4], []]) == [4]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [3, 8], [9], []]) == [8, 9]\n assert candidate(graph = [[1, 2], [2, 3], [5], [0], [5], [], []]) == [2, 4, 5, 6]\n assert candidate(graph = [[], [0, 2, 3, 4, 5], [3], [4, 5], [5], [], []]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [0]]) == []\n assert candidate(graph = [[], [2], [3], [4], [5], [], [5]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(graph = [[1], [2], [3], [4], []]) == [0, 1, 2, 3, 4]\n assert candidate(graph = [[0], [0]]) == []\n assert candidate(graph = [[], [], [], [], [], [], [], [], [], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [], [10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(graph = [[], [0, 2, 3, 4], [3], [4], []]) == [0, 1, 2, 3, 4]\n assert candidate(graph = [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], []]) == [4]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(graph = [[1], [0, 2], [2]]) == []\n assert candidate(graph = [[0, 1, 2], [2, 2, 3], [3], [4], []]) == [1, 2, 3, 4]\n assert candidate(graph = [[1, 2], [2, 4], [3], [6], [5], [6], []]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(graph = [[1], [2], [3], []]) == [0, 1, 2, 3]\n assert candidate(graph = [[5, 2, 5, 3, 2, 3], [2, 4, 2, 2], [4, 5, 2, 2, 2], [2], [0, 3, 0, 0, 2, 2], [0, 0, 2, 5, 2, 0]]) == []\n assert candidate(graph = [[1], [2], [0], [3], [3, 5], [4, 5, 6], [4, 6, 7], [5, 6, 8], [7, 9], [], [10, 11, 12], [10], [10, 12], [13, 14, 15], [13, 15], [14], [15], [], [], [], [], [16, 17, 18], [16, 18], [16, 17, 19], [20, 21], [20, 22], [20, 21, 22], [23, 24, 25], [23, 25], [23, 24, 25], [26], [27, 28, 29], [27, 29], [27, 28, 30], [31], [32, 33, 34], [32, 34], [32, 33, 35], [33, 35], [34, 35], []]) == [9, 17, 18, 19, 20, 40]\n assert candidate(graph = [[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], [], [28], [29], [30], [31], [32], [33], [34], [35], [36], [37], [38], [39], [40], [0]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(graph = [[], [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]\n assert candidate(graph = [[1, 2], [2, 3], [3, 4], [4, 0], [4]]) == []\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [0]]) == []\n assert candidate(graph = [[1, 2], [3], [3], [4], [5], [6], [5], [7], [8], [9], [10], [], [11], [], [13], [], [], [], [], [], []]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(graph = [[1, 2], [0, 3], [3, 4], [4, 1], [5], [], [4, 6]]) == [4, 5]\n assert candidate(graph = [[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, 0, 0, 0, 0]]) == []\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [0], [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], [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, 0]]) == []\n assert candidate(graph = [[], [2], [1], [3], [3, 4], [3, 5], [4, 7], [8], [], [], [], [7], [10], [11], [12], [], [14], [], [16], [17], [18], [19], [0]]) == [0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n assert candidate(graph = [[], [0], [0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [31], [32], [33], [34], [35], [36], [37], [38], [39], [40], [41], [42], [43], [44], [45], [46], [47], [48], [49], [50], [51], [52], [53], [54], [55], [56], [57], [58], [59], [60], [61], [62], [63], [64], [65], [66], [67], [68], [69], [70], [71], [72], [73], [74], [75], [76], [77], [78], [79], [80], [81], [82], [83], [84], [85], [86], [87], [88], [89], [90], [91], [92], [93], [94], [95], [96], [97], [98], [99]]) == [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, 101]\n assert candidate(graph = [[1], [2], [3], [4], [0], [6], [7], [8], [9], [10], [11], [12], [13], [14], [], [16], [], [18], [19], [20], [21], [0]]) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(graph = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], []]) == [4]\n assert candidate(graph = [[1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5], [6], [7], [8], [9], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(graph = [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == [0]\n assert candidate(graph = [[], [2, 2, 3], [2], [4], [5, 6, 7], [8, 9], [10], [10, 9, 8], [11], [12], [12], [13], [13], []]) == [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], []]) == [21]\n assert candidate(graph = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 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], [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(graph = [[1, 2, 3], [2, 3], [3], [4, 5, 6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [0], [0, 1], [2]]) == []\n assert candidate(graph = [[1, 2], [0], [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, 19], [19]]) == []\n assert candidate(graph = [[], [0], [0, 1], [2], [3], [3], [3], [4]]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(graph = [[4, 3, 1], [3, 2, 4], [3], [4], []]) == [0, 1, 2, 3, 4]\n assert candidate(graph = [[], [0, 2], [0, 3], [0, 4], [0]]) == [0, 1, 2, 3, 4]\n assert candidate(graph = [[], [1, 2], [1, 2], [1, 2], [3, 4], [4], [5], [5], [5], [5]]) == [0]\n assert candidate(graph = [[1, 2, 3, 4], [2, 3, 5], [0, 2, 3, 5], [0, 1, 2, 3, 6], [0, 1, 2, 5], [1, 2, 3, 4, 7], [], [8], [9], [8]]) == [6]\n assert candidate(graph = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13], [12, 13, 14], [13, 14, 15], [14, 15, 16], [15, 16, 17], [16, 17, 18], [17, 18, 19], [18, 19, 0], [19, 1], [0, 2]]) == []\n assert candidate(graph = [[1, 3], [2], [3, 4], [5], [6], [7], [8], [9], [], [1]]) == [4, 6, 8]\n assert candidate(graph = [[1, 2], [0, 3], [4, 5], [4, 6], [7], [7], [7], []]) == [2, 3, 4, 5, 6, 7]\n assert candidate(graph = [[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, 10, 11], [9, 10, 11, 12], [10, 11, 12, 13], [11, 12, 13, 14], [12, 13, 14, 15], [13, 14, 15, 16], [14, 15, 16, 17], [15, 16, 17, 18], [16, 17, 18, 19], [17, 18, 19, 0], [18, 19, 0, 1], [19, 0, 1, 2], [0, 1, 2, 3]]) == []\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [3, 8], [9, 10], [10], [10, 11], [12], [13], [14], [15], [16], [17], [18], [19], [20, 21, 22], [20, 22], [20, 21, 22], [23, 24, 25], [23, 25], [23, 24, 25], [26], [27, 28, 29], [27, 29], [27, 28, 30], [31], [32, 33, 34], [32, 34], [32, 33, 35], [33, 35], [34, 35], [36], [37, 38, 39], [37, 39], [37, 38, 40], [41], [42, 43, 44], [42, 44], [42, 43, 45], [43, 45], [44, 45], [46], [47, 48, 49], [47, 49], [47, 48, 50], [51], [52, 53, 54], [52, 54], [52, 53, 55], [53, 55], [54, 55], []]) == [55]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [3, 8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [20]]) == [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 31]\n assert candidate(graph = [[1, 2], [2, 3], [3, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], []]) == [20]\n assert candidate(graph = [[1, 2, 3], [2, 3], [3], []]) == [0, 1, 2, 3]\n assert candidate(graph = [[1, 2, 3], [0, 2], [3], [4], [5], [], [5], [8], [9], [8], [11], [12], [], [10]]) == [2, 3, 4, 5, 6, 10, 11, 12, 13]\n assert candidate(graph = [[1, 2, 3], [2], [0], [4], []]) == [3, 4]\n assert candidate(graph = [[1], [2], [3], [4], [3], [6], [5], [7], [7], [8], [], [9], [10], [11], [12], [], [14], [], [16], [17], [18], [19], [0]]) == [10, 12, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(graph = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13], [12, 13, 14], [13, 14, 15], [14, 15, 16], [15, 16, 17], [16, 17, 18], [17, 18, 19], [], [], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [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(graph = [[1, 2], [0, 3], [4, 5], [6], [5], [6, 7], [7], [8, 9], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [10]]) == []\n assert candidate(graph = [[], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], []]) == [0, 21]\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[5],[0],[5],[],[]]", "[[1,2,3,4],[1,2],[3,4],[0,4],[]]"], "hints": [], "metadata": {"canonical_parameter_names": ["graph"], "leetcode_dataset_entry_point": "Solution().eventualSafeNodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:11+00:00", "tests_total": 81, "tests_dropped": 14, "flags": ["figure_reference", "has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph", "topological-sort", "kosarajus-algorithm", "tarjans-scc-algorithm"]}, "language": "python", "interface": {"raw_signature": "def eventualSafeNodes(self, graph: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "eventualSafeNodes", "parameters": [{"name": "graph", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 803, "task_id": "bricks-falling-when-hit", "difficulty": "Hard", "problem_description": "You are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space. A brick is stable if:\n\n- It is directly connected to the top of the grid, or\n- At least one other brick in its four adjacent cells is stable.\n\nYou are also given an array hits, which is a sequence of erasures we want to apply. Each time we want to erase the brick at the location hits[i] = (row_i, col_i). The brick on that location (if it exists) will disappear. Some other bricks may no longer be stable because of that erasure and will fall. Once a brick falls, it is immediately erased from the grid (i.e., it does not land on other stable bricks).\n\nReturn an array result, where each result[i] is the number of bricks that will fall after the i^th erasure is applied.\n\nNote that an erasure may refer to a location with no brick, and if it does, no bricks drop.\n\nExample 1:\n\nInput: grid = [[1,0,0,0],[1,1,1,0]], hits = [[1,0]]\nOutput: [2]\nExplanation: Starting with the grid:\n[[1,0,0,0],\n [1,1,1,0]]\nWe erase the underlined brick at (1,0), resulting in the grid:\n[[1,0,0,0],\n [0,1,1,0]]\nThe two underlined bricks are no longer stable as they are no longer connected to the top nor adjacent to another stable brick, so they will fall. The resulting grid is:\n[[1,0,0,0],\n [0,0,0,0]]\nHence the result is [2].\n\nExample 2:\n\nInput: grid = [[1,0,0,0],[1,1,0,0]], hits = [[1,1],[1,0]]\nOutput: [0,0]\nExplanation: Starting with the grid:\n[[1,0,0,0],\n [1,1,0,0]]\nWe erase the underlined brick at (1,1), resulting in the grid:\n[[1,0,0,0],\n [1,0,0,0]]\nAll remaining bricks are still stable, so no bricks fall. The grid remains the same:\n[[1,0,0,0],\n [1,0,0,0]]\nNext, we erase the underlined brick at (1,0), resulting in the grid:\n[[1,0,0,0],\n [0,0,0,0]]\nOnce again, all remaining bricks are still stable, so no bricks fall.\nHence the result is [0,0].\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 200\n- grid[i][j] is 0 or 1.\n- 1 <= hits.length <= 4 * 10^4\n- hits[i].length == 2\n- 0 <= x_i<= m - 1\n- 0 <= y_i <= n - 1\n- All (x_i, y_i) are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 1, 0]],hits = [[0, 0], [1, 1], [2, 2]]) == [4, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [0, 1, 0, 1], [1, 1, 1, 1]],hits = [[1, 0], [1, 2]]) == [0, 0]\n assert candidate(grid = [[1, 0, 1], [1, 1, 1]],hits = [[0, 0], [0, 2]]) == [0, 3]\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 1, 0]],hits = [[1, 0]]) == [2]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],hits = [[0, 0], [0, 1], [0, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[1, 1]]) == [0]\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 0, 0]],hits = [[1, 1], [1, 0]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],hits = [[1, 0]]) == [0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[1, 1], [1, 2], [1, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 0, 1, 0], [0, 0, 1, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0]],hits = [[0, 0], [1, 2], [2, 1], [3, 1], [4, 0]]) == [10, 0, 0, 0, 0]\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]],hits = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0]],hits = [[0, 2], [0, 4], [2, 3], [4, 2]]) == [0, 0, 0, 0]\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, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],hits = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [0, 0, 6, 0, 0, 0, 7, 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]],hits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 1, 0]],hits = [[0, 1], [2, 3], [4, 1]]) == [0, 0, 0]\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], [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]],hits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [0, 0, 0, 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]],hits = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0], [1, 1, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 5, 0, 0]\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 1, 1, 0, 1], [0, 0, 0, 1, 1], [1, 0, 0, 1, 1]],hits = [[0, 0], [2, 4], [1, 2], [3, 1], [2, 3]]) == [0, 3, 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, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],hits = [[0, 0], [0, 6], [4, 0], [4, 6]]) == [0, 0, 0, 0]\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]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]],hits = [[1, 2], [2, 3], [3, 4]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 0, 1, 1, 1, 1]],hits = [[0, 0], [0, 9], [2, 0], [2, 9], [4, 0], [4, 9]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [1, 0, 0, 1, 1], [1, 1, 1, 1, 1]],hits = [[0, 1], [1, 2], [2, 1], [3, 3], [4, 4]]) == [0, 13, 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]],hits = [[0, 0], [0, 4], [4, 0], [4, 4], [1, 1], [2, 2], [3, 3]]) == [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, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],hits = [[2, 3], [3, 3], [4, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1]],hits = [[1, 1], [1, 2], [1, 3], [1, 4]]) == [0, 0, 0, 0]\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]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 5], [1, 4], [2, 3], [3, 2]]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],hits = [[1, 1], [1, 9], [3, 1], [3, 9], [5, 1], [5, 9]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [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, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],hits = [[0, 0], [0, 9], [4, 0], [4, 9], [2, 2], [2, 7], [1, 1], [1, 8], [3, 3], [3, 6]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]],hits = [[1, 1], [1, 2], [1, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[2, 2], [1, 1], [3, 3], [0, 0], [4, 4]]) == [0, 0, 0, 0, 7]\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], [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]],hits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [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]],hits = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 3], [2, 0], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3]]) == [0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1]],hits = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 0, 3, 0, 0, 0]\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],hits = [[0, 1], [0, 4], [1, 1], [1, 4], [2, 2], [2, 4], [3, 1], [3, 4]]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1]],hits = [[1, 1], [1, 4], [2, 2], [3, 3], [4, 2], [4, 4]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 3, 0]\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, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],hits = [[1, 1], [1, 7], [2, 2], [2, 6], [3, 3], [3, 5], [4, 3], [4, 5], [5, 2], [5, 6]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],hits = [[2, 2], [1, 3], [3, 2], [4, 4]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],hits = [[0, 0], [4, 5], [2, 2], [3, 3]]) == [0, 8, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [3, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]],hits = [[1, 2], [2, 2], [3, 2], [4, 2]]) == [0, 0, 0, 6]\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]],hits = [[0, 2], [1, 2], [2, 2], [3, 2], [1, 1], [2, 1], [3, 1], [2, 0], [2, 3]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]],hits = [[0, 1], [1, 2], [3, 3], [4, 4]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 1, 1, 0], [1, 1, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0]],hits = [[0, 0], [1, 2], [2, 4]]) == [0, 0, 0]\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]],hits = [[1, 1], [2, 2], [3, 1]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1]],hits = [[0, 0], [0, 4], [2, 2], [2, 4], [4, 0]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],hits = [[1, 1], [1, 5], [2, 2], [2, 4], [3, 3]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1]],hits = [[1, 1], [2, 2], [3, 3], [4, 4]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],hits = [[0, 1], [0, 3], [0, 5], [2, 1], [2, 3], [2, 5], [4, 1], [4, 3], [4, 5]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1]],hits = [[1, 1], [2, 2], [3, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[0, 1], [1, 2], [2, 1], [3, 2], [4, 3]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[1, 2], [1, 3]]) == [0, 0]\n assert candidate(grid = [[1, 1, 0, 0, 1, 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, 1, 0, 0, 1, 1]],hits = [[0, 0], [5, 5], [2, 2], [3, 3]]) == [1, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 3], [3, 0], [1, 2], [2, 1]]) == [0, 0, 0, 6, 0, 0, 2, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],hits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0]],hits = [[0, 0], [2, 2], [4, 4]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 1, 0, 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, 0, 0, 0, 1, 0, 1, 0, 1]],hits = [[0, 0], [0, 8], [4, 0], [4, 8]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[2, 2], [1, 1], [3, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[0, 1], [1, 2], [3, 1], [2, 3]]) == [0, 0, 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]],hits = [[1, 1], [1, 5], [2, 2], [2, 4], [3, 3], [4, 3], [4, 2], [5, 2], [5, 4]]) == [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, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],hits = [[0, 0], [5, 6], [2, 3], [3, 4]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]],hits = [[0, 0], [2, 2], [4, 4]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1, 1], [0, 1, 0, 1, 1, 0, 0], [0, 0, 1, 0, 1, 1, 0], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 1, 0, 1]],hits = [[0, 0], [5, 6], [2, 2], [3, 3], [4, 4], [1, 5]]) == [1, 0, 0, 0, 0, 0]\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, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],hits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 1, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0]],hits = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [0, 2, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]],hits = [[0, 0], [6, 6], [2, 2], [4, 4]]) == [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]],hits = [[2, 2], [1, 2], [0, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 0, 1, 0]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 5, 0]\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 1]],hits = [[0, 0], [2, 2]]) == [0, 0]\n assert candidate(grid = [[1, 1], [1, 1], [1, 1]],hits = [[0, 0], [1, 1]]) == [0, 3]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0]],hits = [[0, 0], [0, 1], [0, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 0, 1, 0], [1, 0, 0, 0, 0]],hits = [[1, 0], [1, 1], [1, 2], [1, 3]]) == [0, 3, 0, 1]\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 0]],hits = [[2, 1]]) == [0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],hits = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]) == [0, 0, 0, 0, 15]\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]],hits = [[0, 0], [0, 5], [4, 0], [4, 5]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [1, 0], [2, 0], [3, 0]]) == [0, 0, 0, 0]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],hits = [[0, 0], [1, 1], [2, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],hits = [[1, 1]]) == [0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [0, 1]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]],hits = [[0, 0], [1, 1]]) == [0, 2]\n assert candidate(grid = [[1, 0], [0, 1]],hits = [[0, 0], [1, 1]]) == [0, 0]\n assert candidate(grid = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],hits = [[0, 0], [1, 1]]) == [0, 1]\n assert candidate(grid = [[0]],hits = [[0, 0]]) == [0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],hits = [[1, 1], [1, 2]]) == [0, 0]\n assert candidate(grid = [[1, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0]],hits = [[0, 0], [1, 1], [2, 2]]) == [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]],hits = [[3, 3], [2, 2], [1, 1], [0, 0]]) == [0, 0, 0, 6]\n assert candidate(grid = [[1, 0, 1, 0], [1, 1, 1, 1], [0, 1, 0, 1]],hits = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [0, 0, 4, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]],hits = [[0, 1], [1, 0], [1, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [3, 0, 1, 0]\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]],hits = [[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]]) == [0, 0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 0]],hits = [[0, 3], [1, 3], [2, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1], [1], [1], [1], [1]],hits = [[2, 0], [3, 0]]) == [2, 0]\n assert candidate(grid = [[1, 0, 1], [1, 1, 1], [1, 0, 1]],hits = [[1, 1]]) == [0]\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 0, 0, 0]],hits = [[1, 1], [1, 2]]) == [0, 0]\n assert candidate(grid = [[1, 0, 1], [0, 0, 0], [1, 0, 1]],hits = [[0, 0], [2, 2], [0, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0], [1, 1, 1, 1], [0, 1, 0, 1]],hits = [[1, 1]]) == [1]\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],hits = [[0, 0], [0, 2], [2, 0], [2, 2]]) == [0, 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]],hits = [[1, 1], [1, 2], [1, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0], [1, 0]],hits = [[1, 0]]) == [0]\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],hits = [[0, 0], [1, 1], [2, 2]]) == [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]],hits = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == [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]],hits = [[1, 1], [2, 2]]) == [0, 0]\n assert candidate(grid = [[1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]],hits = [[1, 0], [1, 1]]) == [4, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[1, 1], [1, 2]]) == [0, 0]\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 1], [1, 1, 0, 1], [0, 1, 1, 1]],hits = [[1, 1], [0, 0], [2, 2]]) == [0, 1, 1]\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 0, 1], [1, 1, 0, 1]],hits = [[1, 0], [1, 2], [1, 3]]) == [0, 0, 1]\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],hits = [[0, 0], [1, 1], [2, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],hits = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == [0, 0, 9, 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]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 0, 6]\n assert candidate(grid = [[1, 0, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[1, 0], [0, 1]]) == [0, 0]\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [1, 1, 0, 0]],hits = [[0, 0], [2, 1]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [0, 1], [0, 2], [0, 3]]) == [0, 0, 0, 12]\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],hits = [[0, 0], [0, 4], [2, 2], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 1, 0], [1, 1, 1, 0], [1, 0, 1, 0], [1, 1, 1, 0]],hits = [[1, 1], [2, 2], [3, 3]]) == [0, 0, 0]\n assert candidate(grid = [[1], [1], [1], [1]],hits = [[0, 0], [1, 0], [2, 0], [3, 0]]) == [3, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],hits = [[1, 2], [3, 2]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]],hits = [[1, 0], [1, 2]]) == [0, 0]\n assert candidate(grid = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],hits = [[2, 2], [2, 3]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1], [0, 1, 0], [1, 1, 1]],hits = [[0, 0], [1, 1], [2, 2]]) == [0, 3, 0]\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [1, 1]]) == [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]],hits = [[3, 3], [0, 3], [0, 0], [3, 0], [1, 2]]) == [0, 0, 0, 2, 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]],hits = [[2, 2], [2, 3]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],hits = [[1, 0], [1, 1], [1, 2]]) == [0, 0, 3]\n assert candidate(grid = [[1, 1, 1], [0, 1, 0], [1, 1, 1]],hits = [[0, 0], [0, 1], [0, 2]]) == [0, 4, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]],hits = [[1, 1]]) == [0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [1, 1], [2, 2]]) == [0, 0, 3]\n assert candidate(grid = [[1, 0, 1, 0], [1, 1, 1, 1], [0, 1, 0, 1]],hits = [[1, 1], [1, 2]]) == [1, 2]\n assert candidate(grid = [[1, 1, 1], [0, 1, 0], [0, 0, 0]],hits = [[0, 0], [1, 1]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [0, 1], [0, 2], [0, 3]]) == [0, 0, 0, 8]\n assert candidate(grid = [[1, 1, 1], [0, 1, 0], [1, 1, 1]],hits = [[0, 0], [1, 1]]) == [0, 3]\n assert candidate(grid = [[1, 0, 1], [1, 1, 1], [1, 0, 1]],hits = [[1, 1], [1, 0]]) == [0, 1]\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],hits = [[0, 0], [0, 1], [0, 2], [0, 3]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],hits = [[2, 0], [1, 0], [0, 0], [3, 1], [3, 0], [2, 2], [1, 1], [0, 1]]) == [0, 0, 0, 0, 0, 0, 1, 0]\n assert candidate(grid = [[1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 1]],hits = [[0, 1], [2, 1]]) == [0, 0]\n assert candidate(grid = [[1, 1, 1], [0, 1, 0], [0, 0, 1]],hits = [[1, 1]]) == [0]\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 0]],hits = [[2, 2], [1, 1]]) == [0, 0]\n assert candidate(grid = [[1]],hits = [[0, 0]]) == [0]\n assert candidate(grid = [[1, 0, 1, 0], [1, 0, 1, 0], [1, 0, 1, 0]],hits = [[0, 0], [2, 2]]) == [2, 0]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],hits = [[0, 0], [1, 0], [2, 0]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],hits = [[0, 0], [1, 1], [2, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],hits = [[0, 0], [1, 1], [2, 2], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],hits = [[1, 1], [1, 2], [1, 3], [1, 4]]) == [0, 0, 0, 0]\n assert candidate(grid = [[1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1]],hits = [[0, 1], [0, 2], [2, 1], [2, 2]]) == [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]],hits = [[1, 2], [2, 2], [3, 2]]) == [0, 0, 0]\n assert candidate(grid = [[1, 1, 1], [0, 1, 0], [1, 1, 1]],hits = [[1, 1]]) == [3]\n assert candidate(grid = [[1, 0, 0, 1], [1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 1]],hits = [[1, 1], [1, 2]]) == [0, 0]\n", "comparison": "exact"}, "public_tests": ["[[1,0,0,0],[1,1,1,0]]\n[[1,0]]", "[[1,0,0,0],[1,1,0,0]]\n[[1,1],[1,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid", "hits"], "leetcode_dataset_entry_point": "Solution().hitBricks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:13+00:00", "tests_total": 155, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def hitBricks(self, grid: list[list[int]], hits: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "hitBricks", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "hits", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 804, "task_id": "unique-morse-code-words", "difficulty": "Easy", "problem_description": "International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:\n\n- 'a' maps to \".-\",\n- 'b' maps to \"-...\",\n- 'c' maps to \"-.-.\", and so on.\n\nFor convenience, the full table for the 26 letters of the English alphabet is given below:\n\n[\".-\",\"-...\",\"-.-.\",\"-..\",\".\",\"..-.\",\"--.\",\"....\",\"..\",\".---\",\"-.-\",\".-..\",\"--\",\"-.\",\"---\",\".--.\",\"--.-\",\".-.\",\"...\",\"-\",\"..-\",\"...-\",\".--\",\"-..-\",\"-.--\",\"--..\"]\n\nGiven an array of strings words where each word can be written as a concatenation of the Morse code of each letter.\n\n- For example, \"cab\" can be written as \"-.-..--...\", which is the concatenation of \"-.-.\", \".-\", and \"-...\". We will call such a concatenation the transformation of a word.\n\nReturn the number of different transformations among all words we have.\n\nExample 1:\n\nInput: words = [\"gin\",\"zen\",\"gig\",\"msg\"]\nOutput: 2\nExplanation: The transformation of each word is:\n\"gin\" -> \"--...-.\"\n\"zen\" -> \"--...-.\"\n\"gig\" -> \"--...--.\"\n\"msg\" -> \"--...--.\"\nThere are 2 different transformations: \"--...-.\" and \"--...--.\".\n\nExample 2:\n\nInput: words = [\"a\"]\nOutput: 1\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 12\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['s', 'u', 'n']) == 3\n assert candidate(words = ['mnop', 'qrst', 'uvwx', 'yz']) == 4\n assert candidate(words = ['hello', 'world']) == 2\n assert candidate(words = ['a']) == 1\n assert candidate(words = ['morse', 'coding', 'challenge']) == 3\n assert candidate(words = ['hello', 'world']) == 2\n assert candidate(words = ['test', 'code', 'abcd']) == 3\n assert candidate(words = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']) == 7\n assert candidate(words = ['abcd', 'efgh', 'ijkl']) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz']) == 8\n assert candidate(words = ['gin', 'zen', 'gig', 'msg']) == 2\n assert candidate(words = ['abcd', 'dcba', 'abba', 'baab']) == 4\n assert candidate(words = ['hello', 'world', 'python', 'challenge']) == 4\n assert candidate(words = ['single', 'letter', 'words', 'testcase', 'unique', 'morse', 'alphabet']) == 7\n assert candidate(words = ['abcd', 'dcba', 'mnop', 'ponm', 'qrst', 'tsrq', 'wxyz', 'zyxw']) == 8\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj']) == 10\n assert candidate(words = ['programming', 'is', 'fun']) == 3\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccabba', 'abacab', 'cabacb']) == 5\n assert candidate(words = ['zzzzzzzzzzzz', 'aaaaaaaaaaaa', 'bbbbbbbbbbbb', 'cccccccccccc', 'dddddddddddd', 'eeeeeeeeeeee', 'ffffffffffff']) == 7\n assert candidate(words = ['alice', 'bob', 'charlie', 'david']) == 4\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhiijj', 'kkllmm', 'nnoopp', 'qqrrss', 'ttuuvv', 'wwxxyy', 'zz']) == 9\n assert candidate(words = ['hello', 'world', 'python', 'programming']) == 4\n assert candidate(words = ['abcdefghijk', 'lmnopqrst', 'uvwxyz']) == 3\n assert candidate(words = ['quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dogs']) == 7\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm']) == 10\n assert candidate(words = ['qwen', 'alibaba', 'cloud', 'computing', 'solution', 'developer', 'engineer']) == 7\n assert candidate(words = ['alice', 'bob', 'charlie', 'david', 'eve', 'frank', 'grace', 'heidi', 'ivan', 'judy']) == 10\n assert candidate(words = ['repeated', 'words', 'in', 'this', 'list', 'repeated', 'words']) == 5\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == 26\n assert candidate(words = ['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']) == 26\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat', 'unique']) == 2\n assert candidate(words = ['hello', 'world', 'this', 'is', 'a', 'test', 'case']) == 7\n assert candidate(words = ['repeated', 'words', 'are', 'here', 'repeated', 'words']) == 4\n assert candidate(words = ['qz', 'jx', 'vk', 'bf']) == 4\n assert candidate(words = ['mississippi', 'bookkeeper', 'anagram', 'controller', 'algorithm']) == 5\n assert candidate(words = ['algorithms', 'data', 'structures', 'machine', 'learning']) == 5\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee']) == 5\n assert candidate(words = ['qzj', 'xlt', 'bkw', 'fmo', 'hmu', 'fsz', 'qqt', 'ztl', 'rgj', 'zhm', 'gmo', 'bwz', 'pqt', 'kcu', 'wqt', 'hmr', 'pgt', 'xqt', 'nzm', 'nhu', 'xzm', 'cmu', 'pqh', 'pgj', 'xju', 'zmh', 'xmu']) == 27\n assert candidate(words = ['single', 'unique', 'distinct', 'different']) == 4\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'different']) == 2\n assert candidate(words = ['morsetest', 'codeforces', 'competitive', 'algorithm']) == 4\n assert candidate(words = ['morse', 'code', 'morsecode', 'codemorse']) == 4\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'different', 'words']) == 3\n assert candidate(words = ['zebra', 'yak', 'antelope', 'hippopotamus', 'elephant', 'giraffe']) == 6\n assert candidate(words = ['this', 'is', 'a', 'simple', 'test', 'case']) == 6\n assert candidate(words = ['amazingrace', 'triathlon', 'cycling', 'running', 'swimming', 'tri', 'duathlon', 'aquathlon']) == 8\n assert candidate(words = ['alice', 'bob', 'charlie', 'delta', 'echo', 'foxtrot', 'golf', 'hotel', 'india', 'juliett', 'kilo', 'lima', 'mike', 'november', 'oscar', 'papa', 'quebec', 'romeo', 'sierra', 'tango', 'uniform', 'victor', 'whiskey', 'xray', 'yankee', 'zulu']) == 26\n assert candidate(words = ['karen', 'mike', 'nancy', 'olivia', 'peter', 'quincy', 'rachel', 'steve', 'tina', 'ulysses', 'victor', 'wendy', 'xander', 'yvonne', 'zach']) == 15\n assert candidate(words = ['qzj', 'xmv', 'nkt', 'hbw', 'lyf']) == 5\n assert candidate(words = ['programming', 'is', 'fun']) == 3\n assert candidate(words = ['programming', 'challenge', 'python', 'codeforces']) == 4\n assert candidate(words = ['racecar', 'level', 'rotor', 'radar', 'deified', 'noon', 'kayak', 'reviler']) == 8\n assert candidate(words = ['qzcv', 'wqop', 'rgmo', 'mnlx', 'axta', 'qwkl', 'qzcv', 'wqop', 'rgmo', 'mnlx', 'axta', 'qwkl']) == 6\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ccddeeff', 'ddeeffcc', 'eeffccdd', 'ffccddeeff', 'ccddeeff', 'ddeeffcc', 'eeffccdd', 'ffccddeeff']) == 6\n assert candidate(words = ['python', 'java', 'csharp', 'javascript']) == 4\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat']) == 1\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'challenge']) == 5\n", "comparison": "exact"}, "public_tests": ["[\"gin\",\"zen\",\"gig\",\"msg\"]", "[\"a\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().uniqueMorseRepresentations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:15+00:00", "tests_total": 82, "tests_dropped": 25, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def uniqueMorseRepresentations(self, words: list[str]) -> int:", "container": "Solution", "callable": "uniqueMorseRepresentations", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 805, "task_id": "split-array-with-same-average", "difficulty": "Hard", "problem_description": "You are given an integer array nums.\n\nYou should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B).\n\nReturn true if it is possible to achieve that and false otherwise.\n\nNote that for an array arr, average(arr) is the sum of all the elements of arr over the length of arr.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5,6,7,8]\nOutput: true\nExplanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both of them have an average of 4.5.\n\nExample 2:\n\nInput: nums = [3,1]\nOutput: false\n\nConstraints:\n\n- 1 <= nums.length <= 30\n- 0 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [2, 4, 6, 8, 10]) == True\n assert candidate(nums = [1, 3, 5, 7, 9]) == True\n assert candidate(nums = [10000, 10000, 10000]) == True\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]) == True\n assert candidate(nums = [1, 2, 3, 4]) == True\n assert candidate(nums = [18, 10, 5, 3]) == False\n assert candidate(nums = [10000, 0, 10000, 0]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(nums = [10, 20, 30, 40, 50]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == False\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [3, 1]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 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]) == True\n assert candidate(nums = [0, 0, 0, 0]) == True\n assert candidate(nums = [2, 2, 2, 2]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [6, 6, 6, 6, 6, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [6, 6, 6, 6]) == True\n assert candidate(nums = [1, 3, 5, 7]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 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(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 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, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 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 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 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, 1]) == False\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]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == True\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]) == 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, 60]) == 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]) == 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, 100, 100, 100, 100, 100, 100, 100, 100, 100, 5000]) == False\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 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, 100]) == False\n assert candidate(nums = [10000, 0, 10000, 0, 10000, 0, 10000, 0, 10000, 0, 10000, 0, 10000, 0, 10000, 0, 10000, 0, 10000, 0]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == False\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]) == 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]) == True\n assert candidate(nums = [1, 2, 3, 6, 4, 5, 9, 7, 8, 10]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 50]) == True\n assert candidate(nums = [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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 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, 58]) == 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, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 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]) == True\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, 5, 6, 7, 8, 9, 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]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 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, 2]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == True\n assert candidate(nums = [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 = [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]) == 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, 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 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 300]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 59]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 1]) == 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]) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145]) == 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, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 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]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 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, 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]) == True\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 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]) == 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 assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [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, 590]) == 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]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6,7,8]", "[3,1]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().splitArraySameAverage", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:17+00:00", "tests_total": 100, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "hash-table", "math", "dynamic-programming", "bit-manipulation", "meet-in-the-middle", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def splitArraySameAverage(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "splitArraySameAverage", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 806, "task_id": "number-of-lines-to-write-string", "difficulty": "Easy", "problem_description": "You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on.\n\nYou are trying to write s across several lines, where each line is no longer than 100 pixels. Starting at the beginning of s, write as many letters on the first line such that the total width does not exceed 100 pixels. Then, from where you stopped in s, continue writing as many letters as you can on the second line. Continue this process until you have written all of s.\n\nReturn an array result of length 2 where:\n\n- result[0] is the total number of lines.\n- result[1] is the width of the last line in pixels.\n\nExample 1:\n\nInput: widths = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = \"abcdefghijklmnopqrstuvwxyz\"\nOutput: [3,60]\nExplanation: You can write s as follows:\nabcdefghij // 100 pixels wide\nklmnopqrst // 100 pixels wide\nuvwxyz // 60 pixels wide\nThere are a total of 3 lines, and the last line is 60 pixels wide.\n\nExample 2:\n\nInput: widths = [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = \"bbbcccdddaaa\"\nOutput: [2,4]\nExplanation: You can write s as follows:\nbbbcccdddaa // 98 pixels wide\na // 4 pixels wide\nThere are a total of 2 lines, and the last line is 4 pixels wide.\n\nConstraints:\n\n- widths.length == 26\n- 2 <= widths[i] <= 10\n- 1 <= s.length <= 1000\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(widths = [4, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"bbbcccdddaaa\") == [2, 4]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"a\") == [1, 10]\n assert candidate(widths = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],s = \"equalpairsofequalrowsandcolumnsinamatrix\") == [2, 100]\n assert candidate(widths = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],s = \"samewidthforallcharacters\") == [2, 25]\n assert candidate(widths = [5, 7, 9, 3, 5, 7, 9, 3, 5, 7, 9, 3, 5, 7, 9, 3, 5, 7, 9, 3, 5, 7, 9, 3, 5, 7],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == [4, 24]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"abcdefghijklmnopqrstuvwxyz\") == [3, 60]\n assert candidate(widths = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],s = \"equalwidthseachletter\") == [1, 63]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmmnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwxxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\") == [26, 90]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"ababababababababababababababababababababababababababababababababababababab\") == [8, 40]\n assert candidate(widths = [9, 2, 2, 8, 4, 4, 7, 6, 6, 2, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],s = \"narrowwidthsshouldwrapquickly\") == [2, 76]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"mississippi\") == [2, 10]\n assert candidate(widths = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == [3, 60]\n assert candidate(widths = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],s = \"wonderfulwizardwithawonderfulwizardofoz\") == [1, 78]\n assert candidate(widths = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == [2, 4]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == [6, 20]\n assert candidate(widths = [8, 6, 4, 2, 10, 6, 4, 2, 8, 6, 4, 2, 10, 6, 4, 2, 8, 6, 4, 2, 10, 6, 4, 2, 8, 6],s = \"algorithmsanddatastructures\") == [2, 46]\n", "comparison": "exact"}, "public_tests": ["[10,10,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\"abcdefghijklmnopqrstuvwxyz\"", "[4,10,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\"bbbcccdddaaa\""], "hints": [], "metadata": {"canonical_parameter_names": ["widths", "s"], "leetcode_dataset_entry_point": "Solution().numberOfLines", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:19+00:00", "tests_total": 46, "tests_dropped": 30, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def numberOfLines(self, widths: List[int], s: str) -> List[int]:", "container": "Solution", "callable": "numberOfLines", "parameters": [{"name": "widths", "type": "List[int]"}, {"name": "s", "type": "str"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 807, "task_id": "max-increase-to-keep-city-skyline", "difficulty": "Medium", "problem_description": "There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n integer matrix grid where grid[r][c] represents the height of the building located in the block at row r and column c.\n\nA city's skyline is the outer contour formed by all the building when viewing the side of the city from a distance. The skyline from each cardinal direction north, east, south, and west may be different.\n\nWe are allowed to increase the height of any number of buildings by any amount (the amount can be different per building). The height of a 0-height building can also be increased. However, increasing the height of a building should not affect the city's skyline from any cardinal direction.\n\nReturn the maximum total sum that the height of the buildings can be increased by without changing the city's skyline from any cardinal direction.\n\nExample 1:\n\nInput: grid = [[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]\nOutput: 35\nExplanation: The building heights are shown in the center of the above image.\nThe skylines when viewed from each cardinal direction are drawn in red.\nThe grid after increasing the height of buildings without affecting skylines is:\ngridNew = [ [8, 4, 8, 7],\n [7, 4, 7, 7],\n [9, 4, 8, 7],\n [3, 3, 3, 3] ]\n\nExample 2:\n\nInput: grid = [[0,0,0],[0,0,0],[0,0,0]]\nOutput: 0\nExplanation: Increasing the height of any building will result in the skyline changing.\n\nConstraints:\n\n- n == grid.length\n- n == grid[r].length\n- 2 <= n <= 50\n- 0 <= grid[r][c] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[3, 0, 8, 4], [2, 4, 5, 7], [9, 2, 6, 3], [0, 3, 1, 0]]) == 35\n assert candidate(grid = [[10, 0, 0, 0], [0, 10, 0, 0], [0, 0, 10, 0], [0, 0, 0, 10]]) == 120\n assert candidate(grid = [[5, 3, 3, 2], [4, 4, 4, 4], [3, 4, 5, 4], [2, 3, 4, 5]]) == 14\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 0\n assert candidate(grid = [[5, 3, 7, 8], [4, 4, 6, 6], [1, 2, 3, 4], [8, 7, 5, 3]]) == 24\n assert candidate(grid = [[1, 2], [3, 4]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 6\n assert candidate(grid = [[50, 0, 0], [0, 0, 0], [0, 0, 50]]) == 100\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[50, 50], [50, 50]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 2, 5, 3, 4], [4, 3, 5, 2, 6, 1], [2, 4, 6, 1, 5, 3], [3, 1, 4, 6, 1, 2]]) == 94\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 0, 0, 0, 9], [9, 0, 1, 0, 9], [9, 0, 0, 0, 9], [9, 9, 9, 9, 9]]) == 80\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]]) == 55\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 2, 1, 6, 5, 4], [4, 5, 6, 1, 2, 3]]) == 90\n assert candidate(grid = [[2, 0, 8, 6, 8], [5, 9, 3, 6, 4], [6, 4, 1, 3, 9], [7, 8, 9, 1, 6], [3, 5, 2, 4, 8]]) == 67\n assert candidate(grid = [[2, 3, 4, 5, 1], [1, 2, 3, 4, 5], [5, 1, 2, 3, 4], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2]]) == 50\n assert candidate(grid = [[8, 2, 3, 4, 5], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11]]) == 42\n assert candidate(grid = [[10, 5, 2, 0, 4], [8, 3, 10, 10, 10], [9, 5, 3, 10, 6], [2, 6, 6, 9, 4], [3, 2, 3, 4, 2]]) == 64\n assert candidate(grid = [[10, 15, 7, 12, 8], [3, 18, 6, 9, 5], [14, 1, 17, 11, 10], [13, 16, 4, 2, 19], [1, 20, 16, 2, 0]]) == 151\n assert candidate(grid = [[10, 10, 10, 10], [10, 0, 0, 10], [10, 0, 0, 10], [10, 10, 10, 10]]) == 40\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]]) == 2\n assert candidate(grid = [[9, 6, 3, 8, 7, 2], [5, 4, 1, 10, 6, 1], [3, 9, 3, 2, 7, 2], [8, 1, 9, 1, 1, 1], [2, 3, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2]]) == 80\n assert candidate(grid = [[20, 10, 30, 50, 40], [30, 20, 40, 60, 50], [10, 30, 50, 70, 60], [40, 50, 70, 90, 80], [50, 60, 80, 100, 90]]) == 330\n assert candidate(grid = [[10, 15, 20, 25, 30, 35], [35, 30, 25, 20, 15, 10], [10, 35, 15, 30, 20, 25], [25, 20, 30, 15, 35, 10], [30, 10, 20, 35, 15, 25], [15, 25, 35, 10, 20, 30]]) == 450\n assert candidate(grid = [[3, 8, 8, 8, 3], [8, 4, 4, 4, 8], [8, 4, 4, 4, 8], [8, 4, 4, 4, 8], [3, 8, 8, 8, 3]]) == 56\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], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == 54\n assert candidate(grid = [[5, 1, 9, 1, 5], [1, 1, 1, 1, 1], [9, 1, 9, 1, 9], [1, 1, 1, 1, 1], [5, 1, 9, 1, 5]]) == 16\n assert candidate(grid = [[2, 8, 4, 6, 2], [6, 3, 1, 7, 3], [7, 1, 4, 2, 8], [2, 8, 3, 7, 4], [1, 6, 2, 5, 9]]) == 58\n assert candidate(grid = [[40, 10, 50, 20, 30], [10, 20, 30, 40, 50], [50, 30, 20, 10, 40], [20, 40, 10, 30, 50], [30, 50, 40, 20, 10]]) == 450\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 0, 0, 0, 0, 0, 5], [5, 0, 5, 5, 5, 0, 5], [5, 0, 5, 0, 5, 0, 5], [5, 0, 5, 5, 5, 0, 5], [5, 0, 0, 0, 0, 0, 5], [5, 5, 5, 5, 5, 5, 5]]) == 85\n assert candidate(grid = [[2, 0, 0, 2, 2], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [2, 0, 0, 2, 2], [2, 2, 2, 2, 2]]) == 14\n assert candidate(grid = [[5, 0, 10, 15, 20], [15, 20, 5, 0, 10], [0, 10, 15, 20, 5], [20, 5, 0, 10, 15], [10, 15, 20, 5, 0]]) == 250\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, 3, 0, 3, 0, 0], [0, 2, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 1]]) == 56\n assert candidate(grid = [[2, 8, 4, 0, 0, 0], [4, 4, 4, 4, 4, 4], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 14\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 0], [2, 3, 4, 5, 0, 1], [3, 4, 5, 0, 1, 2], [4, 5, 0, 1, 2, 3], [5, 0, 1, 2, 3, 4]]) == 90\n assert candidate(grid = [[9, 5, 7, 2, 8], [1, 3, 6, 4, 5], [8, 4, 1, 9, 2], [3, 8, 6, 7, 1], [2, 6, 5, 4, 3]]) == 62\n assert candidate(grid = [[30, 0, 9, 20, 40], [15, 25, 10, 35, 20], [20, 15, 5, 45, 30], [30, 40, 25, 10, 5], [5, 30, 35, 20, 45]]) == 366\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 1], [0, 3, 0, 0, 0, 0, 3, 0], [0, 0, 5, 0, 0, 5, 0, 0], [0, 0, 0, 7, 7, 0, 0, 0], [0, 0, 0, 7, 7, 0, 0, 0], [0, 0, 5, 0, 0, 5, 0, 0], [0, 3, 0, 0, 0, 0, 3, 0], [1, 0, 0, 1, 0, 0, 0, 1]]) == 110\n assert candidate(grid = [[10, 2, 3, 4, 5], [1, 6, 7, 8, 9], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [9, 8, 7, 6, 10]]) == 52\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [1, 1, 1, 1, 1]]) == 32\n assert candidate(grid = [[15, 0, 0, 0, 10], [5, 0, 0, 0, 5], [10, 0, 0, 0, 5], [5, 0, 0, 0, 10], [10, 0, 0, 0, 15]]) == 20\n assert candidate(grid = [[10, 20, 30, 40, 50], [40, 30, 20, 10, 0], [50, 40, 30, 20, 10], [0, 10, 20, 30, 40], [5, 15, 25, 35, 45]]) == 375\n assert candidate(grid = [[10, 20, 30, 40, 50], [9, 19, 29, 39, 49], [8, 18, 28, 38, 48], [7, 17, 27, 37, 47], [6, 16, 26, 36, 46]]) == 40\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 100, 0, 0, 0, 0, 0], [0, 0, 100, 0, 0, 0, 0], [0, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 100, 0, 0], [0, 0, 0, 0, 0, 100, 0], [0, 0, 0, 0, 0, 0, 100]]) == 3000\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]]) == 0\n assert candidate(grid = [[3, 0, 8, 4, 10], [2, 4, 5, 7, 1], [9, 2, 6, 3, 8], [0, 3, 1, 0, 9], [5, 5, 5, 5, 5]]) == 63\n assert candidate(grid = [[8, 2, 5, 9], [7, 5, 8, 8], [9, 8, 7, 6], [2, 8, 5, 9]]) == 28\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], [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]]) == 180\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], [3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3]]) == 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 90\n assert candidate(grid = [[20, 10, 0, 10, 20], [10, 20, 30, 20, 10], [0, 30, 40, 30, 0], [10, 20, 30, 20, 10], [20, 10, 0, 10, 20]]) == 200\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 40\n assert candidate(grid = [[7, 0, 1, 2, 5], [4, 0, 0, 0, 0], [6, 0, 0, 0, 0], [0, 0, 1, 0, 0], [5, 0, 5, 0, 5]]) == 31\n assert candidate(grid = [[5, 2, 7, 4], [4, 0, 9, 6], [3, 6, 1, 8], [9, 5, 4, 2]]) == 46\n assert candidate(grid = [[3, 1, 4, 1, 5, 9], [2, 6, 5, 3, 5, 9], [5, 0, 5, 0, 5, 0], [2, 6, 5, 3, 5, 9], [5, 0, 5, 0, 5, 0], [3, 1, 4, 1, 5, 9]]) == 52\n assert candidate(grid = [[9, 8, 7, 6, 5, 4], [8, 9, 6, 7, 5, 4], [7, 6, 9, 8, 4, 5], [6, 7, 8, 9, 5, 4], [5, 4, 7, 6, 9, 8], [4, 5, 6, 7, 8, 9]]) == 90\n assert candidate(grid = [[9, 8, 7, 6], [6, 5, 4, 3], [3, 4, 5, 6], [7, 8, 9, 10]]) == 19\n assert candidate(grid = [[9, 4, 8, 7, 10], [3, 5, 6, 4, 9], [7, 1, 2, 8, 3], [6, 5, 4, 2, 1], [8, 6, 7, 3, 5]]) == 54\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12], [12, 10, 8, 6, 4, 2]]) == 110\n assert candidate(grid = [[5, 3, 3, 3, 3], [3, 3, 3, 3, 5], [3, 3, 3, 3, 3], [3, 3, 3, 3, 3], [3, 5, 3, 3, 3]]) == 12\n assert candidate(grid = [[0, 10, 0, 10], [10, 0, 10, 0], [0, 10, 0, 10], [10, 0, 10, 0]]) == 80\n assert candidate(grid = [[1, 10, 10, 1], [1, 1, 1, 10], [10, 1, 1, 1], [1, 10, 1, 10]]) == 90\n assert candidate(grid = [[30, 10, 20, 40, 50], [25, 35, 15, 45, 55], [60, 50, 40, 30, 20], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45]]) == 385\n assert candidate(grid = [[9, 9, 9, 9], [9, 0, 0, 9], [9, 0, 0, 9], [9, 9, 9, 9]]) == 36\n assert candidate(grid = [[20, 0, 15, 10, 25], [5, 10, 8, 12, 18], [0, 5, 0, 5, 0], [15, 12, 8, 6, 14], [25, 18, 14, 10, 9]]) == 104\n", "comparison": "exact"}, "public_tests": ["[[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]", "[[0,0,0],[0,0,0],[0,0,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxIncreaseKeepingSkyline", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:22+00:00", "tests_total": 69, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "greedy", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxIncreaseKeepingSkyline(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maxIncreaseKeepingSkyline", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 808, "task_id": "soup-servings", "difficulty": "Medium", "problem_description": "You have two soups, A and B, each starting with n mL. On every turn, one of the following four serving operations is chosen at random, each with probability 0.25 independent of all previous turns:\n\n- pour 100 mL from type A and 0 mL from type B\n- pour 75 mL from type A and 25 mL from type B\n- pour 50 mL from type A and 50 mL from type B\n- pour 25 mL from type A and 75 mL from type B\n\nNote:\n\n- There is no operation that pours 0 mL from A and 100 mL from B.\n- The amounts from A and B are poured simultaneously during the turn.\n- If an operation asks you to pour more than you have left of a soup, pour all that remains of that soup.\n\nThe process stops immediately after any turn in which one of the soups is used up.\n\nReturn the probability that A is used up before B, plus half the probability that both soups are used up in the same turn. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: n = 50\nOutput: 0.62500\nExplanation:\nIf we perform either of the first two serving operations, soup A will become empty first.\nIf we perform the third operation, A and B will become empty at the same time.\nIf we perform the fourth operation, B will become empty first.\nSo the total probability of A becoming empty first plus half the probability that A and B become empty at the same time, is 0.25 * (1 + 1 + 0.5 + 0) = 0.625.\n\nExample 2:\n\nInput: n = 100\nOutput: 0.71875\nExplanation:\nIf we perform the first serving operation, soup A will become empty first.\nIf we perform the second serving operations, A will become empty on performing operation [1, 2, 3], and both A and B become empty on performing operation 4.\nIf we perform the third operation, A will become empty on performing operation [1, 2], and both A and B become empty on performing operation 3.\nIf we perform the fourth operation, A will become empty on performing operation 1, and both A and B become empty on performing operation 2.\nSo the total probability of A becoming empty first plus half the probability that A and B become empty at the same time, is 0.71875.\n\nConstraints:\n\n- 0 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=0), 0.5)\n assert answers_match(candidate(n=125), 0.7421875)\n assert answers_match(candidate(n=200), 0.796875)\n assert answers_match(candidate(n=100), 0.71875)\n assert answers_match(candidate(n=1000000000), 1)\n assert answers_match(candidate(n=50), 0.625)\n assert answers_match(candidate(n=625), 0.9417028725147247)\n assert answers_match(candidate(n=999999999), 1)\n assert answers_match(candidate(n=12345), 1)\n assert answers_match(candidate(n=999999996), 1)\n assert answers_match(candidate(n=7500), 1)\n assert answers_match(candidate(n=2000), 0.9977163163248763)\n assert answers_match(candidate(n=300000), 1)\n assert answers_match(candidate(n=50000), 1)\n assert answers_match(candidate(n=1000), 0.9765650521094358)\n assert answers_match(candidate(n=3333), 0.9998851608898072)\n assert answers_match(candidate(n=250000), 1)\n assert answers_match(candidate(n=999999998), 1)\n assert answers_match(candidate(n=3000), 0.9997529725570642)\n assert answers_match(candidate(n=875000000), 1)\n assert answers_match(candidate(n=1200), 0.9855064973468473)\n assert answers_match(candidate(n=750000), 1)\n assert answers_match(candidate(n=10000), 1)\n assert answers_match(candidate(n=750000000), 1)\n assert answers_match(candidate(n=12345678), 1)\n assert answers_match(candidate(n=250), 0.82763671875)\n assert answers_match(candidate(n=999999995), 1)\n assert answers_match(candidate(n=100000), 1)\n assert answers_match(candidate(n=20000), 1)\n assert answers_match(candidate(n=375), 0.88482666015625)\n assert answers_match(candidate(n=999), 0.9765650521094358)\n assert answers_match(candidate(n=5000), 1)\n assert answers_match(candidate(n=75000), 1)\n assert answers_match(candidate(n=25000), 1)\n assert answers_match(candidate(n=9999), 1)\n assert answers_match(candidate(n=987654321), 1)\n assert answers_match(candidate(n=800), 0.961617625085637)\n assert answers_match(candidate(n=567890123), 1)\n assert answers_match(candidate(n=2500), 0.99925483400331)\n assert answers_match(candidate(n=500000), 1)\n assert answers_match(candidate(n=999999997), 1)\n assert answers_match(candidate(n=400), 0.8896331787109375)\n assert answers_match(candidate(n=500000000), 1)\n assert answers_match(candidate(n=1000000), 1)\n assert answers_match(candidate(n=750), 0.9564644806087017)\n assert answers_match(candidate(n=123456789), 1)\n assert answers_match(candidate(n=1234567), 1)\n assert answers_match(candidate(n=999999), 1)\n assert answers_match(candidate(n=123456), 1)\n assert answers_match(candidate(n=500), 0.916344165802002)\n assert answers_match(candidate(n=25), 0.625)\n assert answers_match(candidate(n=1500), 0.9928319024738018)\n", "comparison": "float"}, "public_tests": ["50", "100"], "hints": ["For large n, the answer approaches a constant value.", "Which soup is more likely to deplete first if we are allowed to perform many operations without bias?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().soupServings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:24+00:00", "tests_total": 55, "tests_dropped": 3, "flags": ["decimal_answer"], "topic_tags": ["math", "dynamic-programming", "probability-and-statistics"]}, "language": "python", "interface": {"raw_signature": "def soupServings(self, n: int) -> float:", "container": "Solution", "callable": "soupServings", "parameters": [{"name": "n", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 809, "task_id": "expressive-words", "difficulty": "Medium", "problem_description": "Sometimes people repeat letters to represent extra feeling. For example:\n\n- \"hello\" -> \"heeellooo\"\n- \"hi\" -> \"hiiii\"\n\nIn these strings like \"heeellooo\", we have groups of adjacent letters that are all the same: \"h\", \"eee\", \"ll\", \"ooo\".\n\nYou are given a string s and an array of query strings words. A query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is three or more.\n\n- For example, starting with \"hello\", we could do an extension on the group \"o\" to get \"hellooo\", but we cannot get \"helloo\" since the group \"oo\" has a size less than three. Also, we could do another extension like \"ll\" -> \"lllll\" to get \"helllllooo\". If s = \"helllllooo\", then the query word \"hello\" would be stretchy because of these two extension operations: query = \"hello\" -> \"hellooo\" -> \"helllllooo\" = s.\n\nReturn the number of query strings that are stretchy.\n\nExample 1:\n\nInput: s = \"heeellooo\", words = [\"hello\", \"hi\", \"helo\"]\nOutput: 1\nExplanation:\nWe can extend \"e\" and \"o\" in the word \"hello\" to get \"heeellooo\".\nWe can't extend \"helo\" to get \"heeellooo\" because the group \"ll\" is not size 3 or more.\n\nExample 2:\n\nInput: s = \"zzzzzyyyyy\", words = [\"zzyy\",\"zy\",\"zyy\"]\nOutput: 3\n\nConstraints:\n\n- 1 <= s.length, words.length <= 100\n- 1 <= words[i].length <= 100\n- s and words[i] consist of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabaaa\",words = ['aa', 'aaa', 'aaaa', 'aabaaa']) == 1\n assert candidate(s = \"aaabaaa\",words = ['aaa', 'aab', 'aaaaa', 'aaabaa', 'aaaba']) == 2\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abdc', 'aabbccdd']) == 1\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abcde']) == 1\n assert candidate(s = \"aaabbbcccddd\",words = ['aabbccddd', 'aabbbcccddd', 'aabbbcccdd']) == 3\n assert candidate(s = \"a\",words = ['a', 'aa', 'aaa', 'aaaa']) == 1\n assert candidate(s = \"aabbcc\",words = ['aabbcc', 'aabbc', 'aaabc']) == 1\n assert candidate(s = \"abcd\",words = ['aabbccdd', 'abccdd', 'abbbccdd', 'aabbcccddd']) == 0\n assert candidate(s = \"heeellooo\",words = ['hello', 'hi', 'helo']) == 1\n assert candidate(s = \"aaabaaa\",words = ['aab', 'aaab', 'aaaab', 'aaaba', 'aaaaaaab']) == 1\n assert candidate(s = \"abcd\",words = ['abc', 'ab', 'abcd', 'abcde']) == 1\n assert candidate(s = \"aaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa']) == 3\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abcde', 'ab', 'a']) == 1\n assert candidate(s = \"aaabbb\",words = ['aabb', 'aabbbb', 'aaabbbb']) == 1\n assert candidate(s = \"abcd\",words = ['abc', 'ab', 'abcd', 'abcde', 'aabbccdd']) == 1\n assert candidate(s = \"zzzzzyyyyy\",words = ['zzyy', 'zy', 'zyy']) == 3\n assert candidate(s = \"heeellloooopppp\",words = ['helloppp', 'heellooppp', 'helooppp', 'helllopppp', 'heeelllooooooo', 'hello']) == 4\n assert candidate(s = \"ttttuuuuuuuuuuuuvvv\",words = ['tuv', 'tttuuuuuuuuuuvvv', 'ttttuuuuuuuuuuu', 'ttttuuuuuuuuuvv', 'ttttuuuuuuuuuuuuv']) == 4\n assert candidate(s = \"heeeloooooo\",words = ['hello', 'heeellooo', 'helllooo', 'heellooo', 'heeelloo']) == 0\n assert candidate(s = \"aaaabbbbcccc\",words = ['aabbcc', 'aaabbbcccc', 'aaaabbbbccc', 'aaaabbbcccc', 'aaaaabbbbcccc']) == 4\n assert candidate(s = \"aaaabbbbccccddddeeee\",words = ['aabcd', 'abbbcd', 'abccde', 'abcde', 'aaaaabbbbccccddddeee']) == 2\n assert candidate(s = \"mmmmnnnnnnoooopppppp\",words = ['mnop', 'mmnnnnoooppp', 'mmmmmnnnnnnnoooooopppppp', 'mmnnoopp', 'mmnnoooopppp']) == 4\n assert candidate(s = \"xxxxxyyyyyyzzzzzz\",words = ['xyzz', 'xxxyyyyzzz', 'xxxxxyyyzzzzz', 'xxxxxyyyyyyzzzz', 'xxxxxyyyyyyzzzzzz']) == 5\n assert candidate(s = \"llllaaaabbbbccccddddeeeee\",words = ['laabcd', 'labbbccddeee', 'labcde', 'laaaabbbbccccddddeee', 'lbbbcccddddeeee']) == 3\n assert candidate(s = \"abbbcccddd\",words = ['abc', 'abbc', 'abbcc', 'abbbcccd', 'abbbcccddd', 'abbbcccdd', 'abbbccccd', 'abbbccccdd']) == 3\n assert candidate(s = \"mmmmnnnnoooopppp\",words = ['mno', 'mmnnnnooooppp', 'mmmmnnnnoooop', 'mmmmnnnnoooopppp', 'mmmmnnnnoooppp']) == 4\n assert candidate(s = \"heeellloooowooorlddd\",words = ['helo', 'hello', 'helooworld', 'heeellooworld', 'heeelllooooowooorlddd']) == 2\n assert candidate(s = \"mmmmmmmnnnnnnn\",words = ['mmnn', 'mmmnnn', 'mmmmnnnn', 'mmmmmn', 'mmmmnn', 'mmmmmnnn', 'mmmmmmnnnnn', 'mmmmmmnnnn']) == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zzzzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbbccddeeefffgghhhiiiijjjkkklllmmmnnnooooppppqqqqrrrrsssss', 'aabbccddeeefffgggiiiijjjkkklllmmmnnnoooopppqqqqrrrrrrsssss', 'aabbccddeeffgghhiijjkkklllmmmmmnnnnnoooooopppppqqqqqqrrrrrrssssss']) == 1\n assert candidate(s = \"xyzzzzzyyyyyyyy\",words = ['xyz', 'xyyz', 'xyzz', 'xyzzz', 'xyzzzz', 'xyzzzzzyyyyy', 'xyzzzzzyyyyyy', 'xyzzzzzyyyyyyyy']) == 3\n assert candidate(s = \"zzzzzzzyyyyyyy\",words = ['zzzyyyy', 'zzzzzyyy', 'zzzyyyyyyy', 'zzzzzzzzyy', 'zyyyyyyy']) == 4\n assert candidate(s = \"mississippiiii\",words = ['mississippi', 'missisiiippi', 'mississippiiiii', 'missisipi', 'misisipi']) == 1\n assert candidate(s = \"xxyyzzzz\",words = ['xxyyz', 'xxyyzz', 'xxxyyyzzzz', 'xxyyzzz', 'xyzzz']) == 3\n assert candidate(s = \"aabbccccddddeeeffggg\",words = ['aabbccddeeffg', 'aabbcccddddeffgg', 'aabbbccccddddeeeffggg', 'aabbbcccddddeeeffgg', 'aabbccccdddddeeeffggg']) == 2\n assert candidate(s = \"xxxxxxyyyyyyzzzzzz\",words = ['xyzz', 'xyzzz', 'xyyz', 'xxxyyyyzzz', 'xxxxxyyyyyyzzzzzz']) == 5\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",words = ['qq', 'qqq', 'qqqq', 'qqqqqq', 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq']) == 4\n assert candidate(s = \"ttttttttttttuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvvv\",words = ['tuv', 'ttuuuvvv', 'ttttuuuuuuuvvvvvvv', 'tttuuuuuuvvvvvvvvvv', 'ttttuuuuuuuuuuuvvvvvvvvvvvvvvvvvv']) == 5\n assert candidate(s = \"ppppqqqqrrrrssss\",words = ['pqrst', 'pqrs', 'ppqrs', 'ppqqrrss', 'ppqqqrrrssss', 'ppqqqqrrrrsssss']) == 4\n assert candidate(s = \"helloooooworlddddd\",words = ['hellooworld', 'hellooworlddd', 'hellllooworld', 'helloooworldddddd', 'hellooooooworlddddd']) == 2\n assert candidate(s = \"mississippiissi\",words = ['mississippissi', 'misisipi', 'mississippi', 'mississsippi', 'mississippiii']) == 0\n assert candidate(s = \"aabbccddeee\",words = ['abcde', 'aabbcdeee', 'aaabbbcccdddeee', 'aabbccdde', 'aabccdeee']) == 1\n assert candidate(s = \"ppppqqqqrrrssss\",words = ['pqr', 'ppqqrrsss', 'pppqqqrrrrssss', 'ppqqrrsssss', 'ppqqrrr']) == 1\n assert candidate(s = \"abcdefghijklllllmnopqrstuvwxyz\",words = ['abcdefghijklmopqrstuvwxyz', 'abcdefghijklllmmnopqrstuvwxyz', 'abcdefghijkllllmnopqrstuvwxyz', 'abcdefghijklllllmnopqrstuvwxy', 'abcdefghijklllllmnopqrstuvwxyz']) == 2\n assert candidate(s = \"hhheeelllllooooworrlldd\",words = ['helloworld', 'hhhellooooworld', 'hheeellllllooooworld', 'hellooworld', 'hheellooworl']) == 0\n assert candidate(s = \"ssssaaafffff\",words = ['saff', 'ssaff', 'ssaaaff', 'ssaaaafff', 'ssaaaaaffff', 'ssssaaaafffff']) == 3\n assert candidate(s = \"abcdefghijjjjjjjklmnopqrstuvwxyz\",words = ['abcdefghijklnopqrstuvwxyz', 'abcdefghijjjklmnopqrstuvwxyz', 'abcdefghijjjjjjklmnopqrstuvwxyz', 'abcdefghijjjjjjjklmnopqrstuv', 'abcdefghijjjjjjjmnopqrstuvwxyz']) == 2\n assert candidate(s = \"abcdefghiiiiijjjjjjkkkkkkk\",words = ['abcdefghijjk', 'abcdefghijk', 'abcdefghiiijjjjkk', 'abcdefghiiijjjjjjkkkkk', 'abcdefghiiijjjjjjkkkkkkk']) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abcdefghijklmnopqrstuvwxyzz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyzzz', 'abcdefghijklmnopqrstuvwxyzzzz', 'abcdefghijklmnopqrstuvwxyzzzzz']) == 0\n assert candidate(s = \"aaaaaaabbbbcccdd\",words = ['aabbbccdd', 'aaabbbcccdd', 'aaaabbbcccdd', 'aaaaabbbcccdd', 'aaaaaaabbbcccdd', 'aaaaaaabbbcccd', 'aaaaaaabbbbccdd', 'aaaaaaabbbbcccdd']) == 7\n assert candidate(s = \"qqqqqqqqqqqwwweeeerrrrttttt\",words = ['qqqqqqqwwwreeeeeerttt', 'qqqwwwreeert', 'qqqqqqqwwwreeerrttt', 'qqqqqqqqqqqwwweeeerrrtttt', 'qqqqqqqwwweeeerrrtttt']) == 2\n assert candidate(s = \"abcdeeeeef\",words = ['abcdeeef', 'abcdeeeef', 'abcdeeeeeef', 'abcdfeeeef', 'abcdef']) == 3\n assert candidate(s = \"abbbccdddd\",words = ['abcdd', 'abbbccdd', 'abbbccccdd', 'abbbccdddd', 'aabbccddd']) == 2\n assert candidate(s = \"ppppqqqqrrr\",words = ['pqr', 'pppqqrr', 'ppqqqrrr', 'pppqqqqrrr', 'ppppqqqrrr']) == 5\n assert candidate(s = \"aaaaaabbcccddeeeee\",words = ['aabccddee', 'aaabbbcccdddeeee', 'aaaabbbcccdddeee', 'aaaaabbcccddeeee', 'aaaaabbbbccccddeeeeee']) == 1\n assert candidate(s = \"llllllmmmnnnnoo\",words = ['lmno', 'lllmmnno', 'lllllmmnnnoo', 'lllmmmnnnnoo', 'llllllmmmnnno']) == 2\n assert candidate(s = \"aabbccddeeefffggg\",words = ['aabbccddeefffggg', 'aabbbcccdddeeefffggg', 'aabbccddeeeffffgggg', 'aabbccddeeeffg', 'aabbcddfeeeffggg']) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']) == 4\n assert candidate(s = \"ttrrreeee\",words = ['tree', 'ttrree', 'ttrreee', 'ttreee', 'ttrre', 'ttre', 'trreee', 'ttreere']) == 5\n assert candidate(s = \"mmmaaa\",words = ['maa', 'maaaa', 'mmmaaa', 'mmma', 'mmmaaaam']) == 3\n assert candidate(s = \"sssssssssssssssssssssssssssss\",words = ['s', 'ss', 'sss', 'sssss', 'sssssss', 'sssssssssssssssssssssssssssss']) == 6\n assert candidate(s = \"nnnnooouuuuuuuuu\",words = ['no', 'noon', 'nou', 'noou', 'noonnouuuu', 'nnoooouuuuuuuu', 'nnooouuuuuuuuu', 'nnnooouuuuuuuuu']) == 4\n assert candidate(s = \"aaabbbccc\",words = ['aabbccc', 'aaabccc', 'aaabbbcc', 'aabbbccc', 'aaabbbccccc']) == 4\n assert candidate(s = \"aaabbbcccddd\",words = ['ab', 'aabbccddd', 'aabbbcccddd', 'aaabbbcccdd', 'aaabbbcccd']) == 4\n assert candidate(s = \"aaaabbbbccccdddd\",words = ['aabbccdd', 'aaabbbcccddd', 'aaaabbbbccccdddd', 'aabbbbccccdddd', 'aaaabbbcccdddd']) == 5\n assert candidate(s = \"qqqqqqqqqqqqqqqqq\",words = ['q', 'qq', 'qqq', 'qqqq', 'qqqqq', 'qqqqqq', 'qqqqqqqq', 'qqqqqqqqqqqqqqqqq']) == 8\n assert candidate(s = \"xxxyyyzzz\",words = ['xyzz', 'xxyyz', 'xxyyzz', 'xxxyyyzzz', 'xxxyyzzz', 'xxxxyyzzz', 'xxxyyyyzzz']) == 5\n assert candidate(s = \"abbbbbccccdddd\",words = ['abc', 'abcd', 'abbc', 'abcdd', 'abbbbbccccdddd']) == 3\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",words = ['aabbbccc', 'aaaaaaaaabbbbbbbbbbcccccccc', 'aaaaaaaaabbbbbbbbcccccccccc', 'aaaaaaaaaabbbbbbbbbbcccccc', 'aaaaaaaaaabbbbbbbbbbccccccccccc']) == 4\n assert candidate(s = \"mississiissippii\",words = ['mississippi', 'mississiippii', 'mississsippii', 'mississssippiii', 'mississssiiiiippiii']) == 0\n assert candidate(s = \"xyzzzzzzzzzxyzzzzzzzzzxyzzzzzzzzz\",words = ['xyzyxzy', 'xyzzzxyzzzxyzzz', 'xyzzzzxyzzzzxyzzzz', 'xyzzzzzzzzxyzzzzzzzzxyzzzzzzzz', 'xyzzzzzzzzzxyzzzzzzzzxzzzzzzzzzz']) == 3\n", "comparison": "exact"}, "public_tests": ["\"heeellooo\"\n[\"hello\", \"hi\", \"helo\"]", "\"zzzzzyyyyy\"\n[\"zzyy\",\"zy\",\"zyy\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "words"], "leetcode_dataset_entry_point": "Solution().expressiveWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:26+00:00", "tests_total": 71, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def expressiveWords(self, s: str, words: list[str]) -> int:", "container": "Solution", "callable": "expressiveWords", "parameters": [{"name": "s", "type": "str"}, {"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 810, "task_id": "chalkboard-xor-game", "difficulty": "Hard", "problem_description": "You are given an array of integers nums represents the numbers written on a chalkboard.\n\nAlice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0.\n\nAlso, if any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player wins.\n\nReturn true if and only if Alice wins the game, assuming both players play optimally.\n\nExample 1:\n\nInput: nums = [1,1,2]\nOutput: false\nExplanation:\nAlice has two choices: erase 1 or erase 2.\nIf she erases 1, the nums array becomes [1, 2]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 2 = 3. Now Bob can remove any element he wants, because Alice will be the one to erase the last element and she will lose.\nIf Alice erases 2 first, now nums become [1, 1]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 1 = 0. Alice will lose.\n\nExample 2:\n\nInput: nums = [0,1]\nOutput: true\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: true\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 0 <= nums[i] < 2^16\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [8, 15, 23, 42, 67]) == False\n assert candidate(nums = [1, 2, 2, 1]) == True\n assert candidate(nums = [1, 3, 5, 7, 9]) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 4]) == True\n assert candidate(nums = [1]) == False\n assert candidate(nums = [5, 7, 9, 11]) == True\n assert candidate(nums = [0, 1]) == True\n assert candidate(nums = [4, 5, 6, 7, 8]) == False\n assert candidate(nums = [1, 1, 2]) == False\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 1, 1]) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [4, 4, 4, 4]) == True\n assert candidate(nums = [0, 0, 0, 0]) == True\n assert candidate(nums = [7, 11, 14, 12]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 2]) == 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, 10, 20, 30, 40, 50]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 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]) == True\n assert candidate(nums = [15, 15, 14, 14, 13, 13, 12, 12, 11, 11]) == 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, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 4, 4, 4, 4]) == False\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]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]) == True\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == 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]) == False\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == True\n assert candidate(nums = [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 = [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, 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]) == 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]) == True\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 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 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3, 3, 3, 1]) == 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, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 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]) == True\n assert candidate(nums = [17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23]) == False\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, 16, 16, 16, 16, 16, 16, 16]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 3, 2, 3, 2, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\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, 16]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 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]) == True\n assert candidate(nums = [16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == False\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]) == True\n assert candidate(nums = [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]) == True\n assert candidate(nums = [1, 3, 3, 1, 5, 5, 5]) == 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]) == True\n assert candidate(nums = [3, 3, 4, 4, 4, 5, 5, 5]) == True\n assert candidate(nums = [17, 17, 34, 34, 1, 2, 3, 3, 2, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 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]) == True\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == False\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 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 = [0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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]) == 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]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\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 = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 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 = [7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023]) == 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]) == False\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255]) == False\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]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n", "comparison": "exact"}, "public_tests": ["[1,1,2]", "[0,1]", "[1,2,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().xorGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:28+00:00", "tests_total": 122, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "math", "bit-manipulation", "brainteaser", "game-theory", "zero-sum-game", "impartial-game"]}, "language": "python", "interface": {"raw_signature": "def xorGame(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "xorGame", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 811, "task_id": "subdomain-visit-count", "difficulty": "Medium", "problem_description": "A website domain \"discuss.leetcode.com\" consists of various subdomains. At the top level, we have \"com\", at the next level, we have \"leetcode.com\" and at the lowest level, \"discuss.leetcode.com\". When we visit a domain like \"discuss.leetcode.com\", we will also visit the parent domains \"leetcode.com\" and \"com\" implicitly.\n\nA count-paired domain is a domain that has one of the two formats \"rep d1.d2.d3\" or \"rep d1.d2\" where rep is the number of visits to the domain and d1.d2.d3 is the domain itself.\n\n- For example, \"9001 discuss.leetcode.com\" is a count-paired domain that indicates that discuss.leetcode.com was visited 9001 times.\n\nGiven an array of count-paired domains cpdomains, return an array of the count-paired domains of each subdomain in the input. You may return the answer in any order.\n\nExample 1:\n\nInput: cpdomains = [\"9001 discuss.leetcode.com\"]\nOutput: [\"9001 leetcode.com\",\"9001 discuss.leetcode.com\",\"9001 com\"]\nExplanation: We only have one website domain: \"discuss.leetcode.com\".\nAs discussed above, the subdomain \"leetcode.com\" and \"com\" will also be visited. So they will all be visited 9001 times.\n\nExample 2:\n\nInput: cpdomains = [\"900 google.mail.com\", \"50 yahoo.com\", \"1 intel.mail.com\", \"5 wiki.org\"]\nOutput: [\"901 mail.com\",\"50 yahoo.com\",\"900 google.mail.com\",\"5 wiki.org\",\"5 org\",\"1 intel.mail.com\",\"951 com\"]\nExplanation: We will visit \"google.mail.com\" 900 times, \"yahoo.com\" 50 times, \"intel.mail.com\" once and \"wiki.org\" 5 times.\nFor the subdomains, we will visit \"mail.com\" 900 + 1 = 901 times, \"com\" 900 + 50 + 1 = 951 times, and \"org\" 5 times.\n\nConstraints:\n\n- 1 <= cpdomain.length <= 100\n- 1 <= cpdomain[i].length <= 100\n- cpdomain[i] follows either the \"rep_i d1_i.d2_i.d3_i\" format or the \"rep_i d1_i.d2_i\" format.\n- rep_i is an integer in the range [1, 10^4].\n- d1_i, d2_i, and d3_i consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(cpdomains=['1 x.y.z', '2 y.z', '3 z']), ['1 x.y.z', '3 y.z', '6 z'])\n assert answers_match(candidate(cpdomains=['1 a.com', '2 b.a.com', '3 c.b.a.com']), ['6 a.com', '6 com', '5 b.a.com', '3 c.b.a.com'])\n assert answers_match(candidate(cpdomains=['1 a.com', '2 a.b.com', '3 a.b.c.com']), ['1 a.com', '6 com', '2 a.b.com', '2 b.com', '3 a.b.c.com', '3 b.c.com', '3 c.com'])\n assert answers_match(candidate(cpdomains=['500 blog.example.co', '200 news.example.co', '100 example.co']), ['500 blog.example.co', '800 example.co', '800 co', '200 news.example.co'])\n assert answers_match(candidate(cpdomains=['900 google.mail.com', '50 yahoo.com', '1 intel.mail.com', '5 wiki.org']), ['900 google.mail.com', '901 mail.com', '951 com', '50 yahoo.com', '1 intel.mail.com', '5 wiki.org', '5 org'])\n assert answers_match(candidate(cpdomains=['50 mail.google.com', '1 mail.yahoo.com', '5 mail.msn.com']), ['50 mail.google.com', '50 google.com', '56 com', '1 mail.yahoo.com', '1 yahoo.com', '5 mail.msn.com', '5 msn.com'])\n assert answers_match(candidate(cpdomains=['9001 discuss.leetcode.com']), ['9001 discuss.leetcode.com', '9001 leetcode.com', '9001 com'])\n assert answers_match(candidate(cpdomains=['10 example.com', '5 example.co.uk', '3 sub.example.co.uk']), ['10 example.com', '10 com', '8 example.co.uk', '8 co.uk', '8 uk', '3 sub.example.co.uk'])\n assert answers_match(candidate(cpdomains=['100 x.y.z', '20 w.x.y.z', '30 v.w.x.y.z']), ['150 x.y.z', '150 y.z', '150 z', '50 w.x.y.z', '30 v.w.x.y.z'])\n assert answers_match(candidate(cpdomains=['1 example.com', '2 sub.example.com', '3 sub.sub.example.com']), ['6 example.com', '6 com', '5 sub.example.com', '3 sub.sub.example.com'])\n assert answers_match(candidate(cpdomains=['1000 main.domain.com', '500 sub.main.domain.com', '200 sub.domain.com']), ['1500 main.domain.com', '1700 domain.com', '1700 com', '500 sub.main.domain.com', '200 sub.domain.com'])\n assert answers_match(candidate(cpdomains=['100 a.com', '50 b.a.com', '25 c.b.a.com']), ['175 a.com', '175 com', '75 b.a.com', '25 c.b.a.com'])\n assert answers_match(candidate(cpdomains=['10 example.com', '5 sub.example.com', '3 subsub.example.com']), ['18 example.com', '18 com', '5 sub.example.com', '3 subsub.example.com'])\n assert answers_match(candidate(cpdomains=['700 tech.forum.net', '800 tech.net', '900 forum.net', '1000 net', '500 tech.forum.forge.net', '300 forum.forge.net', '200 forge.net']), ['700 tech.forum.net', '1600 forum.net', '4400 net', '800 tech.net', '500 tech.forum.forge.net', '800 forum.forge.net', '1000 forge.net'])\n assert answers_match(candidate(cpdomains=['300 deep.subdomain.example.com', '200 subdomain.example.com', '100 example.com', '150 another.subdomain.example.com', '50 yet.another.example.com']), ['300 deep.subdomain.example.com', '650 subdomain.example.com', '800 example.com', '800 com', '150 another.subdomain.example.com', '50 yet.another.example.com', '50 another.example.com'])\n assert answers_match(candidate(cpdomains=['3000 complex.sub.domain.com', '2000 sub.domain.com', '1000 domain.com', '500 verydeep.sub.domain.com', '100 verydeep.sub.sub.domain.com']), ['3000 complex.sub.domain.com', '5600 sub.domain.com', '6600 domain.com', '6600 com', '500 verydeep.sub.domain.com', '100 verydeep.sub.sub.domain.com', '100 sub.sub.domain.com'])\n assert answers_match(candidate(cpdomains=['300 www.example.co.uk', '200 mail.example.co.uk', '150 blog.example.co.uk', '100 co.uk']), ['300 www.example.co.uk', '650 example.co.uk', '750 co.uk', '750 uk', '200 mail.example.co.uk', '150 blog.example.co.uk'])\n assert answers_match(candidate(cpdomains=['600 alpha.beta.gamma.delta.com', '500 beta.gamma.delta.com', '400 gamma.delta.com', '300 delta.com', '200 alpha.com', '100 com']), ['600 alpha.beta.gamma.delta.com', '1100 beta.gamma.delta.com', '1500 gamma.delta.com', '1800 delta.com', '2100 com', '200 alpha.com'])\n assert answers_match(candidate(cpdomains=['1000 x.y.z.com', '500 y.z.com', '250 z.com', '150 a.b.y.z.com', '100 b.y.z.com', '75 y.z.com', '60 z.com', '40 w.x.y.z.com']), ['1040 x.y.z.com', '1865 y.z.com', '2175 z.com', '2175 com', '150 a.b.y.z.com', '250 b.y.z.com', '40 w.x.y.z.com'])\n assert answers_match(candidate(cpdomains=['100 one.two.three.four.com', '200 two.three.four.com', '150 three.four.com', '100 four.com', '75 one.two.four.com', '50 two.four.com', '40 four.com', '25 one.two.three.com', '100 two.three.com', '60 three.com', '35 com']), ['100 one.two.three.four.com', '300 two.three.four.com', '450 three.four.com', '715 four.com', '935 com', '75 one.two.four.com', '125 two.four.com', '25 one.two.three.com', '125 two.three.com', '185 three.com'])\n assert answers_match(candidate(cpdomains=['10 co.uk', '20 uk', '30 com', '40 google.com', '50 google.co.uk', '60 blog.google.co.uk', '70 news.google.co.uk', '80 mail.google.co.uk', '90 google.uk', '100 uk', '200 blog.uk', '300 news.uk', '400 mail.uk']), ['270 co.uk', '1380 uk', '70 com', '40 google.com', '260 google.co.uk', '60 blog.google.co.uk', '70 news.google.co.uk', '80 mail.google.co.uk', '90 google.uk', '200 blog.uk', '300 news.uk', '400 mail.uk'])\n assert answers_match(candidate(cpdomains=['100 example1.com', '200 example2.com', '300 example3.com', '400 example4.com', '500 example5.com', '600 example6.com', '700 example7.com', '800 example8.com', '900 example9.com', '1000 example10.com']), ['100 example1.com', '5500 com', '200 example2.com', '300 example3.com', '400 example4.com', '500 example5.com', '600 example6.com', '700 example7.com', '800 example8.com', '900 example9.com', '1000 example10.com'])\n assert answers_match(candidate(cpdomains=['1000 main.homepage.net', '2000 sub.main.homepage.net', '300 sub.homepage.net', '150 homepage.net', '500 main.net', '100 net', '250 sub.sub.main.homepage.net']), ['3250 main.homepage.net', '3700 homepage.net', '4300 net', '2250 sub.main.homepage.net', '300 sub.homepage.net', '500 main.net', '250 sub.sub.main.homepage.net'])\n assert answers_match(candidate(cpdomains=['1200 verydeep.subdomain.example.com', '300 deep.subdomain.example.com', '400 subdomain.example.com', '100 example.com']), ['1200 verydeep.subdomain.example.com', '1900 subdomain.example.com', '2000 example.com', '2000 com', '300 deep.subdomain.example.com'])\n assert answers_match(candidate(cpdomains=['800 blog.medium.com', '200 tech.medium.com', '300 news.medium.com', '100 medium.com', '500 articles.blog.medium.com']), ['1300 blog.medium.com', '1900 medium.com', '1900 com', '200 tech.medium.com', '300 news.medium.com', '500 articles.blog.medium.com'])\n assert answers_match(candidate(cpdomains=['1000 main.site.org', '500 sub1.main.site.org', '200 sub2.main.site.org', '100 site.org', '50 sub3.sub1.main.site.org', '25 sub4.sub1.main.site.org']), ['1775 main.site.org', '1875 site.org', '1875 org', '575 sub1.main.site.org', '200 sub2.main.site.org', '50 sub3.sub1.main.site.org', '25 sub4.sub1.main.site.org'])\n assert answers_match(candidate(cpdomains=['10000 top.level.domain.io', '9000 level.domain.io', '8000 domain.io', '7000 io', '6000 another.top.level.domain.io', '5000 another.level.domain.io', '4000 another.domain.io', '3000 another.io']), ['16000 top.level.domain.io', '30000 level.domain.io', '42000 domain.io', '52000 io', '6000 another.top.level.domain.io', '5000 another.level.domain.io', '4000 another.domain.io', '3000 another.io'])\n assert answers_match(candidate(cpdomains=['500 support.microsoft.com', '300 download.microsoft.com', '200 services.microsoft.com', '100 microsoft.com', '400 updates.microsoft.com', '150 secure.microsoft.com']), ['500 support.microsoft.com', '1650 microsoft.com', '1650 com', '300 download.microsoft.com', '200 services.microsoft.com', '400 updates.microsoft.com', '150 secure.microsoft.com'])\n assert answers_match(candidate(cpdomains=['100 forum.discussion.community.org', '50 news.discussion.community.org', '200 discussion.community.org', '100 community.org', '50 org', '300 updates.discussion.community.org']), ['100 forum.discussion.community.org', '650 discussion.community.org', '750 community.org', '800 org', '50 news.discussion.community.org', '300 updates.discussion.community.org'])\n assert answers_match(candidate(cpdomains=['150 mail.google.com', '50 docs.google.com', '200 accounts.google.com', '100 google.com', '300 app.mail.google.com']), ['450 mail.google.com', '800 google.com', '800 com', '50 docs.google.com', '200 accounts.google.com', '300 app.mail.google.com'])\n assert answers_match(candidate(cpdomains=['10000 main.prod.env.com', '5000 sub.main.prod.env.com', '2500 service.sub.main.prod.env.com', '1250 prod.env.com', '625 env.com', '312 helper.service.sub.main.prod.env.com', '156 feedback.helper.service.sub.main.prod.env.com']), ['17968 main.prod.env.com', '19218 prod.env.com', '19843 env.com', '19843 com', '7968 sub.main.prod.env.com', '2968 service.sub.main.prod.env.com', '468 helper.service.sub.main.prod.env.com', '156 feedback.helper.service.sub.main.prod.env.com'])\n assert answers_match(candidate(cpdomains=['1 abc.def.ghi', '2 abc.def', '3 def', '4 ghi', '5 abc', '6 abc.def.ghi.jkl', '7 def.ghi.jkl', '8 ghi.jkl', '9 jkl']), ['1 abc.def.ghi', '1 def.ghi', '5 ghi', '2 abc.def', '5 def', '5 abc', '6 abc.def.ghi.jkl', '13 def.ghi.jkl', '21 ghi.jkl', '30 jkl'])\n assert answers_match(candidate(cpdomains=['10000 main.example.com', '3000 sub1.main.example.com', '2000 sub2.sub1.main.example.com', '1500 sub.example.com', '1000 another.sub.example.com']), ['15000 main.example.com', '17500 example.com', '17500 com', '5000 sub1.main.example.com', '2000 sub2.sub1.main.example.com', '2500 sub.example.com', '1000 another.sub.example.com'])\n assert answers_match(candidate(cpdomains=['100 company.corp.local', '200 it.corp.local', '300 hr.corp.local', '400 dev.it.corp.local', '500 qa.it.corp.local', '600 design.it.corp.local', '700 finance.hr.corp.local', '800 marketing.hr.corp.local']), ['100 company.corp.local', '3600 corp.local', '3600 local', '1700 it.corp.local', '1800 hr.corp.local', '400 dev.it.corp.local', '500 qa.it.corp.local', '600 design.it.corp.local', '700 finance.hr.corp.local', '800 marketing.hr.corp.local'])\n assert answers_match(candidate(cpdomains=['1000 a.b.c.d.e.com', '500 f.g.c.d.e.com', '250 g.c.d.e.com', '125 c.d.e.com', '60 d.e.com', '30 e.com']), ['1000 a.b.c.d.e.com', '1000 b.c.d.e.com', '1875 c.d.e.com', '1935 d.e.com', '1965 e.com', '1965 com', '500 f.g.c.d.e.com', '750 g.c.d.e.com'])\n assert answers_match(candidate(cpdomains=['1 abc.com', '2 xyz.abc.com', '3 def.abc.com', '4 ghi.def.abc.com', '5 jkl.ghi.def.abc.com', '6 mno.jkl.ghi.def.abc.com']), ['21 abc.com', '21 com', '2 xyz.abc.com', '18 def.abc.com', '15 ghi.def.abc.com', '11 jkl.ghi.def.abc.com', '6 mno.jkl.ghi.def.abc.com'])\n assert answers_match(candidate(cpdomains=['1500 tech.gaming.website.com', '300 mobile.gaming.website.com', '200 gaming.website.com', '1000 website.com']), ['1500 tech.gaming.website.com', '2000 gaming.website.com', '3000 website.com', '3000 com', '300 mobile.gaming.website.com'])\n assert answers_match(candidate(cpdomains=['150 tech.productivitytools.io', '250 productivitytools.io', '400 blog.productivitytools.io', '300 dev.productivitytools.io', '200 docs.productivitytools.io', '100 io']), ['150 tech.productivitytools.io', '1300 productivitytools.io', '1400 io', '400 blog.productivitytools.io', '300 dev.productivitytools.io', '200 docs.productivitytools.io'])\n assert answers_match(candidate(cpdomains=['1500 forum.discussion.web', '2500 chat.forum.discussion.web', '1000 support.web', '500 help.support.web', '2000 help.web', '800 forum.web', '1200 web']), ['4000 forum.discussion.web', '4000 discussion.web', '9500 web', '2500 chat.forum.discussion.web', '1500 support.web', '500 help.support.web', '2000 help.web', '800 forum.web'])\n assert answers_match(candidate(cpdomains=['200 admin.internal.server.net', '150 db.internal.server.net', '100 internal.server.net', '50 server.net', '25 net']), ['200 admin.internal.server.net', '450 internal.server.net', '500 server.net', '525 net', '150 db.internal.server.net'])\n assert answers_match(candidate(cpdomains=['100 abc.def.com', '200 def.com', '300 ghi.jkl.com', '400 jkl.com', '500 mno.pqr.com', '600 pqr.com']), ['100 abc.def.com', '300 def.com', '2100 com', '300 ghi.jkl.com', '700 jkl.com', '500 mno.pqr.com', '1100 pqr.com'])\n assert answers_match(candidate(cpdomains=['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.com', '2 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.com', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com']), ['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.com', '1 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.com', '1 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 o.p.q.r.s.t.u.v.w.x.y.z.com', '1 p.q.r.s.t.u.v.w.x.y.z.com', '1 q.r.s.t.u.v.w.x.y.z.com', '1 r.s.t.u.v.w.x.y.z.com', '1 s.t.u.v.w.x.y.z.com', '1 t.u.v.w.x.y.z.com', '1 u.v.w.x.y.z.com', '1 v.w.x.y.z.com', '1 w.x.y.z.com', '1 x.y.z.com', '1 y.z.com', '1 z.com', '6 com', '2 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.com', '2 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 n.o.p.q.r.s.t.u.v.w.x.y.com', '2 o.p.q.r.s.t.u.v.w.x.y.com', '2 p.q.r.s.t.u.v.w.x.y.com', '2 q.r.s.t.u.v.w.x.y.com', '2 r.s.t.u.v.w.x.y.com', '2 s.t.u.v.w.x.y.com', '2 t.u.v.w.x.y.com', '2 u.v.w.x.y.com', '2 v.w.x.y.com', '2 w.x.y.com', '2 x.y.com', '2 y.com', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 m.n.o.p.q.r.s.t.u.v.w.x.com', '3 n.o.p.q.r.s.t.u.v.w.x.com', '3 o.p.q.r.s.t.u.v.w.x.com', '3 p.q.r.s.t.u.v.w.x.com', '3 q.r.s.t.u.v.w.x.com', '3 r.s.t.u.v.w.x.com', '3 s.t.u.v.w.x.com', '3 t.u.v.w.x.com', '3 u.v.w.x.com', '3 v.w.x.com', '3 w.x.com', '3 x.com'])\n assert answers_match(candidate(cpdomains=['1000 blog.devsite.co.uk', '2000 devsite.co.uk', '300 sub.devsite.co.uk', '150 sub.blog.devsite.co.uk', '500 blog.co.uk', '100 co.uk']), ['1150 blog.devsite.co.uk', '3450 devsite.co.uk', '4050 co.uk', '4050 uk', '300 sub.devsite.co.uk', '150 sub.blog.devsite.co.uk', '500 blog.co.uk'])\n assert answers_match(candidate(cpdomains=['1 example.net', '2 sub1.example.net', '3 sub2.sub1.example.net', '4 sub3.sub2.sub1.example.net', '5 sub4.sub3.sub2.sub1.example.net']), ['15 example.net', '15 net', '14 sub1.example.net', '12 sub2.sub1.example.net', '9 sub3.sub2.sub1.example.net', '5 sub4.sub3.sub2.sub1.example.net'])\n assert answers_match(candidate(cpdomains=['150 a.b.com', '200 b.com', '100 a.c.com', '120 c.com', '80 a.b.c.com', '50 b.c.com', '30 c.com', '25 d.e.f.g.com']), ['150 a.b.com', '350 b.com', '755 com', '100 a.c.com', '380 c.com', '80 a.b.c.com', '130 b.c.com', '25 d.e.f.g.com', '25 e.f.g.com', '25 f.g.com', '25 g.com'])\n assert answers_match(candidate(cpdomains=['10 tech.guru.experts.net', '20 experts.net', '30 guru.experts.net', '40 tech.net', '50 guru.net', '60 tech.guru.net', '70 guru.experts.net', '80 experts.tech.guru.net']), ['10 tech.guru.experts.net', '110 guru.experts.net', '130 experts.net', '360 net', '40 tech.net', '190 guru.net', '140 tech.guru.net', '80 experts.tech.guru.net'])\n assert answers_match(candidate(cpdomains=['300 tech.interview.prep.co', '200 coding.blog.tech.interview.prep.co', '100 interview.prep.co', '50 prep.co']), ['500 tech.interview.prep.co', '600 interview.prep.co', '650 prep.co', '650 co', '200 coding.blog.tech.interview.prep.co', '200 blog.tech.interview.prep.co'])\n assert answers_match(candidate(cpdomains=['1234 main.site.org', '4321 sub.site.org', '1111 sub.sub.site.org', '2222 site.org']), ['1234 main.site.org', '8888 site.org', '8888 org', '5432 sub.site.org', '1111 sub.sub.site.org'])\n assert answers_match(candidate(cpdomains=['12000 main.home.user.net', '6000 personal.main.home.user.net', '4000 work.home.user.net', '3000 personal.work.home.user.net', '2000 user.net', '1500 home.user.net', '1000 main.user.net']), ['18000 main.home.user.net', '26500 home.user.net', '29500 user.net', '29500 net', '6000 personal.main.home.user.net', '7000 work.home.user.net', '3000 personal.work.home.user.net', '1000 main.user.net'])\n assert answers_match(candidate(cpdomains=['9001 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 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 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', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '4 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '5 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '6 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '7 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '8 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '9 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '10 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '11 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', '12 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o', '13 a.b.c.d.e.f.g.h.i.j.k.l.m.n', '14 a.b.c.d.e.f.g.h.i.j.k.l.m', '15 a.b.c.d.e.f.g.h.i.j.k.l', '16 a.b.c.d.e.f.g.h.i.j.k', '17 a.b.c.d.e.f.g.h.i.j', '18 a.b.c.d.e.f.g.h.i', '19 a.b.c.d.e.f.g.h', '20 a.b.c.d.e.f.g']), ['9002 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', '9002 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', '9002 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 o.p.q.r.s.t.u.v.w.x.y.z', '9002 p.q.r.s.t.u.v.w.x.y.z', '9002 q.r.s.t.u.v.w.x.y.z', '9002 r.s.t.u.v.w.x.y.z', '9002 s.t.u.v.w.x.y.z', '9002 t.u.v.w.x.y.z', '9002 u.v.w.x.y.z', '9002 v.w.x.y.z', '9002 w.x.y.z', '9002 x.y.z', '9002 y.z', '9002 z', '2 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', '2 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 m.n.o.p.q.r.s.t.u.v.w.x.y', '2 n.o.p.q.r.s.t.u.v.w.x.y', '2 o.p.q.r.s.t.u.v.w.x.y', '2 p.q.r.s.t.u.v.w.x.y', '2 q.r.s.t.u.v.w.x.y', '2 r.s.t.u.v.w.x.y', '2 s.t.u.v.w.x.y', '2 t.u.v.w.x.y', '2 u.v.w.x.y', '2 v.w.x.y', '2 w.x.y', '2 x.y', '2 y', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 l.m.n.o.p.q.r.s.t.u.v.w.x', '3 m.n.o.p.q.r.s.t.u.v.w.x', '3 n.o.p.q.r.s.t.u.v.w.x', '3 o.p.q.r.s.t.u.v.w.x', '3 p.q.r.s.t.u.v.w.x', '3 q.r.s.t.u.v.w.x', '3 r.s.t.u.v.w.x', '3 s.t.u.v.w.x', '3 t.u.v.w.x', '3 u.v.w.x', '3 v.w.x', '3 w.x', '3 x', '4 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 k.l.m.n.o.p.q.r.s.t.u.v.w', '4 l.m.n.o.p.q.r.s.t.u.v.w', '4 m.n.o.p.q.r.s.t.u.v.w', '4 n.o.p.q.r.s.t.u.v.w', '4 o.p.q.r.s.t.u.v.w', '4 p.q.r.s.t.u.v.w', '4 q.r.s.t.u.v.w', '4 r.s.t.u.v.w', '4 s.t.u.v.w', '4 t.u.v.w', '4 u.v.w', '4 v.w', '4 w', '5 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 j.k.l.m.n.o.p.q.r.s.t.u.v', '5 k.l.m.n.o.p.q.r.s.t.u.v', '5 l.m.n.o.p.q.r.s.t.u.v', '5 m.n.o.p.q.r.s.t.u.v', '5 n.o.p.q.r.s.t.u.v', '5 o.p.q.r.s.t.u.v', '5 p.q.r.s.t.u.v', '5 q.r.s.t.u.v', '5 r.s.t.u.v', '5 s.t.u.v', '5 t.u.v', '5 u.v', '5 v', '6 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 i.j.k.l.m.n.o.p.q.r.s.t.u', '6 j.k.l.m.n.o.p.q.r.s.t.u', '6 k.l.m.n.o.p.q.r.s.t.u', '6 l.m.n.o.p.q.r.s.t.u', '6 m.n.o.p.q.r.s.t.u', '6 n.o.p.q.r.s.t.u', '6 o.p.q.r.s.t.u', '6 p.q.r.s.t.u', '6 q.r.s.t.u', '6 r.s.t.u', '6 s.t.u', '6 t.u', '6 u', '7 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 h.i.j.k.l.m.n.o.p.q.r.s.t', '7 i.j.k.l.m.n.o.p.q.r.s.t', '7 j.k.l.m.n.o.p.q.r.s.t', '7 k.l.m.n.o.p.q.r.s.t', '7 l.m.n.o.p.q.r.s.t', '7 m.n.o.p.q.r.s.t', '7 n.o.p.q.r.s.t', '7 o.p.q.r.s.t', '7 p.q.r.s.t', '7 q.r.s.t', '7 r.s.t', '7 s.t', '7 t', '8 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 g.h.i.j.k.l.m.n.o.p.q.r.s', '8 h.i.j.k.l.m.n.o.p.q.r.s', '8 i.j.k.l.m.n.o.p.q.r.s', '8 j.k.l.m.n.o.p.q.r.s', '8 k.l.m.n.o.p.q.r.s', '8 l.m.n.o.p.q.r.s', '8 m.n.o.p.q.r.s', '8 n.o.p.q.r.s', '8 o.p.q.r.s', '8 p.q.r.s', '8 q.r.s', '8 r.s', '8 s', '9 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 f.g.h.i.j.k.l.m.n.o.p.q.r', '9 g.h.i.j.k.l.m.n.o.p.q.r', '9 h.i.j.k.l.m.n.o.p.q.r', '9 i.j.k.l.m.n.o.p.q.r', '9 j.k.l.m.n.o.p.q.r', '9 k.l.m.n.o.p.q.r', '9 l.m.n.o.p.q.r', '9 m.n.o.p.q.r', '9 n.o.p.q.r', '9 o.p.q.r', '9 p.q.r', '9 q.r', '9 r', '10 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 e.f.g.h.i.j.k.l.m.n.o.p.q', '10 f.g.h.i.j.k.l.m.n.o.p.q', '10 g.h.i.j.k.l.m.n.o.p.q', '10 h.i.j.k.l.m.n.o.p.q', '10 i.j.k.l.m.n.o.p.q', '10 j.k.l.m.n.o.p.q', '10 k.l.m.n.o.p.q', '10 l.m.n.o.p.q', '10 m.n.o.p.q', '10 n.o.p.q', '10 o.p.q', '10 p.q', '10 q', '11 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', '11 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', '11 c.d.e.f.g.h.i.j.k.l.m.n.o.p', '11 d.e.f.g.h.i.j.k.l.m.n.o.p', '11 e.f.g.h.i.j.k.l.m.n.o.p', '11 f.g.h.i.j.k.l.m.n.o.p', '11 g.h.i.j.k.l.m.n.o.p', '11 h.i.j.k.l.m.n.o.p', '11 i.j.k.l.m.n.o.p', '11 j.k.l.m.n.o.p', '11 k.l.m.n.o.p', '11 l.m.n.o.p', '11 m.n.o.p', '11 n.o.p', '11 o.p', '11 p', '12 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o', '12 b.c.d.e.f.g.h.i.j.k.l.m.n.o', '12 c.d.e.f.g.h.i.j.k.l.m.n.o', '12 d.e.f.g.h.i.j.k.l.m.n.o', '12 e.f.g.h.i.j.k.l.m.n.o', '12 f.g.h.i.j.k.l.m.n.o', '12 g.h.i.j.k.l.m.n.o', '12 h.i.j.k.l.m.n.o', '12 i.j.k.l.m.n.o', '12 j.k.l.m.n.o', '12 k.l.m.n.o', '12 l.m.n.o', '12 m.n.o', '12 n.o', '12 o', '13 a.b.c.d.e.f.g.h.i.j.k.l.m.n', '13 b.c.d.e.f.g.h.i.j.k.l.m.n', '13 c.d.e.f.g.h.i.j.k.l.m.n', '13 d.e.f.g.h.i.j.k.l.m.n', '13 e.f.g.h.i.j.k.l.m.n', '13 f.g.h.i.j.k.l.m.n', '13 g.h.i.j.k.l.m.n', '13 h.i.j.k.l.m.n', '13 i.j.k.l.m.n', '13 j.k.l.m.n', '13 k.l.m.n', '13 l.m.n', '13 m.n', '13 n', '14 a.b.c.d.e.f.g.h.i.j.k.l.m', '14 b.c.d.e.f.g.h.i.j.k.l.m', '14 c.d.e.f.g.h.i.j.k.l.m', '14 d.e.f.g.h.i.j.k.l.m', '14 e.f.g.h.i.j.k.l.m', '14 f.g.h.i.j.k.l.m', '14 g.h.i.j.k.l.m', '14 h.i.j.k.l.m', '14 i.j.k.l.m', '14 j.k.l.m', '14 k.l.m', '14 l.m', '14 m', '15 a.b.c.d.e.f.g.h.i.j.k.l', '15 b.c.d.e.f.g.h.i.j.k.l', '15 c.d.e.f.g.h.i.j.k.l', '15 d.e.f.g.h.i.j.k.l', '15 e.f.g.h.i.j.k.l', '15 f.g.h.i.j.k.l', '15 g.h.i.j.k.l', '15 h.i.j.k.l', '15 i.j.k.l', '15 j.k.l', '15 k.l', '15 l', '16 a.b.c.d.e.f.g.h.i.j.k', '16 b.c.d.e.f.g.h.i.j.k', '16 c.d.e.f.g.h.i.j.k', '16 d.e.f.g.h.i.j.k', '16 e.f.g.h.i.j.k', '16 f.g.h.i.j.k', '16 g.h.i.j.k', '16 h.i.j.k', '16 i.j.k', '16 j.k', '16 k', '17 a.b.c.d.e.f.g.h.i.j', '17 b.c.d.e.f.g.h.i.j', '17 c.d.e.f.g.h.i.j', '17 d.e.f.g.h.i.j', '17 e.f.g.h.i.j', '17 f.g.h.i.j', '17 g.h.i.j', '17 h.i.j', '17 i.j', '17 j', '18 a.b.c.d.e.f.g.h.i', '18 b.c.d.e.f.g.h.i', '18 c.d.e.f.g.h.i', '18 d.e.f.g.h.i', '18 e.f.g.h.i', '18 f.g.h.i', '18 g.h.i', '18 h.i', '18 i', '19 a.b.c.d.e.f.g.h', '19 b.c.d.e.f.g.h', '19 c.d.e.f.g.h', '19 d.e.f.g.h', '19 e.f.g.h', '19 f.g.h', '19 g.h', '19 h', '20 a.b.c.d.e.f.g', '20 b.c.d.e.f.g', '20 c.d.e.f.g', '20 d.e.f.g', '20 e.f.g', '20 f.g', '20 g'])\n assert answers_match(candidate(cpdomains=['75 blog.health.com', '25 news.health.com', '50 health.com', '1000 medicine.com', '500 health.medicine.com']), ['75 blog.health.com', '150 health.com', '1650 com', '25 news.health.com', '1500 medicine.com', '500 health.medicine.com'])\n assert answers_match(candidate(cpdomains=['1234 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', '5678 y.x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a']), ['1234 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', '1234 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', '1234 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 o.p.q.r.s.t.u.v.w.x.y.z', '1234 p.q.r.s.t.u.v.w.x.y.z', '1234 q.r.s.t.u.v.w.x.y.z', '1234 r.s.t.u.v.w.x.y.z', '1234 s.t.u.v.w.x.y.z', '1234 t.u.v.w.x.y.z', '1234 u.v.w.x.y.z', '1234 v.w.x.y.z', '1234 w.x.y.z', '1234 x.y.z', '1234 y.z', '1234 z', '5678 y.x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 l.k.j.i.h.g.f.e.d.c.b.a', '5678 k.j.i.h.g.f.e.d.c.b.a', '5678 j.i.h.g.f.e.d.c.b.a', '5678 i.h.g.f.e.d.c.b.a', '5678 h.g.f.e.d.c.b.a', '5678 g.f.e.d.c.b.a', '5678 f.e.d.c.b.a', '5678 e.d.c.b.a', '5678 d.c.b.a', '5678 c.b.a', '5678 b.a', '5678 a'])\n assert answers_match(candidate(cpdomains=['9000 market.shop.com', '4500 tech.shop.com', '2250 blog.shop.com', '1125 shop.com', '562 support.blog.shop.com', '281 team.support.blog.shop.com', '140 help.team.support.blog.shop.com']), ['9000 market.shop.com', '17858 shop.com', '17858 com', '4500 tech.shop.com', '3233 blog.shop.com', '983 support.blog.shop.com', '421 team.support.blog.shop.com', '140 help.team.support.blog.shop.com'])\n assert answers_match(candidate(cpdomains=['1000 a.b.c.d.e', '500 f.g.h.i', '200 j.k.l', '300 m.n.o.p']), ['1000 a.b.c.d.e', '1000 b.c.d.e', '1000 c.d.e', '1000 d.e', '1000 e', '500 f.g.h.i', '500 g.h.i', '500 h.i', '500 i', '200 j.k.l', '200 k.l', '200 l', '300 m.n.o.p', '300 n.o.p', '300 o.p', '300 p'])\n assert answers_match(candidate(cpdomains=['10 main.business.world.com', '2 sub.main.business.world.com', '3 subsub.main.business.world.com', '4 business.world.com', '5 world.com']), ['15 main.business.world.com', '19 business.world.com', '24 world.com', '24 com', '2 sub.main.business.world.com', '3 subsub.main.business.world.com'])\n assert answers_match(candidate(cpdomains=['4000 blog.news.co', '1500 tech.blog.news.co', '1000 sports.co', '2000 sports.news.co', '500 tech.sports.co', '300 tech.co']), ['5500 blog.news.co', '7500 news.co', '9300 co', '1500 tech.blog.news.co', '1500 sports.co', '2000 sports.news.co', '500 tech.sports.co', '300 tech.co'])\n assert answers_match(candidate(cpdomains=['300 video.youtube.com', '200 music.youtube.com', '100 youtube.com', '500 m.youtube.com', '200 mobile.youtube.com', '100 google.com', '50 com']), ['300 video.youtube.com', '1300 youtube.com', '1450 com', '200 music.youtube.com', '500 m.youtube.com', '200 mobile.youtube.com', '100 google.com'])\n assert answers_match(candidate(cpdomains=['300 blog.businessinsider.com', '400 businessinsider.com', '200 news.businessinsider.com', '100 tech.businessinsider.com', '50 insider.com', '500 blog.insider.com', '200 tech.insider.com', '100 insider.com']), ['300 blog.businessinsider.com', '1000 businessinsider.com', '1850 com', '200 news.businessinsider.com', '100 tech.businessinsider.com', '850 insider.com', '500 blog.insider.com', '200 tech.insider.com'])\n assert answers_match(candidate(cpdomains=['500 blog.example.co', '300 news.example.co', '200 tech.example.co', '100 example.co', '50 sub.tech.example.co']), ['500 blog.example.co', '1150 example.co', '1150 co', '300 news.example.co', '250 tech.example.co', '50 sub.tech.example.co'])\n assert answers_match(candidate(cpdomains=['1234 company.job.search.engine.com', '4321 job.search.engine.com', '1111 search.engine.com', '2222 engine.com', '3333 com', '5678 tech.engine.com', '8765 tech.com']), ['1234 company.job.search.engine.com', '5555 job.search.engine.com', '6666 search.engine.com', '14566 engine.com', '26664 com', '5678 tech.engine.com', '8765 tech.com'])\n assert answers_match(candidate(cpdomains=['10000 web.page.co.uk', '2500 blog.page.co.uk', '1500 news.page.co.uk', '1000 mail.co.uk', '5000 co.uk', '7500 uk']), ['10000 web.page.co.uk', '14000 page.co.uk', '20000 co.uk', '27500 uk', '2500 blog.page.co.uk', '1500 news.page.co.uk', '1000 mail.co.uk'])\n assert answers_match(candidate(cpdomains=['1000 news.media.co', '5000 news.sport.media.co', '3000 news.culture.media.co', '2000 sport.media.co', '1500 culture.media.co', '1000 media.co', '800 news.co', '500 co']), ['1000 news.media.co', '13500 media.co', '14800 co', '5000 news.sport.media.co', '7000 sport.media.co', '3000 news.culture.media.co', '4500 culture.media.co', '800 news.co'])\n assert answers_match(candidate(cpdomains=['10 abc.def.ghi', '20 def.ghi', '30 ghi', '40 h.i.j', '50 i.j', '60 j', '70 k.l.m', '80 l.m', '90 m']), ['10 abc.def.ghi', '30 def.ghi', '60 ghi', '40 h.i.j', '90 i.j', '150 j', '70 k.l.m', '150 l.m', '240 m'])\n assert answers_match(candidate(cpdomains=['1000 main.domain.com', '500 sub.main.domain.com', '200 sub.domain.com', '300 another.sub.main.domain.com', '150 sub.another.main.domain.com', '50 yet.another.domain.com', '25 yet.sub.another.domain.com', '125 another.yet.sub.domain.com']), ['1950 main.domain.com', '2350 domain.com', '2350 com', '800 sub.main.domain.com', '325 sub.domain.com', '300 another.sub.main.domain.com', '150 sub.another.main.domain.com', '150 another.main.domain.com', '50 yet.another.domain.com', '75 another.domain.com', '25 yet.sub.another.domain.com', '25 sub.another.domain.com', '125 another.yet.sub.domain.com', '125 yet.sub.domain.com'])\n assert answers_match(candidate(cpdomains=['750 gaming.gamesite.net', '250 gamesite.net', '150 news.gamesite.net', '1000 gaming.net', '500 net', '200 streaming.gamesite.net', '100 gaming.streaming.gamesite.net']), ['750 gaming.gamesite.net', '1450 gamesite.net', '2950 net', '150 news.gamesite.net', '1000 gaming.net', '300 streaming.gamesite.net', '100 gaming.streaming.gamesite.net'])\n assert answers_match(candidate(cpdomains=['250 news.market.com', '150 finance.market.com', '1000 market.com', '500 news.international.market.com', '300 finance.international.market.com', '200 international.market.com']), ['250 news.market.com', '2400 market.com', '2400 com', '150 finance.market.com', '500 news.international.market.com', '1000 international.market.com', '300 finance.international.market.com'])\n assert answers_match(candidate(cpdomains=['1234 a.b.c.d.e.f.com', '5678 g.h.i.j.k.com', '9101 l.m.n.o.p.q.r.com', '1112 m.n.o.p.q.r.com', '1314 n.o.p.q.r.com']), ['1234 a.b.c.d.e.f.com', '1234 b.c.d.e.f.com', '1234 c.d.e.f.com', '1234 d.e.f.com', '1234 e.f.com', '1234 f.com', '18439 com', '5678 g.h.i.j.k.com', '5678 h.i.j.k.com', '5678 i.j.k.com', '5678 j.k.com', '5678 k.com', '9101 l.m.n.o.p.q.r.com', '10213 m.n.o.p.q.r.com', '11527 n.o.p.q.r.com', '11527 o.p.q.r.com', '11527 p.q.r.com', '11527 q.r.com', '11527 r.com'])\n assert answers_match(candidate(cpdomains=['500 x.y.z', '200 a.b.c.d', '100 e.f.g', '400 h.i.j.k.l', '600 m.n.o']), ['500 x.y.z', '500 y.z', '500 z', '200 a.b.c.d', '200 b.c.d', '200 c.d', '200 d', '100 e.f.g', '100 f.g', '100 g', '400 h.i.j.k.l', '400 i.j.k.l', '400 j.k.l', '400 k.l', '400 l', '600 m.n.o', '600 n.o', '600 o'])\n", "comparison": "unordered"}, "public_tests": ["[\"9001 discuss.leetcode.com\"]", "[\"900 google.mail.com\", \"50 yahoo.com\", \"1 intel.mail.com\", \"5 wiki.org\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["cpdomains"], "leetcode_dataset_entry_point": "Solution().subdomainVisits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:30+00:00", "tests_total": 68, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def subdomainVisits(self, cpdomains: list[str]) -> list[str]:", "container": "Solution", "callable": "subdomainVisits", "parameters": [{"name": "cpdomains", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 812, "task_id": "largest-triangle-area", "difficulty": "Easy", "problem_description": "Given an array of points on the X-Y plane points where points[i] = [x_i, y_i], return the area of the largest triangle that can be formed by any three different points. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]\nOutput: 2.00000\nExplanation: The five points are shown in the above figure. The red triangle is the largest.\n\nExample 2:\n\nInput: points = [[1,0],[0,0],[0,1]]\nOutput: 0.50000\n\nConstraints:\n\n- 3 <= points.length <= 50\n- -50 <= x_i, y_i <= 50\n- All the given points are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [-2, -3], [-3, -1]]), 2.0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [-50, 50], [50, -50], [0, 0]]), 5000.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [0, 2], [2, 0]]), 2.0)\n assert answers_match(candidate(points=[[-50, -50], [-50, 50], [50, -50], [50, 50], [0, 0]]), 5000.0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [0, 0]]), 0)\n assert answers_match(candidate(points=[[10, 10], [10, 20], [20, 10], [20, 20], [15, 15]]), 50.0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [3, 1]]), 2.0)\n assert answers_match(candidate(points=[[-1, 0], [0, -1], [1, 0], [0, 1], [0, 0]]), 1.0)\n assert answers_match(candidate(points=[[-50, -50], [-49, -49], [-48, -48], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [0, 0], [25, -25], [-25, 25]]), 2500.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [0.5, 0.5]]), 0.5)\n assert answers_match(candidate(points=[[1, 0], [0, 0], [0, 1]]), 0.5)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [5, 5], [5, 10], [10, 5]]), 50.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2]]), 1.5)\n assert answers_match(candidate(points=[[0, 0], [5, 0], [0, 5]]), 12.5)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [-1, 1], [1, -1], [0, 0]]), 2.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[10, 0], [0, 10], [-10, 0], [0, -10], [0, 0]]), 100.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [5, 1], [3, 4], [4, 5], [6, 2]]), 8.5)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[-10, -10], [10, 10], [-10, 10], [10, -10], [0, 0]]), 200.0)\n assert answers_match(candidate(points=[[5, 5], [5, -5], [-5, -5], [-5, 5], [0, 0]]), 50.0)\n assert answers_match(candidate(points=[[-50, -50], [0, 0], [50, 50], [-40, -40], [40, 40]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 8.5)\n assert answers_match(candidate(points=[[10, 20], [20, 30], [30, 10], [40, 40], [50, 5], [0, 0]]), 900.0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [15, 25], [25, 15], [5, 5], [25, 35], [35, 25]]), 250.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [5, 5], [8, 2], [3, 7], [6, 1], [9, 4], [2, 6], [7, 3], [4, 8]]), 40.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [1, 1], [9, 9], [2, 2], [8, 8], [3, 3], [7, 7]]), 50.0)\n assert answers_match(candidate(points=[[-20, 20], [30, -30], [15, 45], [-40, -10], [25, 10], [0, 0], [-15, -25]]), 2475.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 0], [2, 1], [1, 2], [0, 2], [2, 2], [1.5, 1.5]]), 2.0)\n assert answers_match(candidate(points=[[5, 5], [15, 10], [25, 5], [15, 0], [25, 10], [35, 5]]), 100.0)\n assert answers_match(candidate(points=[[-40, 40], [40, -40], [-30, 30], [30, -30], [-20, 20], [20, -20], [-10, 10], [10, -10], [0, 0], [-5, 5], [5, -5]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[-20, 30], [10, -40], [0, 0], [25, 25], [-30, -30], [40, 40], [5, 5]]), 2250.0)\n assert answers_match(candidate(points=[[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [-3, 3], [-2, 2], [-1, 1]]), 18.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[-30, -20], [20, 25], [0, 0], [10, -10], [-25, 15], [5, 30], [-15, -25], [15, -5], [25, 10]]), 975.0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]), 0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [-10, -10], [-20, -20], [-30, -30], [-40, -40], [-50, -50]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[-50, -40], [-40, -30], [-30, -20], [-20, -10], [-10, 0], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50]]), 0)\n assert answers_match(candidate(points=[[-30, -30], [0, 0], [30, 30], [-20, 20], [20, -20], [-10, 10], [10, -10], [-5, 5], [5, -5]]), 1200.0)\n assert answers_match(candidate(points=[[-25, 0], [0, 25], [25, 0], [0, -25], [0, 0], [12.5, 12.5], [-12.5, -12.5]]), 625.0)\n assert answers_match(candidate(points=[[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5], [-5, 5], [5, -5], [1, 1], [-1, -1]]), 100.0)\n assert answers_match(candidate(points=[[-45, 45], [-35, 35], [-25, 25], [-15, 15], [-5, 5], [5, -5], [15, -15], [25, -25], [35, -35], [45, -45], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-25, 25], [-50, 0], [0, 0], [25, 0], [50, 0], [0, -25], [0, 25], [25, 25], [-25, 0]]), 1562.5)\n assert answers_match(candidate(points=[[-10, 10], [-5, 5], [0, 0], [5, -5], [10, -10], [-8, 8], [-3, 3], [3, -3], [8, -8]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]), 0)\n assert answers_match(candidate(points=[[50, 0], [0, 50], [-50, 0], [0, -50], [25, 25], [-25, -25], [25, -25], [-25, 25], [0, 0]]), 2500.0)\n assert answers_match(candidate(points=[[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]), 0)\n assert answers_match(candidate(points=[[-40, -40], [-20, -20], [-30, -10], [0, 0], [10, 10], [20, 20], [30, 30]]), 700.0)\n assert answers_match(candidate(points=[[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]), 11.5)\n assert answers_match(candidate(points=[[-2, -2], [-1, 1], [0, 0], [1, -1], [2, 2], [3, -3], [4, 4]]), 18.0)\n assert answers_match(candidate(points=[[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]), 0)\n assert answers_match(candidate(points=[[-10, -20], [15, 25], [-15, -25], [20, 20], [0, 0], [25, 15], [-25, -15]]), 400.0)\n assert answers_match(candidate(points=[[-3, -3], [3, 3], [0, 0], [2, 4], [-2, -4], [5, -1], [-5, 1]]), 23.0)\n assert answers_match(candidate(points=[[-45, 45], [-40, 40], [-35, 35], [-30, 30], [-25, 25], [-20, 20], [-15, 15], [-10, 10], [-5, 5], [0, 0]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2]]), 2.5)\n assert answers_match(candidate(points=[[-45, -45], [45, 45], [45, -45], [-45, 45], [0, 0], [25, 25], [-25, -25], [25, -25], [-25, 25]]), 4050.0)\n assert answers_match(candidate(points=[[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]]), 0)\n assert answers_match(candidate(points=[[-49, -49], [49, 49], [-49, 49], [49, -49], [0, 0], [25, 25], [-25, -25], [30, 30], [-30, -30]]), 4802.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [1, -1], [2, -2], [3, -3], [4, -4], [5, -5]]), 0)\n assert answers_match(candidate(points=[[-49, -49], [-48, -48], [-47, -47], [-46, -46], [-45, -45], [-44, -44], [-43, -43], [-42, -42], [-41, -41], [-40, -40]]), 0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]), 10.5)\n assert answers_match(candidate(points=[[-30, -30], [-30, 30], [30, -30], [30, 30], [0, 0], [10, 10], [-10, -10], [10, -10], [-10, 10]]), 1800.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 7.5)\n assert answers_match(candidate(points=[[-25, 25], [0, 50], [25, -25], [50, 0], [-50, 0], [0, -50], [-25, -25], [25, 25], [0, 0]]), 2500.0)\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [-6, 6], [-7, 7], [-8, 8], [-9, 9], [-10, 10]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]), 2.0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 3], [3, 4], [4, 4], [5, 5], [6, 5], [5, 6], [6, 6]]), 4.5)\n assert answers_match(candidate(points=[[-5, -5], [5, 5], [-5, 5], [5, -5], [0, 0], [3, 3], [-3, -3], [2, 2], [-2, -2]]), 50.0)\n assert answers_match(candidate(points=[[-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, 20], [30, -30]]), 1000.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [1, 4], [2, 4], [3, 4]]), 3.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10]]), 22.5)\n assert answers_match(candidate(points=[[0, 1], [1, 0], [0, -1], [-1, 0], [2, 2], [-2, -2], [2, -2], [-2, 2], [3, 3], [-3, -3]]), 12.0)\n assert answers_match(candidate(points=[[-30, 30], [30, -30], [-20, 20], [20, -20], [-10, 10], [10, -10], [0, 0], [-5, 5], [5, -5]]), 0)\n assert answers_match(candidate(points=[[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3]]), 3.0)\n assert answers_match(candidate(points=[[-10, -10], [10, 10], [-10, 10], [10, -10], [0, 0], [2, 2], [4, 4]]), 200.0)\n assert answers_match(candidate(points=[[-10, 0], [-20, 10], [0, 20], [10, 10], [20, -10], [10, -20], [0, -20], [-20, -10]]), 600.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2], [0, 3]]), 3.0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [-15, 15], [-5, 5], [5, -5], [15, -15]]), 0)\n assert answers_match(candidate(points=[[-5, 0], [-4, 1], [-3, 2], [-2, 3], [-1, 4], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]), 25.0)\n assert answers_match(candidate(points=[[-10, -10], [-10, 10], [10, -10], [10, 10], [0, 0], [5, 5], [-5, 5], [-5, -5], [5, -5]]), 200.0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5], [0, 0], [-0.5, -0.5], [0.5, 0.5]]), 0)\n assert answers_match(candidate(points=[[-10, 0], [0, -10], [10, 0], [0, 10], [5, 5], [-5, -5], [5, -5], [-5, 5], [2, 2], [-2, -2]]), 100.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[-40, 40], [-30, 30], [-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [30, -30], [40, -40], [25, 25], [-25, -25]]), 2000.0)\n assert answers_match(candidate(points=[[-10, -10], [10, -10], [-10, 10], [10, 10], [0, 0], [5, 5], [-5, -5], [5, -5], [-5, 5]]), 200.0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 1], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 12.5)\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [1, 1], [2, 2], [3, 3], [0, 0], [-1, 1], [1, -1], [-2, 2], [2, -2]]), 12.0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [-20, -20], [-10, -10], [10, 10], [20, 20]]), 800.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [-1, 1], [-1, -1], [1, -1], [0, 2]]), 3.0)\n assert answers_match(candidate(points=[[0, 50], [50, 0], [25, 25], [-25, 25], [25, -25], [-25, -25], [10, 10], [-10, 10], [10, -10], [-10, -10]]), 2500.0)\n assert answers_match(candidate(points=[[-10, 10], [0, 0], [10, -10], [20, 20], [30, -30], [40, 40]]), 1600.0)\n assert answers_match(candidate(points=[[-5, 5], [5, -5], [10, 10], [-10, -10], [0, 0], [15, -15], [-15, 15], [5, 5], [-5, -5]]), 300.0)\n", "comparison": "float"}, "public_tests": ["[[0,0],[0,1],[1,0],[0,2],[2,0]]", "[[1,0],[0,0],[0,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().largestTriangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:33+00:00", "tests_total": 113, "tests_dropped": 5, "flags": ["figure_reference", "decimal_answer", "has_images"], "topic_tags": ["array", "math", "geometry", "polygons"]}, "language": "python", "interface": {"raw_signature": "def largestTriangleArea(self, points: list[list[int]]) -> float:", "container": "Solution", "callable": "largestTriangleArea", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 813, "task_id": "largest-sum-of-averages", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. You can partition the array into at most k non-empty adjacent subarrays. The score of a partition is the sum of the averages of each subarray.\n\nNote that the partition must use every integer in nums, and that the score is not necessarily an integer.\n\nReturn the maximum score you can achieve of all the possible partitions. Answers within 10^-6 of the actual answer will be accepted.\n\nExample 1:\n\nInput: nums = [9,1,2,3,9], k = 3\nOutput: 20.00000\nExplanation:\nThe best choice is to partition nums into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.\nWe could have also partitioned nums into [9, 1], [2], [3, 9], for example.\nThat partition would lead to a score of 5 + 2 + 6 = 13, which is worse.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,6,7], k = 4\nOutput: 20.50000\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 10^4\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5], k=5), 15.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9], k=3), 20.0)\n assert answers_match(candidate(nums=[1, 2, 3], k=1), 2.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7], k=1), 4.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7], k=4), 20.5)\n assert answers_match(candidate(nums=[4, 1, 7, 5, 6, 2, 3], k=4), 18.166666666666664)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50], k=5), 150.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5], k=1), 5.0)\n assert answers_match(candidate(nums=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], k=5), 50.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5], k=3), 15.0)\n assert answers_match(candidate(nums=[1, 2, 3], k=2), 4.5)\n assert answers_match(candidate(nums=[100, 200, 300, 400], k=2), 600.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7], k=7), 28.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4], k=2), 6.0)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=4), 27.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=10), 55.0)\n assert answers_match(candidate(nums=[5, 3, 8, 1, 9, 2], k=3), 16.0)\n assert answers_match(candidate(nums=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=5), 37.5)\n assert answers_match(candidate(nums=[5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=8), 125.17647058823529)\n assert answers_match(candidate(nums=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45], k=8), 265.5)\n assert answers_match(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.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=5), 37.5)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50], k=2), 75.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], k=3), 360.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=10), 550.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=3), 36.0)\n assert answers_match(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.0)\n assert answers_match(candidate(nums=[100, 100, 100, 100, 100, 100, 100, 100, 100, 100], k=10), 1000.0)\n assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59], k=15), 660.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=10), 50.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 1, 2, 3, 9], k=3), 21.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=5), 375.0)\n assert answers_match(candidate(nums=[5, 3, 6, 4, 8, 9, 1, 2], k=3), 16.5)\n assert answers_match(candidate(nums=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=2), 15.0)\n assert answers_match(candidate(nums=[100, 10, 1, 10, 100, 100, 1, 10, 100, 100, 1, 10, 100], k=5), 370.14285714285717)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=1), 1.0)\n assert answers_match(candidate(nums=[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195], k=6), 950.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=10), 55.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=1), 5.5)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3], k=4), 23.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=5), 5.0)\n assert answers_match(candidate(nums=[4, 5, 6, 7, 8, 9, 10, 11, 12, 13], k=3), 32.5)\n assert answers_match(candidate(nums=[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=6), 102.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=5), 60.0)\n assert answers_match(candidate(nums=[1, 2, 2, 3, 3, 3, 4, 4, 4, 4], k=5), 18.333333333333332)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=3), 3.0)\n assert answers_match(candidate(nums=[15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], k=5), 55.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=15), 75.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=3), 3.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200], k=8), 1260.0)\n assert answers_match(candidate(nums=[9, 1, 4, 3, 8, 7, 5, 6, 2], k=4), 24.666666666666664)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=5), 375.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=1), 5.0)\n assert answers_match(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.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 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), 405.0)\n assert answers_match(candidate(nums=[10, 20, 10, 20, 10, 20, 10, 20, 10, 20], k=5), 81.66666666666667)\n assert answers_match(candidate(nums=[5, 3, 8, 1, 9, 2, 6, 7], k=3), 18.25)\n assert answers_match(candidate(nums=[3, 1, 2, 4, 5, 6, 7, 8, 9, 10], k=3), 23.5)\n assert answers_match(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.0625)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=5), 33.0)\n assert answers_match(candidate(nums=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000], k=5), 50000.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 5, 7, 8], k=3), 21.5)\n assert answers_match(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), 50.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=5), 25.0)\n assert answers_match(candidate(nums=[10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991], k=5), 49987.5)\n assert answers_match(candidate(nums=[4, 3, 2, 6, 2, 3, 4, 5, 1, 2], k=4), 15.333333333333334)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500], k=2), 750.0)\n assert answers_match(candidate(nums=[2, 3, 4, 5, 6, 7, 8, 9], k=3), 21.5)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=10), 5500.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=1), 55.0)\n assert answers_match(candidate(nums=[5, 6, 1, 8, 4, 9], k=2), 13.8)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=5), 82.5)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=3), 235.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=7), 80.0)\n assert answers_match(candidate(nums=[1, 100, 1, 100, 1, 100, 1, 100, 1, 100], k=5), 318.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=15), 120.0)\n assert answers_match(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=15), 15.0)\n assert answers_match(candidate(nums=[5, 2, 3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, 3, 1], k=7), 24.32857142857143)\n assert answers_match(candidate(nums=[9, 7, 5, 3, 1, 2, 4, 6, 8, 10], k=2), 15.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=2), 22.5)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=2), 150.0)\n assert answers_match(candidate(nums=[5, 1, 4, 2, 3, 6, 8, 7], k=3), 18.5)\n assert answers_match(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.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=3), 23.5)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3], k=6), 34.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=10), 150.0)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=5), 3750.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=10), 10.0)\n assert answers_match(candidate(nums=[1, 100, 2, 100, 3, 100, 4, 100, 5, 100], k=5), 322.49999999999994)\n assert answers_match(candidate(nums=[10000, 10000, 10000, 10000, 10000], k=3), 30000.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=10), 150.0)\n assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], k=4), 58.0)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=2), 1500.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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), 937.5)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=3), 21.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 8, 7, 6, 5, 4], k=5), 33.5)\n assert answers_match(candidate(nums=[1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100], k=10), 670.0)\n assert answers_match(candidate(nums=[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], k=20), 180.0)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=9), 45.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=10), 50.0)\n", "comparison": "float"}, "public_tests": ["[9,1,2,3,9]\n3", "[1,2,3,4,5,6,7]\n4"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().largestSumOfAverages", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:35+00:00", "tests_total": 102, "tests_dropped": 2, "flags": ["decimal_answer"], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def largestSumOfAverages(self, nums: list[int], k: int) -> float:", "container": "Solution", "callable": "largestSumOfAverages", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 815, "task_id": "bus-routes", "difficulty": "Hard", "problem_description": "You are given an array routes representing bus routes where routes[i] is a bus route that the i^th bus repeats forever.\n\n- For example, if routes[0] = [1, 5, 7], this means that the 0^th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever.\n\nYou will start at the bus stop source (You are not on any bus initially), and you want to go to the bus stop target. You can travel between bus stops by buses only.\n\nReturn the least number of buses you must take to travel from source to target. Return -1 if it is not possible.\n\nExample 1:\n\nInput: routes = [[1,2,7],[3,6,7]], source = 1, target = 6\nOutput: 2\nExplanation: The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6.\n\nExample 2:\n\nInput: routes = [[7,12],[4,5,15],[6],[15,19],[9,12,13]], source = 15, target = 12\nOutput: -1\n\nConstraints:\n\n- 1 <= routes.length <= 500.\n- 1 <= routes[i].length <= 10^5\n- All the values of routes[i] are unique.\n- sum(routes[i].length) <= 10^5\n- 0 <= routes[i][j] < 10^6\n- 0 <= source, target < 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(routes = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],source = 1,target = 9) == -1\n assert candidate(routes = [[1, 2, 3, 4, 5]],source = 1,target = 5) == 1\n assert candidate(routes = [[7, 12], [4, 5, 15], [6], [15, 19], [9, 12, 13]],source = 15,target = 12) == -1\n assert candidate(routes = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],source = 1,target = 8) == -1\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 1]],source = 2,target = 6) == 2\n assert candidate(routes = [[1, 5, 7], [1, 5, 3], [3, 7, 9]],source = 1,target = 9) == 2\n assert candidate(routes = [[1, 2, 3], [4, 5, 6]],source = 1,target = 6) == -1\n assert candidate(routes = [[1, 7], [3, 7], [5, 7], [7, 9]],source = 1,target = 9) == 2\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 1]],source = 1,target = 5) == 1\n assert candidate(routes = [[1, 7], [3, 5]],source = 5,target = 7) == -1\n assert candidate(routes = [[1, 5, 9], [3, 5, 7], [7, 8, 9]],source = 1,target = 8) == 2\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],source = 1,target = 7) == 3\n assert candidate(routes = [[1, 2, 7], [3, 6, 7]],source = 1,target = 6) == 2\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 1], [6, 7, 8], [8, 9, 10], [10, 1, 2]],source = 1,target = 10) == 1\n assert candidate(routes = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13], [12, 13, 14], [13, 14, 15], [14, 15, 16], [15, 16, 17], [16, 17, 18], [17, 18, 19], [18, 19, 20], [19, 20, 21], [20, 21, 22], [21, 22, 23], [22, 23, 24], [23, 24, 25]],source = 1,target = 25) == 12\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],source = 1,target = 11) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20], [21, 22, 23, 24, 25, 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]],source = 1,target = 50) == -1\n assert candidate(routes = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [5, 10, 15, 20, 25, 30], [15, 25, 35, 45, 55, 65]],source = 1,target = 65) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]],source = 1,target = 21) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [19, 20, 21, 22, 23, 24, 25, 26, 27, 28], [28, 29, 30, 1]],source = 1,target = 30) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 21], [21, 22, 23, 24, 25]],source = 1,target = 25) == 6\n assert candidate(routes = [[1, 10, 20, 30, 40], [2, 11, 21, 31, 41], [3, 12, 22, 32, 42], [4, 13, 23, 33, 43], [5, 14, 24, 34, 44]],source = 1,target = 44) == -1\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]],source = 1,target = 75) == 2\n assert candidate(routes = [[1, 10, 15, 20], [2, 10, 12], [10, 15, 25], [5, 15, 30], [1, 5]],source = 1,target = 25) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],source = 1,target = 30) == -1\n assert candidate(routes = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]],source = 100,target = 500) == 1\n assert candidate(routes = [[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49], [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50], [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 11, 21, 31, 41], [5, 15, 25, 35, 45]],source = 1,target = 50) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49]],source = 1,target = 50) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]],source = 1,target = 43) == 3\n assert candidate(routes = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 7, 10, 13, 16], [5, 8, 11, 14, 17]],source = 1,target = 17) == 2\n assert candidate(routes = [[3, 11, 16, 18, 23], [2, 10, 12, 21, 22, 24, 26, 33, 34, 38], [11, 13, 19, 32, 36, 43], [6, 16, 19, 26, 29, 34, 36, 37, 38, 39, 43, 44], [5, 9, 10, 12, 18, 21, 24, 27, 28, 32, 33, 35, 40, 41, 42, 45, 46, 48, 49], [2, 5, 8, 9, 13, 14, 17, 21, 22, 23, 24, 25, 30, 31, 33, 35, 41, 44, 45, 47], [3, 6, 7, 8, 10, 12, 14, 15, 17, 20, 21, 23, 27, 31, 32, 33, 37, 40, 41, 43, 45, 46, 47, 48, 49], [1, 6, 9, 13, 14, 25, 31, 32, 34, 35, 40, 41, 43, 44, 45, 46, 47, 48, 49], [3, 14, 17, 20, 21, 22, 26, 28, 30, 31, 32, 35, 37, 39, 40, 41, 42, 43, 44, 47, 48, 49], [1, 2, 4, 6, 8, 9, 11, 13, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [2, 4, 8, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21, 23, 25, 26, 27, 28, 29, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [4, 6, 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [1, 3, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 24, 25, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [1, 3, 5, 7, 8, 9, 11, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]],source = 4,target = 36) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]],source = 1,target = 50) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 21, 11, 31], [10, 20, 30, 40], [15, 25, 35, 45]],source = 1,target = 45) == 2\n assert candidate(routes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [10, 25, 40, 55, 70, 85, 100, 115, 130, 145]],source = 10,target = 145) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 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]],source = 1,target = 100) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 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, 21, 30], [10, 20, 30]],source = 1,target = 30) == 1\n assert candidate(routes = [[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]],source = 1,target = 9) == 2\n assert candidate(routes = [[10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25], [25, 26, 27, 28, 29, 30]],source = 10,target = 30) == 4\n assert candidate(routes = [[10, 20, 30], [20, 40, 50], [30, 50, 60], [60, 70, 80]],source = 10,target = 80) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 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, 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], [10, 20, 30]],source = 1,target = 30) == 2\n assert candidate(routes = [[33, 22, 5, 13], [41, 33, 23, 32, 45, 35], [5, 6, 11, 15, 41, 47, 4, 19], [4, 31, 10, 48, 38, 16], [29, 38, 48, 18, 44, 35, 37, 42], [25, 22, 39, 43, 1, 26, 36, 28, 32, 30, 21], [12, 35, 29, 49, 11, 24], [47, 24, 40, 46, 42, 23, 41, 39, 34, 28], [26, 1, 34, 48, 49], [41, 26, 43, 20, 35, 30, 15, 37, 12], [11, 25, 39, 28, 10, 47, 21], [39, 18, 41, 19, 23, 26, 20, 11, 37, 33, 22, 34], [35, 18, 22, 40, 43, 27, 1, 37, 32, 20, 33], [32, 27, 28, 36, 43, 35, 24, 34, 39, 46, 42, 40, 37, 30, 31, 21, 15, 13, 4, 33, 19, 25, 10, 49, 23, 41, 12, 11, 47, 48], [4, 22, 18, 24, 40, 39, 26, 36, 43, 13, 11, 15, 28, 20, 37, 35, 33, 42, 47, 23, 30, 19, 1, 46, 34, 41, 49, 12, 31]],source = 1,target = 40) == 1\n assert candidate(routes = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [20, 80, 100], [50, 60, 70], [10, 50, 60, 70, 80, 90]],source = 10,target = 90) == 1\n assert candidate(routes = [[1, 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, 16], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]],source = 1,target = 17) == 2\n assert candidate(routes = [[1, 4, 6, 8, 10], [2, 5, 7, 9, 11], [3, 6, 9, 12, 15], [4, 7, 10, 13, 16], [5, 8, 11, 14, 17]],source = 1,target = 17) == 2\n assert candidate(routes = [[2, 5, 10], [8, 10, 11], [13, 14, 15], [1, 2, 5], [2, 6, 11], [3, 6, 13], [4, 5, 8, 14], [5, 6, 15]],source = 1,target = 15) == 2\n assert candidate(routes = [[1, 4, 5, 6], [2, 5, 7, 8], [3, 6, 8, 10], [4, 7, 9, 10], [5, 9, 11, 12], [6, 10, 12, 13], [7, 11, 13, 14], [8, 12, 14, 15]],source = 1,target = 15) == 3\n assert candidate(routes = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 21], [21, 1, 2, 3, 4], [4, 5, 6, 7, 8]],source = 1,target = 21) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [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, 6, 11, 16, 21, 26, 31, 36, 41, 46], [2, 7, 12, 17, 22, 27, 32, 37, 42, 47], [3, 8, 13, 18, 23, 28, 33, 38, 43, 48], [4, 9, 14, 19, 24, 29, 34, 39, 44, 49], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]],source = 1,target = 50) == 2\n assert candidate(routes = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [1, 11, 21, 31, 41, 51], [2, 12, 22, 32, 42, 52], [3, 13, 23, 33, 43, 53], [4, 14, 24, 34, 44, 54], [5, 15, 25, 35, 45, 55]],source = 1,target = 55) == -1\n assert candidate(routes = [[2, 7, 8, 9], [4, 7, 8, 11, 12, 13, 14, 17, 19, 20, 22, 23, 24, 26, 27, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48], [2, 3, 4, 6, 11, 12, 13, 16, 18, 19, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 46, 48, 49], [4, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [2, 3, 5, 6, 11, 12, 13, 14, 16, 18, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48], [4, 7, 8, 11, 12, 13, 14, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [4, 7, 8, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 48], [4, 7, 8, 11, 12, 14, 15, 17, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [3, 4, 5, 6, 7, 8, 11, 13, 14, 15, 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], [2, 3, 5, 7, 8, 9, 11, 12, 14, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]],source = 4,target = 34) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58]],source = 1,target = 58) == 3\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 11], [11, 12, 13], [13, 14, 15], [15, 16, 17], [17, 18, 19], [19, 20, 21], [21, 22, 23], [23, 24, 25], [25, 26, 27], [27, 28, 29], [29, 30, 31], [31, 32, 33], [33, 34, 35], [35, 36, 37], [37, 38, 39], [39, 40, 41], [41, 42, 43], [43, 44, 45]],source = 1,target = 45) == 22\n assert candidate(routes = [[3, 7, 9, 11, 13, 15], [1, 3, 5, 7, 9, 11], [5, 11, 17, 23, 29], [7, 15, 21, 27, 33], [9, 13, 19, 25, 31], [11, 17, 23, 29, 35], [13, 21, 25, 29, 37], [15, 27, 35, 43, 47], [17, 29, 39, 49, 53], [19, 31, 41, 49, 57], [21, 25, 31, 43, 49], [23, 37, 43, 51, 57], [25, 29, 35, 43, 49, 53, 57]],source = 3,target = 47) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 1]],source = 1,target = 20) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],source = 1,target = 20) == -1\n assert candidate(routes = [[1, 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, 16], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [5, 10, 15, 20], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],source = 1,target = 20) == 2\n assert candidate(routes = [[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]],source = 1,target = 55) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92]],source = 1,target = 92) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 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], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],source = 1,target = 100) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],source = 1,target = 30) == -1\n assert candidate(routes = [[3, 11, 13, 19], [7, 11, 17], [9, 13, 18, 23], [10, 14, 19, 23], [12, 15, 17, 21], [13, 18, 20, 22], [14, 15, 19, 21], [16, 17, 22, 23], [18, 20, 23, 24], [20, 21, 22, 24]],source = 3,target = 24) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 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], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250]],source = 1,target = 250) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5], [2, 6, 7, 8], [3, 9, 10, 11], [4, 12, 13, 14], [5, 6, 9, 12], [7, 10, 13, 15], [8, 11, 14, 16], [15, 16, 17, 18], [17, 18, 19, 20]],source = 1,target = 20) == 5\n assert candidate(routes = [[10, 20, 30, 40], [20, 50, 60], [30, 70, 80], [40, 50, 90], [60, 70, 100], [80, 90, 100]],source = 10,target = 100) == 3\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [2, 4, 6], [8, 10, 12], [12, 14, 16], [16, 18, 20], [20, 1, 3]],source = 1,target = 20) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],source = 1,target = 40) == -1\n assert candidate(routes = [[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]],source = 1,target = 13) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25], [25, 26, 27, 28, 29, 30]],source = 1,target = 30) == 5\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],source = 1,target = 30) == -1\n assert candidate(routes = [[1, 10, 19], [2, 3, 10, 14], [4, 14, 16, 20], [11, 16, 18], [6, 7, 11, 18], [9, 15, 20]],source = 1,target = 20) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 1]],source = 1,target = 20) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 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, 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]],source = 1,target = 40) == 2\n assert candidate(routes = [[1000, 2000], [2000, 3000, 4000], [4000, 5000, 6000], [6000, 7000, 8000], [8000, 9000, 10000], [10000, 11000], [11000, 12000, 13000], [13000, 14000], [14000, 15000, 1000]],source = 1000,target = 15000) == 1\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41], [41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61]],source = 1,target = 61) == 3\n", "comparison": "exact"}, "public_tests": ["[[1,2,7],[3,6,7]]\n1\n6", "[[7,12],[4,5,15],[6],[15,19],[9,12,13]]\n15\n12"], "hints": [], "metadata": {"canonical_parameter_names": ["routes", "source", "target"], "leetcode_dataset_entry_point": "Solution().numBusesToDestination", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:39+00:00", "tests_total": 77, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def numBusesToDestination(self, routes: list[list[int]], source: int, target: int) -> int:", "container": "Solution", "callable": "numBusesToDestination", "parameters": [{"name": "routes", "type": "list[list[int]]"}, {"name": "source", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 816, "task_id": "ambiguous-coordinates", "difficulty": "Medium", "problem_description": "We had some 2-dimensional coordinates, like \"(1, 3)\" or \"(2, 0.5)\". Then, we removed all commas, decimal points, and spaces and ended up with the string s.\n\n- For example, \"(1, 3)\" becomes s = \"(13)\" and \"(2, 0.5)\" becomes s = \"(205)\".\n\nReturn a list of strings representing all possibilities for what our original coordinates could have been.\n\nOur original representation never had extraneous zeroes, so we never started with numbers like \"00\", \"0.0\", \"0.00\", \"1.0\", \"001\", \"00.01\", or any other number that can be represented with fewer digits. Also, a decimal point within a number never occurs without at least one digit occurring before it, so we never started with numbers like \".1\".\n\nThe final answer list can be returned in any order. All coordinates in the final answer have exactly one space between them (occurring after the comma.)\n\nExample 1:\n\nInput: s = \"(123)\"\nOutput: [\"(1, 2.3)\",\"(1, 23)\",\"(1.2, 3)\",\"(12, 3)\"]\n\nExample 2:\n\nInput: s = \"(0123)\"\nOutput: [\"(0, 1.23)\",\"(0, 12.3)\",\"(0, 123)\",\"(0.1, 2.3)\",\"(0.1, 23)\",\"(0.12, 3)\"]\nExplanation: 0.0, 00, 0001 or 00.01 are not allowed.\n\nExample 3:\n\nInput: s = \"(00011)\"\nOutput: [\"(0, 0.011)\",\"(0.001, 1)\"]\n\nConstraints:\n\n- 4 <= s.length <= 12\n- s[0] == '(' and s[s.length - 1] == ')'.\n- The rest of s are digits.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(s='(1001)'), ['(1, 0.01)', '(10, 0.1)', '(100, 1)'])\n assert answers_match(candidate(s='(12345)'), ['(1, 2.345)', '(1, 23.45)', '(1, 234.5)', '(1, 2345)', '(1.2, 3.45)', '(1.2, 34.5)', '(1.2, 345)', '(12, 3.45)', '(12, 34.5)', '(12, 345)', '(1.23, 4.5)', '(1.23, 45)', '(12.3, 4.5)', '(12.3, 45)', '(123, 4.5)', '(123, 45)', '(1.234, 5)', '(12.34, 5)', '(123.4, 5)', '(1234, 5)'])\n assert answers_match(candidate(s='(01001)'), ['(0, 1.001)', '(0, 10.01)', '(0, 100.1)', '(0, 1001)', '(0.1, 0.01)'])\n assert answers_match(candidate(s='(1010)'), ['(10, 10)', '(1.01, 0)', '(10.1, 0)', '(101, 0)'])\n assert answers_match(candidate(s='(1000)'), ['(100, 0)'])\n assert answers_match(candidate(s='(0123)'), ['(0, 1.23)', '(0, 12.3)', '(0, 123)', '(0.1, 2.3)', '(0.1, 23)', '(0.12, 3)'])\n assert answers_match(candidate(s='(00011)'), ['(0, 0.011)', '(0.001, 1)'])\n assert answers_match(candidate(s='(123)'), ['(1, 2.3)', '(1, 23)', '(1.2, 3)', '(12, 3)'])\n assert answers_match(candidate(s='(1234)'), ['(1, 2.34)', '(1, 23.4)', '(1, 234)', '(1.2, 3.4)', '(1.2, 34)', '(12, 3.4)', '(12, 34)', '(1.23, 4)', '(12.3, 4)', '(123, 4)'])\n assert answers_match(candidate(s='(100)'), ['(10, 0)'])\n assert answers_match(candidate(s='(110)'), ['(1, 10)', '(1.1, 0)', '(11, 0)'])\n assert answers_match(candidate(s='(10001)'), ['(1, 0.001)', '(10, 0.01)', '(100, 0.1)', '(1000, 1)'])\n assert answers_match(candidate(s='(0000)'), [])\n assert answers_match(candidate(s='(00100)'), [])\n assert answers_match(candidate(s='(00001)'), ['(0, 0.001)'])\n assert answers_match(candidate(s='(010)'), ['(0, 10)', '(0.1, 0)'])\n assert answers_match(candidate(s='(987654)'), ['(9, 8.7654)', '(9, 87.654)', '(9, 876.54)', '(9, 8765.4)', '(9, 87654)', '(9.8, 7.654)', '(9.8, 76.54)', '(9.8, 765.4)', '(9.8, 7654)', '(98, 7.654)', '(98, 76.54)', '(98, 765.4)', '(98, 7654)', '(9.87, 6.54)', '(9.87, 65.4)', '(9.87, 654)', '(98.7, 6.54)', '(98.7, 65.4)', '(98.7, 654)', '(987, 6.54)', '(987, 65.4)', '(987, 654)', '(9.876, 5.4)', '(9.876, 54)', '(98.76, 5.4)', '(98.76, 54)', '(987.6, 5.4)', '(987.6, 54)', '(9876, 5.4)', '(9876, 54)', '(9.8765, 4)', '(98.765, 4)', '(987.65, 4)', '(9876.5, 4)', '(98765, 4)'])\n assert answers_match(candidate(s='(00010001)'), ['(0, 0.010001)', '(0.001, 0.001)'])\n assert answers_match(candidate(s='(12340001)'), ['(1, 2.340001)', '(1, 23.40001)', '(1, 234.0001)', '(1, 2340.001)', '(1, 23400.01)', '(1, 234000.1)', '(1, 2340001)', '(1.2, 3.40001)', '(1.2, 34.0001)', '(1.2, 340.001)', '(1.2, 3400.01)', '(1.2, 34000.1)', '(1.2, 340001)', '(12, 3.40001)', '(12, 34.0001)', '(12, 340.001)', '(12, 3400.01)', '(12, 34000.1)', '(12, 340001)', '(1.23, 4.0001)', '(1.23, 40.001)', '(1.23, 400.01)', '(1.23, 4000.1)', '(1.23, 40001)', '(12.3, 4.0001)', '(12.3, 40.001)', '(12.3, 400.01)', '(12.3, 4000.1)', '(12.3, 40001)', '(123, 4.0001)', '(123, 40.001)', '(123, 400.01)', '(123, 4000.1)', '(123, 40001)', '(1.234, 0.001)', '(12.34, 0.001)', '(123.4, 0.001)', '(1234, 0.001)', '(12340, 0.01)', '(123400, 0.1)', '(1234000, 1)'])\n assert answers_match(candidate(s='(000100)'), [])\n assert answers_match(candidate(s='(12300123)'), ['(1, 2.300123)', '(1, 23.00123)', '(1, 230.0123)', '(1, 2300.123)', '(1, 23001.23)', '(1, 230012.3)', '(1, 2300123)', '(1.2, 3.00123)', '(1.2, 30.0123)', '(1.2, 300.123)', '(1.2, 3001.23)', '(1.2, 30012.3)', '(1.2, 300123)', '(12, 3.00123)', '(12, 30.0123)', '(12, 300.123)', '(12, 3001.23)', '(12, 30012.3)', '(12, 300123)', '(1.23, 0.0123)', '(12.3, 0.0123)', '(123, 0.0123)', '(1230, 0.123)', '(12300, 1.23)', '(12300, 12.3)', '(12300, 123)', '(1.23001, 2.3)', '(1.23001, 23)', '(12.3001, 2.3)', '(12.3001, 23)', '(123.001, 2.3)', '(123.001, 23)', '(1230.01, 2.3)', '(1230.01, 23)', '(12300.1, 2.3)', '(12300.1, 23)', '(123001, 2.3)', '(123001, 23)', '(1.230012, 3)', '(12.30012, 3)', '(123.0012, 3)', '(1230.012, 3)', '(12300.12, 3)', '(123001.2, 3)', '(1230012, 3)'])\n assert answers_match(candidate(s='(0010001)'), ['(0, 0.10001)', '(0.01, 0.001)'])\n assert answers_match(candidate(s='(1234567)'), ['(1, 2.34567)', '(1, 23.4567)', '(1, 234.567)', '(1, 2345.67)', '(1, 23456.7)', '(1, 234567)', '(1.2, 3.4567)', '(1.2, 34.567)', '(1.2, 345.67)', '(1.2, 3456.7)', '(1.2, 34567)', '(12, 3.4567)', '(12, 34.567)', '(12, 345.67)', '(12, 3456.7)', '(12, 34567)', '(1.23, 4.567)', '(1.23, 45.67)', '(1.23, 456.7)', '(1.23, 4567)', '(12.3, 4.567)', '(12.3, 45.67)', '(12.3, 456.7)', '(12.3, 4567)', '(123, 4.567)', '(123, 45.67)', '(123, 456.7)', '(123, 4567)', '(1.234, 5.67)', '(1.234, 56.7)', '(1.234, 567)', '(12.34, 5.67)', '(12.34, 56.7)', '(12.34, 567)', '(123.4, 5.67)', '(123.4, 56.7)', '(123.4, 567)', '(1234, 5.67)', '(1234, 56.7)', '(1234, 567)', '(1.2345, 6.7)', '(1.2345, 67)', '(12.345, 6.7)', '(12.345, 67)', '(123.45, 6.7)', '(123.45, 67)', '(1234.5, 6.7)', '(1234.5, 67)', '(12345, 6.7)', '(12345, 67)', '(1.23456, 7)', '(12.3456, 7)', '(123.456, 7)', '(1234.56, 7)', '(12345.6, 7)', '(123456, 7)'])\n assert answers_match(candidate(s='(987654321)'), ['(9, 8.7654321)', '(9, 87.654321)', '(9, 876.54321)', '(9, 8765.4321)', '(9, 87654.321)', '(9, 876543.21)', '(9, 8765432.1)', '(9, 87654321)', '(9.8, 7.654321)', '(9.8, 76.54321)', '(9.8, 765.4321)', '(9.8, 7654.321)', '(9.8, 76543.21)', '(9.8, 765432.1)', '(9.8, 7654321)', '(98, 7.654321)', '(98, 76.54321)', '(98, 765.4321)', '(98, 7654.321)', '(98, 76543.21)', '(98, 765432.1)', '(98, 7654321)', '(9.87, 6.54321)', '(9.87, 65.4321)', '(9.87, 654.321)', '(9.87, 6543.21)', '(9.87, 65432.1)', '(9.87, 654321)', '(98.7, 6.54321)', '(98.7, 65.4321)', '(98.7, 654.321)', '(98.7, 6543.21)', '(98.7, 65432.1)', '(98.7, 654321)', '(987, 6.54321)', '(987, 65.4321)', '(987, 654.321)', '(987, 6543.21)', '(987, 65432.1)', '(987, 654321)', '(9.876, 5.4321)', '(9.876, 54.321)', '(9.876, 543.21)', '(9.876, 5432.1)', '(9.876, 54321)', '(98.76, 5.4321)', '(98.76, 54.321)', '(98.76, 543.21)', '(98.76, 5432.1)', '(98.76, 54321)', '(987.6, 5.4321)', '(987.6, 54.321)', '(987.6, 543.21)', '(987.6, 5432.1)', '(987.6, 54321)', '(9876, 5.4321)', '(9876, 54.321)', '(9876, 543.21)', '(9876, 5432.1)', '(9876, 54321)', '(9.8765, 4.321)', '(9.8765, 43.21)', '(9.8765, 432.1)', '(9.8765, 4321)', '(98.765, 4.321)', '(98.765, 43.21)', '(98.765, 432.1)', '(98.765, 4321)', '(987.65, 4.321)', '(987.65, 43.21)', '(987.65, 432.1)', '(987.65, 4321)', '(9876.5, 4.321)', '(9876.5, 43.21)', '(9876.5, 432.1)', '(9876.5, 4321)', '(98765, 4.321)', '(98765, 43.21)', '(98765, 432.1)', '(98765, 4321)', '(9.87654, 3.21)', '(9.87654, 32.1)', '(9.87654, 321)', '(98.7654, 3.21)', '(98.7654, 32.1)', '(98.7654, 321)', '(987.654, 3.21)', '(987.654, 32.1)', '(987.654, 321)', '(9876.54, 3.21)', '(9876.54, 32.1)', '(9876.54, 321)', '(98765.4, 3.21)', '(98765.4, 32.1)', '(98765.4, 321)', '(987654, 3.21)', '(987654, 32.1)', '(987654, 321)', '(9.876543, 2.1)', '(9.876543, 21)', '(98.76543, 2.1)', '(98.76543, 21)', '(987.6543, 2.1)', '(987.6543, 21)', '(9876.543, 2.1)', '(9876.543, 21)', '(98765.43, 2.1)', '(98765.43, 21)', '(987654.3, 2.1)', '(987654.3, 21)', '(9876543, 2.1)', '(9876543, 21)', '(9.8765432, 1)', '(98.765432, 1)', '(987.65432, 1)', '(9876.5432, 1)', '(98765.432, 1)', '(987654.32, 1)', '(9876543.2, 1)', '(98765432, 1)'])\n assert answers_match(candidate(s='(000000)'), [])\n assert answers_match(candidate(s='(00000123)'), ['(0, 0.000123)', '(0.00001, 2.3)', '(0.00001, 23)', '(0.000012, 3)'])\n assert answers_match(candidate(s='(123050)'), ['(1, 23050)', '(1.2, 3050)', '(12, 3050)', '(1230, 50)', '(1.2305, 0)', '(12.305, 0)', '(123.05, 0)', '(1230.5, 0)', '(12305, 0)'])\n assert answers_match(candidate(s='(000123)'), ['(0, 0.0123)', '(0.001, 2.3)', '(0.001, 23)', '(0.0012, 3)'])\n assert answers_match(candidate(s='(0000000001)'), ['(0, 0.00000001)'])\n assert answers_match(candidate(s='(00012345)'), ['(0, 0.012345)', '(0.001, 2.345)', '(0.001, 23.45)', '(0.001, 234.5)', '(0.001, 2345)', '(0.0012, 3.45)', '(0.0012, 34.5)', '(0.0012, 345)', '(0.00123, 4.5)', '(0.00123, 45)', '(0.001234, 5)'])\n assert answers_match(candidate(s='(012301)'), ['(0, 1.2301)', '(0, 12.301)', '(0, 123.01)', '(0, 1230.1)', '(0, 12301)', '(0.1, 2.301)', '(0.1, 23.01)', '(0.1, 230.1)', '(0.1, 2301)', '(0.12, 3.01)', '(0.12, 30.1)', '(0.12, 301)', '(0.123, 0.1)'])\n assert answers_match(candidate(s='(123450123)'), ['(1, 2.3450123)', '(1, 23.450123)', '(1, 234.50123)', '(1, 2345.0123)', '(1, 23450.123)', '(1, 234501.23)', '(1, 2345012.3)', '(1, 23450123)', '(1.2, 3.450123)', '(1.2, 34.50123)', '(1.2, 345.0123)', '(1.2, 3450.123)', '(1.2, 34501.23)', '(1.2, 345012.3)', '(1.2, 3450123)', '(12, 3.450123)', '(12, 34.50123)', '(12, 345.0123)', '(12, 3450.123)', '(12, 34501.23)', '(12, 345012.3)', '(12, 3450123)', '(1.23, 4.50123)', '(1.23, 45.0123)', '(1.23, 450.123)', '(1.23, 4501.23)', '(1.23, 45012.3)', '(1.23, 450123)', '(12.3, 4.50123)', '(12.3, 45.0123)', '(12.3, 450.123)', '(12.3, 4501.23)', '(12.3, 45012.3)', '(12.3, 450123)', '(123, 4.50123)', '(123, 45.0123)', '(123, 450.123)', '(123, 4501.23)', '(123, 45012.3)', '(123, 450123)', '(1.234, 5.0123)', '(1.234, 50.123)', '(1.234, 501.23)', '(1.234, 5012.3)', '(1.234, 50123)', '(12.34, 5.0123)', '(12.34, 50.123)', '(12.34, 501.23)', '(12.34, 5012.3)', '(12.34, 50123)', '(123.4, 5.0123)', '(123.4, 50.123)', '(123.4, 501.23)', '(123.4, 5012.3)', '(123.4, 50123)', '(1234, 5.0123)', '(1234, 50.123)', '(1234, 501.23)', '(1234, 5012.3)', '(1234, 50123)', '(1.2345, 0.123)', '(12.345, 0.123)', '(123.45, 0.123)', '(1234.5, 0.123)', '(12345, 0.123)', '(123450, 1.23)', '(123450, 12.3)', '(123450, 123)', '(1.234501, 2.3)', '(1.234501, 23)', '(12.34501, 2.3)', '(12.34501, 23)', '(123.4501, 2.3)', '(123.4501, 23)', '(1234.501, 2.3)', '(1234.501, 23)', '(12345.01, 2.3)', '(12345.01, 23)', '(123450.1, 2.3)', '(123450.1, 23)', '(1234501, 2.3)', '(1234501, 23)', '(1.2345012, 3)', '(12.345012, 3)', '(123.45012, 3)', '(1234.5012, 3)', '(12345.012, 3)', '(123450.12, 3)', '(1234501.2, 3)', '(12345012, 3)'])\n assert answers_match(candidate(s='(010101)'), ['(0, 1.0101)', '(0, 10.101)', '(0, 101.01)', '(0, 1010.1)', '(0, 10101)', '(0.1, 0.101)', '(0.101, 0.1)'])\n assert answers_match(candidate(s='(0001234)'), ['(0, 0.01234)', '(0.001, 2.34)', '(0.001, 23.4)', '(0.001, 234)', '(0.0012, 3.4)', '(0.0012, 34)', '(0.00123, 4)'])\n assert answers_match(candidate(s='(00012340)'), ['(0.001, 2340)', '(0.0012, 340)', '(0.00123, 40)', '(0.001234, 0)'])\n assert answers_match(candidate(s='(0000001)'), ['(0, 0.00001)'])\n assert answers_match(candidate(s='(10000010)'), ['(100000, 10)', '(1.000001, 0)', '(10.00001, 0)', '(100.0001, 0)', '(1000.001, 0)', '(10000.01, 0)', '(100000.1, 0)', '(1000001, 0)'])\n assert answers_match(candidate(s='(12012012)'), ['(1, 2.012012)', '(1, 20.12012)', '(1, 201.2012)', '(1, 2012.012)', '(1, 20120.12)', '(1, 201201.2)', '(1, 2012012)', '(1.2, 0.12012)', '(12, 0.12012)', '(120, 1.2012)', '(120, 12.012)', '(120, 120.12)', '(120, 1201.2)', '(120, 12012)', '(1.201, 2.012)', '(1.201, 20.12)', '(1.201, 201.2)', '(1.201, 2012)', '(12.01, 2.012)', '(12.01, 20.12)', '(12.01, 201.2)', '(12.01, 2012)', '(120.1, 2.012)', '(120.1, 20.12)', '(120.1, 201.2)', '(120.1, 2012)', '(1201, 2.012)', '(1201, 20.12)', '(1201, 201.2)', '(1201, 2012)', '(1.2012, 0.12)', '(12.012, 0.12)', '(120.12, 0.12)', '(1201.2, 0.12)', '(12012, 0.12)', '(120120, 1.2)', '(120120, 12)', '(1.201201, 2)', '(12.01201, 2)', '(120.1201, 2)', '(1201.201, 2)', '(12012.01, 2)', '(120120.1, 2)', '(1201201, 2)'])\n assert answers_match(candidate(s='(001203)'), ['(0, 0.1203)', '(0.01, 2.03)', '(0.01, 20.3)', '(0.01, 203)', '(0.012, 0.3)'])\n assert answers_match(candidate(s='(000010001)'), ['(0, 0.0010001)', '(0.0001, 0.001)'])\n assert answers_match(candidate(s='(100001)'), ['(1, 0.0001)', '(10, 0.001)', '(100, 0.01)', '(1000, 0.1)', '(10000, 1)'])\n assert answers_match(candidate(s='(01230123)'), ['(0, 1.230123)', '(0, 12.30123)', '(0, 123.0123)', '(0, 1230.123)', '(0, 12301.23)', '(0, 123012.3)', '(0, 1230123)', '(0.1, 2.30123)', '(0.1, 23.0123)', '(0.1, 230.123)', '(0.1, 2301.23)', '(0.1, 23012.3)', '(0.1, 230123)', '(0.12, 3.0123)', '(0.12, 30.123)', '(0.12, 301.23)', '(0.12, 3012.3)', '(0.12, 30123)', '(0.123, 0.123)', '(0.12301, 2.3)', '(0.12301, 23)', '(0.123012, 3)'])\n assert answers_match(candidate(s='(1000000)'), ['(100000, 0)'])\n assert answers_match(candidate(s='(0001000100)'), [])\n assert answers_match(candidate(s='(120030)'), ['(1, 20030)', '(1200, 30)', '(1.2003, 0)', '(12.003, 0)', '(120.03, 0)', '(1200.3, 0)', '(12003, 0)'])\n assert answers_match(candidate(s='(001001)'), ['(0, 0.1001)', '(0.01, 0.01)'])\n assert answers_match(candidate(s='(100000001)'), ['(1, 0.0000001)', '(10, 0.000001)', '(100, 0.00001)', '(1000, 0.0001)', '(10000, 0.001)', '(100000, 0.01)', '(1000000, 0.1)', '(10000000, 1)'])\n assert answers_match(candidate(s='(000000001)'), ['(0, 0.0000001)'])\n assert answers_match(candidate(s='(001234056)'), ['(0, 0.1234056)', '(0.01, 2.34056)', '(0.01, 23.4056)', '(0.01, 234.056)', '(0.01, 2340.56)', '(0.01, 23405.6)', '(0.01, 234056)', '(0.012, 3.4056)', '(0.012, 34.056)', '(0.012, 340.56)', '(0.012, 3405.6)', '(0.012, 34056)', '(0.0123, 4.056)', '(0.0123, 40.56)', '(0.0123, 405.6)', '(0.0123, 4056)', '(0.01234, 0.56)', '(0.0123405, 6)'])\n assert answers_match(candidate(s='(100100)'), ['(100, 100)', '(10010, 0)'])\n assert answers_match(candidate(s='(12345678)'), ['(1, 2.345678)', '(1, 23.45678)', '(1, 234.5678)', '(1, 2345.678)', '(1, 23456.78)', '(1, 234567.8)', '(1, 2345678)', '(1.2, 3.45678)', '(1.2, 34.5678)', '(1.2, 345.678)', '(1.2, 3456.78)', '(1.2, 34567.8)', '(1.2, 345678)', '(12, 3.45678)', '(12, 34.5678)', '(12, 345.678)', '(12, 3456.78)', '(12, 34567.8)', '(12, 345678)', '(1.23, 4.5678)', '(1.23, 45.678)', '(1.23, 456.78)', '(1.23, 4567.8)', '(1.23, 45678)', '(12.3, 4.5678)', '(12.3, 45.678)', '(12.3, 456.78)', '(12.3, 4567.8)', '(12.3, 45678)', '(123, 4.5678)', '(123, 45.678)', '(123, 456.78)', '(123, 4567.8)', '(123, 45678)', '(1.234, 5.678)', '(1.234, 56.78)', '(1.234, 567.8)', '(1.234, 5678)', '(12.34, 5.678)', '(12.34, 56.78)', '(12.34, 567.8)', '(12.34, 5678)', '(123.4, 5.678)', '(123.4, 56.78)', '(123.4, 567.8)', '(123.4, 5678)', '(1234, 5.678)', '(1234, 56.78)', '(1234, 567.8)', '(1234, 5678)', '(1.2345, 6.78)', '(1.2345, 67.8)', '(1.2345, 678)', '(12.345, 6.78)', '(12.345, 67.8)', '(12.345, 678)', '(123.45, 6.78)', '(123.45, 67.8)', '(123.45, 678)', '(1234.5, 6.78)', '(1234.5, 67.8)', '(1234.5, 678)', '(12345, 6.78)', '(12345, 67.8)', '(12345, 678)', '(1.23456, 7.8)', '(1.23456, 78)', '(12.3456, 7.8)', '(12.3456, 78)', '(123.456, 7.8)', '(123.456, 78)', '(1234.56, 7.8)', '(1234.56, 78)', '(12345.6, 7.8)', '(12345.6, 78)', '(123456, 7.8)', '(123456, 78)', '(1.234567, 8)', '(12.34567, 8)', '(123.4567, 8)', '(1234.567, 8)', '(12345.67, 8)', '(123456.7, 8)', '(1234567, 8)'])\n assert answers_match(candidate(s='(01001001)'), ['(0, 1.001001)', '(0, 10.01001)', '(0, 100.1001)', '(0, 1001.001)', '(0, 10010.01)', '(0, 100100.1)', '(0, 1001001)', '(0.1, 0.01001)', '(0.1001, 0.01)'])\n assert answers_match(candidate(s='(100100100)'), ['(100, 100100)', '(100100, 100)', '(10010010, 0)'])\n assert answers_match(candidate(s='(120000)'), ['(1, 20000)', '(12000, 0)'])\n assert answers_match(candidate(s='(10010)'), ['(100, 10)', '(1.001, 0)', '(10.01, 0)', '(100.1, 0)', '(1001, 0)'])\n assert answers_match(candidate(s='(123456)'), ['(1, 2.3456)', '(1, 23.456)', '(1, 234.56)', '(1, 2345.6)', '(1, 23456)', '(1.2, 3.456)', '(1.2, 34.56)', '(1.2, 345.6)', '(1.2, 3456)', '(12, 3.456)', '(12, 34.56)', '(12, 345.6)', '(12, 3456)', '(1.23, 4.56)', '(1.23, 45.6)', '(1.23, 456)', '(12.3, 4.56)', '(12.3, 45.6)', '(12.3, 456)', '(123, 4.56)', '(123, 45.6)', '(123, 456)', '(1.234, 5.6)', '(1.234, 56)', '(12.34, 5.6)', '(12.34, 56)', '(123.4, 5.6)', '(123.4, 56)', '(1234, 5.6)', '(1234, 56)', '(1.2345, 6)', '(12.345, 6)', '(123.45, 6)', '(1234.5, 6)', '(12345, 6)'])\n assert answers_match(candidate(s='(01000100)'), ['(0, 1000100)'])\n assert answers_match(candidate(s='(0120304)'), ['(0, 1.20304)', '(0, 12.0304)', '(0, 120.304)', '(0, 1203.04)', '(0, 12030.4)', '(0, 120304)', '(0.1, 2.0304)', '(0.1, 20.304)', '(0.1, 203.04)', '(0.1, 2030.4)', '(0.1, 20304)', '(0.12, 0.304)', '(0.1203, 0.4)'])\n assert answers_match(candidate(s='(001234567)'), ['(0, 0.1234567)', '(0.01, 2.34567)', '(0.01, 23.4567)', '(0.01, 234.567)', '(0.01, 2345.67)', '(0.01, 23456.7)', '(0.01, 234567)', '(0.012, 3.4567)', '(0.012, 34.567)', '(0.012, 345.67)', '(0.012, 3456.7)', '(0.012, 34567)', '(0.0123, 4.567)', '(0.0123, 45.67)', '(0.0123, 456.7)', '(0.0123, 4567)', '(0.01234, 5.67)', '(0.01234, 56.7)', '(0.01234, 567)', '(0.012345, 6.7)', '(0.012345, 67)', '(0.0123456, 7)'])\n assert answers_match(candidate(s='(9876543210)'), ['(9, 876543210)', '(9.8, 76543210)', '(98, 76543210)', '(9.87, 6543210)', '(98.7, 6543210)', '(987, 6543210)', '(9.876, 543210)', '(98.76, 543210)', '(987.6, 543210)', '(9876, 543210)', '(9.8765, 43210)', '(98.765, 43210)', '(987.65, 43210)', '(9876.5, 43210)', '(98765, 43210)', '(9.87654, 3210)', '(98.7654, 3210)', '(987.654, 3210)', '(9876.54, 3210)', '(98765.4, 3210)', '(987654, 3210)', '(9.876543, 210)', '(98.76543, 210)', '(987.6543, 210)', '(9876.543, 210)', '(98765.43, 210)', '(987654.3, 210)', '(9876543, 210)', '(9.8765432, 10)', '(98.765432, 10)', '(987.65432, 10)', '(9876.5432, 10)', '(98765.432, 10)', '(987654.32, 10)', '(9876543.2, 10)', '(98765432, 10)', '(9.87654321, 0)', '(98.7654321, 0)', '(987.654321, 0)', '(9876.54321, 0)', '(98765.4321, 0)', '(987654.321, 0)', '(9876543.21, 0)', '(98765432.1, 0)', '(987654321, 0)'])\n assert answers_match(candidate(s='(1230000000)'), ['(1, 230000000)', '(1.2, 30000000)', '(12, 30000000)', '(123000000, 0)'])\n assert answers_match(candidate(s='(0123456789)'), ['(0, 1.23456789)', '(0, 12.3456789)', '(0, 123.456789)', '(0, 1234.56789)', '(0, 12345.6789)', '(0, 123456.789)', '(0, 1234567.89)', '(0, 12345678.9)', '(0, 123456789)', '(0.1, 2.3456789)', '(0.1, 23.456789)', '(0.1, 234.56789)', '(0.1, 2345.6789)', '(0.1, 23456.789)', '(0.1, 234567.89)', '(0.1, 2345678.9)', '(0.1, 23456789)', '(0.12, 3.456789)', '(0.12, 34.56789)', '(0.12, 345.6789)', '(0.12, 3456.789)', '(0.12, 34567.89)', '(0.12, 345678.9)', '(0.12, 3456789)', '(0.123, 4.56789)', '(0.123, 45.6789)', '(0.123, 456.789)', '(0.123, 4567.89)', '(0.123, 45678.9)', '(0.123, 456789)', '(0.1234, 5.6789)', '(0.1234, 56.789)', '(0.1234, 567.89)', '(0.1234, 5678.9)', '(0.1234, 56789)', '(0.12345, 6.789)', '(0.12345, 67.89)', '(0.12345, 678.9)', '(0.12345, 6789)', '(0.123456, 7.89)', '(0.123456, 78.9)', '(0.123456, 789)', '(0.1234567, 8.9)', '(0.1234567, 89)', '(0.12345678, 9)'])\n assert answers_match(candidate(s='(010010)'), ['(0, 10010)', '(0.1001, 0)'])\n assert answers_match(candidate(s='(0001230456)'), ['(0, 0.01230456)', '(0.001, 2.30456)', '(0.001, 23.0456)', '(0.001, 230.456)', '(0.001, 2304.56)', '(0.001, 23045.6)', '(0.001, 230456)', '(0.0012, 3.0456)', '(0.0012, 30.456)', '(0.0012, 304.56)', '(0.0012, 3045.6)', '(0.0012, 30456)', '(0.00123, 0.456)', '(0.0012304, 5.6)', '(0.0012304, 56)', '(0.00123045, 6)'])\n assert answers_match(candidate(s='(0101010)'), ['(0, 101010)', '(0.10101, 0)'])\n assert answers_match(candidate(s='(123450000)'), ['(1, 23450000)', '(1.2, 3450000)', '(12, 3450000)', '(1.23, 450000)', '(12.3, 450000)', '(123, 450000)', '(1.234, 50000)', '(12.34, 50000)', '(123.4, 50000)', '(1234, 50000)', '(12345000, 0)'])\n assert answers_match(candidate(s='(1230000)'), ['(1, 230000)', '(1.2, 30000)', '(12, 30000)', '(123000, 0)'])\n assert answers_match(candidate(s='(1001001001)'), ['(1, 0.01001001)', '(10, 0.1001001)', '(100, 1.001001)', '(100, 10.01001)', '(100, 100.1001)', '(100, 1001.001)', '(100, 10010.01)', '(100, 100100.1)', '(100, 1001001)', '(1.001, 0.01001)', '(10.01, 0.01001)', '(100.1, 0.01001)', '(1001, 0.01001)', '(10010, 0.1001)', '(100100, 1.001)', '(100100, 10.01)', '(100100, 100.1)', '(100100, 1001)', '(1.001001, 0.01)', '(10.01001, 0.01)', '(100.1001, 0.01)', '(1001.001, 0.01)', '(10010.01, 0.01)', '(100100.1, 0.01)', '(1001001, 0.01)', '(10010010, 0.1)', '(100100100, 1)'])\n assert answers_match(candidate(s='(100010100)'), ['(1000, 10100)', '(100010, 100)', '(10001010, 0)'])\n assert answers_match(candidate(s='(123456789)'), ['(1, 2.3456789)', '(1, 23.456789)', '(1, 234.56789)', '(1, 2345.6789)', '(1, 23456.789)', '(1, 234567.89)', '(1, 2345678.9)', '(1, 23456789)', '(1.2, 3.456789)', '(1.2, 34.56789)', '(1.2, 345.6789)', '(1.2, 3456.789)', '(1.2, 34567.89)', '(1.2, 345678.9)', '(1.2, 3456789)', '(12, 3.456789)', '(12, 34.56789)', '(12, 345.6789)', '(12, 3456.789)', '(12, 34567.89)', '(12, 345678.9)', '(12, 3456789)', '(1.23, 4.56789)', '(1.23, 45.6789)', '(1.23, 456.789)', '(1.23, 4567.89)', '(1.23, 45678.9)', '(1.23, 456789)', '(12.3, 4.56789)', '(12.3, 45.6789)', '(12.3, 456.789)', '(12.3, 4567.89)', '(12.3, 45678.9)', '(12.3, 456789)', '(123, 4.56789)', '(123, 45.6789)', '(123, 456.789)', '(123, 4567.89)', '(123, 45678.9)', '(123, 456789)', '(1.234, 5.6789)', '(1.234, 56.789)', '(1.234, 567.89)', '(1.234, 5678.9)', '(1.234, 56789)', '(12.34, 5.6789)', '(12.34, 56.789)', '(12.34, 567.89)', '(12.34, 5678.9)', '(12.34, 56789)', '(123.4, 5.6789)', '(123.4, 56.789)', '(123.4, 567.89)', '(123.4, 5678.9)', '(123.4, 56789)', '(1234, 5.6789)', '(1234, 56.789)', '(1234, 567.89)', '(1234, 5678.9)', '(1234, 56789)', '(1.2345, 6.789)', '(1.2345, 67.89)', '(1.2345, 678.9)', '(1.2345, 6789)', '(12.345, 6.789)', '(12.345, 67.89)', '(12.345, 678.9)', '(12.345, 6789)', '(123.45, 6.789)', '(123.45, 67.89)', '(123.45, 678.9)', '(123.45, 6789)', '(1234.5, 6.789)', '(1234.5, 67.89)', '(1234.5, 678.9)', '(1234.5, 6789)', '(12345, 6.789)', '(12345, 67.89)', '(12345, 678.9)', '(12345, 6789)', '(1.23456, 7.89)', '(1.23456, 78.9)', '(1.23456, 789)', '(12.3456, 7.89)', '(12.3456, 78.9)', '(12.3456, 789)', '(123.456, 7.89)', '(123.456, 78.9)', '(123.456, 789)', '(1234.56, 7.89)', '(1234.56, 78.9)', '(1234.56, 789)', '(12345.6, 7.89)', '(12345.6, 78.9)', '(12345.6, 789)', '(123456, 7.89)', '(123456, 78.9)', '(123456, 789)', '(1.234567, 8.9)', '(1.234567, 89)', '(12.34567, 8.9)', '(12.34567, 89)', '(123.4567, 8.9)', '(123.4567, 89)', '(1234.567, 8.9)', '(1234.567, 89)', '(12345.67, 8.9)', '(12345.67, 89)', '(123456.7, 8.9)', '(123456.7, 89)', '(1234567, 8.9)', '(1234567, 89)', '(1.2345678, 9)', '(12.345678, 9)', '(123.45678, 9)', '(1234.5678, 9)', '(12345.678, 9)', '(123456.78, 9)', '(1234567.8, 9)', '(12345678, 9)'])\n assert answers_match(candidate(s='(001001001)'), ['(0, 0.1001001)', '(0.01, 0.01001)', '(0.01001, 0.01)'])\n assert answers_match(candidate(s='(001234)'), ['(0, 0.1234)', '(0.01, 2.34)', '(0.01, 23.4)', '(0.01, 234)', '(0.012, 3.4)', '(0.012, 34)', '(0.0123, 4)'])\n assert answers_match(candidate(s='(1230456)'), ['(1, 2.30456)', '(1, 23.0456)', '(1, 230.456)', '(1, 2304.56)', '(1, 23045.6)', '(1, 230456)', '(1.2, 3.0456)', '(1.2, 30.456)', '(1.2, 304.56)', '(1.2, 3045.6)', '(1.2, 30456)', '(12, 3.0456)', '(12, 30.456)', '(12, 304.56)', '(12, 3045.6)', '(12, 30456)', '(1.23, 0.456)', '(12.3, 0.456)', '(123, 0.456)', '(1230, 4.56)', '(1230, 45.6)', '(1230, 456)', '(1.2304, 5.6)', '(1.2304, 56)', '(12.304, 5.6)', '(12.304, 56)', '(123.04, 5.6)', '(123.04, 56)', '(1230.4, 5.6)', '(1230.4, 56)', '(12304, 5.6)', '(12304, 56)', '(1.23045, 6)', '(12.3045, 6)', '(123.045, 6)', '(1230.45, 6)', '(12304.5, 6)', '(123045, 6)'])\n assert answers_match(candidate(s='(1001001)'), ['(1, 0.01001)', '(10, 0.1001)', '(100, 1.001)', '(100, 10.01)', '(100, 100.1)', '(100, 1001)', '(1.001, 0.01)', '(10.01, 0.01)', '(100.1, 0.01)', '(1001, 0.01)', '(10010, 0.1)', '(100100, 1)'])\n assert answers_match(candidate(s='(101010)'), ['(10, 1010)', '(1010, 10)', '(1.0101, 0)', '(10.101, 0)', '(101.01, 0)', '(1010.1, 0)', '(10101, 0)'])\n assert answers_match(candidate(s='(1111111)'), ['(1, 1.11111)', '(1, 11.1111)', '(1, 111.111)', '(1, 1111.11)', '(1, 11111.1)', '(1, 111111)', '(1.1, 1.1111)', '(1.1, 11.111)', '(1.1, 111.11)', '(1.1, 1111.1)', '(1.1, 11111)', '(11, 1.1111)', '(11, 11.111)', '(11, 111.11)', '(11, 1111.1)', '(11, 11111)', '(1.11, 1.111)', '(1.11, 11.11)', '(1.11, 111.1)', '(1.11, 1111)', '(11.1, 1.111)', '(11.1, 11.11)', '(11.1, 111.1)', '(11.1, 1111)', '(111, 1.111)', '(111, 11.11)', '(111, 111.1)', '(111, 1111)', '(1.111, 1.11)', '(1.111, 11.1)', '(1.111, 111)', '(11.11, 1.11)', '(11.11, 11.1)', '(11.11, 111)', '(111.1, 1.11)', '(111.1, 11.1)', '(111.1, 111)', '(1111, 1.11)', '(1111, 11.1)', '(1111, 111)', '(1.1111, 1.1)', '(1.1111, 11)', '(11.111, 1.1)', '(11.111, 11)', '(111.11, 1.1)', '(111.11, 11)', '(1111.1, 1.1)', '(1111.1, 11)', '(11111, 1.1)', '(11111, 11)', '(1.11111, 1)', '(11.1111, 1)', '(111.111, 1)', '(1111.11, 1)', '(11111.1, 1)', '(111111, 1)'])\n assert answers_match(candidate(s='(123000)'), ['(1, 23000)', '(1.2, 3000)', '(12, 3000)', '(12300, 0)'])\n assert answers_match(candidate(s='(1000000000)'), ['(100000000, 0)'])\n", "comparison": "unordered"}, "public_tests": ["\"(123)\"", "\"(0123)\"", "\"(00011)\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().ambiguousCoordinates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:41+00:00", "tests_total": 93, "tests_dropped": 15, "flags": ["any_order"], "topic_tags": ["string", "backtracking", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def ambiguousCoordinates(self, s: str) -> list[str]:", "container": "Solution", "callable": "ambiguousCoordinates", "parameters": [{"name": "s", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 818, "task_id": "race-car", "difficulty": "Hard", "problem_description": "Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R' (reverse):\n\n- When you get an instruction 'A', your car does the following:\n - position += speed\n - speed *= 2\n- When you get an instruction 'R', your car does the following:\n - If your speed is positive then speed = -1\n - otherwise speed = 1\nYour position stays the same.\n\nFor example, after commands \"AAR\", your car goes to positions 0 --> 1 --> 3 --> 3, and your speed goes to 1 --> 2 --> 4 --> -1.\n\nGiven a target position target, return the length of the shortest sequence of instructions to get there.\n\nExample 1:\n\nInput: target = 3\nOutput: 2\nExplanation:\nThe shortest instruction sequence is \"AA\".\nYour position goes from 0 --> 1 --> 3.\n\nExample 2:\n\nInput: target = 6\nOutput: 5\nExplanation:\nThe shortest instruction sequence is \"AAARA\".\nYour position goes from 0 --> 1 --> 3 --> 7 --> 7 --> 6.\n\nConstraints:\n\n- 1 <= target <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = 3) == 2\n assert candidate(target = 6) == 5\n assert candidate(target = 4) == 5\n assert candidate(target = 10) == 7\n assert candidate(target = 1) == 1\n assert candidate(target = 100) == 19\n assert candidate(target = 15) == 4\n assert candidate(target = 1000) == 23\n assert candidate(target = 999) == 20\n assert candidate(target = 5000) == 41\n assert candidate(target = 8) == 6\n assert candidate(target = 6553) == 53\n assert candidate(target = 25) == 11\n assert candidate(target = 5120) == 29\n assert candidate(target = 200) == 22\n assert candidate(target = 29) == 10\n assert candidate(target = 2047) == 11\n assert candidate(target = 31) == 5\n assert candidate(target = 3000) == 33\n assert candidate(target = 2000) == 26\n assert candidate(target = 123) == 13\n assert candidate(target = 8192) == 16\n assert candidate(target = 40) == 15\n assert candidate(target = 8191) == 13\n assert candidate(target = 17) == 9\n assert candidate(target = 20) == 12\n assert candidate(target = 10000) == 45\n assert candidate(target = 500) == 20\n assert candidate(target = 750) == 25\n assert candidate(target = 9999) == 43\n assert candidate(target = 250) == 16\n assert candidate(target = 63) == 6\n assert candidate(target = 7) == 3\n assert candidate(target = 1023) == 10\n assert candidate(target = 42) == 15\n assert candidate(target = 1024) == 13\n assert candidate(target = 50) == 16\n assert candidate(target = 30) == 7\n assert candidate(target = 4096) == 15\n assert candidate(target = 4095) == 12\n assert candidate(target = 16) == 7\n assert candidate(target = 99) == 16\n assert candidate(target = 2048) == 14\n assert candidate(target = 5432) == 45\n", "comparison": "exact"}, "public_tests": ["3", "6"], "hints": [], "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().racecar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:46+00:00", "tests_total": 49, "tests_dropped": 5, "flags": [], "topic_tags": ["dynamic-programming", "heuristic-search", "a-search"]}, "language": "python", "interface": {"raw_signature": "def racecar(self, target: int) -> int:", "container": "Solution", "callable": "racecar", "parameters": [{"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 820, "task_id": "short-encoding-of-words", "difficulty": "Medium", "problem_description": "A valid encoding of an array of words is any reference string s and array of indices indices such that:\n\n- words.length == indices.length\n- The reference string s ends with the '#' character.\n- For each index indices[i], the substring of s starting from indices[i] and up to (but not including) the next '#' character is equal to words[i].\n\nGiven an array of words, return the length of the shortest reference string s possible of any valid encoding of words.\n\nExample 1:\n\nInput: words = [\"time\", \"me\", \"bell\"]\nOutput: 10\nExplanation: A valid encoding would be s = \"time#bell#\" and indices = [0, 2, 5].\nwords[0] = \"time\", the substring of s starting from indices[0] = 0 to the next '#' is underlined in \"time#bell#\"\nwords[1] = \"me\", the substring of s starting from indices[1] = 2 to the next '#' is underlined in \"time#bell#\"\nwords[2] = \"bell\", the substring of s starting from indices[2] = 5 to the next '#' is underlined in \"time#bell#\"\n\nExample 2:\n\nInput: words = [\"t\"]\nOutput: 2\nExplanation: A valid encoding would be s = \"t#\" and indices = [0].\n\nConstraints:\n\n- 1 <= words.length <= 2000\n- 1 <= words[i].length <= 7\n- words[i] consists of only lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno']) == 20\n assert candidate(words = ['hello', 'hell', 'he', 'h']) == 16\n assert candidate(words = ['aaa', 'aa', 'a']) == 4\n assert candidate(words = ['one', 'two', 'three', 'four', 'five']) == 24\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg']) == 20\n assert candidate(words = ['apple', 'ple', 'le', 'e']) == 6\n assert candidate(words = ['apple', 'pple', 'ple', 'le', 'e']) == 6\n assert candidate(words = ['ab', 'bc', 'cd', 'da']) == 12\n assert candidate(words = ['aa', 'aaa', 'aaaa', 'aaaaa']) == 6\n assert candidate(words = ['aa', 'aaa', 'aaaa']) == 5\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']) == 52\n assert candidate(words = ['xyz', 'xy', 'y', 'z']) == 7\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == 14\n assert candidate(words = ['cat', 'dog', 'rat', 'car']) == 16\n assert candidate(words = ['hello', 'world', 'hold']) == 17\n assert candidate(words = ['time', 'me', 'bell']) == 10\n assert candidate(words = ['at', 'ac', 'bc', 'abc']) == 10\n assert candidate(words = ['hello', 'world', 'code', 'word']) == 22\n assert candidate(words = ['abc', 'bcd', 'cde']) == 12\n assert candidate(words = ['t']) == 2\n assert candidate(words = ['hello', 'world', 'word', 'hello']) == 17\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde']) == 20\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh']) == 24\n assert candidate(words = ['banana', 'nana', 'ana', 'na', 'a', 'nan', 'nanan']) == 13\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z']) == 12\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'yxz', 'zxy', 'xzy', 'zy', 'yx', 'xz', 'zx', 'xy']) == 24\n assert candidate(words = ['random', 'andom', 'dom', 'om', 'm', 'rando', 'and', 'nd', 'd', 'rand', 'ran', 'ra', 'ndom']) == 25\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh']) == 25\n assert candidate(words = ['abc', 'bc', 'c', 'abcd', 'bcd']) == 9\n assert candidate(words = ['aa', 'aaa', 'aaaa', 'aab', 'aabaa', 'aabaaa', 'aabaaaa']) == 25\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']) == 35\n assert candidate(words = ['abcd', 'bcd', 'cd', 'd', 'abcde', 'bcde', 'cde', 'de', 'e']) == 11\n assert candidate(words = ['hello', 'hell', 'hel', 'he', 'h', 'world', 'worl', 'wor', 'wo', 'w']) == 40\n assert candidate(words = ['abcd', 'bcd', 'cd', 'd', 'a', 'ab', 'abc', 'bc', 'c']) == 14\n assert candidate(words = ['aaaaaa', 'aaaaa', 'aaaa', 'aaa', 'aa', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa']) == 7\n assert candidate(words = ['zebra', 'bra', 'ra', 'a', 'abacaxi', 'bacaxi', 'acaxi', 'caxi', 'axi', 'xi', 'i']) == 14\n assert candidate(words = ['zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z']) == 8\n assert candidate(words = ['ab', 'abc', 'abcd', 'abcde', 'abcdef']) == 25\n assert candidate(words = ['abcd', 'bcd', 'cd', 'd', 'efgh', 'fgh', 'gh', 'h', 'ijkl', 'jkl', 'kl', 'l']) == 15\n assert candidate(words = ['banana', 'anana', 'nana', 'ana', 'na', 'a', 'ban']) == 11\n assert candidate(words = ['abcd', 'bcd', 'cd', 'd', 'def', 'ef', 'f', 'fgh', 'gh', 'h']) == 13\n assert candidate(words = ['banana', 'anana', 'nana', 'ana', 'na', 'a', 'nabana', 'bananab']) == 22\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jkl', 'kl', 'l']) == 45\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 78\n assert candidate(words = ['hello', 'hell', 'helo', 'he', 'h', 'e']) == 21\n assert candidate(words = ['abacaxi', 'bacaxi', 'caxi', 'axi', 'xi', 'i']) == 8\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'yxz', 'xzy', 'zxy']) == 24\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa']) == 8\n assert candidate(words = ['word', 'ord', 'rd', 'd', 'word', 'ord', 'rd', 'd', 'word', 'ord', 'rd', 'd', 'word', 'ord', 'rd', 'd', 'word', 'ord', 'rd', 'd']) == 5\n assert candidate(words = ['apple', 'peel', 'pale', 'ale', 'le']) == 16\n assert candidate(words = ['apple', 'ple', 'le', 'e', 'app', 'ppl']) == 14\n assert candidate(words = ['ab', 'bc', 'abc', 'abcd', 'abcde']) == 18\n assert candidate(words = ['apple', 'ple', 'le', 'e', 'app', 'pple', 'plea']) == 15\n assert candidate(words = ['zebra', 'ebra', 'bra', 'ra', 'a', 'z']) == 8\n assert candidate(words = ['cat', 'dog', 'god', 'tac', 'act', 'gat']) == 24\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg']) == 20\n assert candidate(words = ['coding', 'ing', 'ode', 'de', 'e']) == 11\n assert candidate(words = ['aaa', 'aab', 'aba', 'abb', 'baa', 'bab', 'bba', 'bbb', 'bbb', 'bbb']) == 32\n assert candidate(words = ['abcd', 'bcd', 'cd', 'd', 'abcds', 'bcde', 'cde', 'de', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 96\n assert candidate(words = ['unique', 'un', 'iq', 'que', 'eue', 'eu', 'ue', 'eq', 'qu', 'uq']) == 29\n assert candidate(words = ['zebra', 'ebra', 'bra', 'ra', 'a', 'cab', 'ab', 'b']) == 10\n assert candidate(words = ['sun', 'un', 'n', 'moon', 'oon', 'on', 'noon', 'oon', 'on', 'n']) == 14\n assert candidate(words = ['apple', 'peach', 'pear', 'leap', 'lead', 'meat', 'heat', 'seat']) == 42\n assert candidate(words = ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb']) == 25\n assert candidate(words = ['banana', 'ananas', 'nana', 'ana', 'na', 'a', 'banana', 'ananas', 'nana', 'ana', 'na', 'a']) == 14\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll', 'mmmm', 'nnnn', 'oooo', 'pppp', 'qqqq', 'rrrr', 'ssss', 'tttt']) == 100\n assert candidate(words = ['aaa', 'aab', 'aac', 'aba', 'abc', 'aca', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc']) == 96\n assert candidate(words = ['aaaa', 'aaa', 'aa', 'a', 'aaaaa']) == 6\n assert candidate(words = ['banana', 'anana', 'nana', 'ana', 'na', 'a', 'cat', 'at', 't']) == 11\n assert candidate(words = ['xyz', 'yz', 'z', 'xy', 'x', 'yx', 'zxy', 'zyx', 'yxz', 'zyxz', 'xyzz', 'zyzzz', 'zyzyz']) == 34\n assert candidate(words = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn', 'klmno', 'lmnop', 'mnopq', 'nopqr', 'opqrs', 'pqrst', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz', 'wxyz', 'xyz', 'yz', 'z']) == 132\n assert candidate(words = ['apple', 'app', 'ple', 'le', 'e']) == 10\n assert candidate(words = ['pqr', 'pqs', 'prq', 'prs', 'psq', 'psr', 'rpq', 'rps', 'rsp', 'rsq', 'spq', 'spr']) == 48\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']) == 75\n assert candidate(words = ['apple', 'ple', 'le', 'e', 'orange', 'range', 'age', 'ge']) == 17\n assert candidate(words = ['abcd', 'bcd', 'cd', 'd', 'abcd', 'bcd', 'cd', 'd']) == 5\n assert candidate(words = ['apple', 'ple', 'app', 'le', 'p', 'l', 'e', 'a']) == 14\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']) == 96\n assert candidate(words = ['abcdefg', 'cdefg', 'defg', 'efg', 'fg', 'g']) == 8\n assert candidate(words = ['kitten', 'ten', 'en', 'n', 'sitting', 'ting', 'ing', 'ng', 'g']) == 15\n", "comparison": "exact"}, "public_tests": ["[\"time\",\"me\",\"bell\"]", "[\"t\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().minimumLengthEncoding", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:48+00:00", "tests_total": 116, "tests_dropped": 36, "flags": [], "topic_tags": ["array", "hash-table", "string", "trie"]}, "language": "python", "interface": {"raw_signature": "def minimumLengthEncoding(self, words: list[str]) -> int:", "container": "Solution", "callable": "minimumLengthEncoding", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 821, "task_id": "shortest-distance-to-a-character", "difficulty": "Easy", "problem_description": "Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s.\n\nThe distance between two indices i and j is abs(i - j), where abs is the absolute value function.\n\nExample 1:\n\nInput: s = \"loveleetcode\", c = \"e\"\nOutput: [3,2,1,0,1,0,0,1,2,2,1,0]\nExplanation: The character 'e' appears at indices 3, 5, 6, and 11 (0-indexed).\nThe closest occurrence of 'e' for index 0 is at index 3, so the distance is abs(0 - 3) = 3.\nThe closest occurrence of 'e' for index 1 is at index 3, so the distance is abs(1 - 3) = 2.\nFor index 4, there is a tie between the 'e' at index 3 and the 'e' at index 5, but the distance is still the same: abs(4 - 3) == abs(4 - 5) = 1.\nThe closest occurrence of 'e' for index 8 is at index 6, so the distance is abs(8 - 6) = 2.\n\nExample 2:\n\nInput: s = \"aaab\", c = \"b\"\nOutput: [3,2,1,0]\n\nConstraints:\n\n- 1 <= s.length <= 10^4\n- s[i] and c are lowercase English letters.\n- It is guaranteed that c occurs at least once in s.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abba\",c = \"a\") == [0, 1, 1, 0]\n assert candidate(s = \"loveleetcode\",c = \"e\") == [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]\n assert candidate(s = \"abcde\",c = \"e\") == [4, 3, 2, 1, 0]\n assert candidate(s = \"abcabcabc\",c = \"b\") == [1, 0, 1, 1, 0, 1, 1, 0, 1]\n assert candidate(s = \"abcdabcabcde\",c = \"c\") == [2, 1, 0, 1, 2, 1, 0, 1, 1, 0, 1, 2]\n assert candidate(s = \"eccdccccdcccdcced\",c = \"e\") == [0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1]\n assert candidate(s = \"abcdabc\",c = \"a\") == [0, 1, 2, 1, 0, 1, 2]\n assert candidate(s = \"aabbcc\",c = \"b\") == [2, 1, 0, 0, 1, 2]\n assert candidate(s = \"zzzz\",c = \"z\") == [0, 0, 0, 0]\n assert candidate(s = \"bbaacc\",c = \"c\") == [4, 3, 2, 1, 0, 0]\n assert candidate(s = \"ababab\",c = \"a\") == [0, 1, 0, 1, 0, 1]\n assert candidate(s = \"aabbccddeeff\",c = \"d\") == [6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4]\n assert candidate(s = \"abcdefg\",c = \"a\") == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"aabaabaaa\",c = \"b\") == [2, 1, 0, 1, 1, 0, 1, 2, 3]\n assert candidate(s = \"aaab\",c = \"b\") == [3, 2, 1, 0]\n assert candidate(s = \"abcde\",c = \"a\") == [0, 1, 2, 3, 4]\n assert candidate(s = \"mississippi\",c = \"i\") == [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(s = \"abcdefg\",c = \"g\") == [6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"abba\",c = \"b\") == [1, 0, 0, 1]\n assert candidate(s = \"aaaa\",c = \"a\") == [0, 0, 0, 0]\n assert candidate(s = \"aaaaabbbbbccccc\",c = \"b\") == [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]\n assert candidate(s = \"a\",c = \"a\") == [0]\n assert candidate(s = \"mnopqrstuvwxyzmnpqrstuvwxyzmnpqrstuvwxyzmnpqrstuvwxyzmnpqrstuvwxyz\",c = \"z\") == [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",c = \"m\") == [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]\n assert candidate(s = \"hellohellohello\",c = \"h\") == [0, 1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 4]\n assert candidate(s = \"abracadabraabracadabraabracadabra\",c = \"a\") == [0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0]\n assert candidate(s = \"zzzxxxyyyzzz\",c = \"y\") == [6, 5, 4, 3, 2, 1, 0, 0, 0, 1, 2, 3]\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",c = \"o\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 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, 0, 1]\n assert candidate(s = \"abcdefghijabcdefghij\",c = \"f\") == [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]\n assert candidate(s = \"leetcodeleetcodeleetcode\",c = \"e\") == [1, 0, 0, 1, 2, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]\n assert candidate(s = \"zzzzzzzzz\",c = \"z\") == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(s = \"allaboutthatbass\",c = \"a\") == [0, 1, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 1, 0, 1, 2]\n assert candidate(s = \"alibabaibabaibabaibabaibabaibabaibabaibaba\",c = \"b\") == [3, 2, 1, 0, 1, 0, 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, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",c = \"z\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = \"bbaabbaabbaabbaabbaa\",c = \"b\") == [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 2]\n assert candidate(s = \"xyxzyzyxzyxzyzyx\",c = \"z\") == [3, 2, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 2]\n assert candidate(s = \"banana\",c = \"n\") == [2, 1, 0, 1, 0, 1]\n assert candidate(s = \"antidisestablishmentarianism\",c = \"a\") == [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 1, 0, 1, 2, 3, 4]\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",c = \"b\") == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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(s = \"banana\",c = \"a\") == [1, 0, 1, 0, 1, 0]\n assert candidate(s = \"ababababababababababa\",c = \"b\") == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(s = \"xyxxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\",c = \"x\") == [0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"aaaaaaaabaaaaaaaa\",c = \"b\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(s = \"aaaaaabbbaaaa\",c = \"b\") == [6, 5, 4, 3, 2, 1, 0, 0, 0, 1, 2, 3, 4]\n assert candidate(s = \"helloworld\",c = \"o\") == [4, 3, 2, 1, 0, 1, 0, 1, 2, 3]\n assert candidate(s = \"abababababababababab\",c = \"a\") == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(s = \"zzzxyzxxzyzxzzzxzyzxzyzxzyzxzyz\",c = \"x\") == [3, 2, 1, 0, 1, 1, 0, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",c = \"z\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(s = \"ababababab\",c = \"b\") == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"abcdefghij\",c = \"a\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(s = \"ababababababababababababababababababababa\",c = \"a\") == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"abcdefgabcdefg\",c = \"c\") == [2, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 4]\n assert candidate(s = \"ababababababababababababababababababababab\",c = \"a\") == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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(s = \"honorificabilitudinitatibus\",c = \"i\") == [5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",c = \"y\") == [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]\n assert candidate(s = \"leetcodeleetcodeleetcode\",c = \"o\") == [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2]\n assert candidate(s = \"mississippi\",c = \"p\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1]\n assert candidate(s = \"bababababababababababababababababababababa\",c = \"b\") == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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(s = \"abcdefghijklmnopqrstuvwxyz\",c = \"m\") == [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]\n assert candidate(s = \"abcdefghij\",c = \"c\") == [2, 1, 0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(s = \"longstringwithvariouscharacters\",c = \"r\") == [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 2, 1, 0, 1]\n assert candidate(s = \"bbbbbbaaaabbbbbbaaaabbbbbbaaaabbbbbb\",c = \"a\") == [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"abcdefghij\",c = \"h\") == [7, 6, 5, 4, 3, 2, 1, 0, 1, 2]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",c = \"a\") == [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]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",c = \"d\") == [3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"xyxzyzyzxzyzxzyzx\",c = \"z\") == [3, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(s = \"aaabbbcccdddeee\",c = \"c\") == [6, 5, 4, 3, 2, 1, 0, 0, 0, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",c = \"q\") == [0, 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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(s = \"abcdefghij\",c = \"j\") == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",c = \"o\") == [5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 1, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0, 1, 0, 1, 1, 0, 1, 2, 3]\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",c = \"o\") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1]\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",c = \"a\") == [0, 0, 0, 0, 0, 0, 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 = \"zxyxzyxzyxz\",c = \"y\") == [2, 1, 0, 1, 1, 0, 1, 1, 0, 1, 2]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",c = \"z\") == [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 = \"zzzzzzzzzz\",c = \"z\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(s = \"longwordwithmanyletters\",c = \"w\") == [4, 3, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(s = \"racecar\",c = \"e\") == [3, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"abacabadabacaba\",c = \"c\") == [3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"programming\",c = \"m\") == [6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3]\n assert candidate(s = \"abcabcabcabcabc\",c = \"b\") == [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]\n assert candidate(s = \"abacabadabacaba\",c = \"b\") == [1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1]\n assert candidate(s = \"aaaaabaaaabaaaaabaaa\",c = \"b\") == [5, 4, 3, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",c = \"f\") == [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]\n assert candidate(s = \"pppppppppp\",c = \"p\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(s = \"xxyyzzxxxyyzz\",c = \"z\") == [4, 3, 2, 1, 0, 0, 1, 2, 3, 2, 1, 0, 0]\n assert candidate(s = \"aaaaaaaaaaaaaaaab\",c = \"b\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"bbaabbaabbaa\",c = \"a\") == [2, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",c = \"p\") == [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(s = \"civicciviccivic\",c = \"v\") == [2, 1, 0, 1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2]\n assert candidate(s = \"xyzxyzxyz\",c = \"z\") == [2, 1, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(s = \"zzzzzzz\",c = \"z\") == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(s = \"abababababababababab\",c = \"b\") == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"abcdefgabcdefg\",c = \"d\") == [3, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",c = \"c\") == [4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",c = \"q\") == [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]\n assert candidate(s = \"nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\",c = \"n\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = \"abcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\",c = \"b\") == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"xylophone\",c = \"o\") == [3, 2, 1, 0, 1, 1, 0, 1, 2]\n assert candidate(s = \"abababababababababababababab\",c = \"b\") == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"racecar\",c = \"a\") == [1, 0, 1, 2, 1, 0, 1]\n assert candidate(s = \"aaabbaaa\",c = \"b\") == [3, 2, 1, 0, 0, 1, 2, 3]\n assert candidate(s = \"floccinaucinihilipilification\",c = \"f\") == [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]\n assert candidate(s = \"elephantelephant\",c = \"e\") == [0, 1, 0, 1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5]\n assert candidate(s = \"thisisaverylongstringwithsomerepeatedcharacters\",c = \"s\") == [3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 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]\n assert candidate(s = \"abacabadabacaba\",c = \"d\") == [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(s = \"aaaaaaaaaabbbbcccc\",c = \"b\") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 1, 2, 3, 4]\n assert candidate(s = \"abcdefghigklmnopqrstuvwxyz\",c = \"m\") == [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]\n assert candidate(s = \"abracadabra\",c = \"a\") == [0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0]\n assert candidate(s = \"leetcodeisnice\",c = \"e\") == [1, 0, 0, 1, 2, 2, 1, 0, 1, 2, 3, 2, 1, 0]\n assert candidate(s = \"abcdefgabcdefgabcdefg\",c = \"g\") == [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0]\n assert candidate(s = \"ababababa\",c = \"a\") == [0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(s = \"lkhfjldshgflsjghljsfgljsdgfljsgdfjlsghsflkghsflkl\",c = \"l\") == [0, 1, 2, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 0]\n assert candidate(s = \"supercalifragilisticexpialidocious\",c = \"i\") == [8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 2, 1, 0, 1, 0, 1, 1, 0, 1, 2, 2, 1, 0, 1, 1, 0, 1, 2, 1, 0, 1, 2, 3]\n assert candidate(s = \"hellohellohellohello\",c = \"l\") == [2, 1, 0, 0, 1, 2, 1, 0, 0, 1, 2, 1, 0, 0, 1, 2, 1, 0, 0, 1]\n assert candidate(s = \"elephant\",c = \"e\") == [0, 1, 0, 1, 2, 3, 4, 5]\n assert candidate(s = \"thisisaverylongstringwithmultiplescharacters\",c = \"s\") == [3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"llllllllllllllllllllllllllllllllllllllllllllllllllllll\",c = \"l\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = \"supercalifragilisticexpialidocious\",c = \"x\") == [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, 6, 7, 8, 9, 10, 11, 12]\n", "comparison": "exact"}, "public_tests": ["\"loveleetcode\"\n\"e\"", "\"aaab\"\n\"b\""], "hints": [], "metadata": {"canonical_parameter_names": ["s", "c"], "leetcode_dataset_entry_point": "Solution().shortestToChar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:51+00:00", "tests_total": 118, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def shortestToChar(self, s: str, c: str) -> list[int]:", "container": "Solution", "callable": "shortestToChar", "parameters": [{"name": "s", "type": "str"}, {"name": "c", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 822, "task_id": "card-flipping-game", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays fronts and backs of length n, where the i^th card has the positive integer fronts[i] printed on the front and backs[i] printed on the back. Initially, each card is placed on a table such that the front number is facing up and the other is facing down. You may flip over any number of cards (possibly zero).\n\nAfter flipping the cards, an integer is considered good if it is facing down on some card and not facing up on any card.\n\nReturn the minimum possible good integer after flipping the cards. If there are no good integers, return 0.\n\nExample 1:\n\nInput: fronts = [1,2,4,4,7], backs = [1,3,4,1,3]\nOutput: 2\nExplanation:\nIf we flip the second card, the face up numbers are [1,3,4,4,7] and the face down are [1,2,4,1,3].\n2 is the minimum good integer as it appears facing down but not facing up.\nIt can be shown that 2 is the minimum possible good integer obtainable after flipping some cards.\n\nExample 2:\n\nInput: fronts = [1], backs = [1]\nOutput: 0\nExplanation:\nThere are no good integers no matter how we flip the cards, so we return 0.\n\nConstraints:\n\n- n == fronts.length == backs.length\n- 1 <= n <= 1000\n- 1 <= fronts[i], backs[i] <= 2000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(fronts = [1, 3, 5, 7],backs = [2, 4, 6, 8]) == 1\n assert candidate(fronts = [1, 1, 2, 2],backs = [2, 2, 1, 1]) == 1\n assert candidate(fronts = [1, 3, 5, 7],backs = [2, 4, 6, 8]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [1, 3, 5, 7, 9],backs = [2, 4, 6, 8, 10]) == 1\n assert candidate(fronts = [5, 6, 7, 8],backs = [8, 7, 6, 5]) == 5\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [1],backs = [1]) == 0\n assert candidate(fronts = [1, 1, 1, 1],backs = [1, 1, 1, 1]) == 0\n assert candidate(fronts = [1000, 1000, 1000],backs = [1001, 1002, 1003]) == 1000\n assert candidate(fronts = [1, 1, 1, 1, 1],backs = [2, 2, 2, 2, 1]) == 2\n assert candidate(fronts = [2, 2, 2, 2],backs = [2, 2, 2, 2]) == 0\n assert candidate(fronts = [1, 2, 3],backs = [3, 2, 1]) == 1\n assert candidate(fronts = [1, 2, 3],backs = [3, 2, 1]) == 1\n assert candidate(fronts = [1, 1, 1, 2],backs = [1, 1, 2, 1]) == 2\n assert candidate(fronts = [1, 1, 1, 1],backs = [2, 2, 2, 2]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [6, 7, 8, 9, 10]) == 1\n assert candidate(fronts = [1, 2, 4, 4, 7],backs = [1, 3, 4, 1, 3]) == 2\n assert candidate(fronts = [1000, 2000],backs = [2000, 1000]) == 1000\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],backs = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],backs = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1\n assert candidate(fronts = [1, 2, 2, 3, 3, 4, 5, 6],backs = [6, 5, 4, 3, 2, 1, 2, 3]) == 1\n assert candidate(fronts = [2, 3, 2, 3, 2, 3],backs = [3, 2, 3, 2, 3, 2]) == 2\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],backs = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(fronts = [10, 20, 30, 40, 50, 60],backs = [60, 50, 40, 30, 20, 10]) == 10\n assert candidate(fronts = [1, 1, 1, 1],backs = [1, 1, 1, 1]) == 0\n assert candidate(fronts = [2000, 1999, 1998, 1997, 1996, 1995],backs = [1995, 1996, 1997, 1998, 1999, 2000]) == 1995\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(fronts = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],backs = [109, 108, 107, 106, 105, 104, 103, 102, 101, 100]) == 100\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(fronts = [1000, 2000, 1500, 500, 1200],backs = [2000, 1000, 1500, 1000, 500]) == 500\n assert candidate(fronts = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],backs = [6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(fronts = [1, 1, 1, 1, 1, 1],backs = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [6, 7, 8, 9, 10]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [10, 10, 10, 10, 10],backs = [1, 2, 3, 4, 5]) == 1\n assert candidate(fronts = [500, 501, 502, 503, 504],backs = [504, 503, 502, 501, 500]) == 500\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 10]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(fronts = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],backs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(fronts = [10, 10, 20, 30, 40, 50],backs = [50, 20, 10, 30, 40, 60]) == 10\n assert candidate(fronts = [2000, 1999, 1998, 1997, 1996],backs = [1995, 1994, 1993, 1992, 1991]) == 1991\n assert candidate(fronts = [500, 500, 500, 500, 500],backs = [500, 501, 502, 503, 504]) == 501\n assert candidate(fronts = [1, 1, 2, 2, 3, 3],backs = [3, 3, 1, 1, 2, 2]) == 1\n assert candidate(fronts = [2000, 1999, 1998, 1997, 1996],backs = [1995, 1996, 1997, 1998, 1999]) == 1995\n assert candidate(fronts = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],backs = [1009, 1008, 1007, 1006, 1005, 1004, 1003, 1002, 1001, 1000]) == 1000\n assert candidate(fronts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],backs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(fronts = [1, 3, 5, 7, 9],backs = [2, 4, 6, 8, 1000]) == 1\n assert candidate(fronts = [1, 1, 1, 2, 2, 2, 3, 3, 3],backs = [3, 2, 1, 3, 2, 1, 3, 2, 1]) == 0\n assert candidate(fronts = [2, 3, 5, 7, 11, 13],backs = [11, 13, 2, 3, 5, 7]) == 2\n assert candidate(fronts = [1, 1, 1, 1, 1],backs = [1, 1, 1, 1, 1]) == 0\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [1, 2, 3, 4, 5]) == 0\n assert candidate(fronts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],backs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1\n assert candidate(fronts = [2, 3, 5, 7, 11, 13, 17, 19],backs = [19, 17, 13, 11, 7, 5, 3, 2]) == 2\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],backs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [1, 3, 3, 7, 9],backs = [2, 3, 5, 7, 8]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],backs = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11]) == 1\n assert candidate(fronts = [1, 1, 2, 3, 4, 5],backs = [5, 4, 3, 2, 1, 1]) == 1\n assert candidate(fronts = [500, 501, 502, 503, 504, 505],backs = [505, 504, 503, 502, 501, 500]) == 500\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [2, 1, 4, 3, 5]) == 1\n assert candidate(fronts = [11, 22, 33, 44, 55],backs = [55, 44, 33, 22, 11]) == 11\n assert candidate(fronts = [5, 5, 5, 5, 5],backs = [5, 5, 5, 5, 5]) == 0\n assert candidate(fronts = [2, 3, 2, 4, 3, 4, 5, 6, 7, 8],backs = [8, 7, 6, 5, 4, 3, 2, 1, 2, 3]) == 1\n assert candidate(fronts = [1, 1, 1, 1, 1],backs = [2, 2, 2, 2, 2]) == 1\n assert candidate(fronts = [1, 1, 1, 1, 2, 2, 2, 2],backs = [2, 2, 2, 2, 1, 1, 1, 1]) == 1\n assert candidate(fronts = [1, 1, 2, 2, 3, 3],backs = [2, 2, 3, 3, 4, 4]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],backs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [100, 200, 300, 400, 500],backs = [500, 400, 300, 200, 100]) == 100\n assert candidate(fronts = [10, 20, 30, 40, 50],backs = [50, 40, 30, 20, 10]) == 10\n assert candidate(fronts = [1500, 1600, 1700, 1800, 1900],backs = [1900, 1800, 1700, 1600, 1500]) == 1500\n assert candidate(fronts = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991],backs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(fronts = [1, 1, 2, 2, 3, 3],backs = [2, 2, 3, 3, 1, 1]) == 1\n assert candidate(fronts = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],backs = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 11\n assert candidate(fronts = [100, 100, 200, 200, 300, 300],backs = [200, 200, 300, 300, 100, 100]) == 100\n assert candidate(fronts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],backs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(fronts = [1, 2, 2, 3, 4],backs = [4, 3, 3, 2, 1]) == 1\n assert candidate(fronts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],backs = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 11]) == 1\n assert candidate(fronts = [15, 15, 15, 15, 16],backs = [16, 15, 15, 15, 15]) == 16\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(fronts = [1000, 2, 3, 4, 5],backs = [5, 1000, 3, 4, 2]) == 2\n assert candidate(fronts = [10, 20, 30, 40, 50, 60],backs = [10, 30, 50, 70, 90, 110]) == 20\n assert candidate(fronts = [101, 102, 103, 104, 105],backs = [106, 105, 104, 103, 102]) == 101\n assert candidate(fronts = [2000, 1999, 1998, 1997, 1996],backs = [1996, 1997, 1998, 1999, 2000]) == 1996\n assert candidate(fronts = [5, 5, 5, 5, 5, 5],backs = [6, 6, 6, 6, 6, 6]) == 5\n assert candidate(fronts = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4],backs = [4, 4, 4, 3, 3, 3, 2, 2, 2, 1]) == 1\n assert candidate(fronts = [1, 1, 1, 2, 2, 3],backs = [1, 2, 3, 3, 1, 1]) == 2\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],backs = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 1\n assert candidate(fronts = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],backs = [4, 3, 3, 2, 2, 2, 1, 1, 1, 1]) == 1\n assert candidate(fronts = [2, 3, 5, 7, 11, 13],backs = [13, 11, 7, 5, 3, 2]) == 2\n assert candidate(fronts = [1000, 2000, 1000, 2000, 1000, 2000],backs = [2000, 1000, 2000, 1000, 2000, 1000]) == 1000\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4],backs = [1, 2, 1, 3, 2, 4, 3, 5]) == 2\n assert candidate(fronts = [2000, 2000, 2000, 2000, 2000],backs = [1, 2, 3, 4, 5]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],backs = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],backs = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 2\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],backs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == 10\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],backs = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5],backs = [5, 1, 4, 3, 2]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],backs = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(fronts = [1, 1, 2, 2, 3, 3, 4, 4],backs = [2, 2, 1, 1, 4, 4, 3, 3]) == 1\n assert candidate(fronts = [1, 3, 5, 7, 9, 11],backs = [11, 9, 7, 5, 3, 1]) == 1\n assert candidate(fronts = [1, 2, 3, 2, 1, 4, 5],backs = [5, 4, 3, 3, 4, 1, 2]) == 1\n assert candidate(fronts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],backs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(fronts = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],backs = [6, 5, 5, 4, 3, 3, 2, 1, 1, 1]) == 1\n assert candidate(fronts = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],backs = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 2\n assert candidate(fronts = [2, 4, 6, 8, 10],backs = [1, 3, 5, 7, 9]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,2,4,4,7]\n[1,3,4,1,3]", "[1]\n[1]"], "hints": [], "metadata": {"canonical_parameter_names": ["fronts", "backs"], "leetcode_dataset_entry_point": "Solution().flipgame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:53+00:00", "tests_total": 107, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def flipgame(self, fronts: list[int], backs: list[int]) -> int:", "container": "Solution", "callable": "flipgame", "parameters": [{"name": "fronts", "type": "list[int]"}, {"name": "backs", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 823, "task_id": "binary-trees-with-factors", "difficulty": "Medium", "problem_description": "Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1.\n\nWe make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children.\n\nReturn the number of binary trees we can make. The answer may be too large so return the answer modulo 10^9 + 7.\n\nExample 1:\n\nInput: arr = [2,4]\nOutput: 3\nExplanation: We can make these trees: [2], [4], [4, 2, 2]\n\nExample 2:\n\nInput: arr = [2,4,5,10]\nOutput: 7\nExplanation: We can make these trees: [2], [4], [5], [10], [4, 2, 2], [10, 2, 5], [10, 5, 2].\n\nConstraints:\n\n- 1 <= arr.length <= 1000\n- 2 <= arr[i] <= 10^9\n- All the values of arr are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 40, 80]) == 4\n assert candidate(arr = [2, 4, 5, 10]) == 7\n assert candidate(arr = [2, 3, 6, 18]) == 12\n assert candidate(arr = [5, 10, 20, 40, 80]) == 5\n assert candidate(arr = [18, 3, 6, 2]) == 12\n assert candidate(arr = [3, 6, 9]) == 4\n assert candidate(arr = [2, 3, 4, 6, 8, 12, 16, 24, 48]) == 278\n assert candidate(arr = [2, 3, 6]) == 5\n assert candidate(arr = [2, 3, 5, 6, 10, 15, 30]) == 31\n assert candidate(arr = [2, 5, 10, 20, 40]) == 27\n assert candidate(arr = [2, 4]) == 3\n assert candidate(arr = [3, 6, 9, 18, 27]) == 12\n assert candidate(arr = [6, 10, 14, 15, 21, 22, 26, 33, 34, 35, 38, 39, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95, 106, 111, 115, 118, 119, 121, 122, 123, 133, 134, 141, 142, 143, 145, 146, 155, 158, 159, 161, 166, 177, 178, 183, 187, 194]) == 54\n assert candidate(arr = [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]) == 93720241\n assert candidate(arr = [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]) == 31\n assert candidate(arr = [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, 546, 567, 588, 609, 630, 651, 672, 693, 714, 735, 756, 777, 798, 819, 840, 861, 882, 903, 924, 945, 966, 987, 1008, 1029, 1050, 1071, 1092, 1113, 1134, 1155, 1176, 1197, 1218, 1239, 1260, 1281, 1302, 1323, 1344, 1365, 1386, 1407, 1428, 1449, 1470, 1491, 1512, 1533, 1554, 1575, 1596, 1617, 1638, 1659, 1680, 1701, 1722, 1743, 1764, 1785, 1806, 1827, 1848, 1869, 1890, 1911, 1932, 1953, 1974, 1995, 2016, 2037, 2058, 2079, 2100, 2121, 2142, 2163, 2184, 2205, 2226, 2247, 2268, 2289, 2310]) == 120\n assert candidate(arr = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125]) == 16178\n assert candidate(arr = [8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024]) == 64\n assert candidate(arr = [2, 3, 4, 6, 8, 12, 24]) == 68\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == 10\n assert candidate(arr = [7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61]) == 15\n assert candidate(arr = [13, 169, 2197, 28561, 371293]) == 74\n assert candidate(arr = [7, 11, 13, 14, 15, 21, 22, 26, 33, 39, 77, 143]) == 16\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256]) == 3943\n assert candidate(arr = [100, 200, 400, 500, 800, 1000, 2000, 4000, 8000, 10000]) == 11\n assert candidate(arr = [7, 14, 28, 49, 98, 196]) == 12\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 68000\n assert candidate(arr = [2, 5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 98\n assert candidate(arr = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 16178\n assert candidate(arr = [12, 15, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 100, 120, 144, 150, 180, 200, 240, 300, 360, 400, 450, 600, 720, 900, 1200, 1800, 3600]) == 108\n assert candidate(arr = [7, 14, 28, 49, 98, 196, 343, 686, 1372]) == 47\n assert candidate(arr = [18, 3, 6, 2, 9]) == 18\n assert candidate(arr = [13, 169, 2197, 28561, 371293, 4826809, 62748517, 815730721]) == 3943\n assert candidate(arr = [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(arr = [2, 3, 6, 12, 24]) == 27\n assert candidate(arr = [7, 14, 28, 49, 98, 196, 343, 686]) == 28\n assert candidate(arr = [3, 9, 27, 81, 243, 729, 2187]) == 993\n assert candidate(arr = [13, 17, 221, 289, 299, 377, 4913]) == 14\n assert candidate(arr = [6, 10, 15, 30, 60, 150, 300, 750, 1500]) == 21\n assert candidate(arr = [5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 625, 1000, 1250, 2500, 5000]) == 366\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704, 1408, 2816, 5632, 11264]) == 11\n assert candidate(arr = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 21\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368, 391, 414, 437, 460, 483, 506, 529, 552, 575, 598, 621, 644, 667, 690, 713, 736, 759, 782, 805, 828, 851, 874, 897, 920, 943, 966, 989, 1012, 1035, 1058, 1081, 1104, 1127, 1150, 1173, 1196, 1219, 1242, 1265, 1288, 1311, 1334, 1357, 1380, 1403, 1426, 1449, 1472, 1495, 1518, 1541, 1564, 1587, 1610, 1633, 1656, 1679, 1702, 1725, 1748, 1771, 1794, 1817, 1840, 1863, 1886, 1909, 1932, 1955, 1978, 2001, 2024, 2047, 2070, 2093, 2116, 2139, 2162, 2185, 2208, 2231, 2254, 2277, 2300, 2323, 2346, 2369, 2392, 2415, 2438, 2461, 2484, 2507, 2530, 2553, 2576, 2599, 2622, 2645, 2668, 2691, 2714, 2737, 2760, 2783, 2806, 2829, 2852, 2875, 2898, 2921, 2944, 2967, 2990, 3013, 3036, 3059, 3082, 3105, 3128, 3151, 3174, 3197, 3220, 3243, 3266, 3289, 3312, 3335, 3358, 3381, 3404, 3427, 3450, 3473, 3496, 3519, 3542, 3565, 3588, 3611, 3634, 3657, 3680, 3703, 3726, 3749, 3772, 3795, 3818, 3841, 3864, 3887, 3910, 3933, 3956, 3979, 4002, 4025, 4048, 4071, 4094, 4117, 4140, 4163, 4186, 4209, 4232, 4255, 4278, 4301, 4324, 4347, 4370, 4393, 4416, 4439, 4462, 4485, 4508, 4531, 4554, 4577, 4600, 4623, 4646, 4669, 4692, 4715, 4738, 4761, 4784, 4807, 4830, 4853, 4876, 4899, 4922, 4945, 4968, 4991]) == 240\n assert candidate(arr = [8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 96, 108, 144, 162, 192, 216, 243, 288, 324, 384, 432, 486, 576, 648, 729, 768, 864, 972, 1152, 1296, 1458, 1728, 1944, 2187, 2304, 2592, 2916, 3456, 3888, 4374, 4608, 5184, 5832, 6561, 6912, 7776, 8748, 9216, 10368, 11664, 13122, 13824, 15552, 17496, 19683, 20736, 23328, 26244, 27648, 31104, 34992, 36450, 39366, 41472, 46656, 49152, 55296, 61440, 62208, 69984, 73728, 82944, 93312, 98304, 104976, 110592, 116640, 118098, 139968, 147456, 165888, 186624, 196608, 209952, 221184, 233280, 236196, 279936, 294912, 331776, 373248, 393216, 419904, 442368, 466560, 472392, 559872, 589824, 663552, 746496, 786432, 839808, 884736, 933120, 944784, 1039776, 1179648, 1327104, 1474560, 1568640, 1679616, 1769472, 1966080, 1989568, 2179328, 2654208, 2752512, 3133440, 3201152, 3556864, 3906240, 4014336, 4354560, 4482112, 4718592, 4839552, 5308416, 5505024, 6266880, 6402304, 6913728, 7208320, 7228672, 7837184, 8388608, 8449344, 9175040, 9612800, 9657344, 10285568, 10813440, 10898688, 11753728, 12288000, 12298752, 13136640, 13604864, 14336000, 14417408, 15422464, 16588800, 16797504, 17740800, 17783808, 18963200, 19215360, 19234816]) == 917736\n assert candidate(arr = [13, 130, 169, 260, 338, 520, 676, 1040, 1352, 2080, 2704, 4160, 5408, 8320, 10816]) == 16\n assert candidate(arr = [11, 22, 44, 88, 176, 352]) == 6\n assert candidate(arr = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190]) == 10\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330, 341, 352, 363, 374, 385, 396, 407, 418, 429, 440, 451, 462, 473, 484, 495, 506, 517, 528, 539, 550, 561, 572, 583, 594, 605, 616, 627, 638, 649, 660, 671, 682, 693, 704, 715, 726, 737, 748, 759, 770, 781, 792, 803, 814, 825, 836, 847, 858, 869, 880, 891, 902, 913, 924, 935, 946, 957, 968, 979, 990, 1001]) == 111\n assert candidate(arr = [2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 30, 36, 40, 45, 48, 50, 60, 72, 75, 80, 90, 100]) == 1298\n assert candidate(arr = [2, 3, 6, 9, 18]) == 18\n assert candidate(arr = [10, 14, 20, 28, 35, 40, 70, 140]) == 10\n assert candidate(arr = [7, 11, 13, 14, 15, 21, 22, 26, 33, 35, 39, 70, 77, 105, 143, 154, 182, 210, 231, 286, 385, 429, 715, 1001, 1430, 2002]) == 110\n assert candidate(arr = [5, 10, 20, 50, 100, 200]) == 13\n assert candidate(arr = [2, 3, 6, 9, 18]) == 18\n assert candidate(arr = [2, 5, 10, 25, 50, 125, 250, 625, 1250, 3125, 6250]) == 1202\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == 20\n assert candidate(arr = [3, 5, 15, 25, 75, 125, 375, 625, 1875, 3125, 9375, 15625, 46875, 78125, 234375, 390625, 1171875, 1953125]) == 126293\n assert candidate(arr = [2, 10, 100, 1000, 10000]) == 24\n assert candidate(arr = [2, 5, 10, 20, 50, 100, 250, 500]) == 221\n assert candidate(arr = [5, 10, 25, 50, 125, 250]) == 23\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256]) == 3943\n assert candidate(arr = [10, 14, 20, 28, 35, 40, 49, 70, 100, 140, 175, 200, 245, 490, 700, 980, 1400, 2450, 4900]) == 83\n assert candidate(arr = [2, 3, 5, 6, 10, 15, 30]) == 31\n assert candidate(arr = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 21\n assert candidate(arr = [5, 10, 20, 25, 50, 100, 250, 500]) == 42\n assert candidate(arr = [7, 11, 13, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 22\n assert candidate(arr = [18, 2, 9, 12, 6, 3]) == 25\n assert candidate(arr = [18, 36, 54, 72, 90, 108, 126, 144, 162, 180]) == 10\n assert candidate(arr = [2, 3, 6, 9, 18, 27, 54]) == 68\n assert candidate(arr = [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]) == 46\n assert candidate(arr = [11, 121, 1331, 14641, 161051]) == 74\n assert candidate(arr = [3, 5, 7, 15, 21, 35, 105]) == 31\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704, 1408, 2816]) == 9\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 10\n assert candidate(arr = [2, 5, 10, 20, 40, 80, 160]) == 121\n assert candidate(arr = [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]) == 31\n assert candidate(arr = [2, 5, 10, 25, 50, 125, 250]) == 68\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1500, 1600, 1800, 2000, 2100, 2400, 2500, 2700, 2800, 3000, 3100, 3500, 4000, 4200, 4500, 5000, 5200, 5400, 6000, 6300, 6500, 7000, 7500, 8000, 8400, 9000, 9100, 9500, 10000]) == 42\n assert candidate(arr = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 11\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 47166081\n assert candidate(arr = [11, 13, 143, 157, 1853, 1729, 1943, 22187, 24539, 25397, 30167, 31721, 35981, 42361, 45343, 52943, 56171]) == 19\n assert candidate(arr = [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]) == 60\n assert candidate(arr = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195]) == 16\n assert candidate(arr = [2, 5, 7, 10, 14, 17, 35, 70]) == 32\n assert candidate(arr = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 68000\n assert candidate(arr = [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, 589, 608, 627, 646, 665, 684, 703, 722, 741, 760, 779, 798, 817, 836, 855, 874, 893, 912, 931, 950, 969, 988, 1007, 1026, 1045, 1064, 1083, 1102, 1121, 1140, 1159, 1178, 1197, 1216, 1235, 1254, 1273, 1292, 1311, 1330, 1349, 1368, 1387, 1406, 1425, 1444, 1463, 1482, 1501, 1520, 1539, 1558, 1577, 1596, 1615, 1634, 1653, 1672, 1691, 1710, 1729, 1748, 1767, 1786, 1805, 1824, 1843, 1862, 1881, 1900, 1919, 1938, 1957, 1976, 1995, 2014]) == 116\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 800, 900, 1000, 1200, 1500, 1800, 2000, 2400, 2500, 3000, 3600, 4000, 4500, 5000]) == 20\n assert candidate(arr = [3, 9, 27, 81, 243, 729]) == 262\n assert candidate(arr = [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, 442, 459, 476, 493, 510, 527, 544, 561, 578, 595, 612, 629, 646, 663, 680, 697, 714, 731, 748, 765, 782, 799, 816, 833, 850, 867, 884, 901, 918, 935, 952, 969, 986, 1003, 1020, 1037, 1054, 1071, 1088, 1105]) == 70\n assert candidate(arr = [5, 10, 20, 40, 80, 160]) == 6\n assert candidate(arr = [6, 10, 15, 30, 50, 75, 150, 250, 375, 750, 1250, 1875, 3750, 9375, 18750, 28125, 37500, 46875, 56250, 93750, 112500]) == 181\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368, 391, 414, 437, 460, 483, 506, 529, 552, 575, 598, 621, 644, 667, 690, 713, 736, 759, 782, 805, 828, 851, 874, 897, 920, 943, 966, 989]) == 44\n assert candidate(arr = [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600]) == 9\n assert candidate(arr = [2, 3, 5, 7, 10, 14, 15, 21, 22, 30, 35, 42, 70, 77, 105, 110, 140, 154, 165, 210, 231, 385, 462, 550, 770, 1001, 1155, 1540, 2310, 3003, 3850, 5005, 6930, 10010, 11550, 15015, 21021, 30030, 50050, 100100]) == 3630\n assert candidate(arr = [5, 10, 15, 25, 50, 75, 125, 250]) == 27\n assert candidate(arr = [2, 3, 6, 18, 36]) == 36\n assert candidate(arr = [7, 14, 28, 49, 98, 196]) == 12\n assert candidate(arr = [3, 6, 9, 12, 18, 27, 36, 54, 72, 108, 162, 216, 324, 486, 648]) == 516\n", "comparison": "exact"}, "public_tests": ["[2,4]", "[2,4,5,10]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().numFactoredBinaryTrees", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:55+00:00", "tests_total": 105, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "hash-table", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numFactoredBinaryTrees(self, arr: list[int]) -> int:", "container": "Solution", "callable": "numFactoredBinaryTrees", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 824, "task_id": "goat-latin", "difficulty": "Easy", "problem_description": "You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only.\n\nWe would like to convert the sentence to \"Goat Latin\" (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:\n\n- If a word begins with a vowel ('a', 'e', 'i', 'o', or 'u'), append \"ma\" to the end of the word.\n - For example, the word \"apple\" becomes \"applema\".\n- If a word begins with a consonant (i.e., not a vowel), remove the first letter and append it to the end, then add \"ma\".\n - For example, the word \"goat\" becomes \"oatgma\".\n- Add one letter 'a' to the end of each word per its word index in the sentence, starting with 1.\n - For example, the first word gets \"a\" added to the end, the second word gets \"aa\" added to the end, and so on.\n\nReturn the final sentence representing the conversion from sentence to Goat Latin.\n\nExample 1:\n\nInput: sentence = \"I speak Goat Latin\"\nOutput: \"Imaa peaksmaaa oatGmaaaa atinLmaaaaa\"\n\nExample 2:\n\nInput: sentence = \"The quick brown fox jumped over the lazy dog\"\nOutput: \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\"\n\nConstraints:\n\n- 1 <= sentence.length <= 150\n- sentence consists of English letters and spaces.\n- sentence has no leading or trailing spaces.\n- All the words in sentence are separated by a single space.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"Convert this sentence\") == \"onvertCmaa histmaaa entencesmaaaa\"\n assert candidate(sentence = \"In the end\") == \"Inmaa hetmaaa endmaaaa\"\n assert candidate(sentence = \"a e i o u\") == \"amaa emaaa imaaaa omaaaaa umaaaaaa\"\n assert candidate(sentence = \"Hello world\") == \"elloHmaa orldwmaaa\"\n assert candidate(sentence = \"Python is great\") == \"ythonPmaa ismaaa reatgmaaaa\"\n assert candidate(sentence = \"This is a test\") == \"hisTmaa ismaaa amaaaa esttmaaaaa\"\n assert candidate(sentence = \"Hello World\") == \"elloHmaa orldWmaaa\"\n assert candidate(sentence = \"Goat Latin Example\") == \"oatGmaa atinLmaaa Examplemaaaa\"\n assert candidate(sentence = \"Convert this sentence to Goat Latin\") == \"onvertCmaa histmaaa entencesmaaaa otmaaaaa oatGmaaaaaa atinLmaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumped over the lazy dog\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\"\n assert candidate(sentence = \"Programming is fun\") == \"rogrammingPmaa ismaaa unfmaaaa\"\n assert candidate(sentence = \"Every vowel example\") == \"Everymaa owelvmaaa examplemaaaa\"\n assert candidate(sentence = \"hello world\") == \"ellohmaa orldwmaaa\"\n assert candidate(sentence = \"Goat Latin is easy\") == \"oatGmaa atinLmaaa ismaaaa easymaaaaa\"\n assert candidate(sentence = \"Keep practicing\") == \"eepKmaa racticingpmaaa\"\n assert candidate(sentence = \"Conversion to Goat Latin\") == \"onversionCmaa otmaaa oatGmaaaa atinLmaaaaa\"\n assert candidate(sentence = \"I speak Goat Latin\") == \"Imaa peaksmaaa oatGmaaaa atinLmaaaaa\"\n assert candidate(sentence = \"Every word matters\") == \"Everymaa ordwmaaa attersmmaaaa\"\n assert candidate(sentence = \"ChatGPT is an AI language model\") == \"hatGPTCmaa ismaaa anmaaaa AImaaaaa anguagelmaaaaaa odelmmaaaaaaa\"\n assert candidate(sentence = \"A big brown dog jumps over a lazy fox\") == \"Amaa igbmaaa rownbmaaaa ogdmaaaaa umpsjmaaaaaa overmaaaaaaa amaaaaaaaa azylmaaaaaaaaa oxfmaaaaaaaaaa\"\n assert candidate(sentence = \"Quick brown fox jumps over the lazy dog\") == \"uickQmaa rownbmaaa oxfmaaaa umpsjmaaaaa overmaaaaaa hetmaaaaaaa azylmaaaaaaaa ogdmaaaaaaaaa\"\n assert candidate(sentence = \"Frogs jump joyfully in the rain\") == \"rogsFmaa umpjmaaa oyfullyjmaaaa inmaaaaa hetmaaaaaa ainrmaaaaaaa\"\n assert candidate(sentence = \"Conversion to Goat Latin should handle complex sentences properly\") == \"onversionCmaa otmaaa oatGmaaaa atinLmaaaaa houldsmaaaaaa andlehmaaaaaaa omplexcmaaaaaaaa entencessmaaaaaaaaa roperlypmaaaaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumps over the lazy dog and runs\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa andmaaaaaaaaaaa unsrmaaaaaaaaaaaa\"\n assert candidate(sentence = \"User experience design and usability\") == \"Usermaa experiencemaaa esigndmaaaa andmaaaaa usabilitymaaaaaa\"\n assert candidate(sentence = \"This is an interesting problem to solve\") == \"hisTmaa ismaaa anmaaaa interestingmaaaaa roblempmaaaaaa otmaaaaaaa olvesmaaaaaaaa\"\n assert candidate(sentence = \"A quick brown fox jumps over the lazy dog\") == \"Amaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\"\n assert candidate(sentence = \"This is a simple test case for Goat Latin\") == \"hisTmaa ismaaa amaaaa implesmaaaaa esttmaaaaaa asecmaaaaaaa orfmaaaaaaaa oatGmaaaaaaaaa atinLmaaaaaaaaaa\"\n assert candidate(sentence = \"Another Example to demonstrate the Conversion\") == \"Anothermaa Examplemaaa otmaaaa emonstratedmaaaaa hetmaaaaaa onversionCmaaaaaaa\"\n assert candidate(sentence = \"Let us create more examples for testing\") == \"etLmaa usmaaa reatecmaaaa oremmaaaaa examplesmaaaaaa orfmaaaaaaa estingtmaaaaaaaa\"\n assert candidate(sentence = \"a e i o u A E I O U\") == \"amaa emaaa imaaaa omaaaaa umaaaaaa Amaaaaaaa Emaaaaaaaa Imaaaaaaaaa Omaaaaaaaaaa Umaaaaaaaaaaa\"\n assert candidate(sentence = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\") == \"oremLmaa ipsummaaa olordmaaaa itsmaaaaa ametmaaaaaa onsecteturcmaaaaaaa adipiscingmaaaaaaaa elitmaaaaaaaaa\"\n assert candidate(sentence = \"Every vowel and consonant has its own rule\") == \"Everymaa owelvmaaa andmaaaa onsonantcmaaaaa ashmaaaaaa itsmaaaaaaa ownmaaaaaaaa ulermaaaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumps over the lazy dog and plays\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa andmaaaaaaaaaaa layspmaaaaaaaaaaaa\"\n assert candidate(sentence = \"Sphinx of black quartz judge my vow\") == \"phinxSmaa ofmaaa lackbmaaaa uartzqmaaaaa udgejmaaaaaa ymmaaaaaaa owvmaaaaaaaa\"\n assert candidate(sentence = \"Artificial intelligence is transforming the world\") == \"Artificialmaa intelligencemaaa ismaaaa ransformingtmaaaaa hetmaaaaaa orldwmaaaaaaa\"\n assert candidate(sentence = \"Gnomes gather golden grains gracefully gathering groups\") == \"nomesGmaa athergmaaa oldengmaaaa rainsgmaaaaa racefullygmaaaaaa atheringgmaaaaaaa roupsgmaaaaaaaa\"\n assert candidate(sentence = \"Natural language processing is revolutionizing technology\") == \"aturalNmaa anguagelmaaa rocessingpmaaaa ismaaaaa evolutionizingrmaaaaaa echnologytmaaaaaaa\"\n assert candidate(sentence = \"Python programming is fun\") == \"ythonPmaa rogrammingpmaaa ismaaaa unfmaaaaa\"\n assert candidate(sentence = \"The weather today is absolutely perfect\") == \"heTmaa eatherwmaaa odaytmaaaa ismaaaaa absolutelymaaaaaa erfectpmaaaaaaa\"\n assert candidate(sentence = \"Let us see how this conversion works\") == \"etLmaa usmaaa eesmaaaa owhmaaaaa histmaaaaaa onversioncmaaaaaaa orkswmaaaaaaaa\"\n assert candidate(sentence = \"Internet of Things and smart devices\") == \"Internetmaa ofmaaa hingsTmaaaa andmaaaaa martsmaaaaaa evicesdmaaaaaaa\"\n assert candidate(sentence = \"OpenAI develops advanced AI systems\") == \"OpenAImaa evelopsdmaaa advancedmaaaa AImaaaaa ystemssmaaaaaa\"\n assert candidate(sentence = \"Edge cases exercise existing expertise effectively\") == \"Edgemaa asescmaaa exercisemaaaa existingmaaaaa expertisemaaaaaa effectivelymaaaaaaa\"\n assert candidate(sentence = \"Zoologists zealously zoom into zoological zoological zones\") == \"oologistsZmaa ealouslyzmaaa oomzmaaaa intomaaaaa oologicalzmaaaaaa oologicalzmaaaaaaa oneszmaaaaaaaa\"\n assert candidate(sentence = \"Beautiful scenery and wonderful views\") == \"eautifulBmaa cenerysmaaa andmaaaa onderfulwmaaaaa iewsvmaaaaaa\"\n assert candidate(sentence = \"Mixed CASE Words Should Still Work\") == \"ixedMmaa ASECmaaa ordsWmaaaa houldSmaaaaa tillSmaaaaaa orkWmaaaaaaa\"\n assert candidate(sentence = \"Every vowel and consonant has a unique rule\") == \"Everymaa owelvmaaa andmaaaa onsonantcmaaaaa ashmaaaaaa amaaaaaaa uniquemaaaaaaaa ulermaaaaaaaaa\"\n assert candidate(sentence = \"Artificial intelligence will change our lives\") == \"Artificialmaa intelligencemaaa illwmaaaa hangecmaaaaa ourmaaaaaa iveslmaaaaaaa\"\n assert candidate(sentence = \"Testing edge cases like empty spaces in between words\") == \"estingTmaa edgemaaa asescmaaaa ikelmaaaaa emptymaaaaaa pacessmaaaaaaa inmaaaaaaaa etweenbmaaaaaaaaa ordswmaaaaaaaaaa\"\n assert candidate(sentence = \"Programming in Python is fun and challenging\") == \"rogrammingPmaa inmaaa ythonPmaaaa ismaaaaa unfmaaaaaa andmaaaaaaa hallengingcmaaaaaaaa\"\n assert candidate(sentence = \"This is a longer sentence that includes several words to ensure the solution works correctly\") == \"hisTmaa ismaaa amaaaa ongerlmaaaaa entencesmaaaaaa hattmaaaaaaa includesmaaaaaaaa everalsmaaaaaaaaa ordswmaaaaaaaaaa otmaaaaaaaaaaa ensuremaaaaaaaaaaaa hetmaaaaaaaaaaaaa olutionsmaaaaaaaaaaaaaa orkswmaaaaaaaaaaaaaaa orrectlycmaaaaaaaaaaaaaaaa\"\n assert candidate(sentence = \"This is a simple test\") == \"hisTmaa ismaaa amaaaa implesmaaaaa esttmaaaaaa\"\n assert candidate(sentence = \"Conversion to Goat Latin can be tricky\") == \"onversionCmaa otmaaa oatGmaaaa atinLmaaaaa ancmaaaaaa ebmaaaaaaa rickytmaaaaaaaa\"\n assert candidate(sentence = \"Complex sentences with various words\") == \"omplexCmaa entencessmaaa ithwmaaaa ariousvmaaaaa ordswmaaaaaa\"\n assert candidate(sentence = \"Understanding algorithms and data structures\") == \"Understandingmaa algorithmsmaaa andmaaaa atadmaaaaa tructuressmaaaaaa\"\n assert candidate(sentence = \"Goat Latin is a fun and creative language\") == \"oatGmaa atinLmaaa ismaaaa amaaaaa unfmaaaaaa andmaaaaaaa reativecmaaaaaaaa anguagelmaaaaaaaaa\"\n assert candidate(sentence = \"Consonants should move their first letter to the end\") == \"onsonantsCmaa houldsmaaa ovemmaaaa heirtmaaaaa irstfmaaaaaa etterlmaaaaaaa otmaaaaaaaa hetmaaaaaaaaa endmaaaaaaaaaa\"\n assert candidate(sentence = \"Fascinating flora frequently feed furry friends\") == \"ascinatingFmaa lorafmaaa requentlyfmaaaa eedfmaaaaa urryfmaaaaaa riendsfmaaaaaaa\"\n assert candidate(sentence = \"Keep pushing your limits and you will achieve great things\") == \"eepKmaa ushingpmaaa ourymaaaa imitslmaaaaa andmaaaaaa ouymaaaaaaa illwmaaaaaaaa achievemaaaaaaaaa reatgmaaaaaaaaaa hingstmaaaaaaaaaaa\"\n assert candidate(sentence = \"Software engineering principles\") == \"oftwareSmaa engineeringmaaa rinciplespmaaaa\"\n assert candidate(sentence = \"Every vowel must be handled\") == \"Everymaa owelvmaaa ustmmaaaa ebmaaaaa andledhmaaaaaa\"\n assert candidate(sentence = \"Testing multiple words with varied starting letters\") == \"estingTmaa ultiplemmaaa ordswmaaaa ithwmaaaaa ariedvmaaaaaa tartingsmaaaaaaa etterslmaaaaaaaa\"\n assert candidate(sentence = \"Beautiful butterflies brightly bask in blazing sunshine\") == \"eautifulBmaa utterfliesbmaaa rightlybmaaaa askbmaaaaa inmaaaaaa lazingbmaaaaaaa unshinesmaaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumps over the lazy dog on a sunny day\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa onmaaaaaaaaaaa amaaaaaaaaaaaa unnysmaaaaaaaaaaaaa aydmaaaaaaaaaaaaaa\"\n assert candidate(sentence = \"Machine learning is transforming the world\") == \"achineMmaa earninglmaaa ismaaaa ransformingtmaaaaa hetmaaaaaa orldwmaaaaaaa\"\n assert candidate(sentence = \"b c d f g h j k l m n p q r s t v w x y z B C D F G H J K L M N P Q R S T V W X Y Z\") == \"bmaa cmaaa dmaaaa fmaaaaa gmaaaaaa hmaaaaaaa jmaaaaaaaa kmaaaaaaaaa lmaaaaaaaaaa mmaaaaaaaaaaa nmaaaaaaaaaaaa pmaaaaaaaaaaaaa qmaaaaaaaaaaaaaa rmaaaaaaaaaaaaaaa smaaaaaaaaaaaaaaaa tmaaaaaaaaaaaaaaaaa vmaaaaaaaaaaaaaaaaaa wmaaaaaaaaaaaaaaaaaaa xmaaaaaaaaaaaaaaaaaaaa ymaaaaaaaaaaaaaaaaaaaaa zmaaaaaaaaaaaaaaaaaaaaaa Bmaaaaaaaaaaaaaaaaaaaaaaa Cmaaaaaaaaaaaaaaaaaaaaaaaa Dmaaaaaaaaaaaaaaaaaaaaaaaaa Fmaaaaaaaaaaaaaaaaaaaaaaaaaa Gmaaaaaaaaaaaaaaaaaaaaaaaaaaa Hmaaaaaaaaaaaaaaaaaaaaaaaaaaaa Jmaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Kmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Lmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Mmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Nmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Pmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Rmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Smaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Tmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Vmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Wmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Xmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Ymaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Zmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(sentence = \"Bright vixens jump over the lazy dog\") == \"rightBmaa ixensvmaaa umpjmaaaa overmaaaaa hetmaaaaaa azylmaaaaaaa ogdmaaaaaaaa\"\n assert candidate(sentence = \"Hello world this is a test sentence\") == \"elloHmaa orldwmaaa histmaaaa ismaaaaa amaaaaaa esttmaaaaaaa entencesmaaaaaaaa\"\n assert candidate(sentence = \"Natural language processing and chatbots\") == \"aturalNmaa anguagelmaaa rocessingpmaaaa andmaaaaa hatbotscmaaaaaa\"\n assert candidate(sentence = \"Lazy dogs jump over sleeping cats\") == \"azyLmaa ogsdmaaa umpjmaaaa overmaaaaa leepingsmaaaaaa atscmaaaaaaa\"\n assert candidate(sentence = \"Computer vision and image processing\") == \"omputerCmaa isionvmaaa andmaaaa imagemaaaaa rocessingpmaaaaaa\"\n assert candidate(sentence = \"Every vowel should remain unchanged ma\") == \"Everymaa owelvmaaa houldsmaaaa emainrmaaaaa unchangedmaaaaaa ammaaaaaaa\"\n assert candidate(sentence = \"The five boxing wizards jump quickly\") == \"heTmaa ivefmaaa oxingbmaaaa izardswmaaaaa umpjmaaaaaa uicklyqmaaaaaaa\"\n assert candidate(sentence = \"Blockchain technology and cryptography\") == \"lockchainBmaa echnologytmaaa andmaaaa ryptographycmaaaaa\"\n assert candidate(sentence = \"Debugging code can be challenging\") == \"ebuggingDmaa odecmaaa ancmaaaa ebmaaaaa hallengingcmaaaaaa\"\n assert candidate(sentence = \"Python Programming Language is Fun\") == \"ythonPmaa rogrammingPmaaa anguageLmaaaa ismaaaaa unFmaaaaaa\"\n assert candidate(sentence = \"Algorithm design and analysis\") == \"Algorithmmaa esigndmaaa andmaaaa analysismaaaaa\"\n assert candidate(sentence = \"Alphabet University of Economics and Business Administration\") == \"Alphabetmaa Universitymaaa ofmaaaa Economicsmaaaaa andmaaaaaa usinessBmaaaaaaa Administrationmaaaaaaaa\"\n assert candidate(sentence = \"Continuous integration and deployment\") == \"ontinuousCmaa integrationmaaa andmaaaa eploymentdmaaaaa\"\n assert candidate(sentence = \"Beautiful scenery in nature\") == \"eautifulBmaa cenerysmaaa inmaaaa aturenmaaaaa\"\n assert candidate(sentence = \"Machine learning models are fascinating\") == \"achineMmaa earninglmaaa odelsmmaaaa aremaaaaa ascinatingfmaaaaaa\"\n assert candidate(sentence = \"Jackdaws love my big sphinx of quartz\") == \"ackdawsJmaa ovelmaaa ymmaaaa igbmaaaaa phinxsmaaaaaa ofmaaaaaaa uartzqmaaaaaaaa\"\n assert candidate(sentence = \"The brown fox jumps over a lazy dog\") == \"heTmaa rownbmaaa oxfmaaaa umpsjmaaaaa overmaaaaaa amaaaaaaa azylmaaaaaaaa ogdmaaaaaaaaa\"\n assert candidate(sentence = \"Python programming promotes productivity and problem solving\") == \"ythonPmaa rogrammingpmaaa romotespmaaaa roductivitypmaaaaa andmaaaaaa roblempmaaaaaaa olvingsmaaaaaaaa\"\n assert candidate(sentence = \"High performance computing and big data\") == \"ighHmaa erformancepmaaa omputingcmaaaa andmaaaaa igbmaaaaaa atadmaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumps over the lazy dog quickly\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa uicklyqmaaaaaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumps over the lazy dog\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\"\n assert candidate(sentence = \"Data analysis and machine learning\") == \"ataDmaa analysismaaa andmaaaa achinemmaaaaa earninglmaaaaaa\"\n assert candidate(sentence = \"ComplexSentencesWithNoSpaces\") == \"omplexSentencesWithNoSpacesCmaa\"\n assert candidate(sentence = \"Understanding complex algorithms unravelles endless possibilities\") == \"Understandingmaa omplexcmaaa algorithmsmaaaa unravellesmaaaaa endlessmaaaaaa ossibilitiespmaaaaaaa\"\n assert candidate(sentence = \"Watch Jeopardy on NBC\") == \"atchWmaa eopardyJmaaa onmaaaa BCNmaaaaa\"\n assert candidate(sentence = \"Artificial neural networks and deep learning\") == \"Artificialmaa euralnmaaa etworksnmaaaa andmaaaaa eepdmaaaaaa earninglmaaaaaaa\"\n assert candidate(sentence = \"Data structures and algorithms\") == \"ataDmaa tructuressmaaa andmaaaa algorithmsmaaaaa\"\n assert candidate(sentence = \"Algorithms are crucial for computer science\") == \"Algorithmsmaa aremaaa rucialcmaaaa orfmaaaaa omputercmaaaaaa ciencesmaaaaaaa\"\n assert candidate(sentence = \"Consonants should also be tested\") == \"onsonantsCmaa houldsmaaa alsomaaaa ebmaaaaa estedtmaaaaaa\"\n assert candidate(sentence = \"She sells sea shells by the sea shore\") == \"heSmaa ellssmaaa easmaaaa hellssmaaaaa ybmaaaaaa hetmaaaaaaa easmaaaaaaaa horesmaaaaaaaaa\"\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzmaa\"\n assert candidate(sentence = \"A big black bear sat on a big black rug\") == \"Amaa igbmaaa lackbmaaaa earbmaaaaa atsmaaaaaa onmaaaaaaa amaaaaaaaa igbmaaaaaaaaa lackbmaaaaaaaaaa ugrmaaaaaaaaaaa\"\n assert candidate(sentence = \"Multiple words starting with a consonant\") == \"ultipleMmaa ordswmaaa tartingsmaaaa ithwmaaaaa amaaaaaa onsonantcmaaaaaaa\"\n assert candidate(sentence = \"How vexingly quick daft zebras jump\") == \"owHmaa exinglyvmaaa uickqmaaaa aftdmaaaaa ebraszmaaaaaa umpjmaaaaaaa\"\n assert candidate(sentence = \"SingleWord\") == \"ingleWordSmaa\"\n assert candidate(sentence = \"An example of a more complex sentence conversion\") == \"Anmaa examplemaaa ofmaaaa amaaaaa oremmaaaaaa omplexcmaaaaaaa entencesmaaaaaaaa onversioncmaaaaaaaaa\"\n assert candidate(sentence = \"Transformations are always fascinating\") == \"ransformationsTmaa aremaaa alwaysmaaaa ascinatingfmaaaaa\"\n assert candidate(sentence = \"Single\") == \"ingleSmaa\"\n assert candidate(sentence = \"bc df gh jk lm np qr st vx zy\") == \"cbmaa fdmaaa hgmaaaa kjmaaaaa mlmaaaaaa pnmaaaaaaa rqmaaaaaaaa tsmaaaaaaaaa xvmaaaaaaaaaa yzmaaaaaaaaaaa\"\n assert candidate(sentence = \"Algorithms and data structures\") == \"Algorithmsmaa andmaaa atadmaaaa tructuressmaaaaa\"\n assert candidate(sentence = \"Sometimes it rains cats and dogs\") == \"ometimesSmaa itmaaa ainsrmaaaa atscmaaaaa andmaaaaaa ogsdmaaaaaaa\"\n assert candidate(sentence = \"Understanding the rules of Goat Latin\") == \"Understandingmaa hetmaaa ulesrmaaaa ofmaaaaa oatGmaaaaaa atinLmaaaaaaa\"\n assert candidate(sentence = \"This is an elaborate test case with multiple words\") == \"hisTmaa ismaaa anmaaaa elaboratemaaaaa esttmaaaaaa asecmaaaaaaa ithwmaaaaaaaa ultiplemmaaaaaaaaa ordswmaaaaaaaaaa\"\n assert candidate(sentence = \"The early morning dew dries\") == \"heTmaa earlymaaa orningmmaaaa ewdmaaaaa riesdmaaaaaa\"\n assert candidate(sentence = \"Short long longer longest longestest\") == \"hortSmaa onglmaaa ongerlmaaaa ongestlmaaaaa ongestestlmaaaaaa\"\n assert candidate(sentence = \"Quantum computing and future technologies\") == \"uantumQmaa omputingcmaaa andmaaaa uturefmaaaaa echnologiestmaaaaaa\"\n assert candidate(sentence = \"The five boxing wizards jump quickly on this extraordinary bicycle\") == \"heTmaa ivefmaaa oxingbmaaaa izardswmaaaaa umpjmaaaaaa uicklyqmaaaaaaa onmaaaaaaaa histmaaaaaaaaa extraordinarymaaaaaaaaaa icyclebmaaaaaaaaaaa\"\n assert candidate(sentence = \"Python programming is fun and educational\") == \"ythonPmaa rogrammingpmaaa ismaaaa unfmaaaaa andmaaaaaa educationalmaaaaaaa\"\n assert candidate(sentence = \"Multiple words starting with a vowel\") == \"ultipleMmaa ordswmaaa tartingsmaaaa ithwmaaaaa amaaaaaa owelvmaaaaaaa\"\n assert candidate(sentence = \"Fuzzy wuzzy was a bear\") == \"uzzyFmaa uzzywmaaa aswmaaaa amaaaaa earbmaaaaaa\"\n assert candidate(sentence = \"Cloud computing and artificial intelligence\") == \"loudCmaa omputingcmaaa andmaaaa artificialmaaaaa intelligencemaaaaaa\"\n assert candidate(sentence = \"AEIOU aeiou UUIIOOAAEE\") == \"AEIOUmaa aeioumaaa UUIIOOAAEEmaaaa\"\n assert candidate(sentence = \"Multiple words with different starting letters\") == \"ultipleMmaa ordswmaaa ithwmaaaa ifferentdmaaaaa tartingsmaaaaaa etterslmaaaaaaa\"\n assert candidate(sentence = \"The quick brown fox jumps over the lazy dog several times\") == \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa everalsmaaaaaaaaaaa imestmaaaaaaaaaaaa\"\n assert candidate(sentence = \"Xylophones yield xylophonic xenon xylophonically\") == \"ylophonesXmaa ieldymaaa ylophonicxmaaaa enonxmaaaaa ylophonicallyxmaaaaaa\"\n assert candidate(sentence = \"Open source software development\") == \"Openmaa ourcesmaaa oftwaresmaaaa evelopmentdmaaaaa\"\n assert candidate(sentence = \"A rapid brown fox jumps over the lazy dog\") == \"Amaa apidrmaaa rownbmaaaa oxfmaaaaa umpsjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\"\n assert candidate(sentence = \"Quickly zigzagging through the dense forest\") == \"uicklyQmaa igzaggingzmaaa hroughtmaaaa hetmaaaaa ensedmaaaaaa orestfmaaaaaaa\"\n assert candidate(sentence = \"Programming in Python is fun\") == \"rogrammingPmaa inmaaa ythonPmaaaa ismaaaaa unfmaaaaaa\"\n assert candidate(sentence = \"An elephant and an antelope\") == \"Anmaa elephantmaaa andmaaaa anmaaaaa antelopemaaaaaa\"\n assert candidate(sentence = \"This is an exceptionally long sentence to test the robustness of the solution\") == \"hisTmaa ismaaa anmaaaa exceptionallymaaaaa onglmaaaaaa entencesmaaaaaaa otmaaaaaaaa esttmaaaaaaaaa hetmaaaaaaaaaa obustnessrmaaaaaaaaaaa ofmaaaaaaaaaaaa hetmaaaaaaaaaaaaa olutionsmaaaaaaaaaaaaaa\"\n assert candidate(sentence = \"An exquisite oriental fan\") == \"Anmaa exquisitemaaa orientalmaaaa anfmaaaaa\"\n assert candidate(sentence = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"ABCDEFGHIJKLMNOPQRSTUVWXYZmaa\"\n assert candidate(sentence = \"Virtual reality and augmented reality\") == \"irtualVmaa ealityrmaaa andmaaaa augmentedmaaaaa ealityrmaaaaaa\"\n assert candidate(sentence = \"Every vowel should be handled properly\") == \"Everymaa owelvmaaa houldsmaaaa ebmaaaaa andledhmaaaaaa roperlypmaaaaaaa\"\n assert candidate(sentence = \"A quick movement of the enemy will jeopardize five gunboats\") == \"Amaa uickqmaaa ovementmmaaaa ofmaaaaa hetmaaaaaa enemymaaaaaaa illwmaaaaaaaa eopardizejmaaaaaaaaa ivefmaaaaaaaaaa unboatsgmaaaaaaaaaaa\"\n assert candidate(sentence = \"Beautiful butterflies brightly bask in blazing sun\") == \"eautifulBmaa utterfliesbmaaa rightlybmaaaa askbmaaaaa inmaaaaaa lazingbmaaaaaaa unsmaaaaaaaa\"\n assert candidate(sentence = \"This is a test of the Goat Latin conversion tool\") == \"hisTmaa ismaaa amaaaa esttmaaaaa ofmaaaaaa hetmaaaaaaa oatGmaaaaaaaa atinLmaaaaaaaaa onversioncmaaaaaaaaaa ooltmaaaaaaaaaaa\"\n", "comparison": "exact"}, "public_tests": ["\"I speak Goat Latin\"", "\"The quick brown fox jumped over the lazy dog\""], "hints": [], "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().toGoatLatin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:57+00:00", "tests_total": 135, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def toGoatLatin(self, sentence: str) -> str:", "container": "Solution", "callable": "toGoatLatin", "parameters": [{"name": "sentence", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 825, "task_id": "friends-of-appropriate-ages", "difficulty": "Medium", "problem_description": "There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the i^th person.\n\nA Person x will not send a friend request to a person y (x != y) if any of the following conditions is true:\n\n- age[y] <= 0.5 * age[x] + 7\n- age[y] > age[x]\n- age[y] > 100 && age[x] < 100\n\nOtherwise, x will send a friend request to y.\n\nNote that if x sends a request to y, y will not necessarily send a request to x. Also, a person will not send a friend request to themself.\n\nReturn the total number of friend requests made.\n\nExample 1:\n\nInput: ages = [16,16]\nOutput: 2\nExplanation: 2 people friend request each other.\n\nExample 2:\n\nInput: ages = [16,17,18]\nOutput: 2\nExplanation: Friend requests are made 17 -> 16, 18 -> 17.\n\nExample 3:\n\nInput: ages = [20,30,100,110,120]\nOutput: 3\nExplanation: Friend requests are made 110 -> 100, 120 -> 110, 120 -> 100.\n\nConstraints:\n\n- n == ages.length\n- 1 <= n <= 2 * 10^4\n- 1 <= ages[i] <= 120\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ages = [120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110]) == 55\n assert candidate(ages = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 90\n assert candidate(ages = [18, 18, 18, 18, 18, 18, 18, 18, 18, 18]) == 90\n assert candidate(ages = [15, 15, 15, 15, 15]) == 20\n assert candidate(ages = [20, 20, 21, 22, 23, 24, 25]) == 22\n assert candidate(ages = [1, 2, 3, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110]) == 55\n assert candidate(ages = [15, 15, 15, 15]) == 12\n assert candidate(ages = [16, 17, 18, 19, 20]) == 6\n assert candidate(ages = [20, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 220\n assert candidate(ages = [15, 15, 15, 16, 17]) == 7\n assert candidate(ages = [120, 119, 118, 117, 116, 115, 114, 113, 112, 111]) == 45\n assert candidate(ages = [120, 119, 118, 117, 116]) == 10\n assert candidate(ages = [15, 16, 15, 17, 18]) == 4\n assert candidate(ages = [1, 120, 1, 120, 1, 120, 1, 120, 1, 120]) == 20\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 25\n assert candidate(ages = [16, 16]) == 2\n assert candidate(ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(ages = [16, 16, 16, 16, 16, 16, 16]) == 42\n assert candidate(ages = [16, 32, 48, 64, 80, 96, 112]) == 9\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 16\n assert candidate(ages = [15, 15, 15]) == 6\n assert candidate(ages = [100, 101, 102, 103, 104]) == 10\n assert candidate(ages = [20, 30, 100, 110, 120]) == 3\n assert candidate(ages = [101, 102, 103, 104, 105]) == 10\n assert candidate(ages = [120, 119, 118, 117, 116, 115]) == 15\n assert candidate(ages = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 90\n assert candidate(ages = [1, 2, 3, 100, 101, 102, 103, 104, 105]) == 15\n assert candidate(ages = [16, 17, 18]) == 2\n assert candidate(ages = [100, 100, 100, 100, 100]) == 20\n assert candidate(ages = [50, 50, 50, 50, 50]) == 20\n assert candidate(ages = [1, 15, 16, 17, 18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 101, 102, 105, 110, 115, 120]) == 140\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 306\n assert candidate(ages = [18, 19, 20, 21, 22, 23, 24, 25, 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]) == 303\n assert candidate(ages = [10, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111]) == 20\n assert candidate(ages = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 306\n assert candidate(ages = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 72\n assert candidate(ages = [16, 16, 17, 18, 18, 19, 20, 20, 21, 21, 22, 22]) == 43\n assert candidate(ages = [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(ages = [16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]) == 120\n assert candidate(ages = [1, 120, 2, 119, 3, 118, 4, 117, 5, 116, 6, 115, 7, 114, 8, 113, 9, 112, 10, 111, 11, 110, 12]) == 55\n assert candidate(ages = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 72\n assert candidate(ages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 72\n assert candidate(ages = [16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20]) == 84\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 2756\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 110, 111, 112, 113, 114, 115]) == 71\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 10, 20, 30, 40, 50]) == 43\n assert candidate(ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 2756\n assert candidate(ages = [15, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]) == 126\n assert candidate(ages = [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]) == 676\n assert candidate(ages = [25, 50, 75, 100, 120, 100, 75, 50, 25]) == 20\n assert candidate(ages = [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]) == 812\n assert candidate(ages = [5, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(ages = [20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 60, 60, 60, 60]) == 124\n assert candidate(ages = [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, 120]) == 702\n assert candidate(ages = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 120]) == 57\n assert candidate(ages = [18, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 144\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 120, 120, 120]) == 106\n assert candidate(ages = [18, 25, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 120, 120]) == 53\n assert candidate(ages = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 56\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 122\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]) == 210\n assert candidate(ages = [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]) == 285\n assert candidate(ages = [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 56\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 100\n assert candidate(ages = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 306\n assert candidate(ages = [16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 16, 24, 32, 40, 48, 56, 64, 72]) == 109\n assert candidate(ages = [15, 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]) == 200\n assert candidate(ages = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66]) == 136\n assert candidate(ages = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 110\n assert candidate(ages = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(ages = [120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120]) == 462\n assert candidate(ages = [75, 75, 75, 75, 80, 80, 80, 85, 85, 90, 90, 95, 95, 100, 100, 105, 105, 110, 110, 115, 115, 120, 120]) == 270\n assert candidate(ages = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == 279\n assert candidate(ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 156\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 25\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 120, 120, 120, 120, 120]) == 3046\n assert candidate(ages = [15, 15, 16, 17, 18, 19, 20, 20, 20]) == 18\n assert candidate(ages = [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]) == 1211\n assert candidate(ages = [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]) == 254\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 2756\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 99\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 56\n assert candidate(ages = [10, 12, 14, 16, 18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 73\n assert candidate(ages = [18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23]) == 64\n assert candidate(ages = [20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 42\n assert candidate(ages = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 190\n assert candidate(ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 291\n assert candidate(ages = [18, 24, 24, 30, 30, 30, 40, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 48\n assert candidate(ages = [1, 7, 14, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 1, 7, 14, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 124\n assert candidate(ages = [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]) == 465\n assert candidate(ages = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 156\n assert candidate(ages = [20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50, 60, 60, 60, 70, 70, 70]) == 90\n assert candidate(ages = [16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100]) == 110\n assert candidate(ages = [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]) == 756\n assert candidate(ages = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 156\n assert candidate(ages = [20, 20, 20, 21, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 173\n assert candidate(ages = [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]) == 326\n assert candidate(ages = [16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23]) == 80\n assert candidate(ages = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 110, 120, 110, 120, 110, 120, 110, 120, 110, 120]) == 160\n assert candidate(ages = [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]) == 2756\n assert candidate(ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 2756\n assert candidate(ages = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n", "comparison": "exact"}, "public_tests": ["[16,16]", "[16,17,18]", "[20,30,100,110,120]"], "hints": [], "metadata": {"canonical_parameter_names": ["ages"], "leetcode_dataset_entry_point": "Solution().numFriendRequests", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:59+00:00", "tests_total": 102, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numFriendRequests(self, ages: list[int]) -> int:", "container": "Solution", "callable": "numFriendRequests", "parameters": [{"name": "ages", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 826, "task_id": "most-profit-assigning-work", "difficulty": "Medium", "problem_description": "You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where:\n\n- difficulty[i] and profit[i] are the difficulty and the profit of the i^th job, and\n- worker[j] is the ability of j^th worker (i.e., the j^th worker can only complete a job with difficulty at most worker[j]).\n\nEvery worker can be assigned at most one job, but one job can be completed multiple times.\n\n- For example, if three workers attempt the same job that pays $1, then the total profit will be $3. If a worker cannot complete any job, their profit is $0.\n\nReturn the maximum profit we can achieve after assigning the workers to the jobs.\n\nExample 1:\n\nInput: difficulty = [2,4,6,8,10], profit = [10,20,30,40,50], worker = [4,5,6,7]\nOutput: 100\nExplanation: Workers are assigned jobs of difficulty [4,4,6,6] and they get a profit of [20,20,30,30] separately.\n\nExample 2:\n\nInput: difficulty = [85,47,57], profit = [24,66,99], worker = [40,25,25]\nOutput: 0\n\nConstraints:\n\n- n == difficulty.length\n- n == profit.length\n- m == worker.length\n- 1 <= n, m <= 10^4\n- 1 <= difficulty[i], profit[i], worker[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(difficulty = [68, 35, 52, 47, 86],profit = [67, 17, 17, 26, 86],worker = [68, 37, 50, 76, 33]) == 177\n assert candidate(difficulty = [10, 15, 25],profit = [100, 150, 250],worker = [20, 25, 30]) == 650\n assert candidate(difficulty = [66, 1, 28, 73, 56, 30, 96, 82, 21, 63],profit = [68, 40, 84, 84, 89, 46, 68, 105, 27, 68],worker = [40, 57, 88, 27, 11, 93, 8, 40, 20, 75]) == 716\n assert candidate(difficulty = [10, 20, 30],profit = [60, 50, 40],worker = [40, 25, 20]) == 180\n assert candidate(difficulty = [66, 1, 21, 88, 76, 13, 11, 60, 20, 35, 96, 77, 6, 46, 93],profit = [67, 68, 69, 55, 73, 60, 59, 66, 70, 58, 74, 72, 67, 68, 71],worker = [65, 91, 33, 52, 78]) == 356\n assert candidate(difficulty = [85, 47, 57],profit = [24, 66, 99],worker = [40, 25, 25]) == 0\n assert candidate(difficulty = [100],profit = [100],worker = [100]) == 100\n assert candidate(difficulty = [10, 20, 30],profit = [100, 200, 300],worker = [15, 25, 35]) == 600\n assert candidate(difficulty = [2, 4, 6, 8, 10],profit = [10, 20, 30, 40, 50],worker = [4, 5, 6, 7]) == 100\n assert candidate(difficulty = [5, 9, 10, 7, 4],profit = [4, 1, 10, 3, 9],worker = [4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(difficulty = [5, 10, 15],profit = [10, 20, 30],worker = [5, 10, 15, 20]) == 90\n assert candidate(difficulty = [1, 2, 3, 4, 5],profit = [1, 2, 3, 4, 5],worker = [5, 4, 3, 2, 1]) == 15\n assert candidate(difficulty = [1, 1, 1],profit = [1, 2, 3],worker = [1, 1, 1]) == 9\n assert candidate(difficulty = [68, 35, 52, 47, 86],profit = [67, 17, 1, 50, 76],worker = [36, 99, 24, 79, 50]) == 210\n assert candidate(difficulty = [5, 15, 25, 35, 45, 55],profit = [10, 20, 30, 40, 50, 60],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 450\n assert candidate(difficulty = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 830\n assert candidate(difficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1000\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],profit = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],worker = [1, 3, 5, 7, 9, 11, 13, 15]) == 1200\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1000\n assert candidate(difficulty = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(difficulty = [1, 2, 3, 4, 5],profit = [10, 2, 15, 4, 25],worker = [1, 2, 3, 4, 5]) == 75\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],worker = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 9\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1050\n assert candidate(difficulty = [5, 2, 10, 3, 8],profit = [20, 10, 30, 5, 40],worker = [3, 15, 10, 2, 8]) == 140\n assert candidate(difficulty = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],worker = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 1900\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1000\n assert candidate(difficulty = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],worker = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 10000\n assert candidate(difficulty = [1, 1, 1, 1, 1],profit = [100, 200, 300, 400, 500],worker = [1, 1, 1, 1, 1]) == 2500\n assert candidate(difficulty = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 100\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],worker = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 1200\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(difficulty = [100, 200, 300, 400, 500],profit = [1000, 900, 800, 700, 600],worker = [250, 150, 350, 450, 550]) == 5000\n assert candidate(difficulty = [10, 20, 30, 40, 50],profit = [10, 10, 10, 10, 10],worker = [5, 15, 25, 35, 45, 55]) == 50\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39],worker = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 300\n assert candidate(difficulty = [5, 10, 15, 20, 25],profit = [10, 20, 30, 40, 50],worker = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 290\n assert candidate(difficulty = [2, 2, 2, 2, 2],profit = [50, 50, 50, 50, 50],worker = [2, 2, 2, 2, 2]) == 250\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 11\n assert candidate(difficulty = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],worker = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 180\n assert candidate(difficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(difficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],profit = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],worker = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 100\n assert candidate(difficulty = [1, 5, 7, 10, 15],profit = [2, 8, 10, 4, 6],worker = [1, 3, 5, 7, 9, 11, 13, 15]) == 62\n assert candidate(difficulty = [1, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650],worker = [3, 6, 8, 12, 16, 18, 22, 26, 28, 32, 36, 38]) == 3900\n assert candidate(difficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(difficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],profit = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],worker = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10000\n assert candidate(difficulty = [1, 2, 3, 4, 5],profit = [100000, 90000, 80000, 70000, 60000],worker = [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]) == 2500000\n assert candidate(difficulty = [1, 5, 10, 15, 20],profit = [500, 400, 300, 200, 100],worker = [25, 20, 15, 10, 5]) == 2500\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],worker = [1, 3, 5, 7, 9]) == 2500\n assert candidate(difficulty = [1, 2, 3, 4, 5],profit = [1, 2, 3, 4, 5],worker = [5, 5, 5, 5, 5]) == 25\n assert candidate(difficulty = [1, 10, 100, 1000, 10000],profit = [10000, 1000, 100, 10, 1],worker = [1, 5, 10, 50, 100, 500, 1000, 5000, 10000]) == 90000\n assert candidate(difficulty = [20, 10, 30, 40, 50],profit = [100, 50, 200, 150, 250],worker = [5, 15, 25, 35, 45, 55]) == 800\n assert candidate(difficulty = [100000, 10000, 1000, 100, 10],profit = [1, 10, 100, 1000, 10000],worker = [50, 500, 5000, 50000, 100000]) == 50000\n assert candidate(difficulty = [5, 5, 5],profit = [10, 20, 30],worker = [5, 5, 5]) == 90\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],worker = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(difficulty = [10, 20, 30, 40, 50],profit = [10, 20, 30, 40, 50],worker = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 250\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 14250\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],worker = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 4500\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5500\n assert candidate(difficulty = [50, 25, 75, 100, 125],profit = [10, 20, 30, 40, 50],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 430\n assert candidate(difficulty = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5000\n assert candidate(difficulty = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 100\n assert candidate(difficulty = [100000],profit = [100000],worker = [100000]) == 100000\n assert candidate(difficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(difficulty = [30, 20, 10],profit = [3, 2, 1],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(difficulty = [10, 20, 30, 40, 50],profit = [5, 15, 25, 35, 45],worker = [10, 25, 35, 45, 55]) == 125\n assert candidate(difficulty = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],worker = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(difficulty = [10, 20, 30, 40, 50],profit = [50, 40, 30, 20, 10],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 500\n assert candidate(difficulty = [5, 2, 1, 8, 3, 7, 4, 6, 9, 10],profit = [50, 20, 10, 80, 30, 70, 40, 60, 90, 100],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(difficulty = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 300\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1000\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(difficulty = [100, 50, 150, 200, 250],profit = [300, 200, 400, 500, 600],worker = [200, 300, 100, 150, 250, 50]) == 2600\n assert candidate(difficulty = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46]) == 450\n assert candidate(difficulty = [50, 40, 30, 20, 10],profit = [1000, 900, 800, 700, 600],worker = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 8000\n assert candidate(difficulty = [3, 6, 12, 24, 48],profit = [10, 20, 40, 80, 160],worker = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == 630\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 750\n assert candidate(difficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1100\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [5, 8, 3, 10, 2, 7, 6, 9, 1, 4],worker = [1, 3, 5, 7, 9]) == 43\n assert candidate(difficulty = [100, 150, 200],profit = [10, 20, 30],worker = [50, 100, 125, 150, 175, 200, 250]) == 120\n assert candidate(difficulty = [10, 20, 30, 40, 50],profit = [50, 40, 30, 20, 10],worker = [5, 15, 25, 35, 45, 55]) == 250\n assert candidate(difficulty = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 60\n assert candidate(difficulty = [1, 10, 100, 1000, 10000],profit = [10, 100, 1000, 10000, 100000],worker = [1, 5, 50, 500, 5000, 10000, 15000]) == 211120\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],worker = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1000\n assert candidate(difficulty = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],worker = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210]) == 55\n assert candidate(difficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],profit = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],worker = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(difficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],worker = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 10\n assert candidate(difficulty = [5, 15, 25, 35, 45],profit = [10, 20, 30, 40, 50],worker = [1, 10, 20, 30, 40, 50]) == 150\n assert candidate(difficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],profit = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],worker = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],worker = [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]) == 400\n assert candidate(difficulty = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 550\n assert candidate(difficulty = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [99999, 89999, 79999, 69999, 59999, 49999, 39999, 29999, 19999, 9999]) == 900\n assert candidate(difficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 550\n assert candidate(difficulty = [50000, 40000, 30000, 20000, 10000],profit = [100, 200, 300, 400, 500],worker = [50000, 45000, 40000, 35000, 30000, 25000, 20000, 15000, 10000, 5000]) == 4500\n assert candidate(difficulty = [1, 2, 3, 4, 5],profit = [5, 4, 3, 2, 1],worker = [1, 2, 3, 4, 5]) == 25\n assert candidate(difficulty = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],profit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],worker = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 380\n assert candidate(difficulty = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],worker = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 600\n assert candidate(difficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],worker = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(difficulty = [100000, 100000, 100000],profit = [100000, 100000, 100000],worker = [100000, 100000, 100000]) == 300000\n assert candidate(difficulty = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],worker = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 6000\n assert candidate(difficulty = [5, 4, 8, 6, 9, 10, 12, 14, 16, 18],profit = [30, 20, 80, 60, 90, 100, 110, 120, 130, 140],worker = [5, 7, 9, 11, 13, 15, 17, 19, 21]) == 920\n assert candidate(difficulty = [10000, 20000, 30000, 40000, 50000],profit = [100, 200, 300, 400, 500],worker = [5000, 15000, 25000, 35000, 45000, 55000]) == 1500\n assert candidate(difficulty = [5, 10, 15, 20],profit = [50, 30, 20, 60],worker = [5, 10, 15, 20]) == 210\n", "comparison": "exact"}, "public_tests": ["[2,4,6,8,10]\n[10,20,30,40,50]\n[4,5,6,7]", "[85,47,57]\n[24,66,99]\n[40,25,25]"], "hints": [], "metadata": {"canonical_parameter_names": ["difficulty", "profit", "worker"], "leetcode_dataset_entry_point": "Solution().maxProfitAssignment", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:02+00:00", "tests_total": 106, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxProfitAssignment(self, difficulty: list[int], profit: list[int], worker: list[int]) -> int:", "container": "Solution", "callable": "maxProfitAssignment", "parameters": [{"name": "difficulty", "type": "list[int]"}, {"name": "profit", "type": "list[int]"}, {"name": "worker", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 827, "task_id": "making-a-large-island", "difficulty": "Hard", "problem_description": "You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1.\n\nReturn the size of the largest island in grid after applying this operation.\n\nAn island is a 4-directionally connected group of 1s.\n\nExample 1:\n\nInput: grid = [[1,0],[0,1]]\nOutput: 3\nExplanation: Change one 0 to 1 and connect two 1s, then we get an island with area = 3.\n\nExample 2:\n\nInput: grid = [[1,1],[1,0]]\nOutput: 4\nExplanation: Change the 0 to 1 and make the island bigger, only one island with area = 4.\n\nExample 3:\n\nInput: grid = [[1,1],[1,1]]\nOutput: 4\nExplanation: Can't change any 0 to 1, only one island with area = 4.\n\nConstraints:\n\n- n == grid.length\n- n == grid[i].length\n- 1 <= n <= 500\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1], [1, 0]]) == 4\n assert candidate(grid = [[1, 0], [0, 1]]) == 3\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 13\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 5\n assert candidate(grid = [[1, 0, 1, 1], [0, 1, 0, 0], [1, 0, 1, 1], [1, 0, 1, 1]]) == 8\n assert candidate(grid = [[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 0]]) == 9\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1], [1, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 1, 1], [0, 0, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0]]) == 4\n assert candidate(grid = [[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, 1, 0, 1, 0, 1, 0, 1], [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, 1, 0, 1, 0, 1, 0, 1]]) == 3\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == 7\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 = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 7\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]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 0, 1, 1], [1, 1, 0, 0, 0], [0, 0, 0, 0, 1]]) == 13\n assert candidate(grid = [[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, 1, 1, 1], [0, 0, 0, 1, 1, 1]]) == 19\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]]) == 2\n assert candidate(grid = [[1, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 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(grid = [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 17\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], [0, 0, 0, 0, 1, 1]]) == 4\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, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [1, 0, 0, 1, 0], [1, 0, 0, 0, 1], [1, 0, 1, 1, 1]]) == 9\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 17\n assert candidate(grid = [[0, 1, 0, 0, 0], [1, 1, 1, 0, 0], [0, 1, 0, 1, 1], [0, 0, 1, 1, 0], [0, 0, 0, 1, 0]]) == 11\n assert candidate(grid = [[1, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 0, 1, 1, 1]]) == 6\n assert candidate(grid = [[1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1], [0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 1, 0]]) == 5\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 1]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 14\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 0, 0], [0, 0, 0, 1, 1]]) == 13\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 1, 0, 0, 1]]) == 6\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]]) == 9\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1]]) == 16\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 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]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 18\n assert candidate(grid = [[1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [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(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, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0]]) == 9\n assert candidate(grid = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 0, 0], [1, 0, 1, 0, 0]]) == 8\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 0]]) == 8\n assert candidate(grid = [[0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]]) == 10\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == 7\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, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 1]]) == 11\n assert candidate(grid = [[1, 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, 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, 1], [0, 0, 0, 0, 0, 0, 0, 1]]) == 5\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0]]) == 5\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, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 13\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 = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 0]]) == 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]]) == 5\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0]]) == 12\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [1, 1, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1]]) == 7\n assert candidate(grid = [[1, 1, 0, 0, 1, 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], [1, 1, 0, 0, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [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], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1]]) == 17\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 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, 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]]) == 5\n assert candidate(grid = [[0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 0, 0, 0]]) == 7\n assert candidate(grid = [[1, 0, 1, 1, 0], [0, 0, 1, 0, 0], [1, 1, 1, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]]) == 11\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 1, 0], [1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 19\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 0], [0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [1, 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, 1]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 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]]) == 49\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 0, 1, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[1,0],[0,1]]", "[[1,1],[1,0]]", "[[1,1],[1,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largestIsland", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:05+00:00", "tests_total": 81, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def largestIsland(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "largestIsland", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 828, "task_id": "count-unique-characters-of-all-substrings-of-a-given-string", "difficulty": "Hard", "problem_description": "Let's define a function countUniqueChars(s) that returns the number of unique characters in s.\n\n- For example, calling countUniqueChars(s) if s = \"LEETCODE\" then \"L\", \"T\", \"C\", \"O\", \"D\" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.\n\nGiven a string s, return the sum of countUniqueChars(t) where t is a substring of s. The test cases are generated such that the answer fits in a 32-bit integer.\n\nNotice that some substrings can be repeated so in this case you have to count the repeated ones too.\n\nExample 1:\n\nInput: s = \"ABC\"\nOutput: 10\nExplanation: All possible substrings are: \"A\",\"B\",\"C\",\"AB\",\"BC\" and \"ABC\".\nEvery substring is composed with only unique letters.\nSum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10\n\nExample 2:\n\nInput: s = \"ABA\"\nOutput: 8\nExplanation: The same as example 1, except countUniqueChars(\"ABA\") = 1.\n\nExample 3:\n\nInput: s = \"LEETCODE\"\nOutput: 92\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of uppercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ABCDEFG\") == 84\n assert candidate(s = \"ABAC\") == 16\n assert candidate(s = \"ABAB\") == 12\n assert candidate(s = \"JXWTRVABFBJSFNWFTTTOWEJXSGZSWQSZSQXRXRJTSFO\") == 4609\n assert candidate(s = \"ABCABC\") == 36\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 3276\n assert candidate(s = \"LEETCODE\") == 92\n assert candidate(s = \"ABABAB\") == 20\n assert candidate(s = \"AA\") == 2\n assert candidate(s = \"UPPERCASEENGLISHLETTERS\") == 1236\n assert candidate(s = \"ABC\") == 10\n assert candidate(s = \"AABAA\") == 15\n assert candidate(s = \"GCIYVUTETZTEKFREERERREERETEEEEEEDDDB\") == 2050\n assert candidate(s = \"A\") == 1\n assert candidate(s = \"ZZZ\") == 3\n assert candidate(s = \"ABA\") == 8\n assert candidate(s = \"ABABABABAB\") == 36\n assert candidate(s = \"AAABBBCCC\") == 27\n assert candidate(s = \"ZYXWVUTSRQPONMLKJIHGFEDCBA\") == 3276\n assert candidate(s = \"ABCA\") == 18\n assert candidate(s = \"ZZZZZZZZZZ\") == 10\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRST\") == 1540\n assert candidate(s = \"UVRMCGWAHTRWWQRRQRQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\") == 3333\n assert candidate(s = \"ABCDABCD\") == 80\n assert candidate(s = \"ZZZZZZZZZZZZZZZZZZZZZZZZZZ\") == 26\n assert candidate(s = \"SUPERLONGSTRINGWITHMANYCHARACTERSTOTESTTHEFUNCTIONALITYOFTHISSOLUTION\") == 11748\n assert candidate(s = \"UPPERCASEISUSEDUPPERCASEISUSEDUPPERCASEISUSEDUPPERCASEISUSED\") == 4352\n assert candidate(s = \"PYTHON\") == 56\n assert candidate(s = \"ALGORITHMSDESIGN\") == 688\n assert candidate(s = \"TESTTESTTESTTESTTEST\") == 166\n assert candidate(s = \"LONGSTRINGLONGSTRINGLONGSTRINGLONGSTRINGLONGSTRINGLONGSTRINGLONGSTRINGLONGSTRING\") == 4992\n assert candidate(s = \"VARYINGVARYINGVARYINGVARYINGVARYINGVARYINGVARYING\") == 2107\n assert candidate(s = \"REALLYLONGSTRINGWITHVARYINGCHARACTERFREQUENCIES\") == 6279\n assert candidate(s = \"XYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZ\") == 576\n assert candidate(s = \"DATASTRUCTURESANDALGORITHMS\") == 2087\n assert candidate(s = \"ALMOSTUNIQUEALMOSTUNIQUEALMOSTUNIQUEALMOSTUNIQUE\") == 4668\n assert candidate(s = \"AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXXXXYYYYYYZZZZZZ\") == 2262\n assert candidate(s = \"HIGHFREQUENCYHIGHFREQUENCYHIGHFREQUENCY\") == 3465\n assert candidate(s = \"THISPROBLEMMIGHTBEHARDTOSOLVEBUTITISNOTTHISPROBLEMMIGHTBEHARDTOSOLVEBUTITISNOT\") == 17778\n assert candidate(s = \"BUNCHOFOFTHEBUNCHOFTHEBUNCHOFTHE\") == 1902\n assert candidate(s = \"HIGHFREQHIGHFREQHIGHFREQHIGHFREQHIGHFREQHIGHFREQHIGHFREQ\") == 2550\n assert candidate(s = \"AACBBBCCCCDDDDEEEEEFFFFFFFFGGGGGGHHHHHHHIIIIIIIIIJJJJJJJJ\") == 579\n assert candidate(s = \"UPPERCASELOWERCASEUPPERCASELOWERCASEUPPERCASELOWERCASE\") == 4631\n assert candidate(s = \"SAMECHARSSAMECHARSSAMECHARSSAMECHARS\") == 1469\n assert candidate(s = \"UPPERCASELOWERCASE\") == 723\n assert candidate(s = \"QWERTYUIOPASDFGHJKLZXCVBNMQWERTYUIOPASDFGHJKLZXCVBNM\") == 18252\n assert candidate(s = \"ABACADAEAFAG\") == 204\n assert candidate(s = \"MMMMMMMMMMMMAAAAAAAAAA\") == 44\n assert candidate(s = \"ALONGSTRINGWITHSOMEUNIQUECHARACTERSTHROUGHOUT\") == 5238\n assert candidate(s = \"LEETCODELEETCODELEETCODE\") == 726\n assert candidate(s = \"HELLOHELLOHELLOHELLOHELLO\") == 352\n assert candidate(s = \"UPPERCASEUPPERCASEUPPERCASE\") == 1001\n assert candidate(s = \"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\") == 52\n assert candidate(s = \"HELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLO\") == 684\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTABCDEFGHIJKLMNOPQRST\") == 8400\n assert candidate(s = \"AAABBBCCCDDD\") == 48\n assert candidate(s = \"THETREESAREBIGANDGREEN\") == 1035\n assert candidate(s = \"PYTHONPROGRAMMINGPYTHONPROGRAMMINGPYTHONPROGRAMMINGPYTHONPROGRAMMINGPYTHONPROGRAMMING\") == 8740\n assert candidate(s = \"REPEATSREPEATSREPEATSREPEATSREPEATSREPEATSREPEATSREPEATSREPEATSREPEATS\") == 2432\n assert candidate(s = \"COMPLEXSTRINGWITHMIXEDCHARACTERSDGFFFVGDVHFDGDFJGDFGDFGDFGDFGDFGDFGDFG\") == 10601\n assert candidate(s = \"ZABZACZADBZADCZADEZAEFZAFGZAFHZAGIZAHJZAKZALZAMZANZAOZAPZAQZARZASZATAUAVAWAXAYAZ\") == 22977\n assert candidate(s = \"REPEATREPEATREPEATREPEATREPEATREPEAT\") == 834\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUPONMLKJIHGFEDCBA\") == 6147\n assert candidate(s = \"XYZXYZXYZXYZXYZ\") == 117\n assert candidate(s = \"UNIQUECHARACTER\") == 468\n assert candidate(s = \"ABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGH\") == 3648\n assert candidate(s = \"AABCCDDEEFFGHHIJKLMMNOOPPQQRRSSTTUUVVWWXXYYZZ\") == 3859\n assert candidate(s = \"CONTAINSREPETITIONSCONTAINSREPETITIONSCONTAINSREPETITIONS\") == 4748\n assert candidate(s = \"KOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOKOK\") == 368\n assert candidate(s = \"SOMEVARIETYOFCHARSHEREANDTHERE\") == 2687\n assert candidate(s = \"SUPERLONGSTRINGWITHVARYINGCHARACTERFREQUENCIES\") == 6393\n assert candidate(s = \"UPPERCASEUPPERCASEUPPERCASEUPPERCASE\") == 1462\n assert candidate(s = \"PYTHONPROGRAMMING\") == 597\n assert candidate(s = \"AABCCDEEFFGHIJKLMMNOOPQRSTUUVWXYZ\") == 4065\n assert candidate(s = \"MISINTERPRETATIONMISINTERPRETATION\") == 2247\n assert candidate(s = \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\") == 72\n assert candidate(s = \"EXAMPLEWITHREPEATEDCHARSEXAMPLEWITHREPEATEDCHARSEXAMPLEWITHREPEATEDCHARS\") == 12926\n assert candidate(s = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\") == 90\n assert candidate(s = \"AAAAAAAAABBBBBBBBCCCCCCCCCC\") == 81\n assert candidate(s = \"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ\") == 1352\n assert candidate(s = \"SHORTLONGSHORTLONGSHORTLONGSHORTLONGSHORTLONG\") == 2515\n assert candidate(s = \"REALLYLONGSTRINGTOCHECKEFFICIENCYREALLYLONGSTRINGTOCHECKEFFICIENCY\") == 9311\n assert candidate(s = \"AABABABABABABABABABABABABABABABABABABABAB\") == 159\n assert candidate(s = \"MULTIPLEOCCURRENCESOFTHESAMELETTER\") == 3148\n assert candidate(s = \"AABBCCEEE\") == 36\n assert candidate(s = \"AAAAABBBBBCCCCC\") == 45\n assert candidate(s = \"AABCCDEE\") == 60\n assert candidate(s = \"AABBCCDDEEFFGGAABBCCDDEEFFGG\") == 280\n assert candidate(s = \"ALLTHELETTERSOFTHEALPHABETALLTHELETTERSOFTHEALPHABET\") == 5626\n assert candidate(s = \"XYZXYZXYZ\") == 63\n assert candidate(s = \"NINCOMPOOP\") == 138\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 18252\n assert candidate(s = \"UNIQUEUNIQUEUNIQUE\") == 356\n assert candidate(s = \"ABACABACABAC\") == 94\n assert candidate(s = \"NOTSOEASYNOTSOEASYNOTSOEASY\") == 1052\n assert candidate(s = \"ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB\") == 244\n assert candidate(s = \"ZZZZZZZZZZYYYYYYYYYYXXXXXXXXXXWWWWWWWWVVVVVVVVUUUUUU\") == 312\n assert candidate(s = \"XYZXYZXYZXYZXYZXYZXYZXYZ\") == 198\n assert candidate(s = \"THISISTHEMOSTCOMPLEXTESTCASE\") == 1699\n assert candidate(s = \"AABCAAABCAAAABC\") == 132\n assert candidate(s = \"NOCOLLISIONNOCOLLISIONNOCOLLISIONNOCOLLISIONNOCOLLISIONNOCOLLISION\") == 1871\n assert candidate(s = \"AAAAABBBBBCCCCCDDDDD\") == 80\n assert candidate(s = \"ABACADAEAFAGAHAIAJAKALAMANAOAPAQAQARASATAUAVAWAXAYAZ\") == 11288\n assert candidate(s = \"X\") == 1\n assert candidate(s = \"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYZZ\") == 1422\n assert candidate(s = \"ABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVA\") == 7168\n assert candidate(s = \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\") == 40\n assert candidate(s = \"SIMPLESTRING\") == 340\n assert candidate(s = \"LEETCODEISAWESOMEEVERYTHINGISPOSSIBLE\") == 4975\n assert candidate(s = \"SUBSTRINGCALCULATIONSARETRICKYTOGETRIGHT\") == 4360\n assert candidate(s = \"ABABABABABABABABABABABABAB\") == 100\n assert candidate(s = \"MIXEDCASEMIXEDCASEMIXEDCASE\") == 1302\n assert candidate(s = \"HELLOWORLDHELLOWORLDHELLOWORLD\") == 1208\n assert candidate(s = \"SUBSTRINGSUBSTRINGSUBSTRINGSUBSTRING\") == 1893\n assert candidate(s = \"SIMPLECOMPLEXSIMPLECOMPLEXSIMPLECOMPLEXSIMPLECOMPLEXSIMPLECOMPLEX\") == 4981\n assert candidate(s = \"REPEATEDCHARACTERSCONTINUOUSLYAAAAAAAAAAAAAAAA\") == 4381\n assert candidate(s = \"SUBSTRINGCALCULATIONISEXTRAORDINARY\") == 3303\n assert candidate(s = \"IDENTICALBLOCKSIDENTICALBLOCKSIDENTICALBLOCKS\") == 4848\n assert candidate(s = \"QWJRTYUPASDFGHJKLZXCVBNM\") == 2540\n assert candidate(s = \"HELLOWORLDHELLOWORLD\") == 647\n assert candidate(s = \"ABCDEFGHIJABCDEFGHIJ\") == 1100\n assert candidate(s = \"WASITATRATITASAWASITATRATITASAWASITATRATITASA\") == 1696\n assert candidate(s = \"AVOIDREPETITIONSINHEREAVOIDREPETITIONSINHEREAVOIDREPETITIONSINHERE\") == 8106\n assert candidate(s = \"ABCDEFGHJIJKLMNOPQRSTUVWXYZ\") == 3348\n assert candidate(s = \"ZBCDEFGHIJKLMNOPQRSTUVWXYZZYXWVUTSRQPONMLKJIHGFEDCBA\") == 12376\n assert candidate(s = \"MISSISSIPPI\") == 61\n assert candidate(s = \"PYTHONPYTHONPYTHONPYTHON\") == 684\n assert candidate(s = \"ALPHABETALPHABETALPHABETALPHABET\") == 1316\n assert candidate(s = \"REPEATREPEATREPEATREPEATREPEATREPEATREPEATREPEATREPEAT\") == 1314\n assert candidate(s = \"CHECKINGUNIQUECHARSCHECKINGUNIQUECHARSCHECKINGUNIQUECHARS\") == 6460\n assert candidate(s = \"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZ\") == 2704\n assert candidate(s = \"AAABBBCCCDDDEEEFFFGGGHHHHIIIJJJKKKLLLMMMNNNOOOPPPPQQQQRRRRSSSSTTTTUUUVVVWWWXXXYYYYZZZZ\") == 2236\n assert candidate(s = \"UNIQUECHARACTERSCOUNTUNIQUECHARACTERSCOUNTUNIQUECHARACTERSCOUNT\") == 7133\n assert candidate(s = \"HELLOOOWORLD\") == 156\n assert candidate(s = \"PYTHONPYTHONPYTHON\") == 468\n assert candidate(s = \"TESTSTRINGTESTSTRINGTESTSTRINGTESTSTRING\") == 1776\n assert candidate(s = \"ABCABCABCABCABCABCABCABCABCABCABCABCABCABC\") == 360\n assert candidate(s = \"CONSECUTIVECHARSAREHERECONSECUTIVECHARSAREHERECONSECUTIVECHARSAREHERE\") == 9088\n assert candidate(s = \"REPEATEDLETTERSARETRICKY\") == 1108\n assert candidate(s = \"RECURSION\") == 155\n assert candidate(s = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\") == 104\n assert candidate(s = \"SUPERDUPERLONGSTRINGWITHMANYCHARACTERS\") == 4375\n assert candidate(s = \"AGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCT\") == 720\n assert candidate(s = \"COMPUTERSCIENCE\") == 557\n assert candidate(s = \"LOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQLOWFREQ\") == 3822\n assert candidate(s = \"THETRUTHISTHETRUTH\") == 567\n assert candidate(s = \"QWERTYUIOPASDFGHJKLZXCVBNM\") == 3276\n assert candidate(s = \"UNIQUECHARACTERFUNCTION\") == 1232\n assert candidate(s = \"ZYXWVUTSRQPONMLKJIHGFEDCBAZYXWVUTSRQPONMLKJIHGFEDCBA\") == 18252\n assert candidate(s = \"LONGSTRINGSOMETIMESCONTAINMANYLETTERS\") == 2957\n assert candidate(s = \"MIXEDCASEBUTSAMECHARSMIXEDCASEBUTSAMECHARSMIXEDCASEBUTSAMECHARS\") == 9433\n assert candidate(s = \"LOWFREQUENCYLOWFREQUENCYLOWFREQUENCY\") == 3138\n assert candidate(s = \"ABACABA\") == 44\n assert candidate(s = \"AAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ\") == 1378\n assert candidate(s = \"MNONMMNONMMNONMMNONMMNONMMNONMMNONMMNONMMNONMMNONMMNONMMNONMMNONM\") == 561\n assert candidate(s = \"AAAAAAAAAAAAAAAAAAAAAAAA\") == 24\n assert candidate(s = \"ABACADAEAFAGAHAIAJAKALAMANAOAPAQAQARASATAUAUAVAWAXAYAZ\") == 11698\n", "comparison": "exact"}, "public_tests": ["\"ABC\"", "\"ABA\"", "\"LEETCODE\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().uniqueLetterString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:08+00:00", "tests_total": 160, "tests_dropped": 3, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def uniqueLetterString(self, s: str) -> int:", "container": "Solution", "callable": "uniqueLetterString", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 829, "task_id": "consecutive-numbers-sum", "difficulty": "Hard", "problem_description": "Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.\n\nExample 1:\n\nInput: n = 5\nOutput: 2\nExplanation: 5 = 2 + 3\n\nExample 2:\n\nInput: n = 9\nOutput: 3\nExplanation: 9 = 4 + 5 = 2 + 3 + 4\n\nExample 3:\n\nInput: n = 15\nOutput: 4\nExplanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5\n\nConstraints:\n\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 100) == 3\n assert candidate(n = 15) == 4\n assert candidate(n = 9) == 3\n assert candidate(n = 1000000) == 7\n assert candidate(n = 25) == 3\n assert candidate(n = 1) == 1\n assert candidate(n = 1000000000) == 10\n assert candidate(n = 1000) == 4\n assert candidate(n = 10) == 2\n assert candidate(n = 5) == 2\n assert candidate(n = 3) == 2\n assert candidate(n = 45) == 6\n assert candidate(n = 210) == 8\n assert candidate(n = 897) == 8\n assert candidate(n = 999999999) == 20\n assert candidate(n = 49) == 3\n assert candidate(n = 12345) == 8\n assert candidate(n = 67890) == 16\n assert candidate(n = 76543210) == 8\n assert candidate(n = 56789) == 4\n assert candidate(n = 89123456) == 4\n assert candidate(n = 2019) == 4\n assert candidate(n = 6789) == 8\n assert candidate(n = 10000) == 5\n assert candidate(n = 43210987) == 8\n assert candidate(n = 1001) == 8\n assert candidate(n = 2) == 1\n assert candidate(n = 200000000) == 9\n assert candidate(n = 50000000) == 9\n assert candidate(n = 1024) == 1\n assert candidate(n = 101) == 2\n assert candidate(n = 8) == 1\n assert candidate(n = 10000000) == 8\n assert candidate(n = 56789123) == 2\n assert candidate(n = 845123) == 4\n assert candidate(n = 1048576) == 1\n assert candidate(n = 89) == 2\n assert candidate(n = 89754321) == 4\n assert candidate(n = 8472187) == 4\n assert candidate(n = 84521) == 2\n assert candidate(n = 13) == 2\n assert candidate(n = 150) == 6\n assert candidate(n = 987654321) == 18\n assert candidate(n = 123456789) == 12\n assert candidate(n = 1234567) == 4\n assert candidate(n = 121) == 3\n assert candidate(n = 999999) == 64\n assert candidate(n = 123456) == 4\n assert candidate(n = 500) == 4\n assert candidate(n = 54321) == 8\n assert candidate(n = 100000000) == 9\n assert candidate(n = 1500) == 8\n", "comparison": "exact"}, "public_tests": ["5", "9", "15"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().consecutiveNumbersSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:10+00:00", "tests_total": 53, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def consecutiveNumbersSum(self, n: int) -> int:", "container": "Solution", "callable": "consecutiveNumbersSum", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 830, "task_id": "positions-of-large-groups", "difficulty": "Easy", "problem_description": "In a string s of lowercase letters, these letters form consecutive groups of the same character.\n\nFor example, a string like s = \"abbxxxxzyy\" has the groups \"a\", \"bb\", \"xxxx\", \"z\", and \"yy\".\n\nA group is identified by an interval [start, end], where start and end denote the start and end indices (inclusive) of the group. In the above example, \"xxxx\" has the interval [3,6].\n\nA group is considered large if it has 3 or more characters.\n\nReturn the intervals of every large group sorted in increasing order by start index.\n\nExample 1:\n\nInput: s = \"abbxxxxzzy\"\nOutput: [[3,6]]\nExplanation: \"xxxx\" is the only large group with start index 3 and end index 6.\n\nExample 2:\n\nInput: s = \"abc\"\nOutput: []\nExplanation: We have groups \"a\", \"b\", and \"c\", none of which are large groups.\n\nExample 3:\n\nInput: s = \"abcdddeeeeaabbbcd\"\nOutput: [[3,5],[6,9],[12,14]]\nExplanation: The large groups are \"ddd\", \"eeee\", and \"bbb\".\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s contains lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbbccccdddd\") == [[2, 4], [5, 8], [9, 12]]\n assert candidate(s = \"aabbbccccddeee\") == [[2, 4], [5, 8], [11, 13]]\n assert candidate(s = \"abcdefghijk\") == []\n assert candidate(s = \"aabbaa\") == []\n assert candidate(s = \"aabbccccaaaabbccccaaaabbcccc\") == [[4, 7], [8, 11], [14, 17], [18, 21], [24, 27]]\n assert candidate(s = \"a\") == []\n assert candidate(s = \"abbxxxxzzy\") == [[3, 6]]\n assert candidate(s = \"zzzzyyyyy\") == [[0, 3], [4, 8]]\n assert candidate(s = \"aa\") == []\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == [[0, 69]]\n assert candidate(s = \"aaa\") == [[0, 2]]\n assert candidate(s = \"pppppqqqppppppqqqqqqqqq\") == [[0, 4], [5, 7], [8, 13], [14, 22]]\n assert candidate(s = \"zzzzzzzzzz\") == [[0, 9]]\n assert candidate(s = \"aabbccddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooopppqqqrrrsttuuvvvwwwwxxxxyyyyzzzz\") == [[8, 11], [12, 15], [16, 19], [20, 23], [24, 27], [28, 31], [32, 35], [36, 39], [40, 43], [44, 47], [48, 50], [51, 53], [54, 56], [57, 59], [65, 67], [68, 71], [72, 75], [76, 79], [80, 83]]\n assert candidate(s = \"abc\") == []\n assert candidate(s = \"abcd\") == []\n assert candidate(s = \"aabbbccddddeeeee\") == [[2, 4], [7, 10], [11, 15]]\n assert candidate(s = \"aaabaaa\") == [[0, 2], [4, 6]]\n assert candidate(s = \"abcdddeeeeaabbbcd\") == [[3, 5], [6, 9], [12, 14]]\n assert candidate(s = \"zzzzz\") == [[0, 4]]\n assert candidate(s = \"aabbccddeee\") == [[8, 10]]\n assert candidate(s = \"aaabbbcccddd\") == [[0, 2], [3, 5], [6, 8], [9, 11]]\n assert candidate(s = \"aaaaabbbbbcccccc\") == [[0, 4], [5, 9], [10, 15]]\n assert candidate(s = \"aabbcccddd\") == [[4, 6], [7, 9]]\n assert candidate(s = \"aabbccddeeffgggghhiijjjkkkllmmnnnooopppqqqqrrrrssss\") == [[12, 15], [20, 22], [23, 25], [30, 32], [33, 35], [36, 38], [39, 42], [43, 46], [47, 50]]\n assert candidate(s = \"zzzzzzyyyyaaaabbcccc\") == [[0, 5], [6, 9], [10, 13], [16, 19]]\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == []\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == [[50, 59]]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == [[0, 101]]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == []\n assert candidate(s = \"aabbccccddeeeffffggggghhhhhiiiiijjjjjjkkkklllllmmmmmnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxyyyyzzzz\") == [[4, 7], [10, 12], [13, 16], [17, 21], [22, 26], [27, 31], [32, 37], [38, 41], [42, 46], [47, 51], [54, 57], [58, 61], [62, 65], [66, 69], [70, 73], [74, 77], [78, 81], [82, 85], [86, 89], [90, 92], [93, 96], [97, 100]]\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababababababab\") == []\n assert candidate(s = \"zzzzzyyyyyxxxxwwwwvvvvuuuuttttsrrrqqqpooooonnnnmmmmmlllllkkkkjjjjjiiiihhhhhgggggfffffeeee\") == [[0, 4], [5, 9], [10, 13], [14, 17], [18, 21], [22, 25], [26, 29], [31, 33], [34, 36], [38, 42], [43, 46], [47, 51], [52, 56], [57, 60], [61, 65], [66, 69], [70, 74], [75, 79], [80, 84], [85, 88]]\n assert candidate(s = \"aabcccccaaaaabbbcccc\") == [[3, 7], [8, 12], [13, 15], [16, 19]]\n assert candidate(s = \"abcdefghijkllllmnopqrstuvwxyz\") == [[11, 14]]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaaaa\") == [[51, 54]]\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == [[0, 84], [85, 166]]\n assert candidate(s = \"aaaaaaabbbbbcccccdddddeeeeeeaaaaaaaaabbbbcccccddeeeeefffff\") == [[0, 6], [7, 11], [12, 16], [17, 21], [22, 27], [28, 36], [37, 40], [41, 45], [48, 52], [53, 57]]\n assert candidate(s = \"abccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccd\") == [[2, 65]]\n assert candidate(s = \"tttttttttttttttttttttttttttttttttttttt\") == [[0, 37]]\n assert candidate(s = \"aabbccddeeeffffggggghhhhhiiiiijjjjjj\") == [[8, 10], [11, 14], [15, 19], [20, 24], [25, 29], [30, 35]]\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == [[2, 47]]\n assert candidate(s = \"aabbccccddeeeffffggggghhhhhiiiiijjjjjjkkkklllllmmmmmnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxyyyyzzzzz\") == [[4, 7], [10, 12], [13, 16], [17, 21], [22, 26], [27, 31], [32, 37], [38, 41], [42, 46], [47, 51], [54, 57], [58, 61], [62, 65], [66, 69], [70, 73], [74, 77], [78, 81], [82, 85], [86, 89], [90, 92], [93, 96], [97, 101]]\n assert candidate(s = \"abcdefghiiiiijkllllmmnopqqqrrr\") == [[8, 12], [15, 18], [24, 26], [27, 29]]\n assert candidate(s = \"abcdefghijklmnopqrstuvwwxyzzaaabbbccc\") == [[28, 30], [31, 33], [34, 36]]\n assert candidate(s = \"kkkkkklllllmmmmmnnnnnoooooopppppqqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwxxyyyyyzzzzz\") == [[0, 5], [6, 10], [11, 15], [16, 20], [21, 26], [27, 31], [32, 37], [38, 42], [43, 47], [48, 52], [53, 57], [58, 62], [63, 67], [70, 74], [75, 79]]\n assert candidate(s = \"aabbccccddddeeeffffffgggghhhiiiiijjjkkllmmnnnooppqqrrssttuuvvwxxxwwvvuuttssrrqponmlkjihgfedcba\") == [[4, 7], [8, 11], [12, 14], [15, 20], [21, 24], [25, 27], [28, 32], [33, 35], [42, 44], [62, 64]]\n assert candidate(s = \"aaaaabbbbccccdddd\") == [[0, 4], [5, 8], [9, 12], [13, 16]]\n assert candidate(s = \"ppppqqqqrrrsssttttuuuuvvvvwxxx\") == [[0, 3], [4, 7], [8, 10], [11, 13], [14, 17], [18, 21], [22, 25], [27, 29]]\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbbbccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffggggggggggggggggg\") == [[0, 9], [10, 23], [24, 47], [48, 84], [85, 116], [117, 131], [132, 148]]\n assert candidate(s = \"nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnmmmm\") == [[0, 47], [48, 51]]\n assert candidate(s = \"xyzzyxwwwwwzzzzzz\") == [[6, 10], [11, 16]]\n assert candidate(s = \"aabbccddeeffggccddeeffggccddeeffggccddeeffggccddeeffgg\") == []\n", "comparison": "exact"}, "public_tests": ["\"abbxxxxzzy\"", "\"abc\"", "\"abcdddeeeeaabbbcd\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().largeGroupPositions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:12+00:00", "tests_total": 54, "tests_dropped": 1, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def largeGroupPositions(self, s: str) -> list[list[int]]:", "container": "Solution", "callable": "largeGroupPositions", "parameters": [{"name": "s", "type": "str"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 831, "task_id": "masking-personal-information", "difficulty": "Medium", "problem_description": "You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules.\n\nEmail address:\n\nAn email address is:\n\n- A name consisting of at least two uppercase and lowercase English letters, followed by\n- The '@' symbol, followed by\n- The domain consisting of uppercase and lowercase English letters with a dot '.' somewhere in the middle (not the first or last character).\n\nTo mask an email:\n\n- The uppercase letters in the name and domain must be converted to lowercase letters.\n- The middle letters of the name (i.e., all but the first and last letters) must be replaced by 5 asterisks \"*****\".\n\nPhone number:\n\nA phone number is formatted as follows:\n\n- The phone number contains 10-13 digits.\n- The last 10 digits make up the local number.\n- The remaining 0-3 digits, in the beginning, make up the country code.\n- Separation characters from the set {'+', '-', '(', ')', ' '} separate the above digits in some way.\n\nTo mask a phone number:\n\n- Remove all separation characters.\n- The masked phone number should have the form:\n - \"***-***-XXXX\" if the country code has 0 digits.\n - \"+*-***-***-XXXX\" if the country code has 1 digit.\n - \"+**-***-***-XXXX\" if the country code has 2 digits.\n - \"+***-***-***-XXXX\" if the country code has 3 digits.\n- \"XXXX\" is the last 4 digits of the local number.\n\nExample 1:\n\nInput: s = \"LeetCode@LeetCode.com\"\nOutput: \"l*****e@leetcode.com\"\nExplanation: s is an email address.\nThe name and domain are converted to lowercase, and the middle of the name is replaced by 5 asterisks.\n\nExample 2:\n\nInput: s = \"AB@qq.com\"\nOutput: \"a*****b@qq.com\"\nExplanation: s is an email address.\nThe name and domain are converted to lowercase, and the middle of the name is replaced by 5 asterisks.\nNote that even though \"ab\" is 2 characters, it still must have 5 asterisks in the middle.\n\nExample 3:\n\nInput: s = \"1(234)567-890\"\nOutput: \"***-***-7890\"\nExplanation: s is a phone number.\nThere are 10 digits, so the local number is 10 digits and the country code is 0 digits.\nThus, the resulting masked number is \"***-***-7890\".\n\nConstraints:\n\n- s is either a valid email or a phone number.\n- If s is an email:\n - 8 <= s.length <= 40\n - s consists of uppercase and lowercase English letters and exactly one '@' symbol and '.' symbol.\n- If s is a phone number:\n - 10 <= s.length <= 20\n - s consists of digits, spaces, and the symbols '(', ')', '-', and '+'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"12345678901\") == \"+*-***-***-8901\"\n assert candidate(s = \"+11234567890\") == \"+*-***-***-7890\"\n assert candidate(s = \"123 456 7890\") == \"***-***-7890\"\n assert candidate(s = \"+1-800-555-0199\") == \"+*-***-***-0199\"\n assert candidate(s = \"9876543210\") == \"***-***-3210\"\n assert candidate(s = \"123456789012\") == \"+**-***-***-9012\"\n assert candidate(s = \"123.456.7890\") == \"***-***-7890\"\n assert candidate(s = \"jane.doe@domain.co\") == \"j*****e@domain.co\"\n assert candidate(s = \"1234567890\") == \"***-***-7890\"\n assert candidate(s = \"John.Doe@example.com\") == \"j*****e@example.com\"\n assert candidate(s = \"alice@leetcode.com\") == \"a*****e@leetcode.com\"\n assert candidate(s = \"LeetCode@LeetCode.com\") == \"l*****e@leetcode.com\"\n assert candidate(s = \"AB@qq.com\") == \"a*****b@qq.com\"\n assert candidate(s = \"0-213-321-2345\") == \"+*-***-***-2345\"\n assert candidate(s = \"+91(123) 456-7890\") == \"+**-***-***-7890\"\n assert candidate(s = \"+123(123) 456-7890\") == \"+***-***-***-7890\"\n assert candidate(s = \"(123) 456-7890\") == \"***-***-7890\"\n assert candidate(s = \"abcdef@gmail.com\") == \"a*****f@gmail.com\"\n assert candidate(s = \"+111234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"+1-234-567-890\") == \"***-***-7890\"\n assert candidate(s = \"+1234567890\") == \"***-***-7890\"\n assert candidate(s = \"a@leetcode.com\") == \"a*****a@leetcode.com\"\n assert candidate(s = \"+1111234567890\") == \"+***-***-***-7890\"\n assert candidate(s = \"john.doe@example.co.uk\") == \"j*****e@example.co.uk\"\n assert candidate(s = \"+1-123-456-7890\") == \"+*-***-***-7890\"\n assert candidate(s = \"+12(123) 456-7890\") == \"+**-***-***-7890\"\n assert candidate(s = \"1234567890123\") == \"+***-***-***-0123\"\n assert candidate(s = \"+(123)-456-7890\") == \"***-***-7890\"\n assert candidate(s = \"bob.cathy@leetcode.com\") == \"b*****y@leetcode.com\"\n assert candidate(s = \"a.b@c.com\") == \"a*****b@c.com\"\n assert candidate(s = \"abcdefghijk@leetcode.com\") == \"a*****k@leetcode.com\"\n assert candidate(s = \"aBcD@eFgHiJ.com\") == \"a*****d@efghij.com\"\n assert candidate(s = \"1(234)567-890\") == \"***-***-7890\"\n assert candidate(s = \"+49 176 2345 6789\") == \"+***-***-***-6789\"\n assert candidate(s = \"+49(123) 456-7890\") == \"+**-***-***-7890\"\n assert candidate(s = \"ABCDE@FGHI.JKL\") == \"a*****e@fghi.jkl\"\n assert candidate(s = \"+442079460958\") == \"+**-***-***-0958\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz@abc.def.ghijklmnopqrstuvwxyz\") == \"a*****z@abc.def.ghijklmnopqrstuvwxyz\"\n assert candidate(s = \"Annie.Marie@service.org\") == \"a*****e@service.org\"\n assert candidate(s = \"+91-8765432109\") == \"+**-***-***-2109\"\n assert candidate(s = \"+1-800-MY-BANK\") == \"+-***-***-1800\"\n assert candidate(s = \"+911234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"(123) 456-7890 ext. 1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"user@website.co\") == \"u*****r@website.co\"\n assert candidate(s = \"john.doe@EXAMPLE.COM\") == \"j*****e@example.com\"\n assert candidate(s = \"+91 (123) 456 7890\") == \"+**-***-***-7890\"\n assert candidate(s = \"+91 (123) 456-7890\") == \"+**-***-***-7890\"\n assert candidate(s = \"(+123) 456-7890123\") == \"+***-***-***-0123\"\n assert candidate(s = \"001234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"+44 20 7946 0958\") == \"+**-***-***-0958\"\n assert candidate(s = \"(012) 345 6789\") == \"***-***-6789\"\n assert candidate(s = \"user@domain.c\") == \"u*****r@domain.c\"\n assert candidate(s = \"ABC.DEF@GMAIL.COM\") == \"a*****f@gmail.com\"\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@domain.com\") == \"a*****z@domain.com\"\n assert candidate(s = \"Alice.Bob.Charlie@example.co.uk\") == \"a*****e@example.co.uk\"\n assert candidate(s = \"+31(0)123456789\") == \"+**-***-***-6789\"\n assert candidate(s = \"+1 800 555 0199\") == \"+*-***-***-0199\"\n assert candidate(s = \"+0 1234 5678901\") == \"+**-***-***-8901\"\n assert candidate(s = \"An.Extremely.Long.Name@subdomain.example.com\") == \"a*****e@subdomain.example.com\"\n assert candidate(s = \"John_Doe@domain.com\") == \"j*****e@domain.com\"\n assert candidate(s = \"John-Doe@Example.com\") == \"j*****e@example.com\"\n assert candidate(s = \"foo-bar@baz-qux.org\") == \"f*****r@baz-qux.org\"\n assert candidate(s = \"FirstName.LastName@domain.co.uk\") == \"f*****e@domain.co.uk\"\n assert candidate(s = \"+01-123-456-7890\") == \"+**-***-***-7890\"\n assert candidate(s = \"PhoneNumber123@domain.com\") == \"p*****3@domain.com\"\n assert candidate(s = \"+1234-567-8901\") == \"+*-***-***-8901\"\n assert candidate(s = \"user@domain\") == \"u*****r@domain\"\n assert candidate(s = \"abcdefghij@klmno.pqr\") == \"a*****j@klmno.pqr\"\n assert candidate(s = \"Alice.Bob-Charlie.D@example.co.uk\") == \"a*****d@example.co.uk\"\n assert candidate(s = \"+1-234-567-89012\") == \"+**-***-***-9012\"\n assert candidate(s = \"(123) 456-7890; 123-456-7891; 123-456-7892\") == \"+********************-***-***-7892\"\n assert candidate(s = \"+44 (0) 1234 567890\") == \"+***-***-***-7890\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz@abc.def\") == \"a*****z@abc.def\"\n assert candidate(s = \"1-800-555-0199\") == \"+*-***-***-0199\"\n assert candidate(s = \"0012345678901\") == \"+***-***-***-8901\"\n assert candidate(s = \"+1234567890123\") == \"+***-***-***-0123\"\n assert candidate(s = \"user@domain.com\") == \"u*****r@domain.com\"\n assert candidate(s = \"abcdefg@hijklmnopqrstuvwxyz.co\") == \"a*****g@hijklmnopqrstuvwxyz.co\"\n assert candidate(s = \"+1 (234) 567-8901\") == \"+*-***-***-8901\"\n assert candidate(s = \"Nina.Nightly-Owl@Mailbox.ORG\") == \"n*****l@mailbox.org\"\n assert candidate(s = \"Name@Domain.co\") == \"n*****e@domain.co\"\n assert candidate(s = \"+91 12345 67890\") == \"+**-***-***-7890\"\n assert candidate(s = \"+33123456789\") == \"+*-***-***-6789\"\n assert candidate(s = \"user.name@sub.domain.co.uk\") == \"u*****e@sub.domain.co.uk\"\n assert candidate(s = \"234-567-8901\") == \"***-***-8901\"\n assert candidate(s = \"+358 (0)10 123 4567\") == \"+***-***-***-4567\"\n assert candidate(s = \"+1 (123) 456-7890x1234\") == \"+*****-***-***-1234\"\n assert candidate(s = \"user.name@sub.domain.com\") == \"u*****e@sub.domain.com\"\n assert candidate(s = \"123-4567-890\") == \"***-***-7890\"\n assert candidate(s = \"+33 (0)1 23 45 67 89\") == \"+**-***-***-6789\"\n assert candidate(s = \"+91-1234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"(+12) 123 456-7890x1234\") == \"+******-***-***-1234\"\n assert candidate(s = \"+44 1234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"A.B.C.D.E.F@domain.com\") == \"a*****f@domain.com\"\n assert candidate(s = \"(+1) 123 456 7890\") == \"+*-***-***-7890\"\n assert candidate(s = \"+1 800-555-0199 ext. 1234\") == \"+*****-***-***-1234\"\n assert candidate(s = \"+33 1 23 45 67 89\") == \"+*-***-***-6789\"\n assert candidate(s = \"++44-1234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"EMail+Address@domain.com\") == \"e*****s@domain.com\"\n assert candidate(s = \"abc-def@ghi.jkl.mno\") == \"a*****f@ghi.jkl.mno\"\n assert candidate(s = \"@domain.com\") == \"+-***-***-\"\n assert candidate(s = \"VeryLongFirstName.Last@website.org\") == \"v*****t@website.org\"\n assert candidate(s = \"+31 (6) 1234 5678\") == \"+*-***-***-5678\"\n assert candidate(s = \"(123) 4567 89012\") == \"+**-***-***-9012\"\n assert candidate(s = \"12345678901234567890\") == \"+**********-***-***-7890\"\n assert candidate(s = \"+123 (456) 7890-1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"++1-123-456-7890\") == \"+*-***-***-7890\"\n assert candidate(s = \"John_Doe-123@website.net\") == \"j*****3@website.net\"\n assert candidate(s = \"+44 1234 567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"(123) 456-7890x1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"(+12) 345-678-9012\") == \"+**-***-***-9012\"\n assert candidate(s = \"McDonalds.Restaurant@domain.co.in\") == \"m*****t@domain.co.in\"\n assert candidate(s = \"+55(11)1234-5678\") == \"+**-***-***-5678\"\n assert candidate(s = \"(123)4567890\") == \"***-***-7890\"\n assert candidate(s = \"123-456-7890\") == \"***-***-7890\"\n assert candidate(s = \"a.b.c.d.e@f.com\") == \"a*****e@f.com\"\n assert candidate(s = \"++33 6 12 34 56 78\") == \"+*-***-***-5678\"\n assert candidate(s = \"FOO@BAR.COM\") == \"f*****o@bar.com\"\n assert candidate(s = \"Elizabeth-II@royal.gov.uk\") == \"e*****i@royal.gov.uk\"\n assert candidate(s = \"+1 (123) 456-7890 ext 1234\") == \"+*****-***-***-1234\"\n assert candidate(s = \"++++1234567890\") == \"***-***-7890\"\n assert candidate(s = \"(123) 456 7890\") == \"***-***-7890\"\n assert candidate(s = \"(123) 456-7890, 123-456-7891, 123-456-7892\") == \"+********************-***-***-7892\"\n assert candidate(s = \"alice+bob.cathy@leetcode.com\") == \"a*****y@leetcode.com\"\n assert candidate(s = \"001 415 796 2345\") == \"+***-***-***-2345\"\n assert candidate(s = \"aBCdE@fGh.iJk\") == \"a*****e@fgh.ijk\"\n assert candidate(s = \"user.name+tag+sorting@example.com\") == \"u*****g@example.com\"\n assert candidate(s = \"+123-456-7890123\") == \"+***-***-***-0123\"\n assert candidate(s = \"(123) 456-7890, 123-456-7891\") == \"+**********-***-***-7891\"\n assert candidate(s = \"1234567890123456\") == \"+******-***-***-3456\"\n assert candidate(s = \"(123)456-789012\") == \"+**-***-***-9012\"\n assert candidate(s = \"++44 1234 567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"first.last@sub.domain.com\") == \"f*****t@sub.domain.com\"\n assert candidate(s = \"a.b.c@domain.com\") == \"a*****c@domain.com\"\n assert candidate(s = \"(012)-34567890\") == \"+*-***-***-7890\"\n assert candidate(s = \"firstname.lastname@sub.domain.co.uk\") == \"f*****e@sub.domain.co.uk\"\n assert candidate(s = \"++44(0)1234 567890\") == \"+***-***-***-7890\"\n assert candidate(s = \"+49 1234 5678901\") == \"+***-***-***-8901\"\n assert candidate(s = \"+49-89-636-48018\") == \"+**-***-***-8018\"\n assert candidate(s = \"john.doe@mywebsite.net\") == \"j*****e@mywebsite.net\"\n assert candidate(s = \"a@b.c\") == \"a*****a@b.c\"\n assert candidate(s = \"(123)-456-78901\") == \"+*-***-***-8901\"\n assert candidate(s = \"John.Doe123@example.co\") == \"j*****3@example.co\"\n assert candidate(s = \"(+44)1234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"+123 456 7890123\") == \"+***-***-***-0123\"\n assert candidate(s = \"eMail@Company.com\") == \"e*****l@company.com\"\n assert candidate(s = \"+1 (415) 796 2345\") == \"+*-***-***-2345\"\n assert candidate(s = \"Abc@xyz.co\") == \"a*****c@xyz.co\"\n assert candidate(s = \"(+12) 123 456-7890 ext 1234\") == \"+******-***-***-1234\"\n assert candidate(s = \"(123) 456-7890 (ext. 1234)\") == \"+****-***-***-1234\"\n assert candidate(s = \"Email@Subdomain.MyDomain.co.uk\") == \"e*****l@subdomain.mydomain.co.uk\"\n assert candidate(s = \"12345678901234\") == \"+****-***-***-1234\"\n assert candidate(s = \"user@.com\") == \"u*****r@.com\"\n assert candidate(s = \"USER.NAME@DOMAIN.COM\") == \"u*****e@domain.com\"\n assert candidate(s = \"123456789012345\") == \"+*****-***-***-2345\"\n assert candidate(s = \"FirstName.LastName@sub.domain.com\") == \"f*****e@sub.domain.com\"\n assert candidate(s = \"+86 123 4567 8901\") == \"+***-***-***-8901\"\n assert candidate(s = \"Foo@bar.com\") == \"f*****o@bar.com\"\n assert candidate(s = \"Alice.Bob.Clarke@mydomain.org\") == \"a*****e@mydomain.org\"\n assert candidate(s = \"Alice.Bob-Carol@domain.co.uk\") == \"a*****l@domain.co.uk\"\n assert candidate(s = \"++++1-234-567-8901\") == \"+*-***-***-8901\"\n assert candidate(s = \"FIRST.Last@domain.com\") == \"f*****t@domain.com\"\n assert candidate(s = \"user@sub.domain.com\") == \"u*****r@sub.domain.com\"\n assert candidate(s = \"++44 1234567890\") == \"+**-***-***-7890\"\n assert candidate(s = \"Alice.Bob-Jones@company.org\") == \"a*****s@company.org\"\n assert candidate(s = \"001-123-456-7890\") == \"+***-***-***-7890\"\n assert candidate(s = \"+358101234567\") == \"+**-***-***-4567\"\n assert candidate(s = \"987654321098765\") == \"+*****-***-***-8765\"\n assert candidate(s = \"(123)-456-7890\") == \"***-***-7890\"\n assert candidate(s = \"+49-123-456789-0\") == \"+**-***-***-7890\"\n assert candidate(s = \"-123-456-7890\") == \"***-***-7890\"\n assert candidate(s = \"+44(0)1234-567890\") == \"+***-***-***-7890\"\n assert candidate(s = \"9876543210123\") == \"+***-***-***-0123\"\n assert candidate(s = \"(123) 456-7890 x1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"Alice.Bob-Carol@domain.co\") == \"a*****l@domain.co\"\n assert candidate(s = \"A.B.C.D.E.F.G.H@subdomain.example.com\") == \"a*****h@subdomain.example.com\"\n assert candidate(s = \"(123) 456-7890; 123-456-7891\") == \"+**********-***-***-7891\"\n assert candidate(s = \"name@sub.sub.domain.com\") == \"n*****e@sub.sub.domain.com\"\n assert candidate(s = \"(123)456-7890\") == \"***-***-7890\"\n assert candidate(s = \"(123) 456-7890-1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"(123)456-7890-1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"valid.email@sub.domain.co.uk\") == \"v*****l@sub.domain.co.uk\"\n assert candidate(s = \"++1-234-567-8901\") == \"+*-***-***-8901\"\n assert candidate(s = \"+1 (123) 456-7890\") == \"+*-***-***-7890\"\n assert candidate(s = \"(123) 456-7890 ext 1234\") == \"+****-***-***-1234\"\n assert candidate(s = \"123456789012123\") == \"+*****-***-***-2123\"\n assert candidate(s = \"123-456-7890-1234\") == \"+****-***-***-1234\"\n", "comparison": "exact"}, "public_tests": ["\"LeetCode@LeetCode.com\"", "\"AB@qq.com\"", "\"1(234)567-890\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maskPII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:15+00:00", "tests_total": 187, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def maskPII(self, s: str) -> str:", "container": "Solution", "callable": "maskPII", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 832, "task_id": "flipping-an-image", "difficulty": "Easy", "problem_description": "Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.\n\nTo flip an image horizontally means that each row of the image is reversed.\n\n- For example, flipping [1,1,0] horizontally results in [0,1,1].\n\nTo invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0.\n\n- For example, inverting [0,1,1] results in [1,0,0].\n\nExample 1:\n\nInput: image = [[1,1,0],[1,0,1],[0,0,0]]\nOutput: [[1,0,0],[0,1,0],[1,1,1]]\nExplanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]].\nThen, invert the image: [[1,0,0],[0,1,0],[1,1,1]]\n\nExample 2:\n\nInput: image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]\nOutput: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]\nExplanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]].\nThen invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]\n\nConstraints:\n\n- n == image.length\n- n == image[i].length\n- 1 <= n <= 20\n- images[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(image = [[1, 1], [1, 0]]) == [[0, 0], [1, 0]]\n assert candidate(image = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 1], [1, 0, 1, 0]]) == [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1], [1, 0, 1, 0]]\n assert candidate(image = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == [[0, 1, 0], [1, 0, 1], [0, 1, 0]]\n assert candidate(image = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(image = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(image = [[1, 1, 0], [1, 0, 1], [0, 0, 0]]) == [[1, 0, 0], [0, 1, 0], [1, 1, 1]]\n assert candidate(image = [[0, 0, 0], [1, 1, 1], [0, 0, 0]]) == [[1, 1, 1], [0, 0, 0], [1, 1, 1]]\n assert candidate(image = [[1, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 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], [1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 1, 0], [1, 0, 1, 0, 0, 1]]\n assert candidate(image = [[0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]\n assert candidate(image = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[1, 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(image = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[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]]\n assert candidate(image = [[1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == [[1, 0, 0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]\n assert candidate(image = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 1, 0, 0]]) == [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 1, 0, 0, 0]]\n assert candidate(image = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 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, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 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]]\n assert candidate(image = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [1, 1, 0, 0, 1]]) == [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 1, 1, 0, 0]]\n assert candidate(image = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 0, 1, 1]]) == [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 1, 0, 0], [0, 1, 0, 1, 1], [0, 0, 1, 1, 0]]\n assert candidate(image = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 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], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]\n assert candidate(image = [[0, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 0, 1, 1]]) == [[1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1], [0, 0, 1, 1, 0, 1, 0]]\n assert candidate(image = [[1, 0, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0], [1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0], [1, 0, 1, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1, 1]]) == [[0, 1, 0, 1, 1, 1, 0], [1, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 0], [1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0]]\n assert candidate(image = [[0, 1, 1, 1, 0, 0, 1, 0], [1, 0, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 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]]) == [[1, 0, 1, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]\n assert candidate(image = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 0, 1]]) == [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 0]]\n assert candidate(image = [[0, 1, 1, 0, 1, 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, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [[0, 1, 0, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]\n assert candidate(image = [[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]]) == [[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]]\n assert candidate(image = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0]]) == [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 1]]\n assert candidate(image = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]\n assert candidate(image = [[0, 0, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 1, 0, 0]]) == [[1, 0, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 1], [1, 1, 0, 1, 0]]\n assert candidate(image = [[1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]\n assert candidate(image = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]\n assert candidate(image = [[0, 0, 1], [1, 0, 0], [0, 1, 0]]) == [[0, 1, 1], [1, 1, 0], [1, 0, 1]]\n assert candidate(image = [[1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == [[0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(image = [[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, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]]) == [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]\n assert candidate(image = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [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, 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]]) == [[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 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, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(image = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 1, 1, 1]]) == [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [0, 0, 0, 0, 0]]\n assert candidate(image = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == [[1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 1, 0, 0, 0]]\n assert candidate(image = [[0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1]]) == [[0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]]\n assert candidate(image = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) == [[0, 0, 0, 0], [1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]\n assert candidate(image = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]\n assert candidate(image = [[1, 0, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0, 0]]) == [[0, 1, 0, 1, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 1, 0, 0, 1, 0, 1, 1, 0]]\n assert candidate(image = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == [[0, 1, 0, 1], [1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 0, 0]]\n assert candidate(image = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]\n assert candidate(image = [[1, 1, 0, 1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 0, 1, 1, 0]]) == [[1, 0, 1, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1, 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, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 1, 0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 1, 0, 1, 0, 0, 1]]\n assert candidate(image = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0], [1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 1, 0, 0]]) == [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1]]\n assert candidate(image = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1, 1]]) == [[0, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 1, 0, 0, 1, 1, 0], [1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 0, 0]]\n assert candidate(image = [[1, 0, 0, 0, 1], [0, 1, 1, 0, 0], [1, 1, 0, 1, 1], [0, 0, 1, 1, 0], [1, 1, 1, 1, 1]]) == [[0, 1, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 0, 0], [1, 0, 0, 1, 1], [0, 0, 0, 0, 0]]\n assert candidate(image = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 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, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]\n assert candidate(image = [[0, 0, 0, 1, 1], [1, 0, 1, 0, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1], [0, 1, 0, 1, 0]]) == [[0, 0, 1, 1, 1], [1, 1, 0, 1, 0], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [1, 0, 1, 0, 1]]\n assert candidate(image = [[1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0]]) == [[0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1]]\n assert candidate(image = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]\n assert candidate(image = [[1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 1, 1, 0], [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, 0, 1, 1, 0, 0, 1]]) == [[0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1, 0], [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, 0, 1, 0]]\n assert candidate(image = [[0, 0, 0, 1], [1, 1, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == [[0, 1, 1, 1], [1, 0, 0, 0], [0, 1, 0, 1], [1, 0, 1, 0]]\n assert candidate(image = [[1, 0, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]]) == [[1, 0, 0, 1, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 0, 1, 1, 0], [0, 1, 0, 0, 1]]\n assert candidate(image = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [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, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]\n assert candidate(image = [[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, 1, 0, 1, 0]]) == [[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, 1]]\n", "comparison": "exact"}, "public_tests": ["[[1,1,0],[1,0,1],[0,0,0]]", "[[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["image"], "leetcode_dataset_entry_point": "Solution().flipAndInvertImage", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:17+00:00", "tests_total": 61, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "two-pointers", "bit-manipulation", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def flipAndInvertImage(self, image: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "flipAndInvertImage", "parameters": [{"name": "image", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 833, "task_id": "find-and-replace-in-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and targets, all of length k.\n\nTo complete the i^th replacement operation:\n\n1. Check if the substring sources[i] occurs at index indices[i] in the original string s.\n2. If it does not occur, do nothing.\n3. Otherwise if it does occur, replace that substring with targets[i].\n\nFor example, if s = \"abcd\", indices[i] = 0, sources[i] = \"ab\", and targets[i] = \"eee\", then the result of this replacement will be \"eeecd\".\n\nAll replacement operations must occur simultaneously, meaning the replacement operations should not affect the indexing of each other. The testcases will be generated such that the replacements will not overlap.\n\n- For example, a testcase with s = \"abc\", indices = [0, 1], and sources = [\"ab\",\"bc\"] will not be generated because the \"ab\" and \"bc\" replacements overlap.\n\nReturn the resulting string after performing all replacement operations on s.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: s = \"abcd\", indices = [0, 2], sources = [\"a\", \"cd\"], targets = [\"eee\", \"ffff\"]\nOutput: \"eeebffff\"\nExplanation:\n\"a\" occurs at index 0 in s, so we replace it with \"eee\".\n\"cd\" occurs at index 2 in s, so we replace it with \"ffff\".\n\nExample 2:\n\nInput: s = \"abcd\", indices = [0, 2], sources = [\"ab\",\"ec\"], targets = [\"eee\",\"ffff\"]\nOutput: \"eeecd\"\nExplanation:\n\"ab\" occurs at index 0 in s, so we replace it with \"eee\".\n\"ec\" does not occur at index 2 in s, so we do nothing.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- k == indices.length == sources.length == targets.length\n- 1 <= k <= 100\n- 0 <= indexes[i] < s.length\n- 1 <= sources[i].length, targets[i].length <= 50\n- s consists of only lowercase English letters.\n- sources[i] and targets[i] consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",indices = [0, 2],sources = ['a', 'cd'],targets = ['eee', 'ffff']) == \"eeebffff\"\n assert candidate(s = \"abcd\",indices = [0, 1, 2, 3],sources = ['a', 'b', 'c', 'd'],targets = ['aa', 'bb', 'cc', 'dd']) == \"aabbccdd\"\n assert candidate(s = \"abcd\",indices = [0, 2],sources = ['ab', 'ec'],targets = ['eee', 'ffff']) == \"eeecd\"\n assert candidate(s = \"vmokgggqzp\",indices = [3, 5, 1],sources = ['kg', 'gggg', 'mo'],targets = ['s', 'so', 'bfr']) == \"vbfrsggqzp\"\n assert candidate(s = \"hello\",indices = [1, 4],sources = ['el', 'o'],targets = ['ll', 'oo']) == \"hllloo\"\n assert candidate(s = \"aaaaabbbbb\",indices = [0, 5],sources = ['aaaaa', 'bbbbb'],targets = ['z', 'y']) == \"zy\"\n assert candidate(s = \"mississippi\",indices = [0, 4, 10],sources = ['mis', 'issi', 'i'],targets = ['xxx', 'yyy', 'zzz']) == \"xxxsyyyppzzz\"\n assert candidate(s = \"abababab\",indices = [0, 2, 4, 6],sources = ['ab', 'ab', 'ab', 'ab'],targets = ['xy', 'yz', 'zx', 'wv']) == \"xyyzzxwv\"\n assert candidate(s = \"ababababab\",indices = [0, 2, 4, 6, 8],sources = ['ab', 'ab', 'ab', 'ab', 'ab'],targets = ['xy', 'yx', 'xy', 'yx', 'xy']) == \"xyyxxyyxxy\"\n assert candidate(s = \"hellothere\",indices = [0, 5],sources = ['he', 'th'],targets = ['hola', 'allahuakbar']) == \"holalloallahuakbarere\"\n assert candidate(s = \"ababababab\",indices = [0, 2, 4, 6, 8],sources = ['ab', 'ab', 'ab', 'ab', 'ab'],targets = ['xy', 'xy', 'xy', 'xy', 'xy']) == \"xyxyxyxyxy\"\n assert candidate(s = \"mississippi\",indices = [0, 4, 6],sources = ['mis', 'sis', 'sip'],targets = ['miss', 'sis', 'sip']) == \"misssissippi\"\n assert candidate(s = \"ababab\",indices = [0, 2, 4],sources = ['ab', 'ab', 'ab'],targets = ['xy', 'yz', 'zx']) == \"xyyzzx\"\n assert candidate(s = \"hellothere\",indices = [0, 5],sources = ['hello', 'there'],targets = ['hi', 'bye']) == \"hibye\"\n assert candidate(s = \"aaaaaa\",indices = [0, 1, 2, 3, 4, 5],sources = ['a', 'a', 'a', 'a', 'a', 'a'],targets = ['b', 'c', 'd', 'e', 'f', 'g']) == \"bcdefg\"\n assert candidate(s = \"xxxyyyzzz\",indices = [0, 3, 6],sources = ['xxx', 'yyy', 'zzz'],targets = ['aaa', 'bbb', 'ccc']) == \"aaabbbccc\"\n assert candidate(s = \"thisisatest\",indices = [0, 2, 4, 6, 8, 10],sources = ['this', 'is', 'a', 'test', 'xx', 'xx'],targets = ['that', 'was', 'the', 'exam', 'yy', 'zz']) == \"thatisatest\"\n assert candidate(s = \"hellohellohello\",indices = [0, 5, 10],sources = ['hello', 'hello', 'hello'],targets = ['hi', 'ho', 'ha']) == \"hihoha\"\n assert candidate(s = \"mississippi\",indices = [1, 4, 7],sources = ['is', 'is', 'is'],targets = ['aa', 'bb', 'cc']) == \"maasbbsippi\"\n assert candidate(s = \"mississippi\",indices = [0, 4, 8],sources = ['mis', 'iss', 'ippi'],targets = ['misss', 'issii', 'ipppi']) == \"missssissiiippi\"\n assert candidate(s = \"hellothere\",indices = [0, 5],sources = ['hello', 'there'],targets = ['hi', 'world']) == \"hiworld\"\n assert candidate(s = \"banana\",indices = [0, 2, 4],sources = ['ba', 'na', 'na'],targets = ['xx', 'yy', 'zz']) == \"xxyyzz\"\n assert candidate(s = \"banana\",indices = [1, 3],sources = ['an', 'na'],targets = ['xx', 'yy']) == \"bxxana\"\n assert candidate(s = \"abracadabra\",indices = [0, 5, 7],sources = ['abra', 'a', 'abra'],targets = ['zzzz', 'x', 'yyyy']) == \"zzzzcxdyyyy\"\n assert candidate(s = \"programmingisfun\",indices = [3, 10, 15],sources = ['gram', 'is', 'fun'],targets = ['code', 'was', 'great']) == \"procodemingisfun\"\n assert candidate(s = \"abcdefg\",indices = [0, 3, 5],sources = ['abc', 'de', 'fg'],targets = ['xyz', 'qrs', 'tuv']) == \"xyzqrstuv\"\n", "comparison": "exact"}, "public_tests": ["\"abcd\"\n[0, 2]\n[\"a\", \"cd\"]\n[\"eee\", \"ffff\"]", "\"abcd\"\n[0, 2]\n[\"ab\",\"ec\"]\n[\"eee\",\"ffff\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "indices", "sources", "targets"], "leetcode_dataset_entry_point": "Solution().findReplaceString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:19+00:00", "tests_total": 96, "tests_dropped": 70, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def findReplaceString(self, s: str, indices: List[int], sources: List[str], targets: List[str]) -> str:", "container": "Solution", "callable": "findReplaceString", "parameters": [{"name": "s", "type": "str"}, {"name": "indices", "type": "List[int]"}, {"name": "sources", "type": "List[str]"}, {"name": "targets", "type": "List[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 834, "task_id": "sum-of-distances-in-tree", "difficulty": "Hard", "problem_description": "There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\n\nYou are given the integer n and the array edges where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree.\n\nReturn an array answer of length n where answer[i] is the sum of the distances between the i^th node in the tree and all other nodes.\n\nExample 1:\n\nInput: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]\nOutput: [8,12,6,10,10,10]\nExplanation: The tree is shown above.\nWe can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)\nequals 1 + 1 + 2 + 2 + 2 = 8.\nHence, answer[0] = 8, and so on.\n\nExample 2:\n\nInput: n = 1, edges = []\nOutput: [0]\n\nExample 3:\n\nInput: n = 2, edges = [[1,0]]\nOutput: [1,1]\n\nConstraints:\n\n- 1 <= n <= 3 * 10^4\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- The given input represents a valid tree.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [15, 19, 19, 19, 27, 27, 27, 27, 27, 27]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [10, 11, 11, 16, 16, 16, 16]\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]]) == [5, 3, 5, 5]\n assert candidate(n = 4,edges = [[0, 1], [0, 2], [1, 3]]) == [4, 4, 6, 6]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == [17, 11, 13, 13, 19, 19, 19, 19]\n assert candidate(n = 2,edges = [[1, 0]]) == [1, 1]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]]) == [2, 3, 3]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [2, 5]]) == [8, 12, 6, 10, 10, 10]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [2, 3], [2, 4]]) == [6, 9, 5, 8, 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]]) == [19, 17, 23, 21, 23, 31, 31, 29, 29, 31]\n assert candidate(n = 1,edges = []) == [0]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]]) == [6, 5, 9, 8, 8]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [2, 5], [4, 6]]) == [11, 16, 8, 13, 11, 13, 16]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11]]) == [11, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 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]]) == [50, 46, 56, 56, 60, 60, 70, 70, 70, 74, 78, 78, 78, 78, 88, 88, 88, 88, 88, 88]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11]]) == [23, 21, 27, 27, 29, 31, 37, 37, 37, 37, 37, 39]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [5, 13], [5, 14]]) == [28, 31, 35, 35, 42, 40, 48, 48, 48, 48, 48, 48, 55, 53, 53]\n assert candidate(n = 30,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], [5, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24], [9, 25], [9, 26], [10, 27], [10, 28], [11, 29]]) == [67, 77, 77, 87, 89, 101, 101, 101, 101, 101, 101, 113, 115, 115, 117, 117, 117, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 141]\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], [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], [10, 31], [10, 32], [10, 33], [11, 34], [11, 35], [11, 36], [12, 37], [12, 38], [12, 39], [13, 40], [13, 41], [13, 42], [14, 43], [14, 44], [14, 45], [15, 46], [15, 47], [15, 48], [16, 49]]) == [142, 146, 166, 166, 170, 186, 188, 208, 208, 208, 208, 208, 208, 212, 212, 212, 232, 234, 234, 236, 236, 236, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 260, 260, 260, 260, 260, 260, 260, 260, 260, 280]\n assert candidate(n = 30,edges = [[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], [6, 18], [6, 19], [6, 20], [7, 21], [7, 22], [7, 23], [8, 24], [8, 25], [8, 26], [9, 27], [9, 28], [9, 29]]) == [80, 78, 84, 94, 100, 100, 106, 106, 106, 116, 122, 122, 128, 128, 128, 128, 128, 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, 144, 144, 144]\n assert candidate(n = 20,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]]) == [41, 47, 49, 55, 55, 61, 61, 63, 65, 73, 73, 73, 73, 79, 79, 79, 79, 81, 81, 83]\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]]) == [30, 31, 37, 39, 40, 40, 48, 50, 52, 52, 53, 53, 53, 53, 61]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 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], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24]]) == [69, 62, 78, 73, 77, 81, 95, 97, 92, 92, 96, 100, 104, 104, 118, 118, 118, 120, 120, 115, 115, 115, 115, 119, 119]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 16], [4, 17], [5, 18], [5, 19], [6, 20], [6, 21], [7, 22], [7, 23], [8, 24], [8, 25], [9, 26], [9, 27], [10, 28], [10, 29]]) == [69, 73, 77, 89, 97, 97, 97, 97, 101, 101, 101, 105, 117, 117, 117, 117, 125, 125, 125, 125, 125, 125, 125, 125, 129, 129, 129, 129, 129, 129]\n assert candidate(n = 22,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], [12, 20], [13, 21]]) == [62, 62, 64, 74, 74, 76, 78, 92, 92, 92, 92, 94, 94, 96, 98, 112, 112, 112, 112, 114, 114, 116]\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]]) == [57, 62, 62, 74, 81, 81, 81, 81, 81, 81, 97, 97, 97, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104]\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]]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\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]]) == [46, 44, 50, 52, 54, 62, 62, 66, 66, 68, 70, 78, 78, 78, 78, 82, 82, 84]\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]]) == [34, 35, 35, 44, 44, 44, 44, 57, 57, 57, 57, 57, 57, 57, 57]\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]]) == [26, 26, 28, 32, 34, 36, 36, 40, 44, 46, 46, 50]\n assert candidate(n = 30,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]]) == [83, 83, 99, 99, 99, 99, 123, 123, 123, 123, 123, 123, 123, 123, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151]\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], [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], [10, 31], [10, 32], [10, 33], [11, 34]]) == [87, 96, 96, 106, 123, 123, 123, 123, 123, 123, 133, 137, 139, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 166, 166, 166, 170]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9]]) == [19, 17, 23, 23, 21, 31, 31, 31, 29, 29]\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]]) == [74, 69, 81, 80, 80, 96, 100, 99, 99, 99, 99, 115, 119, 123, 123, 122, 122, 122, 122, 122, 122, 122, 122, 138, 138]\n assert candidate(n = 12,edges = [[0, 1], [0, 5], [1, 2], [1, 3], [1, 4], [5, 6], [5, 7], [5, 8], [8, 9], [8, 10], [8, 11]]) == [23, 27, 37, 37, 37, 21, 31, 31, 25, 35, 35, 35]\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], [5, 17], [6, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24]]) == [57, 58, 66, 74, 77, 75, 75, 85, 85, 89, 97, 97, 97, 100, 100, 98, 98, 98, 98, 98, 98, 108, 108, 108, 108]\n assert candidate(n = 27,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], [10, 21], [11, 22], [12, 23], [12, 24], [13, 25], [14, 26]]) == [82, 81, 85, 94, 96, 100, 102, 115, 115, 119, 117, 123, 121, 125, 125, 140, 140, 140, 140, 144, 142, 142, 148, 146, 146, 150, 150]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19]]) == [43, 49, 47, 55, 63, 63, 61, 61, 65, 73, 73, 73, 81, 81, 81, 81, 79, 79, 79, 79]\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]]) == [54, 50, 60, 56, 62, 74, 74, 70, 70, 78, 80, 92, 92, 92, 92, 88, 88, 88, 88, 96]\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]]) == [94, 94, 96, 110, 110, 112, 114, 134, 134, 134, 134, 136, 136, 138, 140, 162, 162, 162, 162, 162, 162, 162, 162, 164, 164, 164, 164, 166, 166, 168]\n", "comparison": "exact"}, "public_tests": ["6\n[[0,1],[0,2],[2,3],[2,4],[2,5]]", "1\n[]", "2\n[[1,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().sumOfDistancesInTree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:21+00:00", "tests_total": 40, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming", "tree", "depth-first-search", "graph", "dp-on-trees"]}, "language": "python", "interface": {"raw_signature": "def sumOfDistancesInTree(self, n: int, edges: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "sumOfDistancesInTree", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 835, "task_id": "image-overlap", "difficulty": "Medium", "problem_description": "You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values.\n\nWe translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calculate the overlap by counting the number of positions that have a 1 in both images.\n\nNote also that a translation does not include any kind of rotation. Any 1 bits that are translated outside of the matrix borders are erased.\n\nReturn the largest possible overlap.\n\nExample 1:\n\nInput: img1 = [[1,1,0],[0,1,0],[0,1,0]], img2 = [[0,0,0],[0,1,1],[0,0,1]]\nOutput: 3\nExplanation: We translate img1 to right by 1 unit and down by 1 unit.\n\nThe number of positions that have a 1 in both images is 3 (shown in red).\n\nExample 2:\n\nInput: img1 = [[1]], img2 = [[1]]\nOutput: 1\n\nExample 3:\n\nInput: img1 = [[0]], img2 = [[0]]\nOutput: 0\n\nConstraints:\n\n- n == img1.length == img1[i].length\n- n == img2.length == img2[i].length\n- 1 <= n <= 30\n- img1[i][j] is either 0 or 1.\n- img2[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(img1 = [[1, 1, 0], [0, 1, 0], [0, 1, 0]],img2 = [[0, 0, 0], [0, 1, 1], [0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 1], [1, 1]]) == 2\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[0, 1, 0], [1, 1, 1], [0, 1, 0]]) == 5\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(img1 = [[1]],img2 = [[1]]) == 1\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(img1 = [[1, 1], [1, 1]],img2 = [[0, 0], [0, 0]]) == 0\n assert candidate(img1 = [[0]],img2 = [[0]]) == 0\n assert candidate(img1 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],img2 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 5\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 1], [1, 0]]) == 1\n assert candidate(img1 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],img2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 0], [0, 1]]) == 2\n assert candidate(img1 = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]],img2 = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == 6\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n assert candidate(img1 = [[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]],img2 = [[0, 0, 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(img1 = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 0]],img2 = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[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]],img2 = [[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(img1 = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0]],img2 = [[1, 0, 0, 1, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1]]) == 10\n assert candidate(img1 = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]],img2 = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(img1 = [[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]],img2 = [[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(img1 = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],img2 = [[1, 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(img1 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],img2 = [[1, 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(img1 = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 3\n assert candidate(img1 = [[1, 1, 1, 0], [1, 0, 0, 1], [0, 1, 0, 1], [1, 0, 1, 0]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == 3\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 8\n assert candidate(img1 = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],img2 = [[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(img1 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],img2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[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]],img2 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 9\n assert candidate(img1 = [[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, 0], [0, 0, 0, 0, 0, 0]],img2 = [[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, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]],img2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],img2 = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 0, 0], [1, 1, 0, 0]]) == 4\n assert candidate(img1 = [[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]],img2 = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[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]],img2 = [[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]]) == 9\n assert candidate(img1 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],img2 = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == 1\n assert candidate(img1 = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],img2 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 10\n assert candidate(img1 = [[0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0]],img2 = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[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]],img2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[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]],img2 = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],img2 = [[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(img1 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],img2 = [[0, 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(img1 = [[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]],img2 = [[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]]) == 4\n assert candidate(img1 = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],img2 = [[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]]) == 4\n assert candidate(img1 = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 1, 1]],img2 = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == 5\n assert candidate(img1 = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],img2 = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 6\n assert candidate(img1 = [[1, 1, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 1]],img2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]],img2 = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 0, 1]],img2 = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 1, 0, 0]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]],img2 = [[0, 0, 1, 1], [1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 0, 0]]) == 4\n assert candidate(img1 = [[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]],img2 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 6\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 1\n assert candidate(img1 = [[1, 1, 1, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]],img2 = [[1, 0, 0, 1], [1, 1, 0, 0], [0, 1, 1, 0], [0, 1, 0, 1]]) == 5\n assert candidate(img1 = [[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]],img2 = [[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]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],img2 = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 4\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0]]) == 6\n assert candidate(img1 = [[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]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],img2 = [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 2\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 0, 1], [0, 0, 1, 0]],img2 = [[0, 0, 1, 0], [1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1]]) == 6\n assert candidate(img1 = [[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]],img2 = [[0, 0, 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(img1 = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],img2 = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]]) == 4\n assert candidate(img1 = [[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]],img2 = [[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]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]],img2 = [[0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 8\n assert candidate(img1 = [[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]],img2 = [[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]]) == 8\n assert candidate(img1 = [[0, 1, 1, 1], [1, 1, 1, 0], [1, 1, 1, 0], [0, 1, 1, 1]],img2 = [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]) == 6\n assert candidate(img1 = [[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]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]],img2 = [[0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],img2 = [[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]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],img2 = [[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]]) == 1\n assert candidate(img1 = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],img2 = [[0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0]]) == 9\n", "comparison": "exact"}, "public_tests": ["[[1,1,0],[0,1,0],[0,1,0]]\n[[0,0,0],[0,1,1],[0,0,1]]", "[[1]]\n[[1]]", "[[0]]\n[[0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["img1", "img2"], "leetcode_dataset_entry_point": "Solution().largestOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:23+00:00", "tests_total": 75, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def largestOverlap(self, img1: list[list[int]], img2: list[list[int]]) -> int:", "container": "Solution", "callable": "largestOverlap", "parameters": [{"name": "img1", "type": "list[list[int]]"}, {"name": "img2", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 836, "task_id": "rectangle-overlap", "difficulty": "Easy", "problem_description": "An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.\n\nTwo rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.\n\nGiven two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.\n\nExample 1:\n\nInput: rec1 = [0,0,2,2], rec2 = [1,1,3,3]\nOutput: true\n\nExample 2:\n\nInput: rec1 = [0,0,1,1], rec2 = [1,0,2,1]\nOutput: false\n\nExample 3:\n\nInput: rec1 = [0,0,1,1], rec2 = [2,2,3,3]\nOutput: false\n\nConstraints:\n\n- rec1.length == 4\n- rec2.length == 4\n- -10^9 <= rec1[i], rec2[i] <= 10^9\n- rec1 and rec2 represent a valid rectangle with a non-zero area.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rec1 = [-5, -5, -3, -3],rec2 = [-4, -4, -2, -2]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [4, 4, 8, 8]) == True\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-4, -4, -1, -1]) == True\n assert candidate(rec1 = [-2, -2, 0, 0],rec2 = [-1, -1, 1, 1]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [0, 0, 3, 3]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [1, 1, 6, 6]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [8, 8, 15, 15]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 5, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [2, 2, 3, 3]) == False\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [2, 2, 4, 4]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [2, 2, 3, 3]) == False\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [0, 0, 1, 1]) == False\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [10, 10, 15, 15]) == False\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [11, 11, 16, 16]) == False\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 0, 2, 1]) == False\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-3, -3, -1, -1]) == True\n assert candidate(rec1 = [0, 0, 2, 2],rec2 = [1, 1, 3, 3]) == True\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [6, 6, 11, 11]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [-200000000, -200000000, -100000000, -100000000],rec2 = [-150000000, -150000000, -50000000, -50000000]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [10, 10, 20, 20]) == False\n assert candidate(rec1 = [0, 0, 2, 2],rec2 = [1, -1, 3, 1]) == True\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 3, 5, 6]) == True\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 3, 4, 5]) == True\n assert candidate(rec1 = [0, 0, 1000, 1000],rec2 = [500, 500, 1500, 1500]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 0, 0]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 5, 10, 10]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 45, 55]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [6, 6, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 0, 10, 5]) == False\n assert candidate(rec1 = [-5, 0, 5, 10],rec2 = [0, -10, 10, 0]) == False\n assert candidate(rec1 = [100, 200, 300, 400],rec2 = [250, 250, 350, 350]) == True\n assert candidate(rec1 = [1000, 1000, 2000, 2000],rec2 = [500, 500, 1500, 1500]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, -5, 15, 5]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0.9, 0.9, 2, 2]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 1000000000, 1000000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [-1, -1, 0, 0]) == False\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [0, 0, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [50, 50, 150, 150]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, 5, 15, 15]) == True\n assert candidate(rec1 = [-5, -5, 5, 5],rec2 = [-10, -10, -5, -5]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 35, 45]) == True\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [99, 99, 200, 200]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0.5, 0.5, 1.5, 1.5]) == True\n assert candidate(rec1 = [10, 10, 15, 15],rec2 = [12, 12, 18, 18]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [5, 5, 15, 15]) == True\n assert candidate(rec1 = [-100, 100, -50, 150],rec2 = [-75, 125, -25, 175]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [2, 2, 3, 3]) == True\n assert candidate(rec1 = [-100, -200, -50, -150],rec2 = [-75, -175, -25, -125]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [0, 5, 5, 10]) == False\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0, 1, 1, 2]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [15, 15, 25, 25]) == True\n assert candidate(rec1 = [-10, 20, -5, 25],rec2 = [-7, 15, -2, 22]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0, -1, 1, 0]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, -5, 15, 5]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [10, 10, 20, 20]) == True\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [200, 200, 300, 300]) == False\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [5, 5, 9, 9]) == False\n assert candidate(rec1 = [-1, 0, 0, 1],rec2 = [0, -1, 1, 0]) == False\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [-10, -20, -5, -15],rec2 = [-7, -18, -3, -12]) == True\n assert candidate(rec1 = [-10, -10, 10, 10],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [1, 6, 5, 10]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [10, 0, 20, 10]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [4, 3, 5, 2]) == False\n assert candidate(rec1 = [-1000000000, -1000000000, 1000000000, 1000000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [1, 1, 6, 6]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 0, 2, 1]) == False\n assert candidate(rec1 = [100000000, 100000000, 200000000, 200000000],rec2 = [150000000, 150000000, 250000000, 250000000]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [6, 1, 10, 5]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 45, 55]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [3, 4, 5, 6]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [9, 9, 11, 11]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1.5, 1.5, 2.5, 2.5]) == False\n assert candidate(rec1 = [1000, 1000, 2000, 2000],rec2 = [1500, 1500, 2500, 2500]) == True\n assert candidate(rec1 = [-10, -10, 10, 10],rec2 = [9, 9, 20, 20]) == True\n assert candidate(rec1 = [-500000000, -500000000, 500000000, 500000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [90, 90, 200, 200]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [4, 4, 7, 7]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [21, 21, 30, 30]) == False\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [-5, -5, 0, 0]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [20, 20, 30, 30]) == False\n assert candidate(rec1 = [2, 2, 5, 5],rec2 = [5, 5, 8, 8]) == False\n assert candidate(rec1 = [1, 2, 4, 5],rec2 = [3, 3, 6, 6]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [-10, -10, 0, 0]) == False\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [-100, -100, 0, 0],rec2 = [-50, -50, 50, 50]) == True\n assert candidate(rec1 = [-1000000, -1000000, -900000, -900000],rec2 = [-950000, -950000, -850000, -850000]) == True\n assert candidate(rec1 = [-100, -100, 0, 0],rec2 = [0, 0, 100, 100]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 30, 35, 45]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0.5, 0.5, 1.5, 1.5]) == True\n assert candidate(rec1 = [-20, -20, -10, -10],rec2 = [-15, -15, -5, -5]) == True\n assert candidate(rec1 = [15, 25, 30, 45],rec2 = [20, 30, 40, 50]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [1.5, 1.5, 2.5, 2.5]) == True\n assert candidate(rec1 = [1, 1, 10, 10],rec2 = [5, 5, 5, 10]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 0, 0]) == True\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [150, 150, 250, 250]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 1, 4, 3]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [-5, -5, 0, 0]) == False\n assert candidate(rec1 = [-2, -2, 2, 2],rec2 = [2, 2, 4, 4]) == False\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [50, 50, 150, 150]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 2, 2]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [15, 15, 25, 25]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 0, 0],rec2 = [-500000000, -500000000, 500000000, 500000000]) == True\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [20, 20, 30, 30]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [2, 2, 8, 8]) == True\n assert candidate(rec1 = [-10, -10, -5, -5],rec2 = [-8, -8, -3, -3]) == True\n assert candidate(rec1 = [-1000, -1000, 1000, 1000],rec2 = [-2000, -2000, 0, 0]) == True\n assert candidate(rec1 = [5, 5, 15, 15],rec2 = [5, 15, 15, 25]) == False\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [150, 150, 250, 250]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [0, 0, 100, 100]) == True\n assert candidate(rec1 = [-1, -2, 1, 2],rec2 = [-2, -3, 2, 3]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 0, 0],rec2 = [-500000000, -500000000, 500000000, 500000000]) == True\n", "comparison": "exact"}, "public_tests": ["[0,0,2,2]\n[1,1,3,3]", "[0,0,1,1]\n[1,0,2,1]", "[0,0,1,1]\n[2,2,3,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["rec1", "rec2"], "leetcode_dataset_entry_point": "Solution().isRectangleOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:26+00:00", "tests_total": 122, "tests_dropped": 3, "flags": [], "topic_tags": ["math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def isRectangleOverlap(self, rec1: list[int], rec2: list[int]) -> bool:", "container": "Solution", "callable": "isRectangleOverlap", "parameters": [{"name": "rec1", "type": "list[int]"}, {"name": "rec2", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 837, "task_id": "new-21-game", "difficulty": "Medium", "problem_description": "Alice plays the following game, loosely based on the card game \"21\".\n\nAlice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number of points randomly from the range [1, maxPts], where maxPts is an integer. Each draw is independent and the outcomes have equal probabilities.\n\nAlice stops drawing numbers when she gets k or more points.\n\nReturn the probability that Alice has n or fewer points.\n\nAnswers within 10^-5 of the actual answer are considered accepted.\n\nExample 1:\n\nInput: n = 10, k = 1, maxPts = 10\nOutput: 1.00000\nExplanation: Alice gets a single card, then stops.\n\nExample 2:\n\nInput: n = 6, k = 1, maxPts = 10\nOutput: 0.60000\nExplanation: Alice gets a single card, then stops.\nIn 6 out of 10 possibilities, she is at or below 6 points.\n\nExample 3:\n\nInput: n = 21, k = 17, maxPts = 10\nOutput: 0.73278\n\nConstraints:\n\n- 0 <= k <= n <= 10^4\n- 1 <= maxPts <= 10^4\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=10, k=5, maxPts=5), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=20), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=5), 1.0)\n assert answers_match(candidate(n=6, k=1, maxPts=10), 0.6)\n assert answers_match(candidate(n=10000, k=0, maxPts=10000), 1)\n assert answers_match(candidate(n=10, k=1, maxPts=10), 1.0)\n assert answers_match(candidate(n=21, k=17, maxPts=10), 0.7327777870686083)\n assert answers_match(candidate(n=20, k=15, maxPts=5), 1.0)\n assert answers_match(candidate(n=0, k=0, maxPts=1), 1)\n assert answers_match(candidate(n=100, k=90, maxPts=5), 1.0)\n assert answers_match(candidate(n=5, k=3, maxPts=2), 1.0)\n assert answers_match(candidate(n=20, k=0, maxPts=10), 1)\n assert answers_match(candidate(n=15, k=15, maxPts=10), 0.18009983358324094)\n assert answers_match(candidate(n=75, k=50, maxPts=20), 1.0)\n assert answers_match(candidate(n=25, k=25, maxPts=5), 0.3333044673513253)\n assert answers_match(candidate(n=100, k=100, maxPts=1), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=50), 1.0)\n assert answers_match(candidate(n=30, k=25, maxPts=5), 1.0)\n assert answers_match(candidate(n=200, k=150, maxPts=50), 1.0)\n assert answers_match(candidate(n=75, k=30, maxPts=30), 1.0)\n assert answers_match(candidate(n=9999, k=0, maxPts=100), 1)\n assert answers_match(candidate(n=45, k=45, maxPts=10), 0.18183615529245928)\n assert answers_match(candidate(n=50, k=30, maxPts=20), 1.0)\n assert answers_match(candidate(n=100, k=80, maxPts=20), 1.0)\n assert answers_match(candidate(n=500, k=400, maxPts=50), 1.0)\n assert answers_match(candidate(n=50, k=40, maxPts=10), 1.0)\n assert answers_match(candidate(n=60, k=55, maxPts=10), 0.818177813346613)\n assert answers_match(candidate(n=60, k=30, maxPts=10), 1.0)\n assert answers_match(candidate(n=100, k=0, maxPts=1), 1)\n assert answers_match(candidate(n=200, k=150, maxPts=30), 1.0)\n assert answers_match(candidate(n=15, k=10, maxPts=5), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=25), 1.0)\n assert answers_match(candidate(n=50, k=25, maxPts=20), 1.0)\n assert answers_match(candidate(n=80, k=40, maxPts=15), 1.0)\n assert answers_match(candidate(n=80, k=70, maxPts=10), 1.0)\n assert answers_match(candidate(n=90, k=85, maxPts=5), 1.0)\n assert answers_match(candidate(n=750, k=300, maxPts=50), 1.0)\n assert answers_match(candidate(n=30, k=25, maxPts=10), 0.8193954028011721)\n assert answers_match(candidate(n=500, k=250, maxPts=100), 1.0)\n assert answers_match(candidate(n=15, k=7, maxPts=5), 1.0)\n assert answers_match(candidate(n=80, k=20, maxPts=3), 1.0)\n assert answers_match(candidate(n=15, k=15, maxPts=1), 1.0)\n assert answers_match(candidate(n=80, k=60, maxPts=10), 1.0)\n assert answers_match(candidate(n=25, k=25, maxPts=1), 1.0)\n assert answers_match(candidate(n=25, k=0, maxPts=25), 1)\n assert answers_match(candidate(n=300, k=1, maxPts=100), 1.0)\n assert answers_match(candidate(n=30, k=20, maxPts=10), 1.0)\n assert answers_match(candidate(n=25, k=20, maxPts=15), 0.6217079716932831)\n assert answers_match(candidate(n=25, k=20, maxPts=5), 1.0)\n assert answers_match(candidate(n=120, k=90, maxPts=20), 1.0)\n assert answers_match(candidate(n=70, k=60, maxPts=3), 1.0)\n assert answers_match(candidate(n=15, k=10, maxPts=3), 1.0)\n assert answers_match(candidate(n=90, k=75, maxPts=12), 1.0)\n assert answers_match(candidate(n=50, k=25, maxPts=5), 1.0)\n assert answers_match(candidate(n=75, k=50, maxPts=25), 1.0)\n assert answers_match(candidate(n=40, k=0, maxPts=5), 1)\n assert answers_match(candidate(n=200, k=150, maxPts=10), 1.0)\n assert answers_match(candidate(n=70, k=10, maxPts=30), 1.0)\n assert answers_match(candidate(n=150, k=100, maxPts=15), 1.0)\n assert answers_match(candidate(n=30, k=15, maxPts=10), 1.0)\n assert answers_match(candidate(n=100, k=90, maxPts=10), 1.0)\n assert answers_match(candidate(n=30, k=15, maxPts=5), 1.0)\n assert answers_match(candidate(n=90, k=80, maxPts=5), 1.0)\n", "comparison": "float"}, "public_tests": ["10\n1\n10", "6\n1\n10", "21\n17\n10"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "k", "maxPts"], "leetcode_dataset_entry_point": "Solution().new21Game", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:28+00:00", "tests_total": 63, "tests_dropped": 0, "flags": ["decimal_answer"], "topic_tags": ["math", "dynamic-programming", "sliding-window", "probability-and-statistics"]}, "language": "python", "interface": {"raw_signature": "def new21Game(self, n: int, k: int, maxPts: int) -> float:", "container": "Solution", "callable": "new21Game", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}, {"name": "maxPts", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 838, "task_id": "push-dominoes", "difficulty": "Medium", "problem_description": "There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.\n\nAfter each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right.\n\nWhen a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces.\n\nFor the purposes of this question, we will consider that a falling domino expends no additional force to a falling or already fallen domino.\n\nYou are given a string dominoes representing the initial state where:\n\n- dominoes[i] = 'L', if the i^th domino has been pushed to the left,\n- dominoes[i] = 'R', if the i^th domino has been pushed to the right, and\n- dominoes[i] = '.', if the i^th domino has not been pushed.\n\nReturn a string representing the final state.\n\nExample 1:\n\nInput: dominoes = \"RR.L\"\nOutput: \"RR.L\"\nExplanation: The first domino expends no additional force on the second domino.\n\nExample 2:\n\nInput: dominoes = \".L.R...LR..L..\"\nOutput: \"LL.RR.LLRRLL..\"\n\nConstraints:\n\n- n == dominoes.length\n- 1 <= n <= 10^5\n- dominoes[i] is either 'L', 'R', or '.'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dominoes = \"R..L\") == \"RRLL\"\n assert candidate(dominoes = \"..R......L..\") == \"..RRRRLLLL..\"\n assert candidate(dominoes = \"RRRRRRRRRR\") == \"RRRRRRRRRR\"\n assert candidate(dominoes = \"L........R\") == \"L........R\"\n assert candidate(dominoes = \"L.R...R.L\") == \"L.RRRRR.L\"\n assert candidate(dominoes = \"LLLLL\") == \"LLLLL\"\n assert candidate(dominoes = \"LLRRLLRRLL\") == \"LLRRLLRRLL\"\n assert candidate(dominoes = \"LLLLLLLLLL\") == \"LLLLLLLLLL\"\n assert candidate(dominoes = \"LLRRLLRR\") == \"LLRRLLRR\"\n assert candidate(dominoes = \"RRRRR\") == \"RRRRR\"\n assert candidate(dominoes = \".L.R...LR..L..\") == \"LL.RR.LLRRLL..\"\n assert candidate(dominoes = \"........\") == \"........\"\n assert candidate(dominoes = \"R........\") == \"RRRRRRRRR\"\n assert candidate(dominoes = \"RRRRRRRRR\") == \"RRRRRRRRR\"\n assert candidate(dominoes = \"R....L\") == \"RRRLLL\"\n assert candidate(dominoes = \"L.L.L\") == \"LLLLL\"\n assert candidate(dominoes = \"R.L.R.L.R\") == \"R.L.R.L.R\"\n assert candidate(dominoes = \"R......L\") == \"RRRRLLLL\"\n assert candidate(dominoes = \"L.R.L\") == \"L.R.L\"\n assert candidate(dominoes = \"LR.LR.LR.LR\") == \"LR.LR.LR.LR\"\n assert candidate(dominoes = \"R........L\") == \"RRRRRLLLLL\"\n assert candidate(dominoes = \".....\") == \".....\"\n assert candidate(dominoes = \"R.R.L.L.R\") == \"RRR.LLL.R\"\n assert candidate(dominoes = \"R......R.L\") == \"RRRRRRRR.L\"\n assert candidate(dominoes = \"RR.L\") == \"RR.L\"\n assert candidate(dominoes = \"L.R.R.L.L.R.L.R.L.L.R.L.R.L.L.R.L.R.L\") == \"L.RRR.LLL.R.L.R.LLL.R.L.R.LLL.R.L.R.L\"\n assert candidate(dominoes = \"........L\") == \"LLLLLLLLL\"\n assert candidate(dominoes = \"RLRLRLRL\") == \"RLRLRLRL\"\n assert candidate(dominoes = \"R.....L\") == \"RRR.LLL\"\n assert candidate(dominoes = \"R.R.L\") == \"RRR.L\"\n assert candidate(dominoes = \"L.R.L.R.L\") == \"L.R.L.R.L\"\n assert candidate(dominoes = \".......\") == \".......\"\n assert candidate(dominoes = \"L.R.R.L.L.R\") == \"L.RRR.LLL.R\"\n assert candidate(dominoes = \"LLLLLLLLL\") == \"LLLLLLLLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"............R.L...........\") == \"............R.L...........\"\n assert candidate(dominoes = \"R.....L.....R.....L\") == \"RRR.LLL.....RRR.LLL\"\n assert candidate(dominoes = \"L...R...L...R...L\") == \"L...RR.LL...RR.LL\"\n assert candidate(dominoes = \"L...R.L...R.L...R.L\") == \"L...R.L...R.L...R.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R......L.R.L......R\") == \"RRRRLLLL.R.L......R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.R\") == \"L.R.L.R.L.R.L.RRR\"\n assert candidate(dominoes = \"L.....R.L.....R.L.....R\") == \"L.....R.L.....R.L.....R\"\n assert candidate(dominoes = \"...R...L...R...L...\") == \"...RR.LL...RR.LL...\"\n assert candidate(dominoes = \"R...L...R...L...R...L\") == \"RR.LL...RR.LL...RR.LL\"\n assert candidate(dominoes = \"R.L.R.L.R.L\") == \"R.L.R.L.R.L\"\n assert candidate(dominoes = \".......L........R\") == \"LLLLLLLL........R\"\n assert candidate(dominoes = \"R...L.L...R.R...L\") == \"RR.LLLL...RRRR.LL\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.L.L.L.L.L\") == \"RRRRRRRRRRRRR.LLLLLLLLL\"\n assert candidate(dominoes = \"...R.L.L.R.L.L.R.L...\") == \"...R.LLL.R.LLL.R.L...\"\n assert candidate(dominoes = \"LLLLLLLLLLRRRRRRRRRR\") == \"LLLLLLLLLLRRRRRRRRRR\"\n assert candidate(dominoes = \"L........R........L\") == \"L........RRRRRLLLLL\"\n assert candidate(dominoes = \"L......R.R......L.L......R\") == \"L......RRRRRRLLLLLL......R\"\n assert candidate(dominoes = \"L.R.R.L.L.R.R.L.L\") == \"L.RRR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.R.L\") == \"L.R.L.R.L.R.L.RRR.L\"\n assert candidate(dominoes = \"R.......L.L.......R.R.......L\") == \"RRRR.LLLLLL.......RRRRRR.LLLL\"\n assert candidate(dominoes = \"L.R.R...L.R.L.R.L\") == \"L.RRRR.LL.R.L.R.L\"\n assert candidate(dominoes = \"RL.R.L.RL.R.L.RL\") == \"RL.R.L.RL.R.L.RL\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"RLRLRLRLRLRLRLRLRL\") == \"RLRLRLRLRLRLRLRLRL\"\n assert candidate(dominoes = \"R....L.R.L....L\") == \"RRRLLL.R.LLLLLL\"\n assert candidate(dominoes = \"RRRR.L.L.R..L.RR.L\") == \"RRRR.LLL.RRLL.RR.L\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL\"\n assert candidate(dominoes = \"R.L...L.R.R...L.L.R.L...L\") == \"R.LLLLL.RRRR.LLLL.R.LLLLL\"\n assert candidate(dominoes = \"RR.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"RR.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R.....L.R.....L.R.....L\") == \"RRR.LLL.RRR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R...L.R...L\") == \"RR.LL.RR.LL\"\n assert candidate(dominoes = \"R.........L\") == \"RRRRR.LLLLL\"\n assert candidate(dominoes = \"R...............................L\") == \"RRRRRRRRRRRRRRRR.LLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"R...L.R...L.R...L.R.L\") == \"RR.LL.RR.LL.RR.LL.R.L\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"LLRRRR.LLLLLRRR.L.L.L.L.L.R\") == \"LLRRRR.LLLLLRRR.LLLLLLLLL.R\"\n assert candidate(dominoes = \"RRRRRR.....LLLLL\") == \"RRRRRRRR.LLLLLLL\"\n assert candidate(dominoes = \".......R.L.......\") == \".......R.L.......\"\n assert candidate(dominoes = \"..R.L..R.L..R.L..\") == \"..R.L..R.L..R.L..\"\n assert candidate(dominoes = \"......R.L......\") == \"......R.L......\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"RR.LL.RR.LL.RR.LL\") == \"RR.LL.RR.LL.RR.LL\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"RR...L.L.L.R...RR\") == \"RRR.LLLLLL.RRRRRR\"\n assert candidate(dominoes = \"LRLRLRLRLRLRLRLRLR\") == \"LRLRLRLRLRLRLRLRLR\"\n assert candidate(dominoes = \"R.L.L.L.L.L.L.L.L.L.R\") == \"R.LLLLLLLLLLLLLLLLL.R\"\n assert candidate(dominoes = \"RR.LLLLLRRRR.LLLLLRRRR.LLLLL\") == \"RR.LLLLLRRRR.LLLLLRRRR.LLLLL\"\n assert candidate(dominoes = \"L.L.L.L.L.R.R.R.R.R\") == \"LLLLLLLLL.RRRRRRRRR\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.L\") == \"L.R.L.R.L.R.L.R.L.R.LLL\"\n assert candidate(dominoes = \"L...R...L...R...L...R\") == \"L...RR.LL...RR.LL...R\"\n assert candidate(dominoes = \"RR.LRR.LRR.LRR.L\") == \"RR.LRR.LRR.LRR.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"...R.L...L.R...R.L...\") == \"...R.LLLLL.RRRRR.L...\"\n assert candidate(dominoes = \"........L...R\") == \"LLLLLLLLL...R\"\n assert candidate(dominoes = \"L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L\") == \"L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.L\") == \"R.L.R.L.R.L.R.LLL\"\n assert candidate(dominoes = \"R.L....L.R.R.L\") == \"R.LLLLLL.RRR.L\"\n assert candidate(dominoes = \"L.L.R.R.L.L.R.R.L.L\") == \"LLL.RRR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R......L.L......R.R......L\") == \"RRRRLLLLLL......RRRRRRLLLL\"\n assert candidate(dominoes = \".......................................\") == \".......................................\"\n assert candidate(dominoes = \"L.L.L.L.L.L.R.R.R.R.R\") == \"LLLLLLLLLLL.RRRRRRRRR\"\n assert candidate(dominoes = \"....R.L.....R.L....\") == \"....R.L.....R.L....\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL.R.L\"\n assert candidate(dominoes = \"RRRRLLLLLLLL\") == \"RRRRLLLLLLLL\"\n assert candidate(dominoes = \"L...R.L...R.L...R\") == \"L...R.L...R.L...R\"\n assert candidate(dominoes = \"RRRRRRRRRRLLLLLLLLLL\") == \"RRRRRRRRRRLLLLLLLLLL\"\n assert candidate(dominoes = \"RRRR.LLLLL.LLLLL.RRRR\") == \"RRRR.LLLLLLLLLLL.RRRR\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.....R.R...L.L.R.L\") == \"L.....RRRR.LLLL.R.L\"\n assert candidate(dominoes = \"R........L.......\") == \"RRRRRLLLLL.......\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL.R.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"L.....R.....L.....R\") == \"L.....RRR.LLL.....R\"\n assert candidate(dominoes = \"LR.LR.LR.LR.LR.LR\") == \"LR.LR.LR.LR.LR.LR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.R.L.L.R.R.L.L.R\") == \"L.RRR.LLL.RRR.LLL.R\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL.R\"\n assert candidate(dominoes = \"........L...R........\") == \"LLLLLLLLL...RRRRRRRRR\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.L.R\") == \"R.L.R.L.R.L.R.LLL.R\"\n assert candidate(dominoes = \"........L.R........\") == \"LLLLLLLLL.RRRRRRRRR\"\n assert candidate(dominoes = \"..............R..............L..............\") == \"..............RRRRRRRRLLLLLLLL..............\"\n assert candidate(dominoes = \"R.R.R.R.R.L.L.L.L.L\") == \"RRRRRRRRR.LLLLLLLLL\"\n assert candidate(dominoes = \".RR.L.L.R.R.L.L\") == \".RR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"R.L...........R\") == \"R.L...........R\"\n assert candidate(dominoes = \"..............................\") == \"..............................\"\n assert candidate(dominoes = \"LRR.LL.R..R.L.L...R\") == \"LRR.LL.RRRR.LLL...R\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"LLLLL.....RRRRR\") == \"LLLLL.....RRRRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R.L...R...L...R.L\") == \"R.L...RR.LL...R.L\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"...R.L.R.L.R.L.R.L.R.L...\") == \"...R.L.R.L.R.L.R.L.R.L...\"\n assert candidate(dominoes = \"........LR........\") == \"LLLLLLLLLRRRRRRRRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"..R...L...R...L...R\") == \"..RR.LL...RR.LL...R\"\n assert candidate(dominoes = \"RR.L.L.R.R.L.L.R\") == \"RR.LLL.RRR.LLL.R\"\n assert candidate(dominoes = \"R.L....R.L\") == \"R.L....R.L\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"RR.R.L.LRR\") == \"RRRR.LLLRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R....L.R.L.R....L\") == \"RRRLLL.R.L.RRRLLL\"\n assert candidate(dominoes = \"..R.R.L.L.R..L.L.R..\") == \"..RRR.LLL.RRLLLL.RRR\"\n assert candidate(dominoes = \"L.R...L...R...L\") == \"L.RR.LL...RR.LL\"\n assert candidate(dominoes = \"R.............L\") == \"RRRRRRR.LLLLLLL\"\n assert candidate(dominoes = \"R........L........R\") == \"RRRRRLLLLL........R\"\n assert candidate(dominoes = \"LLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == \"LLLLRRRRLLLLRRRRLLLLRRRRLLLL\"\n assert candidate(dominoes = \"L...R...L...R.L\") == \"L...RR.LL...R.L\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"L...R.L...R.L...R.L.R\") == \"L...R.L...R.L...R.L.R\"\n assert candidate(dominoes = \"L.R...R.L.L...R.R.L.L...R\") == \"L.RRRRR.LLL...RRR.LLL...R\"\n assert candidate(dominoes = \"L...R....L...R\") == \"L...RRRLLL...R\"\n", "comparison": "exact"}, "public_tests": ["\"RR.L\"", "\".L.R...LR..L..\""], "hints": [], "metadata": {"canonical_parameter_names": ["dominoes"], "leetcode_dataset_entry_point": "Solution().pushDominoes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:30+00:00", "tests_total": 162, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["two-pointers", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def pushDominoes(self, dominoes: str) -> str:", "container": "Solution", "callable": "pushDominoes", "parameters": [{"name": "dominoes", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 839, "task_id": "similar-string-groups", "difficulty": "Hard", "problem_description": "Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X.\n\nFor example, \"tars\" and \"rats\" are similar (swapping at positions 0 and 2), and \"rats\" and \"arts\" are similar, but \"star\" is not similar to \"tars\", \"rats\", or \"arts\".\n\nTogether, these form two connected groups by similarity: {\"tars\", \"rats\", \"arts\"} and {\"star\"}. Notice that \"tars\" and \"arts\" are in the same group even though they are not similar. Formally, each group is such that a word is in the group if and only if it is similar to at least one other word in the group.\n\nWe are given a list strs of strings where every string in strs is an anagram of every other string in strs. How many groups are there?\n\nExample 1:\n\nInput: strs = [\"tars\",\"rats\",\"arts\",\"star\"]\nOutput: 2\n\nExample 2:\n\nInput: strs = [\"omv\",\"ovm\"]\nOutput: 1\n\nConstraints:\n\n- 1 <= strs.length <= 300\n- 1 <= strs[i].length <= 300\n- strs[i] consists of lowercase letters only.\n- All words in strs have the same length and are anagrams of each other.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strs = ['abc', 'bca', 'cab', 'cba', 'bac', 'acb']) == 1\n assert candidate(strs = ['ab', 'ba', 'abc', 'cab', 'bca']) == 1\n assert candidate(strs = ['aaaaa', 'aaabb', 'aaabc', 'aaaba', 'aaaaa']) == 1\n assert candidate(strs = ['tars', 'rats', 'arts', 'star']) == 2\n assert candidate(strs = ['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\n assert candidate(strs = ['abc', 'bca', 'cab', 'cba', 'acb', 'bac']) == 1\n assert candidate(strs = ['abcde', 'edcba', 'abced', 'decba', 'decab']) == 2\n assert candidate(strs = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yzw']) == 9\n assert candidate(strs = ['omv', 'ovm']) == 1\n assert candidate(strs = ['kite', 'peek', 'pink', 'pite', 'side', 'like', 'pipe', 'pike', 'lipk', 'kite', 'tape', 'pelt', 'pite', 'pink', 'pite']) == 1\n assert candidate(strs = ['aaa', 'aab', 'aba', 'baa', 'abb', 'bba', 'bab', 'bba', 'bbb', 'bbb']) == 1\n assert candidate(strs = ['aaaaaa', 'aaaabb', 'aaaabc', 'aaaaba', 'aaaaaa']) == 1\n assert candidate(strs = ['abc', 'bca', 'cab', 'acb', 'bac', 'cba']) == 1\n assert candidate(strs = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == 6\n assert candidate(strs = ['abcde', 'edcba', 'abced', 'deabc', 'decab', 'cdeab']) == 5\n assert candidate(strs = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 1\n assert candidate(strs = ['a', 'a', 'a', 'a', 'a']) == 1\n assert candidate(strs = ['abcdefghijklmnopqrstuvwxyz', 'bcadefghijklmnopqrstuvwxyza', 'cdefghijklmnopqrstuvwxyzab']) == 3\n assert candidate(strs = ['aaaa', 'aada', 'aadaa', 'aadda', 'aaddd', 'adaaa', 'adaad', 'adaad', 'addaa', 'adada', 'adada', 'addaa', 'daaaa', 'daada', 'daada', 'dadaa', 'dadad', 'daada', 'dadaa', 'dadad', 'daada', 'ddaaa', 'ddada', 'ddaad', 'ddada', 'dddda']) == 1\n assert candidate(strs = ['zzzzzzzzzz', 'zzzzzzzzzy', 'zzzzzzzzzx', 'zzzzzzzzzw', 'zzzzzzzzzv', 'zzzzzzzzzu', 'zzzzzzzzzt', 'zzzzzzzzzs', 'zzzzzzzzzr', 'zzzzzzzzzq']) == 1\n assert candidate(strs = ['mnopqr', 'nopqmr', 'opqmnr', 'pqomnr', 'qpomnr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr']) == 3\n assert candidate(strs = ['abcde', 'edcba', 'abced', 'decba', 'decab', 'abcde', 'edcba', 'abced', 'decba', 'decab']) == 2\n assert candidate(strs = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 1\n assert candidate(strs = ['abcdefgh', 'bcdefgha', 'cdefghab', 'defghabc', 'efghabcd', 'fghabcde', 'ghabcdef', 'habcdefg']) == 8\n assert candidate(strs = ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']) == 1\n assert candidate(strs = ['abcdeabcde', 'edcbaedcba', 'abcedabced', 'decbaedcba', 'decabdecab', 'abcdeabced', 'abcdeabcdx']) == 3\n assert candidate(strs = ['abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik']) == 1\n assert candidate(strs = ['aabbcc', 'ccaabb', 'bbaacc', 'aabbbc', 'bcaabb', 'abcabc', 'babcac', 'cabcab', 'bacbac', 'acbacb', 'acbbac', 'abacbc', 'cababc', 'cbaabc', 'acabbc', 'bcabac', 'abcbac', 'cabbac', 'bcacab', 'acbbca']) == 1\n assert candidate(strs = ['qwertyuiop', 'qeywrtuiop', 'qwrtypuioe', 'qwertyuiop', 'qwertyuipo']) == 3\n assert candidate(strs = ['abcabcabcabc', 'cbacbacbacba', 'bacbacbacbac', 'abcabcabcacb', 'cbacbacbacac', 'bacbacbacabc', 'abcabcabcaba', 'cbacbacbacad', 'bacbacbacaba', 'abcabcabcaca', 'cbacbacbacad', 'bacbacbacaca', 'abcabcabacba', 'cbacbacbacba', 'bacbacbacacb', 'abcabcabcabc', 'cbacbacbacac', 'bacbacbacabc']) == 3\n assert candidate(strs = ['abacabad', 'babadaba', 'bacabada', 'acabadab', 'adabacab', 'cabadaba', 'abadabac', 'badabaca']) == 4\n assert candidate(strs = ['abcdefghij', 'abcdefghji', 'abcdefghif', 'abcdefghig', 'abcdefghih']) == 1\n assert candidate(strs = ['abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghim', 'abcdefghin', 'abcdefghio']) == 1\n assert candidate(strs = ['xyzzxy', 'zyxzyx', 'zzzyxy', 'zyzzxz', 'xyzzzx', 'zyxzyy', 'zyzzxy', 'zyzzxy']) == 1\n assert candidate(strs = ['abcdefg', 'gfedcba', 'fedcbag', 'gabcdef', 'bacdefg', 'gfeabcd', 'bcdefga', 'gfabcde', 'gefedcb', 'defgabc', 'gdefcab', 'fgedcba', 'gfabced', 'gfadebc', 'gbafced', 'gfacedb', 'gfebacd', 'gfbaced', 'gfbcdea', 'gfbedac', 'gfeadcb', 'gfecdba', 'gfdbeca', 'gfdecba']) == 13\n assert candidate(strs = ['abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghim', 'abcdefghin']) == 1\n assert candidate(strs = ['abcdefgh', 'abcdefgh', 'bcdefgha', 'cdefghab', 'defghabc', 'efghabcd', 'fghabcde', 'ghabcdef', 'habcdefg', 'abcdefgha', 'abcdefghb', 'abcdefghc', 'abcdefghd', 'abcdefghi', 'abcdefghj']) == 8\n assert candidate(strs = ['abcdefgh', 'abcdefgh', 'aefghbcd', 'bcdefgha', 'ghabcdef', 'hgfedcba', 'abcdefgh']) == 5\n assert candidate(strs = ['xyzxyz', 'yzxyxz', 'zxyxyz', 'xyxzyz', 'yxzxzy', 'zxzyxy', 'xzyzxy', 'zyxzyx']) == 6\n assert candidate(strs = ['abcde', 'abced', 'abdec', 'abdec', 'abced', 'abcde', 'abced', 'abdec', 'abced', 'abcde', 'abced', 'abdec', 'abced', 'abcde', 'abced', 'abdec', 'abced', 'abcde']) == 1\n assert candidate(strs = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghij', 'abcdefghim', 'abcdefghij', 'abcdefghin', 'abcdefghio']) == 2\n assert candidate(strs = ['abcdefg', 'bacdefg', 'cbadefg', 'dcabefg', 'edcabfg', 'fedcabc', 'gfedcab', 'hgfedca']) == 6\n assert candidate(strs = ['abcdefghij', 'bacdefghij', 'cabdefghij', 'abcdfehgij', 'abcdefghij', 'abcdefghik', 'abcdefghji']) == 2\n assert candidate(strs = ['abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acdb', 'adcb', 'bcda', 'cdba', 'bdca', 'dacb', 'cadb', 'bdac', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acdb', 'adcb', 'bcda', 'cdba', 'bdca', 'dacb', 'cadb', 'bdac']) == 1\n assert candidate(strs = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 1\n assert candidate(strs = ['aaaaabbbbb', 'aaaabbbbba', 'aaabbbbaaa', 'aabbbbaaaa', 'abbbbaaaaa', 'baaaaabbbb', 'baaaaabbbb', 'bbbbbaaaaa', 'bbbbbaaaab', 'bbbbbaaabb', 'bbbbbaabba', 'bbbbbaabbb', 'bbbbabbbbb', 'bbbbbaabaa', 'bbbbaabbbb', 'bbaaaaabbb', 'bbaaaabbbb', 'bbaaabbbbb', 'bbbaaaaabb', 'bbbaaaabbb', 'bbbaaabbbb', 'bbbbaaaabb', 'bbbbaaabbb', 'bbbbaabbbb', 'bbbbbaaaab', 'bbbbbaaabbb', 'bbbbbaabbb', 'bbbbabbbba', 'bbbbabbaaa', 'bbbbbaabaa', 'bbbbbaaabb', 'bbbbaaaaaa', 'bbbbaaaaba', 'bbbbaaabaa', 'bbbbaaabab', 'bbbbaaabra', 'bbbbbaaaaa', 'bbbbbaaaab', 'bbbbbaaaba', 'bbbbbaabaa', 'bbbbbaaabb']) == 1\n assert candidate(strs = ['abcd', 'acbd', 'adbc', 'cabd', 'dbca', 'dcba', 'dcab']) == 1\n assert candidate(strs = ['abababab', 'babababa', 'aabbaabb', 'bbaabbaa', 'abbaabba', 'baabbaab', 'abbaabba', 'baabbaab', 'bbaabbaa', 'aabbaabb', 'babababa', 'abababab']) == 6\n assert candidate(strs = ['lkjhgfedcba', 'lkjhgfedcba', 'lkjhgfedcba', 'lkjhgfedcba', 'lkjhgfedcba']) == 1\n assert candidate(strs = ['abcde', 'edcba', 'dbeca', 'decba', 'decab', 'cedab', 'aebcd', 'bcdea', 'debac', 'baced', 'acebd', 'bdeca', 'acdeb', 'bacde', 'abced', 'decba', 'edabc', 'abcde', 'acbde', 'baced', 'bcaed']) == 5\n assert candidate(strs = ['qwertyuiop', 'wertyuiopq', 'ertyuiopqw', 'rtyuiopqwe', 'tyuiopqrst', 'yuiopqrstu', 'uiopqrstuv', 'iopqrstuvw', 'opqrstuvwx', 'pqrstuvwxy', 'qrstuvwxyz', 'rstuvwxyzp', 'stuvwxyzpr', 'tuvwxyzprs', 'uvwxyzprst', 'vwxyzprstq', 'wxyzprstqu', 'xyzprstquv', 'yzprstquvx', 'zprstquvxy', 'prstquvxyz', 'rstquvxyza', 'stquvxyzab', 'tquvxyzabc', 'quvxyzabcd', 'uvxyzabcde', 'vxyzabcdef', 'xyzabcdefg', 'yzabcdefgq', 'zabcdefgqr', 'abcdefgqrs', 'bcdefgqrst', 'cdefgqrstu', 'defgqrstuv', 'efgqrstuvw', 'fgqrstuvwxyz', 'gqrstuvwxyzx', 'hqrstuvwxyzx', 'qrstuvwxyzxy', 'rstuvwxyzxyq', 'stuvwxyzxyqp', 'tuvwxyzxyqpr', 'uvwxyzxyqprs', 'vwxyzxyqprst', 'wxyzxyqprstu', 'xyzxyqprstuv', 'yzxyqprstuvw', 'zxyqprstuvwx', 'xyqprstuvwxy', 'yqprstuvwxyz', 'qprstuvwxyzx', 'prstuvwxyzxy', 'rstuvwxyzxyz', 'stuvwxyzxyza', 'tuvwxyzxyqza']) == 44\n assert candidate(strs = ['abcdefg', 'gfedcba', 'bacdefg', 'abcdefg', 'gfedcbx', 'abcdefg', 'gfedcbw']) == 2\n assert candidate(strs = ['aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa']) == 2\n assert candidate(strs = ['ababab', 'bababa', 'bbaaab', 'aababb', 'ababba', 'abbaab', 'aabbab', 'ababab', 'aabbaa']) == 1\n assert candidate(strs = ['aaaaaaaa', 'aaaaabaa', 'aaaabaab', 'aaabaaba', 'aabaaaba', 'abaabaaa', 'baaaaaab', 'baaabaaa', 'baabaaab', 'babaaaaa', 'abaaaaab', 'abaaabaa', 'abaabaab', 'baabaaba', 'aabaaaba', 'aaabaaba', 'baaabaaa', 'baaaaaab', 'abaaaaab', 'baaaabaa', 'aabaaaba', 'abaabaab', 'baabaaba', 'aabaaaba', 'baaaabaa', 'baaaaaab', 'abaaaaab', 'abaabaab', 'baabaaba', 'aabaaaba', 'baaaabaa', 'baaaaaab', 'abaaaaab', 'abaabaab', 'baabaaba', 'aabaaaba', 'baaaabaa', 'baaaaaab', 'abaaaaab']) == 1\n assert candidate(strs = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'ijhgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij', 'ijhgfedcba']) == 2\n assert candidate(strs = ['abacax', 'aacxab', 'abacax', 'bacaxa', 'cacxab', 'abcaxa']) == 3\n", "comparison": "exact"}, "public_tests": ["[\"tars\",\"rats\",\"arts\",\"star\"]", "[\"omv\",\"ovm\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().numSimilarGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:32+00:00", "tests_total": 57, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "depth-first-search", "breadth-first-search", "union-find"]}, "language": "python", "interface": {"raw_signature": "def numSimilarGroups(self, strs: list[str]) -> int:", "container": "Solution", "callable": "numSimilarGroups", "parameters": [{"name": "strs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 840, "task_id": "magic-squares-in-grid", "difficulty": "Medium", "problem_description": "A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.\n\nGiven a row x col grid of integers, how many 3 x 3 magic square subgrids are there?\n\nNote: while a magic square can only contain numbers from 1 to 9, grid may contain numbers up to 15.\n\nExample 1:\n\nInput: grid = [[4,3,8,4],[9,5,1,9],[2,7,6,2]]\nOutput: 1\nExplanation:\nThe following subgrid is a 3 x 3 magic square:\n\nwhile this one is not:\n\nIn total, there is only one magic square inside the given grid.\n\nExample 2:\n\nInput: grid = [[8]]\nOutput: 0\n\nConstraints:\n\n- row == grid.length\n- col == grid[i].length\n- 1 <= row, col <= 10\n- 0 <= grid[i][j] <= 15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[4, 3, 8, 4, 0], [9, 5, 1, 9, 3], [2, 7, 6, 2, 4], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) == 1\n assert candidate(grid = [[7, 0, 5], [3, 5, 1], [6, 4, 3]]) == 0\n assert candidate(grid = [[8]]) == 0\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 0\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2]]) == 1\n assert candidate(grid = [[4, 3, 8, 4, 9], [9, 5, 1, 9, 2], [2, 7, 6, 2, 9], [9, 4, 3, 8, 4]]) == 1\n assert candidate(grid = [[1, 8, 6], [10, 5, 0], [4, 2, 3]]) == 0\n assert candidate(grid = [[9, 2, 7], [6, 5, 4], [3, 8, 1]]) == 0\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 8, 1, 6, 4, 9, 2]]) == 0\n assert candidate(grid = [[9, 2, 3], [4, 5, 6], [7, 8, 1]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 0\n assert candidate(grid = [[4, 3, 8, 4, 5], [9, 5, 1, 9, 3], [2, 7, 6, 2, 7], [1, 2, 3, 4, 5], [9, 8, 7, 6, 5]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 6, 1, 8]]) == 0\n assert candidate(grid = [[4, 3, 8, 4, 1], [9, 5, 1, 9, 7], [2, 7, 6, 2, 6], [9, 5, 1, 9, 7], [2, 7, 6, 2, 6]]) == 1\n assert candidate(grid = [[4, 3, 8, 1, 6], [9, 5, 1, 8, 3], [2, 7, 6, 4, 9], [4, 3, 8, 1, 6], [9, 5, 1, 8, 3]]) == 1\n assert candidate(grid = [[4, 3, 8, 4, 9, 2, 3, 5, 7], [8, 1, 6, 3, 5, 7, 4, 9, 2], [6, 7, 2, 4, 9, 2, 7, 9, 2], [8, 1, 6, 9, 5, 1, 2, 7, 6], [2, 9, 4, 8, 1, 6, 4, 9, 2], [9, 5, 1, 3, 5, 7, 9, 4, 2]]) == 0\n assert candidate(grid = [[15, 10, 5, 1, 6], [4, 3, 8, 9, 2], [7, 12, 13, 14, 15], [8, 11, 10, 9, 7], [5, 4, 3, 2, 1]]) == 0\n assert candidate(grid = [[4, 3, 8, 4, 9, 1, 5], [9, 5, 1, 9, 2, 6, 7], [2, 7, 6, 2, 9, 4, 3], [9, 5, 1, 9, 2, 6, 7], [2, 7, 6, 2, 9, 4, 3], [9, 5, 1, 9, 2, 6, 7], [2, 7, 6, 2, 9, 4, 3]]) == 1\n assert candidate(grid = [[8, 1, 6, 7, 2, 9, 4, 3, 8], [1, 6, 7, 2, 9, 4, 3, 8, 1], [6, 7, 2, 9, 4, 3, 8, 1, 6], [7, 2, 9, 4, 3, 8, 1, 6, 7], [2, 9, 4, 3, 8, 1, 6, 7, 2], [9, 4, 3, 8, 1, 6, 7, 2, 9], [4, 3, 8, 1, 6, 7, 2, 9, 4], [3, 8, 1, 6, 7, 2, 9, 4, 3], [8, 1, 6, 7, 2, 9, 4, 3, 8]]) == 0\n assert candidate(grid = [[5, 3, 4, 9, 1], [6, 7, 2, 8, 10], [1, 9, 8, 3, 5], [4, 2, 6, 7, 3], [9, 8, 1, 4, 6]]) == 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]]) == 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]]) == 0\n assert candidate(grid = [[2, 7, 6, 9, 5], [9, 5, 1, 4, 3], [4, 3, 8, 1, 4], [1, 4, 7, 8, 5], [8, 5, 2, 9, 6]]) == 1\n assert candidate(grid = [[4, 1, 9, 5, 10], [7, 5, 3, 6, 2], [6, 7, 2, 1, 8], [1, 6, 3, 7, 9], [5, 4, 8, 2, 1]]) == 0\n assert candidate(grid = [[5, 7, 3, 10, 1], [6, 1, 8, 2, 9], [7, 3, 5, 6, 4], [4, 9, 2, 8, 7], [9, 2, 4, 7, 6]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 3, 8, 1, 6, 7, 2, 9, 4], [7, 6, 1, 8, 5, 2, 9, 4, 3], [2, 9, 4, 3, 8, 1, 6, 7, 2], [8, 1, 6, 7, 2, 9, 4, 3, 8], [3, 8, 1, 6, 7, 2, 9, 4, 3], [6, 7, 2, 9, 4, 3, 8, 1, 6], [9, 4, 3, 8, 1, 6, 7, 2, 9], [4, 3, 8, 1, 6, 7, 2, 9, 4]]) == 0\n assert candidate(grid = [[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]]) == 0\n assert candidate(grid = [[1, 6, 7, 2, 8], [9, 5, 3, 4, 1], [8, 3, 4, 5, 9], [3, 4, 5, 6, 7], [6, 7, 8, 9, 1]]) == 0\n assert candidate(grid = [[4, 3, 8, 4, 1, 6], [9, 5, 1, 9, 7, 1], [2, 7, 6, 2, 6, 4], [9, 5, 1, 9, 7, 2], [2, 7, 6, 2, 6, 3], [9, 4, 3, 8, 4, 2]]) == 1\n assert candidate(grid = [[8, 1, 6, 7, 2], [3, 5, 7, 8, 4], [4, 9, 2, 1, 6], [9, 5, 1, 8, 3], [2, 7, 6, 4, 9]]) == 1\n assert candidate(grid = [[15, 5, 9, 12, 6, 3], [6, 9, 5, 8, 12, 6], [3, 9, 5, 15, 10, 5], [12, 6, 3, 15, 5, 12], [6, 5, 12, 5, 10, 15], [15, 10, 5, 6, 9, 3]]) == 0\n assert candidate(grid = [[4, 3, 8, 1, 6, 7], [9, 5, 1, 8, 3, 4], [2, 7, 6, 4, 9, 2], [4, 3, 8, 1, 6, 7], [9, 5, 1, 8, 3, 4], [2, 7, 6, 4, 9, 2]]) == 2\n assert candidate(grid = [[4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 8, 1, 6, 4, 9, 2], [8, 1, 6, 7, 9, 2, 3, 5, 7], [4, 9, 2, 7, 9, 2, 3, 5, 7], [3, 5, 7, 6, 1, 8, 9, 4, 2]]) == 1\n assert candidate(grid = [[4, 9, 2, 3, 5, 7], [3, 5, 7, 8, 1, 6], [8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2], [4, 9, 2, 7, 5, 3], [9, 2, 4, 6, 1, 8]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 1], [9, 4, 3, 8, 1, 6], [4, 3, 8, 1, 6, 7], [3, 8, 1, 6, 7, 2], [8, 1, 6, 7, 2, 9], [1, 6, 7, 2, 9, 4]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 9, 2, 3, 5, 7, 8, 1, 6], [7, 6, 1, 8, 1, 4, 9, 2, 3], [2, 7, 6, 1, 9, 8, 4, 3, 5], [9, 5, 1, 4, 3, 8, 2, 7, 6]]) == 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]]) == 0\n assert candidate(grid = [[4, 9, 2, 3, 5, 7], [3, 5, 7, 8, 1, 6], [8, 1, 6, 4, 9, 2], [4, 9, 2, 3, 5, 7], [3, 5, 7, 8, 1, 6]]) == 2\n assert candidate(grid = [[9, 3, 8, 4, 9], [5, 1, 9, 2, 6], [2, 7, 6, 9, 3], [9, 5, 1, 9, 7], [2, 7, 6, 9, 3]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [4, 3, 8, 9, 5, 1, 4, 3, 8, 9], [5, 8, 3, 9, 5, 1, 9, 5, 1, 9], [6, 1, 8, 4, 3, 8, 2, 7, 6, 4], [7, 6, 1, 2, 7, 6, 9, 5, 1, 3]]) == 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, 9, 7, 5, 3, 1], [2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 7, 5, 3, 1, 8, 6, 4, 2], [3, 5, 7, 9, 2, 4, 6, 8, 1], [4, 6, 8, 1, 3, 5, 7, 9, 2], [5, 7, 9, 2, 4, 6, 8, 1, 3]]) == 0\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 4, 9, 2], [4, 9, 2, 7, 6, 1, 8, 3, 5], [9, 2, 7, 6, 1, 8, 3, 5, 4], [2, 7, 6, 1, 8, 3, 5, 4, 9], [7, 6, 1, 8, 3, 5, 4, 9, 2], [6, 1, 8, 3, 5, 4, 9, 2, 7], [1, 8, 3, 5, 4, 9, 2, 7, 6], [8, 3, 5, 4, 9, 2, 7, 6, 1]]) == 1\n assert candidate(grid = [[15, 10, 4, 5, 9, 3], [13, 14, 8, 7, 2, 12], [6, 7, 11, 1, 15, 1], [14, 5, 1, 10, 3, 9], [8, 2, 13, 4, 6, 11]]) == 0\n assert candidate(grid = [[4, 3, 8, 1, 6, 7, 2, 9, 5], [1, 8, 3, 6, 7, 2, 9, 5, 1], [6, 7, 2, 3, 8, 4, 1, 6, 7], [7, 2, 9, 8, 3, 4, 6, 1, 8], [2, 9, 5, 1, 6, 7, 8, 3, 4], [9, 5, 1, 7, 2, 9, 3, 8, 4], [4, 3, 8, 9, 5, 1, 2, 9, 5], [3, 8, 4, 5, 8, 3, 6, 7, 2], [8, 3, 4, 9, 1, 6, 7, 2, 9]]) == 0\n assert candidate(grid = [[5, 3, 4, 9, 7, 12], [1, 6, 2, 5, 9, 14], [7, 8, 9, 3, 11, 4], [10, 6, 1, 8, 2, 7], [3, 5, 2, 4, 10, 9], [11, 4, 13, 6, 7, 8]]) == 0\n assert candidate(grid = [[4, 3, 8, 4, 9, 3, 8, 4, 9], [9, 5, 1, 9, 2, 7, 6, 2, 9], [2, 7, 6, 2, 9, 5, 1, 9, 2], [9, 5, 1, 9, 2, 7, 6, 2, 9], [2, 7, 6, 2, 9, 5, 1, 9, 2], [9, 5, 1, 9, 2, 7, 6, 2, 9], [4, 3, 8, 4, 9, 3, 8, 4, 9], [9, 5, 1, 9, 2, 7, 6, 2, 9], [2, 7, 6, 2, 9, 5, 1, 9, 2]]) == 3\n assert candidate(grid = [[8, 3, 4, 1, 6, 7, 2, 9], [1, 6, 7, 2, 9, 4, 3, 8], [6, 7, 2, 9, 4, 3, 8, 1], [7, 2, 9, 4, 3, 8, 1, 6], [2, 9, 4, 3, 8, 1, 6, 7], [9, 4, 3, 8, 1, 6, 7, 2], [4, 3, 8, 1, 6, 7, 2, 9], [3, 8, 1, 6, 7, 2, 9, 4]]) == 0\n assert candidate(grid = [[8, 1, 6, 3, 5, 7], [3, 5, 7, 8, 1, 6], [4, 9, 2, 4, 9, 2], [3, 5, 7, 3, 5, 7], [8, 1, 6, 8, 1, 6]]) == 3\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, 3, 5, 7, 9, 2, 4, 6, 8, 1], [2, 9, 4, 7, 6, 1, 8, 5, 3, 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 = [[4, 3, 8, 4, 9, 2, 1, 6, 7], [9, 5, 1, 9, 2, 1, 6, 7, 4], [2, 7, 6, 2, 9, 8, 4, 1, 3], [9, 8, 1, 4, 3, 2, 7, 6, 5], [3, 2, 9, 8, 7, 6, 5, 4, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [1, 6, 7, 4, 5, 6, 7, 8, 9], [6, 7, 4, 5, 6, 7, 8, 9, 1], [7, 4, 5, 6, 7, 8, 9, 1, 6]]) == 1\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7], [8, 7, 6, 5, 4, 3, 2], [7, 6, 5, 4, 3, 2, 1], [6, 5, 4, 3, 2, 1, 9], [5, 4, 3, 2, 1, 9, 8]]) == 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]]) == 0\n assert candidate(grid = [[9, 3, 2, 8, 4], [6, 5, 4, 1, 7], [7, 8, 9, 6, 3], [4, 1, 2, 5, 8], [1, 6, 7, 3, 9]]) == 0\n assert candidate(grid = [[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], [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], [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]]) == 0\n assert candidate(grid = [[4, 3, 8, 4, 10], [9, 5, 1, 9, 11], [2, 7, 6, 2, 12], [9, 5, 1, 9, 13], [2, 7, 6, 2, 14]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2, 7], [3, 5, 7, 8, 1, 6, 2, 7, 6, 5], [6, 7, 2, 9, 5, 1, 3, 5, 7, 4], [8, 1, 6, 7, 9, 2, 6, 7, 2, 3], [4, 9, 2, 6, 1, 8, 9, 4, 2, 8], [9, 5, 1, 9, 7, 6, 2, 7, 6, 1]]) == 0\n assert candidate(grid = [[8, 1, 6, 3, 5], [7, 9, 2, 4, 6], [6, 7, 2, 1, 3], [8, 1, 6, 3, 5], [7, 9, 2, 4, 6]]) == 0\n assert candidate(grid = [[5, 3, 4, 9, 10], [6, 7, 2, 8, 11], [1, 9, 8, 7, 6], [3, 4, 5, 6, 7], [8, 9, 1, 2, 3]]) == 0\n assert candidate(grid = [[4, 3, 8, 1, 6, 7, 2, 9, 4], [9, 5, 1, 9, 7, 6, 2, 7, 6], [2, 7, 6, 4, 3, 8, 2, 9, 4], [4, 3, 8, 1, 6, 7, 2, 9, 4], [9, 5, 1, 9, 7, 6, 2, 7, 6]]) == 1\n assert candidate(grid = [[4, 3, 8, 4, 1], [9, 5, 1, 9, 7], [2, 7, 6, 2, 6], [9, 5, 1, 9, 7], [2, 7, 6, 2, 6], [4, 3, 8, 4, 1], [9, 5, 1, 9, 7]]) == 1\n assert candidate(grid = [[4, 3, 8, 4, 1, 9, 7], [9, 5, 1, 9, 2, 6, 8], [2, 7, 6, 2, 7, 4, 2], [9, 5, 1, 9, 2, 6, 8], [2, 7, 6, 2, 7, 4, 2]]) == 1\n assert candidate(grid = [[8, 3, 4, 1, 6, 7, 2, 9, 5], [3, 8, 4, 6, 1, 9, 7, 2, 9], [4, 3, 8, 7, 2, 9, 1, 6, 7], [9, 5, 1, 2, 9, 5, 1, 9, 5], [2, 7, 6, 4, 3, 8, 6, 1, 8], [6, 1, 8, 9, 5, 1, 8, 3, 4], [7, 2, 9, 5, 8, 3, 9, 5, 1], [8, 9, 5, 1, 6, 7, 4, 3, 8], [9, 5, 1, 3, 6, 9, 2, 7, 6]]) == 1\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, 5, 5, 5, 5], [5, 5, 5, 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(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [4, 3, 8, 1, 6], [9, 5, 1, 9, 2]]) == 0\n assert candidate(grid = [[1, 6, 7, 8, 9], [6, 7, 2, 1, 5], [8, 1, 6, 7, 2], [3, 5, 7, 8, 4], [4, 9, 2, 3, 5]]) == 1\n assert candidate(grid = [[2, 7, 6, 9, 5, 1], [9, 5, 1, 9, 5, 1], [4, 3, 8, 4, 3, 8], [3, 6, 9, 2, 7, 6], [4, 3, 8, 9, 5, 1], [2, 7, 6, 4, 3, 8]]) == 2\n assert candidate(grid = [[9, 7, 6, 8, 1, 4, 3, 5, 2], [2, 3, 4, 5, 6, 7, 8, 9, 1], [5, 1, 9, 7, 6, 8, 4, 3, 2], [6, 8, 7, 9, 1, 5, 2, 4, 3], [1, 4, 3, 6, 7, 2, 9, 5, 8], [7, 9, 8, 2, 4, 3, 5, 1, 6], [3, 2, 1, 4, 9, 8, 6, 7, 5], [8, 5, 2, 1, 3, 4, 7, 6, 9], [4, 6, 9, 3, 8, 7, 1, 2, 5]]) == 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, 4, 3, 8, 1, 6, 7, 5], [5, 5, 5, 1, 8, 3, 6, 7, 2, 5], [5, 5, 5, 6, 7, 2, 9, 5, 1, 5], [5, 5, 5, 8, 1, 6, 7, 2, 9, 5], [5, 5, 5, 7, 6, 1, 2, 9, 5, 5], [5, 5, 5, 2, 9, 5, 1, 6, 7, 5], [5, 5, 5, 9, 5, 1, 8, 3, 4, 5]]) == 0\n assert candidate(grid = [[8, 1, 6, 7, 5], [3, 5, 7, 3, 9], [4, 9, 2, 8, 4], [5, 1, 9, 2, 6], [7, 5, 3, 4, 8]]) == 1\n assert candidate(grid = [[4, 3, 8, 4, 9], [9, 5, 1, 9, 2], [2, 7, 6, 2, 9], [9, 4, 3, 8, 4], [9, 5, 1, 9, 2], [2, 7, 6, 2, 9]]) == 1\n assert candidate(grid = [[4, 9, 2, 3, 5], [3, 5, 7, 4, 6], [8, 1, 6, 9, 2], [7, 5, 3, 8, 4], [9, 2, 4, 7, 5]]) == 1\n assert candidate(grid = [[3, 8, 4, 9, 5], [4, 9, 2, 8, 6], [8, 4, 9, 2, 7], [5, 1, 6, 3, 4], [1, 6, 7, 5, 3]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 7, 6, 9, 5, 1, 4, 3, 8], [4, 3, 8, 9, 5, 1, 2, 7, 6], [9, 5, 1, 4, 3, 8, 7, 6, 2], [2, 7, 6, 3, 5, 7, 8, 1, 6], [9, 5, 1, 8, 1, 6, 9, 5, 1], [2, 7, 6, 7, 5, 3, 2, 7, 6]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[4,3,8,4],[9,5,1,9],[2,7,6,2]]", "[[8]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().numMagicSquaresInside", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:35+00:00", "tests_total": 82, "tests_dropped": 9, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "math", "matrix"]}, "language": "python", "interface": {"raw_signature": "def numMagicSquaresInside(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "numMagicSquaresInside", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 841, "task_id": "keys-and-rooms", "difficulty": "Medium", "problem_description": "There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.\n\nWhen you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, and you can take all of them with you to unlock the other rooms.\n\nGiven an array rooms where rooms[i] is the set of keys that you can obtain if you visited room i, return true if you can visit all the rooms, or false otherwise.\n\nExample 1:\n\nInput: rooms = [[1],[2],[3],[]]\nOutput: true\nExplanation:\nWe visit room 0 and pick up key 1.\nWe then visit room 1 and pick up key 2.\nWe then visit room 2 and pick up key 3.\nWe then visit room 3.\nSince we were able to visit every room, we return true.\n\nExample 2:\n\nInput: rooms = [[1,3],[3,0,1],[2],[0]]\nOutput: false\nExplanation: We can not enter room number 2 since the only key that unlocks it is in that room.\n\nConstraints:\n\n- n == rooms.length\n- 2 <= n <= 1000\n- 0 <= rooms[i].length <= 1000\n- 1 <= sum(rooms[i].length) <= 3000\n- 0 <= rooms[i][j] < n\n- All the values of rooms[i] are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rooms = [[1], [2], [], [3]]) == False\n assert candidate(rooms = [[1], [1, 2], [2], []]) == False\n assert candidate(rooms = [[1], [2, 3], [3], []]) == True\n assert candidate(rooms = [[2, 3], [0, 1], [3], [0]]) == False\n assert candidate(rooms = [[1], [2], [3], []]) == True\n assert candidate(rooms = [[2, 3], [], [2], [1, 3, 1]]) == True\n assert candidate(rooms = [[2], [3], [0, 1], []]) == True\n assert candidate(rooms = [[2, 3], [3, 0, 1], [2], [0]]) == False\n assert candidate(rooms = [[1, 3], [3, 0, 1], [2], [0]]) == False\n assert candidate(rooms = [[1, 3], [2, 4], [3], [4], []]) == True\n assert candidate(rooms = [[1, 3], [2], [1, 3, 4], [4, 5], [5], []]) == True\n assert candidate(rooms = [[1, 2], [3], [4], [0], [1, 2, 3, 4]]) == True\n assert candidate(rooms = [[1, 3], [3, 0, 1], [2], [0, 2, 1, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6], [0, 2, 3, 4, 5, 6], [0, 1, 3, 4, 5, 6], [0, 1, 2, 4, 5, 6], [0, 1, 2, 3, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 4, 5]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], []]) == False\n assert candidate(rooms = [[1, 2], [2], [0, 3], [1]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [2, 3, 4], [0, 3, 4], [1, 2, 4], [1, 2, 3], [0, 1]]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [3, 2, 1, 4], [4, 2, 0, 1], [3, 1, 2, 4], [0, 1, 2, 3]]) == True\n assert candidate(rooms = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [0]]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [0, 2, 3, 4], [0, 1, 3, 4], [0, 1, 2, 4], [0, 1, 2, 3], []]) == False\n assert candidate(rooms = [[1], [0, 2, 3, 4], [1, 3, 4], [2, 4], [2, 3], []]) == False\n assert candidate(rooms = [[1], [0, 2, 3, 4], [0, 3, 4], [0, 2, 4], [0, 2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10], [7, 8, 9, 10], [8, 9, 10], [9, 10], [10], []]) == True\n assert candidate(rooms = [[1, 3], [2], [0], [1, 2, 4], [3]]) == True\n assert candidate(rooms = [[1], [0, 2, 3, 4], [1, 3], [1, 2, 4], [1, 2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5], []]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [2, 3, 4], [3, 4], [4], []]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5], []]) == True\n assert candidate(rooms = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [0]]) == True\n assert candidate(rooms = [[1, 2, 3], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8], [6, 8, 9], [7, 9, 10], [8, 10, 11], [9, 11, 12], [10, 12, 13], [11, 13, 14], [12, 14], [13, 14, 15], [14, 15], [15]]) == True\n assert candidate(rooms = [[1], [2, 3, 4, 5], [0], [2, 5], [3], [2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [0, 3, 4, 5], [0, 1, 4, 5], [0, 1, 2, 5], [0, 1, 2, 3], [0, 1, 2, 3, 4]]) == True\n assert candidate(rooms = [[1, 2, 3], [2, 4, 5], [1, 4, 5, 6], [2, 3, 5, 6, 7], [2, 3, 4, 6, 7], [3, 4, 5, 7, 8], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9], [7, 8, 9], []]) == False\n assert candidate(rooms = [[1, 3, 5], [2, 4], [3, 5], [4, 5], [1, 5], [0]]) == True\n assert candidate(rooms = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], []]) == True\n assert candidate(rooms = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], []]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [1, 3, 4, 5, 6], [2, 4, 5, 6, 7], [3, 5, 6, 7, 8], [4, 6, 7, 8, 9], [5, 7, 8, 9, 10], [6, 8, 9, 10, 11], [7, 9, 10, 11, 12], [8, 10, 11, 12, 13], [9, 11, 12, 13, 14], [10, 12, 13, 14], [11, 13, 14], [12, 14], [13, 14], [14]]) == True\n assert candidate(rooms = [[1, 2, 3], [3, 0, 1], [2], [0]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4]]) == True\n assert candidate(rooms = [[1, 2, 3], [2, 4], [3, 5], [4], [5], [0]]) == True\n assert candidate(rooms = [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10], [7, 8, 9, 10], [8, 9, 10], [9, 10], [10], []]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [2, 3, 4], [3, 4, 5], [4, 5], [5], []]) == True\n assert candidate(rooms = [[1], [2], [3], [4], [5], [6], [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]]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [2], [3], [4], []]) == True\n assert candidate(rooms = [[1, 2], [2, 3], [3, 4], [4, 1], [0]]) == True\n assert candidate(rooms = [[1, 2, 3], [2, 3], [3], [], [1]]) == False\n assert candidate(rooms = [[1, 2, 3], [0, 2, 4], [0, 1, 3], [0, 1, 2, 4], [1, 3]]) == True\n assert candidate(rooms = [[1, 2, 3], [0, 4, 5], [0, 5, 6], [0, 6, 7], [1], [1, 2], [2, 3], [3]]) == True\n assert candidate(rooms = [[1, 2], [2, 3], [3, 1], [4], [1, 2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 0], [3, 4, 5, 0, 1], [4, 5, 0, 1, 2], [5, 0, 1, 2, 3], [0, 1, 2, 3, 4]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6, 7], [0, 2, 3, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 4, 5, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 2, 3, 4, 5, 7], [0, 1, 2, 3, 4, 5, 6]]) == True\n assert candidate(rooms = [[1, 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], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15], [8, 9, 10, 11, 12, 13, 14, 15], [9, 10, 11, 12, 13, 14, 15], [10, 11, 12, 13, 14, 15], [11, 12, 13, 14, 15], [12, 13, 14, 15], [13, 14, 15], [14, 15], [15], []]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 3, 4, 5, 6, 7, 8, 9], [0, 1, 4, 5, 6, 7, 8, 9], [0, 1, 2, 5, 6, 7, 8, 9], [0, 1, 2, 3, 6, 7, 8, 9], [0, 1, 2, 3, 4, 7, 8, 9], [0, 1, 2, 3, 4, 5, 8, 9], [0, 1, 2, 3, 4, 5, 6, 9], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8]]) == True\n assert candidate(rooms = [[1, 2, 3], [0], [3, 4], [1, 2], [3]]) == True\n assert candidate(rooms = [[1, 2, 4], [2, 3], [0, 3], [1, 4], [0, 1]]) == True\n assert candidate(rooms = [[1, 2, 3], [0, 2], [1, 3], [1, 2]]) == True\n assert candidate(rooms = [[1], [3], [4], [1, 2, 3], [2]]) == True\n assert candidate(rooms = [[1, 3], [2, 4], [3, 4], [0, 4], [0, 1, 2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [2, 3], [3, 4], [4], []]) == True\n assert candidate(rooms = [[1, 2], [2, 3, 4], [0, 1], [2, 4], [2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9], [0], [2, 5, 6, 7, 8, 9], [3], [2, 3, 6, 7, 8, 9], [0, 1, 3, 4, 7, 8, 9], [0, 1, 2, 3, 4, 6, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8]]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [3, 2, 1, 0], [1, 2, 3], [0, 1], [0, 2]]) == True\n assert candidate(rooms = [[1, 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], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [12, 13, 14, 15, 16, 17, 18, 19, 20], [13, 14, 15, 16, 17, 18, 19, 20], [14, 15, 16, 17, 18, 19, 20], [15, 16, 17, 18, 19, 20], [16, 17, 18, 19, 20], [17, 18, 19, 20], [18, 19, 20], [19, 20], [20], []]) == True\n assert candidate(rooms = [[1, 2, 4], [0, 2, 3, 4], [0, 1, 3, 4], [2, 0, 1, 4], [0, 1, 2, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4], [2, 3], [1, 3, 4], [0, 2, 4], [0, 1, 3]]) == True\n assert candidate(rooms = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == True\n", "comparison": "exact"}, "public_tests": ["[[1],[2],[3],[]]", "[[1,3],[3,0,1],[2],[0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["rooms"], "leetcode_dataset_entry_point": "Solution().canVisitAllRooms", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:37+00:00", "tests_total": 86, "tests_dropped": 19, "flags": [], "topic_tags": ["depth-first-search", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def canVisitAllRooms(self, rooms: list[list[int]]) -> bool:", "container": "Solution", "callable": "canVisitAllRooms", "parameters": [{"name": "rooms", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 842, "task_id": "split-array-into-fibonacci-sequence", "difficulty": "Medium", "problem_description": "You are given a string of digits num, such as \"123456579\". We can split it into a Fibonacci-like sequence [123, 456, 579].\n\nFormally, a Fibonacci-like sequence is a list f of non-negative integers such that:\n\n- 0 <= f[i] < 2^31, (that is, each integer fits in a 32-bit signed integer type),\n- f.length >= 3, and\n- f[i] + f[i + 1] == f[i + 2] for all 0 <= i < f.length - 2.\n\nNote that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself.\n\nReturn any Fibonacci-like sequence split from num, or return [] if it cannot be done.\n\nExample 1:\n\nInput: num = \"1101111\"\nOutput: [11,0,11,11]\nExplanation: The output [110, 1, 111] would also be accepted.\n\nExample 2:\n\nInput: num = \"112358130\"\nOutput: []\nExplanation: The task is impossible.\n\nExample 3:\n\nInput: num = \"0123\"\nOutput: []\nExplanation: Leading zeroes are not allowed, so \"01\", \"2\", \"3\" is not valid.\n\nConstraints:\n\n- 1 <= num.length <= 200\n- num contains only digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"10\") == []\n assert candidate(num = \"1203\") == []\n assert candidate(num = \"101001011001101110000110011100011010011110000\") == []\n assert candidate(num = \"0123\") == []\n assert candidate(num = \"53983465721539834678539834699107966937716195040762699173453431867752970178509821133650133\") == []\n assert candidate(num = \"10112358\") == [1, 0, 1, 1, 2, 3, 5, 8]\n assert candidate(num = \"53983465510284675882952\") == []\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == []\n assert candidate(num = \"1101111\") == [11, 0, 11, 11]\n assert candidate(num = \"111\") == []\n assert candidate(num = \"123456579\") == [123, 456, 579]\n assert candidate(num = \"199100199\") == [1, 99, 100, 199]\n assert candidate(num = \"112358130\") == []\n assert candidate(num = \"0000\") == [0, 0, 0, 0]\n assert candidate(num = \"00000\") == [0, 0, 0, 0, 0]\n assert candidate(num = \"214748364721474836482147483646\") == []\n assert candidate(num = \"539834653091229486220197747750493000537622019774775049300053762\") == []\n assert candidate(num = \"5500550000000000000000000000000000000000000000000000000000000000\") == []\n assert candidate(num = \"1010101010101010101010101010101010101010101010101010101010101010101\") == []\n assert candidate(num = \"2189229958345551690260329539342957514193011232571777825519283043251\") == []\n assert candidate(num = \"1010203050813213455891440\") == []\n assert candidate(num = \"100000000010000000011000000012000000023000000450000007800000123\") == []\n assert candidate(num = \"112358132134558914423337761098715972584418559654330786547413903\") == []\n assert candidate(num = \"19641831781129858327132231435820140521011229963145654252296088955571186180559945309415\") == []\n assert candidate(num = \"55144233377\") == []\n assert candidate(num = \"539834657215398346785398346991818018118818645518818212\") == []\n assert candidate(num = \"30508132134558914423337710141520\") == []\n assert candidate(num = \"19910011992\") == []\n assert candidate(num = \"1001012030508132134558914423337761098159725844181676510946177112865746368750140518752964196544\") == []\n assert candidate(num = \"1000999199899799699599499399299199098979695949392919089796959493\") == []\n assert candidate(num = \"8914423337761098715972584418167651094655921349556979\") == []\n assert candidate(num = \"305078118299718606835889290810611235649871976067436781691303468\") == []\n assert candidate(num = \"01010101010101010101010101010101010101010101010101010101010101\") == []\n assert candidate(num = \"10102030508132134558914423337761098715972584214633628946\") == []\n assert candidate(num = \"101020305081321345589144\") == []\n assert candidate(num = \"5555500000000000000000000000000000000000000000000000000000000000000000000\") == []\n assert candidate(num = \"3654352961622705190521006455228285587903213238462643383279509884035\") == []\n assert candidate(num = \"1224365589144233377\") == []\n assert candidate(num = \"1001010110211233583132134558981391123581321345589144233377610987\") == []\n assert candidate(num = \"123456579101415202535588143\") == []\n assert candidate(num = \"12345678910111213141516171819202122232425262728293031323334353637383940\") == []\n assert candidate(num = \"3000000003\") == []\n assert candidate(num = \"3589014494737144108571129522619683030531176667422058003735352909040718542829032\") == []\n assert candidate(num = \"3174592653897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\") == []\n assert candidate(num = \"21892299583477870\") == []\n assert candidate(num = \"13213455891442333776109871597258441816765109465592134955697921\") == []\n assert candidate(num = \"1010203050813213455891442333776109815972584418167651094617711286574636875014051875296419654423337761098159725844181676510946177112865746368750140518752964196544\") == []\n assert candidate(num = \"1234567890123456789012345678901234567890\") == []\n assert candidate(num = \"11111111111111111111111111111111111111111111111111\") == []\n assert candidate(num = \"504329353555168827726123264864707818289106704556020971834363288219037107536233243\") == []\n assert candidate(num = \"305078116559834749165212441511537708168291561047446076484270032896\") == []\n assert candidate(num = \"1000000000000000000000000000000000000000000000000000000000000000101\") == []\n assert candidate(num = \"10000000000000000000000000000000000000000000000001000000000000000000000000\") == []\n assert candidate(num = \"111111111111111111111111111111111111111111111111111111111111111111111111111\") == []\n assert candidate(num = \"25841321345589144233377610987159725844181676510946\") == []\n assert candidate(num = \"352457863245986551816477364000016558014109896102208342120562338240750010987987\") == []\n assert candidate(num = \"55555555555555555555555555555555555555555555555555\") == []\n assert candidate(num = \"10100010001100021000320005300085001380021130341055089014402330377060\") == []\n assert candidate(num = \"21123581321345589144\") == []\n assert candidate(num = \"505349634\") == []\n assert candidate(num = \"1224366101525358912\") == []\n assert candidate(num = \"891442333776109871597258412914977374154233306638104538732745388111\") == []\n assert candidate(num = \"000000000000000000000000000000\") == [0, 0, 0, 0, 0, 0, 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(num = \"55005500000000000000000000000000000000000000000000000000000000000000000000000000\") == []\n assert candidate(num = \"0101020305081321345589144233377\") == []\n assert candidate(num = \"1000000000100000000020000000000\") == []\n assert candidate(num = \"050050500000000000000000000000000000000000000000000000000000000000000000000000000\") == []\n assert candidate(num = \"10100000000000000000000000000000000000000000000000000000000000000002\") == []\n assert candidate(num = \"2134558914423337761098715972584418559654330786547413903890131055\") == []\n assert candidate(num = \"101123581321345589144\") == [1, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]\n assert candidate(num = \"2112358132134558914423337761098715972584\") == []\n assert candidate(num = \"555555555555\") == []\n assert candidate(num = \"0123581321345589144\") == []\n assert candidate(num = \"1224365813213455891442333776109871597258412914977374154233306638104\") == []\n assert candidate(num = \"1964183938646565104891103515279327917900041088400684259688063\") == []\n assert candidate(num = \"9223372036854775807922337203685477580718446744073709551615\") == []\n", "comparison": "exact"}, "public_tests": ["\"1101111\"", "\"112358130\"", "\"0123\""], "hints": [], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().splitIntoFibonacci", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:39+00:00", "tests_total": 78, "tests_dropped": 2, "flags": [], "topic_tags": ["string", "backtracking"]}, "language": "python", "interface": {"raw_signature": "def splitIntoFibonacci(self, num: str) -> list[int]:", "container": "Solution", "callable": "splitIntoFibonacci", "parameters": [{"name": "num", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 844, "task_id": "backspace-string-compare", "difficulty": "Easy", "problem_description": "Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.\n\nNote that after backspacing an empty text, the text will continue empty.\n\nExample 1:\n\nInput: s = \"ab#c\", t = \"ad#c\"\nOutput: true\nExplanation: Both s and t become \"ac\".\n\nExample 2:\n\nInput: s = \"ab##\", t = \"c#d#\"\nOutput: true\nExplanation: Both s and t become \"\".\n\nExample 3:\n\nInput: s = \"a#c\", t = \"b\"\nOutput: false\nExplanation: s becomes \"c\" while t becomes \"b\".\n\nConstraints:\n\n- 1 <= s.length, t.length <= 200\n- s and t only contain lowercase letters and '#' characters.\n\nFollow up: Can you solve it in O(n) time and O(1) space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"#a#c\",t = \"c\") == True\n assert candidate(s = \"xywrrmp\",t = \"xywrrmu#p\") == True\n assert candidate(s = \"bbbextm#w\",t = \"bb#bbbextm#w\") == False\n assert candidate(s = \"ab\",t = \"a#b\") == False\n assert candidate(s = \"abc#d\",t = \"abzd#\") == False\n assert candidate(s = \"ab#\",t = \"a#b\") == False\n assert candidate(s = \"abc#d\",t = \"abcd#\") == False\n assert candidate(s = \"xywrrmp\",t = \"xywrrmp\") == True\n assert candidate(s = \"a####b\",t = \"b\") == True\n assert candidate(s = \"ab#\",t = \"ab#\") == True\n assert candidate(s = \"aaa###a\",t = \"aaaa##a\") == False\n assert candidate(s = \"abcd\",t = \"dcba\") == False\n assert candidate(s = \"a#c\",t = \"b\") == False\n assert candidate(s = \"abc#d\",t = \"abz#d\") == True\n assert candidate(s = \"ab#c\",t = \"ad#c\") == True\n assert candidate(s = \"hello#world#\",t = \"hello#wor#ld\") == False\n assert candidate(s = \"#a#c\",t = \"b\") == False\n assert candidate(s = \"a##c\",t = \"#a#c\") == True\n assert candidate(s = \"a###b\",t = \"b\") == True\n assert candidate(s = \"a###b\",t = \"a###b\") == True\n assert candidate(s = \"ab##\",t = \"c#d#\") == True\n assert candidate(s = \"ab#cd\",t = \"a#b#cd\") == False\n assert candidate(s = \"y#fo##f\",t = \"y#f#o##f\") == True\n assert candidate(s = \"ab#cd#e##f\",t = \"acdf\") == False\n assert candidate(s = \"abc###d##e##f##g##h##i##j##k##l##m##n##o##p##q##r##s##t##u##v##w##x##y##z##\",t = \"abc\") == False\n assert candidate(s = \"ab#cde##fg#\",t = \"ab#def#g#\") == False\n assert candidate(s = \"ab#cd#e##f\",t = \"abcdef##\") == False\n assert candidate(s = \"abcdef#####\",t = \"ab\") == False\n assert candidate(s = \"###abc###def###ghi###jkl###mno###pqr###stu###vwx###yz#\",t = \"abc###def###ghi###jkl###mno###pqr###stu###vwx###yz###\") == False\n assert candidate(s = \"a#b#cd#ef#gh##ij##klm#nop##qrst##uvw#xyz####\",t = \"a#b#cd#ef#gh##ij##klm#nop##qrst##uvw#xy#z#\") == False\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#\",t = \"#\") == True\n assert candidate(s = \"abcdefghij#klmnopqrst#uvwxyz#\",t = \"uvwxyz#tsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"abcdef#ghijkl#mnopqr#stuvwx#yz##\",t = \"yz##xwvu#tsrqpon#mlkjihg#fedcba\") == False\n assert candidate(s = \"a#b#cd#ef#gh##ij##klm#nop##qrst##uvw#xyz###\",t = \"abcdef#ghijklmnopqrstuvwxyz###\") == False\n assert candidate(s = \"abcd#efgh#ijkl#mnop#qrst#uvwx#yz##\",t = \"zyxw#vuts#rqpon#mlkj#ihgf#edcb#a\") == False\n assert candidate(s = \"x###y##z\",t = \"xyz###\") == False\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#\",t = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"zzzzzzzzzz####zzzzzzzzzz##\",t = \"zzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s = \"abcd##efghijkl##mnopqr##stuv##wxyz####\",t = \"abcd##efghijkl##mnopqr##stuv##wxy##z###\") == False\n assert candidate(s = \"abcd#e#f#gh#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"f####jkl###xyz##\",t = \"jkxyz#\") == False\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#\",t = \"abcdefghijklmnopqrstuvwxyz#\") == False\n assert candidate(s = \"ab#cdef###gh#ij#kl##mno###pqr####stu#####vwxyz##\",t = \"vwxyz##\") == False\n assert candidate(s = \"ab#c#d#efg\",t = \"abcdefg###\") == False\n assert candidate(s = \"abcdefg#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"z#y#x#w#v#u#t#s#r#q#p#o#n#m#l#k#j#i#h#g#f#e#d#c#b#a#\") == False\n assert candidate(s = \"a#b#c#d#e#f#\",t = \"#f#e#d#c#b#a#\") == True\n assert candidate(s = \"abcde#fghij#klmno#pqrs#tu#v#w#x#y#z#\",t = \"abcdefghijklmnopqrstuvwxy\") == False\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#\",t = \"z#y#x#w#v#u#t#s#r#q#p#o#n#m#l#k#j#i#h#g#f#e#d#c#b#a#\") == True\n assert candidate(s = \"##ab#c#d#e#f##g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"abcdefghijklmnopqrstuvwxyz\") == False\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#\",t = \"z##y##x##w##v##u##t##s##r##q##p##o##n##m##l##k##j##i##h##g##f##e##d##c##b##a\") == False\n assert candidate(s = \"x#y#z#\",t = \"x#y#z#\") == True\n assert candidate(s = \"a###a###a###a###a###a###a###a###a###a###\",t = \"a#\") == True\n assert candidate(s = \"a#b#b#c#d#d#e#e#f#f#g#g#h#h#i#i#j#j#k#k#l#l#m#m#n#n#o#o#p#p#q#q#r#r#s#s#t#t#u#u#v#v#w#w#x#x#y#y#z#z#\",t = \"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\") == False\n assert candidate(s = \"abc#d##ef###\",t = \"ab##ef\") == False\n assert candidate(s = \"z#y#x#w#v#u#t#s#r#q#p#o#n#m#l#k#j#i#h#g#f#e#d#c#b#a#\",t = \"zyxwvutsrqponmlkjihgfedcba#\") == False\n assert candidate(s = \"a#b#cd#ef#gh##ij##klm#nop##qrst##uvw#xyz###\",t = \"a#b#cd#ef#gh##ij##klm#nop##qrst##uvw#xy##z###\") == False\n assert candidate(s = \"a#b#c#d#e#f#g#h#i#j#\",t = \"abcdefghij#\") == False\n assert candidate(s = \"abcabcabcabc#abcabcabcabc#\",t = \"abcabcabcabcabcabcabcabc\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz#abc#d##\",t = \"abcdefghijklmnopqrstuvwxy#\") == False\n assert candidate(s = \"abcde#f#ghi#jkl#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"z\") == False\n assert candidate(s = \"######abc\",t = \"abc######\") == False\n assert candidate(s = \"abc#de#fgh#ijk#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"z#y#x#w#v#u#t#s#r#q#p#o#n#m#l#k#j#i#h#g#f#e#d#c#b#a\") == False\n assert candidate(s = \"abcde#f#gh#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"zxywvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"abcde##fgh##ij##k#\",t = \"abcd#efgh#ij##k\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz#abcdefghijklmnopqrstuvwxyz#\",t = \"abcdefghijklmnopqrstuvwxyz#abcdefghijklmnopqrstuvwxyz#\") == True\n assert candidate(s = \"#a#b#c#d#e#f#g#h#i#j#k#\",t = \"abcdefghijk#\") == False\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##\",t = \"#z##y##x##w##v##u##t##s##r##q##p##o##n##m##l##k##j##i##h##g##f##e##d##c##b##a##\") == True\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#\",t = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"####abc##d##ef###g####\",t = \"abc##d##ef###g####\") == True\n assert candidate(s = \"#a#a#a#a#a#a#a#a#a#a#\",t = \"a#a#a#a#a#a#a#a#a#a#\") == True\n assert candidate(s = \"ab#cd##ef#g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"efghijklmnopqrstuvwxyz\") == False\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##\",t = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"longstring#####anotherstring\",t = \"longanotherstring\") == False\n assert candidate(s = \"###xyz\",t = \"xyz###\") == False\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##\",t = \"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##\") == True\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#\",t = \"abcdefghijklmnopqrstuvwxyz\") == False\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##\",t = \"z##y##x##w##v##u##t##s##r##q##p##o##n##m##l##k##j##i##h##g##f##e##d##c##b##a##\") == True\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#\",t = \"#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#\") == True\n assert candidate(s = \"xy#z##\",t = \"xzz#\") == False\n assert candidate(s = \"x####y\",t = \"xy#\") == False\n assert candidate(s = \"qwerty#uiop##asdfghjkl##zxcvbnm##\",t = \"qwerty#uiop##asdfghjkl##zxcvbnm##\") == True\n assert candidate(s = \"abc#d##e\",t = \"ab##de\") == False\n assert candidate(s = \"abcdefg#####hijkl#####mnop#####qrstu#####vwxyz\",t = \"hijklmnopqrstuuvwxyz\") == False\n assert candidate(s = \"abcde######\",t = \"fghij#####\") == True\n assert candidate(s = \"xylophone##music####\",t = \"xylophone###music####\") == False\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#\",t = \"zxywvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz##\",t = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz##\") == False\n assert candidate(s = \"ab#cd#ef#gh#ij#kl#mn#op#qr#st#uv#wx#yz#\",t = \"yz#xw#vu#ts#rq#po#nm#lk#ji#hg#fe#dc#ba\") == False\n assert candidate(s = \"abcde###fghijk###lmnop###qrstuvwxyz###\",t = \"qrstuvwxyz###mnop###fghijk###abcde###\") == False\n assert candidate(s = \"ab##cd##ef##gh##ij##kl##mn##op##qr##st##uv##wx##yz##\",t = \"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#\") == True\n assert candidate(s = \"abc#de#f##g#hi#jkl##mno###pqr####stu#####vwxyz##\",t = \"abc#de#f##g#hi#jkl##mno###pqr####stu#####\") == False\n assert candidate(s = \"##abc#d##ef#g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#\",t = \"abcdefghijklnopqrstuvwxyz\") == False\n", "comparison": "exact"}, "public_tests": ["\"ab#c\"\n\"ad#c\"", "\"ab##\"\n\"c#d#\"", "\"a#c\"\n\"b\""], "hints": [], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().backspaceCompare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:41+00:00", "tests_total": 109, "tests_dropped": 17, "flags": [], "topic_tags": ["two-pointers", "string", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def backspaceCompare(self, s: str, t: str) -> bool:", "container": "Solution", "callable": "backspaceCompare", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 845, "task_id": "longest-mountain-in-array", "difficulty": "Medium", "problem_description": "You may recall that an array arr is a mountain array if and only if:\n\n- arr.length >= 3\n- There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:\n - arr[0] < arr[1] < ... < arr[i - 1] < arr[i]\n - arr[i] > arr[i + 1] > ... > arr[arr.length - 1]\n\nGiven an integer array arr, return the length of the longest subarray, which is a mountain. Return 0 if there is no mountain subarray.\n\nExample 1:\n\nInput: arr = [2,1,4,7,3,2,5]\nOutput: 5\nExplanation: The largest mountain is [1,4,7,3,2] which has length 5.\n\nExample 2:\n\nInput: arr = [2,2,2]\nOutput: 0\nExplanation: There is no mountain.\n\nConstraints:\n\n- 1 <= arr.length <= 10^4\n- 0 <= arr[i] <= 10^4\n\nFollow up:\n\n- Can you solve it using only one pass?\n- Can you solve it in O(1) space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 11\n assert candidate(arr = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1]) == 0\n assert candidate(arr = [1, 3, 1, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == 11\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(arr = [1, 2, 3]) == 0\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 0]) == 8\n assert candidate(arr = [1, 3, 5, 4, 2, 3, 6, 7, 5]) == 5\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1]) == 10\n assert candidate(arr = [3, 3, 3, 2, 1]) == 0\n assert candidate(arr = [1, 2, 2, 1]) == 0\n assert candidate(arr = [3, 3, 3, 2, 1, 2, 3, 3, 3]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 1]) == 7\n assert candidate(arr = [1, 3, 1]) == 3\n assert candidate(arr = [2, 1, 4, 7, 3, 2, 5]) == 5\n assert candidate(arr = [1, 2, 2, 2, 1]) == 0\n assert candidate(arr = [2, 2, 2]) == 0\n assert candidate(arr = [1, 3, 5, 4, 2, 3, 4, 5, 3, 1]) == 6\n assert candidate(arr = [2, 2, 2, 3, 4, 5, 4, 3, 2, 1, 1]) == 8\n assert candidate(arr = [0, 2, 1, 0]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 3, 1, 4, 5, 2, 1]) == 5\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(arr = [0, 2, 1, 0, 2, 0, 1, 0]) == 4\n assert candidate(arr = [2, 3, 3, 2, 2, 2, 1]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(arr = [3, 3, 3, 2, 1, 2, 3]) == 0\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5]) == 3\n assert candidate(arr = [0, 2, 1, 0, 2, 1, 0]) == 4\n assert candidate(arr = [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]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 2, 3, 4, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 11\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 5, 6, 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]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 11\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1]) == 12\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == 10\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1]) == 11\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 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]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 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]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 12\n assert candidate(arr = [1, 2, 3, 4, 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]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(arr = [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]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11]) == 15\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(arr = [5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(arr = [3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 15\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1]) == 11\n assert candidate(arr = [1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 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]) == 23\n assert candidate(arr = [1, 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]) == 5\n assert candidate(arr = [1, 3, 5, 4, 2, 3, 4, 5, 3, 1, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [2, 1, 4, 7, 3, 2, 5, 6, 8, 4, 3, 2, 1]) == 8\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 13\n assert candidate(arr = [8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(arr = [2, 1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 15\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [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, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [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]) == 9\n assert candidate(arr = [1, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 19\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 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]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 17\n assert candidate(arr = [8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1]) == 11\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]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 12\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 19\n assert candidate(arr = [2, 1, 4, 7, 3, 2, 5, 6, 8, 4, 3, 1]) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 19\n assert candidate(arr = [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]) == 19\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(arr = [1, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 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]) == 20\n assert candidate(arr = [1, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 13\n assert candidate(arr = [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, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 19\n assert candidate(arr = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 13\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1]) == 12\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(arr = [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]) == 9\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 9\n assert candidate(arr = [1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 5\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 11\n assert candidate(arr = [2, 1, 4, 7, 3, 2, 5, 8, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(arr = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr = [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, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(arr = [1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 11\n assert candidate(arr = [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]) == 5\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 17\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 11\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 12\n assert candidate(arr = [3, 3, 3, 3, 2, 1, 2, 3, 3, 3, 3, 2, 1, 2, 3, 3, 3, 3, 2, 1]) == 0\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 0\n assert candidate(arr = [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, 0]) == 12\n assert candidate(arr = [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]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6]) == 18\n assert candidate(arr = [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]) == 11\n assert candidate(arr = [5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 14\n assert candidate(arr = [5, 6, 7, 8, 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]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == 20\n assert candidate(arr = [2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 18\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 5, 4, 3, 2, 1, 0]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 8\n assert candidate(arr = [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, 3, 4, 5]) == 9\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 19\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 3, 2, 1, 0]) == 11\n", "comparison": "exact"}, "public_tests": ["[2,1,4,7,3,2,5]", "[2,2,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().longestMountain", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:43+00:00", "tests_total": 160, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "dynamic-programming", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def longestMountain(self, arr: list[int]) -> int:", "container": "Solution", "callable": "longestMountain", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 846, "task_id": "hand-of-straights", "difficulty": "Medium", "problem_description": "Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards.\n\nGiven an integer array hand where hand[i] is the value written on the i^th card and an integer groupSize, return true if she can rearrange the cards, or false otherwise.\n\nExample 1:\n\nInput: hand = [1,2,3,6,2,3,4,7,8], groupSize = 3\nOutput: true\nExplanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8]\n\nExample 2:\n\nInput: hand = [1,2,3,4,5], groupSize = 4\nOutput: false\nExplanation: Alice's hand can not be rearranged into groups of 4.\n\nConstraints:\n\n- 1 <= hand.length <= 10^4\n- 0 <= hand[i] <= 10^9\n- 1 <= groupSize <= hand.length\n\nNote: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hand = [1, 2, 3, 4, 5, 6],groupSize = 2) == True\n assert candidate(hand = [1, 1, 2, 2, 3, 3],groupSize = 3) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],groupSize = 4) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],groupSize = 5) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6],groupSize = 3) == True\n assert candidate(hand = [1, 2, 3, 4, 5],groupSize = 4) == False\n assert candidate(hand = [1, 2, 3, 6, 2, 3, 4, 7, 8],groupSize = 3) == True\n assert candidate(hand = [8, 10, 12],groupSize = 3) == False\n assert candidate(hand = [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],groupSize = 5) == False\n assert candidate(hand = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],groupSize = 10) == True\n assert candidate(hand = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13],groupSize = 4) == False\n assert candidate(hand = [1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12],groupSize = 3) == False\n assert candidate(hand = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],groupSize = 5) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],groupSize = 10) == True\n assert candidate(hand = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],groupSize = 4) == False\n assert candidate(hand = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],groupSize = 5) == True\n assert candidate(hand = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],groupSize = 5) == False\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 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],groupSize = 4) == True\n assert candidate(hand = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],groupSize = 2) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],groupSize = 8) == True\n assert candidate(hand = [1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],groupSize = 5) == False\n assert candidate(hand = [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],groupSize = 8) == False\n assert candidate(hand = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],groupSize = 5) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],groupSize = 3) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],groupSize = 2) == True\n assert candidate(hand = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],groupSize = 4) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],groupSize = 5) == True\n assert candidate(hand = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],groupSize = 4) == False\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 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],groupSize = 6) == False\n assert candidate(hand = [1, 3, 2, 4, 5, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],groupSize = 2) == True\n assert candidate(hand = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],groupSize = 4) == True\n assert candidate(hand = [1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10],groupSize = 3) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],groupSize = 4) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45],groupSize = 5) == True\n assert candidate(hand = [1, 3, 2, 5, 4, 6, 7, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30],groupSize = 2) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],groupSize = 6) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],groupSize = 4) == True\n assert candidate(hand = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],groupSize = 5) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],groupSize = 10) == False\n assert candidate(hand = [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, 15, 15],groupSize = 5) == False\n assert candidate(hand = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],groupSize = 5) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],groupSize = 5) == True\n assert candidate(hand = [3, 3, 3, 2, 2, 1, 4, 4, 4],groupSize = 3) == False\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12],groupSize = 4) == True\n assert candidate(hand = [10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14],groupSize = 4) == False\n assert candidate(hand = [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],groupSize = 6) == False\n assert candidate(hand = [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],groupSize = 5) == False\n assert candidate(hand = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28],groupSize = 7) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45],groupSize = 7) == False\n assert candidate(hand = [5, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14],groupSize = 4) == False\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],groupSize = 2) == True\n assert candidate(hand = [3, 3, 3, 3, 4, 4, 5, 5, 5],groupSize = 3) == False\n assert candidate(hand = [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],groupSize = 3) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],groupSize = 5) == True\n assert candidate(hand = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],groupSize = 10) == False\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],groupSize = 3) == True\n assert candidate(hand = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],groupSize = 5) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],groupSize = 5) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],groupSize = 5) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],groupSize = 3) == True\n assert candidate(hand = [10, 10, 10, 10, 10, 11, 11, 11, 11, 11],groupSize = 5) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],groupSize = 10) == True\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],groupSize = 2) == True\n assert candidate(hand = [1, 3, 2, 5, 4, 6, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28, 33, 32, 31, 36, 35, 34, 39, 38, 37, 42, 41, 40],groupSize = 3) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],groupSize = 10) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],groupSize = 5) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],groupSize = 3) == True\n assert candidate(hand = [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, 8, 9, 9, 9, 9, 10, 10, 10, 10],groupSize = 5) == False\n assert candidate(hand = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],groupSize = 5) == False\n assert candidate(hand = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],groupSize = 3) == True\n assert candidate(hand = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],groupSize = 3) == False\n assert candidate(hand = [3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],groupSize = 3) == False\n assert candidate(hand = [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],groupSize = 4) == False\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],groupSize = 5) == True\n assert candidate(hand = [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],groupSize = 2) == True\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],groupSize = 5) == True\n assert candidate(hand = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],groupSize = 8) == True\n assert candidate(hand = [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],groupSize = 3) == False\n assert candidate(hand = [1, 3, 2, 4, 5, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15],groupSize = 4) == True\n assert candidate(hand = [1, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11],groupSize = 4) == False\n assert candidate(hand = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],groupSize = 2) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,6,2,3,4,7,8]\n3", "[1,2,3,4,5]\n4"], "hints": [], "metadata": {"canonical_parameter_names": ["hand", "groupSize"], "leetcode_dataset_entry_point": "Solution().isNStraightHand", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:46+00:00", "tests_total": 81, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def isNStraightHand(self, hand: list[int], groupSize: int) -> bool:", "container": "Solution", "callable": "isNStraightHand", "parameters": [{"name": "hand", "type": "list[int]"}, {"name": "groupSize", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 847, "task_id": "shortest-path-visiting-all-nodes", "difficulty": "Hard", "problem_description": "You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge.\n\nReturn the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.\n\nExample 1:\n\nInput: graph = [[1,2,3],[0],[0],[0]]\nOutput: 4\nExplanation: One possible path is [1,0,2,0,3]\n\nExample 2:\n\nInput: graph = [[1],[0,2,4],[1,3,4],[2],[1,2]]\nOutput: 4\nExplanation: One possible path is [0,1,4,2,3]\n\nConstraints:\n\n- n == graph.length\n- 1 <= n <= 12\n- 0 <= graph[i].length < n\n- graph[i] does not contain i.\n- If graph[a] contains b, then graph[b] contains a.\n- The input graph is always connected.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(graph = [[1, 2], [0, 2, 3], [0, 1], [1]]) == 3\n assert candidate(graph = [[2, 3, 4, 5], [3, 4, 5, 6], [0, 3, 4, 5], [0, 1, 2, 5], [0, 1, 2], [0, 1, 2, 3], [1]]) == 6\n assert candidate(graph = [[1, 3, 4, 5], [0, 2, 3, 4, 5], [1, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4]]) == 5\n assert candidate(graph = [[1, 2, 3], [0], [0], [0]]) == 4\n assert candidate(graph = [[2, 5, 7], [2, 4], [0, 1], [5], [1, 6], [0, 3], [4], [0]]) == 8\n assert candidate(graph = [[1, 2], [0], [0]]) == 2\n assert candidate(graph = [[1], [0, 2, 4], [1, 3, 4], [2], [1, 2]]) == 4\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 4], [0, 1, 3], [0, 2, 4], [0, 1, 3, 5], [4, 6, 7], [5, 7], [5, 6]]) == 7\n assert candidate(graph = [[1, 2, 3, 4], [0, 2], [0, 1, 3, 4], [0, 2, 4], [0, 1, 2, 3]]) == 4\n assert candidate(graph = [[1, 2, 3], [0, 4, 5], [0, 5, 6], [0, 4, 6], [1, 3, 7], [1, 2, 7], [2, 3, 8], [4, 5, 8], [6, 7]]) == 8\n assert candidate(graph = [[1, 2, 3, 4, 5], [0], [0], [0], [0], [0]]) == 8\n assert candidate(graph = [[1, 4, 5], [0, 2, 4], [1, 3, 4], [2], [0, 1, 2, 6], [0], [4]]) == 7\n assert candidate(graph = [[1, 2, 3], [0, 4], [0, 5], [0, 6], [1], [2], [3]]) == 8\n assert candidate(graph = [[1, 2, 3, 4, 5], [0, 6, 7], [0, 6, 7], [0, 6, 7], [0, 6, 7], [0, 6, 7], [1, 2, 3, 4, 5, 7], [1, 2, 3, 4, 5, 6]]) == 8\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 5], [0, 1, 3], [0, 2, 4], [0, 3, 5], [1, 4]]) == 5\n assert candidate(graph = [[1, 2, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4]]) == 5\n assert candidate(graph = [[1, 4], [0, 2, 3, 4], [1, 3, 4], [1, 2, 4], [0, 1, 2, 3]]) == 4\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 11\n assert candidate(graph = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4, 6], [5]]) == 6\n assert candidate(graph = [[1, 2], [0, 3, 5], [0, 4, 6], [1, 5], [2, 6], [1, 3, 6], [2, 4, 5]]) == 6\n assert candidate(graph = [[1, 3], [0, 2, 4], [1, 5], [0, 4], [1, 3, 5], [2, 4]]) == 5\n assert candidate(graph = [[1, 3], [0, 2, 3, 4, 5], [1, 4, 5], [0, 1, 4, 5], [1, 2, 3, 5], [1, 2, 3, 4]]) == 5\n assert candidate(graph = [[1, 2, 5], [0, 2, 4, 5], [0, 1, 3, 5], [2], [1], [0, 1, 2]]) == 5\n assert candidate(graph = [[1, 5, 7], [0, 2, 6], [1, 3, 6, 7], [2, 4, 6, 7], [3, 5, 6], [0, 1, 4, 6], [1, 2, 3, 4, 5, 7], [0, 2, 3, 6]]) == 7\n assert candidate(graph = [[1, 5], [0, 2, 6], [1, 3, 6], [2, 4, 6], [3, 5, 6], [0, 1, 4, 6], [1, 2, 3, 4, 5]]) == 6\n assert candidate(graph = [[1, 5], [0, 2, 6], [1, 3], [2, 4], [3, 5], [0, 4, 6], [1, 5]]) == 6\n assert candidate(graph = [[1, 3, 4], [0, 2], [1, 3, 4], [0, 2, 5], [0, 2, 5], [3, 4]]) == 5\n assert candidate(graph = [[1, 2], [0, 3, 4, 5], [0, 6, 7], [1], [1, 7], [1, 8], [2], [2, 3, 4], [5]]) == 9\n assert candidate(graph = [[1, 2, 3, 4], [0, 5, 6, 7], [0, 5, 6, 7], [0, 5, 6, 7], [0, 5, 6, 7], [1, 2, 3, 4, 8], [1, 2, 3, 4, 8], [1, 2, 3, 4, 8], [5, 6, 7]]) == 8\n assert candidate(graph = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 3, 5, 6], [0, 1, 2, 5, 6, 7], [1], [2, 3, 6], [2, 3, 5, 7], [3, 6]]) == 7\n assert candidate(graph = [[1, 5, 6], [0, 3], [3, 6], [1, 2, 6], [5], [0, 4], [0, 2, 3, 1]]) == 6\n assert candidate(graph = [[1, 2], [0, 3, 4, 5], [0, 6, 7], [1], [1], [1, 8], [2], [2], [5]]) == 11\n assert candidate(graph = [[1, 4], [0, 2], [1, 3], [2, 4, 5], [0, 1, 3], [3]]) == 5\n assert candidate(graph = [[1, 2, 5], [0, 3, 6], [0, 3, 7], [1, 2, 8], [5, 6, 7], [0, 4, 8], [1, 4, 8], [2, 4, 8], [3, 5, 6, 7]]) == 8\n assert candidate(graph = [[1, 2, 4, 6], [0, 2, 3, 5], [0, 1, 5], [1, 4, 6], [0, 3, 5], [1, 2, 4, 6], [0, 3, 5]]) == 6\n assert candidate(graph = [[1, 2, 3], [0, 4, 5], [0, 6], [0, 7], [1, 5, 7], [1, 4, 6], [2, 5, 7], [3, 4, 6]]) == 7\n assert candidate(graph = [[1, 2, 4], [0, 3, 5], [0, 3, 6], [1, 2, 7], [0, 8], [1, 8], [2, 8], [3, 8], [4, 5, 6, 7]]) == 8\n assert candidate(graph = [[1, 3], [0, 2, 4], [1, 3, 5], [0, 2, 6], [1], [2], [3]]) == 7\n assert candidate(graph = [[1, 2, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4, 6, 7, 8], [5], [5], [5]]) == 10\n assert candidate(graph = [[1], [0, 2], [1, 3, 4], [2], [2, 5, 6], [4], [4, 7], [6, 8], [7]]) == 10\n assert candidate(graph = [[1, 5], [0, 2, 4], [1, 3, 4], [2, 4], [1, 2, 3], [0]]) == 5\n assert candidate(graph = [[1, 3], [0, 2, 4], [1, 3, 5], [0, 2, 6], [1, 5, 7], [2, 4, 8], [3, 8], [4, 8], [5, 6, 7]]) == 8\n assert candidate(graph = [[1, 3], [0, 2], [1, 3, 4], [0, 1, 2], [2, 5], [4]]) == 5\n assert candidate(graph = [[1, 2, 3], [0, 4, 5], [0, 6, 7], [0, 8, 9], [1], [1], [2], [2], [3], [3]]) == 14\n assert candidate(graph = [[1, 5], [0, 2, 6], [1, 3], [2, 5], [5], [0, 1, 3, 4], [1]]) == 7\n assert candidate(graph = [[1, 2, 5], [0, 2, 6], [0, 1, 3], [2], [5], [0, 4, 6], [1, 5]]) == 6\n assert candidate(graph = [[1, 2], [0, 3, 4], [0, 5], [1], [1, 5], [2, 4]]) == 5\n assert candidate(graph = [[1, 3, 4], [0, 2, 4], [1, 3, 4, 5], [0, 2], [0, 1, 2, 5], [2, 4, 6], [5]]) == 6\n assert candidate(graph = [[1], [0, 2, 3, 4], [1, 5], [1, 6], [1, 7], [2], [3], [4, 8], [7]]) == 11\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 3, 5], [0, 1, 5], [0, 1, 4, 6], [0, 3, 6], [1, 2, 6], [3, 4, 5]]) == 6\n assert candidate(graph = [[1, 2, 3, 4, 5], [0, 2, 3, 6, 7], [0, 1, 4, 7, 8], [0, 1, 4, 7, 9], [0, 2, 3, 8, 9, 10], [0, 6, 7, 11], [1, 5, 8, 11], [1, 5, 6, 10, 11], [2, 4, 6, 10], [3, 4, 7, 10, 11], [4, 6, 7, 8, 9, 11], [5, 6, 7, 8, 9, 10]]) == 11\n assert candidate(graph = [[1, 2], [0, 3, 4], [0, 5, 6], [1], [1, 6], [2], [2, 4, 3]]) == 6\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[0],[0],[0]]", "[[1],[0,2,4],[1,3,4],[2],[1,2]]"], "hints": [], "metadata": {"canonical_parameter_names": ["graph"], "leetcode_dataset_entry_point": "Solution().shortestPathLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:48+00:00", "tests_total": 63, "tests_dropped": 10, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "bit-manipulation", "breadth-first-search", "graph", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def shortestPathLength(self, graph: list[list[int]]) -> int:", "container": "Solution", "callable": "shortestPathLength", "parameters": [{"name": "graph", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 848, "task_id": "shifting-letters", "difficulty": "Medium", "problem_description": "You are given a string s of lowercase English letters and an integer array shifts of the same length.\n\nCall the shift() of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a').\n\n- For example, shift('a') = 'b', shift('t') = 'u', and shift('z') = 'a'.\n\nNow for each shifts[i] = x, we want to shift the first i + 1 letters of s, x times.\n\nReturn the final string after all such shifts to s are applied.\n\nExample 1:\n\nInput: s = \"abc\", shifts = [3,5,9]\nOutput: \"rpl\"\nExplanation: We start with \"abc\".\nAfter shifting the first 1 letters of s by 3, we have \"dbc\".\nAfter shifting the first 2 letters of s by 5, we have \"igc\".\nAfter shifting the first 3 letters of s by 9, we have \"rpl\", the answer.\n\nExample 2:\n\nInput: s = \"aaa\", shifts = [1,2,3]\nOutput: \"gfd\"\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n- shifts.length == s.length\n- 0 <= shifts[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaa\",shifts = [1, 2, 3]) == \"gfd\"\n assert candidate(s = \"abc\",shifts = [26, 52, 78]) == \"abc\"\n assert candidate(s = \"a\",shifts = [25]) == \"z\"\n assert candidate(s = \"abcdef\",shifts = [0, 0, 0, 0, 0, 0]) == \"abcdef\"\n assert candidate(s = \"abcd\",shifts = [10, 20, 30, 40]) == \"wnur\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == \"nnmkhdysldukznamxhqyflquxz\"\n assert candidate(s = \"abcdef\",shifts = [1, 2, 3, 4, 5, 6]) == \"vvuspl\"\n assert candidate(s = \"abcd\",shifts = [0, 0, 0, 0]) == \"abcd\"\n assert candidate(s = \"abc\",shifts = [3, 5, 9]) == \"rpl\"\n assert candidate(s = \"aaa\",shifts = [1000000000, 1000000000, 1000000000]) == \"kym\"\n assert candidate(s = \"a\",shifts = [1000000000]) == \"m\"\n assert candidate(s = \"z\",shifts = [1]) == \"a\"\n assert candidate(s = \"zzz\",shifts = [1000000000, 1000000000, 1000000000]) == \"jxl\"\n assert candidate(s = \"xyz\",shifts = [1, 2, 3]) == \"ddc\"\n assert candidate(s = \"abcdef\",shifts = [1, 1, 1, 1, 1, 1]) == \"gggggg\"\n assert candidate(s = \"zzz\",shifts = [1000000000, 1000000000, 1000000000]) == \"jxl\"\n assert candidate(s = \"abcd\",shifts = [1, 1, 1, 1]) == \"eeee\"\n assert candidate(s = \"qzcvxnbtrslkjhgf\",shifts = [97, 86, 75, 64, 53, 42, 31, 20, 9, 8, 7, 6, 5, 4, 3, 2]) == \"iytpfusfjbmexqlh\"\n assert candidate(s = \"aaaabbbbcccc\",shifts = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108]) == \"ipvafiklmljg\"\n assert candidate(s = \"abcabcabc\",shifts = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == \"ssrmmlggf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefgh\",shifts = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500]) == \"etozspob\"\n assert candidate(s = \"hello\",shifts = [5, 5, 5, 5, 5]) == \"gyavt\"\n assert candidate(s = \"abcd\",shifts = [25, 24, 23, 22]) == \"qsvz\"\n assert candidate(s = \"python\",shifts = [97, 97, 97, 97, 97, 97]) == \"zprmag\"\n assert candidate(s = \"hello\",shifts = [25, 98, 23, 56, 78]) == \"bzmpo\"\n assert candidate(s = \"abc\",shifts = [26, 52, 78]) == \"abc\"\n assert candidate(s = \"rollingupdates\",shifts = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == \"ybfntimmuwirtz\"\n assert candidate(s = \"xyz\",shifts = [26, 52, 78]) == \"xyz\"\n assert candidate(s = \"python\",shifts = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555]) == \"mjtdnw\"\n assert candidate(s = \"programming\",shifts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == \"ghbosstgnbb\"\n assert candidate(s = \"xyzabc\",shifts = [3, 2, 1, 0, 5, 4]) == \"mkjjkg\"\n assert candidate(s = \"aabbccdd\",shifts = [9, 8, 7, 6, 5, 4, 3, 2]) == \"sjcvqlif\"\n assert candidate(s = \"abcdefg\",shifts = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000]) == \"sxgtkfe\"\n assert candidate(s = \"abcdabcdabcd\",shifts = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == \"eedbuutrkkjh\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"cbzwsnhasj\"\n assert candidate(s = \"zzzzzz\",shifts = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555]) == \"wkzvyi\"\n assert candidate(s = \"a\",shifts = [0]) == \"a\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000]) == \"ynjmwnlqcv\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == \"nblrtrlbnv\"\n assert candidate(s = \"xyzxyzxyz\",shifts = [25, 24, 23, 22, 21, 20, 19, 18, 17]) == \"egjkpvzhq\"\n assert candidate(s = \"hello\",shifts = [1, 2, 3, 4, 5]) == \"wsxut\"\n assert candidate(s = \"a\",shifts = [1]) == \"b\"\n assert candidate(s = \"programming\",shifts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == \"herulvducoj\"\n assert candidate(s = \"xyzabc\",shifts = [25, 2, 3, 4, 5, 6]) == \"qsrpmi\"\n assert candidate(s = \"abcde\",shifts = [5, 10, 15, 20, 25]) == \"xtkwd\"\n assert candidate(s = \"shift\",shifts = [97, 98, 99, 100, 101]) == \"tpwyq\"\n assert candidate(s = \"zzzzzzzzzz\",shifts = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == \"nrzlbvtvbl\"\n assert candidate(s = \"hello\",shifts = [10, 20, 30, 40, 50]) == \"bobxm\"\n assert candidate(s = \"xyz\",shifts = [1000000000, 1000000000, 1]) == \"wla\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == \"nnmkhdysldukznamxhqyflquxz\"\n assert candidate(s = \"abcd\",shifts = [0, 0, 0, 0]) == \"abcd\"\n assert candidate(s = \"abcdef\",shifts = [26, 52, 78, 104, 130, 156]) == \"abcdef\"\n assert candidate(s = \"abz\",shifts = [1, 1, 25]) == \"bby\"\n assert candidate(s = \"mnopqr\",shifts = [26, 25, 24, 23, 22, 21]) == \"xyadhm\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [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]) == \"noonlieztmevlaobnyirzgmrvy\"\n assert candidate(s = \"wraparound\",shifts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"ztamtfwvgn\"\n assert candidate(s = \"hellothere\",shifts = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == \"almwrsengj\"\n assert candidate(s = \"python\",shifts = [25, 24, 23, 22, 21, 20]) == \"uebsdh\"\n assert candidate(s = \"abcdefghij\",shifts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == \"otcpgbadkv\"\n assert candidate(s = \"zzzzzzzz\",shifts = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == \"rfthvjxl\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\",shifts = [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]) == \"zaplvubtzgnwgqsoshswtibkzr\"\n assert candidate(s = \"z\",shifts = [26]) == \"z\"\n assert candidate(s = \"aabbccddeeff\",shifts = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000, 50000000, 25000000]) == \"ymxdgezpckpr\"\n assert candidate(s = \"aaaabbbb\",shifts = [1, 2, 3, 4, 5, 6, 7, 8]) == \"kjhebwqj\"\n assert candidate(s = \"aaaaabbbbb\",shifts = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == \"kowiytxfrh\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"zxvtrpnljhfdbzxvtrpnljhfdb\"\n assert candidate(s = \"abcdefg\",shifts = [1, 2, 3, 4, 5, 6, 7]) == \"ccbzwsn\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [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]) == \"npswbhowfpamzncsjbuojfcazz\"\n assert candidate(s = \"abcxyz\",shifts = [0, 1, 2, 25, 50, 75]) == \"xyyrtw\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",shifts = [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]) == \"mmnpswbhowfpamzncsjbuojfca\"\n assert candidate(s = \"mnopqr\",shifts = [3, 2, 1, 0, 5, 4]) == \"bzyyzv\"\n assert candidate(s = \"xyz\",shifts = [25, 50, 75]) == \"rtw\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",shifts = [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]) == \"npswbhowfpamzncsjbuojfcazz\"\n assert candidate(s = \"qznooo\",shifts = [987654321, 123456789, 987654321, 123456789, 987654321, 123456789]) == \"skxhgp\"\n assert candidate(s = \"bxyz\",shifts = [2, 3, 25, 1]) == \"gaya\"\n assert candidate(s = \"boundary\",shifts = [26, 26, 26, 26, 26, 26, 26, 26]) == \"boundary\"\n assert candidate(s = \"programming\",shifts = [26, 52, 78, 104, 130, 156, 182, 208, 234, 260, 286]) == \"programming\"\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n[3,5,9]", "\"aaa\"\n[1,2,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "shifts"], "leetcode_dataset_entry_point": "Solution().shiftingLetters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:50+00:00", "tests_total": 88, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "string", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def shiftingLetters(self, s: str, shifts: list[int]) -> str:", "container": "Solution", "callable": "shiftingLetters", "parameters": [{"name": "s", "type": "str"}, {"name": "shifts", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 849, "task_id": "maximize-distance-to-closest-person", "difficulty": "Medium", "problem_description": "You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the i^th seat, and seats[i] = 0 represents that the i^th seat is empty (0-indexed).\n\nThere is at least one empty seat, and at least one person sitting.\n\nAlex wants to sit in the seat such that the distance between him and the closest person to him is maximized.\n\nReturn that maximum distance to the closest person.\n\nExample 1:\n\nInput: seats = [1,0,0,0,1,0,1]\nOutput: 2\nExplanation:\nIf Alex sits in the second open seat (i.e. seats[2]), then the closest person has distance 2.\nIf Alex sits in any other open seat, the closest person has distance 1.\nThus, the maximum distance to the closest person is 2.\n\nExample 2:\n\nInput: seats = [1,0,0,0]\nOutput: 3\nExplanation:\nIf Alex sits in the last seat (i.e. seats[3]), the closest person is 3 seats away.\nThis is the maximum distance possible, so the answer is 3.\n\nExample 3:\n\nInput: seats = [0,1]\nOutput: 1\n\nConstraints:\n\n- 2 <= seats.length <= 2 * 10^4\n- seats[i] is 0 or 1.\n- At least one seat is empty.\n- At least one seat is occupied.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [0, 0, 0, 1, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 1]) == 2\n assert candidate(seats = [0, 0, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [1, 0, 0, 0]) == 3\n assert candidate(seats = [0, 1]) == 1\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0]) == 2\n assert candidate(seats = [1, 1, 0, 0, 0, 0, 1, 1]) == 2\n assert candidate(seats = [0, 0, 0, 1]) == 3\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 1]) == 4\n assert candidate(seats = [1, 0, 0, 1, 0, 0, 1]) == 1\n assert candidate(seats = [1, 0, 0, 0, 1, 0, 1]) == 2\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [0, 0, 1, 0, 1, 0, 1, 0, 0]) == 2\n assert candidate(seats = [0, 0, 1, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [1, 0, 0, 1, 0, 0, 0, 0, 1]) == 2\n assert candidate(seats = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [1, 0, 0, 1, 0, 0, 0, 1]) == 2\n assert candidate(seats = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [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]) == 18\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 19\n assert candidate(seats = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]) == 5\n assert candidate(seats = [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]) == 19\n assert candidate(seats = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) == 4\n assert candidate(seats = [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]) == 27\n assert candidate(seats = [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, 1]) == 29\n assert candidate(seats = [0, 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(seats = [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, 1]) == 14\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [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, 1, 0, 0, 0, 1]) == 10\n assert candidate(seats = [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]) == 13\n assert candidate(seats = [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, 0, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(seats = [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]) == 14\n assert candidate(seats = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]) == 6\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(seats = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 7\n assert candidate(seats = [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]) == 9\n assert candidate(seats = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(seats = [1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]) == 6\n assert candidate(seats = [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]) == 15\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]) == 9\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]) == 9\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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]) == 51\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(seats = [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, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 7\n assert candidate(seats = [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]) == 19\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 10\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [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]) == 11\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 19\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 7\n assert candidate(seats = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [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]) == 16\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 4\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 10\n assert candidate(seats = [0, 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(seats = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1]) == 2\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 20\n assert candidate(seats = [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, 1]) == 18\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 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]) == 33\n assert candidate(seats = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 11\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 14\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 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(seats = [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]) == 13\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 11\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 9\n assert candidate(seats = [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [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(seats = [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 7\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]) == 13\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 11\n assert candidate(seats = [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, 1, 0, 0, 0, 0, 0, 0, 1]) == 17\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 4\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) == 5\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [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]) == 23\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 9\n assert candidate(seats = [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]) == 13\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(seats = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [0, 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]) == 25\n assert candidate(seats = [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]) == 14\n assert candidate(seats = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 1\n assert candidate(seats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1]) == 2\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(seats = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 9\n assert candidate(seats = [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]) == 12\n assert candidate(seats = [1, 0, 0, 0, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 20\n assert candidate(seats = [1, 0, 0, 0, 1, 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, 0, 0, 1]) == 6\n assert candidate(seats = [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]) == 11\n assert candidate(seats = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]) == 8\n assert candidate(seats = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 3\n assert candidate(seats = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]) == 8\n assert candidate(seats = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(seats = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(seats = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == 6\n assert candidate(seats = [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]) == 20\n assert candidate(seats = [0, 0, 0, 0, 0, 0, 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(seats = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [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]) == 12\n assert candidate(seats = [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == 3\n", "comparison": "exact"}, "public_tests": ["[1,0,0,0,1,0,1]", "[1,0,0,0]", "[0,1]"], "hints": [], "metadata": {"canonical_parameter_names": ["seats"], "leetcode_dataset_entry_point": "Solution().maxDistToClosest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:52+00:00", "tests_total": 120, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def maxDistToClosest(self, seats: list[int]) -> int:", "container": "Solution", "callable": "maxDistToClosest", "parameters": [{"name": "seats", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 850, "task_id": "rectangle-area-ii", "difficulty": "Hard", "problem_description": "You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [x_i1, y_i1, x_i2, y_i2] denotes the i^th rectangle where (x_i1, y_i1) are the coordinates of the bottom-left corner, and (x_i2, y_i2) are the coordinates of the top-right corner.\n\nCalculate the total area covered by all rectangles in the plane. Any area covered by two or more rectangles should only be counted once.\n\nReturn the total area. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]]\nOutput: 6\nExplanation: A total area of 6 is covered by all three rectangles, as illustrated in the picture.\nFrom (1,1) to (2,2), the green and red rectangles overlap.\nFrom (1,0) to (2,3), all three rectangles overlap.\n\nExample 2:\n\nInput: rectangles = [[0,0,1000000000,1000000000]]\nOutput: 49\nExplanation: The answer is 10^18 modulo (10^9 + 7), which is 49.\n\nConstraints:\n\n- 1 <= rectangles.length <= 200\n- rectanges[i].length == 4\n- 0 <= x_i1, y_i1, x_i2, y_i2 <= 10^9\n- x_{i1 <=}x_i2\n- y_{i1 <=} y_i2\n- All rectangles have non zero area.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 1, 2, 2], [2, 2, 3, 3]]) == 3\n assert candidate(rectangles = [[0, 0, 1, 10], [0, 0, 10, 1], [1, 1, 2, 11], [1, 1, 11, 2]]) == 38\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1]]) == 3\n assert candidate(rectangles = [[0, 0, 5, 5], [2, 2, 7, 7], [4, 4, 9, 9]]) == 57\n assert candidate(rectangles = [[0, 0, 3, 3], [1, 1, 4, 4], [2, 2, 5, 5], [3, 3, 6, 6]]) == 24\n assert candidate(rectangles = [[1, 1, 5, 5], [2, 2, 6, 6], [3, 3, 7, 7]]) == 30\n assert candidate(rectangles = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 10\n assert candidate(rectangles = [[0, 0, 10, 10], [5, 5, 15, 15], [10, 10, 20, 20]]) == 250\n assert candidate(rectangles = [[0, 0, 2, 2], [1, 0, 2, 3], [1, 0, 3, 1]]) == 6\n assert candidate(rectangles = [[1, 1, 2, 2], [1, 1, 3, 3], [2, 2, 3, 3]]) == 4\n assert candidate(rectangles = [[0, 0, 5, 5], [5, 5, 10, 10], [0, 5, 5, 10]]) == 75\n assert candidate(rectangles = [[0, 0, 5, 5], [5, 5, 10, 10], [0, 5, 10, 10]]) == 75\n assert candidate(rectangles = [[1, 1, 3, 3], [2, 2, 4, 4], [3, 3, 5, 5]]) == 10\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000]]) == 49\n assert candidate(rectangles = [[10, 10, 20, 20], [15, 15, 25, 25], [20, 20, 30, 30]]) == 250\n assert candidate(rectangles = [[0, 0, 10, 10], [1, 1, 9, 9], [2, 2, 8, 8], [3, 3, 7, 7], [4, 4, 6, 6]]) == 100\n assert candidate(rectangles = [[0, 0, 5, 5], [0, 5, 5, 10], [5, 0, 10, 5], [5, 5, 10, 10], [2, 2, 8, 8]]) == 100\n assert candidate(rectangles = [[10, 10, 20, 20], [15, 15, 25, 25], [20, 20, 30, 30], [25, 25, 35, 35], [30, 30, 40, 40], [35, 35, 45, 45]]) == 475\n assert candidate(rectangles = [[0, 0, 1, 2], [1, 0, 2, 2], [2, 0, 3, 2], [0, 1, 1, 3], [1, 1, 2, 3], [2, 1, 3, 3]]) == 9\n assert candidate(rectangles = [[1, 1, 3, 3], [3, 1, 5, 3], [1, 3, 3, 5], [3, 3, 5, 5], [2, 2, 4, 4]]) == 16\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1], [0, 1, 1, 2], [1, 1, 2, 2], [2, 1, 3, 2]]) == 6\n assert candidate(rectangles = [[1, 1, 1000, 1000], [2, 2, 999, 999], [3, 3, 998, 998], [4, 4, 997, 997], [5, 5, 996, 996]]) == 998001\n assert candidate(rectangles = [[0, 0, 10, 10], [1, 1, 9, 9], [2, 2, 8, 8], [3, 3, 7, 7], [4, 4, 6, 6], [5, 5, 5, 5]]) == 100\n assert candidate(rectangles = [[1, 1, 10, 10], [2, 2, 9, 9], [3, 3, 8, 8], [4, 4, 7, 7], [5, 5, 6, 6], [6, 6, 5, 5], [7, 7, 4, 4], [8, 8, 3, 3], [9, 9, 2, 2]]) == 81\n assert candidate(rectangles = [[1, 1, 5, 5], [6, 6, 10, 10], [11, 11, 15, 15], [16, 16, 20, 20], [21, 21, 25, 25]]) == 80\n assert candidate(rectangles = [[1, 1, 5, 5], [2, 2, 6, 6], [3, 3, 7, 7], [4, 4, 8, 8], [5, 5, 9, 9], [6, 6, 10, 10], [7, 7, 11, 11], [8, 8, 12, 12], [9, 9, 13, 13]]) == 72\n assert candidate(rectangles = [[0, 0, 10, 5], [5, 0, 15, 10], [10, 5, 20, 15], [15, 10, 25, 20], [20, 15, 30, 25]]) == 350\n assert candidate(rectangles = [[0, 0, 5, 5], [1, 1, 6, 6], [2, 2, 7, 7], [3, 3, 8, 8], [4, 4, 9, 9], [5, 5, 10, 10], [6, 6, 11, 11]]) == 79\n assert candidate(rectangles = [[0, 0, 2, 2], [2, 0, 4, 2], [4, 0, 6, 2], [2, 2, 4, 4], [4, 2, 6, 4], [1, 1, 5, 5], [3, 3, 7, 7]]) == 37\n assert candidate(rectangles = [[0, 0, 10, 10], [1, 2, 11, 12], [2, 1, 12, 11], [3, 3, 13, 13], [4, 4, 14, 14], [5, 5, 15, 15]]) == 197\n assert candidate(rectangles = [[1, 1, 100, 100], [1, 50, 200, 150], [1, 100, 300, 200], [1, 150, 400, 250], [1, 200, 500, 300]]) == 99601\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [1000000000, 0, 2000000000, 1000000000]]) == 98\n assert candidate(rectangles = [[0, 0, 20, 20], [0, 10, 20, 30], [10, 0, 30, 20], [10, 10, 30, 30]]) == 900\n assert candidate(rectangles = [[0, 0, 1000, 1000], [500, 500, 1500, 1500], [1000, 1000, 2000, 2000], [250, 250, 750, 750], [1250, 1250, 1750, 1750]]) == 2500000\n assert candidate(rectangles = [[0, 0, 10, 10], [2, 2, 8, 8], [4, 4, 12, 12], [6, 6, 14, 14]]) == 156\n assert candidate(rectangles = [[0, 0, 5, 5], [5, 5, 10, 10], [0, 5, 5, 10], [5, 0, 10, 5]]) == 100\n assert candidate(rectangles = [[1, 1, 1000000000, 1000000000], [500000000, 500000000, 1500000000, 1500000000], [1000000000, 1000000000, 2000000000, 2000000000]]) == 500000141\n assert candidate(rectangles = [[0, 0, 10, 10], [0, 10, 10, 20], [0, 20, 10, 30], [0, 30, 10, 40], [0, 40, 10, 50]]) == 500\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [100000000, 100000000, 900000000, 900000000], [200000000, 200000000, 800000000, 800000000]]) == 49\n assert candidate(rectangles = [[0, 0, 100, 50], [10, 10, 90, 40], [20, 20, 80, 30], [30, 30, 70, 20], [40, 40, 60, 10]]) == 5000\n assert candidate(rectangles = [[0, 0, 5, 10], [5, 0, 10, 15], [10, 0, 15, 20], [15, 0, 20, 25], [0, 10, 5, 20], [5, 15, 10, 25], [10, 20, 15, 30], [15, 25, 20, 35]]) == 550\n assert candidate(rectangles = [[0, 0, 10, 5], [5, 0, 15, 10], [10, 0, 20, 5], [5, 5, 15, 15], [10, 5, 20, 10], [15, 5, 25, 15]]) == 300\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1], [3, 0, 4, 1], [4, 0, 5, 1], [5, 0, 6, 1], [6, 0, 7, 1], [7, 0, 8, 1], [8, 0, 9, 1]]) == 9\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [100, 100, 900, 900], [200, 200, 800, 800]]) == 49\n assert candidate(rectangles = [[1, 1, 2, 2], [3, 3, 4, 4], [5, 5, 6, 6], [1, 3, 2, 4], [3, 1, 4, 2], [3, 5, 4, 6], [5, 3, 6, 4], [5, 1, 6, 2], [1, 5, 2, 6]]) == 9\n assert candidate(rectangles = [[10, 10, 20, 20], [15, 15, 25, 25], [10, 20, 20, 30], [20, 10, 30, 20]]) == 325\n assert candidate(rectangles = [[0, 0, 10, 10], [10, 10, 20, 20], [20, 20, 30, 30], [30, 30, 40, 40], [40, 40, 50, 50]]) == 500\n assert candidate(rectangles = [[1, 1, 5, 5], [2, 2, 6, 6], [3, 3, 7, 7], [4, 4, 8, 8], [5, 5, 9, 9], [6, 6, 10, 10]]) == 51\n assert candidate(rectangles = [[10, 10, 15, 15], [10, 15, 15, 20], [15, 10, 20, 15], [15, 15, 20, 20], [10, 20, 15, 25], [15, 20, 20, 25], [10, 10, 20, 20]]) == 150\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [500000000, 500000000, 1500000000, 1500000000]]) == 750000091\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [1, 1, 999999999, 999999999]]) == 49\n assert candidate(rectangles = [[0, 0, 100, 100], [50, 50, 150, 150], [100, 100, 200, 200], [150, 150, 250, 250]]) == 32500\n assert candidate(rectangles = [[0, 0, 1, 2], [0, 1, 1, 3], [1, 0, 2, 2], [1, 1, 2, 3]]) == 6\n assert candidate(rectangles = [[0, 0, 3, 3], [1, 1, 4, 4], [2, 2, 5, 5], [3, 3, 6, 6], [4, 4, 7, 7], [5, 5, 8, 8]]) == 34\n assert candidate(rectangles = [[1, 1, 2, 2], [2, 2, 3, 3], [3, 3, 4, 4], [1, 3, 4, 4], [3, 1, 4, 3]]) == 7\n assert candidate(rectangles = [[0, 0, 5, 5], [0, 5, 5, 10], [0, 10, 5, 15], [0, 15, 5, 20], [5, 0, 10, 5], [5, 5, 10, 10], [5, 10, 10, 15], [5, 15, 10, 20]]) == 200\n assert candidate(rectangles = [[0, 0, 3, 3], [1, 1, 4, 4], [2, 2, 5, 5], [3, 3, 6, 6], [4, 4, 7, 7]]) == 29\n assert candidate(rectangles = [[0, 0, 10, 10], [1, 1, 9, 9], [2, 2, 8, 8], [3, 3, 7, 7], [4, 4, 6, 6], [0, 0, 5, 5], [5, 5, 10, 10], [0, 5, 5, 10], [5, 0, 10, 5]]) == 100\n assert candidate(rectangles = [[0, 0, 100000000, 100000000], [10000000, 10000000, 90000000, 90000000], [20000000, 20000000, 80000000, 80000000], [30000000, 30000000, 70000000, 70000000], [40000000, 40000000, 60000000, 60000000]]) == 930000007\n assert candidate(rectangles = [[100, 100, 200, 200], [200, 200, 300, 300], [300, 300, 400, 400], [400, 400, 500, 500], [500, 500, 600, 600]]) == 50000\n assert candidate(rectangles = [[0, 0, 100, 100], [25, 25, 75, 75], [50, 50, 125, 125]]) == 13125\n assert candidate(rectangles = [[0, 0, 500, 500], [100, 100, 600, 600], [200, 200, 700, 700], [300, 300, 800, 800], [400, 400, 900, 900]]) == 610000\n assert candidate(rectangles = [[0, 0, 10, 10], [1, 1, 11, 11], [2, 2, 12, 12], [3, 3, 13, 13], [4, 4, 14, 14]]) == 176\n assert candidate(rectangles = [[0, 0, 200, 200], [100, 100, 300, 300], [50, 50, 150, 150], [150, 150, 250, 250], [250, 250, 350, 350], [0, 100, 100, 200], [100, 0, 200, 100]]) == 77500\n assert candidate(rectangles = [[0, 0, 100, 200], [0, 100, 200, 300], [0, 200, 300, 400], [100, 0, 200, 100], [200, 0, 300, 200], [300, 0, 400, 300]]) == 150000\n assert candidate(rectangles = [[0, 0, 1000000, 1000000], [0, 0, 500000, 500000], [500000, 500000, 1000000, 1000000], [250000, 250000, 750000, 750000]]) == 999993007\n assert candidate(rectangles = [[0, 0, 10, 10], [0, 5, 10, 15], [0, 10, 10, 20], [5, 0, 15, 10], [5, 5, 15, 15], [5, 10, 15, 20], [10, 0, 20, 10], [10, 5, 20, 15], [10, 10, 20, 20]]) == 400\n assert candidate(rectangles = [[10, 10, 20, 20], [15, 15, 25, 25], [20, 20, 30, 30], [25, 25, 35, 35]]) == 325\n assert candidate(rectangles = [[0, 0, 50, 50], [0, 50, 50, 100], [50, 0, 100, 50], [50, 50, 100, 100], [25, 25, 75, 75]]) == 10000\n assert candidate(rectangles = [[1, 1, 2, 2], [2, 2, 3, 3], [3, 3, 4, 4], [4, 4, 5, 5], [5, 5, 6, 6], [1, 5, 2, 6], [2, 5, 3, 6], [3, 5, 4, 6], [4, 5, 5, 6], [5, 1, 6, 2], [5, 2, 6, 3], [5, 3, 6, 4]]) == 12\n assert candidate(rectangles = [[1, 1, 2, 2], [2, 2, 3, 3], [3, 3, 4, 4], [4, 4, 5, 5]]) == 4\n assert candidate(rectangles = [[10, 10, 20, 20], [25, 25, 35, 35], [15, 15, 25, 25], [30, 30, 40, 40], [5, 5, 15, 15], [45, 45, 55, 55]]) == 525\n assert candidate(rectangles = [[0, 0, 2, 2], [0, 2, 2, 4], [2, 0, 4, 2], [2, 2, 4, 4]]) == 16\n assert candidate(rectangles = [[1, 1, 10, 10], [2, 2, 9, 9], [3, 3, 8, 8], [4, 4, 7, 7], [5, 5, 6, 6], [6, 6, 5, 5], [7, 7, 4, 4], [8, 8, 3, 3], [9, 9, 2, 2], [10, 10, 1, 1]]) == 81\n assert candidate(rectangles = [[100, 100, 200, 200], [150, 150, 250, 250], [200, 200, 300, 300], [250, 250, 350, 350], [300, 300, 400, 400]]) == 40000\n assert candidate(rectangles = [[0, 0, 100, 100], [50, 50, 150, 150], [100, 100, 200, 200], [125, 125, 175, 175]]) == 25000\n assert candidate(rectangles = [[0, 0, 100, 100], [50, 50, 150, 150], [200, 200, 300, 300], [0, 100, 100, 200], [100, 0, 200, 100], [100, 100, 200, 200]]) == 50000\n assert candidate(rectangles = [[0, 0, 2, 2], [0, 2, 2, 4], [2, 0, 4, 2], [2, 2, 4, 4], [1, 1, 3, 3]]) == 16\n assert candidate(rectangles = [[0, 0, 10, 10], [1, 2, 9, 8], [2, 4, 8, 6], [3, 6, 7, 4], [4, 8, 6, 2]]) == 100\n assert candidate(rectangles = [[0, 0, 5, 10], [5, 5, 15, 15], [10, 0, 20, 5], [0, 10, 20, 20]]) == 350\n assert candidate(rectangles = [[0, 0, 100, 100], [10, 10, 90, 90], [20, 20, 80, 80], [30, 30, 70, 70]]) == 10000\n assert candidate(rectangles = [[0, 0, 10, 10], [0, 0, 10, 5], [5, 0, 10, 10], [0, 5, 10, 10]]) == 100\n assert candidate(rectangles = [[1, 1, 1000000000, 1000000000], [100000000, 100000000, 900000000, 900000000], [200000000, 200000000, 800000000, 800000000], [300000000, 300000000, 700000000, 700000000]]) == 64\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [500000000, 500000000, 1500000000, 1500000000], [1000000000, 1000000000, 2000000000, 2000000000]]) == 500000126\n assert candidate(rectangles = [[0, 0, 10, 10], [2, 2, 12, 12], [5, 5, 15, 15], [8, 8, 18, 18]]) == 238\n assert candidate(rectangles = [[0, 0, 100, 100], [10, 10, 90, 90], [20, 20, 80, 80], [30, 30, 70, 70], [40, 40, 60, 60]]) == 10000\n assert candidate(rectangles = [[0, 0, 100, 100], [50, 0, 150, 100], [100, 0, 200, 100], [150, 0, 250, 100], [200, 0, 300, 100]]) == 30000\n assert candidate(rectangles = [[0, 0, 50, 50], [5, 5, 55, 55], [10, 10, 60, 60], [15, 15, 65, 65], [20, 20, 70, 70]]) == 4400\n assert candidate(rectangles = [[0, 0, 1000000000, 1000000000], [500000000, 500000000, 1500000000, 1500000000], [250000000, 250000000, 750000000, 750000000]]) == 750000091\n assert candidate(rectangles = [[1, 1, 2, 2], [1, 1, 3, 3], [1, 1, 4, 4], [1, 1, 5, 5], [1, 1, 6, 6], [1, 1, 7, 7], [1, 1, 8, 8], [1, 1, 9, 9], [1, 1, 10, 10], [1, 1, 11, 11], [1, 1, 12, 12], [1, 1, 13, 13], [1, 1, 14, 14]]) == 169\n assert candidate(rectangles = [[0, 0, 3, 3], [1, 1, 4, 4], [2, 2, 5, 5], [3, 3, 6, 6], [4, 4, 7, 7], [5, 5, 8, 8], [6, 6, 9, 9]]) == 39\n assert candidate(rectangles = [[0, 0, 10, 1], [1, 1, 20, 2], [2, 2, 30, 3], [3, 3, 40, 4], [4, 4, 50, 5]]) == 140\n assert candidate(rectangles = [[0, 0, 1, 2], [1, 0, 2, 3], [2, 0, 3, 4], [3, 0, 4, 5], [4, 0, 5, 6], [5, 0, 6, 7], [6, 0, 7, 8], [7, 0, 8, 9], [8, 0, 9, 10]]) == 54\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 1, 2, 2], [2, 2, 3, 3], [3, 3, 4, 4], [4, 4, 5, 5]]) == 5\n assert candidate(rectangles = [[100, 100, 200, 200], [200, 200, 300, 300], [300, 300, 400, 400], [150, 150, 250, 250], [250, 250, 350, 350], [350, 350, 450, 450]]) == 47500\n assert candidate(rectangles = [[0, 0, 10, 20], [5, 0, 15, 25], [10, 0, 20, 30], [15, 0, 25, 35], [20, 0, 30, 40]]) == 950\n assert candidate(rectangles = [[0, 0, 3, 3], [0, 3, 3, 6], [3, 0, 6, 3], [3, 3, 6, 6], [1, 1, 5, 5], [1, 4, 5, 8], [4, 1, 8, 5], [4, 4, 8, 8]]) == 60\n assert candidate(rectangles = [[1, 1, 1000000, 1000000], [2, 2, 999999, 999999], [3, 3, 999998, 999998]]) == 997993008\n assert candidate(rectangles = [[100, 100, 200, 200], [150, 150, 250, 250], [200, 200, 300, 300], [250, 250, 350, 350], [300, 300, 400, 400], [350, 350, 450, 450]]) == 47500\n assert candidate(rectangles = [[0, 0, 100, 100], [50, 50, 150, 150], [100, 100, 200, 200], [25, 25, 75, 75]]) == 25000\n assert candidate(rectangles = [[0, 0, 1, 2], [1, 0, 2, 3], [2, 0, 3, 4], [3, 0, 4, 5], [4, 0, 5, 6]]) == 20\n assert candidate(rectangles = [[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\n assert candidate(rectangles = [[0, 0, 10, 10], [0, 5, 5, 15], [5, 0, 15, 5], [5, 5, 15, 15]]) == 225\n assert candidate(rectangles = [[0, 0, 100, 100], [10, 10, 110, 110], [20, 20, 120, 120], [30, 30, 130, 130], [40, 40, 140, 140]]) == 17600\n", "comparison": "exact"}, "public_tests": ["[[0,0,2,2],[1,0,2,3],[1,0,3,1]]", "[[0,0,1000000000,1000000000]]"], "hints": [], "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().rectangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:54+00:00", "tests_total": 105, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "segment-tree", "sweep-line", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def rectangleArea(self, rectangles: list[list[int]]) -> int:", "container": "Solution", "callable": "rectangleArea", "parameters": [{"name": "rectangles", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 851, "task_id": "loud-and-rich", "difficulty": "Medium", "problem_description": "There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness.\n\nYou are given an array richer where richer[i] = [a_i, b_i] indicates that a_i has more money than b_i and an integer array quiet where quiet[i] is the quietness of the i^th person. All the given data in richer are logically correct (i.e., the data will not lead you to a situation where x is richer than y and y is richer than x at the same time).\n\nReturn an integer array answer where answer[x] = y if y is the least quiet person (that is, the person y with the smallest value of quiet[y]) among all people who definitely have equal to or more money than the person x.\n\nExample 1:\n\nInput: richer = [[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]], quiet = [3,2,5,4,6,1,7,0]\nOutput: [5,5,2,5,4,5,6,7]\nExplanation:\nanswer[0] = 5.\nPerson 5 has more money than 3, which has more money than 1, which has more money than 0.\nThe only person who is quieter (has lower quiet[x]) is person 7, but it is not clear if they have more money than person 0.\nanswer[7] = 7.\nAmong all people that definitely have equal to or more money than person 7 (which could be persons 3, 4, 5, 6, or 7), the person who is the quietest (has lower quiet[x]) is person 7.\nThe other answers can be filled out with similar reasoning.\n\nExample 2:\n\nInput: richer = [], quiet = [0]\nOutput: [0]\n\nConstraints:\n\n- n == quiet.length\n- 1 <= n <= 500\n- 0 <= quiet[i] < n\n- All the values of quiet are unique.\n- 0 <= richer.length <= n * (n - 1) / 2\n- 0 <= a_i, b_i < n\n- a_i!= b_i\n- All the pairs of richer are unique.\n- The observations in richer are all logically consistent.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(richer = [],quiet = [0]) == [0]\n assert candidate(richer = [[4, 3], [3, 2], [2, 1], [1, 0]],quiet = [4, 3, 2, 1, 0]) == [4, 4, 4, 4, 4]\n assert candidate(richer = [[1, 0], [2, 0], [3, 0]],quiet = [3, 2, 1, 0]) == [3, 1, 2, 3]\n assert candidate(richer = [[2, 0], [2, 1], [3, 1], [3, 7], [4, 3], [5, 3], [6, 3]],quiet = [3, 2, 5, 4, 6, 1, 7, 0]) == [0, 5, 2, 5, 4, 5, 6, 7]\n assert candidate(richer = [[0, 1], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5]],quiet = [6, 5, 4, 3, 2, 1, 0]) == [0, 6, 6, 6, 6, 6, 6]\n assert candidate(richer = [[1, 3], [2, 3]],quiet = [3, 2, 1, 0]) == [0, 1, 2, 3]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4]],quiet = [0, 1, 2, 3, 4]) == [0, 0, 0, 0, 0]\n assert candidate(richer = [[0, 1], [1, 2], [0, 2]],quiet = [2, 1, 0]) == [0, 1, 2]\n assert candidate(richer = [[1, 0], [2, 0], [3, 0], [4, 0]],quiet = [4, 3, 2, 1, 0]) == [4, 1, 2, 3, 4]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],quiet = [5, 4, 3, 2, 1, 0, 6]) == [0, 1, 2, 3, 4, 5, 2]\n assert candidate(richer = [[0, 1], [0, 2], [0, 3]],quiet = [0, 1, 2, 3]) == [0, 0, 0, 0]\n assert candidate(richer = [[0, 1], [2, 3], [4, 5]],quiet = [5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],quiet = [3, 2, 1, 0, 4, 5, 6]) == [0, 1, 2, 3, 1, 2, 2]\n assert candidate(richer = [[1, 0], [2, 1], [3, 1], [3, 7], [4, 3], [5, 3], [6, 3]],quiet = [3, 2, 5, 4, 6, 1, 7, 0]) == [5, 5, 2, 5, 4, 5, 6, 7]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3]],quiet = [3, 2, 1, 0]) == [0, 1, 2, 3]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],quiet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],quiet = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(richer = [[1, 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], [0, 20]],quiet = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(richer = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]],quiet = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [8, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(richer = [[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]],quiet = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [20, 20, 14, 18, 20, 12, 14, 16, 18, 20, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],quiet = [7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(richer = [[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]],quiet = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 19, 18, 17, 16, 15, 14, 13, 12, 11, 0, 20, 21]) == [19, 5, 7, 19, 4, 5, 6, 7, 19, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8], [7, 9], [8, 9]],quiet = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[5, 3], [3, 1], [3, 0], [1, 2], [2, 4]],quiet = [3, 4, 5, 0, 1, 2]) == [3, 3, 3, 3, 3, 5]\n assert candidate(richer = [[9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]],quiet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],quiet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(richer = [[5, 4], [5, 3], [3, 2], [3, 1], [2, 0]],quiet = [5, 4, 3, 2, 1, 0]) == [5, 5, 5, 5, 5, 5]\n assert candidate(richer = [[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]],quiet = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20]) == [0, 10, 11, 3, 10, 11, 13, 15, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],quiet = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]],quiet = [5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5]\n assert candidate(richer = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [7, 5]],quiet = [7, 6, 5, 4, 3, 2, 1, 0]) == [7, 7, 6, 7, 6, 7, 6, 7]\n assert candidate(richer = [[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]],quiet = [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [18, 18, 14, 18, 10, 12, 14, 16, 18, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [2, 4], [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]],quiet = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == [0, 1, 2, 3, 4, 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(richer = [[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]],quiet = [0, 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(richer = [[1, 0], [3, 1], [2, 0], [4, 2], [5, 3]],quiet = [7, 6, 5, 4, 3, 2, 1, 0]) == [5, 5, 4, 5, 4, 5, 6, 7]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [3, 4], [5, 3], [6, 4], [7, 5], [8, 6], [9, 7], [10, 8]],quiet = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 9, 9, 9, 10, 9, 10, 9, 10, 9, 10]\n assert candidate(richer = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],quiet = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == [0, 1, 2, 3, 4, 5, 2, 2, 3, 3]\n assert candidate(richer = [[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]],quiet = [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, 22, 30, 18, 22, 26, 30, 16, 18, 20, 22, 24, 26, 28, 30, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(richer = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 4]],quiet = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [8, 8, 6, 7, 8, 5, 6, 7, 8]\n assert candidate(richer = [[1, 0], [3, 0], [2, 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]],quiet = [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]) == [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]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7]],quiet = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(richer = [[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]],quiet = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 0]) == [15, 15, 9, 15, 9, 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]],quiet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[1, 0], [2, 0], [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, 11], [16, 12]],quiet = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [16, 16, 14, 15, 16, 13, 14, 15, 16, 13, 14, 15, 16, 13, 14, 15, 16]\n assert candidate(richer = [[1, 0], [3, 1], [4, 1], [2, 4], [5, 2], [6, 2], [7, 5], [8, 5], [9, 7], [10, 7], [11, 8], [12, 8]],quiet = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [12, 12, 12, 3, 12, 12, 6, 10, 12, 9, 10, 11, 12]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],quiet = [5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5]\n assert candidate(richer = [[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]],quiet = [0, 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, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(richer = [[3, 0], [3, 1], [3, 2], [3, 4], [5, 0], [5, 1], [5, 2], [5, 3]],quiet = [6, 5, 4, 3, 2, 1, 0]) == [5, 5, 5, 5, 5, 5, 6]\n assert candidate(richer = [[1, 0], [2, 0], [3, 1], [3, 2], [4, 3], [5, 3], [6, 4], [6, 5]],quiet = [3, 2, 5, 4, 6, 1, 7, 0]) == [5, 5, 5, 5, 4, 5, 6, 7]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11]],quiet = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],quiet = [5, 8, 9, 4, 3, 7, 2, 6, 1, 0]) == [0, 0, 0, 3, 4, 4, 6, 6, 8, 9]\n assert candidate(richer = [[1, 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]],quiet = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],quiet = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(richer = [[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]],quiet = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(richer = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]],quiet = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(richer = [[5, 4], [5, 3], [6, 4], [7, 4], [8, 5], [9, 5]],quiet = [2, 6, 5, 8, 1, 3, 7, 4, 9, 0]) == [0, 1, 2, 9, 9, 9, 6, 7, 8, 9]\n assert candidate(richer = [[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]],quiet = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [16, 16, 14, 16, 10, 12, 14, 16, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(richer = [[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]],quiet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(richer = [[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]],quiet = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[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, 15], [9, 16], [10, 16], [11, 17], [12, 17], [13, 18], [14, 18], [15, 19], [16, 19], [17, 19]],quiet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(richer = [[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]],quiet = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(richer = [[1, 0], [3, 0], [2, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4], [10, 4], [11, 5], [12, 5]],quiet = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [12, 12, 12, 8, 10, 12, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(richer = [[1, 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]],quiet = [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]) == [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]\n assert candidate(richer = [[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]],quiet = [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, 1, 2, 3, 4, 5, 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(richer = [[1, 0], [2, 0], [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, 11], [16, 12], [17, 13], [18, 14], [19, 15]],quiet = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [19, 19, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19]\n assert candidate(richer = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 2], [6, 3], [7, 3], [8, 4], [9, 4]],quiet = [8, 7, 9, 1, 2, 5, 6, 3, 4, 0]) == [9, 3, 9, 3, 9, 5, 6, 7, 8, 9]\n assert candidate(richer = [[1, 0], [2, 1], [3, 1], [4, 2], [5, 2], [6, 3], [7, 3], [8, 4], [9, 4]],quiet = [0, 3, 1, 4, 2, 5, 6, 7, 8, 9]) == [0, 2, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],quiet = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == [5, 1, 2, 3, 4, 5, 5, 5, 5, 5]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [0, 10], [11, 10], [12, 11], [13, 12], [14, 13]],quiet = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 14, 14, 14, 14, 14]\n assert candidate(richer = [[0, 1], [0, 2], [1, 3], [2, 4], [4, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10]],quiet = [3, 2, 1, 5, 0, 10, 9, 8, 7, 6, 4]) == [0, 1, 2, 1, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(richer = [[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]],quiet = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(richer = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20], [8, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28], [13, 29], [13, 30], [14, 31], [14, 32], [15, 33], [15, 34], [16, 35], [16, 36], [17, 37], [17, 38], [18, 39], [18, 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], [30, 62], [30, 63]],quiet = [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]) == [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]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [0, 3], [0, 4], [1, 4], [4, 5]],quiet = [3, 4, 5, 1, 2, 0]) == [0, 0, 0, 3, 4, 5]\n assert candidate(richer = [[0, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 4], [2, 5], [3, 6], [5, 7]],quiet = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(richer = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],quiet = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(richer = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6]],quiet = [7, 6, 5, 4, 3, 2, 1, 0]) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(richer = [[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]],quiet = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(richer = [[1, 0], [2, 0], [3, 1], [3, 2], [4, 1], [4, 2], [5, 3], [5, 4]],quiet = [5, 3, 4, 2, 1, 0]) == [5, 5, 5, 5, 5, 5]\n assert candidate(richer = [[3, 0], [3, 1], [3, 2], [3, 4], [4, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [7, 13], [7, 14]],quiet = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(richer = [[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, 12], [9, 12], [10, 13], [11, 13], [12, 14], [13, 15], [14, 16]],quiet = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 16]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14]\n", "comparison": "exact"}, "public_tests": ["[[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]]\n[3,2,5,4,6,1,7,0]", "[]\n[0]"], "hints": [], "metadata": {"canonical_parameter_names": ["richer", "quiet"], "leetcode_dataset_entry_point": "Solution().loudAndRich", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:57+00:00", "tests_total": 100, "tests_dropped": 20, "flags": [], "topic_tags": ["array", "depth-first-search", "graph", "topological-sort", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def loudAndRich(self, richer: list[list[int]], quiet: list[int]) -> list[int]:", "container": "Solution", "callable": "loudAndRich", "parameters": [{"name": "richer", "type": "list[list[int]]"}, {"name": "quiet", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 852, "task_id": "peak-index-in-a-mountain-array", "difficulty": "Medium", "problem_description": "You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease.\n\nReturn the index of the peak element.\n\nYour task is to solve it in O(log(n)) time complexity.\n\nExample 1:\n\nInput: arr = [0,1,0]\nOutput: 1\n\nExample 2:\n\nInput: arr = [0,2,1,0]\nOutput: 1\n\nExample 3:\n\nInput: arr = [0,10,5,2]\nOutput: 1\n\nConstraints:\n\n- 3 <= arr.length <= 10^5\n- 0 <= arr[i] <= 10^6\n- arr is guaranteed to be a mountain array.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 3, 5, 4, 2]) == 2\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 3, 1]) == 5\n assert candidate(arr = [0, 2, 1, 0]) == 1\n assert candidate(arr = [0, 10, 5, 2]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 1]) == 4\n assert candidate(arr = [1, 2, 3, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 6, 7, 8, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [3, 5, 3, 2, 0]) == 1\n assert candidate(arr = [24, 69, 100, 99, 79, 78, 67, 36, 26, 19]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 4\n assert candidate(arr = [0, 1, 0]) == 1\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [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, 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(arr = [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, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 12\n assert candidate(arr = [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]) == 15\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 19\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [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, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 0, 1, 0, 1, 0]) == 38\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589]) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2]) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 8, 6, 4, 2]) == 5\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 15\n assert candidate(arr = [0, 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]) == 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, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 49, 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]) == 49\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 9\n assert candidate(arr = [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]) == 12\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]) == 20\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 8, 6, 4, 2]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 10\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, 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]) == 39\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [0, 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]) == 20\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(arr = [1, 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, 97, 93, 89, 85, 81, 77, 73, 69, 65, 61, 57, 53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5]) == 25\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000, 450000, 400000, 350000, 300000, 250000, 200000, 150000, 100000]) == 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, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3]) == 15\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, 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]) == 44\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 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, 21, 22, 23, 24, 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(arr = [1, 3, 5, 7, 9, 11, 10, 8, 6, 4, 2]) == 5\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 55, 45, 35, 25, 15, 5]) == 5\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 45, 35, 25, 15, 10]) == 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, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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]) == 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, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 2, 3, 4, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [1, 3, 8, 12, 5, 2]) == 3\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 450, 400, 350, 300, 250, 200, 150, 100]) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 9\n assert candidate(arr = [1, 3, 5, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 3, 1]) == 9\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 10\n assert candidate(arr = [1, 3, 8, 12, 17, 20, 19, 15, 10, 5]) == 5\n assert candidate(arr = [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]) == 14\n assert candidate(arr = [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]) == 15\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000, 450000, 400000, 350000, 300000, 250000, 200000, 150000, 100000, 50000]) == 4\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 14\n assert candidate(arr = [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, 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(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10]) == 11\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 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]) == 19\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, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 49\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 8\n", "comparison": "exact"}, "public_tests": ["[0,1,0]", "[0,2,1,0]", "[0,10,5,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().peakIndexInMountainArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:59+00:00", "tests_total": 87, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "binary-search", "ternary-search"]}, "language": "python", "interface": {"raw_signature": "def peakIndexInMountainArray(self, arr: list[int]) -> int:", "container": "Solution", "callable": "peakIndexInMountainArray", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 853, "task_id": "car-fleet", "difficulty": "Medium", "problem_description": "There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.\n\nYou are given two integer arrays position and speed, both of length n, where position[i] is the starting mile of the i^th car and speed[i] is the speed of the i^th car in miles per hour.\n\nA car cannot pass another car, but it can catch up and then travel next to it at the speed of the slower car.\n\nA car fleet is a single car or a group of cars driving next to each other. The speed of the car fleet is the minimum speed of any car in the fleet.\n\nIf a car catches up to a car fleet at the mile target, it will still be considered as part of the car fleet.\n\nReturn the number of car fleets that will arrive at the destination.\n\nExample 1:\n\nInput: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]\nOutput: 3\nExplanation:\n- The cars starting at 10 (speed 2) and 8 (speed 4) become a fleet, meeting each other at 12. The fleet forms at target.\n- The car starting at 0 (speed 1) does not catch up to any other car, so it is a fleet by itself.\n- The cars starting at 5 (speed 1) and 3 (speed 3) become a fleet, meeting each other at 6. The fleet moves at speed 1 until it reaches target.\n\nExample 2:\n\nInput: target = 10, position = [3], speed = [3]\nOutput: 1\nExplanation:\nThere is only one car, hence there is only one fleet.\n\nExample 3:\n\nInput: target = 100, position = [0,2,4], speed = [4,2,1]\nOutput: 1\nExplanation:\n- The cars starting at 0 (speed 4) and 2 (speed 2) become a fleet, meeting each other at 4. The car starting at 4 (speed 1) travels to 5.\n- Then, the fleet at 4 (speed 2) and the car at position 5 (speed 1) become one fleet, meeting each other at 6. The fleet moves at speed 1 until it reaches target.\n\nConstraints:\n\n- n == position.length == speed.length\n- 1 <= n <= 10^5\n- 0 < target <= 10^6\n- 0 <= position[i] < target\n- All the values of position are unique.\n- 0 < speed[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = 1000,position = [100, 200, 300],speed = [100, 50, 25]) == 1\n assert candidate(target = 100,position = [0, 1, 2, 3, 4],speed = [100, 100, 100, 100, 100]) == 5\n assert candidate(target = 300,position = [0, 50, 100, 150, 200, 250],speed = [50, 40, 30, 20, 10, 5]) == 1\n assert candidate(target = 100,position = [90, 80, 70, 60, 50],speed = [10, 20, 30, 40, 50]) == 1\n assert candidate(target = 50,position = [0, 10, 20, 30, 40],speed = [10, 9, 8, 7, 6]) == 5\n assert candidate(target = 50,position = [10, 20, 30],speed = [1, 2, 3]) == 3\n assert candidate(target = 12,position = [10, 8, 0, 5, 3],speed = [2, 4, 1, 1, 3]) == 3\n assert candidate(target = 10,position = [3],speed = [3]) == 1\n assert candidate(target = 1,position = [0],speed = [1]) == 1\n assert candidate(target = 50,position = [10, 20, 30, 40],speed = [5, 4, 3, 2]) == 4\n assert candidate(target = 100,position = [0, 2, 4],speed = [4, 2, 1]) == 1\n assert candidate(target = 200,position = [50, 60, 70, 80, 90],speed = [10, 9, 8, 7, 6]) == 1\n assert candidate(target = 100,position = [10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(target = 20,position = [0, 18, 5],speed = [4, 4, 4]) == 3\n assert candidate(target = 20,position = [6, 2, 17],speed = [3, 9, 2]) == 2\n assert candidate(target = 1000,position = [100, 200, 300, 400],speed = [10, 20, 30, 40]) == 4\n assert candidate(target = 10,position = [6, 8],speed = [3, 2]) == 2\n assert candidate(target = 12,position = [0, 4, 2],speed = [1, 2, 3]) == 2\n assert candidate(target = 20,position = [5, 15, 10],speed = [5, 1, 3]) == 1\n assert candidate(target = 100,position = [10, 20, 30],speed = [1, 2, 3]) == 3\n assert candidate(target = 999999,position = [1, 2, 3, 4, 5],speed = [999998, 999997, 999996, 999995, 999994]) == 1\n assert candidate(target = 200,position = [10, 50, 90, 130, 170],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = 1000,position = [500, 600, 700, 800, 900],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(target = 100,position = [10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(target = 600,position = [50, 150, 250, 350, 450, 550],speed = [5, 10, 15, 20, 25, 30]) == 6\n assert candidate(target = 100,position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = 1000,position = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 120,position = [10, 30, 50, 70, 90],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 100,position = [0, 25, 50, 75, 99],speed = [5, 4, 3, 2, 1]) == 5\n assert candidate(target = 1000,position = [900, 800, 700, 600, 500, 400, 300, 200, 100],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(target = 1000,position = [10, 200, 300, 400, 500, 600, 700, 800, 900],speed = [90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2\n assert candidate(target = 300,position = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(target = 250,position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(target = 1234,position = [123, 456, 789],speed = [321, 654, 987]) == 3\n assert candidate(target = 50,position = [10, 20, 30, 40],speed = [1, 1, 1, 1]) == 4\n assert candidate(target = 700,position = [10, 100, 200, 300, 400],speed = [5, 15, 25, 35, 45]) == 5\n assert candidate(target = 200,position = [50, 100, 150, 0],speed = [2, 2, 2, 1]) == 4\n assert candidate(target = 100,position = [10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 200,position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(target = 100,position = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = 300,position = [0, 50, 100, 150, 200, 250],speed = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(target = 120,position = [10, 30, 50, 70, 90],speed = [10, 8, 6, 4, 2]) == 1\n assert candidate(target = 120,position = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],speed = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(target = 10000,position = [9990, 9980, 9970, 9960, 9950, 9940, 9930, 9920, 9910, 9900],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(target = 500,position = [490, 480, 470, 460, 450],speed = [10, 10, 10, 10, 10]) == 5\n assert candidate(target = 200,position = [0, 50, 100, 150],speed = [20, 15, 10, 5]) == 1\n assert candidate(target = 100,position = [5, 15, 25, 35, 45],speed = [2, 4, 6, 8, 10]) == 5\n assert candidate(target = 150,position = [0, 25, 50, 75, 100],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(target = 150,position = [10, 20, 30, 40, 50, 60],speed = [6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 100,position = [90, 80, 70, 60, 50],speed = [10, 10, 10, 10, 10]) == 5\n assert candidate(target = 120,position = [0, 10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(target = 2000,position = [500, 1000, 1500],speed = [1, 1, 1]) == 3\n assert candidate(target = 600,position = [0, 150, 300, 450],speed = [600, 300, 150, 100]) == 2\n assert candidate(target = 1000,position = [100, 200, 300, 400],speed = [10, 20, 30, 40]) == 4\n assert candidate(target = 120,position = [10, 20, 30, 40, 50, 60],speed = [10, 9, 8, 7, 6, 5]) == 1\n assert candidate(target = 800,position = [10, 30, 50, 70, 90],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 750,position = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700],speed = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 1000,position = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 400,position = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(target = 500,position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(target = 1000,position = [990, 980, 970, 960, 950, 940, 930, 920, 910],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(target = 150,position = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = 200,position = [10, 50, 90, 130, 170],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 800,position = [100, 200, 300, 400, 500, 600, 700],speed = [1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(target = 500,position = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450],speed = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 1\n assert candidate(target = 1000,position = [10, 50, 90, 130, 170],speed = [10, 10, 10, 10, 10]) == 5\n assert candidate(target = 250,position = [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],speed = [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(target = 2000,position = [1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(target = 1000,position = [0, 250, 500, 750],speed = [50, 100, 150, 200]) == 4\n assert candidate(target = 3000,position = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900],speed = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 10\n assert candidate(target = 150,position = [10, 20, 30, 40, 50],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(target = 5000,position = [10, 200, 3000, 4000, 4990],speed = [100, 90, 80, 70, 60]) == 4\n assert candidate(target = 100,position = [10, 20, 30, 40, 50],speed = [10, 9, 8, 7, 6]) == 5\n assert candidate(target = 1500,position = [100, 300, 500, 700, 900],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(target = 600,position = [590, 580, 570, 560, 550],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(target = 120,position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 600,position = [30, 150, 270, 390, 510],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(target = 400,position = [100, 200, 300],speed = [1, 1, 1]) == 3\n assert candidate(target = 300,position = [290, 280, 270, 260, 250],speed = [1, 2, 3, 4, 5]) == 1\n assert candidate(target = 200,position = [10, 30, 50, 70, 90],speed = [50, 40, 30, 20, 10]) == 1\n assert candidate(target = 350,position = [50, 100, 150, 200, 250, 300],speed = [10, 20, 30, 40, 50, 60]) == 6\n assert candidate(target = 150,position = [10, 30, 50, 70, 90, 110, 130],speed = [10, 8, 6, 4, 2, 1, 5]) == 2\n assert candidate(target = 200,position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 900,position = [10, 100, 200, 300, 400, 500, 600, 700, 800],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(target = 500,position = [0, 100, 200, 300, 400],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = 500,position = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(target = 300,position = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280],speed = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 300,position = [0, 100, 200],speed = [100, 50, 1]) == 1\n assert candidate(target = 1200,position = [900, 600, 300, 0],speed = [10, 20, 30, 40]) == 1\n assert candidate(target = 10000,position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(target = 800,position = [100, 200, 300, 400, 500, 600, 700],speed = [700, 600, 500, 400, 300, 200, 100]) == 1\n assert candidate(target = 500,position = [100, 200, 300, 400],speed = [100, 100, 100, 100]) == 4\n assert candidate(target = 900,position = [800, 700, 600, 500, 400, 300, 200, 100, 0],speed = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 1\n assert candidate(target = 1000,position = [50, 250, 450, 650, 850],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 500,position = [100, 150, 200, 250, 300],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(target = 1000,position = [500, 600, 700, 800, 900],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(target = 500,position = [10, 100, 200, 300, 400],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = 300,position = [10, 50, 90, 130, 170, 210, 250, 290],speed = [1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(target = 500,position = [400, 300, 200, 100, 0],speed = [5, 4, 3, 2, 1]) == 5\n assert candidate(target = 300,position = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 2\n assert candidate(target = 500,position = [0, 100, 200, 300, 400],speed = [100, 100, 100, 100, 100]) == 5\n assert candidate(target = 200,position = [50, 100, 150],speed = [1, 2, 3]) == 3\n assert candidate(target = 800,position = [10, 100, 200, 300, 400, 500, 600, 700],speed = [1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(target = 1000,position = [50, 150, 250, 350, 450],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(target = 1000,position = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = 1500,position = [0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 10\n assert candidate(target = 200,position = [0, 20, 40, 60, 80, 100, 120, 140, 160, 180],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = 200,position = [10, 40, 70, 100],speed = [10, 5, 20, 15]) == 2\n assert candidate(target = 300,position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = 1000,position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 300,position = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(target = 2000,position = [1000, 1500],speed = [500, 250]) == 1\n assert candidate(target = 1000,position = [100, 200, 300, 400, 500, 600, 700, 800, 900],speed = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = 500,position = [50, 150, 250, 350, 450],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(target = 700,position = [100, 200, 300, 400, 500, 600],speed = [100, 90, 80, 70, 60, 50]) == 6\n assert candidate(target = 200,position = [10, 50, 90, 130, 170],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 100,position = [10, 20, 30, 40, 50],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(target = 200,position = [10, 20, 30, 40, 50],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(target = 500,position = [10, 50, 90, 130, 170],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(target = 1000,position = [990, 980, 970, 960, 950],speed = [1, 2, 3, 4, 5]) == 1\n assert candidate(target = 1000,position = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(target = 1000,position = [200, 400, 600, 800],speed = [50, 40, 30, 20]) == 4\n", "comparison": "exact"}, "public_tests": ["12\n[10,8,0,5,3]\n[2,4,1,1,3]", "10\n[3]\n[3]", "100\n[0,2,4]\n[4,2,1]"], "hints": [], "metadata": {"canonical_parameter_names": ["target", "position", "speed"], "leetcode_dataset_entry_point": "Solution().carFleet", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:01+00:00", "tests_total": 124, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "stack", "sorting", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def carFleet(self, target: int, position: list[int], speed: list[int]) -> int:", "container": "Solution", "callable": "carFleet", "parameters": [{"name": "target", "type": "int"}, {"name": "position", "type": "list[int]"}, {"name": "speed", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 854, "task_id": "k-similar-strings", "difficulty": "Hard", "problem_description": "Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2.\n\nGiven two anagrams s1 and s2, return the smallest k for which s1 and s2 are k-similar.\n\nExample 1:\n\nInput: s1 = \"ab\", s2 = \"ba\"\nOutput: 1\nExplanation: The two string are 1-similar because we can use one swap to change s1 to s2: \"ab\" --> \"ba\".\n\nExample 2:\n\nInput: s1 = \"abc\", s2 = \"bca\"\nOutput: 2\nExplanation: The two strings are 2-similar because we can use two swaps to change s1 to s2: \"abc\" --> \"bac\" --> \"bca\".\n\nConstraints:\n\n- 1 <= s1.length <= 20\n- s2.length == s1.length\n- s1 and s2 contain only lowercase letters from the set {'a', 'b', 'c', 'd', 'e', 'f'}.\n- s2 is an anagram of s1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == 2\n assert candidate(s1 = \"abac\",s2 = \"baca\") == 2\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == 2\n assert candidate(s1 = \"abc\",s2 = \"bca\") == 2\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == 3\n assert candidate(s1 = \"aabc\",s2 = \"abac\") == 1\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == 2\n assert candidate(s1 = \"ab\",s2 = \"ba\") == 1\n assert candidate(s1 = \"aabbcc\",s2 = \"abcabc\") == 2\n assert candidate(s1 = \"aabbaabbcc\",s2 = \"ccbbaabbaa\") == 2\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"ffeeddccbbaa\") == 6\n assert candidate(s1 = \"abcabcabc\",s2 = \"cbacbacba\") == 3\n assert candidate(s1 = \"abcdeabcde\",s2 = \"edcbaedcba\") == 4\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"fedcbafedcba\") == 7\n assert candidate(s1 = \"aabbcc\",s2 = \"bbaacc\") == 2\n assert candidate(s1 = \"aabbccdd\",s2 = \"ddccbaab\") == 5\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == 4\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbaab\") == 3\n assert candidate(s1 = \"abcdefabc\",s2 = \"cbadefabc\") == 1\n assert candidate(s1 = \"abcabcabc\",s2 = \"bcbacabac\") == 4\n assert candidate(s1 = \"abcabcabc\",s2 = \"cbaabcabc\") == 1\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == 2\n assert candidate(s1 = \"abcdefabc\",s2 = \"fdecbaabc\") == 4\n assert candidate(s1 = \"abcdefghij\",s2 = \"jihgfedcba\") == 5\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbadcba\") == 4\n assert candidate(s1 = \"abcdef\",s2 = \"fabcde\") == 5\n assert candidate(s1 = \"aabbc\",s2 = \"bbaca\") == 3\n assert candidate(s1 = \"abcdefg\",s2 = \"gfedcba\") == 3\n assert candidate(s1 = \"aabbbccc\",s2 = \"cccbbbaa\") == 3\n assert candidate(s1 = \"aabbcc\",s2 = \"cbacba\") == 3\n assert candidate(s1 = \"abababab\",s2 = \"babababa\") == 4\n assert candidate(s1 = \"abcabcabcabc\",s2 = \"cbacbacbacba\") == 4\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"abcdefabcdef\") == 7\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"dcbaabcdabcd\") == 2\n assert candidate(s1 = \"aabbccddeeff\",s2 = \"ffeeddccbaab\") == 7\n assert candidate(s1 = \"abcabdc\",s2 = \"dcbaacb\") == 4\n assert candidate(s1 = \"abcabc\",s2 = \"cbacba\") == 2\n assert candidate(s1 = \"abcabc\",s2 = \"bcbaca\") == 3\n assert candidate(s1 = \"abcdefabcdef\",s2 = \"defabcfedcba\") == 6\n assert candidate(s1 = \"abcabc\",s2 = \"cbabac\") == 2\n assert candidate(s1 = \"abcabcabc\",s2 = \"cccbaabba\") == 4\n assert candidate(s1 = \"aabbcdef\",s2 = \"defbbaac\") == 4\n assert candidate(s1 = \"abcdefabcdef\",s2 = \"fedcbafedcba\") == 6\n assert candidate(s1 = \"aaaabbbb\",s2 = \"bbbbaaaa\") == 4\n assert candidate(s1 = \"abac\",s2 = \"caba\") == 2\n assert candidate(s1 = \"abcdefgabcdefg\",s2 = \"gfedcbagfedcba\") == 6\n assert candidate(s1 = \"abcbca\",s2 = \"bcbaca\") == 2\n", "comparison": "exact"}, "public_tests": ["\"ab\"\n\"ba\"", "\"abc\"\n\"bca\""], "hints": [], "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().kSimilarity", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:03+00:00", "tests_total": 47, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def kSimilarity(self, s1: str, s2: str) -> int:", "container": "Solution", "callable": "kSimilarity", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 856, "task_id": "score-of-parentheses", "difficulty": "Medium", "problem_description": "Given a balanced parentheses string s, return the score of the string.\n\nThe score of a balanced parentheses string is based on the following rule:\n\n- \"()\" has score 1.\n- AB has score A + B, where A and B are balanced parentheses strings.\n- (A) has score 2 * A, where A is a balanced parentheses string.\n\nExample 1:\n\nInput: s = \"()\"\nOutput: 1\n\nExample 2:\n\nInput: s = \"(())\"\nOutput: 2\n\nExample 3:\n\nInput: s = \"()()\"\nOutput: 2\n\nConstraints:\n\n- 2 <= s.length <= 50\n- s consists of only '(' and ')'.\n- s is a balanced parentheses string.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()())\") == 4\n assert candidate(s = \"(()(()))\") == 6\n assert candidate(s = \"()\") == 1\n assert candidate(s = \"((()))\") == 4\n assert candidate(s = \"((()()()))\") == 12\n assert candidate(s = \"()()(())\") == 4\n assert candidate(s = \"()()\") == 2\n assert candidate(s = \"(()(()(())))\") == 14\n assert candidate(s = \"()(())\") == 3\n assert candidate(s = \"(())\") == 2\n assert candidate(s = \"((())())\") == 6\n assert candidate(s = \"()((()))\") == 5\n assert candidate(s = \"(()(()(()())))\") == 22\n assert candidate(s = \"(((())()))\") == 12\n assert candidate(s = \"(())((()))\") == 6\n assert candidate(s = \"()(((())))\") == 9\n assert candidate(s = \"()()()\") == 3\n assert candidate(s = \"(())(())\") == 4\n assert candidate(s = \"()(()(()(())))\") == 15\n assert candidate(s = \"(()((())()))\") == 14\n assert candidate(s = \"(()())(()())\") == 8\n assert candidate(s = \"(()((()))(()))\") == 14\n assert candidate(s = \"((()()()()))\") == 16\n assert candidate(s = \"((()))()()\") == 6\n assert candidate(s = \"((())(()))\") == 8\n assert candidate(s = \"()(()(()))\") == 7\n assert candidate(s = \"((()())(()))\") == 12\n assert candidate(s = \"((()(()(())))())\") == 30\n assert candidate(s = \"(()(()()(())))\") == 18\n assert candidate(s = \"(((()))(()))\") == 12\n assert candidate(s = \"((()))()\") == 5\n assert candidate(s = \"(()(())(()))\") == 10\n assert candidate(s = \"((()))(())()\") == 7\n assert candidate(s = \"((()(()))())\") == 14\n assert candidate(s = \"()((())())\") == 7\n assert candidate(s = \"(((())))\") == 8\n assert candidate(s = \"(()())(())\") == 6\n assert candidate(s = \"((())()())\") == 8\n assert candidate(s = \"((()(())))\") == 12\n assert candidate(s = \"()(())(()(()))\") == 9\n assert candidate(s = \"((()()(())))\") == 16\n assert candidate(s = \"(((()()())))\") == 24\n assert candidate(s = \"(((()()(()))))\") == 32\n assert candidate(s = \"((((()))))\") == 16\n assert candidate(s = \"(()()(()))\") == 8\n assert candidate(s = \"(()((())))\") == 10\n assert candidate(s = \"()((()()()))\") == 13\n assert candidate(s = \"((()())())\") == 10\n assert candidate(s = \"(())(()(()))\") == 8\n assert candidate(s = \"(((()())()))\") == 20\n assert candidate(s = \"()((())()())\") == 9\n assert candidate(s = \"()()()()\") == 4\n assert candidate(s = \"((()))(())\") == 6\n assert candidate(s = \"((()()))\") == 8\n assert candidate(s = \"()(())(())\") == 5\n", "comparison": "exact"}, "public_tests": ["\"()\"", "\"(())\"", "\"()()\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().scoreOfParentheses", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:05+00:00", "tests_total": 55, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def scoreOfParentheses(self, s: str) -> int:", "container": "Solution", "callable": "scoreOfParentheses", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 857, "task_id": "minimum-cost-to-hire-k-workers", "difficulty": "Hard", "problem_description": "There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the i^th worker and wage[i] is the minimum wage expectation for the i^th worker.\n\nWe want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:\n\n1. Every worker in the paid group must be paid at least their minimum wage expectation.\n2. In the group, each worker's pay must be directly proportional to their quality. This means if a worker’s quality is double that of another worker in the group, then they must be paid twice as much as the other worker.\n\nGiven the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: quality = [10,20,5], wage = [70,50,30], k = 2\nOutput: 105.00000\nExplanation: We pay 70 to 0^th worker and 35 to 2^nd worker.\n\nExample 2:\n\nInput: quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3\nOutput: 30.66667\nExplanation: We pay 4 to 0^th worker, 13.33333 to 2^nd and 3^rd workers separately.\n\nConstraints:\n\n- n == quality.length == wage.length\n- 1 <= k <= n <= 10^4\n- 1 <= quality[i], wage[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5], wage=[5, 4, 3, 2, 1], k=3), 12.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1], wage=[1, 1, 1, 1, 1], k=2), 2.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500], wage=[1000, 2000, 3000, 4000, 5000], k=4), 10000.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1], wage=[1, 2, 3, 4], k=2), 4.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500], wage=[500, 400, 300, 200, 100], k=2), 450.0)\n assert answers_match(candidate(quality=[10, 10, 10, 10], wage=[10, 10, 10, 10], k=4), 40.0)\n assert answers_match(candidate(quality=[3, 1, 10, 10, 1], wage=[4, 8, 2, 2, 7], k=3), 30.666666666666664)\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5], wage=[1, 2, 3, 4, 5], k=4), 10.0)\n assert answers_match(candidate(quality=[10, 10, 10, 10, 10], wage=[10, 10, 10, 10, 10], k=5), 50.0)\n assert answers_match(candidate(quality=[4, 1, 3, 2], wage=[20, 10, 30, 20], k=2), 30.0)\n assert answers_match(candidate(quality=[6, 12, 10, 10], wage=[48, 48, 30, 60], k=3), 192.0)\n assert answers_match(candidate(quality=[10, 20, 5], wage=[70, 50, 30], k=2), 105.0)\n assert answers_match(candidate(quality=[15, 10, 25, 5, 30, 20, 35, 40], wage=[150, 100, 250, 50, 300, 200, 350, 400], k=4), 500.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500], wage=[500, 1000, 1500, 2000, 2500], k=2), 1500.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=6), 36.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500], wage=[500, 1000, 1500, 2000, 2500], k=4), 5000.0)\n assert answers_match(candidate(quality=[7, 5, 3, 8, 2], wage=[70, 50, 30, 80, 20], k=2), 50.0)\n assert answers_match(candidate(quality=[12, 15, 18, 21, 24, 27, 30], wage=[60, 75, 90, 105, 120, 135, 150], k=4), 330.0)\n assert answers_match(candidate(quality=[50, 40, 30, 20, 10], wage=[200, 160, 120, 80, 40], k=2), 120.0)\n assert answers_match(candidate(quality=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], wage=[20, 30, 40, 50, 60, 70, 80, 90, 100, 110], k=6), 420.0)\n assert answers_match(candidate(quality=[15, 20, 5, 10, 30], wage=[105, 150, 30, 70, 210], k=3), 210.0)\n assert answers_match(candidate(quality=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], wage=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], k=5), 250.0)\n assert answers_match(candidate(quality=[9, 18, 27, 36, 45, 54, 63], wage=[81, 162, 243, 324, 405, 486, 567], k=5), 1215.0)\n assert answers_match(candidate(quality=[8, 8, 8, 8, 8, 8, 8, 8, 8, 8], wage=[32, 32, 32, 32, 32, 32, 32, 32, 32, 32], k=5), 160.0)\n assert answers_match(candidate(quality=[5, 15, 25, 35, 45, 55], wage=[35, 105, 175, 245, 315, 385], k=4), 560.0)\n assert answers_match(candidate(quality=[20, 10, 30, 40, 50, 60, 70, 80, 90, 100], wage=[140, 70, 210, 280, 350, 420, 490, 560, 630, 700], k=6), 1470.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], wage=[1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000], k=5), 15000.0)\n assert answers_match(candidate(quality=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=10), 100.0)\n assert answers_match(candidate(quality=[1, 3, 2, 5, 4, 6], wage=[1, 9, 4, 25, 16, 36], k=5), 75.0)\n assert answers_match(candidate(quality=[15, 20, 5, 10, 25], wage=[120, 160, 40, 80, 200], k=5), 600.0)\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], wage=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], k=8), 360.0)\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], wage=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225], k=7), 196.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=5), 25.0)\n assert answers_match(candidate(quality=[1, 3, 5, 7, 9, 11, 13], wage=[2, 6, 10, 14, 18, 22, 26], k=5), 50.0)\n assert answers_match(candidate(quality=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=7), 49.0)\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], wage=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=8), 3600.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], wage=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=5), 1500.0)\n assert answers_match(candidate(quality=[1, 3, 5, 7, 9, 11, 13], wage=[2, 6, 10, 14, 18, 22, 26], k=4), 32.0)\n assert answers_match(candidate(quality=[4, 7, 2, 5, 6], wage=[32, 56, 16, 40, 48], k=2), 48.0)\n assert answers_match(candidate(quality=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=5), 25.0)\n assert answers_match(candidate(quality=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30], wage=[6, 12, 18, 24, 30, 36, 42, 48, 54, 60], k=9), 270.0)\n assert answers_match(candidate(quality=[3, 3, 3, 3, 3, 3, 3, 3, 3, 3], wage=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], k=3), 6.0)\n assert answers_match(candidate(quality=[4, 5, 1, 2, 3], wage=[40, 50, 10, 20, 30], k=2), 30.0)\n assert answers_match(candidate(quality=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], wage=[25, 50, 75, 100, 125, 150, 175, 200, 225, 250], k=7), 700.0)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], wage=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=5), 1500.0)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], wage=[50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750], k=8), 1800.0)\n assert answers_match(candidate(quality=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=7), 28.0)\n assert answers_match(candidate(quality=[10, 12, 14, 16, 18, 20], wage=[70, 84, 98, 112, 126, 140], k=5), 490.0)\n assert answers_match(candidate(quality=[2, 3, 5, 7, 11, 13], wage=[14, 21, 35, 49, 77, 91], k=4), 119.0)\n assert answers_match(candidate(quality=[30, 10, 40, 20, 50], wage=[90, 30, 120, 60, 150], k=3), 180.0)\n assert answers_match(candidate(quality=[2, 4, 6, 8, 10], wage=[10, 20, 30, 40, 50], k=3), 60.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500], wage=[1000, 2000, 3000, 4000, 5000], k=4), 10000.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=5), 25.0)\n assert answers_match(candidate(quality=[4, 5, 6, 7, 8, 9], wage=[24, 30, 36, 42, 48, 54], k=4), 132.0)\n assert answers_match(candidate(quality=[4, 3, 2, 1], wage=[16, 12, 8, 4], k=2), 12.0)\n assert answers_match(candidate(quality=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], wage=[19, 17, 15, 13, 11, 9, 7, 5, 3, 1], k=4), 34.46153846153846)\n assert answers_match(candidate(quality=[20, 30, 10, 40, 50], wage=[100, 150, 50, 200, 250], k=4), 500.0)\n assert answers_match(candidate(quality=[15, 25, 35, 45, 55], wage=[105, 175, 245, 315, 385], k=3), 525.0)\n assert answers_match(candidate(quality=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], wage=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], k=3), 30.0)\n assert answers_match(candidate(quality=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5], wage=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11], k=5), 27.0)\n assert answers_match(candidate(quality=[7, 14, 21, 28, 35, 42, 49, 56, 63], wage=[14, 28, 42, 56, 70, 84, 98, 112, 126], k=6), 294.0)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], wage=[70, 140, 210, 280, 350, 420, 490, 560, 630, 700], k=7), 1960.0)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50], wage=[50, 40, 30, 20, 10], k=3), 120.0)\n assert answers_match(candidate(quality=[4, 2, 8, 5, 10, 7], wage=[40, 20, 80, 50, 100, 70], k=4), 180.0)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], wage=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], k=3), 33.75)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50, 60], wage=[50, 100, 150, 200, 250, 300], k=6), 1050.0)\n assert answers_match(candidate(quality=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], wage=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=6), 210.0)\n assert answers_match(candidate(quality=[5, 3, 8, 6, 2], wage=[45, 30, 60, 48, 12], k=3), 100.0)\n assert answers_match(candidate(quality=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], wage=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], k=5), 25.0)\n assert answers_match(candidate(quality=[5, 10, 15, 20, 25, 30, 35], wage=[50, 100, 150, 200, 250, 300, 350], k=4), 500.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1, 1, 1, 1], wage=[1, 2, 3, 4, 5, 6, 7, 8], k=5), 25.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], wage=[700, 1400, 2100, 2800, 3500, 4200, 4900, 5600, 6300, 7000], k=7), 19600.0)\n assert answers_match(candidate(quality=[15, 30, 45, 60, 75, 90, 105], wage=[45, 90, 135, 180, 225, 270, 315], k=5), 675.0)\n assert answers_match(candidate(quality=[5, 2, 10, 15, 20, 1], wage=[100, 60, 200, 300, 400, 50], k=3), 400.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], wage=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=7), 2800.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], wage=[200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000], k=5), 3000.0)\n assert answers_match(candidate(quality=[100, 200, 150, 50, 250], wage=[500, 1000, 750, 250, 1250], k=3), 1500.0)\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], wage=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=7), 280.0)\n assert answers_match(candidate(quality=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], wage=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=5), 150.0)\n assert answers_match(candidate(quality=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], wage=[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], k=6), 180.0)\n assert answers_match(candidate(quality=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], wage=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=8), 360.0)\n assert answers_match(candidate(quality=[1, 3, 2, 4, 5], wage=[3, 9, 6, 12, 15], k=3), 18.0)\n assert answers_match(candidate(quality=[3, 6, 15, 20, 12], wage=[9, 18, 45, 60, 36], k=3), 63.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=3), 9.0)\n assert answers_match(candidate(quality=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], wage=[14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196, 210], k=7), 392.0)\n assert answers_match(candidate(quality=[5, 15, 10, 20, 25], wage=[75, 225, 150, 300, 375], k=3), 450.0)\n assert answers_match(candidate(quality=[2, 4, 6, 8, 10], wage=[10, 20, 30, 40, 50], k=4), 100.0)\n assert answers_match(candidate(quality=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], wage=[50, 100, 150, 200, 250, 300, 350, 400, 450, 500], k=6), 1050.0)\n assert answers_match(candidate(quality=[1, 2, 4, 8, 16, 32, 64], wage=[1, 2, 4, 8, 16, 32, 64], k=4), 15.0)\n assert answers_match(candidate(quality=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30], wage=[6, 12, 18, 24, 30, 36, 42, 48, 54, 60], k=6), 126.0)\n assert answers_match(candidate(quality=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], wage=[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145], k=6), 180.0)\n assert answers_match(candidate(quality=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512], wage=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512], k=5), 31.0)\n assert answers_match(candidate(quality=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], wage=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=10), 100.0)\n assert answers_match(candidate(quality=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41], wage=[4, 6, 10, 14, 22, 26, 34, 38, 46, 58, 62, 74, 82], k=8), 154.0)\n assert answers_match(candidate(quality=[5, 8, 12, 15, 20, 25, 30], wage=[10, 16, 24, 30, 40, 50, 60], k=3), 50.0)\n assert answers_match(candidate(quality=[15, 10, 5, 25, 20], wage=[90, 60, 30, 150, 120], k=3), 180.0)\n assert answers_match(candidate(quality=[15, 25, 10, 40, 30], wage=[105, 175, 70, 280, 210], k=3), 350.0)\n assert answers_match(candidate(quality=[6, 12, 18, 24, 30, 36, 42, 48, 54, 60], wage=[12, 24, 36, 48, 60, 72, 84, 96, 108, 120], k=8), 432.0)\n assert answers_match(candidate(quality=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], wage=[10, 40, 90, 160, 250, 360, 490, 640, 810, 1000], k=6), 1260.0)\n assert answers_match(candidate(quality=[8, 6, 4, 2, 10], wage=[96, 72, 48, 24, 120], k=4), 240.0)\n assert answers_match(candidate(quality=[7, 14, 3, 11, 9], wage=[28, 56, 12, 44, 36], k=4), 120.0)\n assert answers_match(candidate(quality=[100, 200, 300, 400, 500, 600, 700], wage=[700, 1400, 2100, 2800, 3500, 4200, 4900], k=5), 10500.0)\n assert answers_match(candidate(quality=[3, 5, 2, 8, 7], wage=[6, 10, 4, 16, 14], k=3), 20.0)\n assert answers_match(candidate(quality=[5, 3, 10, 2, 4], wage=[50, 30, 100, 20, 40], k=3), 90.0)\n", "comparison": "float"}, "public_tests": ["[10,20,5]\n[70,50,30]\n2", "[3,1,10,10,1]\n[4,8,2,2,7]\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["quality", "wage", "k"], "leetcode_dataset_entry_point": "Solution().mincostToHireWorkers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:08+00:00", "tests_total": 104, "tests_dropped": 0, "flags": ["decimal_answer"], "topic_tags": ["array", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def mincostToHireWorkers(self, quality: list[int], wage: list[int], k: int) -> float:", "container": "Solution", "callable": "mincostToHireWorkers", "parameters": [{"name": "quality", "type": "list[int]"}, {"name": "wage", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 858, "task_id": "mirror-reflection", "difficulty": "Medium", "problem_description": "There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2.\n\nThe square room has walls of length p and a laser ray from the southwest corner first meets the east wall at a distance q from the 0^th receptor.\n\nGiven the two integers p and q, return the number of the receptor that the ray meets first.\n\nThe test cases are guaranteed so that the ray will meet a receptor eventually.\n\nExample 1:\n\nInput: p = 2, q = 1\nOutput: 2\nExplanation: The ray meets receptor 2 the first time it gets reflected back to the left wall.\n\nExample 2:\n\nInput: p = 3, q = 1\nOutput: 1\n\nConstraints:\n\n- 1 <= q <= p <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(p = 2,q = 1) == 2\n assert candidate(p = 10,q = 3) == 2\n assert candidate(p = 6,q = 2) == 1\n assert candidate(p = 4,q = 2) == 2\n assert candidate(p = 10,q = 4) == 0\n assert candidate(p = 5,q = 3) == 1\n assert candidate(p = 3,q = 1) == 1\n assert candidate(p = 7,q = 5) == 1\n assert candidate(p = 5,q = 2) == 0\n assert candidate(p = 6,q = 4) == 0\n assert candidate(p = 10,q = 7) == 2\n assert candidate(p = 72,q = 27) == 2\n assert candidate(p = 75,q = 33) == 1\n assert candidate(p = 500,q = 250) == 2\n assert candidate(p = 720,q = 180) == 2\n assert candidate(p = 999,q = 499) == 1\n assert candidate(p = 999,q = 333) == 1\n assert candidate(p = 999,q = 1) == 1\n assert candidate(p = 997,q = 333) == 1\n assert candidate(p = 450,q = 135) == 2\n assert candidate(p = 500,q = 200) == 0\n assert candidate(p = 500,q = 249) == 2\n assert candidate(p = 64,q = 15) == 2\n assert candidate(p = 999,q = 421) == 1\n assert candidate(p = 1000,q = 333) == 2\n assert candidate(p = 123,q = 45) == 1\n assert candidate(p = 640,q = 160) == 2\n assert candidate(p = 100,q = 37) == 2\n assert candidate(p = 999,q = 998) == 0\n assert candidate(p = 888,q = 352) == 0\n assert candidate(p = 100,q = 33) == 2\n assert candidate(p = 667,q = 222) == 0\n assert candidate(p = 600,q = 150) == 2\n assert candidate(p = 1000,q = 500) == 2\n assert candidate(p = 300,q = 220) == 1\n assert candidate(p = 85,q = 21) == 1\n assert candidate(p = 199,q = 71) == 1\n assert candidate(p = 987,q = 123) == 1\n assert candidate(p = 500,q = 450) == 2\n assert candidate(p = 800,q = 300) == 2\n assert candidate(p = 97,q = 42) == 0\n assert candidate(p = 550,q = 110) == 1\n assert candidate(p = 999,q = 999) == 1\n assert candidate(p = 360,q = 121) == 2\n assert candidate(p = 81,q = 27) == 1\n assert candidate(p = 777,q = 388) == 0\n assert candidate(p = 600,q = 161) == 2\n assert candidate(p = 720,q = 199) == 2\n assert candidate(p = 625,q = 125) == 1\n assert candidate(p = 997,q = 1) == 1\n assert candidate(p = 400,q = 100) == 2\n assert candidate(p = 45,q = 18) == 0\n assert candidate(p = 725,q = 297) == 1\n assert candidate(p = 750,q = 250) == 1\n assert candidate(p = 20,q = 3) == 2\n assert candidate(p = 501,q = 167) == 1\n assert candidate(p = 880,q = 198) == 2\n assert candidate(p = 450,q = 125) == 2\n assert candidate(p = 777,q = 333) == 1\n assert candidate(p = 120,q = 49) == 2\n assert candidate(p = 450,q = 225) == 2\n assert candidate(p = 450,q = 181) == 2\n assert candidate(p = 25,q = 15) == 1\n assert candidate(p = 999,q = 777) == 1\n assert candidate(p = 450,q = 150) == 1\n assert candidate(p = 15,q = 6) == 0\n assert candidate(p = 50,q = 12) == 0\n assert candidate(p = 700,q = 175) == 2\n assert candidate(p = 555,q = 111) == 1\n assert candidate(p = 819,q = 273) == 1\n assert candidate(p = 256,q = 192) == 2\n assert candidate(p = 100,q = 1) == 2\n assert candidate(p = 80,q = 21) == 2\n assert candidate(p = 99,q = 66) == 0\n assert candidate(p = 576,q = 384) == 0\n assert candidate(p = 200,q = 77) == 2\n assert candidate(p = 500,q = 125) == 2\n assert candidate(p = 729,q = 243) == 1\n assert candidate(p = 600,q = 400) == 0\n assert candidate(p = 450,q = 113) == 2\n assert candidate(p = 600,q = 200) == 1\n assert candidate(p = 800,q = 150) == 2\n assert candidate(p = 256,q = 128) == 2\n assert candidate(p = 256,q = 93) == 2\n", "comparison": "exact"}, "public_tests": ["2\n1", "3\n1"], "hints": [], "metadata": {"canonical_parameter_names": ["p", "q"], "leetcode_dataset_entry_point": "Solution().mirrorReflection", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:10+00:00", "tests_total": 84, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["math", "geometry", "number-theory", "least-common-multiple", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def mirrorReflection(self, p: int, q: int) -> int:", "container": "Solution", "callable": "mirrorReflection", "parameters": [{"name": "p", "type": "int"}, {"name": "q", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 859, "task_id": "buddy-strings", "difficulty": "Easy", "problem_description": "Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.\n\nSwapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at s[i] and s[j].\n\n- For example, swapping at indices 0 and 2 in \"abcd\" results in \"cbad\".\n\nExample 1:\n\nInput: s = \"ab\", goal = \"ba\"\nOutput: true\nExplanation: You can swap s[0] = 'a' and s[1] = 'b' to get \"ba\", which is equal to goal.\n\nExample 2:\n\nInput: s = \"ab\", goal = \"ab\"\nOutput: false\nExplanation: The only letters you can swap are s[0] = 'a' and s[1] = 'b', which results in \"ba\" != goal.\n\nExample 3:\n\nInput: s = \"aa\", goal = \"aa\"\nOutput: true\nExplanation: You can swap s[0] = 'a' and s[1] = 'a' to get \"aa\", which is equal to goal.\n\nConstraints:\n\n- 1 <= s.length, goal.length <= 2 * 10^4\n- s and goal consist of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",goal = \"dcba\") == False\n assert candidate(s = \"xyy\",goal = \"xyx\") == False\n assert candidate(s = \"abac\",goal = \"abad\") == False\n assert candidate(s = \"aa\",goal = \"aa\") == True\n assert candidate(s = \"abcde\",goal = \"edcba\") == False\n assert candidate(s = \"aaaa\",goal = \"aaaa\") == True\n assert candidate(s = \"abab\",goal = \"abab\") == True\n assert candidate(s = \"ab\",goal = \"ab\") == False\n assert candidate(s = \"xyz\",goal = \"zyx\") == True\n assert candidate(s = \"aabbcc\",goal = \"ccbbaa\") == False\n assert candidate(s = \"abcd\",goal = \"cbad\") == True\n assert candidate(s = \"abcd\",goal = \"abdc\") == True\n assert candidate(s = \"xy\",goal = \"yx\") == True\n assert candidate(s = \"aabbcc\",goal = \"aabbcc\") == True\n assert candidate(s = \"abcde\",goal = \"abced\") == True\n assert candidate(s = \"ab\",goal = \"bba\") == False\n assert candidate(s = \"abcd\",goal = \"abcd\") == False\n assert candidate(s = \"abab\",goal = \"baba\") == False\n assert candidate(s = \"xx\",goal = \"xx\") == True\n assert candidate(s = \"aba\",goal = \"aba\") == True\n assert candidate(s = \"abcde\",goal = \"abcde\") == False\n assert candidate(s = \"abc\",goal = \"acb\") == True\n assert candidate(s = \"ab\",goal = \"ba\") == True\n assert candidate(s = \"abcdefghij\",goal = \"bacdefghij\") == True\n assert candidate(s = \"abcdefghi\",goal = \"abcdefghj\") == False\n assert candidate(s = \"xyzabc\",goal = \"zyxabc\") == True\n assert candidate(s = \"aabbccddeeff\",goal = \"aabbccdeeff\") == False\n assert candidate(s = \"abcabcabcabc\",goal = \"abcabcabcaba\") == False\n assert candidate(s = \"abacabad\",goal = \"abacabad\") == True\n assert candidate(s = \"aabbccdd\",goal = \"aabbcccc\") == False\n assert candidate(s = \"xyzz\",goal = \"zzyx\") == False\n assert candidate(s = \"aabb\",goal = \"bbaa\") == False\n assert candidate(s = \"xyzz\",goal = \"zzxy\") == False\n assert candidate(s = \"xyzzxyzz\",goal = \"zzxyzzxy\") == False\n assert candidate(s = \"abacab\",goal = \"babaab\") == False\n assert candidate(s = \"abcdefgh\",goal = \"efabcdgh\") == False\n assert candidate(s = \"abcdabcdabcd\",goal = \"abcdabcdabcd\") == True\n assert candidate(s = \"abcabcabc\",goal = \"abcabcabc\") == True\n assert candidate(s = \"abcaa\",goal = \"acbaa\") == True\n assert candidate(s = \"abcabcabc\",goal = \"abcabcbac\") == True\n assert candidate(s = \"aabbcc\",goal = \"abcabc\") == False\n assert candidate(s = \"aaaaaaa\",goal = \"aaaaaaa\") == True\n assert candidate(s = \"mississippi\",goal = \"ssimmisippi\") == False\n assert candidate(s = \"abcdefgh\",goal = \"abcdefgh\") == False\n assert candidate(s = \"aabbc\",goal = \"aabcb\") == True\n assert candidate(s = \"abcdefghi\",goal = \"abcdefghij\") == False\n assert candidate(s = \"aabbcc\",goal = \"aaccbb\") == False\n assert candidate(s = \"abracadabra\",goal = \"abracadabra\") == True\n assert candidate(s = \"aabbaa\",goal = \"aabbba\") == False\n assert candidate(s = \"aabbccddeeff\",goal = \"bbaaddeeccff\") == False\n assert candidate(s = \"abcdefghij\",goal = \"abcdefghij\") == False\n assert candidate(s = \"xyzz\",goal = \"zzxz\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",goal = \"abcdefghijklmnopqrstuvwxzy\") == True\n assert candidate(s = \"abacabad\",goal = \"abacabda\") == True\n assert candidate(s = \"mississippi\",goal = \"misssipii\") == False\n assert candidate(s = \"xyzz\",goal = \"yxzz\") == True\n assert candidate(s = \"aabbccddeeff\",goal = \"bbaaddeeffcc\") == False\n assert candidate(s = \"abcdef\",goal = \"fedcba\") == False\n assert candidate(s = \"xyzz\",goal = \"zyzz\") == False\n assert candidate(s = \"abcab\",goal = \"abcab\") == True\n assert candidate(s = \"mississippi\",goal = \"mpississii\") == False\n assert candidate(s = \"aabbccdd\",goal = \"aabbccdd\") == True\n assert candidate(s = \"abcabcabc\",goal = \"cbaabcabc\") == True\n assert candidate(s = \"abcdabcd\",goal = \"abcdabcd\") == True\n assert candidate(s = \"abac\",goal = \"acba\") == False\n assert candidate(s = \"aabbccddeeff\",goal = \"ffeeddccbbaa\") == False\n assert candidate(s = \"aabb\",goal = \"abab\") == True\n assert candidate(s = \"aabbccddeeffgg\",goal = \"aabbcdddeeffgg\") == False\n assert candidate(s = \"xyzxyz\",goal = \"zyxzyx\") == False\n assert candidate(s = \"xyzxyzxyz\",goal = \"zyxzyxzyx\") == False\n assert candidate(s = \"a\",goal = \"a\") == False\n assert candidate(s = \"abcdef\",goal = \"abdefc\") == False\n assert candidate(s = \"abccba\",goal = \"bacbca\") == False\n assert candidate(s = \"abcabcabc\",goal = \"bacbacbac\") == False\n assert candidate(s = \"xyzz\",goal = \"zyzx\") == True\n assert candidate(s = \"abcdefg\",goal = \"gfedcba\") == False\n assert candidate(s = \"abac\",goal = \"abca\") == True\n assert candidate(s = \"aabbccddeeff\",goal = \"aabbccddffee\") == False\n assert candidate(s = \"abcdexyz\",goal = \"abcdefyz\") == False\n assert candidate(s = \"abacaxbada\",goal = \"abacaxbada\") == True\n assert candidate(s = \"aabcc\",goal = \"acaab\") == False\n assert candidate(s = \"aabbccddeeffgg\",goal = \"aabbccddeeffgg\") == True\n assert candidate(s = \"xyzz\",goal = \"zyxz\") == True\n assert candidate(s = \"abcdeabcde\",goal = \"abcdeabcde\") == True\n assert candidate(s = \"abcdefgh\",goal = \"efghabcd\") == False\n assert candidate(s = \"xyzz\",goal = \"xyzz\") == True\n assert candidate(s = \"abcabcabc\",goal = \"bcaabcabc\") == False\n assert candidate(s = \"xyxyxyxyxy\",goal = \"yxyxyxyxyx\") == False\n assert candidate(s = \"abcdefghij\",goal = \"abcdefghik\") == False\n assert candidate(s = \"abababab\",goal = \"babababa\") == False\n assert candidate(s = \"abcdef\",goal = \"fabcde\") == False\n assert candidate(s = \"ababab\",goal = \"bababa\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",goal = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"aaaabbbbcccc\",goal = \"ccccaaaabbbb\") == False\n assert candidate(s = \"aab\",goal = \"aba\") == True\n assert candidate(s = \"aabbc\",goal = \"aacbb\") == True\n assert candidate(s = \"xyzz\",goal = \"zzzx\") == False\n assert candidate(s = \"zzzzzzzz\",goal = \"zzzzzzzz\") == True\n assert candidate(s = \"abcdefghij\",goal = \"abcdefghji\") == True\n assert candidate(s = \"abcdeabcde\",goal = \"abcdebacde\") == True\n assert candidate(s = \"abcdefg\",goal = \"abcdefg\") == False\n assert candidate(s = \"abacabadabacaba\",goal = \"abacabadabacabb\") == False\n assert candidate(s = \"mississippi\",goal = \"mississippi\") == True\n assert candidate(s = \"abcdxy\",goal = \"abcdyx\") == True\n assert candidate(s = \"abcdexyz\",goal = \"xyzabcdexyz\") == False\n assert candidate(s = \"xyzz\",goal = \"zyyz\") == False\n assert candidate(s = \"abcabcabc\",goal = \"cbacbacba\") == False\n assert candidate(s = \"aabbccddeeff\",goal = \"aabbccddfeef\") == True\n assert candidate(s = \"aabbccddeeff\",goal = \"aabbccdeeef\") == False\n assert candidate(s = \"abacabadabacaba\",goal = \"babacabadabacab\") == False\n assert candidate(s = \"aabbccddeeff\",goal = \"aabbccddeeff\") == True\n assert candidate(s = \"aabbccddeeff\",goal = \"aabbccddeffg\") == False\n assert candidate(s = \"aabbb\",goal = \"bbaaa\") == False\n assert candidate(s = \"mississippi\",goal = \"mississipp\") == False\n assert candidate(s = \"abacabadabacaba\",goal = \"abacabadabacaba\") == True\n assert candidate(s = \"abcabcabcabc\",goal = \"abcabcabcabc\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",goal = \"zzxxwwvvuuttsrqponmlkjihgfedcbaabbccddeeffgg\") == False\n assert candidate(s = \"abcdabcd\",goal = \"dcbaabcd\") == False\n assert candidate(s = \"aabbccdd\",goal = \"bbaaddcc\") == False\n assert candidate(s = \"abcdefgh\",goal = \"hgfedcba\") == False\n assert candidate(s = \"abacaba\",goal = \"abacaba\") == True\n assert candidate(s = \"abcxy\",goal = \"abcyx\") == True\n assert candidate(s = \"abcdefgh\",goal = \"abcdefhg\") == True\n assert candidate(s = \"abacabad\",goal = \"abacabdc\") == False\n assert candidate(s = \"aaaaaa\",goal = \"aaaaaa\") == True\n assert candidate(s = \"abcdefghij\",goal = \"aibcdefghj\") == False\n", "comparison": "exact"}, "public_tests": ["\"ab\"\n\"ba\"", "\"ab\"\n\"ab\"", "\"aa\"\n\"aa\""], "hints": [], "metadata": {"canonical_parameter_names": ["s", "goal"], "leetcode_dataset_entry_point": "Solution().buddyStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:12+00:00", "tests_total": 126, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def buddyStrings(self, s: str, goal: str) -> bool:", "container": "Solution", "callable": "buddyStrings", "parameters": [{"name": "s", "type": "str"}, {"name": "goal", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 860, "task_id": "lemonade-change", "difficulty": "Easy", "problem_description": "At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5.\n\nNote that you do not have any change in hand at first.\n\nGiven an integer array bills where bills[i] is the bill the i^th customer pays, return true if you can provide every customer with the correct change, or false otherwise.\n\nExample 1:\n\nInput: bills = [5,5,5,10,20]\nOutput: true\nExplanation:\nFrom the first 3 customers, we collect three $5 bills in order.\nFrom the fourth customer, we collect a $10 bill and give back a $5.\nFrom the fifth customer, we give a $10 bill and a $5 bill.\nSince all customers got correct change, we output true.\n\nExample 2:\n\nInput: bills = [5,5,10,10,20]\nOutput: false\nExplanation:\nFrom the first two customers in order, we collect two $5 bills.\nFor the next two customers in order, we collect a $10 bill and give back a $5 bill.\nFor the last customer, we can not give the change of $15 back because we only have two $10 bills.\nSince not every customer received the correct change, the answer is false.\n\nConstraints:\n\n- 1 <= bills.length <= 10^5\n- bills[i] is either 5, 10, or 20.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bills = [5, 5, 5, 5, 20, 20, 5, 5, 20, 5]) == False\n assert candidate(bills = [5, 5, 10, 10, 5, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 20, 5, 5, 5, 10, 5, 20]) == True\n assert candidate(bills = [5, 5, 10, 10, 20]) == False\n assert candidate(bills = [5, 5, 10, 10, 5, 20, 10, 5, 5, 20]) == False\n assert candidate(bills = [5, 10, 5, 5, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 10, 5, 10, 20]) == True\n assert candidate(bills = [5, 10, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 20]) == True\n assert candidate(bills = [10, 10]) == False\n assert candidate(bills = [5, 5, 5, 10, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 10]) == True\n assert candidate(bills = [5, 10, 20, 10, 5]) == False\n assert candidate(bills = [5, 10, 5, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 20, 5, 10, 5, 20]) == True\n assert candidate(bills = [5, 20, 5, 5, 10, 10, 5, 10, 20, 5, 5, 10, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 10, 5, 5, 10, 10, 5, 10, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 5, 10, 20, 10, 5, 5, 20, 5, 5, 5, 10, 10, 5, 20, 10, 20, 5]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 5, 20, 5, 10, 5, 20, 5, 10, 5, 20, 5, 10, 5, 20]) == True\n assert candidate(bills = [5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 5, 5, 5, 10, 5, 5, 10, 20, 5, 5, 10, 5, 5, 20, 10, 5, 20, 5, 5, 20]) == True\n assert candidate(bills = [5, 5, 10, 5, 5, 10, 5, 10, 20, 20, 5, 10, 20, 5]) == False\n assert candidate(bills = [20, 5, 5, 10, 5, 10, 20, 5, 10, 5, 10, 20, 5, 10, 5, 10, 20, 5, 10, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 20, 5, 10, 10, 20, 5, 10, 20, 5, 10, 20, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == False\n assert candidate(bills = [5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20]) == True\n assert candidate(bills = [5, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5]) == False\n assert candidate(bills = [5, 10, 20, 10, 5, 20, 10, 5, 10, 20, 5, 5, 5, 10, 10, 5, 20, 10, 20, 5, 5, 10, 10, 10, 20, 5, 10]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [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, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 5, 10, 5, 5, 20, 20, 5, 5, 10, 10, 20, 5, 5, 10, 10, 20, 20, 5, 5, 10, 10, 20, 5, 5, 10, 10, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 10, 20, 5, 10, 5, 10, 20, 10, 5, 5, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 10, 5, 20, 10, 5, 5, 20, 20, 5, 10, 5, 10, 5, 20, 10, 20, 10, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(bills = [5, 10, 10, 10, 10, 20, 20, 20, 20, 5, 5, 5, 5, 10, 10]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 5, 10, 20, 5, 10, 10, 20, 5, 5, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 10, 5, 10, 20, 5, 10, 10, 20, 5, 10, 20, 10, 5, 5, 5, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [20, 5, 5, 5, 10, 10, 20, 5, 5, 10, 5, 10, 20, 20, 5, 5, 10, 5, 10, 20, 5, 5, 10, 5, 10, 20, 20, 5, 5, 10, 5, 10, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20]) == True\n assert candidate(bills = [5, 10, 20, 5, 10, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20, 5, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 10, 5, 5, 10, 20, 5, 10, 5, 5, 10, 10, 5, 5, 10, 20, 5, 10, 5, 5, 10, 20, 5, 10]) == True\n assert candidate(bills = [5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 10, 10, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 10, 10, 20, 5, 5, 5, 10, 10, 20, 5, 5, 5, 10, 10, 20, 5, 5, 5, 5, 10, 10, 10, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 5, 10, 20, 10, 5, 20, 5, 10, 5, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(bills = [5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 10, 10, 20, 20, 20, 10, 10, 10, 10, 10, 10, 5, 5, 5]) == False\n assert candidate(bills = [5, 20, 5, 5, 5, 10, 10, 10, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 20, 5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 10, 5, 20, 10, 10, 20, 5, 10, 5, 20, 5, 10, 5, 20, 5, 10, 5, 20]) == False\n assert candidate(bills = [5, 5, 10, 10, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20]) == False\n assert candidate(bills = [5, 10, 5, 20, 10, 20, 5, 10, 5, 20, 10, 20, 5, 10, 5, 20, 10, 20, 5, 10, 5, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 20, 20, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20, 5, 10, 5, 5, 20, 20, 5, 5, 10, 10, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 10, 20, 5, 10, 10, 20, 5, 5, 10, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 20, 20, 5, 5, 10, 10, 20, 5, 5, 10]) == False\n assert candidate(bills = [20, 5, 5, 5, 10, 10, 5, 5, 20, 5, 10, 5, 5, 20, 10, 5, 10, 20, 5, 10, 20, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 20, 10, 10, 10, 20, 20, 20, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(bills = [5, 10, 5, 10, 5, 10, 5, 10, 20, 20, 20, 5, 5, 10, 10, 20]) == False\n assert candidate(bills = [20, 5, 5, 5, 10, 10, 5, 20, 10, 5, 10, 20, 10, 5, 20, 5, 10, 10, 20, 5, 5]) == False\n assert candidate(bills = [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, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 20, 5, 10, 10, 20, 5, 10, 10, 20, 5, 10, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 10, 10, 10, 20, 20, 20, 5, 5, 5, 10, 10, 10, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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]) == False\n assert candidate(bills = [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, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [20, 5, 5, 5, 10, 10, 20, 5, 5, 10, 5, 10, 20, 20]) == False\n assert candidate(bills = [5, 20, 5, 5, 10, 5, 20, 10, 10, 20, 5, 10, 5, 20, 10, 5, 5, 10, 20, 5, 5]) == False\n assert candidate(bills = [5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20, 5, 20]) == False\n assert candidate(bills = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 20, 20, 20, 20]) == False\n assert candidate(bills = [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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 20, 10, 5, 20, 10, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20, 10, 5, 20]) == False\n assert candidate(bills = [20, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10, 5, 5, 5, 10, 10]) == False\n assert candidate(bills = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 20, 20, 20]) == False\n assert candidate(bills = [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]) == True\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 20, 5, 5, 5, 10, 10, 20, 5, 5, 5, 10, 10, 20, 5, 5, 5, 10, 10, 20, 5, 5]) == True\n assert candidate(bills = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 10, 10, 10, 10, 20, 20, 20, 20, 5, 5, 10, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 5, 10, 20, 5, 10, 10, 20, 5, 5, 5, 10, 20, 20]) == False\n assert candidate(bills = [5, 10, 20, 20, 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]) == False\n assert candidate(bills = [5, 10, 10, 20, 5, 5, 5, 10, 20, 10, 5, 5, 10, 20, 5, 5, 5, 10, 20, 10, 5, 5, 10, 20, 5, 5, 5, 10, 20]) == False\n assert candidate(bills = [20, 5, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 20, 5, 10, 5, 10, 5, 10, 5, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(bills = [5, 5, 10, 5, 10, 10, 20, 5, 10, 10, 20, 5, 10, 10, 20, 5, 10, 10, 20, 5, 10, 10, 20]) == False\n assert candidate(bills = [5, 5, 10, 20, 20, 20, 20, 5, 5, 5, 10, 10, 10, 20, 20, 20, 20, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(bills = [5, 5, 10, 10, 5, 20, 10, 5, 5, 20, 10, 5, 5, 20, 10, 5, 5, 5, 10, 20]) == False\n assert candidate(bills = [5, 10, 5, 10, 5, 10, 20, 5, 10, 20, 5, 10, 20]) == False\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20]) == False\n assert candidate(bills = [5, 20, 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]) == False\n", "comparison": "exact"}, "public_tests": ["[5,5,5,10,20]", "[5,5,10,10,20]"], "hints": [], "metadata": {"canonical_parameter_names": ["bills"], "leetcode_dataset_entry_point": "Solution().lemonadeChange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:15+00:00", "tests_total": 106, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def lemonadeChange(self, bills: list[int]) -> bool:", "container": "Solution", "callable": "lemonadeChange", "parameters": [{"name": "bills", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 861, "task_id": "score-after-flipping-matrix", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix grid.\n\nA move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).\n\nEvery row of the matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers.\n\nReturn the highest possible score after making any number of moves (including zero moves).\n\nExample 1:\n\nInput: grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]]\nOutput: 39\nExplanation: 0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39\n\nExample 2:\n\nInput: grid = [[0]]\nOutput: 1\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 20\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1, 1], [1, 0, 1, 0], [1, 1, 0, 0]]) == 39\n assert candidate(grid = [[1, 0, 0], [0, 1, 1], [1, 1, 0]]) == 19\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0]]) == 83\n assert candidate(grid = [[1, 0, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 1, 0, 0]]) == 78\n assert candidate(grid = [[1, 1, 1], [0, 0, 0], [1, 0, 1]]) == 19\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 45\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]]) == 40\n assert candidate(grid = [[0]]) == 1\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 45\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 21\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 18\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 1, 0]]) == 60\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0, 0, 1, 1], [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]]) == 3370\n assert candidate(grid = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == 270\n assert candidate(grid = [[1, 0, 0, 0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 0, 1, 1, 0, 1, 1, 0]]) == 3453\n assert candidate(grid = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 816\n assert candidate(grid = [[1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0]]) == 211\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 3508\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, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 3410\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]]) == 2044\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2097150\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 406\n assert candidate(grid = [[0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 810\n assert candidate(grid = [[0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1]]) == 267\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0]]) == 852\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]]) == 252\n assert candidate(grid = [[0, 0, 1, 0, 1], [1, 0, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 0, 0, 1]]) == 99\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]]) == 135\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 16380\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]]) == 210\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 3495250\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 850\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, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 3684\n assert candidate(grid = [[0, 1, 1, 0, 1], [1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 0, 0]]) == 110\n assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 1]]) == 210\n assert candidate(grid = [[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]]) == 508\n assert candidate(grid = [[0, 1, 1, 0, 1], [1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [1, 1, 1, 1, 0]]) == 100\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 0, 1, 0, 1]]) == 2044\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]]) == 635\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 418\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0]]) == 257\n assert candidate(grid = [[1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 8188\n assert candidate(grid = [[0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 204\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2044\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 35\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]]) == 1530\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]]) == 110\n assert candidate(grid = [[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], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1704\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]]) == 635\n assert candidate(grid = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 1]]) == 218\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], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 3410\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == 918\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 228\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 100\n assert candidate(grid = [[1, 0, 0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 1]]) == 892\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]]) == 508\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 210\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 0, 0, 1, 0]]) == 1662\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 0]]) == 508\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]]) == 424\n assert candidate(grid = [[1, 1, 1, 0, 1], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0]]) == 113\n assert candidate(grid = [[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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13650\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 0, 1, 1]]) == 433\n assert candidate(grid = [[1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 204\n assert candidate(grid = [[1, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 1]]) == 787\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 116\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 3478\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 60\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]]) == 1020\n assert candidate(grid = [[0, 0, 1, 1, 1], [1, 0, 0, 1, 0], [1, 1, 0, 0, 0], [0, 1, 1, 0, 1]]) == 104\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 850\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0]]) == 418\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]]) == 3274\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]]) == 155\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 124\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [1, 1, 1, 1, 1]]) == 125\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 124\n assert candidate(grid = [[0, 0, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 1]]) == 426\n assert candidate(grid = [[0, 1, 0, 1, 1], [1, 0, 1, 0, 0], [1, 1, 0, 1, 1], [0, 0, 1, 1, 0]]) == 96\n assert candidate(grid = [[1, 1, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == 208\n", "comparison": "exact"}, "public_tests": ["[[0,0,1,1],[1,0,1,0],[1,1,0,0]]", "[[0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().matrixScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:17+00:00", "tests_total": 80, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "greedy", "bit-manipulation", "matrix"]}, "language": "python", "interface": {"raw_signature": "def matrixScore(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "matrixScore", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 862, "task_id": "shortest-subarray-with-sum-at-least-k", "difficulty": "Hard", "problem_description": "Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [1], k = 1\nOutput: 1\n\nExample 2:\n\nInput: nums = [1,2], k = 4\nOutput: -1\n\nExample 3:\n\nInput: nums = [2,-1,2], k = 3\nOutput: 3\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^5 <= nums[i] <= 10^5\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5],k = 3) == 1\n assert candidate(nums = [-1, 2],k = 2) == 1\n assert candidate(nums = [2, -1, 2],k = 3) == 3\n assert candidate(nums = [2, 1, 5, 1, 3, 2],k = 7) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 3) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 5\n assert candidate(nums = [2, -2, 2, -4, 3, -1, 2, -1, 2, -4, 3, -1],k = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 5) == 1\n assert candidate(nums = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8],k = 15) == 2\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 15) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 16) == -1\n assert candidate(nums = [48, 99, 37, 4, -31],k = 140) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 3\n assert candidate(nums = [8],k = 8) == 1\n assert candidate(nums = [8, 2, 4, -6, 7, -4, 3, 5],k = 10) == 2\n assert candidate(nums = [1, 2],k = 4) == -1\n assert candidate(nums = [2, -2, 2, 2, -2, 2, 2, -2, 2, 2],k = 4) == 2\n assert candidate(nums = [8],k = 10) == -1\n assert candidate(nums = [2, -1, 2],k = 2) == 1\n assert candidate(nums = [5],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 250) == 3\n assert candidate(nums = [10, 5, 2, 7],k = 15) == 2\n assert candidate(nums = [10, -2, 5, -1, 3, -1, -2, 4, 7, -5, 2],k = 10) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 55) == 10\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000],k = 500000) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -1\n assert candidate(nums = [1, 2, -1, 2, -1, 2, -1, 2, -1],k = 3) == 2\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 150) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 550) == 10\n assert candidate(nums = [8, 2, 4, -2, 3, 1, 5],k = 10) == 2\n assert candidate(nums = [100, -25, 100, -25, 100, -25, 100, -25, 100, -25],k = 200) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 25) == 3\n assert candidate(nums = [10, 20, -30, 40, 50, -60, 70, -80],k = 150) == -1\n assert candidate(nums = [-1, 2, 3, 4, -10, 5, 6],k = 10) == 2\n assert candidate(nums = [10000, 20000, -30000, 40000, 50000, -60000, 70000, -80000],k = 100000) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 3\n assert candidate(nums = [10, -1, -2, 3, 4, -5, 6, -7, 8, -9],k = 15) == 7\n assert candidate(nums = [100000, -50000, 50000, -25000, 25000, -12500, 12500, 6250],k = 250000) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1500) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 55) == 5\n assert candidate(nums = [1, 0, 1, 1, 1, 0, 1, -1, 1, 1, 1],k = 4) == 5\n assert candidate(nums = [50, 40, 30, 20, 10],k = 90) == 2\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000],k = 100000) == 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) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 55) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 100) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [8, 2, -4, 1, 6, -5, 4],k = 10) == 2\n assert candidate(nums = [10, -10, 10, -10, 10],k = 20) == -1\n assert candidate(nums = [100000, -50000, 50000, -25000, 25000, -12500, 12500],k = 100000) == 1\n assert candidate(nums = [5, -1, 5, -1, 5, -1, 5, -1, 5, -1],k = 15) == 7\n assert candidate(nums = [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 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 8\n assert candidate(nums = [100000, -99999, 100000, -99999, 100000],k = 1) == 1\n assert candidate(nums = [-1, -2, -3, 10, -5, 2, -1, 3],k = 5) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 1\n assert candidate(nums = [84, -37, 32, 40, 95],k = 167) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],k = 150) == 5\n assert candidate(nums = [5, -1, 5, -1, 5, -1],k = 10) == 5\n assert candidate(nums = [100, 200, 300, 400, 500],k = 1500) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 2\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 7) == 1\n assert candidate(nums = [-100, 150, -200, 250, -300, 350, -400, 450, -500, 550],k = 1500) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5],k = 9) == 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],k = 100) == 6\n assert candidate(nums = [3, -2, 5, -1, 2, -3, 1, 4],k = 7) == 5\n assert candidate(nums = [8, 2, -5, 7, 11, -10, 15, 1],k = 15) == 1\n assert candidate(nums = [3, 4, 5, 1, 2, 7, 8, 9, 10, 1],k = 25) == 3\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 100) == 1\n assert candidate(nums = [8, 2, 4, -1, 0, 5, -3, 2],k = 16) == 6\n assert candidate(nums = [5, 1, 3, 5, 2, 4, 6, 1, 7, 8],k = 20) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 2\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 15) == -1\n assert candidate(nums = [3, -2, 5, -1, 4],k = 6) == 3\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == 1\n assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, 60],k = 100) == 2\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 1) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == 1\n assert candidate(nums = [5, -2, 4, 6, -1, 3, -3, 2, 7, -8],k = 12) == 4\n assert candidate(nums = [5, 1, -1, 5, 10, -10, 20, -20, 30, -30],k = 15) == 1\n assert candidate(nums = [1, -1, 5, -2, 3],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 75) == 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 = 50) == 3\n assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, -40, -50, 60, 70],k = 100) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5500) == 10\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0],k = 10) == 5\n assert candidate(nums = [5, 2, 3, -2, 4, 5, 1, -1, 2, -3, 6, 7, 8, -4, 5, 6],k = 20) == 3\n assert candidate(nums = [100, -25, 25, -25, 25, -25, 25, -25, 25],k = 50) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 15\n assert candidate(nums = [2, -2, 2, -2, 2, -2, 2, -2, 2, -2],k = 1) == 1\n assert candidate(nums = [8, 2, -3, 7, 2, -4, 6, -8],k = 5) == 1\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 = 5) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 90) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 5\n assert candidate(nums = [5, -2, 3, 8, -4, 7],k = 10) == 2\n assert candidate(nums = [10, -1, 20, -2, 30, -3, 40, -4, 50, -5],k = 100) == 5\n assert candidate(nums = [-1, 1, 1, -1, 1, 1, 1, -1, 1],k = 2) == 2\n assert candidate(nums = [100000],k = 100000) == 1\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 50) == 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 = 100) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 45) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 5\n assert candidate(nums = [5, -2, 5, -2, 5, -2, 5, -2, 5, -2],k = 10) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 1) == -1\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000],k = 100000) == -1\n assert candidate(nums = [1, 2, 3, -6, 4, 5, -3, 2, 1, 0, -1, 2, 3, -5, 6, 7],k = 15) == 9\n assert candidate(nums = [8, 2, -3, 4, 6, -5, 2, 7],k = 15) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == -1\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 20) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 550) == 10\n", "comparison": "exact"}, "public_tests": ["[1]\n1", "[1,2]\n4", "[2,-1,2]\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().shortestSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:19+00:00", "tests_total": 127, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "binary-search", "queue", "sliding-window", "heap-priority-queue", "prefix-sum", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def shortestSubarray(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "shortestSubarray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 864, "task_id": "shortest-path-to-get-all-keys", "difficulty": "Hard", "problem_description": "You are given an m x n grid grid where:\n\n- '.' is an empty cell.\n- '#' is a wall.\n- '@' is the starting point.\n- Lowercase letters represent keys.\n- Uppercase letters represent locks.\n\nYou start at the starting point and one move consists of walking one space in one of the four cardinal directions. You cannot walk outside the grid, or walk into a wall.\n\nIf you walk over a key, you can pick it up and you cannot walk over a lock unless you have its corresponding key.\n\nFor some 1 <= k <= 6, there is exactly one lowercase and one uppercase letter of the first k letters of the English alphabet in the grid. This means that there is exactly one key for each lock, and one lock for each key; and also that the letters used to represent the keys and locks were chosen in the same order as the English alphabet.\n\nReturn the lowest number of moves to acquire all keys. If it is impossible, return -1.\n\nExample 1:\n\nInput: grid = [\"@.a..\",\"###.#\",\"b.A.B\"]\nOutput: 8\nExplanation: Note that the goal is to obtain all the keys not to open all the locks.\n\nExample 2:\n\nInput: grid = [\"@..aA\",\"..B#.\",\"....b\"]\nOutput: 6\n\nExample 3:\n\nInput: grid = [\"@Aa\"]\nOutput: -1\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 30\n- grid[i][j] is either an English letter, '.', '#', or '@'.\n- There is exactly one '@' in the grid.\n- The number of keys in the grid is in the range [1, 6].\n- Each key in the grid is unique.\n- Each key in the grid has a matching lock.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = ['@.b..', '###.#', 'A.B.c']) == -1\n assert candidate(grid = ['@.b', '#.A', 'aBc']) == 8\n assert candidate(grid = ['@Aa']) == -1\n assert candidate(grid = ['@.b..', '#.A#.', 'a.c.C']) == 8\n assert candidate(grid = ['@...a', '#.#B.', '.....', 'b.cC.', '.....']) == 11\n assert candidate(grid = ['@...a', '.#.b.', '....A', '#..B.', '....b']) == -1\n assert candidate(grid = ['@...a', '#.###', 'b.BA.']) == 10\n assert candidate(grid = ['aA.b', '@.B#', '....']) == 4\n assert candidate(grid = ['@.a..', '###.#', 'b.A.B']) == 8\n assert candidate(grid = ['@.aA', 'b.Bb', '....']) == -1\n assert candidate(grid = ['@..aA', '..B#.', '....b']) == 6\n assert candidate(grid = ['@abc', '###.', 'A#B.', 'C...']) == 3\n assert candidate(grid = ['@abc', '###.', 'A.BC']) == 3\n assert candidate(grid = ['@.....', '.....a', '#.....', '.....b', '#.....', '.....A', '#.....', '.....B']) == 8\n assert candidate(grid = ['@..a..', '###.#B', '...c.C', '#####.', '..b..A']) == 12\n assert candidate(grid = ['@...a', '.#.b.', '....A', '#..B.', '....b', 'c...#', '...C.']) == -1\n assert candidate(grid = ['@.....', '.#...B', 'A...#.', '.c..#.', '.....d']) == -1\n assert candidate(grid = ['@.a..', '###.#', 'b.A.B', 'C#dE.', 'f...G', '#H..i', 'j...K', 'L....']) == -1\n assert candidate(grid = ['@abc', '###.', 'A.BC', 'D#..', '...E', 'f...', '#G..', 'hI..']) == -1\n assert candidate(grid = ['@...a', '###.#', 'b.A.B', '###.#', '....b', 'C...c', 'd.D.e']) == -1\n assert candidate(grid = ['@...a', '###b.', 'A#B..', 'C...d', '###D.', '...eE', 'f..#.', '..F..']) == -1\n assert candidate(grid = ['@.a###', '.....#', 'b...A#', '....#B', '.....c', '.....C']) == 13\n assert candidate(grid = ['@.......', '......#.', 'b.....A.', '....#B..', '.......c', '......C.']) == -1\n assert candidate(grid = ['@...a', '###b.', 'A....', '#B...']) == 6\n assert candidate(grid = ['@.......', '..a.....', '......b.', '......B.', '......A.', '......c.', '......C.', '.......@']) == 11\n assert candidate(grid = ['@..aB', '###.#', '..c.C', '#####', '..bA.']) == -1\n assert candidate(grid = ['@.a.b', '##..#', '.C...', 'A###.', '....B']) == 4\n assert candidate(grid = ['@.aBc', '###D.', 'E...F', 'G#b.H', '....I']) == -1\n assert candidate(grid = ['@.a.B', '###.#', 'cA.BC', '###d.', '....D']) == -1\n assert candidate(grid = ['@.a.B', '###.#', 'cA.BC', '###d.', '....D', '.efE.', '#F...', 'g....']) == -1\n assert candidate(grid = ['@.a..', '###B.', '....A', 'b....']) == 11\n assert candidate(grid = ['@.abc', '###.#', 'A#B#C', 'd.e.f', 'D.E.F', '...gH', '...ih']) == -1\n assert candidate(grid = ['@.a.b', '#.C.D', '....E', 'F.G.H', 'I.J.K', 'L.M.N', 'O.P.@']) == 4\n assert candidate(grid = ['@.aB', '.###', 'C#b.', 'c...', '....']) == -1\n assert candidate(grid = ['@...a', '###.#', 'b.A.B', '###.#', '....b', 'C...c']) == -1\n assert candidate(grid = ['@.a...', '#.....', 'b.....', '#.....', '.....A', '.....B']) == 6\n assert candidate(grid = ['@.aB', '###C', 'D#bE', 'F...', '.G.H']) == -1\n assert candidate(grid = ['@...a', '###b.', '#B...', '....A', '....b']) == -1\n assert candidate(grid = ['@....', '#.aB.', 'C#b.D', '.FEG.', '....H']) == 4\n assert candidate(grid = ['@...a', '###.#', 'b.A.B', '###.#', '....b', 'C...c', 'D...d', 'E...e', 'F...f']) == -1\n assert candidate(grid = ['@abc', '###.', 'A.BC', 'D...', '..EF', 'G...', '.H..', 'IJKL']) == 3\n assert candidate(grid = ['@.aBc', '##D..', 'E...C', 'F#bA.', '....G']) == -1\n assert candidate(grid = ['@.a..', '#.B..', '...cA', 'd.B.c', 'A.#..']) == -1\n assert candidate(grid = ['@...a', '#.b.B', '#.#.#', 'A.B.a', '.B...', 'c....']) == -1\n assert candidate(grid = ['@.#.a', '#..b.', '...A.', '#..B.', '....b', 'c....', 'C...d']) == -1\n assert candidate(grid = ['@.....', '.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(grid = ['@abc', '###.', 'A.BC', 'D...', '..EF', 'G...', '.H..', 'IJKL', '#...', 'M...']) == 3\n assert candidate(grid = ['@.a.b', '##C..', 'D#E.F', 'G...H', '...IJ', '....K', '....L', '....M', '....N']) == 4\n", "comparison": "exact"}, "public_tests": ["[\"@.a..\",\"###.#\",\"b.A.B\"]", "[\"@..aA\",\"..B#.\",\"....b\"]", "[\"@Aa\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().shortestPathAllKeys", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:21+00:00", "tests_total": 60, "tests_dropped": 12, "flags": ["has_images"], "topic_tags": ["array", "bit-manipulation", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def shortestPathAllKeys(self, grid: list[str]) -> int:", "container": "Solution", "callable": "shortestPathAllKeys", "parameters": [{"name": "grid", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 866, "task_id": "prime-palindrome", "difficulty": "Medium", "problem_description": "Given an integer n, return the smallest prime palindrome greater than or equal to n.\n\nAn integer is prime if it has exactly two divisors: 1 and itself. Note that 1 is not a prime number.\n\n- For example, 2, 3, 5, 7, 11, and 13 are all primes.\n\nAn integer is a palindrome if it reads the same from left to right as it does from right to left.\n\n- For example, 101 and 12321 are palindromes.\n\nThe test cases are generated so that the answer always exists and is in the range [2, 2 * 10^8].\n\nExample 1:\n\nInput: n = 6\nOutput: 7\n\nExample 2:\n\nInput: n = 8\nOutput: 11\n\nExample 3:\n\nInput: n = 13\nOutput: 101\n\nConstraints:\n\n- 1 <= n <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == 101\n assert candidate(n = 8) == 11\n assert candidate(n = 10000000) == 100030001\n assert candidate(n = 10007) == 10301\n assert candidate(n = 999) == 10301\n assert candidate(n = 6) == 7\n assert candidate(n = 999983) == 1003001\n assert candidate(n = 2) == 2\n assert candidate(n = 100000000) == 100030001\n assert candidate(n = 9989900) == 100030001\n assert candidate(n = 100) == 101\n assert candidate(n = 10) == 11\n assert candidate(n = 1000) == 10301\n assert candidate(n = 20000000) == 100030001\n assert candidate(n = 1) == 2\n assert candidate(n = 13) == 101\n assert candidate(n = 12345678) == 100030001\n assert candidate(n = 99999) == 1003001\n assert candidate(n = 9999999) == 100030001\n assert candidate(n = 66666666) == 100030001\n assert candidate(n = 12321) == 12421\n assert candidate(n = 80000000) == 100030001\n assert candidate(n = 8999998) == 9002009\n assert candidate(n = 75000000) == 100030001\n assert candidate(n = 1003001) == 1003001\n assert candidate(n = 899989) == 1003001\n assert candidate(n = 50000000) == 100030001\n assert candidate(n = 100003) == 1003001\n assert candidate(n = 98765432) == 100030001\n assert candidate(n = 99999999) == 100030001\n assert candidate(n = 55555555) == 100030001\n assert candidate(n = 9999) == 10301\n assert candidate(n = 90000000) == 100030001\n assert candidate(n = 9988999) == 9989899\n assert candidate(n = 998899) == 1003001\n assert candidate(n = 11111111) == 100030001\n assert candidate(n = 1000000) == 1003001\n assert candidate(n = 88888888) == 100030001\n assert candidate(n = 989) == 10301\n assert candidate(n = 1000001) == 1003001\n assert candidate(n = 999999) == 1003001\n assert candidate(n = 1234567) == 1235321\n assert candidate(n = 100001) == 1003001\n assert candidate(n = 1000003) == 1003001\n", "comparison": "exact"}, "public_tests": ["6", "8", "13"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().primePalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:25+00:00", "tests_total": 52, "tests_dropped": 8, "flags": [], "topic_tags": ["math", "number-theory", "primality-test"]}, "language": "python", "interface": {"raw_signature": "def primePalindrome(self, n: int) -> int:", "container": "Solution", "callable": "primePalindrome", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 867, "task_id": "transpose-matrix", "difficulty": "Easy", "problem_description": "Given a 2D integer array matrix, return the transpose of matrix.\n\nThe transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.\n\nExample 1:\n\nInput: matrix = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [[1,4,7],[2,5,8],[3,6,9]]\n\nExample 2:\n\nInput: matrix = [[1,2,3],[4,5,6]]\nOutput: [[1,4],[2,5],[3,6]]\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 1000\n- 1 <= m * n <= 10^5\n- -10^9 <= matrix[i][j] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1]]) == [(1,)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]]) == [(1, 3, 5), (2, 4, 6)]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [(1, 4, 7), (2, 5, 8), (3, 6, 9)]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6]]) == [(1, 4), (2, 5), (3, 6)]\n assert candidate(matrix = [[-1000, 1000], [2000, -2000]]) == [(-1000, 2000), (1000, -2000)]\n assert candidate(matrix = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [(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)]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == [(-1, -4, -7), (-2, -5, -8), (-3, -6, -9)]\n assert candidate(matrix = [[1000000000, -1000000000], [1000000000, 1000000000], [-1000000000, -1000000000]]) == [(1000000000, 1000000000, -1000000000), (-1000000000, 1000000000, -1000000000)]\n assert candidate(matrix = [[-1, 0, 1], [-2, 0, 2], [-3, 0, 3]]) == [(-1, -2, -3), (0, 0, 0), (1, 2, 3)]\n assert candidate(matrix = [[1000000000, -1000000000], [1000000000, -1000000000], [1000000000, -1000000000]]) == [(1000000000, 1000000000, 1000000000), (-1000000000, -1000000000, -1000000000)]\n assert candidate(matrix = [[1, 0, -1, 2], [3, 4, 5, 6], [7, -8, 9, -10]]) == [(1, 3, 7), (0, 4, -8), (-1, 5, 9), (2, 6, -10)]\n assert candidate(matrix = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3]]) == [(1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [(1, 3, 5, 7, 9), (2, 4, 6, 8, 10)]\n assert candidate(matrix = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)]\n assert candidate(matrix = [[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]]) == [(1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6)]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [(1, 6, 11, 16), (2, 7, 12, 17), (3, 8, 13, 18), (4, 9, 14, 19), (5, 10, 15, 20)]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0]]) == [(1, 0, 9, 4), (2, 0, 8, 3), (3, 0, 7, 2), (4, 0, 6, 1), (5, 0, 5, 0)]\n assert candidate(matrix = [[9]]) == [(9,)]\n assert candidate(matrix = [[1, -1, 2, -2], [-3, 3, -4, 4], [5, -5, 6, -6]]) == [(1, -3, 5), (-1, 3, -5), (2, -4, 6), (-2, 4, -6)]\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == [(1, 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(matrix = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [0, -1, -2]]) == [(9, 6, 3, 0), (8, 5, 2, -1), (7, 4, 1, -2)]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [(1, 5, 9, 13), (2, 6, 10, 14), (3, 7, 11, 15), (4, 8, 12, 16)]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [(1, 5, 9, 13), (2, 6, 10, 14), (3, 7, 11, 15), (4, 8, 12, 16)]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9], [-10, -11, -12]]) == [(-1, -4, -7, -10), (-2, -5, -8, -11), (-3, -6, -9, -12)]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == [(1, 5, 9, 13, 17), (2, 6, 10, 14, 18), (3, 7, 11, 15, 19), (4, 8, 12, 16, 20)]\n assert candidate(matrix = [[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, 3, 4, 5), (1, 2, 3, 4, 5), (1, 2, 3, 4, 5), (1, 2, 3, 4, 5), (1, 2, 3, 4, 5)]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,)]\n assert candidate(matrix = [[1000000, 2000000], [3000000, 4000000], [5000000, 6000000], [7000000, 8000000]]) == [(1000000, 3000000, 5000000, 7000000), (2000000, 4000000, 6000000, 8000000)]\n assert candidate(matrix = [[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18]]) == [(7, 11, 15), (8, 12, 16), (9, 13, 17), (10, 14, 18)]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)]\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]) == [(0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)]\n assert candidate(matrix = [[1000000000, 1000000000, 1000000000], [1000000000, 1000000000, 1000000000]]) == [(1000000000, 1000000000), (1000000000, 1000000000), (1000000000, 1000000000)]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [(0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == [(1, 4, 7, 10, 13), (2, 5, 8, 11, 14), (3, 6, 9, 12, 15)]\n assert candidate(matrix = [[10, 20], [30, 40], [50, 60], [70, 80]]) == [(10, 30, 50, 70), (20, 40, 60, 80)]\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]]) == [(10, 5, 1), (20, 15, 11), (30, 25, 21), (40, 35, 31), (50, 45, 41)]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [(0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [(1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16), (7, 17), (8, 18), (9, 19), (10, 20)]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9], [-10, -11, -12]]) == [(-1, -4, -7, -10), (-2, -5, -8, -11), (-3, -6, -9, -12)]\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]]) == [(0, 1, 2, 3), (0, 1, 2, 3), (0, 1, 2, 3), (0, 1, 2, 3), (0, 1, 2, 3), (0, 1, 2, 3)]\n assert candidate(matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == [(1, 0, 0), (0, 1, 0), (0, 0, 1)]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]\n assert candidate(matrix = [[-999999999, -999999999], [-999999999, -999999999], [999999999, 999999999]]) == [(-999999999, -999999999, 999999999), (-999999999, -999999999, 999999999)]\n assert candidate(matrix = [[-10, 20, -30, 40], [10, -20, 30, -40], [-5, 5, -15, 15], [25, -25, 35, -35]]) == [(-10, 10, -5, 25), (20, -20, 5, -25), (-30, 30, -15, 35), (40, -40, 15, -35)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == [(1, 3, 5, 7, 9, 11, 13), (2, 4, 6, 8, 10, 12, 14)]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == [(1, 4, 7, 10, 13), (2, 5, 8, 11, 14), (3, 6, 9, 12, 15)]\n assert candidate(matrix = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]) == [(1, 2, 3, 4, 5), (2, 3, 4, 5, 6), (3, 4, 5, 6, 7)]\n assert candidate(matrix = [[-1, 2, -3, 4], [5, -6, 7, -8], [9, -10, 11, -12]]) == [(-1, 5, 9), (2, -6, -10), (-3, 7, 11), (4, -8, -12)]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]\n assert candidate(matrix = [[0, 1, 2], [3, 0, 4], [5, 6, 0]]) == [(0, 3, 5), (1, 0, 6), (2, 4, 0)]\n assert candidate(matrix = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == [(1, 0, 1), (0, 1, 0), (1, 0, 1)]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == [(1, 4, 7, 10, 13, 16), (2, 5, 8, 11, 14, 17), (3, 6, 9, 12, 15, 18)]\n assert candidate(matrix = [[1000000000, -1000000000], [1000000000, -1000000000], [1000000000, -1000000000]]) == [(1000000000, 1000000000, 1000000000), (-1000000000, -1000000000, -1000000000)]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == [(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), (10, 20, 30)]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,)]\n assert candidate(matrix = [[1000000000, 0], [-1000000000, 1000000000]]) == [(1000000000, -1000000000), (0, 1000000000)]\n assert candidate(matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0]]) == [(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), (2, 4, 6, 8, 10, 12, 14, 16, 18, 20)]\n assert candidate(matrix = [[-999999999, 999999999, -999999999], [999999999, -999999999, 999999999], [-999999999, 999999999, -999999999]]) == [(-999999999, 999999999, -999999999), (999999999, -999999999, 999999999), (-999999999, 999999999, -999999999)]\n assert candidate(matrix = [[-999999999, 999999999], [0, 1], [2, -2], [3, -3]]) == [(-999999999, 0, 2, 3), (999999999, 1, -2, -3)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [(1, 3, 5, 7), (2, 4, 6, 8)]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [(0, 0, 0, 0, 0), (0, 0, 0, 0, 0), (0, 0, 0, 0, 0), (0, 0, 0, 0, 0), (0, 0, 0, 0, 0)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), (2, 4, 6, 8, 10, 12, 14, 16, 18, 20)]\n assert candidate(matrix = [[-999999999, 999999999], [-888888888, 888888888]]) == [(-999999999, -888888888), (999999999, 888888888)]\n assert candidate(matrix = [[-1, 0, 1], [-2, 0, 2], [-3, 0, 3], [-4, 0, 4], [-5, 0, 5]]) == [(-1, -2, -3, -4, -5), (0, 0, 0, 0, 0), (1, 2, 3, 4, 5)]\n assert candidate(matrix = [[1, 0, -1], [2, 0, -2], [3, 0, -3], [4, 0, -4]]) == [(1, 2, 3, 4), (0, 0, 0, 0), (-1, -2, -3, -4)]\n assert candidate(matrix = [[1000000000, -1000000000], [-1000000000, 1000000000], [1000000000, -1000000000]]) == [(1000000000, -1000000000, 1000000000), (-1000000000, 1000000000, -1000000000)]\n assert candidate(matrix = [[999999999, 888888888, 777777777], [666666666, 555555555, 444444444], [333333333, 222222222, 111111111]]) == [(999999999, 666666666, 333333333), (888888888, 555555555, 222222222), (777777777, 444444444, 111111111)]\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120]]) == [(10, 40, 70, 100), (20, 50, 80, 110), (30, 60, 90, 120)]\n assert candidate(matrix = [[1, 2, 3, 4, 5]]) == [(1,), (2,), (3,), (4,), (5,)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [(1, 3, 5, 7, 9), (2, 4, 6, 8, 10)]\n assert candidate(matrix = [[999, 998, 997], [996, 995, 994], [993, 992, 991], [990, 989, 988]]) == [(999, 996, 993, 990), (998, 995, 992, 989), (997, 994, 991, 988)]\n assert candidate(matrix = [[1], [2], [3], [4], [5]]) == [(1, 2, 3, 4, 5)]\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[4,5,6],[7,8,9]]", "[[1,2,3],[4,5,6]]"], "hints": ["We don't need any special algorithms to do this. You just need to know what the transpose of a matrix looks like. Rows become columns and vice versa!"], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().transpose", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:28+00:00", "tests_total": 74, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def transpose(self, matrix: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "transpose", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 868, "task_id": "binary-gap", "difficulty": "Easy", "problem_description": "Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0.\n\nTwo 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between their bit positions. For example, the two 1's in \"1001\" have a distance of 3.\n\nExample 1:\n\nInput: n = 22\nOutput: 2\nExplanation: 22 in binary is \"10110\".\nThe first adjacent pair of 1's is \"10110\" with a distance of 2.\nThe second adjacent pair of 1's is \"10110\" with a distance of 1.\nThe answer is the largest of these two distances, which is 2.\nNote that \"10110\" is not a valid pair since there is a 1 separating the two 1's underlined.\n\nExample 2:\n\nInput: n = 8\nOutput: 0\nExplanation: 8 in binary is \"1000\".\nThere are not any adjacent pairs of 1's in the binary representation of 8, so we return 0.\n\nExample 3:\n\nInput: n = 5\nOutput: 2\nExplanation: 5 in binary is \"101\".\n\nConstraints:\n\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 0\n assert candidate(n = 3) == 1\n assert candidate(n = 1041) == 6\n assert candidate(n = 15) == 1\n assert candidate(n = 22) == 2\n assert candidate(n = 32) == 0\n assert candidate(n = 6) == 1\n assert candidate(n = 1) == 0\n assert candidate(n = 1000000000) == 3\n assert candidate(n = 7) == 1\n assert candidate(n = 13) == 2\n assert candidate(n = 5) == 2\n assert candidate(n = 29) == 2\n assert candidate(n = 131071) == 1\n assert candidate(n = 999999999) == 3\n assert candidate(n = 47) == 2\n assert candidate(n = 67890) == 5\n assert candidate(n = 67108863) == 1\n assert candidate(n = 536870913) == 29\n assert candidate(n = 511) == 1\n assert candidate(n = 21845) == 2\n assert candidate(n = 536870912) == 0\n assert candidate(n = 665772) == 4\n assert candidate(n = 6754321) == 8\n assert candidate(n = 67) == 5\n assert candidate(n = 134217727) == 1\n assert candidate(n = 37) == 3\n assert candidate(n = 33) == 5\n assert candidate(n = 8388607) == 1\n assert candidate(n = 983041) == 16\n assert candidate(n = 1001) == 3\n assert candidate(n = 134217729) == 27\n assert candidate(n = 101010101) == 7\n assert candidate(n = 1024) == 0\n assert candidate(n = 16777215) == 1\n assert candidate(n = 777777777) == 4\n assert candidate(n = 4194305) == 22\n assert candidate(n = 1048576) == 0\n assert candidate(n = 807798533) == 7\n assert candidate(n = 18) == 3\n assert candidate(n = 131073) == 17\n assert candidate(n = 65535) == 1\n assert candidate(n = 127) == 1\n assert candidate(n = 987654321) == 4\n assert candidate(n = 999999937) == 6\n assert candidate(n = 500000000) == 3\n assert candidate(n = 31) == 1\n assert candidate(n = 123456789) == 4\n assert candidate(n = 33554431) == 1\n", "comparison": "exact"}, "public_tests": ["22", "8", "5"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().binaryGap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:30+00:00", "tests_total": 65, "tests_dropped": 16, "flags": [], "topic_tags": ["bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def binaryGap(self, n: int) -> int:", "container": "Solution", "callable": "binaryGap", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 869, "task_id": "reordered-power-of-2", "difficulty": "Medium", "problem_description": "You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero.\n\nReturn true if and only if we can do this so that the resulting number is a power of two.\n\nExample 1:\n\nInput: n = 1\nOutput: true\n\nExample 2:\n\nInput: n = 10\nOutput: false\n\nConstraints:\n\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 46875) == False\n assert candidate(n = 3245) == False\n assert candidate(n = 86) == False\n assert candidate(n = 10) == False\n assert candidate(n = 4326) == False\n assert candidate(n = 16) == True\n assert candidate(n = 82084) == False\n assert candidate(n = 1024) == True\n assert candidate(n = 128) == True\n assert candidate(n = 821) == True\n assert candidate(n = 8192) == True\n assert candidate(n = 65536) == True\n assert candidate(n = 46) == True\n assert candidate(n = 256) == True\n assert candidate(n = 1000000000) == False\n assert candidate(n = 24) == False\n assert candidate(n = 987654321) == False\n assert candidate(n = 512) == True\n assert candidate(n = 4102) == True\n assert candidate(n = 1) == True\n assert candidate(n = 462) == False\n assert candidate(n = 862467834) == False\n assert candidate(n = 8258) == False\n assert candidate(n = 2097152) == True\n assert candidate(n = 786432) == False\n assert candidate(n = 3145728) == False\n assert candidate(n = 885842624) == False\n assert candidate(n = 999999999) == False\n assert candidate(n = 2359296) == False\n assert candidate(n = 67108864) == True\n assert candidate(n = 4096) == True\n assert candidate(n = 891891891) == False\n assert candidate(n = 8256) == False\n assert candidate(n = 683184) == False\n assert candidate(n = 536870912) == True\n assert candidate(n = 111222333) == False\n assert candidate(n = 524288) == True\n assert candidate(n = 82944) == False\n assert candidate(n = 94371840) == False\n assert candidate(n = 16384) == True\n assert candidate(n = 393216) == False\n assert candidate(n = 16777216) == True\n assert candidate(n = 258048) == False\n assert candidate(n = 125874) == False\n assert candidate(n = 78125) == False\n assert candidate(n = 1024576) == False\n assert candidate(n = 2415919) == False\n assert candidate(n = 134217728) == True\n assert candidate(n = 46340) == False\n assert candidate(n = 9437184) == False\n assert candidate(n = 33554432) == True\n assert candidate(n = 900000000) == False\n assert candidate(n = 24681357) == False\n assert candidate(n = 333333333) == False\n assert candidate(n = 2621440) == False\n assert candidate(n = 1048576) == True\n assert candidate(n = 2048) == True\n assert candidate(n = 22448811) == False\n assert candidate(n = 327684) == False\n assert candidate(n = 18) == False\n assert candidate(n = 768) == False\n assert candidate(n = 196608) == False\n assert candidate(n = 27962028) == False\n assert candidate(n = 894784864) == False\n assert candidate(n = 43112) == False\n assert candidate(n = 262144) == True\n assert candidate(n = 131072) == True\n assert candidate(n = 82128) == False\n assert candidate(n = 111111111) == False\n assert candidate(n = 31415926) == False\n assert candidate(n = 499999999) == False\n assert candidate(n = 318666) == False\n assert candidate(n = 180) == False\n assert candidate(n = 32768) == True\n assert candidate(n = 4104) == False\n assert candidate(n = 123456789) == False\n assert candidate(n = 555555) == False\n assert candidate(n = 4608) == False\n assert candidate(n = 8388608) == True\n", "comparison": "exact"}, "public_tests": ["1", "10"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().reorderedPowerOf2", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:32+00:00", "tests_total": 87, "tests_dropped": 8, "flags": [], "topic_tags": ["hash-table", "math", "sorting", "counting", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def reorderedPowerOf2(self, n: int) -> bool:", "container": "Solution", "callable": "reorderedPowerOf2", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 870, "task_id": "advantage-shuffle", "difficulty": "Medium", "problem_description": "You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i].\n\nReturn any permutation of nums1 that maximizes its advantage with respect to nums2.\n\nExample 1:\n\nInput: nums1 = [2,7,11,15], nums2 = [1,10,4,11]\nOutput: [2,11,7,15]\n\nExample 2:\n\nInput: nums1 = [12,24,8,32], nums2 = [13,25,32,11]\nOutput: [24,32,8,12]\n\nConstraints:\n\n- 1 <= nums1.length <= 10^5\n- nums2.length == nums1.length\n- 0 <= nums1[i], nums2[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == [10, 20, 30, 40, 50]\n assert candidate(nums1 = [5, 15, 25, 35],nums2 = [10, 20, 30, 40]) == [15, 25, 35, 5]\n assert candidate(nums1 = [2, 7, 11, 15],nums2 = [1, 10, 4, 11]) == [2, 11, 7, 15]\n assert candidate(nums1 = [100, 90, 80, 70, 60],nums2 = [60, 70, 80, 90, 100]) == [70, 80, 90, 100, 60]\n assert candidate(nums1 = [9, 12, 24, 22, 15],nums2 = [14, 13, 25, 17, 22]) == [22, 15, 9, 24, 12]\n assert candidate(nums1 = [5, 6, 7, 8, 9],nums2 = [1, 2, 3, 4, 5]) == [5, 6, 7, 8, 9]\n assert candidate(nums1 = [5, 6, 7, 8],nums2 = [4, 5, 6, 7]) == [5, 6, 7, 8]\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [50, 150, 250, 350]) == [100, 200, 300, 400]\n assert candidate(nums1 = [12, 24, 8, 32],nums2 = [13, 25, 32, 11]) == [24, 32, 8, 12]\n assert candidate(nums1 = [10, 10, 10, 10],nums2 = [1, 1, 1, 1]) == [10, 10, 10, 10]\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [1, 2, 3, 4]) == [2, 3, 4, 1]\n assert candidate(nums1 = [100, 90, 80, 70],nums2 = [60, 70, 80, 90]) == [70, 80, 90, 100]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == [1, 5, 4, 3, 2]\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [4, 3, 2, 1]) == [1, 4, 3, 2]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [9, 8, 7, 6, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [5, 6, 7, 8],nums2 = [1, 2, 3, 4]) == [5, 6, 7, 8]\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [5, 6, 7, 8]) == [4, 3, 2, 1]\n assert candidate(nums1 = [8, 24, 15, 3, 17, 22],nums2 = [25, 18, 9, 13, 22, 6]) == [3, 22, 15, 17, 24, 8]\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [450, 350, 250, 150, 50]) == [500, 400, 300, 200, 100]\n assert candidate(nums1 = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9],nums2 = [9, 7, 5, 3, 1, 0, 2, 4, 6, 8]) == [0, 8, 6, 4, 2, 1, 3, 5, 7, 9]\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],nums2 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == [1000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000]\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 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]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [105, 205, 305, 405, 505, 605, 705, 805, 905, 1005]) == [200, 300, 400, 500, 600, 700, 800, 900, 1000, 100]\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, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(nums1 = [47, 29, 22, 18, 4, 37, 30, 25, 36, 42, 3, 20, 5, 11, 13, 27, 8, 2, 24, 17],nums2 = [16, 33, 12, 38, 34, 19, 35, 32, 46, 31, 45, 40, 28, 43, 39, 44, 26, 23, 14, 41]) == [18, 42, 13, 25, 47, 20, 30, 37, 2, 36, 3, 11, 29, 5, 22, 4, 27, 24, 17, 8]\n assert candidate(nums1 = [20, 17, 13, 8, 15, 11, 10, 9],nums2 = [18, 16, 14, 12, 10, 9, 8, 7]) == [20, 17, 15, 13, 11, 10, 9, 8]\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],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]) == [1, 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(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums1 = [8, 11, 13, 18, 12, 14, 10, 17, 15, 16],nums2 = [9, 11, 10, 13, 12, 15, 14, 17, 18, 16]) == [10, 12, 11, 14, 13, 16, 15, 18, 8, 17]\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56],nums2 = [8, 16, 24, 32, 40, 48, 54, 60]) == [14, 21, 28, 35, 42, 49, 56, 7]\n assert candidate(nums1 = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],nums2 = [999999992, 999999995, 999999991, 999999998, 999999997, 999999994, 999999993, 999999996, 1000000000, 999999999]) == [999999993, 999999996, 999999992, 999999999, 999999998, 999999995, 999999994, 999999997, 999999991, 1000000000]\n assert candidate(nums1 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],nums2 = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 15, 13, 11, 9, 7, 5, 3, 1]) == [3, 5, 7, 9, 11, 13, 15, 1, 14, 12, 10, 8, 6, 4, 2]\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]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 1]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(nums1 = [3, 6, 7, 8, 13, 22, 24, 45, 50, 60],nums2 = [9, 12, 25, 32, 35, 40, 46, 51, 61, 62]) == [13, 22, 45, 50, 60, 24, 8, 7, 6, 3]\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [45, 35, 25, 15, 5]) == [50, 40, 30, 20, 10]\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [5000, 500, 50, 5, 50000]) == [10000, 1000, 100, 10, 1]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums1 = [100, 50, 75, 25, 60, 90],nums2 = [55, 80, 65, 40, 95, 30]) == [75, 100, 90, 60, 25, 50]\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [1, 2, 3, 4, 5]) == [10, 20, 30, 40, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [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, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\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, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(nums1 = [1000000000, 999999999, 999999998, 999999997, 999999996],nums2 = [999999995, 999999994, 999999993, 999999992, 999999991]) == [1000000000, 999999999, 999999998, 999999997, 999999996]\n assert candidate(nums1 = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],nums2 = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums1 = [5, 21, 17, 13, 29, 3, 19, 11],nums2 = [6, 25, 18, 14, 28, 4, 20, 12]) == [11, 29, 19, 17, 3, 5, 21, 13]\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]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]\n assert candidate(nums1 = [5, 21, 17, 19, 13, 25, 18],nums2 = [10, 15, 20, 24, 22, 21, 19]) == [13, 17, 25, 5, 18, 19, 21]\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums2 = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]) == [15, 25, 35, 45, 55, 65, 75, 85, 95, 5]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [950, 850, 750, 650, 550, 450, 350, 250, 150, 50]) == [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 9, 10, 10],nums2 = [10, 10, 9, 9, 8, 7, 6, 5, 5, 5, 4, 3, 2, 2, 1]) == [2, 1, 10, 5, 10, 9, 9, 6, 7, 8, 5, 5, 3, 4, 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 = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 1, 20]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == [200, 300, 400, 500, 600, 700, 800, 900, 1000, 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]) == [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(nums1 = [2, 2, 2, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13],nums2 = [1, 3, 4, 4, 6, 8, 9, 10, 10, 12, 12, 14, 15, 16, 17]) == [2, 5, 5, 5, 7, 11, 11, 11, 13, 13, 13, 7, 7, 2, 2]\n assert candidate(nums1 = [5, 3, 8, 9, 1, 7, 6, 2, 4, 10],nums2 = [8, 7, 6, 5, 4, 3, 2, 1, 10, 9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]\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]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 1]\n assert candidate(nums1 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],nums2 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],nums2 = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1099, 1199, 1299, 1399, 1499]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]\n assert candidate(nums1 = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],nums2 = [999999990, 999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999]) == [999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999, 999999990]\n assert candidate(nums1 = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],nums2 = [119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100]) == [100, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101]\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]) == [10, 100, 90, 80, 70, 60, 50, 40, 30, 20]\n assert candidate(nums1 = [25, 15, 35, 5, 45, 10, 55, 20, 65, 30],nums2 = [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == [25, 30, 35, 45, 55, 65, 20, 15, 10, 5]\n assert candidate(nums1 = [23, 34, 45, 56, 67, 78, 89, 90, 101, 112],nums2 = [12, 23, 34, 45, 56, 67, 78, 89, 90, 101]) == [23, 34, 45, 56, 67, 78, 89, 90, 101, 112]\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]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\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, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]) == [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],nums2 = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(nums1 = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],nums2 = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums1 = [3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2]) == [3, 3, 3, 3, 3]\n assert candidate(nums1 = [3, 10, 7, 8, 9, 5, 2, 1, 4, 6],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(nums1 = [29, 14, 37, 18, 25, 19, 40, 32],nums2 = [26, 35, 33, 28, 31, 17, 41, 16]) == [29, 25, 40, 32, 37, 19, 14, 18]\n assert candidate(nums1 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 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, 1]\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [3, 2, 6, 4, 1, 9, 7, 8, 5, 10]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1]\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [6, 7, 8, 8, 9, 10, 10, 11, 5, 5, 4, 3, 2, 2, 1]\n assert candidate(nums1 = [8, 5, 12, 19, 22, 31, 42, 55, 60, 65],nums2 = [10, 9, 20, 21, 30, 35, 50, 54, 56, 61]) == [19, 12, 22, 31, 42, 55, 60, 65, 8, 5]\n assert candidate(nums1 = [41, 39, 33, 21, 32, 30, 25, 14, 17, 13, 27, 22, 15, 20, 26],nums2 = [24, 7, 29, 38, 5, 44, 3, 12, 10, 22, 13, 26, 23, 46, 6]) == [27, 17, 32, 39, 14, 41, 13, 21, 20, 25, 22, 30, 26, 33, 15]\n assert candidate(nums1 = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [999999991, 999999992, 999999993, 999999994, 999999995, 999999996, 999999997, 999999998, 999999999, 1000000000]\n assert candidate(nums1 = [5, 14, 13, 21, 24, 17, 8, 16],nums2 = [18, 20, 19, 16, 15, 14, 13, 12]) == [24, 5, 8, 21, 17, 16, 14, 13]\n assert candidate(nums1 = [5, 23, 15, 32, 6, 9, 18, 20],nums2 = [17, 30, 25, 16, 10, 2, 19, 8]) == [20, 6, 32, 18, 15, 5, 23, 9]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],nums2 = [1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]) == [10, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20]\n assert candidate(nums1 = [3, 5, 8, 2, 1, 9, 7, 4, 6],nums2 = [6, 7, 8, 2, 1, 5, 4, 3, 9]) == [7, 8, 9, 3, 2, 6, 5, 4, 1]\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [18, 27, 36, 45, 54, 63, 72, 81, 99, 108, 117, 126, 135, 90, 9]\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [500, 400, 300, 200, 100, 1100, 900, 800, 700, 600]) == [600, 500, 400, 300, 200, 100, 1000, 900, 800, 700]\n assert candidate(nums1 = [1000000000, 500000000, 750000000, 250000000, 600000000, 900000000],nums2 = [550000000, 800000000, 650000000, 400000000, 950000000, 300000000]) == [750000000, 1000000000, 900000000, 600000000, 250000000, 500000000]\n assert candidate(nums1 = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],nums2 = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [4, 2, 5, 3, 6, 1, 3, 1, 9, 5, 5]\n assert candidate(nums1 = [7, 5, 6, 4, 3, 8, 2, 9, 1, 10],nums2 = [6, 7, 8, 5, 4, 9, 3, 10, 1, 2]) == [7, 8, 9, 6, 5, 10, 4, 1, 2, 3]\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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(nums1 = [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],nums2 = [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]) == [6, 12, 18, 21, 27, 33, 36, 42, 48, 51, 57, 63, 66, 72, 75, 69, 60, 54, 45, 39, 30, 24, 15, 9, 3]\n", "comparison": "exact"}, "public_tests": ["[2,7,11,15]\n[1,10,4,11]", "[12,24,8,32]\n[13,25,32,11]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().advantageCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:34+00:00", "tests_total": 100, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def advantageCount(self, nums1: list[int], nums2: list[int]) -> list[int]:", "container": "Solution", "callable": "advantageCount", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 871, "task_id": "minimum-number-of-refueling-stops", "difficulty": "Hard", "problem_description": "A car travels from a starting position to a destination which is target miles east of the starting position.\n\nThere are gas stations along the way. The gas stations are represented as an array stations where stations[i] = [position_i, fuel_i] indicates that the i^th gas station is position_i miles east of the starting position and has fuel_i liters of gas.\n\nThe car starts with an infinite tank of gas, which initially has startFuel liters of fuel in it. It uses one liter of gas per one mile that it drives. When the car reaches a gas station, it may stop and refuel, transferring all the gas from the station into the car.\n\nReturn the minimum number of refueling stops the car must make in order to reach its destination. If it cannot reach the destination, return -1.\n\nNote that if the car reaches a gas station with 0 fuel left, the car can still refuel there. If the car reaches the destination with 0 fuel left, it is still considered to have arrived.\n\nExample 1:\n\nInput: target = 1, startFuel = 1, stations = []\nOutput: 0\nExplanation: We can reach the target without refueling.\n\nExample 2:\n\nInput: target = 100, startFuel = 1, stations = [[10,100]]\nOutput: -1\nExplanation: We can not reach the target (or even the first gas station).\n\nExample 3:\n\nInput: target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]]\nOutput: 2\nExplanation: We start with 10 liters of fuel.\nWe drive to position 10, expending 10 liters of fuel. We refuel from 0 liters to 60 liters of gas.\nThen, we drive from position 10 to position 60 (expending 50 liters of fuel),\nand refuel from 10 liters to 50 liters of gas. We then drive to and reach the target.\nWe made 2 refueling stops along the way, so we return 2.\n\nConstraints:\n\n- 1 <= target, startFuel <= 10^9\n- 0 <= stations.length <= 500\n- 1 <= position_i < position_{i+1} < target\n- 1 <= fuel_i < 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = 100,startFuel = 100,stations = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 0\n assert candidate(target = 150,startFuel = 50,stations = [[25, 25], [50, 50], [75, 25]]) == 3\n assert candidate(target = 150,startFuel = 50,stations = [[10, 60], [20, 30], [30, 30], [60, 40], [80, 50]]) == 2\n assert candidate(target = 1,startFuel = 1,stations = []) == 0\n assert candidate(target = 100,startFuel = 1,stations = [[10, 100]]) == -1\n assert candidate(target = 100,startFuel = 10,stations = [[10, 60], [20, 30], [30, 30], [60, 40]]) == 2\n assert candidate(target = 150,startFuel = 50,stations = [[25, 25], [50, 25], [75, 50], [100, 100]]) == 3\n assert candidate(target = 1000,startFuel = 500,stations = [[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100]]) == 5\n assert candidate(target = 100,startFuel = 50,stations = [[25, 25], [50, 25], [75, 25]]) == 2\n assert candidate(target = 50,startFuel = 1,stations = [[10, 10], [20, 20], [30, 30], [40, 40]]) == -1\n assert candidate(target = 200,startFuel = 25,stations = [[10, 60], [20, 30], [30, 30], [60, 40], [80, 50], [100, 25]]) == 4\n assert candidate(target = 50,startFuel = 50,stations = [[10, 20], [20, 30], [30, 40], [40, 50]]) == 0\n assert candidate(target = 150,startFuel = 50,stations = [[10, 20], [30, 50], [50, 10], [60, 20], [80, 30], [110, 40]]) == 3\n assert candidate(target = 75,startFuel = 25,stations = [[20, 20], [30, 30], [50, 10], [60, 20]]) == 2\n assert candidate(target = 300,startFuel = 50,stations = [[50, 150], [100, 150], [150, 150], [200, 150], [250, 150]]) == 2\n assert candidate(target = 500,startFuel = 100,stations = [[25, 10], [50, 20], [75, 30], [100, 40], [125, 50], [150, 60]]) == -1\n assert candidate(target = 1200,startFuel = 200,stations = [[100, 50], [200, 100], [300, 150], [400, 200], [500, 250], [600, 300], [700, 350], [800, 400], [900, 450], [1000, 500]]) == 5\n assert candidate(target = 500,startFuel = 50,stations = [[50, 50], [100, 100], [150, 50], [200, 150], [250, 50], [300, 50], [350, 50], [400, 50], [450, 50]]) == 6\n assert candidate(target = 200,startFuel = 50,stations = [[25, 30], [50, 50], [75, 20], [100, 100], [150, 50]]) == 2\n assert candidate(target = 500,startFuel = 100,stations = [[25, 100], [100, 50], [150, 150], [300, 100], [400, 200]]) == 4\n assert candidate(target = 1500,startFuel = 500,stations = [[100, 50], [200, 100], [300, 200], [400, 250], [500, 300], [600, 400], [700, 350], [800, 400], [900, 300], [1000, 200], [1100, 150], [1200, 100], [1300, 50], [1400, 250]]) == 3\n assert candidate(target = 1000,startFuel = 300,stations = [[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100]]) == 7\n assert candidate(target = 1000,startFuel = 1,stations = [[10, 100], [20, 150], [30, 200], [40, 50], [50, 50], [60, 50], [70, 50], [80, 50], [90, 50], [100, 50], [110, 50], [120, 50], [130, 50], [140, 50], [150, 50], [160, 50], [170, 50], [180, 50], [190, 50], [200, 50]]) == -1\n assert candidate(target = 500,startFuel = 200,stations = [[150, 50], [250, 100], [350, 100], [450, 150]]) == 4\n assert candidate(target = 350,startFuel = 20,stations = [[20, 100], [40, 80], [60, 70], [80, 60], [100, 50], [120, 40], [140, 30], [160, 20], [180, 10]]) == 5\n assert candidate(target = 600,startFuel = 100,stations = [[20, 50], [40, 100], [60, 150], [80, 200], [100, 250], [120, 300], [140, 350], [160, 400], [180, 450], [200, 500], [220, 550], [240, 600], [260, 650], [280, 700], [300, 750], [320, 800], [340, 850], [360, 900], [380, 950], [400, 1000], [420, 1050], [440, 1100], [460, 1150], [480, 1200], [500, 1250], [520, 1300], [540, 1350], [560, 1400], [580, 1450]]) == 2\n assert candidate(target = 1000,startFuel = 100,stations = [[100, 200], [200, 150], [300, 50], [400, 100], [500, 250], [600, 100], [700, 200], [800, 50], [900, 100]]) == 5\n assert candidate(target = 1000,startFuel = 300,stations = [[50, 100], [150, 50], [250, 200], [350, 100], [450, 150], [550, 50], [650, 200], [750, 100], [850, 150], [950, 50]]) == 4\n assert candidate(target = 150,startFuel = 100,stations = [[50, 30], [100, 20]]) == 2\n assert candidate(target = 500,startFuel = 100,stations = [[100, 150], [200, 100], [300, 100], [400, 200]]) == 4\n assert candidate(target = 600,startFuel = 100,stations = [[150, 50], [250, 100], [450, 150], [550, 100]]) == -1\n assert candidate(target = 1200,startFuel = 50,stations = [[50, 100], [100, 200], [150, 150], [200, 100], [250, 50], [300, 200], [350, 150], [400, 100], [450, 50], [500, 200], [550, 100], [600, 150], [650, 200], [700, 50], [750, 200], [800, 100], [850, 150], [900, 200], [950, 50], [1000, 200], [1050, 150], [1100, 100]]) == 7\n assert candidate(target = 600,startFuel = 200,stations = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 500]]) == 2\n assert candidate(target = 200,startFuel = 100,stations = [[50, 50], [100, 100], [150, 100], [180, 50]]) == 1\n assert candidate(target = 1000,startFuel = 500,stations = [[200, 100], [300, 150], [500, 200], [600, 300]]) == 2\n assert candidate(target = 300,startFuel = 20,stations = [[10, 40], [20, 30], [30, 50], [40, 20], [50, 60], [60, 10], [70, 70], [80, 25], [90, 25], [100, 20], [110, 20], [120, 20], [130, 20], [140, 20], [150, 20], [160, 20], [170, 20], [180, 20], [190, 20], [200, 20], [210, 20], [220, 20], [230, 20], [240, 20], [250, 20], [260, 20], [270, 20], [280, 20], [290, 20]]) == 7\n assert candidate(target = 1000,startFuel = 500,stations = [[150, 300], [300, 250], [700, 150]]) == 2\n assert candidate(target = 750,startFuel = 250,stations = [[100, 50], [200, 150], [300, 100], [400, 50], [500, 200], [600, 300], [700, 100]]) == 4\n assert candidate(target = 1000,startFuel = 150,stations = [[100, 50], [200, 100], [300, 200], [400, 300], [500, 400], [600, 500], [700, 600], [800, 700], [900, 800]]) == 5\n assert candidate(target = 300,startFuel = 100,stations = [[10, 60], [50, 50], [100, 40], [150, 30], [200, 20], [250, 10]]) == 5\n assert candidate(target = 1000,startFuel = 200,stations = [[50, 100], [150, 100], [250, 100], [350, 100], [450, 100], [550, 100], [650, 100], [750, 100], [850, 100], [950, 100]]) == 8\n assert candidate(target = 150,startFuel = 10,stations = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 3\n assert candidate(target = 450,startFuel = 100,stations = [[20, 100], [40, 120], [60, 140], [80, 160], [100, 180], [120, 200], [140, 220], [160, 240], [180, 260], [200, 280], [220, 300], [240, 320], [260, 340], [280, 360], [300, 380], [320, 400], [340, 420], [360, 440]]) == 2\n assert candidate(target = 400,startFuel = 20,stations = [[10, 30], [30, 40], [50, 50], [70, 60], [90, 70], [110, 80], [130, 90], [150, 100], [170, 110], [190, 120]]) == 5\n assert candidate(target = 600,startFuel = 200,stations = [[50, 10], [100, 10], [150, 10], [200, 10], [250, 10], [300, 10], [350, 10], [400, 10], [450, 10], [500, 10], [550, 400]]) == -1\n assert candidate(target = 1000,startFuel = 500,stations = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950]]) == 1\n assert candidate(target = 500,startFuel = 150,stations = [[50, 50], [150, 200], [250, 100], [350, 50], [450, 30]]) == 3\n assert candidate(target = 1000,startFuel = 1000,stations = [[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100]]) == 0\n assert candidate(target = 300,startFuel = 40,stations = [[20, 100], [40, 50], [60, 30], [100, 20], [150, 50], [250, 75]]) == 5\n assert candidate(target = 700,startFuel = 100,stations = [[100, 50], [200, 75], [300, 100], [400, 125], [500, 150], [600, 175]]) == -1\n assert candidate(target = 500,startFuel = 100,stations = [[100, 100], [200, 100], [300, 100], [400, 100]]) == 4\n assert candidate(target = 500,startFuel = 25,stations = [[25, 25], [50, 50], [75, 75], [100, 100], [125, 125], [150, 150], [175, 175], [200, 200], [225, 225], [250, 250], [275, 275], [300, 300], [325, 325], [350, 350], [375, 375], [400, 400], [425, 425], [450, 450], [475, 475]]) == 5\n assert candidate(target = 600,startFuel = 100,stations = [[50, 100], [150, 100], [250, 100], [350, 100], [450, 100], [550, 100]]) == 5\n assert candidate(target = 1000,startFuel = 1,stations = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900]]) == -1\n assert candidate(target = 200,startFuel = 50,stations = [[25, 30], [50, 10], [75, 20], [100, 50], [150, 40]]) == 5\n assert candidate(target = 1500,startFuel = 400,stations = [[200, 100], [300, 200], [500, 150], [700, 50], [1200, 300], [1400, 100]]) == -1\n assert candidate(target = 800,startFuel = 200,stations = [[150, 80], [300, 100], [450, 120], [600, 140], [750, 160]]) == -1\n assert candidate(target = 1500,startFuel = 100,stations = [[100, 300], [200, 200], [300, 100], [400, 50], [500, 200], [600, 300], [700, 150], [800, 200], [900, 50], [1000, 300], [1100, 200], [1200, 150], [1300, 100], [1400, 50]]) == 6\n assert candidate(target = 200,startFuel = 100,stations = [[50, 50], [100, 50], [150, 50], [175, 25]]) == 2\n assert candidate(target = 500,startFuel = 250,stations = [[100, 100], [200, 150], [300, 200]]) == 2\n assert candidate(target = 1000,startFuel = 100,stations = [[100, 200], [200, 150], [300, 100], [400, 250], [500, 200]]) == 5\n assert candidate(target = 1000,startFuel = 200,stations = [[100, 100], [200, 150], [300, 200], [400, 250], [500, 300], [600, 400]]) == 4\n assert candidate(target = 400,startFuel = 30,stations = [[20, 10], [30, 20], [40, 30], [50, 40], [60, 50], [70, 60], [80, 70], [90, 80], [100, 90]]) == 7\n assert candidate(target = 2000,startFuel = 200,stations = [[100, 150], [200, 100], [300, 50], [400, 200], [500, 250], [600, 150], [700, 100], [800, 200], [900, 250], [1000, 150], [1100, 100], [1200, 200], [1300, 250], [1400, 150], [1500, 100], [1600, 200], [1700, 250], [1800, 150], [1900, 100]]) == 9\n assert candidate(target = 1500,startFuel = 300,stations = [[100, 100], [200, 150], [300, 200], [400, 250], [500, 300], [600, 350], [700, 400], [800, 450], [900, 500]]) == 4\n assert candidate(target = 1200,startFuel = 50,stations = [[50, 50], [150, 50], [250, 50], [350, 50], [450, 50], [550, 50], [650, 50], [750, 50], [850, 50], [950, 50], [1050, 50], [1150, 50]]) == -1\n assert candidate(target = 1000,startFuel = 100,stations = [[100, 200], [200, 100], [300, 50], [400, 300], [500, 200], [600, 100], [700, 500], [800, 100], [900, 100]]) == 4\n assert candidate(target = 1500,startFuel = 400,stations = [[300, 300], [600, 300], [900, 300], [1200, 300]]) == 4\n assert candidate(target = 250,startFuel = 50,stations = [[20, 40], [40, 40], [60, 30], [80, 20], [100, 50], [150, 30], [200, 20]]) == 6\n assert candidate(target = 1000,startFuel = 100,stations = [[50, 30], [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, 750], [850, 800], [900, 850], [950, 900]]) == 5\n assert candidate(target = 3000,startFuel = 250,stations = [[100, 100], [200, 150], [300, 200], [400, 250], [500, 300], [600, 350], [700, 400], [800, 450], [900, 500], [1000, 550], [1100, 600], [1200, 650], [1300, 700], [1400, 750], [1500, 800], [1600, 850], [1700, 900], [1800, 950], [1900, 1000], [2000, 1050], [2100, 1100], [2200, 1150], [2300, 1200], [2400, 1250], [2500, 1300], [2600, 1350], [2700, 1400], [2800, 1450], [2900, 1500]]) == 6\n assert candidate(target = 1200,startFuel = 200,stations = [[200, 300], [400, 200], [600, 400], [800, 100], [1000, 200]]) == 4\n assert candidate(target = 2000,startFuel = 300,stations = [[100, 500], [300, 500], [500, 500], [700, 500], [900, 500], [1100, 500], [1300, 500], [1500, 500], [1700, 500], [1900, 500]]) == 4\n assert candidate(target = 500,startFuel = 10,stations = [[10, 50], [20, 100], [30, 50], [40, 30], [50, 40], [60, 50], [70, 100], [80, 40], [90, 10], [100, 200]]) == 5\n assert candidate(target = 800,startFuel = 400,stations = [[100, 100], [200, 150], [300, 100], [400, 50], [500, 300], [600, 200], [700, 100]]) == 2\n assert candidate(target = 150,startFuel = 50,stations = [[10, 20], [30, 30], [50, 50], [100, 100]]) == 2\n assert candidate(target = 2000,startFuel = 100,stations = [[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]]) == 19\n assert candidate(target = 500,startFuel = 100,stations = [[50, 200], [100, 50], [150, 150], [200, 100], [300, 200], [400, 150]]) == 2\n assert candidate(target = 1000,startFuel = 50,stations = [[50, 200], [150, 150], [250, 100], [350, 50], [450, 200], [550, 100], [650, 150], [750, 100], [850, 50], [950, 200]]) == 7\n assert candidate(target = 1000,startFuel = 500,stations = [[100, 200], [300, 300], [450, 250], [600, 400], [800, 100]]) == 2\n assert candidate(target = 1000,startFuel = 500,stations = [[200, 100], [300, 150], [400, 50], [800, 200]]) == 4\n assert candidate(target = 800,startFuel = 100,stations = [[100, 50], [200, 50], [300, 50], [400, 50], [500, 50], [600, 50], [700, 50]]) == -1\n assert candidate(target = 100,startFuel = 90,stations = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10]]) == 1\n assert candidate(target = 2500,startFuel = 500,stations = [[100, 200], [200, 100], [300, 150], [400, 100], [500, 150], [600, 200], [700, 250], [800, 300], [900, 350], [1000, 400], [1100, 450], [1200, 500], [1300, 550], [1400, 600], [1500, 650], [1600, 700], [1700, 750], [1800, 800], [1900, 850], [2000, 900], [2100, 950], [2200, 1000], [2300, 1050], [2400, 1100]]) == 5\n assert candidate(target = 400,startFuel = 20,stations = [[20, 50], [40, 60], [60, 70], [80, 80], [100, 90], [120, 100], [140, 110], [160, 120], [180, 130]]) == 5\n assert candidate(target = 2000,startFuel = 100,stations = [[100, 150], [200, 200], [300, 100], [400, 50], [500, 300], [600, 250], [700, 150], [800, 200], [900, 100], [1000, 150], [1100, 200], [1200, 50], [1300, 250], [1400, 150], [1500, 50], [1600, 100], [1700, 200], [1800, 150], [1900, 50]]) == 10\n assert candidate(target = 200,startFuel = 10,stations = [[10, 60], [40, 20], [70, 10], [150, 50]]) == -1\n assert candidate(target = 100,startFuel = 25,stations = [[10, 20], [20, 10], [30, 10], [60, 50]]) == 4\n assert candidate(target = 600,startFuel = 150,stations = [[50, 250], [100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [350, 100], [400, 100], [450, 100], [500, 100]]) == 3\n assert candidate(target = 300,startFuel = 100,stations = [[50, 50], [100, 30], [150, 70], [200, 20], [250, 30]]) == 5\n assert candidate(target = 600,startFuel = 150,stations = [[150, 200], [200, 250], [300, 300], [400, 350], [500, 400]]) == 2\n assert candidate(target = 500,startFuel = 100,stations = [[50, 100], [150, 100], [250, 50], [350, 50], [450, 50]]) == -1\n", "comparison": "exact"}, "public_tests": ["1\n1\n[]", "100\n1\n[[10,100]]", "100\n10\n[[10,60],[20,30],[30,30],[60,40]]"], "hints": [], "metadata": {"canonical_parameter_names": ["target", "startFuel", "stations"], "leetcode_dataset_entry_point": "Solution().minRefuelStops", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:36+00:00", "tests_total": 96, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "dynamic-programming", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def minRefuelStops(self, target: int, startFuel: int, stations: list[list[int]]) -> int:", "container": "Solution", "callable": "minRefuelStops", "parameters": [{"name": "target", "type": "int"}, {"name": "startFuel", "type": "int"}, {"name": "stations", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 873, "task_id": "length-of-longest-fibonacci-subsequence", "difficulty": "Medium", "problem_description": "A sequence x_1, x_2, ..., x_n is Fibonacci-like if:\n\n- n >= 3\n- x_i + x_{i+1} == x_{i+2} for all i + 2 <= n\n\nGiven a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence of arr. If one does not exist, return 0.\n\nA subsequence is derived from another sequence arr by deleting any number of elements (including none) from arr, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].\n\nExample 1:\n\nInput: arr = [1,2,3,4,5,6,7,8]\nOutput: 5\nExplanation: The longest subsequence that is fibonacci-like: [1,2,3,5,8].\n\nExample 2:\n\nInput: arr = [1,3,7,11,12,14,18]\nOutput: 3\nExplanation: The longest subsequence that is fibonacci-like: [1,11,12], [3,11,14] or [7,11,18].\n\nConstraints:\n\n- 3 <= arr.length <= 1000\n- 1 <= arr[i] < arr[i + 1] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 6, 9, 13, 19, 28, 41, 60, 88]) == 3\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 20\n assert candidate(arr = [2, 4, 7, 11, 18, 29, 47, 76]) == 7\n assert candidate(arr = [1, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8]) == 5\n assert candidate(arr = [1, 4, 5, 6, 8, 10, 13, 21]) == 4\n assert candidate(arr = [2, 4, 5, 6, 7, 8, 10, 13, 21]) == 4\n assert candidate(arr = [2, 4, 7, 8, 9, 10, 14, 15, 21, 25, 30]) == 3\n assert candidate(arr = [1, 5, 6, 7, 10, 13, 19, 26, 42]) == 4\n assert candidate(arr = [1, 2, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) == 10\n assert candidate(arr = [1, 3, 7, 11, 12, 14, 18]) == 3\n assert candidate(arr = [2, 4, 7, 8, 10, 14, 22, 39]) == 3\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 3\n assert candidate(arr = [1, 3, 4, 7, 11, 18, 29, 47, 76, 123]) == 10\n assert candidate(arr = [1, 2, 4, 8, 13, 21, 34]) == 4\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21]) == 7\n assert candidate(arr = [1, 2, 4, 7, 11, 18, 29]) == 5\n assert candidate(arr = [1, 2, 6, 7, 13, 20, 33, 54, 87, 141, 228, 369, 597, 966, 1563, 2529, 4092, 6621, 10713, 17334]) == 14\n assert candidate(arr = [1, 4, 7, 13, 20, 33, 54, 87]) == 4\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55]) == 9\n assert candidate(arr = [1, 9, 10, 11, 12, 13, 14, 15]) == 3\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 4\n assert candidate(arr = [1, 2, 5, 13, 34, 89, 233, 610, 1597, 4181, 10946]) == 0\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 30, 54, 84, 144, 228, 372, 600, 972, 1572, 2544, 4116, 6660, 10776, 17436]) == 12\n assert candidate(arr = [1, 5, 6, 11, 17, 28, 45, 73, 118, 191, 309, 500, 809]) == 13\n assert candidate(arr = [3, 8, 11, 19, 30, 49, 79, 128, 207, 335, 542, 877, 1419, 2296, 3715, 6011, 9726, 15737, 25453, 41190]) == 18\n assert candidate(arr = [4, 6, 10, 16, 26, 42, 68, 110, 178, 288, 466, 754]) == 12\n assert candidate(arr = [1, 8, 9, 17, 25, 32, 47, 63, 82, 105, 140, 185, 248]) == 4\n assert candidate(arr = [1, 3, 5, 6, 8, 9, 10, 12, 13, 15, 18, 21, 24, 27, 30, 33, 36, 40, 45, 48]) == 5\n assert candidate(arr = [1, 4, 6, 9, 10, 11, 12, 15, 16, 17, 20, 21, 22, 25, 28, 30, 32, 35, 38, 41]) == 5\n assert candidate(arr = [1, 5, 6, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == 18\n assert candidate(arr = [10, 13, 23, 36, 59, 95, 154, 249, 403, 652, 1055, 1707]) == 12\n assert candidate(arr = [1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199]) == 11\n assert candidate(arr = [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]) == 7\n assert candidate(arr = [5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == 18\n assert candidate(arr = [1, 4, 5, 9, 13, 22, 35, 57, 92, 149, 241, 390]) == 10\n assert candidate(arr = [2, 5, 7, 12, 19, 31, 50, 81, 131, 212, 343, 555, 898, 1453, 2351, 3804]) == 16\n assert candidate(arr = [1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843]) == 14\n assert candidate(arr = [3, 7, 10, 17, 27, 44, 71, 115, 186, 301, 487, 788]) == 12\n assert candidate(arr = [5, 11, 16, 27, 43, 70, 113, 183, 296, 479, 772, 1251, 2033]) == 10\n assert candidate(arr = [2, 9, 11, 20, 31, 51, 82, 133, 215, 348, 563, 911, 1474, 2385, 3859, 6234, 10113, 16367, 26480, 42847, 69227]) == 15\n assert candidate(arr = [3, 6, 9, 15, 24, 39, 63, 102, 165, 267]) == 10\n assert candidate(arr = [1, 2, 4, 5, 8, 9, 12, 13, 16, 18, 21, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68]) == 4\n assert candidate(arr = [3, 10, 13, 23, 36, 59, 92, 151, 243, 394, 637, 1030, 1667, 2697, 4324, 7021, 11348, 18379, 29727, 48076]) == 6\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == 20\n assert candidate(arr = [1, 4, 5, 9, 13, 22, 35, 57, 92, 149, 241, 390, 631, 1021, 1652, 2673, 4325, 7008, 11343, 18361]) == 15\n assert candidate(arr = [5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368]) == 20\n assert candidate(arr = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]) == 0\n assert candidate(arr = [1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364]) == 15\n assert candidate(arr = [5, 9, 14, 23, 37, 60, 97, 157, 254, 411]) == 10\n assert candidate(arr = [2, 7, 9, 16, 25, 41, 66, 107, 173, 280, 453, 733, 1186, 1919, 3102]) == 14\n assert candidate(arr = [2, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 13\n assert candidate(arr = [1, 4, 5, 7, 11, 18, 29, 47, 76, 123, 199]) == 9\n assert candidate(arr = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 0\n assert candidate(arr = [5, 9, 14, 23, 37, 60, 97, 157, 254, 411, 665, 1076, 1741, 2817, 4558, 7375, 11933, 19308]) == 18\n assert candidate(arr = [1, 4, 6, 7, 9, 11, 16, 25, 41, 66, 107, 173, 280]) == 9\n assert candidate(arr = [7, 12, 19, 31, 50, 81, 131, 212, 343, 555, 898, 1453, 2351, 3804, 6155, 9959, 16064, 26023, 42083, 68106, 110189, 178292, 288481, 466773, 755254, 1224027, 1979281, 3204308, 5183589, 8382897, 13566496, 21949493, 35536090, 57485583]) == 16\n assert candidate(arr = [1, 4, 5, 7, 11, 18, 29, 47, 76, 123, 199, 322]) == 10\n assert candidate(arr = [1, 7, 12, 18, 25, 33, 42, 51, 61, 72, 84, 97, 111, 126, 142, 159, 177, 196, 216, 237, 259, 282, 306, 331, 357]) == 4\n assert candidate(arr = [1, 4, 5, 7, 12, 17, 29, 46, 75, 121]) == 7\n assert candidate(arr = [1, 2, 6, 9, 15, 24, 41, 65, 106, 171, 277, 448, 725, 1173, 1901, 3076]) == 9\n assert candidate(arr = [2, 8, 10, 18, 28, 46, 74, 120, 194, 314, 508, 822, 1330, 2152, 3482, 5634, 9086, 14718, 23804, 38522]) == 16\n assert candidate(arr = [2, 11, 26, 47, 74, 107, 146, 189, 238, 293, 354, 421, 494, 573, 658, 749, 846, 949, 1058, 1173, 1294, 1421, 1554, 1693]) == 0\n assert candidate(arr = [2, 5, 7, 12, 19, 31, 50, 81, 131, 212, 343]) == 11\n assert candidate(arr = [1, 5, 6, 7, 12, 13, 19, 21, 34, 55, 89]) == 5\n assert candidate(arr = [3, 7, 10, 17, 27, 44, 71, 115, 186, 301, 487, 788, 1275, 2063]) == 14\n assert candidate(arr = [1, 4, 5, 6, 8, 9, 11, 15, 17, 20, 23, 27, 30, 33, 37, 40]) == 5\n assert candidate(arr = [8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 12\n assert candidate(arr = [6, 11, 17, 28, 45, 73, 118, 191, 309, 500, 809, 1309, 2108, 3417]) == 12\n assert candidate(arr = [10, 15, 25, 40, 65, 105, 170, 275, 445, 720, 1165, 1885, 3050, 4935, 8000, 12945, 20980, 33925, 54915, 88940, 143865, 232805, 376670, 610535, 987345, 1607920, 2588465, 4196405, 6784370, 10982835, 17777205, 28760040, 46532845]) == 14\n assert candidate(arr = [1, 5, 6, 8, 11, 16, 27, 43, 70, 113, 183, 296, 479, 772, 1251, 2023, 3274, 5297, 8571, 13868]) == 10\n assert candidate(arr = [1, 6, 7, 13, 20, 33, 53, 86, 139, 225, 364, 599, 963, 1562, 2525, 4087, 6612, 10699, 17311, 27910, 45301]) == 11\n assert candidate(arr = [1, 3, 4, 5, 7, 9, 12, 14, 17, 20, 23, 27, 31, 35, 39, 44, 49, 54, 59, 64, 69, 74, 79, 84, 89]) == 6\n assert candidate(arr = [5, 8, 10, 13, 18, 21, 26, 31, 37, 43, 49, 56, 63, 71, 79, 87, 95, 104, 113, 122, 131, 141]) == 5\n assert candidate(arr = [1, 4, 5, 9, 14, 23, 37, 60, 97, 157, 254, 411, 665, 1076, 1741]) == 15\n assert candidate(arr = [1, 2, 3, 6, 9, 11, 16, 25, 36, 51, 67, 88, 116, 154, 201, 258, 326, 407, 498, 602, 721, 856, 1009, 1181, 1374, 1588, 1825, 2086, 2373, 2687, 3028, 3400]) == 3\n assert candidate(arr = [1, 6, 7, 13, 20, 33, 53, 86, 139, 225]) == 10\n assert candidate(arr = [1, 6, 7, 13, 20, 33, 53, 86, 139, 225, 364, 590, 954, 1544, 2498]) == 11\n assert candidate(arr = [1, 7, 8, 15, 23, 38, 61, 99, 160, 259, 419, 678, 1097, 1776, 2873, 4669, 7542]) == 13\n assert candidate(arr = [1, 5, 6, 11, 17, 28, 45, 73, 118, 191, 309, 500, 809, 1309, 2118]) == 15\n assert candidate(arr = [3, 7, 10, 17, 27, 44, 71, 115, 186, 301, 487, 788, 1275, 2063, 3338, 5401, 8739, 14140, 22879, 36929]) == 19\n assert candidate(arr = [10, 15, 25, 40, 65, 105, 170, 275, 445, 720, 1165, 1885]) == 12\n assert candidate(arr = [3, 5, 6, 7, 10, 11, 13, 14, 16, 17, 18, 20, 23, 25, 29, 32, 36, 39, 41, 43]) == 5\n assert candidate(arr = [5, 10, 15, 25, 40, 65, 105, 170, 275, 445, 720, 1165, 1990, 3355]) == 12\n assert candidate(arr = [10, 15, 25, 40, 65, 105, 170, 275, 445, 720, 1165, 1885, 3050, 4935, 8015, 12950, 20965]) == 14\n assert candidate(arr = [2, 3, 5, 6, 7, 9, 11, 14, 18, 23, 29, 35, 44, 58, 73]) == 4\n assert candidate(arr = [1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, 1705, 3136]) == 0\n assert candidate(arr = [2, 6, 8, 14, 22, 36, 58, 94, 152, 246, 408, 654, 1062, 1716, 2778]) == 10\n assert candidate(arr = [1, 2, 4, 8, 15, 27, 50, 92, 170, 312]) == 0\n assert candidate(arr = [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]) == 0\n assert candidate(arr = [1, 5, 6, 7, 9, 11, 18, 20, 26, 29, 31, 38, 41, 47, 50, 59, 62, 68, 75, 82, 89, 96, 103, 110, 117, 124, 131, 138, 145, 152]) == 5\n assert candidate(arr = [1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322]) == 12\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 27, 45, 72, 117, 192, 309, 501]) == 6\n assert candidate(arr = [5, 7, 10, 13, 17, 21, 25, 30, 35, 41, 47, 53, 60, 67, 74, 81, 88, 95, 103, 111, 119, 127, 135, 143, 151]) == 5\n assert candidate(arr = [3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 17\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657]) == 21\n assert candidate(arr = [3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181]) == 16\n assert candidate(arr = [1, 2, 3, 4, 6, 9, 11, 14, 18, 22, 26, 30, 34, 39, 44, 49, 54, 59, 64, 69, 74]) == 4\n assert candidate(arr = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96]) == 0\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) == 12\n assert candidate(arr = [1, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 20, 21, 22, 25, 27, 30, 33]) == 6\n assert candidate(arr = [1, 2, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 16\n assert candidate(arr = [2, 6, 8, 14, 22, 36, 60, 98, 158, 256, 414, 670]) == 6\n assert candidate(arr = [10, 15, 25, 40, 65, 105, 170, 275, 445, 720, 1165]) == 11\n assert candidate(arr = [1, 2, 3, 4, 6, 9, 15, 24, 39, 63]) == 7\n assert candidate(arr = [10, 15, 25, 40, 65, 105, 170, 275, 445, 720, 1165, 1885, 3045, 4930]) == 12\n assert candidate(arr = [2, 5, 7, 12, 19, 31, 50, 81, 131, 212, 343, 555, 898, 1453, 2351]) == 15\n assert candidate(arr = [1, 8, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025]) == 18\n assert candidate(arr = [1, 4, 5, 9, 14, 23, 37, 60, 97, 157, 254, 411, 665, 1076, 1741, 2817, 4558, 7375, 11933, 19288]) == 19\n assert candidate(arr = [5, 9, 14, 23, 37, 60, 97, 157, 254, 411, 665, 1076]) == 12\n assert candidate(arr = [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]) == 0\n assert candidate(arr = [5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181]) == 15\n assert candidate(arr = [2, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110]) == 7\n assert candidate(arr = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961, 1089, 1225, 1369, 1521, 1681, 1849, 2025, 2209]) == 0\n assert candidate(arr = [4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778]) == 16\n assert candidate(arr = [1, 2, 5, 7, 12, 19, 31, 50, 81, 131, 212, 343, 554]) == 11\n assert candidate(arr = [3, 6, 9, 15, 24, 39, 63, 102, 165, 267, 432, 700]) == 11\n assert candidate(arr = [1, 2, 4, 8, 15, 27, 50, 92, 174, 336, 633, 1212, 2245, 4207, 7920]) == 0\n assert candidate(arr = [2, 9, 11, 20, 31, 51, 82, 133, 215, 348, 563, 901, 1464]) == 11\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6,7,8]", "[1,3,7,11,12,14,18]"], "hints": ["Can we use dynamic programming here?", "Consider a sequence ending at index iarr[i], which can be done in linear time per element."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().lenLongestFibSubseq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:41+00:00", "tests_total": 122, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def lenLongestFibSubseq(self, arr: list[int]) -> int:", "container": "Solution", "callable": "lenLongestFibSubseq", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 874, "task_id": "walking-robot-simulation", "difficulty": "Medium", "problem_description": "A robot on an infinite XY-plane starts at point (0, 0) facing north. The robot receives an array of integers commands, which represents a sequence of moves that it needs to execute. There are only three possible types of instructions the robot can receive:\n\n- -2: Turn left 90 degrees.\n- -1: Turn right 90 degrees.\n- 1 <= k <= 9: Move forward k units, one unit at a time.\n\nSome of the grid squares are obstacles. The i^th obstacle is at grid point obstacles[i] = (x_i, y_i). If the robot runs into an obstacle, it will stay in its current location (on the block adjacent to the obstacle) and move onto the next command.\n\nReturn the maximum squared Euclidean distance that the robot reaches at any point in its path (i.e. if the distance is 5, return 25).\n\nNote:\n\n- There can be an obstacle at (0, 0). If this happens, the robot will ignore the obstacle until it has moved off the origin. However, it will be unable to return to (0, 0) due to the obstacle.\n- North means +Y direction.\n- East means +X direction.\n- South means -Y direction.\n- West means -X direction.\n\nExample 1:\n\nInput: commands = [4,-1,3], obstacles = []\nOutput: 25\nExplanation:\nThe robot starts at (0, 0):\n1. Move north 4 units to (0, 4).\n2. Turn right.\n3. Move east 3 units to (3, 4).\n\nThe furthest point the robot ever gets from the origin is (3, 4), which squared is 3^2 + 4^2= 25 units away.\n\nExample 2:\n\nInput: commands = [4,-1,4,-2,4], obstacles = [[2,4]]\nOutput: 65\nExplanation:\nThe robot starts at (0, 0):\n1. Move north 4 units to (0, 4).\n2. Turn right.\n3. Move east 1 unit and get blocked by the obstacle at (2, 4), robot is at (1, 4).\n4. Turn left.\n5. Move north 4 units to (1, 8).\n\nThe furthest point the robot ever gets from the origin is (1, 8), which squared is 1^2 + 8^2 = 65 units away.\n\nExample 3:\n\nInput: commands = [6,-1,-1,6], obstacles = [[0,0]]\nOutput: 36\nExplanation:\nThe robot starts at (0, 0):\n1. Move north 6 units to (0, 6).\n2. Turn right.\n3. Turn right.\n4. Move south 5 units and get blocked by the obstacle at (0,0), robot is at (0, 1).\n\nThe furthest point the robot ever gets from the origin is (0, 6), which squared is 6^2 = 36 units away.\n\nConstraints:\n\n- 1 <= commands.length <= 10^4\n- commands[i] is either -2, -1, or an integer in the range [1, 9].\n- 0 <= obstacles.length <= 10^4\n- -3 * 10^4 <= x_i, y_i <= 3 * 10^4\n- The answer is guaranteed to be less than 2^31.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(commands = [5, -2, 5, -2, 5, -2, 5],obstacles = [[-1, -1], [1, 1]]) == 50\n assert candidate(commands = [1, -2, 1, -2, 1, -2, 1, -2],obstacles = [[0, 1], [1, 0], [-1, 0], [0, -1]]) == 0\n assert candidate(commands = [5, -2, 5, -2, 5],obstacles = [[0, 2], [0, -2], [2, 0], [-2, 0]]) == 41\n assert candidate(commands = [4, -1, 3],obstacles = []) == 25\n assert candidate(commands = [5, -2, 5, -2, 5],obstacles = [[-1, 0], [1, 0], [0, -1], [0, 1]]) == 0\n assert candidate(commands = [-2, -1, 10],obstacles = [[1, 0]]) == 100\n assert candidate(commands = [1, 1, 1, 1],obstacles = [[1, 1]]) == 16\n assert candidate(commands = [1, -2, 3, -1, 4],obstacles = [[-1, -1], [0, -1], [1, -1], [1, 0]]) == 34\n assert candidate(commands = [1, 1, 1, 1, 1, 1, 1, 1, 1],obstacles = [[2, 2]]) == 81\n assert candidate(commands = [4, -1, 4, -2, 4],obstacles = [[2, 4]]) == 65\n assert candidate(commands = [3, -2, 3, -1, 3, -2, 3],obstacles = [[-2, 3], [-1, 3], [0, 3], [1, 3], [2, 3], [-2, -3], [-1, -3], [0, -3], [1, -3], [2, -3]]) == 61\n assert candidate(commands = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],obstacles = [[5, 5]]) == 8100\n assert candidate(commands = [-2, -2, -2, -2],obstacles = [[0, 1], [0, -1], [1, 0], [-1, 0]]) == 0\n assert candidate(commands = [-2, -2, -2, -2],obstacles = []) == 0\n assert candidate(commands = [6, -1, -1, 6],obstacles = [[0, 0]]) == 36\n assert candidate(commands = [1, 2, 3, 4, -2, -2, -1, -1],obstacles = [[1, 1], [2, 2]]) == 100\n assert candidate(commands = [9, 9, -2, 9, -2, 9, -2, 9],obstacles = [[2, 2]]) == 405\n assert candidate(commands = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],obstacles = [[0, 1]]) == 0\n assert candidate(commands = [9, 9, 9, 9, -2, -2, -2, -2, 9, 9, 9, 9],obstacles = [[2, 2], [2, -2], [-2, -2], [-2, 2]]) == 5184\n assert candidate(commands = [1, 2, 3, 4],obstacles = [[1, 1], [2, 2], [3, 3]]) == 100\n assert candidate(commands = [1, -2, 1, -2, 1, -2, 1, -2],obstacles = [[0, 2], [2, 0], [0, -2], [-2, 0]]) == 2\n assert candidate(commands = [1, 2, 3, 4, 5],obstacles = [[1, 1], [2, 2], [3, 3]]) == 225\n assert candidate(commands = [1, -2, 2, -2, 3, -2, 4, -2, 5, -2, 6, -2, 7, -2, 8, -2, 9, -2],obstacles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 125\n assert candidate(commands = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 400\n assert candidate(commands = [7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1],obstacles = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]) == 0\n assert candidate(commands = [1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 13\n assert candidate(commands = [8, -1, 8, -1, 8, -1, 8, -1, 8, -1, 8, -1, 8, -1, 8, -1, 8, -1, 8],obstacles = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 145\n assert candidate(commands = [7, -2, 8, -1, 9, -2, 1, -1, 2, -2, 3, -1, 4, -2, 5, -1, 6, -2, 7, -1],obstacles = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]) == 1201\n assert candidate(commands = [5, -2, 6, -1, 7, -2, 8, -1, 9],obstacles = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 637\n assert candidate(commands = [9, -2, 8, -1, 7, -2, 6, -1, 5, -2, 4, -1, 3, -2, 2, -1, 1, -2],obstacles = [[-3, 0], [-2, 0], [-1, 0], [0, 0], [1, 0], [2, 0], [3, 0]]) == 1025\n assert candidate(commands = [5, -2, 4, -1, 3, -2, 2, -1, 1, -2],obstacles = [[-1, 1], [0, 0], [1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7]]) == 117\n assert candidate(commands = [1, -2, 2, -1, 3, -2, 4, -1, 5, -2, 6, -1, 7, -2, 8, -1, 9, -2, 1, -1],obstacles = [[-3, 3], [-2, 2], [-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]) == 986\n assert candidate(commands = [3, -2, 2, -1, 5, -2, 5, -1, 3, -2, 3, -1, 3, -2, 3, -1],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 365\n assert candidate(commands = [6, -1, 6, -2, 6, -1, 6, -2, 6, -1, 6, -2],obstacles = [[0, 6], [6, 0], [3, 3], [2, 2], [4, 4], [5, 5]]) == 545\n assert candidate(commands = [5, -2, 5, -2, 5, -2, 5, -2, 5, -2],obstacles = [[-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7]]) == 50\n assert candidate(commands = [8, -2, 6, -1, 5, -2, 7, -1, 4],obstacles = [[-2, 3], [0, 2], [1, 1], [2, 0], [3, -1], [2, -2]]) == 269\n assert candidate(commands = [1, 2, 3, 4, 5, 6, 7, 8, 9, -2, -1, 8, 7, 6, 5, 4, 3, 2, 1],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 6561\n assert candidate(commands = [8, -2, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1],obstacles = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8]]) == 656\n assert candidate(commands = [7, -2, 7, -2, 7, -2, 7, -2, 7, -2, 7, -2],obstacles = [[3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 98\n assert candidate(commands = [4, 4, -2, 4, 4, -2, 4, 4, -2, 4, 4],obstacles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == 128\n assert candidate(commands = [7, 1, 2, -2, 3, -1, 4, -2, 5, -1],obstacles = [[2, 2], [2, 3], [2, 4], [3, 3], [4, 3]]) == 260\n assert candidate(commands = [2, -2, 3, -1, 4, -2, 5, -1, 6, -2, 7, -1, 8, -2, 9],obstacles = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9]]) == 976\n assert candidate(commands = [4, -2, 4, -1, 4, -2, 4, -1, 4, -2, 4, -1],obstacles = [[0, 2], [1, 1], [2, 0], [-1, -1], [-2, -2], [-3, -3], [0, -2], [2, 2]]) == 225\n assert candidate(commands = [5, -1, 5, -1, 5, -2, 5, -2, 5, -1, 5, -1, 5, -2, 5, -2, 5, -1, 5],obstacles = [[1, 2], [2, 1], [3, 0], [4, -1], [5, -2]]) == 650\n assert candidate(commands = [8, -1, 7, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1],obstacles = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 458\n assert candidate(commands = [3, -1, 3, -2, 3, -1, 3, -2, 3, -1, 3, -2, 3, -1, 3, -2, 3, -1, 3, -2],obstacles = [[-3, -3], [-4, -2], [-5, -1], [-6, 0], [-7, 1]]) == 450\n assert candidate(commands = [5, -1, 4, -1, 3, -1, 2, -1, 1, -2, 1, -2, 2, -2, 3, -2, 4, -2, 5, -2],obstacles = [[-2, 5], [-1, 4], [0, 3], [1, 2], [2, 1], [3, 0], [4, -1]]) == 29\n assert candidate(commands = [4, -2, 4, -1, 4, -2, 4, -1, 4, -2, 4, -1, 4, -2, 4, -1, 4, -2, 4, -1],obstacles = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 800\n assert candidate(commands = [9, -2, 8, -1, 7, -2, 6, -1, 5, -2, 4, -1, 3, -2, 2, -1, 1, -2],obstacles = [[-4, -4], [-4, -3], [-3, -4], [-3, -3], [-2, -2], [-2, -1], [-1, -2], [-1, -1]]) == 1025\n assert candidate(commands = [5, 5, -1, 5, -1, 5, -1, 5],obstacles = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 125\n assert candidate(commands = [5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5, -1],obstacles = [[-1, 1], [-1, 2], [-1, 3], [-1, 4], [-1, 5], [-1, 6], [-1, 7], [-1, 8]]) == 50\n assert candidate(commands = [5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1],obstacles = [[-2, -2], [-2, -3], [-2, -4], [-2, -5], [-2, -6], [-2, -7], [-2, -8], [-2, -9], [-2, -10]]) == 1250\n assert candidate(commands = [8, -2, 8, -1, 8, -2, 8, -1],obstacles = [[-2, 0], [0, -2], [2, 0], [0, 2], [1, 1]]) == 337\n assert candidate(commands = [1, -1, 2, -2, 3, -1, 4, -2, 5, -1, 6, -2, 7, -1, 8, -2, 9, -1, 10, -2],obstacles = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 1354\n assert candidate(commands = [9, -2, 8, -1, 7, -2, 6, -1, 5, -2, 4, -1, 3, -2, 2, -1, 1],obstacles = [[0, -5], [1, -4], [2, -3], [3, -2], [4, -1], [5, 0]]) == 1025\n assert candidate(commands = [6, -2, 4, -1, 3, -2, 2, -1, 1],obstacles = [[-2, 3], [-3, 2], [-1, 4], [-1, -4], [4, -1], [3, -2]]) == 136\n assert candidate(commands = [1, 2, 3, 4, 5, 6, 7, 8, 9, -2, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 4050\n assert candidate(commands = [9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1],obstacles = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7]]) == 145\n assert candidate(commands = [1, -2, 2, -2, 3, -2, 4, -2, 5, -2, 6, -2, 7, -2, 8, -2, 9, -2, 10, -2],obstacles = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 136\n assert candidate(commands = [5, -1, 5, -1, 5, -1, 5, -1, 5, -1, 5],obstacles = [[3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9]]) == 34\n assert candidate(commands = [9, -2, 8, -1, 7, -2, 6, -1, 5, -2, 4, -1, 3, -2, 2, -1, 1],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1025\n assert candidate(commands = [9, 9, 9, 9, 9, -2, 9, 9, 9, 9, 9, -2, 9, 9, 9, 9, 9],obstacles = [[4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 4050\n assert candidate(commands = [3, 3, 3, -1, 3, 3, 3, -1, 3, 3, 3, -1, 3, 3, 3, -1, 3],obstacles = [[2, 2], [3, 3], [4, 4], [2, 4], [4, 2], [3, 1], [3, 5]]) == 162\n assert candidate(commands = [9, 9, 9, -2, 9, 9, 9, -2, 9, 9, 9, -2, 9, 9, 9, -2, 9],obstacles = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 5], [3, 5], [2, 5], [1, 5]]) == 1458\n assert candidate(commands = [8, -2, 5, -1, 3, -2, 4, -1, 2],obstacles = [[2, 3], [3, 2], [2, 1], [1, 2], [0, 0]]) == 250\n assert candidate(commands = [10, -1, 9, -2, 8, -1, 7, -2, 6, -1, 5],obstacles = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]) == 16\n assert candidate(commands = [8, -2, 7, -2, 8, -1, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 628\n assert candidate(commands = [9, -2, 8, -1, 7, -2, 6, -1, 5, -2, 4, -1, 3, -2, 2, -1, 1, -2],obstacles = [[-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0]]) == 1025\n assert candidate(commands = [9, 9, 9, 9, -2, 9, 9, 9, 9, -2, 9, 9, 9, 9, -2, 9, 9, 9, 9, -2, 9, 9, 9, 9],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 2592\n assert candidate(commands = [9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1],obstacles = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 232\n assert candidate(commands = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 3600\n assert candidate(commands = [1, -2, 1, -1, 2, -2, 2, -1, 3, -2, 3, -1, 4, -2, 4, -1, 5, -2, 5, -1],obstacles = [[-1, -2], [-1, -3], [-1, -4], [-1, -5], [-1, -6], [-1, -7], [-1, -8], [-1, -9]]) == 450\n assert candidate(commands = [9, -2, 8, -1, 7, -2, 6, -1, 5, -2, 4, -1, 3, -2, 2, -1, 1, -2],obstacles = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 724\n assert candidate(commands = [9, 9, 9, 9, -1, 9, 9, 9, 9, -1, 9, 9, 9, 9, -1, 9, 9, 9, 9, -1],obstacles = [[2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 2592\n assert candidate(commands = [4, -2, 4, -2, 4, -1, 4, -1, 4, -2, 4, -1, 4, -2, 4, -1, 4],obstacles = [[0, 0], [1, 1], [-1, -1], [2, 2], [-2, -2]]) == 400\n assert candidate(commands = [1, -2, 2, -1, 3, -2, 4, -1, 5, -2, 6, -1, 7, -2, 8, -1, 9, -2, 10, -1],obstacles = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1525\n assert candidate(commands = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -1, -2, -1, -2, -1, -2, -1, -2],obstacles = [[2, 1], [4, 2], [6, 3], [8, 4], [10, 5]]) == 2025\n assert candidate(commands = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9],obstacles = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 1853\n assert candidate(commands = [4, -2, 3, -2, 2, -2, 1, -2],obstacles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 25\n assert candidate(commands = [1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2],obstacles = [[0, 1], [1, 0], [-1, 0], [0, -1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(commands = [3, -2, 4, -1, 2, -2, 1, -1, 0, -2, 3, -1, 4],obstacles = [[-2, -1], [-3, 0], [-4, 1], [-5, 2], [-6, 3]]) == 145\n assert candidate(commands = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9],obstacles = [[0, 1], [1, 0], [-1, 0], [0, -1], [1, 2], [2, 1], [-2, 1], [1, -2], [2, -1], [-2, -1], [0, 2], [2, 0], [-2, 0], [0, -2], [-2, -2], [2, -2], [2, 2], [0, 3], [3, 0], [-3, 0], [0, -3], [-3, -3], [3, -3], [3, 3]]) == 0\n assert candidate(commands = [9, -1, 8, -2, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1, -1, 0],obstacles = [[2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]]) == 1025\n assert candidate(commands = [5, -2, 6, -2, 5, -1, 4, -1, 3],obstacles = [[2, 3], [-2, -3], [0, 0]]) == 109\n assert candidate(commands = [1, -2, 3, -1, 5, -2, 7, -1, 9, -2, 11, -1, 13, -2, 15, -1, 17, -2, 19, -1],obstacles = [[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0], [1, -1], [2, -2], [3, -3], [4, -4]]) == 4729\n assert candidate(commands = [6, -2, 4, -1, 2, -2, 5, -1, 1, -2, 3, -1],obstacles = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 153\n assert candidate(commands = [8, -2, 6, -1, 4, -2, 2, -1, 5],obstacles = [[0, 3], [1, 2], [2, 1], [3, 0]]) == 185\n assert candidate(commands = [10, -2, 9, -1, 8, -2, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1, -1],obstacles = [[2, 5], [3, 6], [4, 7], [5, 8]]) == 1525\n assert candidate(commands = [1, -2, 3, -1, 5, -2, 7, -1, 9, -2, 11, -1, 13, -2, 15, -1],obstacles = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13]]) == 2080\n assert candidate(commands = [9, -2, 9, -2, 9, -1, 9, -1, 9, -2, 9, -1, 9, -2, 9],obstacles = [[-3, 3], [-2, 2], [-1, 1], [1, 1], [2, 2], [3, 3]]) == 1620\n assert candidate(commands = [3, -1, 4, -2, 5, -1, 2, -2, 1],obstacles = [[1, 2], [2, 1], [2, 3], [3, 2], [0, 1]]) == 72\n assert candidate(commands = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],obstacles = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, -1], [1, -1], [2, -1], [3, -1], [4, -1], [5, -5], [-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5000\n assert candidate(commands = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1],obstacles = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [9, 11], [8, 12], [7, 13], [6, 14], [5, 15]]) == 565\n assert candidate(commands = [10, -2, 9, -1, 8, -2, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1, -1],obstacles = [[-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 1525\n assert candidate(commands = [10, -2, 10, -1, 10, -2, 10, -1, 10],obstacles = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]]) == 976\n assert candidate(commands = [9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1],obstacles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 221\n assert candidate(commands = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -1, -2, -1, -2],obstacles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 2025\n assert candidate(commands = [5, -2, 5, -2, 5, -2, 5],obstacles = [[0, 2], [1, 3], [-2, 1], [3, -2], [0, 0]]) == 32\n assert candidate(commands = [1, -2, 3, -1, 5, -2, 7, -1, 9, -2, 11, -1, 13, -2, 15, -1, 17, -2, 19],obstacles = [[-1, -2], [-3, -4], [-5, -6], [-7, -8], [-9, -10]]) == 5050\n assert candidate(commands = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1],obstacles = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]]) == 106\n assert candidate(commands = [8, 8, 8, -2, 8, 8, 8, -2, 8, 8, 8, -2, 8, 8, 8, -2, 8, -1, 8, -1, 8, -1, 8, -1],obstacles = [[4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [5, 4], [6, 4], [7, 4], [8, 4]]) == 1152\n assert candidate(commands = [1, -1, 2, -2, 3, -1, 4, -2, 5, -1, 6, -2, 7, -1, 8],obstacles = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]]) == 656\n assert candidate(commands = [9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -2, 9, -2, 8, -2, 7, -2, 6, -2, 5, -2, 4, -2, 3, -2, 2, -2, 1],obstacles = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2]]) == 169\n assert candidate(commands = [9, -1, 8, -2, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1, -1],obstacles = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1025\n assert candidate(commands = [5, 5, 5, 5, -2, 5, 5, 5, 5, -1],obstacles = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 2], [3, 2], [4, 2]]) == 800\n assert candidate(commands = [9, -1, 8, -1, 7, -1, 6, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1, 0],obstacles = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]) == 145\n assert candidate(commands = [1, -2, 3, -1, 4, -2, 5, -1, 6, -2, 7, -1, 8, -2, 9, -1],obstacles = [[-1, -1], [0, -1], [1, -1], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [5, 1], [5, 2], [5, 3]]) == 937\n assert candidate(commands = [8, -2, 7, -1, 6, -2, 5, -1, 4, -2, 3, -1, 2, -2, 1, -1],obstacles = [[3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3]]) == 656\n assert candidate(commands = [1, -1, 2, -2, 3, -1, 4, -2, 5, -1, 6, -2, 7, -1, 8, -2],obstacles = [[-1, -1], [0, -1], [1, -1], [1, 0], [1, 1], [0, 1], [-1, 1]]) == 0\n assert candidate(commands = [1, 2, 3, 4, 5, 4, 3, 2, 1, -1, -2, -1, -2, -1, -2, 2, 4, 6, 8, 10],obstacles = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == 3025\n assert candidate(commands = [2, -1, 2, -1, 2, -2, 2, -2, 2, -1, 2, -1, 2, -2, 2, -2, 2, -1, 2],obstacles = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 100\n assert candidate(commands = [5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5],obstacles = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1]]) == 1250\n assert candidate(commands = [9, -1, 9, -2, 9, -1, 9, -2, 9, -1, 9, -2],obstacles = [[3, 4], [4, 3], [5, 2], [2, 5], [1, 6], [6, 1]]) == 1458\n assert candidate(commands = [5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1, 5, -2, 5, -1],obstacles = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [4, -1], [3, -2], [2, -3], [1, -4], [0, -5]]) == 1201\n", "comparison": "exact"}, "public_tests": ["[4,-1,3]\n[]", "[4,-1,4,-2,4]\n[[2,4]]", "[-1,9]\n[[5,0],[2,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["commands", "obstacles"], "leetcode_dataset_entry_point": "Solution().robotSim", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:43+00:00", "tests_total": 114, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "simulation"]}, "language": "python", "interface": {"raw_signature": "def robotSim(self, commands: list[int], obstacles: list[list[int]]) -> int:", "container": "Solution", "callable": "robotSim", "parameters": [{"name": "commands", "type": "list[int]"}, {"name": "obstacles", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 875, "task_id": "koko-eating-bananas", "difficulty": "Medium", "problem_description": "Koko loves to eat bananas. There are n piles of bananas, the i^th pile has piles[i] bananas. The guards have gone and will come back in h hours.\n\nKoko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour.\n\nKoko likes to eat slowly but still wants to finish eating all the bananas before the guards return.\n\nReturn the minimum integer k such that she can eat all the bananas within h hours.\n\nExample 1:\n\nInput: piles = [3,6,7,11], h = 8\nOutput: 4\n\nExample 2:\n\nInput: piles = [30,11,23,4,20], h = 5\nOutput: 30\n\nExample 3:\n\nInput: piles = [30,11,23,4,20], h = 6\nOutput: 23\n\nConstraints:\n\n- 1 <= piles.length <= 10^4\n- piles.length <= h <= 10^9\n- 1 <= piles[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 2, 3],h = 5) == 2\n assert candidate(piles = [1000000000],h = 1000000000) == 1\n assert candidate(piles = [805306457, 805306457, 805306457],h = 1000000000) == 3\n assert candidate(piles = [30, 11, 23, 4, 20],h = 5) == 30\n assert candidate(piles = [805306457, 933693859, 908256970, 820324087, 610103336],h = 5) == 933693859\n assert candidate(piles = [1, 1, 1, 1],h = 4) == 1\n assert candidate(piles = [10, 10, 10, 10],h = 10) == 5\n assert candidate(piles = [3, 3, 3, 3, 3],h = 5) == 3\n assert candidate(piles = [3, 3, 3, 3, 3],h = 10) == 2\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],h = 10) == 1\n assert candidate(piles = [3, 6, 7, 11],h = 10) == 3\n assert candidate(piles = [1],h = 1) == 1\n assert candidate(piles = [3, 6, 7, 11],h = 8) == 4\n assert candidate(piles = [1, 999999999],h = 2) == 999999999\n assert candidate(piles = [1, 2, 3],h = 3) == 3\n assert candidate(piles = [805306368, 805306368, 805306368],h = 1000000000) == 3\n assert candidate(piles = [1000000000, 1000000000, 1000000000],h = 3) == 1000000000\n assert candidate(piles = [30, 11, 23, 4, 20],h = 6) == 23\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],h = 10) == 3\n assert candidate(piles = [1, 1, 1, 1, 1],h = 5) == 1\n assert candidate(piles = [30, 11, 23, 4, 20, 35],h = 7) == 30\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],h = 10) == 10\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],h = 20) == 35\n assert candidate(piles = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],h = 5) == 1000000000\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],h = 10) == 19\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],h = 10) == 10\n assert candidate(piles = [5, 8, 6, 29, 33, 12],h = 9) == 15\n assert candidate(piles = [5, 8, 6, 12, 20],h = 5) == 20\n assert candidate(piles = [5, 8, 10, 12, 15, 17, 20, 23, 25, 28, 30, 33, 35, 38, 40],h = 15) == 40\n assert candidate(piles = [332484035, 524908576, 855865114, 632739624, 265801521],h = 8) == 427932557\n assert candidate(piles = [312884470],h = 312884469) == 2\n assert candidate(piles = [3, 6, 7, 11, 30, 20],h = 15) == 6\n assert candidate(piles = [5, 8, 6, 3],h = 15) == 2\n assert candidate(piles = [1000000000, 999999999, 888888888, 777777777],h = 10) == 444444444\n assert candidate(piles = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],h = 9) == 100000000\n assert candidate(piles = [1, 10, 100, 1000, 10000, 100000],h = 6) == 100000\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],h = 100) == 1\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],h = 10) == 10\n assert candidate(piles = [3, 6, 7, 11, 20, 25, 30],h = 15) == 9\n assert candidate(piles = [50, 25, 75, 25, 100, 50, 25, 75, 25, 100, 50, 25, 75, 25, 100, 50, 25, 75, 25, 100],h = 50) == 25\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],h = 15) == 15\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1],h = 9) == 9\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],h = 20) == 20\n assert candidate(piles = [1, 10, 100, 1000, 10000, 100000, 1000000],h = 14) == 125000\n assert candidate(piles = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],h = 25) == 66666667\n assert candidate(piles = [10, 20, 30, 40, 50],h = 100) == 2\n assert candidate(piles = [5, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],h = 15) == 26\n assert candidate(piles = [1000000000, 1, 1000000000, 1, 1000000000],h = 1000000000) == 4\n assert candidate(piles = [3, 6, 7, 11, 11, 11, 11, 11, 11, 11],h = 10) == 11\n assert candidate(piles = [3, 6, 7, 11, 20, 30, 40, 50, 60, 70, 80, 90, 100],h = 15) == 80\n assert candidate(piles = [5, 8, 6, 7, 1, 2, 3, 4, 5],h = 9) == 8\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],h = 100) == 3\n assert candidate(piles = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],h = 20) == 10\n assert candidate(piles = [100, 200, 300, 400, 500],h = 50) == 32\n assert candidate(piles = [1000000000, 1000000000, 1000000000],h = 3) == 1000000000\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],h = 10) == 10\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],h = 100) == 234\n assert candidate(piles = [300000000, 100000000, 200000000, 400000000, 500000000],h = 1000000000) == 2\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],h = 100) == 1\n assert candidate(piles = [5, 4, 3, 2, 1],h = 15) == 1\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],h = 10) == 100\n assert candidate(piles = [1, 10, 100, 1000, 10000],h = 10) == 1667\n assert candidate(piles = [100, 150, 200, 250, 300, 350, 400],h = 15) == 150\n assert candidate(piles = [100000000, 200000000, 300000000, 400000000, 500000000],h = 5) == 500000000\n assert candidate(piles = [3, 6, 7, 11, 100, 101, 200],h = 20) == 26\n assert candidate(piles = [8, 5, 6, 10, 12],h = 7) == 8\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],h = 10) == 100\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],h = 50) == 120\n assert candidate(piles = [100, 100, 100, 100, 100],h = 10) == 50\n assert candidate(piles = [1000000000, 1000000000, 1000000000],h = 1000000000) == 4\n assert candidate(piles = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],h = 100) == 5\n assert candidate(piles = [332484035, 524900671, 855865114, 632088198, 232463062],h = 8) == 427932557\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],h = 10) == 5\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],h = 15) == 10\n assert candidate(piles = [10, 15, 20, 25, 30, 35, 40],h = 20) == 10\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],h = 10000) == 1\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],h = 15) == 50\n assert candidate(piles = [805306368, 805306368, 805306368],h = 1000000000) == 3\n assert candidate(piles = [900000000, 800000000, 700000000, 600000000, 500000000],h = 5) == 900000000\n assert candidate(piles = [8, 5, 4, 10, 7, 9, 6],h = 15) == 4\n assert candidate(piles = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],h = 15) == 25\n assert candidate(piles = [10, 15, 7, 30],h = 6) == 15\n assert candidate(piles = [3, 6, 7, 11, 33, 45, 55],h = 25) == 7\n assert candidate(piles = [8, 12, 15, 18, 22],h = 12) == 8\n assert candidate(piles = [3, 6, 7, 11, 11, 11, 11, 11, 11, 11],h = 20) == 6\n assert candidate(piles = [10, 20, 30, 40, 50],h = 20) == 9\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],h = 20) == 1\n assert candidate(piles = [3, 6, 7, 11, 20, 25, 30],h = 25) == 5\n assert candidate(piles = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],h = 32) == 250000000\n assert candidate(piles = [999999999, 999999998, 999999997, 999999996, 999999995],h = 10) == 500000000\n assert candidate(piles = [33, 41, 17, 29, 38, 36, 40, 9, 66, 27],h = 13) == 38\n assert candidate(piles = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1],h = 10) == 1000000000\n assert candidate(piles = [30, 11, 23, 4, 20],h = 7) == 20\n assert candidate(piles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],h = 20) == 20\n assert candidate(piles = [987654321, 123456789, 987654321, 123456789, 987654321],h = 5) == 987654321\n assert candidate(piles = [2, 4, 9, 16, 25, 36, 49, 64, 81, 100],h = 15) == 41\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],h = 25) == 27\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],h = 10) == 1\n assert candidate(piles = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],h = 20) == 100\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],h = 20) == 4\n", "comparison": "exact"}, "public_tests": ["[3,6,7,11]\n8", "[30,11,23,4,20]\n5", "[30,11,23,4,20]\n6"], "hints": [], "metadata": {"canonical_parameter_names": ["piles", "h"], "leetcode_dataset_entry_point": "Solution().minEatingSpeed", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:45+00:00", "tests_total": 124, "tests_dropped": 24, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def minEatingSpeed(self, piles: list[int], h: int) -> int:", "container": "Solution", "callable": "minEatingSpeed", "parameters": [{"name": "piles", "type": "list[int]"}, {"name": "h", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 877, "task_id": "stone-game", "difficulty": "Medium", "problem_description": "Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].\n\nThe objective of the game is to end with the most stones. The total number of stones across all the piles is odd, so there are no ties.\n\nAlice and Bob take turns, with Alice starting first. Each turn, a player takes the entire pile of stones either from the beginning or from the end of the row. This continues until there are no more piles left, at which point the person with the most stones wins.\n\nAssuming Alice and Bob play optimally, return true if Alice wins the game, or false if Bob wins.\n\nExample 1:\n\nInput: piles = [5,3,4,5]\nOutput: true\nExplanation:\nAlice starts first, and can only take the first 5 or the last 5.\nSay she takes the first 5, so that the row becomes [3, 4, 5].\nIf Bob takes 3, then the board is [4, 5], and Alice takes 5 to win with 10 points.\nIf Bob takes the last 5, then the board is [3, 4], and Alice takes 4 to win with 9 points.\nThis demonstrated that taking the first 5 was a winning move for Alice, so we return true.\n\nExample 2:\n\nInput: piles = [3,7,2,3]\nOutput: true\n\nConstraints:\n\n- 2 <= piles.length <= 500\n- piles.length is even.\n- 1 <= piles[i] <= 500\n- sum(piles[i]) is odd.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [15, 30, 5, 10, 20, 25]) == True\n assert candidate(piles = [8, 15, 3, 7]) == True\n assert candidate(piles = [7, 3, 8, 5, 12, 10]) == True\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(piles = [1, 100, 1, 100, 1, 100, 1, 100]) == True\n assert candidate(piles = [2, 2, 2, 2, 2, 2]) == False\n assert candidate(piles = [10, 20, 30, 40, 50, 60]) == True\n assert candidate(piles = [8, 6, 5, 1, 7, 9]) == True\n assert candidate(piles = [10, 20, 30, 40]) == True\n assert candidate(piles = [1, 5, 2, 4, 6, 3]) == True\n assert candidate(piles = [1, 2, 3, 4]) == True\n assert candidate(piles = [2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(piles = [3, 6, 9, 12, 15, 18]) == True\n assert candidate(piles = [8, 9, 7, 6, 5, 4]) == True\n assert candidate(piles = [1, 3, 5, 7, 9, 11]) == True\n assert candidate(piles = [10, 5, 1, 2, 3, 7, 4, 8]) == True\n assert candidate(piles = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(piles = [1, 100, 1, 100, 1, 100]) == True\n assert candidate(piles = [4, 3, 2, 1, 6, 5, 8, 7]) == True\n assert candidate(piles = [7, 2, 5, 10, 14, 3, 1, 2]) == True\n assert candidate(piles = [8, 9, 7, 6]) == False\n assert candidate(piles = [1, 2, 100, 3]) == True\n assert candidate(piles = [4, 1, 5, 2, 6, 3]) == True\n assert candidate(piles = [1, 2, 3, 5, 4, 6]) == True\n assert candidate(piles = [5, 3, 4, 5]) == True\n assert candidate(piles = [100, 100, 100, 100, 100, 100]) == False\n assert candidate(piles = [2, 4, 6, 8, 10, 12]) == True\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(piles = [3, 7, 2, 3]) == True\n assert candidate(piles = [100, 1, 100, 1, 100, 1]) == True\n assert candidate(piles = [7, 9, 8, 6]) == False\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(piles = [29, 18, 17, 26, 34, 15, 45, 13, 50, 25, 30, 10, 35, 40, 5, 20]) == True\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == True\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]) == True\n assert candidate(piles = [5, 1, 100, 4, 10, 8, 6, 2]) == True\n assert candidate(piles = [10, 23, 5, 2, 7, 8, 3, 12, 15, 6]) == True\n assert candidate(piles = [1, 100, 2, 99, 3, 98, 4, 97]) == True\n assert candidate(piles = [8, 15, 3, 7, 6, 9, 5, 10, 4, 12, 11, 14, 2, 13]) == True\n assert candidate(piles = [100, 50, 200, 150, 300, 250, 400, 350, 500, 450]) == True\n assert candidate(piles = [150, 120, 180, 160, 200, 140, 220, 190, 210, 170]) == True\n assert candidate(piles = [50, 100, 75, 25, 120, 150, 80, 60]) == True\n assert candidate(piles = [200, 100, 150, 50, 250, 125, 300, 150, 350, 175, 400, 200, 450, 225, 500, 250]) == True\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(piles = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == True\n assert candidate(piles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == True\n assert candidate(piles = [12, 34, 56, 78, 90, 23, 45, 67, 89, 101, 123, 145]) == True\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(piles = [15, 23, 12, 18, 35, 10, 42, 8, 20, 14]) == True\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(piles = [10, 15, 3, 7, 8, 2, 1, 5]) == True\n assert candidate(piles = [8, 9, 5, 7, 2, 3, 4, 6, 1, 10]) == True\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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == True\n assert candidate(piles = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14]) == True\n assert candidate(piles = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == True\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(piles = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == True\n assert candidate(piles = [2, 8, 4, 6, 10, 14, 12, 16, 18, 20]) == True\n assert candidate(piles = [17, 23, 42, 35, 29, 49, 31, 47, 53, 41]) == True\n assert candidate(piles = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56]) == True\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(piles = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(piles = [3, 1, 2, 5, 4, 6, 9, 7, 8, 10]) == True\n assert candidate(piles = [55, 65, 25, 30, 40, 50, 15, 20, 35, 45]) == True\n assert candidate(piles = [45, 55, 65, 75, 85, 95, 105, 115, 125, 135]) == True\n assert candidate(piles = [500, 1, 500, 1, 500, 1, 500, 1, 500, 1, 500, 1]) == True\n assert candidate(piles = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20]) == True\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(piles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(piles = [45, 22, 33, 11, 55, 66, 77, 88, 99, 111, 222, 333]) == True\n assert candidate(piles = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == False\n assert candidate(piles = [48, 32, 15, 22, 39, 28, 33, 27, 19, 25]) == True\n assert candidate(piles = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == False\n assert candidate(piles = [10, 23, 15, 70, 6, 18, 40, 5]) == True\n assert candidate(piles = [150, 200, 50, 100, 350, 400, 150, 200, 50, 100, 350, 400, 150, 200, 50, 100]) == True\n assert candidate(piles = [500, 1, 500, 1, 500, 1, 500, 1, 500, 1]) == True\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]) == True\n assert candidate(piles = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5]) == True\n assert candidate(piles = [9, 3, 15, 2, 11, 8, 6, 10, 5, 4]) == True\n assert candidate(piles = [500, 1, 500, 1, 500, 1, 500, 1, 500, 1, 500, 1, 500, 1, 500, 1]) == True\n assert candidate(piles = [10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100, 10, 100]) == True\n assert candidate(piles = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == True\n assert candidate(piles = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]) == True\n assert candidate(piles = [3, 2, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(piles = [23, 34, 56, 45, 78, 89, 12, 11, 22, 33, 44, 55]) == True\n assert candidate(piles = [250, 100, 300, 200, 400, 150, 350, 25]) == True\n assert candidate(piles = [5, 1, 9, 4, 8, 2, 7, 3, 6, 11]) == True\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80]) == True\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13]) == True\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(piles = [150, 100, 50, 200, 25, 300, 75, 175, 125, 120, 60, 180, 220, 30, 240, 80]) == True\n assert candidate(piles = [100, 200, 101, 201, 102, 202, 103, 203, 104, 204]) == True\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(piles = [5, 8, 6, 3, 4, 2, 7, 9, 1, 10]) == True\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(piles = [20, 40, 30, 60, 50, 70, 80, 100, 90, 110]) == True\n assert candidate(piles = [8, 15, 3, 7, 12, 9, 6, 11, 2, 10, 5, 14]) == True\n assert candidate(piles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == False\n assert candidate(piles = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20]) == True\n assert candidate(piles = [5, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == True\n assert candidate(piles = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14]) == True\n assert candidate(piles = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(piles = [42, 33, 24, 15, 6, 17, 28, 39, 50, 61, 72, 83]) == True\n assert candidate(piles = [12, 22, 32, 42, 52, 62, 72, 82, 92, 102]) == True\n", "comparison": "exact"}, "public_tests": ["[5,3,4,5]", "[3,7,2,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["piles"], "leetcode_dataset_entry_point": "Solution().stoneGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:50+00:00", "tests_total": 119, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "minimax-algorithm", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGame(self, piles: list[int]) -> bool:", "container": "Solution", "callable": "stoneGame", "parameters": [{"name": "piles", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 878, "task_id": "nth-magical-number", "difficulty": "Hard", "problem_description": "A positive integer is magical if it is divisible by either a or b.\n\nGiven the three integers n, a, and b, return the n^th magical number. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 1, a = 2, b = 3\nOutput: 2\n\nExample 2:\n\nInput: n = 4, a = 2, b = 3\nOutput: 6\n\nConstraints:\n\n- 1 <= n <= 10^9\n- 2 <= a, b <= 4 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,a = 6,b = 5) == 15\n assert candidate(n = 10,a = 3,b = 7) == 24\n assert candidate(n = 1000000000,a = 2,b = 3) == 499999993\n assert candidate(n = 10,a = 7,b = 3) == 24\n assert candidate(n = 5,a = 3,b = 5) == 10\n assert candidate(n = 5,a = 7,b = 5) == 15\n assert candidate(n = 10,a = 3,b = 5) == 21\n assert candidate(n = 4,a = 2,b = 3) == 6\n assert candidate(n = 10,a = 7,b = 11) == 44\n assert candidate(n = 1,a = 2,b = 3) == 2\n assert candidate(n = 10,a = 12,b = 18) == 90\n assert candidate(n = 1000000000,a = 40000,b = 40000) == 999720007\n assert candidate(n = 750000000,a = 8000,b = 16000) == 999958007\n assert candidate(n = 600000000,a = 29,b = 37) == 904615333\n assert candidate(n = 500000000,a = 10000,b = 10000) == 999965007\n assert candidate(n = 100,a = 234,b = 567) == 16848\n assert candidate(n = 500,a = 100,b = 300) == 50000\n assert candidate(n = 1000000000,a = 39999,b = 40000) == 999860007\n assert candidate(n = 999999999,a = 3,b = 11) == 538461521\n assert candidate(n = 750000000,a = 20001,b = 30002) == 689943000\n assert candidate(n = 120000000,a = 11,b = 23) == 920000000\n assert candidate(n = 900000000,a = 89,b = 127) == 314883394\n assert candidate(n = 999999999,a = 3,b = 5) == 142857126\n assert candidate(n = 800000000,a = 7999,b = 8000) == 999977607\n assert candidate(n = 800000000,a = 789,b = 321) == 30893061\n assert candidate(n = 75000000,a = 8888,b = 9999) == 962497382\n assert candidate(n = 500000000,a = 23,b = 47) == 833333281\n assert candidate(n = 400000000,a = 13579,b = 24680) == 891663244\n assert candidate(n = 300000000,a = 11111,b = 22222) == 299976669\n assert candidate(n = 500000000,a = 10000,b = 10001) == 249982500\n assert candidate(n = 5000000,a = 3456,b = 7890) == 22857132\n assert candidate(n = 200000000,a = 23456,b = 34567) == 814186778\n assert candidate(n = 600000000,a = 5000,b = 5001) == 299989500\n assert candidate(n = 900000000,a = 13,b = 19) == 170967696\n assert candidate(n = 345678901,a = 11111,b = 22222) == 838242131\n assert candidate(n = 1,a = 3,b = 5) == 3\n assert candidate(n = 1000000000,a = 2,b = 2) == 999999993\n assert candidate(n = 500000000,a = 2,b = 5) == 833333334\n assert candidate(n = 100000000,a = 10000,b = 20000) == 999993007\n assert candidate(n = 987654321,a = 27182,b = 31415) == 137264409\n assert candidate(n = 750000000,a = 11,b = 29) == 134615346\n assert candidate(n = 123456789,a = 4321,b = 9876) == 119975644\n assert candidate(n = 999999999,a = 37,b = 41) == 701298547\n assert candidate(n = 456789012,a = 14142,b = 17320) == 441321430\n assert candidate(n = 1000000000,a = 29,b = 31) == 237288036\n assert candidate(n = 100000,a = 11111,b = 22222) == 111099993\n assert candidate(n = 750000000,a = 456,b = 789) == 260868172\n assert candidate(n = 999999999,a = 37,b = 100) == 205882140\n assert candidate(n = 100000000,a = 11111,b = 22222) == 99992223\n assert candidate(n = 200000000,a = 100,b = 101) == 99999930\n assert candidate(n = 123456789,a = 1234,b = 5678) == 183610385\n assert candidate(n = 150000000,a = 11111,b = 22222) == 649988338\n assert candidate(n = 600000000,a = 111,b = 222) == 599999538\n assert candidate(n = 999999999,a = 2,b = 3) == 499999991\n assert candidate(n = 500000001,a = 8000,b = 8001) == 249994000\n assert candidate(n = 200000000,a = 15000,b = 17000) == 161273485\n assert candidate(n = 500000000,a = 10000,b = 12345) == 981180666\n assert candidate(n = 1000,a = 2,b = 3) == 1500\n assert candidate(n = 250000000,a = 10000,b = 10003) == 249963753\n assert candidate(n = 300000000,a = 15000,b = 16000) == 999983207\n assert candidate(n = 150000000,a = 17,b = 23) == 503846139\n assert candidate(n = 789012345,a = 1111,b = 2222) == 592709163\n assert candidate(n = 600000000,a = 9000,b = 18000) == 999962207\n assert candidate(n = 400000000,a = 20001,b = 20002) == 399972000\n assert candidate(n = 678901234,a = 12345,b = 12346) == 857288152\n assert candidate(n = 500000000,a = 10001,b = 10007) == 124765147\n assert candidate(n = 50000000,a = 789,b = 1234) == 75815670\n assert candidate(n = 345678912,a = 2345,b = 6789) == 570799481\n assert candidate(n = 123456789,a = 13579,b = 24680) == 448025793\n assert candidate(n = 50000000,a = 10000,b = 10001) == 24998250\n assert candidate(n = 100000000,a = 10001,b = 10002) == 99996500\n assert candidate(n = 999999999,a = 10000,b = 10001) == 499955000\n assert candidate(n = 800000000,a = 41,b = 53) == 692472990\n assert candidate(n = 1000000,a = 1234,b = 5678) == 13987665\n assert candidate(n = 300000000,a = 12345,b = 23456) == 516628373\n assert candidate(n = 123456789,a = 20000,b = 30000) == 851827043\n assert candidate(n = 500000000,a = 4,b = 6) == 499999993\n assert candidate(n = 100000,a = 10001,b = 10002) == 500100000\n assert candidate(n = 800000000,a = 10001,b = 20002) == 799944000\n assert candidate(n = 456789123,a = 2020,b = 3030) == 35515996\n assert candidate(n = 450000000,a = 17,b = 29) == 929999972\n", "comparison": "exact"}, "public_tests": ["1\n2\n3", "4\n2\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "a", "b"], "leetcode_dataset_entry_point": "Solution().nthMagicalNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:52+00:00", "tests_total": 104, "tests_dropped": 23, "flags": [], "topic_tags": ["math", "binary-search", "least-common-multiple", "inclusion-exclusion-principle"]}, "language": "python", "interface": {"raw_signature": "def nthMagicalNumber(self, n: int, a: int, b: int) -> int:", "container": "Solution", "callable": "nthMagicalNumber", "parameters": [{"name": "n", "type": "int"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 879, "task_id": "profitable-schemes", "difficulty": "Hard", "problem_description": "There is a group of n members, and a list of various crimes they could commit. The i^th crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can't participate in another crime.\n\nLet's call a profitable scheme any subset of these crimes that generates at least minProfit profit, and the total number of members participating in that subset of crimes is at most n.\n\nReturn the number of schemes that can be chosen. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 5, minProfit = 3, group = [2,2], profit = [2,3]\nOutput: 2\nExplanation: To make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1.\nIn total, there are 2 schemes.\n\nExample 2:\n\nInput: n = 10, minProfit = 5, group = [2,3,5], profit = [6,7,8]\nOutput: 7\nExplanation: To make a profit of at least 5, the group could commit any crimes, as long as they commit one.\nThere are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2).\n\nConstraints:\n\n- 1 <= n <= 100\n- 0 <= minProfit <= 100\n- 1 <= group.length <= 100\n- 1 <= group[i] <= 100\n- profit.length == group.length\n- 0 <= profit[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,minProfit = 4,group = [4],profit = [5]) == 1\n assert candidate(n = 3,minProfit = 0,group = [1, 2],profit = [0, 0]) == 4\n assert candidate(n = 100,minProfit = 100,group = [100],profit = [100]) == 1\n assert candidate(n = 10,minProfit = 0,group = [1, 2, 3, 4],profit = [1, 1, 1, 1]) == 16\n assert candidate(n = 4,minProfit = 1,group = [1, 2, 3],profit = [1, 2, 3]) == 5\n assert candidate(n = 1,minProfit = 1,group = [1],profit = [1]) == 1\n assert candidate(n = 10,minProfit = 1,group = [1, 2, 3],profit = [1, 2, 3]) == 7\n assert candidate(n = 3,minProfit = 0,group = [1, 1, 1],profit = [0, 0, 0]) == 8\n assert candidate(n = 10,minProfit = 5,group = [2, 3, 5],profit = [6, 7, 8]) == 7\n assert candidate(n = 5,minProfit = 3,group = [2, 2],profit = [2, 3]) == 2\n assert candidate(n = 50,minProfit = 50,group = [10, 20, 30],profit = [5, 10, 15]) == 0\n assert candidate(n = 4,minProfit = 4,group = [4],profit = [4]) == 1\n assert candidate(n = 50,minProfit = 25,group = [10, 10, 10, 10, 10],profit = [5, 5, 5, 5, 5]) == 1\n assert candidate(n = 20,minProfit = 10,group = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 80,minProfit = 40,group = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(n = 50,minProfit = 25,group = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 36\n assert candidate(n = 90,minProfit = 90,group = [18, 18, 18, 18, 18],profit = [18, 18, 18, 18, 18]) == 1\n assert candidate(n = 50,minProfit = 30,group = [10, 20, 30, 40, 50],profit = [5, 10, 15, 20, 25]) == 0\n assert candidate(n = 100,minProfit = 50,group = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],profit = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(n = 99,minProfit = 99,group = [10, 20, 30, 40, 50, 60, 70, 80, 90],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(n = 70,minProfit = 40,group = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],profit = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == 0\n assert candidate(n = 50,minProfit = 50,group = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],profit = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 638\n assert candidate(n = 60,minProfit = 20,group = [10, 15, 20, 5, 25],profit = [6, 8, 10, 2, 12]) == 13\n assert candidate(n = 90,minProfit = 30,group = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 838\n assert candidate(n = 100,minProfit = 5,group = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 449666\n assert candidate(n = 50,minProfit = 50,group = [5, 10, 15, 20],profit = [10, 20, 30, 40]) == 9\n assert candidate(n = 60,minProfit = 20,group = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],profit = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1128\n assert candidate(n = 60,minProfit = 30,group = [15, 10, 25, 5, 30, 20],profit = [12, 8, 15, 3, 20, 18]) == 22\n assert candidate(n = 70,minProfit = 20,group = [5, 10, 15, 20, 25, 30, 35, 40],profit = [1, 2, 3, 4, 5, 6, 7, 8]) == 0\n assert candidate(n = 50,minProfit = 10,group = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 638\n assert candidate(n = 100,minProfit = 100,group = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 95,minProfit = 50,group = [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19],profit = [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 = 75,minProfit = 50,group = [10, 20, 15, 25, 5],profit = [10, 30, 20, 40, 5]) == 18\n assert candidate(n = 10,minProfit = 4,group = [2, 3, 5, 1],profit = [3, 4, 6, 1]) == 12\n assert candidate(n = 60,minProfit = 20,group = [3, 4, 5, 6, 7, 8, 9, 10],profit = [4, 5, 6, 7, 8, 9, 10, 11]) == 210\n assert candidate(n = 100,minProfit = 75,group = [10, 20, 30, 40, 50, 60, 70, 80, 90],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 23\n assert candidate(n = 100,minProfit = 100,group = [20, 20, 20, 20, 20],profit = [20, 20, 20, 20, 20]) == 1\n assert candidate(n = 90,minProfit = 30,group = [10, 20, 30, 40, 50, 60, 70, 80, 90],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 30\n assert candidate(n = 100,minProfit = 50,group = [10, 20, 30, 40, 50],profit = [5, 15, 25, 35, 45]) == 14\n assert candidate(n = 50,minProfit = 30,group = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],profit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(n = 50,minProfit = 50,group = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20215\n assert candidate(n = 65,minProfit = 30,group = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 807231\n assert candidate(n = 60,minProfit = 20,group = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 803\n assert candidate(n = 100,minProfit = 70,group = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(n = 75,minProfit = 40,group = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],profit = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 90,minProfit = 0,group = [9, 18, 27, 36, 45],profit = [0, 0, 0, 0, 0]) == 25\n assert candidate(n = 100,minProfit = 100,group = [20, 30, 40, 50, 10, 20],profit = [25, 35, 45, 55, 5, 15]) == 8\n assert candidate(n = 90,minProfit = 45,group = [10, 20, 30, 40, 50, 60, 70, 80],profit = [5, 10, 15, 20, 25, 30, 35, 40]) == 7\n assert candidate(n = 70,minProfit = 25,group = [7, 14, 21, 28, 35, 42, 49],profit = [4, 8, 12, 16, 20, 24, 28]) == 23\n assert candidate(n = 80,minProfit = 30,group = [10, 20, 30, 40, 50],profit = [5, 7, 9, 11, 13]) == 0\n assert candidate(n = 100,minProfit = 50,group = [10, 20, 30, 40, 50],profit = [20, 30, 40, 50, 60]) == 21\n assert candidate(n = 50,minProfit = 15,group = [5, 10, 15, 20, 25, 30],profit = [3, 6, 9, 12, 15, 18]) == 25\n assert candidate(n = 55,minProfit = 25,group = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 90,minProfit = 30,group = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(n = 75,minProfit = 35,group = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(n = 75,minProfit = 40,group = [5, 10, 15, 20, 25, 30, 35],profit = [2, 4, 6, 8, 10, 12, 14]) == 0\n assert candidate(n = 60,minProfit = 60,group = [12, 12, 12, 12, 12],profit = [12, 12, 12, 12, 12]) == 1\n assert candidate(n = 80,minProfit = 25,group = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],profit = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(n = 90,minProfit = 50,group = [10, 20, 30, 40, 50, 60],profit = [10, 20, 30, 40, 50, 60]) == 20\n assert candidate(n = 70,minProfit = 30,group = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(n = 60,minProfit = 30,group = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(n = 99,minProfit = 99,group = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(n = 85,minProfit = 60,group = [12, 18, 24, 30, 36, 42, 48, 54, 60],profit = [9, 12, 15, 18, 21, 24, 27, 30, 33]) == 0\n assert candidate(n = 100,minProfit = 75,group = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(n = 80,minProfit = 80,group = [16, 16, 16, 16, 16],profit = [16, 16, 16, 16, 16]) == 1\n assert candidate(n = 60,minProfit = 0,group = [6, 12, 18, 24, 30],profit = [0, 0, 0, 0, 0]) == 25\n assert candidate(n = 85,minProfit = 40,group = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],profit = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 470\n assert candidate(n = 100,minProfit = 80,group = [10, 20, 30, 40, 50, 60, 70, 80, 90, 10],profit = [5, 15, 25, 35, 45, 55, 65, 75, 85, 5]) == 23\n assert candidate(n = 70,minProfit = 70,group = [14, 14, 14, 14, 14],profit = [14, 14, 14, 14, 14]) == 1\n assert candidate(n = 50,minProfit = 50,group = [10, 10, 10, 10, 10],profit = [10, 10, 10, 10, 10]) == 1\n assert candidate(n = 85,minProfit = 45,group = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17],profit = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(n = 70,minProfit = 20,group = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],profit = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(n = 100,minProfit = 0,group = [10, 20, 30, 40, 50],profit = [0, 0, 0, 0, 0]) == 25\n assert candidate(n = 50,minProfit = 20,group = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 796\n assert candidate(n = 90,minProfit = 60,group = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],profit = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 210\n assert candidate(n = 100,minProfit = 50,group = [10, 20, 30, 40, 50],profit = [10, 20, 30, 40, 50]) == 18\n assert candidate(n = 100,minProfit = 50,group = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],profit = [5, 10, 15, 20, 25, 5, 10, 15, 20, 25]) == 51\n assert candidate(n = 70,minProfit = 35,group = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(n = 50,minProfit = 20,group = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 50,minProfit = 0,group = [5, 10, 15, 20, 25],profit = [0, 0, 0, 0, 0]) == 25\n assert candidate(n = 95,minProfit = 55,group = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 11\n assert candidate(n = 95,minProfit = 45,group = [10, 20, 30, 40, 50, 60, 70, 80, 90],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 8\n assert candidate(n = 70,minProfit = 30,group = [10, 20, 30, 40],profit = [10, 20, 30, 40]) == 10\n assert candidate(n = 75,minProfit = 40,group = [5, 15, 25, 35, 45],profit = [5, 15, 25, 35, 45]) == 14\n assert candidate(n = 60,minProfit = 20,group = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 95,minProfit = 55,group = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],profit = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 773\n assert candidate(n = 100,minProfit = 0,group = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1024\n assert candidate(n = 85,minProfit = 45,group = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],profit = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 0\n assert candidate(n = 80,minProfit = 60,group = [10, 15, 20, 25, 30, 35, 40],profit = [5, 10, 15, 20, 25, 30, 35]) == 13\n assert candidate(n = 75,minProfit = 25,group = [5, 10, 15, 20, 25, 30, 35],profit = [1, 2, 3, 4, 5, 6, 7]) == 0\n assert candidate(n = 95,minProfit = 70,group = [10, 20, 30, 40, 50, 60, 70, 80, 90],profit = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 0\n assert candidate(n = 80,minProfit = 40,group = [5, 10, 15, 20, 25, 30, 35, 40],profit = [3, 6, 9, 12, 15, 18, 21, 24]) == 38\n assert candidate(n = 80,minProfit = 20,group = [10, 20, 30, 40],profit = [10, 20, 30, 40]) == 12\n assert candidate(n = 50,minProfit = 10,group = [10, 15, 20, 25, 30],profit = [5, 7, 9, 11, 13]) == 13\n assert candidate(n = 90,minProfit = 45,group = [20, 15, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [10, 8, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 80,minProfit = 0,group = [8, 16, 24, 32, 40],profit = [0, 0, 0, 0, 0]) == 25\n assert candidate(n = 50,minProfit = 15,group = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],profit = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 56\n assert candidate(n = 90,minProfit = 45,group = [5, 15, 10, 20, 25, 30, 5, 10],profit = [3, 8, 6, 12, 15, 20, 4, 7]) == 62\n assert candidate(n = 80,minProfit = 60,group = [10, 10, 10, 10, 10, 10, 10, 10],profit = [10, 10, 10, 10, 10, 10, 10, 10]) == 37\n assert candidate(n = 70,minProfit = 0,group = [7, 14, 21, 28, 35],profit = [0, 0, 0, 0, 0]) == 25\n assert candidate(n = 60,minProfit = 20,group = [5, 15, 25, 35, 45],profit = [3, 6, 9, 12, 15]) == 3\n assert candidate(n = 75,minProfit = 75,group = [10, 20, 30, 40, 5, 15, 25, 35],profit = [5, 15, 25, 35, 1, 3, 5, 7]) == 0\n assert candidate(n = 80,minProfit = 40,group = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(n = 65,minProfit = 28,group = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],profit = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 80\n assert candidate(n = 75,minProfit = 50,group = [5, 10, 15, 20, 25],profit = [10, 20, 30, 40, 50]) == 25\n assert candidate(n = 55,minProfit = 25,group = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 1199\n assert candidate(n = 90,minProfit = 70,group = [10, 15, 20, 25, 30, 35, 40],profit = [5, 10, 15, 20, 25, 30, 35]) == 11\n assert candidate(n = 100,minProfit = 100,group = [5, 10, 15, 20, 25, 30],profit = [5, 15, 25, 35, 45, 55]) == 27\n assert candidate(n = 50,minProfit = 10,group = [3, 5, 7, 9, 11, 13],profit = [2, 4, 6, 8, 10, 12]) == 57\n assert candidate(n = 80,minProfit = 30,group = [2, 3, 4, 5, 6, 7, 8, 9, 10],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 109\n assert candidate(n = 60,minProfit = 20,group = [5, 10, 15, 20, 25, 30],profit = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(n = 20,minProfit = 8,group = [3, 5, 7, 4, 2],profit = [5, 7, 9, 6, 4]) == 26\n assert candidate(n = 60,minProfit = 15,group = [5, 10, 15, 20, 25, 30],profit = [3, 6, 9, 12, 15, 18]) == 35\n", "comparison": "exact"}, "public_tests": ["5\n3\n[2,2]\n[2,3]", "10\n5\n[2,3,5]\n[6,7,8]"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "minProfit", "group", "profit"], "leetcode_dataset_entry_point": "Solution().profitableSchemes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:54+00:00", "tests_total": 117, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "dynamic-programming", "knapsack-problem", "0-1-knapsack"]}, "language": "python", "interface": {"raw_signature": "def profitableSchemes(self, n: int, minProfit: int, group: list[int], profit: list[int]) -> int:", "container": "Solution", "callable": "profitableSchemes", "parameters": [{"name": "n", "type": "int"}, {"name": "minProfit", "type": "int"}, {"name": "group", "type": "list[int]"}, {"name": "profit", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 880, "task_id": "decoded-string-at-index", "difficulty": "Medium", "problem_description": "You are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken:\n\n- If the character read is a letter, that letter is written onto the tape.\n- If the character read is a digit d, the entire current tape is repeatedly written d - 1 more times in total.\n\nGiven an integer k, return the k^th letter (1-indexed) in the decoded string.\n\nExample 1:\n\nInput: s = \"leet2code3\", k = 10\nOutput: \"o\"\nExplanation: The decoded string is \"leetleetcodeleetleetcodeleetleetcode\".\nThe 10^th letter in the string is \"o\".\n\nExample 2:\n\nInput: s = \"ha22\", k = 5\nOutput: \"h\"\nExplanation: The decoded string is \"hahahaha\".\nThe 5^th letter is \"h\".\n\nExample 3:\n\nInput: s = \"a2345678999999999999999\", k = 1\nOutput: \"a\"\nExplanation: The decoded string is \"a\" repeated 8301530446056247680 times.\nThe 1^st letter is \"a\".\n\nConstraints:\n\n- 2 <= s.length <= 100\n- s consists of lowercase English letters and digits 2 through 9.\n- s starts with a letter.\n- 1 <= k <= 10^9\n- It is guaranteed that k is less than or equal to the length of the decoded string.\n- The decoded string is guaranteed to have less than 2^63 letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"x5\",k = 15) == \"x\"\n assert candidate(s = \"y959q969u3hb22\",k = 200) == \"y\"\n assert candidate(s = \"abc2d3\",k = 7) == \"d\"\n assert candidate(s = \"y959q969u3hb22\",k = 94921609) == \"y\"\n assert candidate(s = \"xyz4\",k = 10) == \"x\"\n assert candidate(s = \"y959q969u3hb22\",k = 53563622) == \"y\"\n assert candidate(s = \"a2345678999999999999999\",k = 1) == \"a\"\n assert candidate(s = \"v7\",k = 6) == \"v\"\n assert candidate(s = \"a2b2c2\",k = 5) == \"a\"\n assert candidate(s = \"abc2\",k = 2) == \"b\"\n assert candidate(s = \"abcd\",k = 1) == \"a\"\n assert candidate(s = \"abc2def3\",k = 6) == \"c\"\n assert candidate(s = \"x2y3\",k = 5) == \"x\"\n assert candidate(s = \"vzpp636m8y\",k = 88699223) == \"v\"\n assert candidate(s = \"ha22\",k = 5) == \"h\"\n assert candidate(s = \"a2b3\",k = 4) == \"a\"\n assert candidate(s = \"abc2\",k = 3) == \"c\"\n assert candidate(s = \"a9b9\",k = 80) == \"b\"\n assert candidate(s = \"ab2c3\",k = 7) == \"b\"\n assert candidate(s = \"abc2def3\",k = 7) == \"d\"\n assert candidate(s = \"x123\",k = 3) == \"x\"\n assert candidate(s = \"leet2code3\",k = 10) == \"o\"\n assert candidate(s = \"abcd2\",k = 7) == \"c\"\n assert candidate(s = \"vk7\",k = 17) == \"v\"\n assert candidate(s = \"large100string3\",k = 250) == \"i\"\n assert candidate(s = \"a2b2c3d4e5f6g7h8i9j1k2l3m4n5o6p7q8r9s1t2u3v4w5x6y7z8\",k = 1000000) == \"a\"\n assert candidate(s = \"abc3xyz2\",k = 13) == \"a\"\n assert candidate(s = \"hello2world3\",k = 19) == \"l\"\n assert candidate(s = \"abcdefg8\",k = 1000000000) == \"f\"\n assert candidate(s = \"abcde2xyz3\",k = 11) == \"x\"\n assert candidate(s = \"abcd2efg3hij4\",k = 50) == \"c\"\n assert candidate(s = \"nested2brackets3\",k = 25) == \"e\"\n assert candidate(s = \"abcd2efg3hij4klm5nop6qrst7uvw8xyz9\",k = 1000) == \"c\"\n assert candidate(s = \"abcdefgh9\",k = 999999999) == \"g\"\n assert candidate(s = \"ab2cd3ef4gh5ij6kl7mn8op9qr0st1uv2wx3yz4\",k = 750) == \"v\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1\",k = 362880) == \"z\"\n assert candidate(s = \"abc2def3ghi4jkl5\",k = 90) == \"i\"\n assert candidate(s = \"leet2code3xyz4\",k = 25) == \"l\"\n assert candidate(s = \"mnop2qrst3uvw4\",k = 75) == \"t\"\n assert candidate(s = \"hello2world3\",k = 18) == \"l\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1\",k = 987654321) == \"z\"\n assert candidate(s = \"a2b2c2d2e2f2g2h2i2j2\",k = 20) == \"a\"\n assert candidate(s = \"a2b2c3d4e5f6g7h8i9j1\",k = 500) == \"b\"\n assert candidate(s = \"hello2world3\",k = 17) == \"e\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16\",k = 1000) == \"j\"\n assert candidate(s = \"ab2c3d4e5f6\",k = 200) == \"c\"\n assert candidate(s = \"repeat2twice3\",k = 27) == \"e\"\n assert candidate(s = \"xyz2abc3def4\",k = 85) == \"a\"\n assert candidate(s = \"xyz9\",k = 25) == \"x\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\",k = 362880) == \"a\"\n assert candidate(s = \"abcdefg2hijklm2nopqr2stuv2wxyz2\",k = 50) == \"e\"\n assert candidate(s = \"abc2def3ghi4\",k = 46) == \"d\"\n assert candidate(s = \"xyz9abc8\",k = 100) == \"x\"\n assert candidate(s = \"leet2code3\",k = 15) == \"e\"\n assert candidate(s = \"leet2code3\",k = 20) == \"t\"\n assert candidate(s = \"a2b3c4d5\",k = 50) == \"b\"\n assert candidate(s = \"abc123\",k = 200) == \"b\"\n assert candidate(s = \"complex2nested3structure4\",k = 150) == \"l\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27\",k = 2000) == \"u\"\n assert candidate(s = \"abcd2efgh3ijkl4mnop5\",k = 1000) == \"d\"\n assert candidate(s = \"abcdefgh23456789\",k = 876543210) == \"b\"\n assert candidate(s = \"abcdefg2hijklm3nopqr4stuv5wxyz6\",k = 2000) == \"k\"\n assert candidate(s = \"hello5world2\",k = 45) == \"o\"\n assert candidate(s = \"xyz9\",k = 27) == \"z\"\n assert candidate(s = \"repeat2many3times4\",k = 120) == \"a\"\n assert candidate(s = \"abc2def3ghi4\",k = 30) == \"i\"\n assert candidate(s = \"a12b3\",k = 35) == \"a\"\n assert candidate(s = \"abcd2efgh3ijkl4mnop5qrst6uvw7xyz8\",k = 1000) == \"h\"\n assert candidate(s = \"x9y8z7\",k = 200) == \"x\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q9p8o7n6m5l4k3j2i1h9g8f7e6d5c4b3a2\",k = 5000) == \"y\"\n assert candidate(s = \"a2b3c4d5\",k = 11) == \"a\"\n assert candidate(s = \"abcde2fghi3\",k = 25) == \"f\"\n assert candidate(s = \"a2b3c4d5e6\",k = 50) == \"b\"\n assert candidate(s = \"abcd2efgh3ijkl4mnop5qrst6uvw7xyz8abcd2efgh3ijkl4mnop5qrst6uvw7xyz8\",k = 3000) == \"h\"\n assert candidate(s = \"abc2def3ghi4\",k = 150) == \"i\"\n assert candidate(s = \"abc3def4gh5\",k = 100) == \"h\"\n assert candidate(s = \"xyz9abc3\",k = 30) == \"c\"\n assert candidate(s = \"a2b3c4\",k = 10) == \"c\"\n assert candidate(s = \"abc3def2ghi4\",k = 40) == \"a\"\n assert candidate(s = \"ab12c3\",k = 20) == \"c\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\",k = 1000) == \"t\"\n assert candidate(s = \"abc123\",k = 240) == \"c\"\n assert candidate(s = \"xy2z3a4b5\",k = 120) == \"y\"\n assert candidate(s = \"a2b3c4d5\",k = 100) == \"a\"\n assert candidate(s = \"x9y8z7\",k = 500) == \"x\"\n assert candidate(s = \"xyz12\",k = 35) == \"y\"\n assert candidate(s = \"a2b3c4d5\",k = 40) == \"c\"\n assert candidate(s = \"hello5world3\",k = 75) == \"o\"\n assert candidate(s = \"abc2def3ghi4\",k = 50) == \"b\"\n assert candidate(s = \"abc2def3ghi4\",k = 60) == \"i\"\n assert candidate(s = \"hello2world2hello2world2\",k = 20) == \"o\"\n assert candidate(s = \"mnopqr2stuv3wxyz4\",k = 120) == \"v\"\n assert candidate(s = \"leet2code3abc4\",k = 40) == \"l\"\n assert candidate(s = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",k = 52) == \"b\"\n assert candidate(s = \"abc123\",k = 100) == \"a\"\n assert candidate(s = \"abcd2efgh3ijkl4mnop5qrst6uvw7xyz8\",k = 500) == \"d\"\n assert candidate(s = \"leet12code34\",k = 100) == \"t\"\n assert candidate(s = \"nested1nested2nested3\",k = 1000) == \"t\"\n assert candidate(s = \"a2b3c4\",k = 15) == \"a\"\n assert candidate(s = \"ab12cd34\",k = 1234) == \"b\"\n assert candidate(s = \"hello2world3\",k = 14) == \"l\"\n", "comparison": "exact"}, "public_tests": ["\"leet2code3\"\n10", "\"ha22\"\n5", "\"a2345678999999999999999\"\n1"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().decodeAtIndex", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:56+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack"]}, "language": "python", "interface": {"raw_signature": "def decodeAtIndex(self, s: str, k: int) -> str:", "container": "Solution", "callable": "decodeAtIndex", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 881, "task_id": "boats-to-save-people", "difficulty": "Medium", "problem_description": "You are given an array people where people[i] is the weight of the i^th person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most limit.\n\nReturn the minimum number of boats to carry every given person.\n\nExample 1:\n\nInput: people = [1,2], limit = 3\nOutput: 1\nExplanation: 1 boat (1, 2)\n\nExample 2:\n\nInput: people = [3,2,2,1], limit = 3\nOutput: 3\nExplanation: 3 boats (1, 2), (2) and (3)\n\nExample 3:\n\nInput: people = [3,5,3,4], limit = 5\nOutput: 4\nExplanation: 4 boats (3), (3), (4), (5)\n\nConstraints:\n\n- 1 <= people.length <= 5 * 10^4\n- 1 <= people[i] <= limit <= 3 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 11) == 5\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 15) == 5\n assert candidate(people = [3, 2, 2, 1],limit = 3) == 3\n assert candidate(people = [5, 5, 5, 5, 5],limit = 10) == 3\n assert candidate(people = [10, 20, 30, 40, 50],limit = 50) == 3\n assert candidate(people = [3, 5, 3, 4],limit = 5) == 4\n assert candidate(people = [1, 2],limit = 3) == 1\n assert candidate(people = [30, 20, 10],limit = 50) == 2\n assert candidate(people = [1, 3, 5, 7, 9],limit = 10) == 3\n assert candidate(people = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 5\n assert candidate(people = [3, 2, 3, 2, 2],limit = 6) == 3\n assert candidate(people = [1, 1, 1, 1, 1, 1],limit = 2) == 3\n assert candidate(people = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 5\n assert candidate(people = [10, 20, 30, 40, 50],limit = 60) == 3\n assert candidate(people = [3, 3, 3, 3, 3, 3],limit = 6) == 3\n assert candidate(people = [1, 2, 3, 4, 5],limit = 5) == 3\n assert candidate(people = [1, 1, 2, 2, 3, 3],limit = 4) == 3\n assert candidate(people = [1, 1, 2, 2, 3, 3, 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],limit = 19) == 18\n assert candidate(people = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 5\n assert candidate(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],limit = 30) == 16\n assert candidate(people = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 15\n assert candidate(people = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90],limit = 100) == 10\n assert candidate(people = [1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],limit = 11) == 18\n assert candidate(people = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 10\n assert candidate(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],limit = 30) == 16\n assert candidate(people = [1, 10, 100, 1000, 10000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],limit = 10000) == 8\n assert candidate(people = [15, 20, 15, 25, 30, 35, 5, 10],limit = 40) == 4\n assert candidate(people = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 11) == 10\n assert candidate(people = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],limit = 30) == 10\n assert candidate(people = [1, 2, 2, 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, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10],limit = 15) == 26\n assert candidate(people = [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],limit = 20) == 16\n assert candidate(people = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 150) == 5\n assert candidate(people = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29],limit = 29) == 20\n assert candidate(people = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 49\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 15) == 8\n assert candidate(people = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 150) == 5\n assert candidate(people = [30, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],limit = 40) == 10\n assert candidate(people = [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],limit = 10) == 34\n assert candidate(people = [30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000],limit = 30000) == 10\n assert candidate(people = [20, 40, 20, 40, 10, 30, 20, 10, 50, 30],limit = 60) == 5\n assert candidate(people = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],limit = 10) == 15\n assert candidate(people = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 8\n assert candidate(people = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 8\n assert candidate(people = [15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000],limit = 30000) == 8\n assert candidate(people = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 10\n assert candidate(people = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 4) == 10\n assert candidate(people = [30, 40, 50, 20, 10, 60],limit = 80) == 3\n assert candidate(people = [30000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],limit = 30000) == 11\n assert candidate(people = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],limit = 22) == 5\n assert candidate(people = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 5) == 20\n assert candidate(people = [1, 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],limit = 11) == 15\n assert candidate(people = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10],limit = 12) == 6\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 21) == 10\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 20) == 8\n assert candidate(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],limit = 26) == 13\n assert candidate(people = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 15\n assert candidate(people = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],limit = 10) == 8\n assert candidate(people = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],limit = 80) == 10\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 30) == 10\n assert candidate(people = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 8\n assert candidate(people = [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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 3) == 41\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 21) == 10\n assert candidate(people = [30, 40, 50, 20, 30, 40, 50, 20, 30, 40, 50],limit = 100) == 6\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 16) == 8\n assert candidate(people = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 11) == 10\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 20) == 11\n assert candidate(people = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 8\n assert candidate(people = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],limit = 6) == 11\n assert candidate(people = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 67\n assert candidate(people = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],limit = 10) == 10\n assert candidate(people = [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],limit = 300) == 13\n assert candidate(people = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 190) == 5\n assert candidate(people = [1, 2, 2, 3, 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],limit = 18) == 17\n assert candidate(people = [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],limit = 10) == 22\n assert candidate(people = [3, 6, 7, 9, 10, 12, 13, 15, 18, 20],limit = 25) == 5\n assert candidate(people = [3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],limit = 25) == 11\n assert candidate(people = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 20) == 11\n assert candidate(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],limit = 25) == 13\n assert candidate(people = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 20) == 11\n assert candidate(people = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 11) == 11\n assert candidate(people = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 133\n assert candidate(people = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 110) == 5\n assert candidate(people = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 19\n assert candidate(people = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 16\n assert candidate(people = [15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000, 15000],limit = 30000) == 10\n assert candidate(people = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],limit = 30) == 11\n assert candidate(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],limit = 31) == 15\n assert candidate(people = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60],limit = 80) == 5\n assert candidate(people = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],limit = 25) == 13\n", "comparison": "exact"}, "public_tests": ["[1,2]\n3", "[3,2,2,1]\n3", "[3,5,3,4]\n5"], "hints": [], "metadata": {"canonical_parameter_names": ["people", "limit"], "leetcode_dataset_entry_point": "Solution().numRescueBoats", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:59+00:00", "tests_total": 89, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting", "timsort"]}, "language": "python", "interface": {"raw_signature": "def numRescueBoats(self, people: list[int], limit: int) -> int:", "container": "Solution", "callable": "numRescueBoats", "parameters": [{"name": "people", "type": "list[int]"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 882, "task_id": "reachable-nodes-in-subdivided-graph", "difficulty": "Hard", "problem_description": "You are given an undirected graph (the \"original graph\") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge.\n\nThe graph is given as a 2D array of edges where edges[i] = [u_i, v_i, cnt_i] indicates that there is an edge between nodes u_i and v_i in the original graph, and cnt_i is the total number of new nodes that you will subdivide the edge into. Note that cnt_i == 0 means you will not subdivide the edge.\n\nTo subdivide the edge [u_i, v_i], replace it with (cnt_i + 1) new edges and cnt_i new nodes. The new nodes are x_1, x_2, ..., x_{cnt_i}, and the new edges are [u_i, x_1], [x_1, x_2], [x_2, x_3], ..., [x_{cnt_i-1}, x_{cnt_i}], [x_{cnt_i}, v_i].\n\nIn this new graph, you want to know how many nodes are reachable from the node 0, where a node is reachable if the distance is maxMoves or less.\n\nGiven the original graph and maxMoves, return the number of nodes that are reachable from node 0 in the new graph.\n\nExample 1:\n\nInput: edges = [[0,1,10],[0,2,1],[1,2,2]], maxMoves = 6, n = 3\nOutput: 13\nExplanation: The edge subdivisions are shown in the image above.\nThe nodes that are reachable are highlighted in yellow.\n\nExample 2:\n\nInput: edges = [[0,1,4],[1,2,6],[0,2,8],[1,3,1]], maxMoves = 10, n = 4\nOutput: 23\n\nExample 3:\n\nInput: edges = [[1,2,4],[1,4,5],[1,3,1],[2,3,4],[3,4,5]], maxMoves = 17, n = 5\nOutput: 1\nExplanation: Node 0 is disconnected from the rest of the graph, so only node 0 is reachable.\n\nConstraints:\n\n- 0 <= edges.length <= min(n * (n - 1) / 2, 10^4)\n- edges[i].length == 3\n- 0 <= u_i < v_i < n\n- There are no multiple edges in the graph.\n- 0 <= cnt_i <= 10^4\n- 0 <= maxMoves <= 10^9\n- 1 <= n <= 3000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1, 4], [1, 2, 6], [0, 2, 8], [1, 3, 1]],maxMoves = 10,n = 4) == 23\n assert candidate(edges = [[0, 1, 0], [1, 2, 0]],maxMoves = 3,n = 3) == 3\n assert candidate(edges = [[0, 1, 5]],maxMoves = 5,n = 2) == 6\n assert candidate(edges = [[1, 2, 4], [1, 4, 5], [1, 3, 1], [2, 3, 4], [3, 4, 5]],maxMoves = 17,n = 5) == 1\n assert candidate(edges = [[0, 1, 5]],maxMoves = 10,n = 2) == 7\n assert candidate(edges = [[0, 1, 0], [1, 2, 0]],maxMoves = 1,n = 3) == 2\n assert candidate(edges = [[0, 1, 3], [0, 2, 2], [1, 2, 2]],maxMoves = 10,n = 3) == 10\n assert candidate(edges = [[0, 1, 0], [1, 2, 0], [2, 3, 0]],maxMoves = 3,n = 4) == 4\n assert candidate(edges = [[0, 1, 0], [0, 2, 0], [1, 2, 0]],maxMoves = 1,n = 3) == 3\n assert candidate(edges = [],maxMoves = 0,n = 1) == 1\n assert candidate(edges = [[0, 1, 10], [0, 2, 1], [1, 2, 2]],maxMoves = 6,n = 3) == 13\n assert candidate(edges = [],maxMoves = 5,n = 1) == 1\n assert candidate(edges = [],maxMoves = 10,n = 1) == 1\n assert candidate(edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10]],maxMoves = 15,n = 5) == 45\n assert candidate(edges = [[0, 1, 100], [0, 2, 200], [1, 3, 300], [2, 4, 400], [3, 5, 500], [4, 6, 600], [5, 7, 700], [6, 8, 800], [7, 9, 900]],maxMoves = 1500,n = 10) == 3001\n assert candidate(edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 6, 1], [2, 7, 1], [3, 8, 1], [3, 9, 1]],maxMoves = 5,n = 10) == 19\n assert candidate(edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 2, 10], [1, 3, 10], [2, 3, 10]],maxMoves = 20,n = 4) == 64\n assert candidate(edges = [[0, 1, 3], [0, 2, 2], [1, 2, 1]],maxMoves = 5,n = 3) == 9\n assert candidate(edges = [[0, 1, 2], [0, 3, 4], [1, 2, 1], [2, 3, 2], [3, 4, 3]],maxMoves = 10,n = 5) == 17\n assert candidate(edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],maxMoves = 9,n = 10) == 10\n assert candidate(edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [0, 3, 4]],maxMoves = 7,n = 4) == 14\n assert candidate(edges = [[0, 1, 100], [0, 2, 100], [1, 2, 100], [1, 3, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [8, 9, 100]],maxMoves = 300,n = 10) == 602\n assert candidate(edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]],maxMoves = 1,n = 4) == 4\n assert candidate(edges = [[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]],maxMoves = 5,n = 10) == 6\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9]],maxMoves = 20,n = 6) == 51\n assert candidate(edges = [[0, 1, 3], [1, 2, 2], [0, 2, 4]],maxMoves = 5,n = 3) == 11\n assert candidate(edges = [[0, 1, 0], [1, 2, 0], [2, 3, 0], [3, 4, 0], [4, 5, 0]],maxMoves = 5,n = 6) == 6\n assert candidate(edges = [[0, 1, 5], [0, 2, 5], [1, 2, 5], [1, 3, 5], [2, 3, 5]],maxMoves = 15,n = 4) == 29\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [0, 3, 4], [1, 3, 5], [2, 3, 6], [0, 4, 7], [1, 4, 8], [2, 4, 9], [3, 4, 10]],maxMoves = 15,n = 5) == 60\n assert candidate(edges = [[0, 1, 4], [1, 2, 6], [0, 2, 8], [1, 3, 1], [3, 4, 5], [2, 5, 3]],maxMoves = 15,n = 6) == 33\n assert candidate(edges = [[0, 1, 3], [0, 2, 4], [1, 2, 5]],maxMoves = 7,n = 3) == 15\n assert candidate(edges = [[0, 1, 5], [0, 2, 5], [0, 3, 5], [0, 4, 5], [1, 2, 5], [1, 3, 5], [1, 4, 5], [2, 3, 5], [2, 4, 5], [3, 4, 5]],maxMoves = 15,n = 5) == 55\n assert candidate(edges = [[0, 1, 10], [0, 2, 5], [2, 3, 3], [1, 4, 4]],maxMoves = 15,n = 5) == 26\n assert candidate(edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [2, 4, 2]],maxMoves = 8,n = 5) == 17\n assert candidate(edges = [[0, 1, 10], [0, 2, 5], [1, 2, 10], [1, 3, 7], [2, 4, 3], [3, 4, 8]],maxMoves = 20,n = 5) == 48\n assert candidate(edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1], [0, 10, 1]],maxMoves = 1,n = 11) == 11\n assert candidate(edges = [[0, 1, 1000], [1, 2, 2000], [2, 3, 3000], [3, 4, 4000]],maxMoves = 10000,n = 5) == 10001\n assert candidate(edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7]],maxMoves = 15,n = 7) == 31\n assert candidate(edges = [[0, 1, 3], [0, 2, 3], [1, 2, 3], [1, 3, 3], [2, 3, 3], [0, 4, 3], [1, 4, 3], [2, 4, 3], [3, 4, 3]],maxMoves = 5,n = 5) == 22\n assert candidate(edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 4, 50]],maxMoves = 35,n = 5) == 71\n assert candidate(edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],maxMoves = 15,n = 7) == 16\n assert candidate(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], [5, 9, 11], [6, 9, 12]],maxMoves = 30,n = 10) == 87\n assert candidate(edges = [[0, 1, 100], [0, 2, 50], [1, 3, 25], [1, 4, 75], [2, 5, 20], [2, 6, 40], [3, 7, 30], [4, 8, 60], [5, 9, 10], [6, 10, 15], [7, 11, 20], [8, 12, 25], [9, 13, 30], [10, 14, 35], [11, 15, 40], [12, 16, 45], [13, 17, 50], [14, 18, 55], [15, 19, 60]],maxMoves = 300,n = 20) == 795\n assert candidate(edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],maxMoves = 25,n = 10) == 26\n assert candidate(edges = [[0, 1, 10], [0, 2, 5], [1, 2, 3], [1, 3, 4], [2, 3, 2]],maxMoves = 15,n = 4) == 28\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [2, 3, 5]],maxMoves = 10,n = 4) == 19\n assert candidate(edges = [[0, 1, 0], [0, 2, 0], [1, 2, 0], [1, 3, 0], [2, 3, 0]],maxMoves = 5,n = 4) == 4\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [1, 2, 1], [1, 3, 2], [2, 3, 1], [2, 4, 2], [3, 4, 1], [3, 5, 2], [4, 5, 1]],maxMoves = 5,n = 6) == 13\n assert candidate(edges = [[0, 1, 100], [0, 2, 50], [1, 2, 50], [1, 3, 30], [2, 3, 20], [2, 4, 40], [3, 4, 50]],maxMoves = 200,n = 5) == 345\n assert candidate(edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8]],maxMoves = 30,n = 9) == 31\n assert candidate(edges = [[0, 1, 5], [0, 2, 5], [0, 3, 5], [0, 4, 5], [0, 5, 5], [0, 6, 5], [0, 7, 5], [0, 8, 5], [0, 9, 5], [0, 10, 5]],maxMoves = 20,n = 11) == 61\n assert candidate(edges = [[0, 1, 10], [0, 2, 1], [1, 2, 2], [2, 3, 5], [3, 4, 3]],maxMoves = 12,n = 5) == 26\n assert candidate(edges = [[0, 1, 2], [0, 2, 2], [0, 3, 2], [0, 4, 2], [1, 5, 2], [2, 6, 2], [3, 7, 2], [4, 8, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2]],maxMoves = 5,n = 9) == 21\n assert candidate(edges = [[0, 1, 20], [0, 2, 15], [1, 2, 10], [1, 3, 25], [2, 4, 30], [3, 4, 5]],maxMoves = 50,n = 5) == 110\n assert candidate(edges = [[0, 1, 4], [0, 2, 4], [1, 2, 5], [1, 3, 2], [2, 3, 3]],maxMoves = 10,n = 4) == 22\n assert candidate(edges = [[0, 1, 1], [2, 3, 1], [4, 5, 1]],maxMoves = 3,n = 6) == 3\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [0, 9, 9]],maxMoves = 15,n = 10) == 55\n assert candidate(edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [1, 2, 1], [1, 3, 1], [1, 4, 1], [1, 5, 1]],maxMoves = 5,n = 6) == 15\n assert candidate(edges = [[0, 1, 2], [0, 2, 4], [0, 3, 3], [1, 2, 1], [1, 3, 2], [2, 3, 5], [3, 4, 2], [4, 5, 3], [5, 6, 4], [6, 7, 1]],maxMoves = 25,n = 8) == 35\n assert candidate(edges = [[0, 1, 5], [0, 2, 5], [0, 3, 5], [1, 2, 5], [1, 3, 5], [2, 3, 5]],maxMoves = 10,n = 4) == 34\n assert candidate(edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10]],maxMoves = 55,n = 11) == 56\n assert candidate(edges = [[0, 1, 10], [0, 2, 5], [1, 3, 3], [2, 3, 7], [3, 4, 2]],maxMoves = 20,n = 5) == 32\n assert candidate(edges = [[0, 1, 5], [0, 2, 5], [1, 2, 5], [1, 3, 5], [2, 3, 5], [2, 4, 5], [3, 4, 5], [3, 5, 5], [4, 5, 5]],maxMoves = 10,n = 6) == 30\n assert candidate(edges = [[0, 1, 1000], [0, 2, 1000], [1, 2, 1000], [1, 3, 1000], [2, 3, 1000], [2, 4, 1000], [3, 4, 1000], [3, 5, 1000], [4, 5, 1000]],maxMoves = 3000,n = 6) == 9001\n assert candidate(edges = [[0, 1, 3], [0, 2, 2], [0, 3, 1], [1, 4, 2], [2, 5, 3], [3, 6, 4], [4, 7, 1], [5, 8, 2], [6, 9, 3]],maxMoves = 20,n = 10) == 31\n assert candidate(edges = [[0, 1, 2], [0, 2, 2], [0, 3, 2], [1, 2, 2], [1, 3, 2], [2, 3, 2], [0, 4, 2], [1, 4, 2], [2, 4, 2], [3, 4, 2]],maxMoves = 3,n = 5) == 13\n assert candidate(edges = [[0, 1, 10], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 3], [3, 4, 7]],maxMoves = 20,n = 5) == 33\n assert candidate(edges = [[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, 0]],maxMoves = 5,n = 11) == 6\n assert candidate(edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],maxMoves = 5,n = 10) == 6\n assert candidate(edges = [[0, 1, 1000], [0, 2, 1000], [1, 3, 1000], [1, 4, 1000], [2, 5, 1000], [2, 6, 1000], [3, 7, 1000], [4, 8, 1000], [5, 9, 1000], [6, 10, 1000], [7, 11, 1000], [8, 12, 1000], [9, 13, 1000], [10, 14, 1000], [11, 15, 1000], [12, 16, 1000], [13, 17, 1000], [14, 18, 1000], [15, 19, 1000]],maxMoves = 10000,n = 20) == 19020\n assert candidate(edges = [[0, 1, 4], [1, 2, 6], [0, 2, 8], [1, 3, 1], [3, 4, 2], [4, 5, 7]],maxMoves = 20,n = 6) == 34\n assert candidate(edges = [[0, 1, 10], [0, 2, 5], [1, 2, 5], [1, 3, 3], [2, 3, 2], [2, 4, 4], [3, 4, 5]],maxMoves = 15,n = 5) == 39\n", "comparison": "exact"}, "public_tests": ["[[0,1,10],[0,2,1],[1,2,2]]\n6\n3", "[[0,1,4],[1,2,6],[0,2,8],[1,3,1]]\n10\n4", "[[1,2,4],[1,4,5],[1,3,1],[2,3,4],[3,4,5]]\n17\n5"], "hints": [], "metadata": {"canonical_parameter_names": ["edges", "maxMoves", "n"], "leetcode_dataset_entry_point": "Solution().reachableNodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:01+00:00", "tests_total": 103, "tests_dropped": 31, "flags": ["figure_reference", "has_images"], "topic_tags": ["graph", "heap-priority-queue", "shortest-path", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def reachableNodes(self, edges: list[list[int]], maxMoves: int, n: int) -> int:", "container": "Solution", "callable": "reachableNodes", "parameters": [{"name": "edges", "type": "list[list[int]]"}, {"name": "maxMoves", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 883, "task_id": "projection-area-of-3d-shapes", "difficulty": "Easy", "problem_description": "You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes.\n\nEach value v = grid[i][j] represents a tower of v cubes placed on top of the cell (i, j).\n\nWe view the projection of these cubes onto the xy, yz, and zx planes.\n\nA projection is like a shadow, that maps our 3-dimensional figure to a 2-dimensional plane. We are viewing the \"shadow\" when looking at the cubes from the top, the front, and the side.\n\nReturn the total area of all three projections.\n\nExample 1:\n\nInput: grid = [[1,2],[3,4]]\nOutput: 17\nExplanation: Here are the three projections (\"shadows\") of the shape made with each axis-aligned plane.\n\nExample 2:\n\nInput: grid = [[2]]\nOutput: 5\n\nExample 3:\n\nInput: grid = [[1,0],[0,2]]\nOutput: 8\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 1 <= n <= 50\n- 0 <= grid[i][j] <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[2, 2, 2], [2, 1, 2], [2, 2, 2]]) == 21\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 14\n assert candidate(grid = [[2]]) == 5\n assert candidate(grid = [[1, 2], [3, 4]]) == 17\n assert candidate(grid = [[1, 0], [0, 2]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 2, 1], [2, 1, 0, 2], [1, 0, 2, 1], [2, 1, 0, 2]]) == 27\n assert candidate(grid = [[5, 0, 0, 1], [0, 5, 0, 2], [0, 0, 5, 3], [1, 2, 3, 4]]) == 48\n assert candidate(grid = [[1, 0, 2, 0, 1], [0, 0, 0, 0, 0], [2, 0, 1, 0, 2], [0, 0, 0, 0, 0], [1, 0, 2, 0, 1]]) == 21\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [5, 3, 1, 3, 5], [1, 5, 3, 5, 1]]) == 75\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 56\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 0, 3, 2, 4], [2, 3, 0, 4, 1], [3, 2, 4, 0, 2], [4, 4, 1, 2, 0]]) == 60\n assert candidate(grid = [[4, 3, 2], [3, 2, 1], [2, 1, 0]]) == 26\n assert candidate(grid = [[4, 1, 1, 1], [1, 4, 1, 1], [1, 1, 4, 1], [1, 1, 1, 4]]) == 48\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 15\n assert candidate(grid = [[3, 0, 1], [1, 2, 3], [4, 5, 6]]) == 35\n assert candidate(grid = [[3, 0, 0, 0], [0, 2, 0, 0], [0, 0, 4, 0], [0, 0, 0, 1]]) == 24\n assert candidate(grid = [[9, 0, 0, 0], [0, 9, 0, 0], [0, 0, 9, 0], [0, 0, 0, 9]]) == 76\n assert candidate(grid = [[10, 5, 5, 3], [4, 7, 6, 2], [1, 3, 4, 0], [3, 1, 2, 5]]) == 69\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == 80\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 9\n assert candidate(grid = [[0, 0, 5, 0, 0], [0, 0, 5, 0, 0], [5, 5, 5, 5, 5], [0, 0, 5, 0, 0], [0, 0, 5, 0, 0]]) == 59\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 11\n assert candidate(grid = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]]) == 40\n assert candidate(grid = [[10, 10, 10], [10, 1, 10], [10, 10, 10]]) == 69\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 15\n assert candidate(grid = [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 51\n assert candidate(grid = [[3, 0, 0, 0], [0, 3, 0, 0], [0, 0, 3, 0], [0, 0, 0, 3]]) == 28\n assert candidate(grid = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]]) == 40\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == 80\n assert candidate(grid = [[5, 0, 0, 0, 0], [0, 5, 0, 0, 0], [0, 0, 5, 0, 0], [0, 0, 0, 5, 0], [0, 0, 0, 0, 5]]) == 55\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [4, 2, 1, 2, 4], [2, 4, 2, 4, 2]]) == 71\n assert candidate(grid = [[10, 10, 10], [10, 0, 10], [10, 10, 10]]) == 68\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]]) == 35\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]]) == 75\n assert candidate(grid = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == 16\n assert candidate(grid = [[5, 0, 0], [0, 5, 0], [0, 0, 5]]) == 33\n assert candidate(grid = [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]]) == 56\n assert candidate(grid = [[5, 8, 3], [3, 7, 2], [6, 4, 1]]) == 47\n assert candidate(grid = [[5, 1, 3], [0, 2, 4], [6, 0, 0]]) == 33\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 5, 2, 4, 3], [3, 4, 1, 5, 2], [2, 1, 4, 3, 5]]) == 74\n assert candidate(grid = [[4, 4, 4], [4, 0, 4], [4, 4, 4]]) == 32\n assert candidate(grid = [[3, 0, 4, 0], [0, 2, 0, 0], [1, 0, 3, 0], [0, 0, 0, 3]]) == 30\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]]) == 55\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [5, 3, 1, 3, 5], [2, 4, 6, 4, 2]]) == 75\n assert candidate(grid = [[3, 1, 4], [1, 5, 9], [2, 6, 5]]) == 46\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 0]]) == 14\n assert candidate(grid = [[10, 0, 0, 0], [0, 20, 0, 0], [0, 0, 30, 0], [0, 0, 0, 40]]) == 204\n assert candidate(grid = [[5, 3, 1], [4, 2, 0], [1, 4, 2]]) == 32\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]]) == 103\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12], [12, 11, 10, 9, 8, 7]]) == 158\n assert candidate(grid = [[0, 1, 2, 3, 4], [5, 4, 3, 2, 1], [4, 5, 6, 7, 8], [3, 2, 1, 0, 9], [2, 3, 4, 5, 6]]) == 87\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == 136\n assert candidate(grid = [[2, 2, 2, 2], [2, 1, 1, 2], [2, 1, 1, 2], [2, 2, 2, 2]]) == 32\n assert candidate(grid = [[3, 0, 3], [0, 4, 0], [3, 0, 3]]) == 25\n assert candidate(grid = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]]) == 105\n assert candidate(grid = [[5, 0, 0], [0, 5, 0], [0, 0, 5]]) == 33\n assert candidate(grid = [[4, 0, 0, 0], [0, 4, 0, 0], [0, 0, 4, 0], [0, 0, 0, 4]]) == 36\n assert candidate(grid = [[3, 0, 0, 3, 3], [0, 2, 0, 0, 0], [0, 0, 4, 0, 0], [3, 0, 0, 3, 3], [3, 0, 0, 3, 3]]) == 41\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, 1]]) == 19\n assert candidate(grid = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]) == 21\n assert candidate(grid = [[4, 0, 0], [0, 0, 0], [0, 0, 4]]) == 18\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 12\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, 4], [2, 1, 0, 4, 3], [1, 0, 4, 3, 2]]) == 63\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 24\n assert candidate(grid = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 2, 3, 4], [8, 7, 6, 5]]) == 72\n assert candidate(grid = [[5, 0, 0, 0], [0, 5, 0, 0], [0, 0, 5, 0], [0, 0, 0, 5]]) == 44\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 51\n assert candidate(grid = [[3, 1, 4], [2, 5, 6], [7, 8, 9]]) == 52\n assert candidate(grid = [[0, 1, 2, 3], [3, 2, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 28\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50]]) == 249\n", "comparison": "exact"}, "public_tests": ["[[1,2],[3,4]]", "[[2]]", "[[1,0],[0,2]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().projectionArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:03+00:00", "tests_total": 72, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry", "matrix"]}, "language": "python", "interface": {"raw_signature": "def projectionArea(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "projectionArea", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 884, "task_id": "uncommon-words-from-two-sentences", "difficulty": "Easy", "problem_description": "A sentence is a string of single-space separated words where each word consists only of lowercase letters.\n\nA word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.\n\nGiven two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order.\n\nExample 1:\n\nInput: s1 = \"this apple is sweet\", s2 = \"this apple is sour\"\nOutput: [\"sweet\",\"sour\"]\nExplanation:\nThe word \"sweet\" appears only in s1, while the word \"sour\" appears only in s2.\n\nExample 2:\n\nInput: s1 = \"apple apple\", s2 = \"banana\"\nOutput: [\"banana\"]\n\nConstraints:\n\n- 1 <= s1.length, s2.length <= 200\n- s1 and s2 consist of lowercase English letters and spaces.\n- s1 and s2 do not have leading or trailing spaces.\n- All the words in s1 and s2 are separated by a single space.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(s1='overlap words here', s2='words here'), ['overlap'])\n assert answers_match(candidate(s1='hello world', s2='hold the door'), ['hello', 'world', 'hold', 'the', 'door'])\n assert answers_match(candidate(s1='hello world', s2='hello there'), ['world', 'there'])\n assert answers_match(candidate(s1='cat dog', s2='fish bird'), ['cat', 'dog', 'fish', 'bird'])\n assert answers_match(candidate(s1='unique words here', s2='some unique there'), ['words', 'here', 'some', 'there'])\n assert answers_match(candidate(s1='unique words', s2='different words'), ['unique', 'different'])\n assert answers_match(candidate(s1='single', s2='word'), ['single', 'word'])\n assert answers_match(candidate(s1='one two three', s2='four five six'), ['one', 'two', 'three', 'four', 'five', 'six'])\n assert answers_match(candidate(s1='same same', s2='same same'), [])\n assert answers_match(candidate(s1='apple apple', s2='banana'), ['banana'])\n assert answers_match(candidate(s1='a b c', s2='d e f'), ['a', 'b', 'c', 'd', 'e', 'f'])\n assert answers_match(candidate(s1='hello world', s2='world is great'), ['hello', 'is', 'great'])\n assert answers_match(candidate(s1='a b c', s2='a b d'), ['c', 'd'])\n assert answers_match(candidate(s1='a b c d', s2='d e f g'), ['a', 'b', 'c', 'e', 'f', 'g'])\n assert answers_match(candidate(s1='one two three', s2='three two one'), [])\n assert answers_match(candidate(s1='this apple is sweet', s2='this apple is sour'), ['sweet', 'sour'])\n assert answers_match(candidate(s1='hello from the other side', s2='hello from this side'), ['the', 'other', 'this'])\n assert answers_match(candidate(s1='long sentence with multiple occurrences of words', s2='words occurrences sentence'), ['long', 'with', 'multiple', 'of'])\n assert answers_match(candidate(s1='shared unique shared', s2='unique shared unique'), [])\n assert answers_match(candidate(s1='abc def ghi jkl mno pqr stu vwx yz', s2='stu vwx yz abc def ghi jkl mno pqr'), [])\n assert answers_match(candidate(s1='python is great', s2='great language python'), ['is', 'language'])\n assert answers_match(candidate(s1='alpha beta gamma', s2='delta epsilon zeta'), ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta'])\n assert answers_match(candidate(s1='common common words in both', s2='common words in both sentences'), ['sentences'])\n assert answers_match(candidate(s1='repeat repeat repeat repeat', s2='single'), ['single'])\n assert answers_match(candidate(s1='hello world from python', s2='hello world from java'), ['python', 'java'])\n assert answers_match(candidate(s1='same same same same', s2='same'), [])\n assert answers_match(candidate(s1='multiple words in a sentence', s2='multiple unique words'), ['in', 'a', 'sentence', 'unique'])\n assert answers_match(candidate(s1='alpha beta gamma delta', s2='delta epsilon zeta'), ['alpha', 'beta', 'gamma', 'epsilon', 'zeta'])\n assert answers_match(candidate(s1='repeated repeated words', s2='words words repeated'), [])\n assert answers_match(candidate(s1='repeated repeated repeated', s2='unique word'), ['unique', 'word'])\n assert answers_match(candidate(s1='unique words only here', s2='completely different set of words'), ['unique', 'only', 'here', 'completely', 'different', 'set', 'of'])\n assert answers_match(candidate(s1='one two three four five six seven eight nine ten eleven twelve', s2='twelve eleven ten nine eight seven six five four three two one'), [])\n assert answers_match(candidate(s1='one two one', s2='three two three'), [])\n assert answers_match(candidate(s1='apple orange banana', s2='banana orange grape'), ['apple', 'grape'])\n assert answers_match(candidate(s1='a quick brown fox jumps over the lazy dog', s2='the quick brown dog jumps over a lazy'), ['fox'])\n assert answers_match(candidate(s1='common words appear here', s2='here common words appear'), [])\n assert answers_match(candidate(s1='common common common', s2='uncommon'), ['uncommon'])\n assert answers_match(candidate(s1='single', s2='different'), ['single', 'different'])\n assert answers_match(candidate(s1='one two three four five six seven eight nine ten', s2='ten nine eight seven six five four three two one'), [])\n assert answers_match(candidate(s1='overlap this is a test', s2='this is another test'), ['overlap', 'a', 'another'])\n assert answers_match(candidate(s1='longer sentence with many uncommon words', s2='many uncommon words longer sentence'), ['with'])\n assert answers_match(candidate(s1='common words in both', s2='common words in both'), [])\n assert answers_match(candidate(s1='abc def ghi jkl mno pqr stu vwx yza', s2='stu vwx yza abc def ghi jkl'), ['mno', 'pqr'])\n assert answers_match(candidate(s1='python java cplusplus', s2='java csharp python'), ['cplusplus', 'csharp'])\n assert answers_match(candidate(s1='same same same', s2='different different different'), [])\n assert answers_match(candidate(s1='hello world hello', s2='world world'), [])\n assert answers_match(candidate(s1='test test test', s2='unique test'), ['unique'])\n assert answers_match(candidate(s1='distinct words only', s2='entirely distinct words'), ['only', 'entirely'])\n assert answers_match(candidate(s1='repeated repeated words', s2='unique words in second sentence'), ['unique', 'in', 'second', 'sentence'])\n assert answers_match(candidate(s1='test test test', s2='test test test test'), [])\n assert answers_match(candidate(s1='single', s2='unique'), ['single', 'unique'])\n assert answers_match(candidate(s1='repeated repeated word', s2='word unique'), ['unique'])\n assert answers_match(candidate(s1='unique word in first sentence', s2='unique word in second sentence'), ['first', 'second'])\n assert answers_match(candidate(s1='many many words in this sentence', s2='many words'), ['in', 'this', 'sentence'])\n assert answers_match(candidate(s1='unique words only', s2='completely different set'), ['unique', 'words', 'only', 'completely', 'different', 'set'])\n assert answers_match(candidate(s1='unique words only', s2='different set words'), ['unique', 'only', 'different', 'set'])\n assert answers_match(candidate(s1='this is a test', s2='this is another test'), ['a', 'another'])\n assert answers_match(candidate(s1='same same same', s2='same'), [])\n assert answers_match(candidate(s1='unique word in sentence one', s2='unique word in sentence two'), ['one', 'two'])\n assert answers_match(candidate(s1='multiple words are present', s2='multiple words are missing'), ['present', 'missing'])\n assert answers_match(candidate(s1='overlap words in both', s2='overlap words in both'), [])\n assert answers_match(candidate(s1='longer sentence with more words', s2='shorter with'), ['longer', 'sentence', 'more', 'words', 'shorter'])\n assert answers_match(candidate(s1='identical identical identical', s2='identical identical identical'), [])\n assert answers_match(candidate(s1='this is a test sentence', s2='sentence is a this'), ['test'])\n assert answers_match(candidate(s1='common common words in both', s2='common words'), ['in', 'both'])\n assert answers_match(candidate(s1='overlapping words in both', s2='overlapping words in both'), [])\n assert answers_match(candidate(s1='repeated repeated words here', s2='different words here'), ['different'])\n assert answers_match(candidate(s1='distinctive words in each sentence', s2='each sentence has distinctive words'), ['in', 'has'])\n assert answers_match(candidate(s1='a a a b 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', s2='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 answers_match(candidate(s1='a b c d e f g h i j', s2='k l m n o p q r s t'), ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'])\n assert answers_match(candidate(s1='unique words only here', s2='unique words are everywhere'), ['only', 'here', 'are', 'everywhere'])\n assert answers_match(candidate(s1='one two three four five six', s2='six five four three two one'), [])\n assert answers_match(candidate(s1='longer sentence with multiple uncommon words here', s2='here are some uncommon words'), ['longer', 'sentence', 'with', 'multiple', 'are', 'some'])\n assert answers_match(candidate(s1='first sentence here', s2='second unique sentence'), ['first', 'here', 'second', 'unique'])\n assert answers_match(candidate(s1='same same same same', s2='different different'), [])\n assert answers_match(candidate(s1='unique words in each sentence', s2='other unique words'), ['in', 'each', 'sentence', 'other'])\n assert answers_match(candidate(s1='common words and unique', s2='unique words and common'), [])\n assert answers_match(candidate(s1='shared words words', s2='words shared'), [])\n assert answers_match(candidate(s1='overlap overlap words', s2='words overlap'), [])\n assert answers_match(candidate(s1='some common words here', s2='here some unique'), ['common', 'words', 'unique'])\n assert answers_match(candidate(s1='unique word only', s2='entirely different'), ['unique', 'word', 'only', 'entirely', 'different'])\n assert answers_match(candidate(s1='multiple multiple words in first', s2='words in second'), ['first', 'second'])\n assert answers_match(candidate(s1='repeated repeated words', s2='unique single'), ['words', 'unique', 'single'])\n assert answers_match(candidate(s1='one two three four five', s2='six seven eight nine ten'), ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'])\n assert answers_match(candidate(s1='complexity in first', s2='complexity in second'), ['first', 'second'])\n assert answers_match(candidate(s1='same same same', s2='same same'), [])\n assert answers_match(candidate(s1='no overlap', s2='no common words'), ['overlap', 'common', 'words'])\n assert answers_match(candidate(s1='shared words shared', s2='shared words unique'), ['unique'])\n assert answers_match(candidate(s1='common word common', s2='word common unique'), ['unique'])\n assert answers_match(candidate(s1='shared words are common', s2='common shared words'), ['are'])\n assert answers_match(candidate(s1='singleword', s2='singleword'), [])\n assert answers_match(candidate(s1='a a a a a a a a a a', s2='b b b b b b b b b b'), [])\n assert answers_match(candidate(s1='repeated repeated repeated', s2='repeated unique'), ['unique'])\n assert answers_match(candidate(s1='hello world hello', s2='world hello universe'), ['universe'])\n assert answers_match(candidate(s1='repeated repeated word', s2='word'), [])\n assert answers_match(candidate(s1='common words in both sentences', s2='common words in both sentences'), [])\n assert answers_match(candidate(s1='a b c d e f g h i j', s2='j i h g f e d c b a'), [])\n assert answers_match(candidate(s1='overlap overlap here', s2='here overlap'), [])\n assert answers_match(candidate(s1='exclusive to first', s2='exclusive to second'), ['first', 'second'])\n assert answers_match(candidate(s1='multiple unique words here', s2='here multiple'), ['unique', 'words'])\n assert answers_match(candidate(s1='one two three four', s2='five six seven eight'), ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'])\n assert answers_match(candidate(s1='singleword', s2='differentword'), ['singleword', 'differentword'])\n assert answers_match(candidate(s1='unique words only', s2='completely different'), ['unique', 'words', 'only', 'completely', 'different'])\n assert answers_match(candidate(s1='a b c d e', s2='f g h i j'), ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'])\n assert answers_match(candidate(s1='overlap words here and there', s2='there and words'), ['overlap', 'here'])\n assert answers_match(candidate(s1='apple banana cherry', s2='banana cherry date'), ['apple', 'date'])\n assert answers_match(candidate(s1='a b c d e f g', s2='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 answers_match(candidate(s1='uncommon word one', s2='uncommon word two'), ['one', 'two'])\n assert answers_match(candidate(s1='single', s2='single single'), [])\n assert answers_match(candidate(s1='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', s2='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 answers_match(candidate(s1='repeated repeated repeated', s2='unique'), ['unique'])\n assert answers_match(candidate(s1='a b c d e f g', s2='h i j k l m n'), ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'])\n assert answers_match(candidate(s1='longer sentence with more words included', s2='included more words with longer sentence'), [])\n assert answers_match(candidate(s1='overlap many words here', s2='many words overlap'), ['here'])\n assert answers_match(candidate(s1='singleword', s2='different'), ['singleword', 'different'])\n assert answers_match(candidate(s1='multiple same words here and here', s2='here and'), ['multiple', 'same', 'words'])\n assert answers_match(candidate(s1='python programming language', s2='programming language for python'), ['for'])\n assert answers_match(candidate(s1='abc def ghi jkl mno', s2='pqr stu vwx yza'), ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yza'])\n assert answers_match(candidate(s1='single', s2='single unique'), ['unique'])\n assert answers_match(candidate(s1='many different words in this sentence', s2='completely different words in this sentence'), ['many', 'completely'])\n assert answers_match(candidate(s1='common words overlap', s2='overlap common words'), [])\n", "comparison": "unordered"}, "public_tests": ["\"this apple is sweet\"\n\"this apple is sour\"", "\"apple apple\"\n\"banana\""], "hints": [], "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().uncommonFromSentences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:05+00:00", "tests_total": 130, "tests_dropped": 9, "flags": ["any_order"], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def uncommonFromSentences(self, s1: str, s2: str) -> list[str]:", "container": "Solution", "callable": "uncommonFromSentences", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 885, "task_id": "spiral-matrix-iii", "difficulty": "Medium", "problem_description": "You start at the cell (rStart, cStart) of an rows x cols grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column.\n\nYou will walk in a clockwise spiral shape to visit every position in this grid. Whenever you move outside the grid's boundary, we continue our walk outside the grid (but may return to the grid boundary later.). Eventually, we reach all rows * cols spaces of the grid.\n\nReturn an array of coordinates representing the positions of the grid in the order you visited them.\n\nExample 1:\n\nInput: rows = 1, cols = 4, rStart = 0, cStart = 0\nOutput: [[0,0],[0,1],[0,2],[0,3]]\n\nExample 2:\n\nInput: rows = 5, cols = 6, rStart = 1, cStart = 4\nOutput: [[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]\n\nConstraints:\n\n- 1 <= rows, cols <= 100\n- 0 <= rStart < rows\n- 0 <= cStart < cols\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rows = 5,cols = 6,rStart = 1,cStart = 4) == [[1, 4], [1, 5], [2, 5], [2, 4], [2, 3], [1, 3], [0, 3], [0, 4], [0, 5], [3, 5], [3, 4], [3, 3], [3, 2], [2, 2], [1, 2], [0, 2], [4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 3,cols = 3,rStart = 1,cStart = 1) == [[1, 1], [1, 2], [2, 2], [2, 1], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2]]\n assert candidate(rows = 10,cols = 10,rStart = 5,cStart = 5) == [[5, 5], [5, 6], [6, 6], [6, 5], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [5, 7], [6, 7], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]\n assert candidate(rows = 1,cols = 4,rStart = 0,cStart = 0) == [[0, 0], [0, 1], [0, 2], [0, 3]]\n assert candidate(rows = 7,cols = 8,rStart = 3,cStart = 2) == [[3, 2], [3, 3], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [3, 4], [4, 4], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]\n assert candidate(rows = 4,cols = 4,rStart = 2,cStart = 2) == [[2, 2], [2, 3], [3, 3], [3, 2], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3]]\n assert candidate(rows = 2,cols = 3,rStart = 0,cStart = 1) == [[0, 1], [0, 2], [1, 2], [1, 1], [1, 0], [0, 0]]\n assert candidate(rows = 15,cols = 20,rStart = 10,cStart = 10) == [[10, 10], [10, 11], [11, 11], [11, 10], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [10, 12], [11, 12], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [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], [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], [3, 19], [4, 19], [5, 19], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19], [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], [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], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19]]\n assert candidate(rows = 9,cols = 9,rStart = 8,cStart = 8) == [[8, 8], [8, 7], [7, 7], [7, 8], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8]]\n assert candidate(rows = 30,cols = 30,rStart = 29,cStart = 29) == [[29, 29], [29, 28], [28, 28], [28, 29], [29, 27], [28, 27], [27, 27], [27, 28], [27, 29], [29, 26], [28, 26], [27, 26], [26, 26], [26, 27], [26, 28], [26, 29], [29, 25], [28, 25], [27, 25], [26, 25], [25, 25], [25, 26], [25, 27], [25, 28], [25, 29], [29, 24], [28, 24], [27, 24], [26, 24], [25, 24], [24, 24], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [29, 23], [28, 23], [27, 23], [26, 23], [25, 23], [24, 23], [23, 23], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [29, 22], [28, 22], [27, 22], [26, 22], [25, 22], [24, 22], [23, 22], [22, 22], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [29, 21], [28, 21], [27, 21], [26, 21], [25, 21], [24, 21], [23, 21], [22, 21], [21, 21], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [29, 20], [28, 20], [27, 20], [26, 20], [25, 20], [24, 20], [23, 20], [22, 20], [21, 20], [20, 20], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [29, 19], [28, 19], [27, 19], [26, 19], [25, 19], [24, 19], [23, 19], [22, 19], [21, 19], [20, 19], [19, 19], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [29, 18], [28, 18], [27, 18], [26, 18], [25, 18], [24, 18], [23, 18], [22, 18], [21, 18], [20, 18], [19, 18], [18, 18], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [29, 17], [28, 17], [27, 17], [26, 17], [25, 17], [24, 17], [23, 17], [22, 17], [21, 17], [20, 17], [19, 17], [18, 17], [17, 17], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [29, 16], [28, 16], [27, 16], [26, 16], [25, 16], [24, 16], [23, 16], [22, 16], [21, 16], [20, 16], [19, 16], [18, 16], [17, 16], [16, 16], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [29, 15], [28, 15], [27, 15], [26, 15], [25, 15], [24, 15], [23, 15], [22, 15], [21, 15], [20, 15], [19, 15], [18, 15], [17, 15], [16, 15], [15, 15], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [29, 14], [28, 14], [27, 14], [26, 14], [25, 14], [24, 14], [23, 14], [22, 14], [21, 14], [20, 14], [19, 14], [18, 14], [17, 14], [16, 14], [15, 14], [14, 14], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [29, 13], [28, 13], [27, 13], [26, 13], [25, 13], [24, 13], [23, 13], [22, 13], [21, 13], [20, 13], [19, 13], [18, 13], [17, 13], [16, 13], [15, 13], [14, 13], [13, 13], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [29, 12], [28, 12], [27, 12], [26, 12], [25, 12], [24, 12], [23, 12], [22, 12], [21, 12], [20, 12], [19, 12], [18, 12], [17, 12], [16, 12], [15, 12], [14, 12], [13, 12], [12, 12], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [29, 11], [28, 11], [27, 11], [26, 11], [25, 11], [24, 11], [23, 11], [22, 11], [21, 11], [20, 11], [19, 11], [18, 11], [17, 11], [16, 11], [15, 11], [14, 11], [13, 11], [12, 11], [11, 11], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [29, 10], [28, 10], [27, 10], [26, 10], [25, 10], [24, 10], [23, 10], [22, 10], [21, 10], [20, 10], [19, 10], [18, 10], [17, 10], [16, 10], [15, 10], [14, 10], [13, 10], [12, 10], [11, 10], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [29, 9], [28, 9], [27, 9], [26, 9], [25, 9], [24, 9], [23, 9], [22, 9], [21, 9], [20, 9], [19, 9], [18, 9], [17, 9], [16, 9], [15, 9], [14, 9], [13, 9], [12, 9], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [29, 8], [28, 8], [27, 8], [26, 8], [25, 8], [24, 8], [23, 8], [22, 8], [21, 8], [20, 8], [19, 8], [18, 8], [17, 8], [16, 8], [15, 8], [14, 8], [13, 8], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [29, 7], [28, 7], [27, 7], [26, 7], [25, 7], [24, 7], [23, 7], [22, 7], [21, 7], [20, 7], [19, 7], [18, 7], [17, 7], [16, 7], [15, 7], [14, 7], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [29, 6], [28, 6], [27, 6], [26, 6], [25, 6], [24, 6], [23, 6], [22, 6], [21, 6], [20, 6], [19, 6], [18, 6], [17, 6], [16, 6], [15, 6], [14, 6], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [29, 5], [28, 5], [27, 5], [26, 5], [25, 5], [24, 5], [23, 5], [22, 5], [21, 5], [20, 5], [19, 5], [18, 5], [17, 5], [16, 5], [15, 5], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [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, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [29, 4], [28, 4], [27, 4], [26, 4], [25, 4], [24, 4], [23, 4], [22, 4], [21, 4], [20, 4], [19, 4], [18, 4], [17, 4], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [29, 3], [28, 3], [27, 3], [26, 3], [25, 3], [24, 3], [23, 3], [22, 3], [21, 3], [20, 3], [19, 3], [18, 3], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [29, 2], [28, 2], [27, 2], [26, 2], [25, 2], [24, 2], [23, 2], [22, 2], [21, 2], [20, 2], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [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], [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], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [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], [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], [29, 0], [28, 0], [27, 0], [26, 0], [25, 0], [24, 0], [23, 0], [22, 0], [21, 0], [20, 0], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29]]\n assert candidate(rows = 20,cols = 10,rStart = 15,cStart = 5) == [[15, 5], [15, 6], [16, 6], [16, 5], [16, 4], [15, 4], [14, 4], [14, 5], [14, 6], [14, 7], [15, 7], [16, 7], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [13, 4], [13, 5], [13, 6], [13, 7], [13, 8], [14, 8], [15, 8], [16, 8], [17, 8], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [18, 2], [17, 2], [16, 2], [15, 2], [14, 2], [13, 2], [12, 2], [12, 3], [12, 4], [12, 5], [12, 6], [12, 7], [12, 8], [12, 9], [13, 9], [14, 9], [15, 9], [16, 9], [17, 9], [18, 9], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [19, 1], [18, 1], [17, 1], [16, 1], [15, 1], [14, 1], [13, 1], [12, 1], [11, 1], [11, 2], [11, 3], [11, 4], [11, 5], [11, 6], [11, 7], [11, 8], [11, 9], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]\n assert candidate(rows = 4,cols = 8,rStart = 2,cStart = 3) == [[2, 3], [2, 4], [3, 4], [3, 3], [3, 2], [2, 2], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [3, 1], [2, 1], [1, 1], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 6], [2, 6], [3, 6], [3, 0], [2, 0], [1, 0], [0, 0], [0, 7], [1, 7], [2, 7], [3, 7]]\n assert candidate(rows = 9,cols = 6,rStart = 4,cStart = 2) == [[4, 2], [4, 3], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [3, 2], [3, 3], [3, 4], [4, 4], [5, 4], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]\n assert candidate(rows = 14,cols = 14,rStart = 13,cStart = 13) == [[13, 13], [13, 12], [12, 12], [12, 13], [13, 11], [12, 11], [11, 11], [11, 12], [11, 13], [13, 10], [12, 10], [11, 10], [10, 10], [10, 11], [10, 12], [10, 13], [13, 9], [12, 9], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [13, 8], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [13, 2], [12, 2], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [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], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13]]\n assert candidate(rows = 7,cols = 7,rStart = 3,cStart = 3) == [[3, 3], [3, 4], [4, 4], [4, 3], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6]]\n assert candidate(rows = 15,cols = 20,rStart = 14,cStart = 0) == [[14, 0], [14, 1], [13, 0], [13, 1], [13, 2], [14, 2], [12, 0], [12, 1], [12, 2], [12, 3], [13, 3], [14, 3], [11, 0], [11, 1], [11, 2], [11, 3], [11, 4], [12, 4], [13, 4], [14, 4], [10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [10, 6], [11, 6], [12, 6], [13, 6], [14, 6], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [9, 7], [10, 7], [11, 7], [12, 7], [13, 7], [14, 7], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [8, 8], [9, 8], [10, 8], [11, 8], [12, 8], [13, 8], [14, 8], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [7, 9], [8, 9], [9, 9], [10, 9], [11, 9], [12, 9], [13, 9], [14, 9], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [12, 11], [13, 11], [14, 11], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 12], [13, 12], [14, 12], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [14, 13], [1, 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], [2, 14], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [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], [0, 16], [1, 16], [2, 16], [3, 16], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [0, 17], [1, 17], [2, 17], [3, 17], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [0, 18], [1, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [0, 19], [1, 19], [2, 19], [3, 19], [4, 19], [5, 19], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]\n assert candidate(rows = 9,cols = 18,rStart = 4,cStart = 8) == [[4, 8], [4, 9], [5, 9], [5, 8], [5, 7], [4, 7], [3, 7], [3, 8], [3, 9], [3, 10], [4, 10], [5, 10], [6, 10], [6, 9], [6, 8], [6, 7], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [7, 10], [7, 9], [7, 8], [7, 7], [7, 6], [7, 5], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [8, 11], [8, 10], [8, 9], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [0, 14], [1, 14], [2, 14], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [0, 15], [1, 15], [2, 15], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [0, 16], [1, 16], [2, 16], [3, 16], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 17], [1, 17], [2, 17], [3, 17], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17]]\n assert candidate(rows = 8,cols = 5,rStart = 2,cStart = 2) == [[2, 2], [2, 3], [3, 3], [3, 2], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0]]\n assert candidate(rows = 8,cols = 3,rStart = 2,cStart = 1) == [[2, 1], [2, 2], [3, 2], [3, 1], [3, 0], [2, 0], [1, 0], [1, 1], [1, 2], [4, 2], [4, 1], [4, 0], [0, 0], [0, 1], [0, 2], [5, 2], [5, 1], [5, 0], [6, 2], [6, 1], [6, 0], [7, 2], [7, 1], [7, 0]]\n assert candidate(rows = 25,cols = 25,rStart = 12,cStart = 12) == [[12, 12], [12, 13], [13, 13], [13, 12], [13, 11], [12, 11], [11, 11], [11, 12], [11, 13], [11, 14], [12, 14], [13, 14], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [13, 10], [12, 10], [11, 10], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [15, 14], [15, 13], [15, 12], [15, 11], [15, 10], [15, 9], [14, 9], [13, 9], [12, 9], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [15, 16], [16, 16], [16, 15], [16, 14], [16, 13], [16, 12], [16, 11], [16, 10], [16, 9], [16, 8], [15, 8], [14, 8], [13, 8], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [15, 17], [16, 17], [17, 17], [17, 16], [17, 15], [17, 14], [17, 13], [17, 12], [17, 11], [17, 10], [17, 9], [17, 8], [17, 7], [16, 7], [15, 7], [14, 7], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [15, 18], [16, 18], [17, 18], [18, 18], [18, 17], [18, 16], [18, 15], [18, 14], [18, 13], [18, 12], [18, 11], [18, 10], [18, 9], [18, 8], [18, 7], [18, 6], [17, 6], [16, 6], [15, 6], [14, 6], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [18, 19], [19, 19], [19, 18], [19, 17], [19, 16], [19, 15], [19, 14], [19, 13], [19, 12], [19, 11], [19, 10], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [18, 5], [17, 5], [16, 5], [15, 5], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [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], [6, 20], [7, 20], [8, 20], [9, 20], [10, 20], [11, 20], [12, 20], [13, 20], [14, 20], [15, 20], [16, 20], [17, 20], [18, 20], [19, 20], [20, 20], [20, 19], [20, 18], [20, 17], [20, 16], [20, 15], [20, 14], [20, 13], [20, 12], [20, 11], [20, 10], [20, 9], [20, 8], [20, 7], [20, 6], [20, 5], [20, 4], [19, 4], [18, 4], [17, 4], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [5, 21], [6, 21], [7, 21], [8, 21], [9, 21], [10, 21], [11, 21], [12, 21], [13, 21], [14, 21], [15, 21], [16, 21], [17, 21], [18, 21], [19, 21], [20, 21], [21, 21], [21, 20], [21, 19], [21, 18], [21, 17], [21, 16], [21, 15], [21, 14], [21, 13], [21, 12], [21, 11], [21, 10], [21, 9], [21, 8], [21, 7], [21, 6], [21, 5], [21, 4], [21, 3], [20, 3], [19, 3], [18, 3], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [4, 22], [5, 22], [6, 22], [7, 22], [8, 22], [9, 22], [10, 22], [11, 22], [12, 22], [13, 22], [14, 22], [15, 22], [16, 22], [17, 22], [18, 22], [19, 22], [20, 22], [21, 22], [22, 22], [22, 21], [22, 20], [22, 19], [22, 18], [22, 17], [22, 16], [22, 15], [22, 14], [22, 13], [22, 12], [22, 11], [22, 10], [22, 9], [22, 8], [22, 7], [22, 6], [22, 5], [22, 4], [22, 3], [22, 2], [21, 2], [20, 2], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [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], [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], [2, 20], [2, 21], [2, 22], [2, 23], [3, 23], [4, 23], [5, 23], [6, 23], [7, 23], [8, 23], [9, 23], [10, 23], [11, 23], [12, 23], [13, 23], [14, 23], [15, 23], [16, 23], [17, 23], [18, 23], [19, 23], [20, 23], [21, 23], [22, 23], [23, 23], [23, 22], [23, 21], [23, 20], [23, 19], [23, 18], [23, 17], [23, 16], [23, 15], [23, 14], [23, 13], [23, 12], [23, 11], [23, 10], [23, 9], [23, 8], [23, 7], [23, 6], [23, 5], [23, 4], [23, 3], [23, 2], [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], [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], [2, 24], [3, 24], [4, 24], [5, 24], [6, 24], [7, 24], [8, 24], [9, 24], [10, 24], [11, 24], [12, 24], [13, 24], [14, 24], [15, 24], [16, 24], [17, 24], [18, 24], [19, 24], [20, 24], [21, 24], [22, 24], [23, 24], [24, 24], [24, 23], [24, 22], [24, 21], [24, 20], [24, 19], [24, 18], [24, 17], [24, 16], [24, 15], [24, 14], [24, 13], [24, 12], [24, 11], [24, 10], [24, 9], [24, 8], [24, 7], [24, 6], [24, 5], [24, 4], [24, 3], [24, 2], [24, 1], [24, 0], [23, 0], [22, 0], [21, 0], [20, 0], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24]]\n assert candidate(rows = 12,cols = 12,rStart = 6,cStart = 6) == [[6, 6], [6, 7], [7, 7], [7, 6], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [6, 8], [7, 8], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11]]\n assert candidate(rows = 12,cols = 7,rStart = 6,cStart = 3) == [[6, 3], [6, 4], [7, 4], [7, 3], [7, 2], [6, 2], [5, 2], [5, 3], [5, 4], [5, 5], [6, 5], [7, 5], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 6], [6, 6], [7, 6], [8, 6], [9, 6], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [11, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6]]\n assert candidate(rows = 8,cols = 5,rStart = 0,cStart = 4) == [[0, 4], [1, 4], [1, 3], [0, 3], [2, 4], [2, 3], [2, 2], [1, 2], [0, 2], [3, 4], [3, 3], [3, 2], [3, 1], [2, 1], [1, 1], [0, 1], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0]]\n assert candidate(rows = 7,cols = 7,rStart = 3,cStart = 4) == [[3, 4], [3, 5], [4, 5], [4, 4], [4, 3], [3, 3], [2, 3], [2, 4], [2, 5], [2, 6], [3, 6], [4, 6], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 12,cols = 15,rStart = 0,cStart = 14) == [[0, 14], [1, 14], [1, 13], [0, 13], [2, 14], [2, 13], [2, 12], [1, 12], [0, 12], [3, 14], [3, 13], [3, 12], [3, 11], [2, 11], [1, 11], [0, 11], [4, 14], [4, 13], [4, 12], [4, 11], [4, 10], [3, 10], [2, 10], [1, 10], [0, 10], [5, 14], [5, 13], [5, 12], [5, 11], [5, 10], [5, 9], [4, 9], [3, 9], [2, 9], [1, 9], [0, 9], [6, 14], [6, 13], [6, 12], [6, 11], [6, 10], [6, 9], [6, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8], [7, 14], [7, 13], [7, 12], [7, 11], [7, 10], [7, 9], [7, 8], [7, 7], [6, 7], [5, 7], [4, 7], [3, 7], [2, 7], [1, 7], [0, 7], [8, 14], [8, 13], [8, 12], [8, 11], [8, 10], [8, 9], [8, 8], [8, 7], [8, 6], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [1, 6], [0, 6], [9, 14], [9, 13], [9, 12], [9, 11], [9, 10], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [0, 5], [10, 14], [10, 13], [10, 12], [10, 11], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [11, 14], [11, 13], [11, 12], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [11, 1], [10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 3,cols = 7,rStart = 1,cStart = 3) == [[1, 3], [1, 4], [2, 4], [2, 3], [2, 2], [1, 2], [0, 2], [0, 3], [0, 4], [0, 5], [1, 5], [2, 5], [2, 1], [1, 1], [0, 1], [0, 6], [1, 6], [2, 6], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 11,cols = 11,rStart = 2,cStart = 2) == [[2, 2], [2, 3], [3, 3], [3, 2], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0], [0, 8], [1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0], [0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [9, 0], [0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0]]\n assert candidate(rows = 8,cols = 3,rStart = 4,cStart = 1) == [[4, 1], [4, 2], [5, 2], [5, 1], [5, 0], [4, 0], [3, 0], [3, 1], [3, 2], [6, 2], [6, 1], [6, 0], [2, 0], [2, 1], [2, 2], [7, 2], [7, 1], [7, 0], [1, 0], [1, 1], [1, 2], [0, 0], [0, 1], [0, 2]]\n assert candidate(rows = 1,cols = 10,rStart = 0,cStart = 5) == [[0, 5], [0, 6], [0, 4], [0, 7], [0, 3], [0, 8], [0, 2], [0, 9], [0, 1], [0, 0]]\n assert candidate(rows = 20,cols = 15,rStart = 0,cStart = 14) == [[0, 14], [1, 14], [1, 13], [0, 13], [2, 14], [2, 13], [2, 12], [1, 12], [0, 12], [3, 14], [3, 13], [3, 12], [3, 11], [2, 11], [1, 11], [0, 11], [4, 14], [4, 13], [4, 12], [4, 11], [4, 10], [3, 10], [2, 10], [1, 10], [0, 10], [5, 14], [5, 13], [5, 12], [5, 11], [5, 10], [5, 9], [4, 9], [3, 9], [2, 9], [1, 9], [0, 9], [6, 14], [6, 13], [6, 12], [6, 11], [6, 10], [6, 9], [6, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8], [7, 14], [7, 13], [7, 12], [7, 11], [7, 10], [7, 9], [7, 8], [7, 7], [6, 7], [5, 7], [4, 7], [3, 7], [2, 7], [1, 7], [0, 7], [8, 14], [8, 13], [8, 12], [8, 11], [8, 10], [8, 9], [8, 8], [8, 7], [8, 6], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [1, 6], [0, 6], [9, 14], [9, 13], [9, 12], [9, 11], [9, 10], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [0, 5], [10, 14], [10, 13], [10, 12], [10, 11], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [11, 14], [11, 13], [11, 12], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [12, 14], [12, 13], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [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], [13, 14], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [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], [0, 1], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [15, 14], [15, 13], [15, 12], [15, 11], [15, 10], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [15, 4], [15, 3], [15, 2], [15, 1], [15, 0], [16, 14], [16, 13], [16, 12], [16, 11], [16, 10], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [16, 4], [16, 3], [16, 2], [16, 1], [16, 0], [17, 14], [17, 13], [17, 12], [17, 11], [17, 10], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [17, 2], [17, 1], [17, 0], [18, 14], [18, 13], [18, 12], [18, 11], [18, 10], [18, 9], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [18, 2], [18, 1], [18, 0], [19, 14], [19, 13], [19, 12], [19, 11], [19, 10], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [19, 1], [19, 0]]\n assert candidate(rows = 20,cols = 10,rStart = 10,cStart = 5) == [[10, 5], [10, 6], [11, 6], [11, 5], [11, 4], [10, 4], [9, 4], [9, 5], [9, 6], [9, 7], [10, 7], [11, 7], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [9, 8], [10, 8], [11, 8], [12, 8], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [12, 2], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 9], [9, 9], [10, 9], [11, 9], [12, 9], [13, 9], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [13, 1], [12, 1], [11, 1], [10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [15, 4], [15, 3], [15, 2], [15, 1], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [16, 4], [16, 3], [16, 2], [16, 1], [16, 0], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [17, 2], [17, 1], [17, 0], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [18, 9], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [18, 2], [18, 1], [18, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [19, 1], [19, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]\n assert candidate(rows = 6,cols = 6,rStart = 3,cStart = 3) == [[3, 3], [3, 4], [4, 4], [4, 3], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]\n assert candidate(rows = 9,cols = 7,rStart = 2,cStart = 3) == [[2, 3], [2, 4], [3, 4], [3, 3], [3, 2], [2, 2], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0]]\n assert candidate(rows = 18,cols = 18,rStart = 17,cStart = 0) == [[17, 0], [17, 1], [16, 0], [16, 1], [16, 2], [17, 2], [15, 0], [15, 1], [15, 2], [15, 3], [16, 3], [17, 3], [14, 0], [14, 1], [14, 2], [14, 3], [14, 4], [15, 4], [16, 4], [17, 4], [13, 0], [13, 1], [13, 2], [13, 3], [13, 4], [13, 5], [14, 5], [15, 5], [16, 5], [17, 5], [12, 0], [12, 1], [12, 2], [12, 3], [12, 4], [12, 5], [12, 6], [13, 6], [14, 6], [15, 6], [16, 6], [17, 6], [11, 0], [11, 1], [11, 2], [11, 3], [11, 4], [11, 5], [11, 6], [11, 7], [12, 7], [13, 7], [14, 7], [15, 7], [16, 7], [17, 7], [10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [11, 8], [12, 8], [13, 8], [14, 8], [15, 8], [16, 8], [17, 8], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 9], [11, 9], [12, 9], [13, 9], [14, 9], [15, 9], [16, 9], [17, 9], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [12, 11], [13, 11], [14, 11], [15, 11], [16, 11], [17, 11], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 12], [13, 12], [14, 12], [15, 12], [16, 12], [17, 12], [5, 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], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [14, 13], [15, 13], [16, 13], [17, 13], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [15, 14], [16, 14], [17, 14], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [16, 15], [17, 15], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [3, 16], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [15, 16], [16, 16], [17, 16], [1, 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], [2, 17], [3, 17], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [15, 17], [16, 17], [17, 17], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17]]\n assert candidate(rows = 8,cols = 7,rStart = 2,cStart = 3) == [[2, 3], [2, 4], [3, 4], [3, 3], [3, 2], [2, 2], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0]]\n assert candidate(rows = 4,cols = 4,rStart = 1,cStart = 1) == [[1, 1], [1, 2], [2, 2], [2, 1], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [1, 3], [2, 3], [3, 3], [3, 2], [3, 1], [3, 0]]\n assert candidate(rows = 9,cols = 13,rStart = 4,cStart = 12) == [[4, 12], [5, 12], [5, 11], [4, 11], [3, 11], [3, 12], [6, 12], [6, 11], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [2, 11], [2, 12], [7, 12], [7, 11], [7, 10], [7, 9], [6, 9], [5, 9], [4, 9], [3, 9], [2, 9], [1, 9], [1, 10], [1, 11], [1, 12], [8, 12], [8, 11], [8, 10], [8, 9], [8, 8], [7, 8], [6, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [8, 7], [7, 7], [6, 7], [5, 7], [4, 7], [3, 7], [2, 7], [1, 7], [0, 7], [8, 6], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [1, 6], [0, 6], [8, 5], [7, 5], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [0, 5], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 15,cols = 10,rStart = 7,cStart = 5) == [[7, 5], [7, 6], [8, 6], [8, 5], [8, 4], [7, 4], [6, 4], [6, 5], [6, 6], [6, 7], [7, 7], [8, 7], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [6, 8], [7, 8], [8, 8], [9, 8], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [10, 9], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [12, 2], [12, 1], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [13, 1], [13, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]\n assert candidate(rows = 20,cols = 20,rStart = 10,cStart = 10) == [[10, 10], [10, 11], [11, 11], [11, 10], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [10, 12], [11, 12], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [15, 14], [15, 13], [15, 12], [15, 11], [15, 10], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [15, 16], [16, 16], [16, 15], [16, 14], [16, 13], [16, 12], [16, 11], [16, 10], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [15, 17], [16, 17], [17, 17], [17, 16], [17, 15], [17, 14], [17, 13], [17, 12], [17, 11], [17, 10], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [15, 18], [16, 18], [17, 18], [18, 18], [18, 17], [18, 16], [18, 15], [18, 14], [18, 13], [18, 12], [18, 11], [18, 10], [18, 9], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [18, 2], [17, 2], [16, 2], [15, 2], [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], [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], [3, 19], [4, 19], [5, 19], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [18, 19], [19, 19], [19, 18], [19, 17], [19, 16], [19, 15], [19, 14], [19, 13], [19, 12], [19, 11], [19, 10], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [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], [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], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19]]\n assert candidate(rows = 16,cols = 16,rStart = 8,cStart = 8) == [[8, 8], [8, 9], [9, 9], [9, 8], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [8, 10], [9, 10], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [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], [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], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [15, 14], [15, 13], [15, 12], [15, 11], [15, 10], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [15, 4], [15, 3], [15, 2], [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], [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], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15]]\n assert candidate(rows = 50,cols = 50,rStart = 25,cStart = 25) == [[25, 25], [25, 26], [26, 26], [26, 25], [26, 24], [25, 24], [24, 24], [24, 25], [24, 26], [24, 27], [25, 27], [26, 27], [27, 27], [27, 26], [27, 25], [27, 24], [27, 23], [26, 23], [25, 23], [24, 23], [23, 23], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 28], [25, 28], [26, 28], [27, 28], [28, 28], [28, 27], [28, 26], [28, 25], [28, 24], [28, 23], [28, 22], [27, 22], [26, 22], [25, 22], [24, 22], [23, 22], [22, 22], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [23, 29], [24, 29], [25, 29], [26, 29], [27, 29], [28, 29], [29, 29], [29, 28], [29, 27], [29, 26], [29, 25], [29, 24], [29, 23], [29, 22], [29, 21], [28, 21], [27, 21], [26, 21], [25, 21], [24, 21], [23, 21], [22, 21], [21, 21], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [22, 30], [23, 30], [24, 30], [25, 30], [26, 30], [27, 30], [28, 30], [29, 30], [30, 30], [30, 29], [30, 28], [30, 27], [30, 26], [30, 25], [30, 24], [30, 23], [30, 22], [30, 21], [30, 20], [29, 20], [28, 20], [27, 20], [26, 20], [25, 20], [24, 20], [23, 20], [22, 20], [21, 20], [20, 20], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [21, 31], [22, 31], [23, 31], [24, 31], [25, 31], [26, 31], [27, 31], [28, 31], [29, 31], [30, 31], [31, 31], [31, 30], [31, 29], [31, 28], [31, 27], [31, 26], [31, 25], [31, 24], [31, 23], [31, 22], [31, 21], [31, 20], [31, 19], [30, 19], [29, 19], [28, 19], [27, 19], [26, 19], [25, 19], [24, 19], [23, 19], [22, 19], [21, 19], [20, 19], [19, 19], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [20, 32], [21, 32], [22, 32], [23, 32], [24, 32], [25, 32], [26, 32], [27, 32], [28, 32], [29, 32], [30, 32], [31, 32], [32, 32], [32, 31], [32, 30], [32, 29], [32, 28], [32, 27], [32, 26], [32, 25], [32, 24], [32, 23], [32, 22], [32, 21], [32, 20], [32, 19], [32, 18], [31, 18], [30, 18], [29, 18], [28, 18], [27, 18], [26, 18], [25, 18], [24, 18], [23, 18], [22, 18], [21, 18], [20, 18], [19, 18], [18, 18], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [19, 33], [20, 33], [21, 33], [22, 33], [23, 33], [24, 33], [25, 33], [26, 33], [27, 33], [28, 33], [29, 33], [30, 33], [31, 33], [32, 33], [33, 33], [33, 32], [33, 31], [33, 30], [33, 29], [33, 28], [33, 27], [33, 26], [33, 25], [33, 24], [33, 23], [33, 22], [33, 21], [33, 20], [33, 19], [33, 18], [33, 17], [32, 17], [31, 17], [30, 17], [29, 17], [28, 17], [27, 17], [26, 17], [25, 17], [24, 17], [23, 17], [22, 17], [21, 17], [20, 17], [19, 17], [18, 17], [17, 17], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [18, 34], [19, 34], [20, 34], [21, 34], [22, 34], [23, 34], [24, 34], [25, 34], [26, 34], [27, 34], [28, 34], [29, 34], [30, 34], [31, 34], [32, 34], [33, 34], [34, 34], [34, 33], [34, 32], [34, 31], [34, 30], [34, 29], [34, 28], [34, 27], [34, 26], [34, 25], [34, 24], [34, 23], [34, 22], [34, 21], [34, 20], [34, 19], [34, 18], [34, 17], [34, 16], [33, 16], [32, 16], [31, 16], [30, 16], [29, 16], [28, 16], [27, 16], [26, 16], [25, 16], [24, 16], [23, 16], [22, 16], [21, 16], [20, 16], [19, 16], [18, 16], [17, 16], [16, 16], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [17, 35], [18, 35], [19, 35], [20, 35], [21, 35], [22, 35], [23, 35], [24, 35], [25, 35], [26, 35], [27, 35], [28, 35], [29, 35], [30, 35], [31, 35], [32, 35], [33, 35], [34, 35], [35, 35], [35, 34], [35, 33], [35, 32], [35, 31], [35, 30], [35, 29], [35, 28], [35, 27], [35, 26], [35, 25], [35, 24], [35, 23], [35, 22], [35, 21], [35, 20], [35, 19], [35, 18], [35, 17], [35, 16], [35, 15], [34, 15], [33, 15], [32, 15], [31, 15], [30, 15], [29, 15], [28, 15], [27, 15], [26, 15], [25, 15], [24, 15], [23, 15], [22, 15], [21, 15], [20, 15], [19, 15], [18, 15], [17, 15], [16, 15], [15, 15], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [16, 36], [17, 36], [18, 36], [19, 36], [20, 36], [21, 36], [22, 36], [23, 36], [24, 36], [25, 36], [26, 36], [27, 36], [28, 36], [29, 36], [30, 36], [31, 36], [32, 36], [33, 36], [34, 36], [35, 36], [36, 36], [36, 35], [36, 34], [36, 33], [36, 32], [36, 31], [36, 30], [36, 29], [36, 28], [36, 27], [36, 26], [36, 25], [36, 24], [36, 23], [36, 22], [36, 21], [36, 20], [36, 19], [36, 18], [36, 17], [36, 16], [36, 15], [36, 14], [35, 14], [34, 14], [33, 14], [32, 14], [31, 14], [30, 14], [29, 14], [28, 14], [27, 14], [26, 14], [25, 14], [24, 14], [23, 14], [22, 14], [21, 14], [20, 14], [19, 14], [18, 14], [17, 14], [16, 14], [15, 14], [14, 14], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [15, 37], [16, 37], [17, 37], [18, 37], [19, 37], [20, 37], [21, 37], [22, 37], [23, 37], [24, 37], [25, 37], [26, 37], [27, 37], [28, 37], [29, 37], [30, 37], [31, 37], [32, 37], [33, 37], [34, 37], [35, 37], [36, 37], [37, 37], [37, 36], [37, 35], [37, 34], [37, 33], [37, 32], [37, 31], [37, 30], [37, 29], [37, 28], [37, 27], [37, 26], [37, 25], [37, 24], [37, 23], [37, 22], [37, 21], [37, 20], [37, 19], [37, 18], [37, 17], [37, 16], [37, 15], [37, 14], [37, 13], [36, 13], [35, 13], [34, 13], [33, 13], [32, 13], [31, 13], [30, 13], [29, 13], [28, 13], [27, 13], [26, 13], [25, 13], [24, 13], [23, 13], [22, 13], [21, 13], [20, 13], [19, 13], [18, 13], [17, 13], [16, 13], [15, 13], [14, 13], [13, 13], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [14, 38], [15, 38], [16, 38], [17, 38], [18, 38], [19, 38], [20, 38], [21, 38], [22, 38], [23, 38], [24, 38], [25, 38], [26, 38], [27, 38], [28, 38], [29, 38], [30, 38], [31, 38], [32, 38], [33, 38], [34, 38], [35, 38], [36, 38], [37, 38], [38, 38], [38, 37], [38, 36], [38, 35], [38, 34], [38, 33], [38, 32], [38, 31], [38, 30], [38, 29], [38, 28], [38, 27], [38, 26], [38, 25], [38, 24], [38, 23], [38, 22], [38, 21], [38, 20], [38, 19], [38, 18], [38, 17], [38, 16], [38, 15], [38, 14], [38, 13], [38, 12], [37, 12], [36, 12], [35, 12], [34, 12], [33, 12], [32, 12], [31, 12], [30, 12], [29, 12], [28, 12], [27, 12], [26, 12], [25, 12], [24, 12], [23, 12], [22, 12], [21, 12], [20, 12], [19, 12], [18, 12], [17, 12], [16, 12], [15, 12], [14, 12], [13, 12], [12, 12], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 39], [14, 39], [15, 39], [16, 39], [17, 39], [18, 39], [19, 39], [20, 39], [21, 39], [22, 39], [23, 39], [24, 39], [25, 39], [26, 39], [27, 39], [28, 39], [29, 39], [30, 39], [31, 39], [32, 39], [33, 39], [34, 39], [35, 39], [36, 39], [37, 39], [38, 39], [39, 39], [39, 38], [39, 37], [39, 36], [39, 35], [39, 34], [39, 33], [39, 32], [39, 31], [39, 30], [39, 29], [39, 28], [39, 27], [39, 26], [39, 25], [39, 24], [39, 23], [39, 22], [39, 21], [39, 20], [39, 19], [39, 18], [39, 17], [39, 16], [39, 15], [39, 14], [39, 13], [39, 12], [39, 11], [38, 11], [37, 11], [36, 11], [35, 11], [34, 11], [33, 11], [32, 11], [31, 11], [30, 11], [29, 11], [28, 11], [27, 11], [26, 11], [25, 11], [24, 11], [23, 11], [22, 11], [21, 11], [20, 11], [19, 11], [18, 11], [17, 11], [16, 11], [15, 11], [14, 11], [13, 11], [12, 11], [11, 11], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [12, 40], [13, 40], [14, 40], [15, 40], [16, 40], [17, 40], [18, 40], [19, 40], [20, 40], [21, 40], [22, 40], [23, 40], [24, 40], [25, 40], [26, 40], [27, 40], [28, 40], [29, 40], [30, 40], [31, 40], [32, 40], [33, 40], [34, 40], [35, 40], [36, 40], [37, 40], [38, 40], [39, 40], [40, 40], [40, 39], [40, 38], [40, 37], [40, 36], [40, 35], [40, 34], [40, 33], [40, 32], [40, 31], [40, 30], [40, 29], [40, 28], [40, 27], [40, 26], [40, 25], [40, 24], [40, 23], [40, 22], [40, 21], [40, 20], [40, 19], [40, 18], [40, 17], [40, 16], [40, 15], [40, 14], [40, 13], [40, 12], [40, 11], [40, 10], [39, 10], [38, 10], [37, 10], [36, 10], [35, 10], [34, 10], [33, 10], [32, 10], [31, 10], [30, 10], [29, 10], [28, 10], [27, 10], [26, 10], [25, 10], [24, 10], [23, 10], [22, 10], [21, 10], [20, 10], [19, 10], [18, 10], [17, 10], [16, 10], [15, 10], [14, 10], [13, 10], [12, 10], [11, 10], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [11, 41], [12, 41], [13, 41], [14, 41], [15, 41], [16, 41], [17, 41], [18, 41], [19, 41], [20, 41], [21, 41], [22, 41], [23, 41], [24, 41], [25, 41], [26, 41], [27, 41], [28, 41], [29, 41], [30, 41], [31, 41], [32, 41], [33, 41], [34, 41], [35, 41], [36, 41], [37, 41], [38, 41], [39, 41], [40, 41], [41, 41], [41, 40], [41, 39], [41, 38], [41, 37], [41, 36], [41, 35], [41, 34], [41, 33], [41, 32], [41, 31], [41, 30], [41, 29], [41, 28], [41, 27], [41, 26], [41, 25], [41, 24], [41, 23], [41, 22], [41, 21], [41, 20], [41, 19], [41, 18], [41, 17], [41, 16], [41, 15], [41, 14], [41, 13], [41, 12], [41, 11], [41, 10], [41, 9], [40, 9], [39, 9], [38, 9], [37, 9], [36, 9], [35, 9], [34, 9], [33, 9], [32, 9], [31, 9], [30, 9], [29, 9], [28, 9], [27, 9], [26, 9], [25, 9], [24, 9], [23, 9], [22, 9], [21, 9], [20, 9], [19, 9], [18, 9], [17, 9], [16, 9], [15, 9], [14, 9], [13, 9], [12, 9], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [10, 42], [11, 42], [12, 42], [13, 42], [14, 42], [15, 42], [16, 42], [17, 42], [18, 42], [19, 42], [20, 42], [21, 42], [22, 42], [23, 42], [24, 42], [25, 42], [26, 42], [27, 42], [28, 42], [29, 42], [30, 42], [31, 42], [32, 42], [33, 42], [34, 42], [35, 42], [36, 42], [37, 42], [38, 42], [39, 42], [40, 42], [41, 42], [42, 42], [42, 41], [42, 40], [42, 39], [42, 38], [42, 37], [42, 36], [42, 35], [42, 34], [42, 33], [42, 32], [42, 31], [42, 30], [42, 29], [42, 28], [42, 27], [42, 26], [42, 25], [42, 24], [42, 23], [42, 22], [42, 21], [42, 20], [42, 19], [42, 18], [42, 17], [42, 16], [42, 15], [42, 14], [42, 13], [42, 12], [42, 11], [42, 10], [42, 9], [42, 8], [41, 8], [40, 8], [39, 8], [38, 8], [37, 8], [36, 8], [35, 8], [34, 8], [33, 8], [32, 8], [31, 8], [30, 8], [29, 8], [28, 8], [27, 8], [26, 8], [25, 8], [24, 8], [23, 8], [22, 8], [21, 8], [20, 8], [19, 8], [18, 8], [17, 8], [16, 8], [15, 8], [14, 8], [13, 8], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [9, 43], [10, 43], [11, 43], [12, 43], [13, 43], [14, 43], [15, 43], [16, 43], [17, 43], [18, 43], [19, 43], [20, 43], [21, 43], [22, 43], [23, 43], [24, 43], [25, 43], [26, 43], [27, 43], [28, 43], [29, 43], [30, 43], [31, 43], [32, 43], [33, 43], [34, 43], [35, 43], [36, 43], [37, 43], [38, 43], [39, 43], [40, 43], [41, 43], [42, 43], [43, 43], [43, 42], [43, 41], [43, 40], [43, 39], [43, 38], [43, 37], [43, 36], [43, 35], [43, 34], [43, 33], [43, 32], [43, 31], [43, 30], [43, 29], [43, 28], [43, 27], [43, 26], [43, 25], [43, 24], [43, 23], [43, 22], [43, 21], [43, 20], [43, 19], [43, 18], [43, 17], [43, 16], [43, 15], [43, 14], [43, 13], [43, 12], [43, 11], [43, 10], [43, 9], [43, 8], [43, 7], [42, 7], [41, 7], [40, 7], [39, 7], [38, 7], [37, 7], [36, 7], [35, 7], [34, 7], [33, 7], [32, 7], [31, 7], [30, 7], [29, 7], [28, 7], [27, 7], [26, 7], [25, 7], [24, 7], [23, 7], [22, 7], [21, 7], [20, 7], [19, 7], [18, 7], [17, 7], [16, 7], [15, 7], [14, 7], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 44], [8, 44], [9, 44], [10, 44], [11, 44], [12, 44], [13, 44], [14, 44], [15, 44], [16, 44], [17, 44], [18, 44], [19, 44], [20, 44], [21, 44], [22, 44], [23, 44], [24, 44], [25, 44], [26, 44], [27, 44], [28, 44], [29, 44], [30, 44], [31, 44], [32, 44], [33, 44], [34, 44], [35, 44], [36, 44], [37, 44], [38, 44], [39, 44], [40, 44], [41, 44], [42, 44], [43, 44], [44, 44], [44, 43], [44, 42], [44, 41], [44, 40], [44, 39], [44, 38], [44, 37], [44, 36], [44, 35], [44, 34], [44, 33], [44, 32], [44, 31], [44, 30], [44, 29], [44, 28], [44, 27], [44, 26], [44, 25], [44, 24], [44, 23], [44, 22], [44, 21], [44, 20], [44, 19], [44, 18], [44, 17], [44, 16], [44, 15], [44, 14], [44, 13], [44, 12], [44, 11], [44, 10], [44, 9], [44, 8], [44, 7], [44, 6], [43, 6], [42, 6], [41, 6], [40, 6], [39, 6], [38, 6], [37, 6], [36, 6], [35, 6], [34, 6], [33, 6], [32, 6], [31, 6], [30, 6], [29, 6], [28, 6], [27, 6], [26, 6], [25, 6], [24, 6], [23, 6], [22, 6], [21, 6], [20, 6], [19, 6], [18, 6], [17, 6], [16, 6], [15, 6], [14, 6], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [7, 45], [8, 45], [9, 45], [10, 45], [11, 45], [12, 45], [13, 45], [14, 45], [15, 45], [16, 45], [17, 45], [18, 45], [19, 45], [20, 45], [21, 45], [22, 45], [23, 45], [24, 45], [25, 45], [26, 45], [27, 45], [28, 45], [29, 45], [30, 45], [31, 45], [32, 45], [33, 45], [34, 45], [35, 45], [36, 45], [37, 45], [38, 45], [39, 45], [40, 45], [41, 45], [42, 45], [43, 45], [44, 45], [45, 45], [45, 44], [45, 43], [45, 42], [45, 41], [45, 40], [45, 39], [45, 38], [45, 37], [45, 36], [45, 35], [45, 34], [45, 33], [45, 32], [45, 31], [45, 30], [45, 29], [45, 28], [45, 27], [45, 26], [45, 25], [45, 24], [45, 23], [45, 22], [45, 21], [45, 20], [45, 19], [45, 18], [45, 17], [45, 16], [45, 15], [45, 14], [45, 13], [45, 12], [45, 11], [45, 10], [45, 9], [45, 8], [45, 7], [45, 6], [45, 5], [44, 5], [43, 5], [42, 5], [41, 5], [40, 5], [39, 5], [38, 5], [37, 5], [36, 5], [35, 5], [34, 5], [33, 5], [32, 5], [31, 5], [30, 5], [29, 5], [28, 5], [27, 5], [26, 5], [25, 5], [24, 5], [23, 5], [22, 5], [21, 5], [20, 5], [19, 5], [18, 5], [17, 5], [16, 5], [15, 5], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [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, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 37], [5, 38], [5, 39], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 46], [6, 46], [7, 46], [8, 46], [9, 46], [10, 46], [11, 46], [12, 46], [13, 46], [14, 46], [15, 46], [16, 46], [17, 46], [18, 46], [19, 46], [20, 46], [21, 46], [22, 46], [23, 46], [24, 46], [25, 46], [26, 46], [27, 46], [28, 46], [29, 46], [30, 46], [31, 46], [32, 46], [33, 46], [34, 46], [35, 46], [36, 46], [37, 46], [38, 46], [39, 46], [40, 46], [41, 46], [42, 46], [43, 46], [44, 46], [45, 46], [46, 46], [46, 45], [46, 44], [46, 43], [46, 42], [46, 41], [46, 40], [46, 39], [46, 38], [46, 37], [46, 36], [46, 35], [46, 34], [46, 33], [46, 32], [46, 31], [46, 30], [46, 29], [46, 28], [46, 27], [46, 26], [46, 25], [46, 24], [46, 23], [46, 22], [46, 21], [46, 20], [46, 19], [46, 18], [46, 17], [46, 16], [46, 15], [46, 14], [46, 13], [46, 12], [46, 11], [46, 10], [46, 9], [46, 8], [46, 7], [46, 6], [46, 5], [46, 4], [45, 4], [44, 4], [43, 4], [42, 4], [41, 4], [40, 4], [39, 4], [38, 4], [37, 4], [36, 4], [35, 4], [34, 4], [33, 4], [32, 4], [31, 4], [30, 4], [29, 4], [28, 4], [27, 4], [26, 4], [25, 4], [24, 4], [23, 4], [22, 4], [21, 4], [20, 4], [19, 4], [18, 4], [17, 4], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 47], [5, 47], [6, 47], [7, 47], [8, 47], [9, 47], [10, 47], [11, 47], [12, 47], [13, 47], [14, 47], [15, 47], [16, 47], [17, 47], [18, 47], [19, 47], [20, 47], [21, 47], [22, 47], [23, 47], [24, 47], [25, 47], [26, 47], [27, 47], [28, 47], [29, 47], [30, 47], [31, 47], [32, 47], [33, 47], [34, 47], [35, 47], [36, 47], [37, 47], [38, 47], [39, 47], [40, 47], [41, 47], [42, 47], [43, 47], [44, 47], [45, 47], [46, 47], [47, 47], [47, 46], [47, 45], [47, 44], [47, 43], [47, 42], [47, 41], [47, 40], [47, 39], [47, 38], [47, 37], [47, 36], [47, 35], [47, 34], [47, 33], [47, 32], [47, 31], [47, 30], [47, 29], [47, 28], [47, 27], [47, 26], [47, 25], [47, 24], [47, 23], [47, 22], [47, 21], [47, 20], [47, 19], [47, 18], [47, 17], [47, 16], [47, 15], [47, 14], [47, 13], [47, 12], [47, 11], [47, 10], [47, 9], [47, 8], [47, 7], [47, 6], [47, 5], [47, 4], [47, 3], [46, 3], [45, 3], [44, 3], [43, 3], [42, 3], [41, 3], [40, 3], [39, 3], [38, 3], [37, 3], [36, 3], [35, 3], [34, 3], [33, 3], [32, 3], [31, 3], [30, 3], [29, 3], [28, 3], [27, 3], [26, 3], [25, 3], [24, 3], [23, 3], [22, 3], [21, 3], [20, 3], [19, 3], [18, 3], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [4, 48], [5, 48], [6, 48], [7, 48], [8, 48], [9, 48], [10, 48], [11, 48], [12, 48], [13, 48], [14, 48], [15, 48], [16, 48], [17, 48], [18, 48], [19, 48], [20, 48], [21, 48], [22, 48], [23, 48], [24, 48], [25, 48], [26, 48], [27, 48], [28, 48], [29, 48], [30, 48], [31, 48], [32, 48], [33, 48], [34, 48], [35, 48], [36, 48], [37, 48], [38, 48], [39, 48], [40, 48], [41, 48], [42, 48], [43, 48], [44, 48], [45, 48], [46, 48], [47, 48], [48, 48], [48, 47], [48, 46], [48, 45], [48, 44], [48, 43], [48, 42], [48, 41], [48, 40], [48, 39], [48, 38], [48, 37], [48, 36], [48, 35], [48, 34], [48, 33], [48, 32], [48, 31], [48, 30], [48, 29], [48, 28], [48, 27], [48, 26], [48, 25], [48, 24], [48, 23], [48, 22], [48, 21], [48, 20], [48, 19], [48, 18], [48, 17], [48, 16], [48, 15], [48, 14], [48, 13], [48, 12], [48, 11], [48, 10], [48, 9], [48, 8], [48, 7], [48, 6], [48, 5], [48, 4], [48, 3], [48, 2], [47, 2], [46, 2], [45, 2], [44, 2], [43, 2], [42, 2], [41, 2], [40, 2], [39, 2], [38, 2], [37, 2], [36, 2], [35, 2], [34, 2], [33, 2], [32, 2], [31, 2], [30, 2], [29, 2], [28, 2], [27, 2], [26, 2], [25, 2], [24, 2], [23, 2], [22, 2], [21, 2], [20, 2], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [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], [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], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [3, 49], [4, 49], [5, 49], [6, 49], [7, 49], [8, 49], [9, 49], [10, 49], [11, 49], [12, 49], [13, 49], [14, 49], [15, 49], [16, 49], [17, 49], [18, 49], [19, 49], [20, 49], [21, 49], [22, 49], [23, 49], [24, 49], [25, 49], [26, 49], [27, 49], [28, 49], [29, 49], [30, 49], [31, 49], [32, 49], [33, 49], [34, 49], [35, 49], [36, 49], [37, 49], [38, 49], [39, 49], [40, 49], [41, 49], [42, 49], [43, 49], [44, 49], [45, 49], [46, 49], [47, 49], [48, 49], [49, 49], [49, 48], [49, 47], [49, 46], [49, 45], [49, 44], [49, 43], [49, 42], [49, 41], [49, 40], [49, 39], [49, 38], [49, 37], [49, 36], [49, 35], [49, 34], [49, 33], [49, 32], [49, 31], [49, 30], [49, 29], [49, 28], [49, 27], [49, 26], [49, 25], [49, 24], [49, 23], [49, 22], [49, 21], [49, 20], [49, 19], [49, 18], [49, 17], [49, 16], [49, 15], [49, 14], [49, 13], [49, 12], [49, 11], [49, 10], [49, 9], [49, 8], [49, 7], [49, 6], [49, 5], [49, 4], [49, 3], [49, 2], [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], [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], [49, 0], [48, 0], [47, 0], [46, 0], [45, 0], [44, 0], [43, 0], [42, 0], [41, 0], [40, 0], [39, 0], [38, 0], [37, 0], [36, 0], [35, 0], [34, 0], [33, 0], [32, 0], [31, 0], [30, 0], [29, 0], [28, 0], [27, 0], [26, 0], [25, 0], [24, 0], [23, 0], [22, 0], [21, 0], [20, 0], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 48], [0, 49]]\n assert candidate(rows = 3,cols = 8,rStart = 1,cStart = 4) == [[1, 4], [1, 5], [2, 5], [2, 4], [2, 3], [1, 3], [0, 3], [0, 4], [0, 5], [0, 6], [1, 6], [2, 6], [2, 2], [1, 2], [0, 2], [0, 7], [1, 7], [2, 7], [2, 1], [1, 1], [0, 1], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 6,cols = 6,rStart = 3,cStart = 0) == [[3, 0], [3, 1], [4, 1], [4, 0], [2, 0], [2, 1], [2, 2], [3, 2], [4, 2], [5, 2], [5, 1], [5, 0], [1, 0], [1, 1], [1, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]\n assert candidate(rows = 18,cols = 20,rStart = 9,cStart = 10) == [[9, 10], [9, 11], [10, 11], [10, 10], [10, 9], [9, 9], [8, 9], [8, 10], [8, 11], [8, 12], [9, 12], [10, 12], [11, 12], [11, 11], [11, 10], [11, 9], [11, 8], [10, 8], [9, 8], [8, 8], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [15, 16], [15, 15], [15, 14], [15, 13], [15, 12], [15, 11], [15, 10], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [15, 17], [16, 17], [16, 16], [16, 15], [16, 14], [16, 13], [16, 12], [16, 11], [16, 10], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [16, 4], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [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], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [15, 18], [16, 18], [17, 18], [17, 17], [17, 16], [17, 15], [17, 14], [17, 13], [17, 12], [17, 11], [17, 10], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [17, 2], [16, 2], [15, 2], [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], [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, 19], [3, 19], [4, 19], [5, 19], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [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], [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], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 12,cols = 12,rStart = 11,cStart = 11) == [[11, 11], [11, 10], [10, 10], [10, 11], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [11, 1], [10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11]]\n assert candidate(rows = 12,cols = 9,rStart = 0,cStart = 8) == [[0, 8], [1, 8], [1, 7], [0, 7], [2, 8], [2, 7], [2, 6], [1, 6], [0, 6], [3, 8], [3, 7], [3, 6], [3, 5], [2, 5], [1, 5], [0, 5], [4, 8], [4, 7], [4, 6], [4, 5], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [5, 8], [5, 7], [5, 6], [5, 5], [5, 4], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [6, 8], [6, 7], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [7, 8], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [9, 8], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [9, 0], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [11, 0]]\n assert candidate(rows = 20,cols = 10,rStart = 3,cStart = 9) == [[3, 9], [4, 9], [4, 8], [3, 8], [2, 8], [2, 9], [5, 9], [5, 8], [5, 7], [4, 7], [3, 7], [2, 7], [1, 7], [1, 8], [1, 9], [6, 9], [6, 8], [6, 7], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [1, 6], [0, 6], [0, 7], [0, 8], [0, 9], [7, 9], [7, 8], [7, 7], [7, 6], [7, 5], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [0, 5], [8, 9], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [12, 2], [12, 1], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [13, 1], [13, 0], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [15, 4], [15, 3], [15, 2], [15, 1], [15, 0], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [16, 4], [16, 3], [16, 2], [16, 1], [16, 0], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [17, 2], [17, 1], [17, 0], [18, 9], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [18, 2], [18, 1], [18, 0], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [19, 1], [19, 0]]\n assert candidate(rows = 8,cols = 12,rStart = 7,cStart = 5) == [[7, 5], [7, 6], [7, 4], [6, 4], [6, 5], [6, 6], [6, 7], [7, 7], [7, 3], [6, 3], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [6, 8], [7, 8], [7, 2], [6, 2], [5, 2], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 9], [6, 9], [7, 9], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11]]\n assert candidate(rows = 8,cols = 6,rStart = 1,cStart = 1) == [[1, 1], [1, 2], [2, 2], [2, 1], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [1, 3], [2, 3], [3, 3], [3, 2], [3, 1], [3, 0], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0]]\n assert candidate(rows = 15,cols = 15,rStart = 7,cStart = 7) == [[7, 7], [7, 8], [8, 8], [8, 7], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [7, 9], [8, 9], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [12, 2], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [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], [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, 14], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]\n assert candidate(rows = 5,cols = 5,rStart = 1,cStart = 1) == [[1, 1], [1, 2], [2, 2], [2, 1], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [1, 3], [2, 3], [3, 3], [3, 2], [3, 1], [3, 0], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0]]\n assert candidate(rows = 9,cols = 9,rStart = 4,cStart = 4) == [[4, 4], [4, 5], [5, 5], [5, 4], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8]]\n assert candidate(rows = 5,cols = 5,rStart = 0,cStart = 0) == [[0, 0], [0, 1], [1, 1], [1, 0], [0, 2], [1, 2], [2, 2], [2, 1], [2, 0], [0, 3], [1, 3], [2, 3], [3, 3], [3, 2], [3, 1], [3, 0], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0]]\n assert candidate(rows = 6,cols = 6,rStart = 5,cStart = 5) == [[5, 5], [5, 4], [4, 4], [4, 5], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]\n assert candidate(rows = 20,cols = 15,rStart = 14,cStart = 7) == [[14, 7], [14, 8], [15, 8], [15, 7], [15, 6], [14, 6], [13, 6], [13, 7], [13, 8], [13, 9], [14, 9], [15, 9], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [15, 5], [14, 5], [13, 5], [12, 5], [12, 6], [12, 7], [12, 8], [12, 9], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [11, 5], [11, 6], [11, 7], [11, 8], [11, 9], [11, 10], [11, 11], [12, 11], [13, 11], [14, 11], [15, 11], [16, 11], [17, 11], [18, 11], [18, 10], [18, 9], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [10, 11], [10, 12], [11, 12], [12, 12], [13, 12], [14, 12], [15, 12], [16, 12], [17, 12], [18, 12], [19, 12], [19, 11], [19, 10], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [14, 2], [13, 2], [12, 2], [11, 2], [10, 2], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [14, 13], [15, 13], [16, 13], [17, 13], [18, 13], [19, 13], [19, 1], [18, 1], [17, 1], [16, 1], [15, 1], [14, 1], [13, 1], [12, 1], [11, 1], [10, 1], [9, 1], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [15, 14], [16, 14], [17, 14], [18, 14], [19, 14], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [5, 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], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [1, 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], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]\n assert candidate(rows = 7,cols = 14,rStart = 3,cStart = 7) == [[3, 7], [3, 8], [4, 8], [4, 7], [4, 6], [3, 6], [2, 6], [2, 7], [2, 8], [2, 9], [3, 9], [4, 9], [5, 9], [5, 8], [5, 7], [5, 6], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [6, 9], [6, 8], [6, 7], [6, 6], [6, 5], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [0, 12], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [0, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 5,cols = 5,rStart = 4,cStart = 4) == [[4, 4], [4, 3], [3, 3], [3, 4], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]\n assert candidate(rows = 20,cols = 15,rStart = 19,cStart = 14) == [[19, 14], [19, 13], [18, 13], [18, 14], [19, 12], [18, 12], [17, 12], [17, 13], [17, 14], [19, 11], [18, 11], [17, 11], [16, 11], [16, 12], [16, 13], [16, 14], [19, 10], [18, 10], [17, 10], [16, 10], [15, 10], [15, 11], [15, 12], [15, 13], [15, 14], [19, 9], [18, 9], [17, 9], [16, 9], [15, 9], [14, 9], [14, 10], [14, 11], [14, 12], [14, 13], [14, 14], [19, 8], [18, 8], [17, 8], [16, 8], [15, 8], [14, 8], [13, 8], [13, 9], [13, 10], [13, 11], [13, 12], [13, 13], [13, 14], [19, 7], [18, 7], [17, 7], [16, 7], [15, 7], [14, 7], [13, 7], [12, 7], [12, 8], [12, 9], [12, 10], [12, 11], [12, 12], [12, 13], [12, 14], [19, 6], [18, 6], [17, 6], [16, 6], [15, 6], [14, 6], [13, 6], [12, 6], [11, 6], [11, 7], [11, 8], [11, 9], [11, 10], [11, 11], [11, 12], [11, 13], [11, 14], [19, 5], [18, 5], [17, 5], [16, 5], [15, 5], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [19, 4], [18, 4], [17, 4], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [19, 3], [18, 3], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [14, 2], [13, 2], [12, 2], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [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], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 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], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [1, 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], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]\n assert candidate(rows = 15,cols = 20,rStart = 7,cStart = 10) == [[7, 10], [7, 11], [8, 11], [8, 10], [8, 9], [7, 9], [6, 9], [6, 10], [6, 11], [6, 12], [7, 12], [8, 12], [9, 12], [9, 11], [9, 10], [9, 9], [9, 8], [8, 8], [7, 8], [6, 8], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [10, 12], [10, 11], [10, 10], [10, 9], [10, 8], [10, 7], [9, 7], [8, 7], [7, 7], [6, 7], [5, 7], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [11, 13], [11, 12], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [12, 14], [12, 13], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [3, 16], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [13, 15], [13, 14], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [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], [2, 17], [3, 17], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [14, 16], [14, 15], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [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], [1, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [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, 19], [1, 19], [2, 19], [3, 19], [4, 19], [5, 19], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19], [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], [0, 1], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 9,cols = 7,rStart = 4,cStart = 6) == [[4, 6], [5, 6], [5, 5], [4, 5], [3, 5], [3, 6], [6, 6], [6, 5], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [2, 5], [2, 6], [7, 6], [7, 5], [7, 4], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [1, 4], [1, 5], [1, 6], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 15,cols = 20,rStart = 0,cStart = 0) == [[0, 0], [0, 1], [1, 1], [1, 0], [0, 2], [1, 2], [2, 2], [2, 1], [2, 0], [0, 3], [1, 3], [2, 3], [3, 3], [3, 2], [3, 1], [3, 0], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0], [0, 8], [1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0], [0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [9, 8], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [9, 0], [0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0], [0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [11, 10], [11, 9], [11, 8], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [11, 0], [0, 12], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 12], [12, 11], [12, 10], [12, 9], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [12, 2], [12, 1], [12, 0], [0, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [13, 12], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [13, 1], [13, 0], [0, 14], [1, 14], [2, 14], [3, 14], [4, 14], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [14, 13], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [0, 15], [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], [0, 16], [1, 16], [2, 16], [3, 16], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [0, 17], [1, 17], [2, 17], [3, 17], [4, 17], [5, 17], [6, 17], [7, 17], [8, 17], [9, 17], [10, 17], [11, 17], [12, 17], [13, 17], [14, 17], [0, 18], [1, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 18], [9, 18], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [0, 19], [1, 19], [2, 19], [3, 19], [4, 19], [5, 19], [6, 19], [7, 19], [8, 19], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]\n assert candidate(rows = 10,cols = 1,rStart = 9,cStart = 0) == [[9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 15,cols = 12,rStart = 7,cStart = 3) == [[7, 3], [7, 4], [8, 4], [8, 3], [8, 2], [7, 2], [6, 2], [6, 3], [6, 4], [6, 5], [7, 5], [8, 5], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 6], [7, 6], [8, 6], [9, 6], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 7], [6, 7], [7, 7], [8, 7], [9, 7], [10, 7], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [11, 0], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 8], [9, 8], [10, 8], [11, 8], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4], [12, 3], [12, 2], [12, 1], [12, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 9], [10, 9], [11, 9], [12, 9], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [13, 4], [13, 3], [13, 2], [13, 1], [13, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 11], [12, 11], [13, 11], [14, 11]]\n assert candidate(rows = 9,cols = 14,rStart = 4,cStart = 7) == [[4, 7], [4, 8], [5, 8], [5, 7], [5, 6], [4, 6], [3, 6], [3, 7], [3, 8], [3, 9], [4, 9], [5, 9], [6, 9], [6, 8], [6, 7], [6, 6], [6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [7, 9], [7, 8], [7, 7], [7, 6], [7, 5], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [8, 10], [8, 9], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [0, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 30,cols = 15,rStart = 29,cStart = 14) == [[29, 14], [29, 13], [28, 13], [28, 14], [29, 12], [28, 12], [27, 12], [27, 13], [27, 14], [29, 11], [28, 11], [27, 11], [26, 11], [26, 12], [26, 13], [26, 14], [29, 10], [28, 10], [27, 10], [26, 10], [25, 10], [25, 11], [25, 12], [25, 13], [25, 14], [29, 9], [28, 9], [27, 9], [26, 9], [25, 9], [24, 9], [24, 10], [24, 11], [24, 12], [24, 13], [24, 14], [29, 8], [28, 8], [27, 8], [26, 8], [25, 8], [24, 8], [23, 8], [23, 9], [23, 10], [23, 11], [23, 12], [23, 13], [23, 14], [29, 7], [28, 7], [27, 7], [26, 7], [25, 7], [24, 7], [23, 7], [22, 7], [22, 8], [22, 9], [22, 10], [22, 11], [22, 12], [22, 13], [22, 14], [29, 6], [28, 6], [27, 6], [26, 6], [25, 6], [24, 6], [23, 6], [22, 6], [21, 6], [21, 7], [21, 8], [21, 9], [21, 10], [21, 11], [21, 12], [21, 13], [21, 14], [29, 5], [28, 5], [27, 5], [26, 5], [25, 5], [24, 5], [23, 5], [22, 5], [21, 5], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10], [20, 11], [20, 12], [20, 13], [20, 14], [29, 4], [28, 4], [27, 4], [26, 4], [25, 4], [24, 4], [23, 4], [22, 4], [21, 4], [20, 4], [19, 4], [19, 5], [19, 6], [19, 7], [19, 8], [19, 9], [19, 10], [19, 11], [19, 12], [19, 13], [19, 14], [29, 3], [28, 3], [27, 3], [26, 3], [25, 3], [24, 3], [23, 3], [22, 3], [21, 3], [20, 3], [19, 3], [18, 3], [18, 4], [18, 5], [18, 6], [18, 7], [18, 8], [18, 9], [18, 10], [18, 11], [18, 12], [18, 13], [18, 14], [29, 2], [28, 2], [27, 2], [26, 2], [25, 2], [24, 2], [23, 2], [22, 2], [21, 2], [20, 2], [19, 2], [18, 2], [17, 2], [17, 3], [17, 4], [17, 5], [17, 6], [17, 7], [17, 8], [17, 9], [17, 10], [17, 11], [17, 12], [17, 13], [17, 14], [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], [16, 2], [16, 3], [16, 4], [16, 5], [16, 6], [16, 7], [16, 8], [16, 9], [16, 10], [16, 11], [16, 12], [16, 13], [16, 14], [29, 0], [28, 0], [27, 0], [26, 0], [25, 0], [24, 0], [23, 0], [22, 0], [21, 0], [20, 0], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [15, 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], [14, 0], [14, 1], [14, 2], [14, 3], [14, 4], [14, 5], [14, 6], [14, 7], [14, 8], [14, 9], [14, 10], [14, 11], [14, 12], [14, 13], [14, 14], [13, 0], [13, 1], [13, 2], [13, 3], [13, 4], [13, 5], [13, 6], [13, 7], [13, 8], [13, 9], [13, 10], [13, 11], [13, 12], [13, 13], [13, 14], [12, 0], [12, 1], [12, 2], [12, 3], [12, 4], [12, 5], [12, 6], [12, 7], [12, 8], [12, 9], [12, 10], [12, 11], [12, 12], [12, 13], [12, 14], [11, 0], [11, 1], [11, 2], [11, 3], [11, 4], [11, 5], [11, 6], [11, 7], [11, 8], [11, 9], [11, 10], [11, 11], [11, 12], [11, 13], [11, 14], [10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [5, 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], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [1, 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], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]\n assert candidate(rows = 20,cols = 5,rStart = 10,cStart = 2) == [[10, 2], [10, 3], [11, 3], [11, 2], [11, 1], [10, 1], [9, 1], [9, 2], [9, 3], [9, 4], [10, 4], [11, 4], [12, 4], [12, 3], [12, 2], [12, 1], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [13, 4], [13, 3], [13, 2], [13, 1], [13, 0], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [14, 4], [14, 3], [14, 2], [14, 1], [14, 0], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [15, 4], [15, 3], [15, 2], [15, 1], [15, 0], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [16, 4], [16, 3], [16, 2], [16, 1], [16, 0], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [17, 4], [17, 3], [17, 2], [17, 1], [17, 0], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [18, 4], [18, 3], [18, 2], [18, 1], [18, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [19, 4], [19, 3], [19, 2], [19, 1], [19, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]\n assert candidate(rows = 20,cols = 15,rStart = 10,cStart = 8) == [[10, 8], [10, 9], [11, 9], [11, 8], [11, 7], [10, 7], [9, 7], [9, 8], [9, 9], [9, 10], [10, 10], [11, 10], [12, 10], [12, 9], [12, 8], [12, 7], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10], [8, 11], [9, 11], [10, 11], [11, 11], [12, 11], [13, 11], [13, 10], [13, 9], [13, 8], [13, 7], [13, 6], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 12], [13, 12], [14, 12], [14, 11], [14, 10], [14, 9], [14, 8], [14, 7], [14, 6], [14, 5], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [14, 13], [15, 13], [15, 12], [15, 11], [15, 10], [15, 9], [15, 8], [15, 7], [15, 6], [15, 5], [15, 4], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [6, 14], [7, 14], [8, 14], [9, 14], [10, 14], [11, 14], [12, 14], [13, 14], [14, 14], [15, 14], [16, 14], [16, 13], [16, 12], [16, 11], [16, 10], [16, 9], [16, 8], [16, 7], [16, 6], [16, 5], [16, 4], [16, 3], [16, 2], [15, 2], [14, 2], [13, 2], [12, 2], [11, 2], [10, 2], [9, 2], [8, 2], [7, 2], [6, 2], [5, 2], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [17, 14], [17, 13], [17, 12], [17, 11], [17, 10], [17, 9], [17, 8], [17, 7], [17, 6], [17, 5], [17, 4], [17, 3], [17, 2], [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], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [18, 14], [18, 13], [18, 12], [18, 11], [18, 10], [18, 9], [18, 8], [18, 7], [18, 6], [18, 5], [18, 4], [18, 3], [18, 2], [18, 1], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [19, 14], [19, 13], [19, 12], [19, 11], [19, 10], [19, 9], [19, 8], [19, 7], [19, 6], [19, 5], [19, 4], [19, 3], [19, 2], [19, 1], [19, 0], [1, 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], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]\n assert candidate(rows = 5,cols = 20,rStart = 2,cStart = 19) == [[2, 19], [3, 19], [3, 18], [2, 18], [1, 18], [1, 19], [4, 19], [4, 18], [4, 17], [3, 17], [2, 17], [1, 17], [0, 17], [0, 18], [0, 19], [4, 16], [3, 16], [2, 16], [1, 16], [0, 16], [4, 15], [3, 15], [2, 15], [1, 15], [0, 15], [4, 14], [3, 14], [2, 14], [1, 14], [0, 14], [4, 13], [3, 13], [2, 13], [1, 13], [0, 13], [4, 12], [3, 12], [2, 12], [1, 12], [0, 12], [4, 11], [3, 11], [2, 11], [1, 11], [0, 11], [4, 10], [3, 10], [2, 10], [1, 10], [0, 10], [4, 9], [3, 9], [2, 9], [1, 9], [0, 9], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8], [4, 7], [3, 7], [2, 7], [1, 7], [0, 7], [4, 6], [3, 6], [2, 6], [1, 6], [0, 6], [4, 5], [3, 5], [2, 5], [1, 5], [0, 5], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]\n assert candidate(rows = 12,cols = 8,rStart = 0,cStart = 0) == [[0, 0], [0, 1], [1, 1], [1, 0], [0, 2], [1, 2], [2, 2], [2, 1], [2, 0], [0, 3], [1, 3], [2, 3], [3, 3], [3, 2], [3, 1], [3, 0], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [6, 0], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1], [7, 0], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [8, 1], [8, 0], [9, 7], [9, 6], [9, 5], [9, 4], [9, 3], [9, 2], [9, 1], [9, 0], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [10, 0], [11, 7], [11, 6], [11, 5], [11, 4], [11, 3], [11, 2], [11, 1], [11, 0]]\n assert candidate(rows = 8,cols = 5,rStart = 7,cStart = 0) == [[7, 0], [7, 1], [6, 0], [6, 1], [6, 2], [7, 2], [5, 0], [5, 1], [5, 2], [5, 3], [6, 3], [7, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 4], [6, 4], [7, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]\n assert candidate(rows = 7,cols = 7,rStart = 3,cStart = 0) == [[3, 0], [3, 1], [4, 1], [4, 0], [2, 0], [2, 1], [2, 2], [3, 2], [4, 2], [5, 2], [5, 1], [5, 0], [1, 0], [1, 1], [1, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [6, 2], [6, 1], [6, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]]\n assert candidate(rows = 30,cols = 30,rStart = 15,cStart = 15) == [[15, 15], [15, 16], [16, 16], [16, 15], [16, 14], [15, 14], [14, 14], [14, 15], [14, 16], [14, 17], [15, 17], [16, 17], [17, 17], [17, 16], [17, 15], [17, 14], [17, 13], [16, 13], [15, 13], [14, 13], [13, 13], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 18], [15, 18], [16, 18], [17, 18], [18, 18], [18, 17], [18, 16], [18, 15], [18, 14], [18, 13], [18, 12], [17, 12], [16, 12], [15, 12], [14, 12], [13, 12], [12, 12], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [13, 19], [14, 19], [15, 19], [16, 19], [17, 19], [18, 19], [19, 19], [19, 18], [19, 17], [19, 16], [19, 15], [19, 14], [19, 13], [19, 12], [19, 11], [18, 11], [17, 11], [16, 11], [15, 11], [14, 11], [13, 11], [12, 11], [11, 11], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [12, 20], [13, 20], [14, 20], [15, 20], [16, 20], [17, 20], [18, 20], [19, 20], [20, 20], [20, 19], [20, 18], [20, 17], [20, 16], [20, 15], [20, 14], [20, 13], [20, 12], [20, 11], [20, 10], [19, 10], [18, 10], [17, 10], [16, 10], [15, 10], [14, 10], [13, 10], [12, 10], [11, 10], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [11, 21], [12, 21], [13, 21], [14, 21], [15, 21], [16, 21], [17, 21], [18, 21], [19, 21], [20, 21], [21, 21], [21, 20], [21, 19], [21, 18], [21, 17], [21, 16], [21, 15], [21, 14], [21, 13], [21, 12], [21, 11], [21, 10], [21, 9], [20, 9], [19, 9], [18, 9], [17, 9], [16, 9], [15, 9], [14, 9], [13, 9], [12, 9], [11, 9], [10, 9], [9, 9], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [10, 22], [11, 22], [12, 22], [13, 22], [14, 22], [15, 22], [16, 22], [17, 22], [18, 22], [19, 22], [20, 22], [21, 22], [22, 22], [22, 21], [22, 20], [22, 19], [22, 18], [22, 17], [22, 16], [22, 15], [22, 14], [22, 13], [22, 12], [22, 11], [22, 10], [22, 9], [22, 8], [21, 8], [20, 8], [19, 8], [18, 8], [17, 8], [16, 8], [15, 8], [14, 8], [13, 8], [12, 8], [11, 8], [10, 8], [9, 8], [8, 8], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [9, 23], [10, 23], [11, 23], [12, 23], [13, 23], [14, 23], [15, 23], [16, 23], [17, 23], [18, 23], [19, 23], [20, 23], [21, 23], [22, 23], [23, 23], [23, 22], [23, 21], [23, 20], [23, 19], [23, 18], [23, 17], [23, 16], [23, 15], [23, 14], [23, 13], [23, 12], [23, 11], [23, 10], [23, 9], [23, 8], [23, 7], [22, 7], [21, 7], [20, 7], [19, 7], [18, 7], [17, 7], [16, 7], [15, 7], [14, 7], [13, 7], [12, 7], [11, 7], [10, 7], [9, 7], [8, 7], [7, 7], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [8, 24], [9, 24], [10, 24], [11, 24], [12, 24], [13, 24], [14, 24], [15, 24], [16, 24], [17, 24], [18, 24], [19, 24], [20, 24], [21, 24], [22, 24], [23, 24], [24, 24], [24, 23], [24, 22], [24, 21], [24, 20], [24, 19], [24, 18], [24, 17], [24, 16], [24, 15], [24, 14], [24, 13], [24, 12], [24, 11], [24, 10], [24, 9], [24, 8], [24, 7], [24, 6], [23, 6], [22, 6], [21, 6], [20, 6], [19, 6], [18, 6], [17, 6], [16, 6], [15, 6], [14, 6], [13, 6], [12, 6], [11, 6], [10, 6], [9, 6], [8, 6], [7, 6], [6, 6], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [7, 25], [8, 25], [9, 25], [10, 25], [11, 25], [12, 25], [13, 25], [14, 25], [15, 25], [16, 25], [17, 25], [18, 25], [19, 25], [20, 25], [21, 25], [22, 25], [23, 25], [24, 25], [25, 25], [25, 24], [25, 23], [25, 22], [25, 21], [25, 20], [25, 19], [25, 18], [25, 17], [25, 16], [25, 15], [25, 14], [25, 13], [25, 12], [25, 11], [25, 10], [25, 9], [25, 8], [25, 7], [25, 6], [25, 5], [24, 5], [23, 5], [22, 5], [21, 5], [20, 5], [19, 5], [18, 5], [17, 5], [16, 5], [15, 5], [14, 5], [13, 5], [12, 5], [11, 5], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [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, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [6, 26], [7, 26], [8, 26], [9, 26], [10, 26], [11, 26], [12, 26], [13, 26], [14, 26], [15, 26], [16, 26], [17, 26], [18, 26], [19, 26], [20, 26], [21, 26], [22, 26], [23, 26], [24, 26], [25, 26], [26, 26], [26, 25], [26, 24], [26, 23], [26, 22], [26, 21], [26, 20], [26, 19], [26, 18], [26, 17], [26, 16], [26, 15], [26, 14], [26, 13], [26, 12], [26, 11], [26, 10], [26, 9], [26, 8], [26, 7], [26, 6], [26, 5], [26, 4], [25, 4], [24, 4], [23, 4], [22, 4], [21, 4], [20, 4], [19, 4], [18, 4], [17, 4], [16, 4], [15, 4], [14, 4], [13, 4], [12, 4], [11, 4], [10, 4], [9, 4], [8, 4], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [5, 27], [6, 27], [7, 27], [8, 27], [9, 27], [10, 27], [11, 27], [12, 27], [13, 27], [14, 27], [15, 27], [16, 27], [17, 27], [18, 27], [19, 27], [20, 27], [21, 27], [22, 27], [23, 27], [24, 27], [25, 27], [26, 27], [27, 27], [27, 26], [27, 25], [27, 24], [27, 23], [27, 22], [27, 21], [27, 20], [27, 19], [27, 18], [27, 17], [27, 16], [27, 15], [27, 14], [27, 13], [27, 12], [27, 11], [27, 10], [27, 9], [27, 8], [27, 7], [27, 6], [27, 5], [27, 4], [27, 3], [26, 3], [25, 3], [24, 3], [23, 3], [22, 3], [21, 3], [20, 3], [19, 3], [18, 3], [17, 3], [16, 3], [15, 3], [14, 3], [13, 3], [12, 3], [11, 3], [10, 3], [9, 3], [8, 3], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [4, 28], [5, 28], [6, 28], [7, 28], [8, 28], [9, 28], [10, 28], [11, 28], [12, 28], [13, 28], [14, 28], [15, 28], [16, 28], [17, 28], [18, 28], [19, 28], [20, 28], [21, 28], [22, 28], [23, 28], [24, 28], [25, 28], [26, 28], [27, 28], [28, 28], [28, 27], [28, 26], [28, 25], [28, 24], [28, 23], [28, 22], [28, 21], [28, 20], [28, 19], [28, 18], [28, 17], [28, 16], [28, 15], [28, 14], [28, 13], [28, 12], [28, 11], [28, 10], [28, 9], [28, 8], [28, 7], [28, 6], [28, 5], [28, 4], [28, 3], [28, 2], [27, 2], [26, 2], [25, 2], [24, 2], [23, 2], [22, 2], [21, 2], [20, 2], [19, 2], [18, 2], [17, 2], [16, 2], [15, 2], [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], [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], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [3, 29], [4, 29], [5, 29], [6, 29], [7, 29], [8, 29], [9, 29], [10, 29], [11, 29], [12, 29], [13, 29], [14, 29], [15, 29], [16, 29], [17, 29], [18, 29], [19, 29], [20, 29], [21, 29], [22, 29], [23, 29], [24, 29], [25, 29], [26, 29], [27, 29], [28, 29], [29, 29], [29, 28], [29, 27], [29, 26], [29, 25], [29, 24], [29, 23], [29, 22], [29, 21], [29, 20], [29, 19], [29, 18], [29, 17], [29, 16], [29, 15], [29, 14], [29, 13], [29, 12], [29, 11], [29, 10], [29, 9], [29, 8], [29, 7], [29, 6], [29, 5], [29, 4], [29, 3], [29, 2], [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], [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], [29, 0], [28, 0], [27, 0], [26, 0], [25, 0], [24, 0], [23, 0], [22, 0], [21, 0], [20, 0], [19, 0], [18, 0], [17, 0], [16, 0], [15, 0], [14, 0], [13, 0], [12, 0], [11, 0], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29]]\n assert candidate(rows = 8,cols = 4,rStart = 7,cStart = 3) == [[7, 3], [7, 2], [6, 2], [6, 3], [7, 1], [6, 1], [5, 1], [5, 2], [5, 3], [7, 0], [6, 0], [5, 0], [4, 0], [4, 1], [4, 2], [4, 3], [3, 0], [3, 1], [3, 2], [3, 3], [2, 0], [2, 1], [2, 2], [2, 3], [1, 0], [1, 1], [1, 2], [1, 3], [0, 0], [0, 1], [0, 2], [0, 3]]\n assert candidate(rows = 8,cols = 8,rStart = 7,cStart = 7) == [[7, 7], [7, 6], [6, 6], [6, 7], [7, 5], [6, 5], [5, 5], [5, 6], [5, 7], [7, 4], [6, 4], [5, 4], [4, 4], [4, 5], [4, 6], [4, 7], [7, 3], [6, 3], [5, 3], [4, 3], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7]]\n", "comparison": "exact"}, "public_tests": ["1\n4\n0\n0", "5\n6\n1\n4"], "hints": [], "metadata": {"canonical_parameter_names": ["rows", "cols", "rStart", "cStart"], "leetcode_dataset_entry_point": "Solution().spiralMatrixIII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:07+00:00", "tests_total": 74, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def spiralMatrixIII(self, rows: int, cols: int, rStart: int, cStart: int) -> list[list[int]]:", "container": "Solution", "callable": "spiralMatrixIII", "parameters": [{"name": "rows", "type": "int"}, {"name": "cols", "type": "int"}, {"name": "rStart", "type": "int"}, {"name": "cStart", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 886, "task_id": "possible-bipartition", "difficulty": "Medium", "problem_description": "We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group.\n\nGiven the integer n and the array dislikes where dislikes[i] = [a_i, b_i] indicates that the person labeled a_i does not like the person labeled b_i, return true if it is possible to split everyone into two groups in this way.\n\nExample 1:\n\nInput: n = 4, dislikes = [[1,2],[1,3],[2,4]]\nOutput: true\nExplanation: The first group has [1,4], and the second group has [2,3].\n\nExample 2:\n\nInput: n = 3, dislikes = [[1,2],[1,3],[2,3]]\nOutput: false\nExplanation: We need at least 3 groups to divide them. We cannot put them in two groups.\n\nConstraints:\n\n- 1 <= n <= 2000\n- 0 <= dislikes.length <= 10^4\n- dislikes[i].length == 2\n- 1 <= a_i < b_i <= n\n- All the pairs of dislikes are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,dislikes = [[1, 2], [1, 3], [2, 4]]) == True\n assert candidate(n = 5,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == False\n assert candidate(n = 3,dislikes = [[1, 2]]) == True\n assert candidate(n = 3,dislikes = [[1, 2], [2, 3]]) == True\n assert candidate(n = 1,dislikes = []) == True\n assert candidate(n = 6,dislikes = [[1, 2], [3, 4], [5, 6]]) == True\n assert candidate(n = 3,dislikes = [[1, 2], [1, 3], [2, 3]]) == False\n assert candidate(n = 5,dislikes = [[1, 2], [3, 4]]) == True\n assert candidate(n = 5,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5]]) == True\n assert candidate(n = 5,dislikes = [[1, 2], [3, 4], [4, 5], [3, 5]]) == False\n assert candidate(n = 10,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 3], [4, 6], [7, 9], [2, 10]]) == True\n assert candidate(n = 20,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [2, 4], [6, 8], [10, 12], [14, 16], [18, 20]]) == True\n assert candidate(n = 15,dislikes = [[1, 2], [2, 3], [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]]) == False\n assert candidate(n = 7,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 7]]) == False\n assert candidate(n = 15,dislikes = [[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]]) == True\n assert candidate(n = 9,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9], [1, 3], [3, 5], [5, 7], [2, 4], [4, 6], [6, 8]]) == False\n assert candidate(n = 7,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 7], [1, 3], [2, 4], [5, 7]]) == False\n assert candidate(n = 6,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6]]) == True\n assert candidate(n = 6,dislikes = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 6]]) == True\n assert candidate(n = 8,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]]) == True\n assert candidate(n = 20,dislikes = [[1, 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]]) == True\n assert candidate(n = 10,dislikes = [[1, 3], [1, 5], [2, 4], [2, 6], [3, 5], [3, 7], [4, 6], [4, 8], [5, 7], [5, 9], [6, 8], [6, 10], [7, 9], [8, 10]]) == False\n assert candidate(n = 9,dislikes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 9], [2, 8], [3, 7], [4, 6]]) == False\n assert candidate(n = 2000,dislikes = [[1, 2], [2, 3], [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]]) == False\n assert candidate(n = 16,dislikes = [[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]]) == True\n assert candidate(n = 8,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8], [1, 5], [2, 6], [3, 7], [4, 8]]) == True\n assert candidate(n = 16,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [1, 3], [2, 4], [5, 7], [6, 8], [9, 11], [10, 12], [13, 15], [14, 16]]) == True\n assert candidate(n = 10,dislikes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [4, 5], [6, 7], [8, 9], [9, 10]]) == False\n assert candidate(n = 10,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 3], [4, 6], [7, 9], [2, 8], [5, 10]]) == True\n assert candidate(n = 12,dislikes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == False\n assert candidate(n = 10,dislikes = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 3], [2, 4], [5, 7], [6, 8], [7, 9], [8, 10]]) == True\n", "comparison": "exact"}, "public_tests": ["4\n[[1,2],[1,3],[2,4]]", "3\n[[1,2],[1,3],[2,3]]"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "dislikes"], "leetcode_dataset_entry_point": "Solution().possibleBipartition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:09+00:00", "tests_total": 76, "tests_dropped": 45, "flags": [], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph", "graph-coloring", "bipartite-graph"]}, "language": "python", "interface": {"raw_signature": "def possibleBipartition(self, n: int, dislikes: list[list[int]]) -> bool:", "container": "Solution", "callable": "possibleBipartition", "parameters": [{"name": "n", "type": "int"}, {"name": "dislikes", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 887, "task_id": "super-egg-drop", "difficulty": "Hard", "problem_description": "You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.\n\nYou know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.\n\nEach move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.\n\nReturn the minimum number of moves that you need to determine with certainty what the value of f is.\n\nExample 1:\n\nInput: k = 1, n = 2\nOutput: 2\nExplanation:\nDrop the egg from floor 1. If it breaks, we know that f = 0.\nOtherwise, drop the egg from floor 2. If it breaks, we know that f = 1.\nIf it does not break, then we know f = 2.\nHence, we need at minimum 2 moves to determine with certainty what the value of f is.\n\nExample 2:\n\nInput: k = 2, n = 6\nOutput: 3\n\nExample 3:\n\nInput: k = 3, n = 14\nOutput: 4\n\nConstraints:\n\n- 1 <= k <= 100\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 2,n = 1) == 1\n assert candidate(k = 5,n = 1000) == 11\n assert candidate(k = 1,n = 100) == 100\n assert candidate(k = 1,n = 2) == 2\n assert candidate(k = 2,n = 6) == 3\n assert candidate(k = 50,n = 10000) == 14\n assert candidate(k = 10,n = 5000) == 13\n assert candidate(k = 10,n = 1000) == 10\n assert candidate(k = 2,n = 100) == 14\n assert candidate(k = 2,n = 1000) == 45\n assert candidate(k = 3,n = 5) == 3\n assert candidate(k = 100,n = 10000) == 14\n assert candidate(k = 3,n = 25) == 5\n assert candidate(k = 10,n = 10000) == 14\n assert candidate(k = 3,n = 14) == 4\n assert candidate(k = 1,n = 1) == 1\n assert candidate(k = 8,n = 9000) == 14\n assert candidate(k = 3,n = 20) == 5\n assert candidate(k = 7,n = 5000) == 13\n assert candidate(k = 3,n = 50) == 7\n assert candidate(k = 2,n = 10) == 4\n assert candidate(k = 10,n = 200) == 8\n assert candidate(k = 3,n = 1000) == 19\n assert candidate(k = 4,n = 25) == 5\n assert candidate(k = 24,n = 450) == 9\n assert candidate(k = 15,n = 3000) == 12\n assert candidate(k = 6,n = 3000) == 13\n assert candidate(k = 10,n = 500) == 9\n assert candidate(k = 50,n = 7500) == 13\n assert candidate(k = 20,n = 3000) == 12\n assert candidate(k = 5,n = 100) == 7\n assert candidate(k = 5,n = 5000) == 16\n assert candidate(k = 50,n = 750) == 10\n assert candidate(k = 75,n = 9000) == 14\n assert candidate(k = 70,n = 950) == 10\n assert candidate(k = 50,n = 1000) == 10\n assert candidate(k = 75,n = 9900) == 14\n assert candidate(k = 90,n = 9999) == 14\n assert candidate(k = 4,n = 2000) == 16\n assert candidate(k = 25,n = 8000) == 13\n assert candidate(k = 4,n = 20) == 5\n assert candidate(k = 25,n = 7500) == 13\n assert candidate(k = 4,n = 30) == 5\n assert candidate(k = 50,n = 7000) == 13\n assert candidate(k = 20,n = 4000) == 12\n assert candidate(k = 40,n = 650) == 10\n assert candidate(k = 60,n = 8000) == 13\n assert candidate(k = 8,n = 150) == 8\n assert candidate(k = 90,n = 10000) == 14\n assert candidate(k = 3,n = 1234) == 20\n assert candidate(k = 5,n = 10000) == 18\n assert candidate(k = 3,n = 100) == 9\n assert candidate(k = 25,n = 6000) == 13\n assert candidate(k = 25,n = 500) == 9\n assert candidate(k = 4,n = 4096) == 19\n assert candidate(k = 75,n = 10000) == 14\n assert candidate(k = 4,n = 256) == 10\n assert candidate(k = 5,n = 500) == 10\n assert candidate(k = 30,n = 550) == 10\n assert candidate(k = 60,n = 9500) == 14\n assert candidate(k = 75,n = 8000) == 13\n assert candidate(k = 10,n = 3000) == 12\n assert candidate(k = 50,n = 9000) == 14\n assert candidate(k = 10,n = 2000) == 11\n assert candidate(k = 60,n = 850) == 10\n assert candidate(k = 2,n = 32) == 8\n assert candidate(k = 80,n = 9999) == 14\n assert candidate(k = 5,n = 50) == 6\n assert candidate(k = 20,n = 8000) == 13\n assert candidate(k = 100,n = 5000) == 13\n assert candidate(k = 99,n = 9999) == 14\n assert candidate(k = 4,n = 100) == 8\n assert candidate(k = 4,n = 700) == 12\n assert candidate(k = 100,n = 9999) == 14\n assert candidate(k = 75,n = 7500) == 13\n assert candidate(k = 6,n = 2000) == 12\n assert candidate(k = 8,n = 4000) == 13\n assert candidate(k = 100,n = 1) == 1\n assert candidate(k = 8,n = 8192) == 14\n assert candidate(k = 8,n = 200) == 8\n assert candidate(k = 50,n = 5000) == 13\n assert candidate(k = 3,n = 250) == 12\n assert candidate(k = 90,n = 9000) == 14\n assert candidate(k = 90,n = 9500) == 14\n assert candidate(k = 2,n = 10000) == 141\n assert candidate(k = 12,n = 250) == 8\n assert candidate(k = 15,n = 5000) == 13\n assert candidate(k = 20,n = 9000) == 14\n assert candidate(k = 18,n = 350) == 9\n assert candidate(k = 6,n = 70) == 7\n assert candidate(k = 20,n = 5000) == 13\n assert candidate(k = 7,n = 3456) == 13\n", "comparison": "exact"}, "public_tests": ["1\n2", "2\n6", "3\n14"], "hints": [], "metadata": {"canonical_parameter_names": ["k", "n"], "leetcode_dataset_entry_point": "Solution().superEggDrop", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:12+00:00", "tests_total": 92, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "binary-search", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def superEggDrop(self, k: int, n: int) -> int:", "container": "Solution", "callable": "superEggDrop", "parameters": [{"name": "k", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 888, "task_id": "fair-candy-swap", "difficulty": "Easy", "problem_description": "Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the i^th box of candy that Alice has and bobSizes[j] is the number of candies of the j^th box of candy that Bob has.\n\nSince they are friends, they would like to exchange one candy box each so that after the exchange, they both have the same total amount of candy. The total amount of candy a person has is the sum of the number of candies in each box they have.\n\nReturn an integer array answer where answer[0] is the number of candies in the box that Alice must exchange, and answer[1] is the number of candies in the box that Bob must exchange. If there are multiple answers, you may return any one of them. It is guaranteed that at least one answer exists.\n\nExample 1:\n\nInput: aliceSizes = [1,1], bobSizes = [2,2]\nOutput: [1,2]\n\nExample 2:\n\nInput: aliceSizes = [1,2], bobSizes = [2,3]\nOutput: [1,2]\n\nExample 3:\n\nInput: aliceSizes = [2], bobSizes = [1,3]\nOutput: [2,3]\n\nConstraints:\n\n- 1 <= aliceSizes.length, bobSizes.length <= 10^4\n- 1 <= aliceSizes[i], bobSizes[j] <= 10^5\n- Alice and Bob have a different total number of candies.\n- There will be at least one valid answer for the given input.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(aliceSizes = [3, 7],bobSizes = [1, 9]) == None\n assert candidate(aliceSizes = [10, 20, 30],bobSizes = [5, 15, 25]) == None\n assert candidate(aliceSizes = [1, 1],bobSizes = [2, 2]) == [1, 2]\n assert candidate(aliceSizes = [5, 4, 3],bobSizes = [7, 8, 9]) == [3, 9]\n assert candidate(aliceSizes = [4, 1, 2, 1],bobSizes = [1, 2, 2, 10]) == None\n assert candidate(aliceSizes = [1, 3, 5, 7],bobSizes = [2, 4, 6, 8]) == None\n assert candidate(aliceSizes = [1, 2, 5],bobSizes = [2, 4]) == [5, 4]\n assert candidate(aliceSizes = [35, 17, 4, 24, 19],bobSizes = [68, 32, 20, 92, 21]) == None\n assert candidate(aliceSizes = [1, 2],bobSizes = [2, 3]) == [1, 2]\n assert candidate(aliceSizes = [3, 4],bobSizes = [2, 5]) == None\n assert candidate(aliceSizes = [2],bobSizes = [1, 3]) == [2, 3]\n assert candidate(aliceSizes = [35, 17, 4, 24, 10],bobSizes = [66, 56, 5, 1, 58]) == [10, 58]\n assert candidate(aliceSizes = [4, 1, 2, 1],bobSizes = [1, 2, 2, 3]) == [1, 1]\n assert candidate(aliceSizes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobSizes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == None\n assert candidate(aliceSizes = [1, 3, 5, 7, 9, 11, 13, 15],bobSizes = [2, 4, 6, 8, 10, 12, 14, 16]) == None\n assert candidate(aliceSizes = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],bobSizes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 30]\n assert candidate(aliceSizes = [10000, 20000, 30000, 40000],bobSizes = [5000, 15000, 25000, 35000]) == None\n assert candidate(aliceSizes = [12345, 67890, 54321, 98765],bobSizes = [23456, 78901, 1234, 5678]) == None\n assert candidate(aliceSizes = [55555, 44444, 33333, 22222, 11111],bobSizes = [99999, 88888, 77777, 66666, 55555]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400, 500],bobSizes = [90, 190, 290, 390, 490]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400],bobSizes = [150, 250, 350, 450]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],bobSizes = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == None\n assert candidate(aliceSizes = [5, 20, 10, 30],bobSizes = [15, 25, 35, 5]) == None\n assert candidate(aliceSizes = [2, 4, 6, 8, 10, 12],bobSizes = [1, 3, 5, 7, 9, 11, 13]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400],bobSizes = [150, 250, 350, 450, 550]) == None\n assert candidate(aliceSizes = [50000, 25000, 12500, 6250, 3125],bobSizes = [45000, 22500, 11250, 5625, 2812]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400],bobSizes = [50, 150, 250, 350]) == None\n assert candidate(aliceSizes = [101, 202, 303, 404, 505, 606, 707, 808, 909],bobSizes = [99, 198, 297, 396, 495, 594, 693, 792, 891]) == None\n assert candidate(aliceSizes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bobSizes = [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]) == None\n assert candidate(aliceSizes = [100000, 1, 2, 3],bobSizes = [99999, 4, 5, 6]) == [1, 5]\n assert candidate(aliceSizes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],bobSizes = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [300, 50]\n assert candidate(aliceSizes = [9, 18, 27, 36, 45],bobSizes = [12, 24, 36, 48, 60]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400, 500],bobSizes = [50, 150, 250, 350, 450]) == None\n assert candidate(aliceSizes = [9, 18, 27, 36, 45],bobSizes = [10, 20, 30, 40, 50]) == None\n assert candidate(aliceSizes = [99, 198, 297, 396, 495],bobSizes = [100, 200, 300, 400, 500]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400, 500, 600, 700],bobSizes = [75, 175, 275, 375, 475, 575, 675]) == None\n assert candidate(aliceSizes = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],bobSizes = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40, 50],bobSizes = [5, 15, 25, 35, 45]) == None\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000, 5000],bobSizes = [1500, 2500, 3500, 4500, 5500]) == None\n assert candidate(aliceSizes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],bobSizes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [8, 1]\n assert candidate(aliceSizes = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000],bobSizes = [5000, 15000, 25000, 35000, 45000, 55000, 65000, 75000, 85000]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400, 500, 600, 700, 800],bobSizes = [150, 250, 350, 450, 550, 650, 750, 850, 950]) == None\n assert candidate(aliceSizes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobSizes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 6]\n assert candidate(aliceSizes = [99999, 88888, 77777, 66666, 55555],bobSizes = [11111, 22222, 33333, 44444, 66666, 77777, 88888]) == [99999, 77777]\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],bobSizes = [1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500, 10500]) == [1000, 3500]\n assert candidate(aliceSizes = [101, 203, 305, 407, 509],bobSizes = [102, 204, 306, 408, 510]) == None\n assert candidate(aliceSizes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobSizes = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40],bobSizes = [5, 15, 25, 35, 45, 55]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobSizes = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == None\n assert candidate(aliceSizes = [1, 5, 9, 13, 17, 21],bobSizes = [2, 6, 10, 14, 18, 22]) == None\n assert candidate(aliceSizes = [50, 51, 52, 53, 54, 55, 56],bobSizes = [49, 50, 51, 52, 53, 54, 55]) == [52, 49]\n assert candidate(aliceSizes = [88, 44, 22, 11, 55, 33, 66, 99, 77],bobSizes = [132, 66, 33, 22, 110, 44, 88, 11, 77]) == [88, 132]\n assert candidate(aliceSizes = [23456, 78901, 34567, 89012],bobSizes = [65432, 12345, 54321, 98765]) == None\n assert candidate(aliceSizes = [10000, 20000, 30000, 40000, 50000, 60000],bobSizes = [15000, 25000, 35000, 45000, 55000, 65000]) == [10000, 25000]\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000, 5000],bobSizes = [5500, 6500, 7500, 8500]) == [1000, 7500]\n assert candidate(aliceSizes = [500, 600, 700, 800, 900],bobSizes = [100, 200, 300, 400, 1400]) == None\n assert candidate(aliceSizes = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999],bobSizes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == None\n assert candidate(aliceSizes = [3, 5, 7, 9, 11, 13, 15, 17, 19],bobSizes = [4, 6, 8, 10, 12, 14, 16, 18, 20]) == [3, 8]\n assert candidate(aliceSizes = [12345, 6789, 2468, 1357, 9753],bobSizes = [8642, 7531, 9513, 5791, 6842]) == None\n assert candidate(aliceSizes = [23, 45, 67, 89, 101, 123, 145],bobSizes = [34, 56, 78, 90, 112, 134, 156]) == None\n assert candidate(aliceSizes = [100000, 100000, 100000, 100000, 100000],bobSizes = [50000, 50000, 50000, 50000, 50000, 50000, 50000]) == None\n assert candidate(aliceSizes = [50, 100, 150, 200, 250, 300],bobSizes = [60, 110, 160, 210, 260, 310]) == None\n assert candidate(aliceSizes = [10000, 20000, 30000, 40000],bobSizes = [5000, 6000, 7000, 8000]) == None\n assert candidate(aliceSizes = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9],bobSizes = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == None\n assert candidate(aliceSizes = [10000, 20000, 30000, 40000, 50000],bobSizes = [5000, 15000, 25000, 35000, 45000, 55000]) == [10000, 25000]\n assert candidate(aliceSizes = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],bobSizes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [17, 2]\n assert candidate(aliceSizes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobSizes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == None\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000],bobSizes = [500, 1500, 2500, 3500]) == None\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000, 5000],bobSizes = [1100, 2100, 3100, 4100, 5100]) == None\n assert candidate(aliceSizes = [1, 3, 5, 7, 9, 11],bobSizes = [2, 4, 6, 8, 10, 12]) == [1, 4]\n assert candidate(aliceSizes = [1, 1, 1, 1, 10000],bobSizes = [5000, 5000, 5000, 5000, 5000]) == None\n assert candidate(aliceSizes = [99990, 1, 2, 3, 4, 5],bobSizes = [100000, 6, 7, 8, 9, 10]) == None\n assert candidate(aliceSizes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000],bobSizes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == None\n assert candidate(aliceSizes = [10000, 20000, 30000],bobSizes = [15000, 25000, 35000]) == None\n assert candidate(aliceSizes = [7, 2, 5, 3, 8, 1, 4, 6, 9, 10],bobSizes = [12, 15, 14, 11, 13, 10, 9, 8, 7, 6]) == None\n assert candidate(aliceSizes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobSizes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 6]\n assert candidate(aliceSizes = [50000, 10000, 30000, 20000, 40000],bobSizes = [15000, 25000, 35000, 45000, 55000]) == None\n assert candidate(aliceSizes = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],bobSizes = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150]) == None\n assert candidate(aliceSizes = [100, 200, 300],bobSizes = [50, 100, 150, 200, 250, 300]) == None\n assert candidate(aliceSizes = [5, 10, 15, 20, 25, 30, 35],bobSizes = [7, 14, 21, 28, 35, 42, 49]) == None\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000],bobSizes = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500, 10500, 11500, 12500, 13500]) == [4000, 500]\n assert candidate(aliceSizes = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],bobSizes = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobSizes = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [30, 5]\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000],bobSizes = [1500, 2500, 3500, 500]) == None\n assert candidate(aliceSizes = [1000, 2000, 3000, 4000, 5000],bobSizes = [500, 1500, 2500, 3500, 4500]) == None\n assert candidate(aliceSizes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bobSizes = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40, 50],bobSizes = [5, 15, 25, 35, 45]) == None\n assert candidate(aliceSizes = [15, 25, 35, 45, 55, 65],bobSizes = [14, 24, 34, 44, 54, 64]) == None\n assert candidate(aliceSizes = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],bobSizes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == None\n assert candidate(aliceSizes = [10, 20, 30, 40, 50],bobSizes = [15, 25, 35, 45, 55]) == None\n assert candidate(aliceSizes = [1, 10, 100, 1000, 10000],bobSizes = [2, 20, 200, 2000, 20000]) == None\n", "comparison": "exact"}, "public_tests": ["[1,1]\n[2,2]", "[1,2]\n[2,3]", "[2]\n[1,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["aliceSizes", "bobSizes"], "leetcode_dataset_entry_point": "Solution().fairCandySwap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:14+00:00", "tests_total": 93, "tests_dropped": 2, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def fairCandySwap(self, aliceSizes: list[int], bobSizes: list[int]) -> list[int]:", "container": "Solution", "callable": "fairCandySwap", "parameters": [{"name": "aliceSizes", "type": "list[int]"}, {"name": "bobSizes", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 890, "task_id": "find-and-replace-pattern", "difficulty": "Medium", "problem_description": "Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order.\n\nA word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.\n\nRecall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.\n\nExample 1:\n\nInput: words = [\"abc\",\"deq\",\"mee\",\"aqq\",\"dkd\",\"ccc\"], pattern = \"abb\"\nOutput: [\"mee\",\"aqq\"]\nExplanation: \"mee\" matches the pattern because there is a permutation {a -> m, b -> e, ...}.\n\"ccc\" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, since a and b map to the same letter.\n\nExample 2:\n\nInput: words = [\"a\",\"b\",\"c\"], pattern = \"a\"\nOutput: [\"a\",\"b\",\"c\"]\n\nConstraints:\n\n- 1 <= pattern.length <= 20\n- 1 <= words.length <= 50\n- words[i].length == pattern.length\n- pattern and words[i] are lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(words=['abc', 'deq', 'mee', 'aqq', 'dkd', 'ccc'], pattern='abb'), ['mee', 'aqq'])\n assert answers_match(candidate(words=['abb', 'abb', 'abb'], pattern='abc'), [])\n assert answers_match(candidate(words=['abb', 'abc', 'abz', 'xyz', 'xyy'], pattern='abb'), ['abb', 'xyy'])\n assert answers_match(candidate(words=['aaa', 'bbb', 'ccc'], pattern='aaa'), ['aaa', 'bbb', 'ccc'])\n assert answers_match(candidate(words=['a', 'b', 'c'], pattern='a'), ['a', 'b', 'c'])\n assert answers_match(candidate(words=['hello', 'world', 'abcde', 'uvwxy'], pattern='abcde'), ['world', 'abcde', 'uvwxy'])\n assert answers_match(candidate(words=['abb', 'abb', 'abb', 'abb'], pattern='abc'), [])\n assert answers_match(candidate(words=['abb', 'abc', 'aab'], pattern='abb'), ['abb'])\n assert answers_match(candidate(words=['aba', 'bcb', 'bab'], pattern='aba'), ['aba', 'bcb', 'bab'])\n assert answers_match(candidate(words=['abb', 'abc', 'aab', 'aba'], pattern='abb'), ['abb'])\n assert answers_match(candidate(words=['abb', 'abc', 'xyz', 'xyy'], pattern='abb'), ['abb', 'xyy'])\n assert answers_match(candidate(words=['abb', 'aaa', 'aab'], pattern='abb'), ['abb'])\n assert answers_match(candidate(words=['abba', 'abab', 'baab', 'baba', 'aaaa'], pattern='aabb'), [])\n assert answers_match(candidate(words=['abac', 'bcad', 'aacc', 'bbdd', 'aabb'], pattern='abab'), [])\n assert answers_match(candidate(words=['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'cdefghi'], pattern='abcdefg'), ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'cdefghi'])\n assert answers_match(candidate(words=['abcabc', 'bcbcbc', 'dedede', 'aiaiai', 'jkjkjk'], pattern='abcabc'), ['abcabc'])\n assert answers_match(candidate(words=['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi'], pattern='abcde'), ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi'])\n assert answers_match(candidate(words=['zyx', 'yxz', 'xyz', 'zyz', 'yzy', 'zzy', 'zzz', 'zzz'], pattern='zyx'), ['zyx', 'yxz', 'xyz'])\n assert answers_match(candidate(words=['xyx', 'yxy', 'xyz', 'zyz'], pattern='aba'), ['xyx', 'yxy', 'zyz'])\n assert answers_match(candidate(words=['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd'], pattern='abcde'), ['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd'])\n assert answers_match(candidate(words=['abcd', 'efgh', 'ijkl'], pattern='abcd'), ['abcd', 'efgh', 'ijkl'])\n assert answers_match(candidate(words=['abcd', 'abcc', 'abbc', 'abcb', 'acbb', 'adbb'], pattern='abbc'), ['abbc'])\n assert answers_match(candidate(words=['abcd', 'dcba', 'abab', 'dcdc', 'aabb'], pattern='abcd'), ['abcd', 'dcba'])\n assert answers_match(candidate(words=['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'], pattern='aabbcc'), ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'])\n assert answers_match(candidate(words=['zzzz', 'zzzz', 'zzzz', 'zzzz'], pattern='aaaa'), ['zzzz', 'zzzz', 'zzzz', 'zzzz'])\n assert answers_match(candidate(words=['abbc', 'deee', 'zzzz'], pattern='aabb'), [])\n assert answers_match(candidate(words=['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd', 'fghij'], pattern='abcde'), ['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd', 'fghij'])\n assert answers_match(candidate(words=['abcdef', 'fedcba', 'ghijkl', 'lkjihg', 'mnopqr', 'rqponm'], pattern='abcdef'), ['abcdef', 'fedcba', 'ghijkl', 'lkjihg', 'mnopqr', 'rqponm'])\n assert answers_match(candidate(words=['ijkl', 'ikjl', 'ijlk', 'ijlk', 'ikjl'], pattern='ijkl'), ['ijkl', 'ikjl', 'ijlk', 'ijlk', 'ikjl'])\n assert answers_match(candidate(words=['mnop', 'qrst', 'uvwx'], pattern='mnop'), ['mnop', 'qrst', 'uvwx'])\n assert answers_match(candidate(words=['xyzx', 'yzxy', 'zxyx', 'yxzy', 'xzyz', 'zyzx', 'yzyz', 'zyzy'], pattern='abcb'), ['zxyx', 'xzyz'])\n assert answers_match(candidate(words=['mnop', 'mnop', 'mnop', 'mnop', 'mnop', 'mnop', 'mnop', 'mnop'], pattern='mnop'), ['mnop', 'mnop', 'mnop', 'mnop', 'mnop', 'mnop', 'mnop', 'mnop'])\n assert answers_match(candidate(words=['tttt', 'tqtq', 'ttqt', 'qtqt', 'qtqq'], pattern='aaaa'), ['tttt'])\n assert answers_match(candidate(words=['xyy', 'yxx', 'xyz', 'xyx', 'xxy'], pattern='aba'), ['xyx'])\n assert answers_match(candidate(words=['qrst', 'qstr', 'qrts', 'qtsr', 'qtpr', 'qrsp'], pattern='qrst'), ['qrst', 'qstr', 'qrts', 'qtsr', 'qtpr', 'qrsp'])\n assert answers_match(candidate(words=['xyzy', 'zyxy', 'yzyx', 'zyxz'], pattern='xyzy'), ['xyzy', 'zyxy'])\n assert answers_match(candidate(words=['mnop', 'qrst', 'uvwx', 'yzxy', 'qrst'], pattern='abcd'), ['mnop', 'qrst', 'uvwx', 'qrst'])\n assert answers_match(candidate(words=['qrst', 'rstq', 'stqr', 'tqrs', 'qrst', 'rstq', 'stqr', 'tqrs'], pattern='abcd'), ['qrst', 'rstq', 'stqr', 'tqrs', 'qrst', 'rstq', 'stqr', 'tqrs'])\n assert answers_match(candidate(words=['mnop', 'nopm', 'opmn', 'pqrs', 'qrst', 'stuv', 'tuvw', 'uvwx'], pattern='mnop'), ['mnop', 'nopm', 'opmn', 'pqrs', 'qrst', 'stuv', 'tuvw', 'uvwx'])\n assert answers_match(candidate(words=['xxy', 'xyy', 'yxx', 'yyx', 'xyx', 'yxy'], pattern='xyy'), ['xyy', 'yxx'])\n assert answers_match(candidate(words=['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk'], pattern='abc'), ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk'])\n assert answers_match(candidate(words=['abacabadabacaba', 'babcbabcbbabcbb', 'abacabadabcadaa'], pattern='abacabadabacaba'), ['abacabadabacaba'])\n assert answers_match(candidate(words=['xyyx', 'mnop', 'qrst'], pattern='mnop'), ['mnop', 'qrst'])\n assert answers_match(candidate(words=['deq', 'mee', 'aqq', 'dkd', 'ccc', 'eii', 'fff', 'ggh'], pattern='abb'), ['mee', 'aqq', 'eii'])\n assert answers_match(candidate(words=['abcde', 'vwxyz', 'pqrst'], pattern='uvwxy'), ['abcde', 'vwxyz', 'pqrst'])\n assert answers_match(candidate(words=['qrst', 'uvwx', 'yzab'], pattern='abcd'), ['qrst', 'uvwx', 'yzab'])\n assert answers_match(candidate(words=['xyx', 'yxy', 'zaz', 'azz', 'bzb', 'abb'], pattern='aba'), ['xyx', 'yxy', 'zaz', 'bzb'])\n assert answers_match(candidate(words=['xyz', 'xyy', 'xzy', 'yxy', 'yzy', 'zyx'], pattern='xyz'), ['xyz', 'xzy', 'zyx'])\n assert answers_match(candidate(words=['mnop', 'nmop', 'mnop', 'npom', 'mnop'], pattern='abcd'), ['mnop', 'nmop', 'mnop', 'npom', 'mnop'])\n assert answers_match(candidate(words=['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf'], pattern='abcdef'), ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcf'])\n assert answers_match(candidate(words=['mnop', 'nomp', 'mpon', 'mnop', 'mnoo', 'mmno'], pattern='mnop'), ['mnop', 'nomp', 'mpon', 'mnop'])\n assert answers_match(candidate(words=['abca', 'decd', 'mefm', 'aqqz', 'dkdf', 'ccca'], pattern='abba'), [])\n assert answers_match(candidate(words=['aabbcc', 'bbccdd', 'ccddaa', 'ddeeff', 'eefggh'], pattern='aabbcc'), ['aabbcc', 'bbccdd', 'ccddaa', 'ddeeff'])\n assert answers_match(candidate(words=['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk'], pattern='abcd'), ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk'])\n assert answers_match(candidate(words=['abba', 'abab', 'aabb', 'baba', 'baab', 'bbaa'], pattern='abba'), ['abba', 'baab'])\n assert answers_match(candidate(words=['abacaba', 'cabadab', 'bacabac', 'adabaad', 'abaabab'], pattern='abacaba'), ['abacaba'])\n assert answers_match(candidate(words=['ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs'], pattern='mnop'), ['ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs'])\n assert answers_match(candidate(words=['zzzzz', 'yyyyy', 'xxxxx', 'wwwww', 'vvvvv'], pattern='aaaaa'), ['zzzzz', 'yyyyy', 'xxxxx', 'wwwww', 'vvvvv'])\n assert answers_match(candidate(words=['mnoonm', 'mnoono', 'mmnnoo', 'noonmm'], pattern='mnoonm'), ['mnoonm'])\n assert answers_match(candidate(words=['xyyx', 'mnop', 'qrst'], pattern='abba'), ['xyyx'])\n assert answers_match(candidate(words=['zzz', 'aaa', 'zzz', 'aaa'], pattern='abc'), [])\n assert answers_match(candidate(words=['abcde', 'edcba', 'abcde', 'edcba'], pattern='abcde'), ['abcde', 'edcba', 'abcde', 'edcba'])\n assert answers_match(candidate(words=['abcd', 'abca', 'abcb', 'abcc', 'abdd'], pattern='abba'), [])\n assert answers_match(candidate(words=['baba', 'abab', 'aaaa', 'bbbb', 'abcd'], pattern='abba'), [])\n assert answers_match(candidate(words=['abcd', 'abab', 'abac', 'aabb', 'abba', 'aaaa', 'bbbb', 'abac'], pattern='abcd'), ['abcd'])\n assert answers_match(candidate(words=['abac', 'deed', 'zaff'], pattern='deed'), ['deed'])\n assert answers_match(candidate(words=['abcdefgh', 'hgfedcba', 'ijklmnop', 'ponmlkji', 'qrstuvwx', 'xwvutsrq'], pattern='abcdefgh'), ['abcdefgh', 'hgfedcba', 'ijklmnop', 'ponmlkji', 'qrstuvwx', 'xwvutsrq'])\n assert answers_match(candidate(words=['abcde', 'vwxyz', 'pqrst'], pattern='vwxyz'), ['abcde', 'vwxyz', 'pqrst'])\n assert answers_match(candidate(words=['abac', 'baba', 'abca', 'baac', 'caba', 'dada'], pattern='abac'), ['abac'])\n assert answers_match(candidate(words=['efgh', 'efgi', 'efgh', 'efgi', 'efgh'], pattern='abcd'), ['efgh', 'efgi', 'efgh', 'efgi', 'efgh'])\n assert answers_match(candidate(words=['ababab', 'bababa', 'cdcdcd', 'dcdcdc', 'efefef', 'fefefe'], pattern='ababab'), ['ababab', 'bababa', 'cdcdcd', 'dcdcdc', 'efefef', 'fefefe'])\n assert answers_match(candidate(words=['abab', 'baba', 'abba', 'aaaa', 'bbbb', 'cccc', 'aabb', 'abab'], pattern='abab'), ['abab', 'baba', 'abab'])\n assert answers_match(candidate(words=['abab', 'baba', 'abba', 'baab', 'aaaa', 'bbbb'], pattern='abab'), ['abab', 'baba'])\n assert answers_match(candidate(words=['aabbcc', 'bbccdd', 'ccddaa', 'ddeeff', 'eeffgg', 'ffggee'], pattern='abcdef'), [])\n assert answers_match(candidate(words=['zzzz', 'zzyz', 'zyzy', 'zyyz'], pattern='aaaa'), ['zzzz'])\n assert answers_match(candidate(words=['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee', 'ffffff'], pattern='aaaaaa'), ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee', 'ffffff'])\n assert answers_match(candidate(words=['aab', 'aba', 'aab', 'aba', 'aab'], pattern='aba'), ['aba', 'aba'])\n assert answers_match(candidate(words=['aaaaa', 'bbbbb', 'ccccc'], pattern='abcde'), [])\n assert answers_match(candidate(words=['abcde', 'vwxyz', 'mnopq', 'rstuv', 'fghij'], pattern='abcde'), ['abcde', 'vwxyz', 'mnopq', 'rstuv', 'fghij'])\n assert answers_match(candidate(words=['aab', 'aba', 'baa', 'aaa'], pattern='aab'), ['aab'])\n assert answers_match(candidate(words=['aabb', 'bbcc', 'ccdd'], pattern='aabb'), ['aabb', 'bbcc', 'ccdd'])\n assert answers_match(candidate(words=['aabbccdd', 'bbaaddcc', 'ccddaabb', 'ddccaabb'], pattern='aabbccdd'), ['aabbccdd', 'bbaaddcc', 'ccddaabb', 'ddccaabb'])\n assert answers_match(candidate(words=['abcdefgh', 'hgfedcba', 'abcdefgh', 'hgfedcba'], pattern='abcdefgh'), ['abcdefgh', 'hgfedcba', 'abcdefgh', 'hgfedcba'])\n assert answers_match(candidate(words=['wxyz', 'wyxz', 'wyzx', 'wxzy', 'wxyz'], pattern='wxyz'), ['wxyz', 'wyxz', 'wyzx', 'wxzy', 'wxyz'])\n assert answers_match(candidate(words=['zzzz', 'yyyy', 'xxxx', 'wwww', 'vvvv', 'uuuu'], pattern='aaaa'), ['zzzz', 'yyyy', 'xxxx', 'wwww', 'vvvv', 'uuuu'])\n assert answers_match(candidate(words=['ab', 'ba', 'aa', 'bb', 'cc', 'dd'], pattern='ab'), ['ab', 'ba'])\n assert answers_match(candidate(words=['xxyy', 'xyyx', 'xxyx', 'yxyx'], pattern='abab'), ['yxyx'])\n assert answers_match(candidate(words=['abac', 'abcd', 'abca', 'abac'], pattern='abac'), ['abac', 'abac'])\n assert answers_match(candidate(words=['uvw', 'uvw', 'uvw', 'uvw', 'uvw', 'uvw'], pattern='uvw'), ['uvw', 'uvw', 'uvw', 'uvw', 'uvw', 'uvw'])\n assert answers_match(candidate(words=['pqrs', 'prqs', 'psqr', 'psrq', 'pqsr'], pattern='qrst'), ['pqrs', 'prqs', 'psqr', 'psrq', 'pqsr'])\n assert answers_match(candidate(words=['abc', 'bcd', 'cde', 'def', 'efg', 'fgh'], pattern='abc'), ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh'])\n assert answers_match(candidate(words=['aabcb', 'bbaab', 'cbbaa', 'ababa'], pattern='aabcb'), ['aabcb'])\n assert answers_match(candidate(words=['aaaabbbb', 'ccccdddd', 'eeeeffff', 'ggggaaaa', 'bbbbcccc'], pattern='aabbccdd'), [])\n assert answers_match(candidate(words=['aaaaa', 'bbbbb', 'ccccc'], pattern='zzzzz'), ['aaaaa', 'bbbbb', 'ccccc'])\n assert answers_match(candidate(words=['mxyz', 'yzxy', 'zxyz', 'yzzx', 'zzzz'], pattern='wxyz'), ['mxyz'])\n assert answers_match(candidate(words=['aabb', 'bbcc', 'ccdd', 'aacc', 'abab'], pattern='aabb'), ['aabb', 'bbcc', 'ccdd', 'aacc'])\n assert answers_match(candidate(words=['abc', 'acb', 'bac', 'bca', 'cab', 'cba'], pattern='abc'), ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'])\n assert answers_match(candidate(words=['abcd', 'abdc', 'acbd', 'acdb'], pattern='acdb'), ['abcd', 'abdc', 'acbd', 'acdb'])\n assert answers_match(candidate(words=['stuv', 'stvu', 'tuvv', 'stvv', 'stvu'], pattern='stvu'), ['stuv', 'stvu', 'stvu'])\n assert answers_match(candidate(words=['abac', 'deed', 'zaff'], pattern='abab'), [])\n assert answers_match(candidate(words=['ababab', 'bababa', 'ababba', 'bababb', 'aabbab', 'bbaaab', 'abbaab', 'babaab'], pattern='ababab'), ['ababab', 'bababa'])\n assert answers_match(candidate(words=['mnop', 'ponm', 'mpon', 'mnop', 'nmop'], pattern='mnop'), ['mnop', 'ponm', 'mpon', 'mnop', 'nmop'])\n assert answers_match(candidate(words=['abac', 'baca', 'caab', 'acab', 'caba'], pattern='abac'), ['abac', 'acab'])\n assert answers_match(candidate(words=['aabb', 'bbaa', 'abab', 'baab', 'aaaa', 'bbbb', 'abba', 'baba'], pattern='aabb'), ['aabb', 'bbaa'])\n assert answers_match(candidate(words=['abcabc', 'defdef', 'ghighi', 'jkljkl', 'mnopqr'], pattern='abcabc'), ['abcabc', 'defdef', 'ghighi', 'jkljkl'])\n", "comparison": "unordered"}, "public_tests": ["[\"abc\",\"deq\",\"mee\",\"aqq\",\"dkd\",\"ccc\"]\n\"abb\"", "[\"a\",\"b\",\"c\"]\n\"a\""], "hints": [], "metadata": {"canonical_parameter_names": ["words", "pattern"], "leetcode_dataset_entry_point": "Solution().findAndReplacePattern", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:18+00:00", "tests_total": 118, "tests_dropped": 13, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def findAndReplacePattern(self, words: list[str], pattern: str) -> list[str]:", "container": "Solution", "callable": "findAndReplacePattern", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "pattern", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 891, "task_id": "sum-of-subsequence-widths", "difficulty": "Hard", "problem_description": "The width of a sequence is the difference between the maximum and minimum elements in the sequence.\n\nGiven an array of integers nums, return the sum of the widths of all the non-empty subsequences of nums. Since the answer may be very large, return it modulo 10^9 + 7.\n\nA subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].\n\nExample 1:\n\nInput: nums = [2,1,3]\nOutput: 6\nExplanation: The subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3].\nThe corresponding widths are 0, 0, 0, 1, 1, 2, 2.\nThe sum of these widths is 6.\n\nExample 2:\n\nInput: nums = [2]\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == 60\n assert candidate(nums = [9, 7, 5, 3, 1]) == 144\n assert candidate(nums = [1, 2, 4, 8, 16]) == 261\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3084\n assert candidate(nums = [1, 3, 5, 7, 9]) == 144\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7181\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 2, 3, 4]) == 23\n assert candidate(nums = [2, 1, 3]) == 6\n assert candidate(nums = [2]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 720\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 71810\n assert candidate(nums = [5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 100000]) == 99999\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 2, 4, 1, 3]) == 72\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [100000]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 2345\n assert candidate(nums = [100000, 100000, 100000]) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 357668181\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 17825815\n assert candidate(nums = [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]) == 782581493\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 929942988\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992]) == 3084\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5]) == 96096610\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 89129075\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 71810000\n assert candidate(nums = [5, 2, 9, 1, 5, 6, 7, 8, 4, 3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 16810038\n assert candidate(nums = [2, 1, 3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 393234\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 39323400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 991029085\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 344405\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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 35651630\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 96097571\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 7181\n assert candidate(nums = [7, 5, 3, 1, 9, 11, 13, 15, 17, 19]) == 14362\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 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]) == 991029085\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17825815\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 14362\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == 85077\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 7181\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 96097571\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]) == 316557572\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 7181\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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 738197532\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 8738145\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 3420\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 3243429\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 393234\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 393234\n assert candidate(nums = [50, 40, 30, 20, 10, 60, 70, 80, 90, 100]) == 71810\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 108954\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7181\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 34200\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 3084\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 178258150\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 51102071\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 7181\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 35651630\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]) == 982058163\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 90000, 80000, 70000, 60000, 55000, 54000, 53000, 52000, 51000, 56000, 57000, 58000, 59000, 61000, 62000]) == 945879552\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 22316373\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1]) == 1291\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 991029085\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]) == 356892986\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450]) == 154200\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 17825815\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 7181\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1, 10, 100, 1000, 10000, 100000]) == 314578971\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 3801600\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 393234000\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]) == 713034816\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 90876700\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 17825815\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 3932340\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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]) == 1966170\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 17825815\n", "comparison": "exact"}, "public_tests": ["[2,1,3]", "[2]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumSubseqWidths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:21+00:00", "tests_total": 86, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "math", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sumSubseqWidths(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumSubseqWidths", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 892, "task_id": "surface-area-of-3d-shapes", "difficulty": "Easy", "problem_description": "You are given an n x n grid where you have placed some 1 x 1 x 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of cell (i, j).\n\nAfter placing these cubes, you have decided to glue any directly adjacent cubes to each other, forming several irregular 3D shapes.\n\nReturn the total surface area of the resulting shapes.\n\nNote: The bottom face of each shape counts toward its surface area.\n\nExample 1:\n\nInput: grid = [[1,2],[3,4]]\nOutput: 34\n\nExample 2:\n\nInput: grid = [[1,1,1],[1,0,1],[1,1,1]]\nOutput: 32\n\nExample 3:\n\nInput: grid = [[2,2,2],[2,1,2],[2,2,2]]\nOutput: 46\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 1 <= n <= 50\n- 0 <= grid[i][j] <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[3, 3, 3], [3, 3, 3], [3, 3, 3]]) == 54\n assert candidate(grid = [[2, 2, 2], [2, 1, 2], [2, 2, 2]]) == 46\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 32\n assert candidate(grid = [[50, 50, 50], [50, 50, 50], [50, 50, 50]]) == 618\n assert candidate(grid = [[1, 2], [3, 4]]) == 34\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]]) == 18\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1]]) == 110\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]]) == 54\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]]) == 78\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [5, 3, 1, 3, 5], [1, 5, 3, 5, 1]]) == 188\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 112\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 78\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 48\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 228\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 9, 8, 7, 6], [1, 2, 3, 4, 5], [6, 7, 8, 9, 0], [5, 4, 3, 2, 1]]) == 218\n assert candidate(grid = [[3, 2, 1], [1, 3, 2], [2, 1, 3]]) == 58\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]]) == 30\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]]) == 32\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 1, 1, 1, 2], [2, 1, 2, 1, 2], [2, 1, 1, 1, 2], [2, 2, 2, 2, 2]]) == 106\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 1, 1, 1, 2], [2, 1, 0, 1, 2], [2, 1, 1, 1, 2], [2, 2, 2, 2, 2]]) == 104\n assert candidate(grid = [[10, 0, 10, 0, 10], [0, 10, 0, 10, 0], [10, 0, 10, 0, 10], [0, 10, 0, 10, 0], [10, 0, 10, 0, 10]]) == 546\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 70\n assert candidate(grid = [[10, 10, 10], [10, 1, 10], [10, 10, 10]]) == 174\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]]) == 90\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]]) == 72\n assert candidate(grid = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == 32\n assert candidate(grid = [[5, 0, 0, 5], [0, 5, 5, 0], [0, 5, 5, 0], [5, 0, 0, 5]]) == 136\n assert candidate(grid = [[0, 0, 0, 0], [0, 9, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 38\n assert candidate(grid = [[5, 5, 5], [5, 0, 5], [5, 5, 5]]) == 96\n assert candidate(grid = [[4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19]]) == 276\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]]) == 178\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]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 96\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 2, 0], [0, 2, 1, 0], [0, 0, 0, 0]]) == 24\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, 3, 5, 4], [3, 2, 3, 1], [5, 1, 5, 3], [4, 1, 4, 2]]) == 132\n assert candidate(grid = [[4, 3, 2, 1, 0], [3, 2, 1, 0, 4], [2, 1, 0, 4, 3], [1, 0, 4, 3, 2], [0, 4, 3, 2, 1]]) == 144\n assert candidate(grid = [[3, 2, 1, 0], [1, 1, 1, 1], [0, 1, 2, 3], [4, 3, 2, 1]]) == 82\n assert candidate(grid = [[10, 0, 10], [0, 20, 0], [10, 0, 10]]) == 250\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 66\n assert candidate(grid = [[4, 0, 0, 0, 0], [0, 4, 0, 0, 0], [0, 0, 4, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 4]]) == 90\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 2, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 26\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]]) == 168\n assert candidate(grid = [[3, 3, 3, 3], [3, 0, 0, 3], [3, 0, 0, 3], [3, 3, 3, 3]]) == 96\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == 108\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [5, 4, 3, 2, 1], [1, 1, 1, 1, 1], [2, 3, 4, 5, 6]]) == 164\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]]) == 86\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == 108\n assert candidate(grid = [[3, 0, 2, 4], [0, 1, 3, 0], [2, 0, 1, 1], [4, 0, 0, 2]]) == 92\n assert candidate(grid = [[3, 4, 5, 6], [5, 6, 7, 8], [7, 8, 9, 10], [9, 10, 11, 12]]) == 188\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, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 98\n assert candidate(grid = [[3, 3, 3, 3], [3, 2, 2, 3], [3, 2, 2, 3], [3, 3, 3, 3]]) == 88\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 0, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == 88\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], [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]]) == 734\n assert candidate(grid = [[4, 0, 4, 0, 4], [0, 3, 0, 3, 0], [4, 0, 4, 0, 4], [0, 3, 0, 3, 0], [4, 0, 4, 0, 4]]) == 218\n assert candidate(grid = [[3, 0, 3], [0, 4, 0], [3, 0, 3]]) == 74\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [1, 3, 5, 3, 1]]) == 160\n assert candidate(grid = [[0, 0, 5, 0], [0, 0, 5, 0], [0, 0, 5, 0], [0, 0, 5, 0]]) == 58\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 0, 0, 0, 0, 5], [5, 0, 1, 1, 0, 5], [5, 0, 1, 1, 0, 5], [5, 0, 0, 0, 0, 5], [5, 5, 5, 5, 5, 5]]) == 256\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2]]) == 78\n assert candidate(grid = [[5, 0, 0, 0, 5], [0, 3, 0, 3, 0], [0, 0, 4, 0, 0], [0, 3, 0, 3, 0], [5, 0, 0, 0, 5]]) == 162\n assert candidate(grid = [[0, 1, 2, 3], [3, 2, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 66\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 48\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 16\n assert candidate(grid = [[5, 0, 0, 0], [0, 5, 0, 0], [0, 0, 5, 0], [0, 0, 0, 5]]) == 88\n assert candidate(grid = [[3, 0, 2, 1], [1, 2, 0, 3], [4, 1, 2, 2], [2, 0, 3, 4]]) == 104\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 40\n assert candidate(grid = [[0, 5, 0, 5], [5, 0, 5, 0], [0, 5, 0, 5], [5, 0, 5, 0]]) == 176\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 2, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 34\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]]) == 286\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 2, 0], [0, 2, 3, 4, 3, 0], [0, 3, 4, 5, 4, 0], [0, 2, 3, 4, 3, 0], [0, 0, 0, 0, 0, 0]]) == 96\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 4, 4, 4, 5], [5, 4, 3, 4, 5], [5, 4, 4, 4, 5], [5, 5, 5, 5, 5]]) == 166\n", "comparison": "exact"}, "public_tests": ["[[1,2],[3,4]]", "[[1,1,1],[1,0,1],[1,1,1]]", "[[2,2,2],[2,1,2],[2,2,2]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().surfaceArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:23+00:00", "tests_total": 78, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry", "matrix"]}, "language": "python", "interface": {"raw_signature": "def surfaceArea(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "surfaceArea", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 893, "task_id": "groups-of-special-equivalent-strings", "difficulty": "Medium", "problem_description": "You are given an array of strings of the same length words.\n\nIn one move, you can swap any two even indexed characters or any two odd indexed characters of a string words[i].\n\nTwo strings words[i] and words[j] are special-equivalent if after any number of moves, words[i] == words[j].\n\n- For example, words[i] = \"zzxy\" and words[j] = \"xyzz\" are special-equivalent because we may make the moves \"zzxy\" -> \"xzzy\" -> \"xyzz\".\n\nA group of special-equivalent strings from words is a non-empty subset of words such that:\n\n- Every pair of strings in the group are special equivalent, and\n- The group is the largest size possible (i.e., there is not a string words[i] not in the group such that words[i] is special-equivalent to every string in the group).\n\nReturn the number of groups of special-equivalent strings from words.\n\nExample 1:\n\nInput: words = [\"abcd\",\"cdab\",\"cbad\",\"xyzz\",\"zzxy\",\"zzyx\"]\nOutput: 3\nExplanation:\nOne group is [\"abcd\", \"cdab\", \"cbad\"], since they are all pairwise special equivalent, and none of the other strings is all pairwise special equivalent to these.\nThe other two groups are [\"xyzz\", \"zzxy\"] and [\"zzyx\"].\nNote that in particular, \"zzxy\" is not special equivalent to \"zzyx\".\n\nExample 2:\n\nInput: words = [\"abc\",\"acb\",\"bac\",\"bca\",\"cab\",\"cba\"]\nOutput: 3\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length <= 20\n- words[i] consist of lowercase English letters.\n- All the strings are of the same length.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abcd', 'abdc', 'cdab', 'cdba', 'dcba', 'bacd']) == 4\n assert candidate(words = ['abcd', 'abdc', 'cdab', 'cdba']) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr']) == 6\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba', 'abba', 'baab']) == 3\n assert candidate(words = ['aabb', 'abab', 'baba', 'bbaa', 'abba', 'baab']) == 3\n assert candidate(words = ['abcde', 'edcba', 'acebd', 'decab', 'bdeca', 'cabed']) == 4\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 3\n assert candidate(words = ['abcde', 'abced', 'adcbe', 'aebcd', 'eabcd', 'ebacd']) == 5\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba', 'aaaa', 'bbbb']) == 5\n assert candidate(words = ['abcd', 'cdab', 'cbad', 'xyzz', 'zzxy', 'zzyx']) == 3\n assert candidate(words = ['abcde', 'edcba', 'abced', 'decba']) == 2\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba']) == 3\n assert candidate(words = ['mnopqr', 'nopqr', 'opqr', 'pqr', 'qr', 'r', 'mnopqrs', 'nopqrs', 'opqrs', 'pqr', 'qr', 'r', 'mnopqrst', 'nopqrst', 'opqrst', 'pqrst', 'qrst', 'rst', 'st', 't']) == 17\n assert candidate(words = ['abcdeabcde', 'cdeabcdeab', 'deabcdeabc', 'eabcdeabcd', 'abcdecdeab', 'bacdecdeba', 'cabdecdeab', 'cbadecdeba', 'abcdefedcb', 'fedcbaedcb', 'gfedcbedcb', 'bacdefedcb', 'defabcdecb', 'cabfedecba', 'cbafedecba', 'dcbaefdcba', 'efabcdecba', 'fedcbaecba', 'gfedcbedcb', 'bacdefecba']) == 12\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 1\n assert candidate(words = ['xxyyzz', 'yyzzxx', 'zzxxyy', 'yxzyxz', 'yzyxzx', 'zyzyyx', 'zyxzyx', 'xyzzyx']) == 3\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccabba', 'aabbcc', 'bbaacc', 'ccabba', 'aabbcc', 'bbaacc']) == 1\n assert candidate(words = ['aabbcc', 'bbaacc', 'ababcc', 'babcac', 'cabcab', 'acbacb']) == 3\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz']) == 1\n assert candidate(words = ['abcdef', 'bacdef', 'decfab', 'fedcba', 'fedbac', 'defacb']) == 6\n assert candidate(words = ['aabbccddeeff', 'bbaaccddeeff', 'aacbbddeeff', 'ddffeeaabbbc', 'effeeddabbcc', 'bbccddfeea', 'ccddeeffaabb', 'effddcbaabbb']) == 6\n assert candidate(words = ['abcdefg', 'gfedcba', 'bdfhace', 'fhdbaec', 'acegfb', 'bfhacd', 'fhbdcae', 'gacfbde']) == 7\n assert candidate(words = ['xyzzxy', 'zzxyxy', 'zxyzyx', 'xyzyzx', 'zyxzyx', 'yxzyxz', 'zyxzyx', 'zxzyzx']) == 5\n assert candidate(words = ['xyxzyxzyx', 'yxzyxzyxy', 'xzyxzyxzy', 'zyxzyxzyx', 'yxyxzyxzy', 'xyzzyxzyx']) == 4\n assert candidate(words = ['aabbcc', 'bbaacc', 'abacbc', 'babcac', 'aabbccdd', 'ddccbb', 'abcdabcd', 'cdabcdab', 'abcdabdc', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd', 'abcdabcd']) == 7\n assert candidate(words = ['abcdefghij', 'abcdefghji', 'jihgfedcba', 'ihgfedcbaj', 'jihgfedabc', 'abcdefghij', 'cbadefghij']) == 3\n assert candidate(words = ['aaaabbbb', 'bbbaaa', 'abababab', 'babaabab', 'bababaab', 'abababba']) == 5\n assert candidate(words = ['abcdabcd', 'cdabcdab', 'bacdbacd', 'dcbadabc', 'badcabcd', 'dcababcd', 'abcdadcb']) == 5\n assert candidate(words = ['abcdef', 'fedcba', 'gfedcb', 'bacdef', 'defabc', 'cabfed', 'cbafed', 'dcbaef', 'efabcd', 'fedabc', 'gfedcb', 'bacdef', 'defabc', 'cabfed', 'cbafed', 'dcbaef', 'efabcd', 'fedabc', 'gfedcb', 'bacdef']) == 5\n assert candidate(words = ['abcdefghij', 'bacdefghij', 'cbadefghij', 'abcdefghij', 'ijabcdefgh', 'hgfedcba', 'abcdefghij', 'bacdefghij']) == 3\n assert candidate(words = ['aabbcc', 'bbaaccaabb', 'ababcc', 'aabcbcba', 'ccbaab', 'bccabaab', 'abccbaab', 'baccbaab', 'aabbccba', 'bbaabbcc']) == 7\n assert candidate(words = ['abcdabcd', 'cdabcdab', 'cbadabcd', 'xyzzxyzz', 'zzxyzzxy', 'zzyxzzyx']) == 3\n assert candidate(words = ['abac', 'baca', 'caba', 'acba', 'abca', 'baca', 'caba', 'acba']) == 4\n assert candidate(words = ['abcdef', 'bacdef', 'cbadef', 'abcdefg', 'gfedcba', 'fedcbag', 'gfedabc', 'gfdecba']) == 5\n assert candidate(words = ['abcdefgh', 'ghfedcba', 'abcdghfe', 'bacdefgh', 'hgfedcba', 'abcdefgh', 'ghfedcba', 'bacdefgh']) == 5\n assert candidate(words = ['aabbcc', 'bbaacc', 'abacbc', 'accabb', 'abcabc', 'cbaabc']) == 2\n assert candidate(words = ['mnopqr', 'qrpmno', 'pqmron', 'opmqrn', 'rnmqpo', 'nqrpom', 'mnopqr', 'qrpmno', 'pqmron', 'opmqrn', 'rnmqpo', 'nqrpom']) == 6\n assert candidate(words = ['abcdef', 'acbedf', 'abefcd', 'efabcd', 'cbadef', 'fedcba']) == 3\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 2\n assert candidate(words = ['abcde', 'edcba', 'deabc', 'cdeab', 'bcdea', 'aebcd', 'abced', 'bcdea', 'cdeab', 'deabc', 'edcba', 'abcde']) == 4\n assert candidate(words = ['abcdefg', 'bacdefg', 'cbadefg', 'dcbaefg', 'edcbafg', 'fedcgb', 'gfedcba']) == 4\n assert candidate(words = ['aabbccddeeff', 'bbaaccddeeff', 'aacbbddeeff', 'deeffaabbcc', 'efdeaabbcc', 'ccddeeffaabb']) == 4\n assert candidate(words = ['aabbccddeeff', 'bbaaccddeeff', 'abbaccddeeff', 'aabbccceeffd', 'aabbccddeff', 'bbaaccddeeff', 'abbaccddeeff', 'aabbccceeffd', 'aabbccddeff', 'bbaaccddeeff', 'abbaccddeeff', 'aabbccceeffd', 'aabbccddeff', 'bbaaccddeeff', 'abbaccddeeff', 'aabbccceeffd', 'aabbccddeff', 'bbaaccddeeff', 'abbaccddeeff', 'aabbccceeffd']) == 3\n assert candidate(words = ['abcdef', 'defabc', 'bcdefa', 'efabcd', 'fabcde', 'abcdefg', 'defabce', 'bcdefag', 'efabcdg', 'fabcdeg', 'abcdefh', 'defabceg', 'bcdefagh', 'efabcdgh', 'fabcdegh', 'abcdef', 'defabc', 'bcdefa', 'efabcd', 'fabcde', 'abcdefg', 'defabce', 'bcdefag', 'efabcdg', 'fabcdeg', 'abcdefh', 'defabceg', 'bcdefagh', 'efabcdgh', 'fabcdegh']) == 9\n assert candidate(words = ['abcdef', 'fedcba', 'bdfeca', 'fdbeca', 'acefbd', 'bfecad', 'fdbeca', 'gacfbde', 'abcdefg', 'gfedcba', 'bdfhace', 'fhdbaec', 'acegfb', 'bfhacd', 'fhbdcae', 'gacfbde', 'mnopqr', 'qrpmno', 'pqmron', 'opmqrn', 'rnmqpo', 'nqrpom', 'mnopqr', 'qrpmno', 'pqmron', 'opmqrn', 'rnmqpo', 'nqrpom']) == 17\n assert candidate(words = ['aabbccddeeff', 'bbaaddccffee', 'aacccbbbddffee', 'ddffeeaaabbbcc', 'bbccddaaffee', 'ffeeddaabbcc', 'ccddeeffaabbbb', 'ddeeffaacccbbbbb']) == 5\n assert candidate(words = ['abcabc', 'bacbac', 'cababc', 'abcbac', 'baccab', 'acbacb', 'acbbac', 'bacbac']) == 4\n assert candidate(words = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh']) == 1\n assert candidate(words = ['pqrstuvw', 'qrstuvwp', 'rstuvwqp', 'stuvwqpr', 'tuvwqprs', 'uvwqprst', 'vwqprstu', 'wqprstuv', 'qprstuvw', 'prstuvqw', 'rstuvqwp', 'stuvqprw', 'tuvqprws', 'uvqprwst', 'vqprwstu', 'qprwstuv']) == 8\n assert candidate(words = ['mnopqr', 'opqrmn', 'pqrmon', 'qrmpno', 'rmpnoq', 'mpnoqr', 'nqrmpo', 'qrpmno']) == 5\n assert candidate(words = ['abcdef', 'defabc', 'bcadef', 'fedcba', 'defacb', 'efabcd']) == 4\n assert candidate(words = ['abcdef', 'fedcba', 'efabcd', 'cdefab', 'bacdef', 'defabc', 'fabcde', 'abcdefg', 'gfedcba', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz']) == 5\n assert candidate(words = ['abcdefgh', 'efghabcd', 'hgfedcba', 'cdabefgh', 'bacdefgh', 'cbadefgh', 'fedcbaab', 'ghfedcba', 'abcdabef', 'efghabcdab']) == 7\n assert candidate(words = ['abcdefg', 'gfedcba', 'cdabefg', 'efgabcd', 'fedcbag', 'bacdefg']) == 4\n assert candidate(words = ['abcdefghijk', 'abcdefghijk', 'abcdefghijk', 'abcdefghijk', 'abcdefghijk', 'abcdefghijk']) == 1\n assert candidate(words = ['abcdefg', 'gfedcba', 'cebgfad', 'bacdfeg', 'adgfceb', 'fdgecab']) == 4\n assert candidate(words = ['aaabbbccc', 'bbbaaaccc', 'aabbccabb', 'bbccaaabb', 'ccbbbaaab', 'aabbbccc', 'bbbaaaccc', 'aabbccabb']) == 5\n assert candidate(words = ['xyzxyz', 'zyxzyx', 'yzxyzx', 'xzyzxz', 'zyxzxy', 'zxyxzy']) == 4\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ababcdcd', 'babcadcd', 'cbadcbad', 'dcbadabc', 'abcdabcd', 'badcabcd']) == 4\n assert candidate(words = ['abcdabcd', 'cdabcdab', 'bacdbacd', 'abcdcdab', 'cdababcd', 'bacdabcd', 'abcdabcd', 'cdabcdab']) == 3\n assert candidate(words = ['zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz']) == 1\n assert candidate(words = ['abcdefgh', 'bacdefgh', 'decfghab', 'fedghabc', 'fedcbagh', 'defghacb', 'gfedcbah', 'hgfedcba']) == 6\n assert candidate(words = ['aabbccddeeff', 'bbaaddeeccff', 'ababcdcdefef', 'babaabcdcdef', 'ccddeeffabcd', 'ddaabbccdefe', 'abcdccddeeff', 'ccddeeffaabb', 'bbccddeeffaa', 'aabbddeeffcc', 'fedcbafedcba', 'defcbafedcba', 'efcbadfedcba', 'cdefbafedcba', 'bacdefedcba', 'abcdefedcba', 'fedcbadefcba', 'defcbadefcba', 'efcbadfedcba', 'cdefbafedcba', 'bacdefedcba', 'abcdebcdfa', 'defcbedabcfa', 'efcbadefabcf', 'cdefbafedabcf', 'bacdefedabcf', 'abcdebcfabcf']) == 14\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'efghabcd', 'cdefghab', 'bacdefgh', 'defghcab', 'fghabcde', 'ghabcdef', 'habcdefg', 'abcdefghg', 'gfedcbaa', 'efghabcd', 'cdefghab', 'bacdefgh', 'defghcab', 'fghabcde', 'ghabcdef', 'habcdefg', 'abcdefghh', 'gfedcbab']) == 8\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'bacdefghij', 'jihgfedcba', 'bacdefghij', 'jihgfedcba']) == 3\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'bdfhjacegi', 'fhjdgbacae', 'acegfbidhj', 'bfhacdijeg', 'fhbdcaejg', 'gacfbdehji']) == 8\n assert candidate(words = ['aabbcc', 'bbaacc', 'abacbc', 'cababc', 'acbacb', 'bcabac', 'cabcab', 'abcabc']) == 3\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ababcdcd', 'babaabcd', 'ccddabcd', 'ddaabbcc', 'abcdccdd', 'ccddabba', 'bbccddaa', 'aabbddcc']) == 4\n assert candidate(words = ['abcdefgh', 'bacdefgh', 'cbadefgh', 'abcdfehg', 'gfedcba', 'hgfedcba', 'abcdefgh', 'bacdefgh']) == 5\n assert candidate(words = ['aabbccddeeff', 'bbaacceeddff', 'aabcbceddeff', 'aabbccddfeef', 'bbaacceeddff', 'aabcbceddeff', 'aabbccddeeff', 'bbaacceeddff']) == 2\n assert candidate(words = ['abcdefgh', 'acegbdfh', 'agbfcehd', 'hgfedcba', 'efghabcd', 'ceafghbd']) == 5\n assert candidate(words = ['aabbccddeeff', 'ffeeddccbbaa', 'bbaaccddffee', 'ffeeddccbbaa', 'aabbccddeeff', 'ffeeddccbbaa']) == 1\n assert candidate(words = ['zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz', 'zzzzzz']) == 1\n assert candidate(words = ['abcdef', 'bacdef', 'cbadef', 'defabc', 'fedcba', 'efdcba', 'fabced']) == 5\n assert candidate(words = ['abcdefgh', 'bacdefgh', 'cbadefgh', 'defghabc', 'fedcbagh', 'efdcgbah', 'gahfedcb', 'hgfedcba']) == 6\n assert candidate(words = ['aabbccddeeff', 'bbaaccddeeff', 'ababccddeeff', 'bbacacddeeff', 'aabbccddeeff', 'aabbcdeeffcc', 'aaabbbcccddd']) == 5\n assert candidate(words = ['xyzxyz', 'yzxzyx', 'zxyxyz', 'xyzyxz', 'yzxyzx', 'zxyzxy', 'xyzxzy', 'yzzxyx', 'zyxxyz', 'xzyzyx']) == 5\n assert candidate(words = ['xyzabc', 'yzxcba', 'zxcbya', 'zyxcba', 'yxzabc', 'yxzcba', 'zxycba']) == 4\n assert candidate(words = ['abcdefg', 'gfedcba', 'bacdefg', 'gfedcba', 'bacdefg', 'gfedcba']) == 2\n assert candidate(words = ['ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa', 'ababab', 'bababa']) == 2\n assert candidate(words = ['mnopqr', 'mopnqr', 'mpnoqr', 'mnopqr', 'pmonqr', 'pmqnor', 'npoqmr', 'qmonpr']) == 5\n", "comparison": "exact"}, "public_tests": ["[\"abcd\",\"cdab\",\"cbad\",\"xyzz\",\"zzxy\",\"zzyx\"]", "[\"abc\",\"acb\",\"bac\",\"bca\",\"cab\",\"cba\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().numSpecialEquivGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:25+00:00", "tests_total": 81, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numSpecialEquivGroups(self, words: list[str]) -> int:", "container": "Solution", "callable": "numSpecialEquivGroups", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 896, "task_id": "monotonic-array", "difficulty": "Easy", "problem_description": "An array is monotonic if it is either monotone increasing or monotone decreasing.\n\nAn array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j].\n\nGiven an integer array nums, return true if the given array is monotonic, or false otherwise.\n\nExample 1:\n\nInput: nums = [1,2,2,3]\nOutput: true\n\nExample 2:\n\nInput: nums = [6,5,4,4]\nOutput: true\n\nExample 3:\n\nInput: nums = [1,3,2]\nOutput: false\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^5 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 2, 4, 5]) == True\n assert candidate(nums = [-1, -2, -2, -3]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [1, 1, 1]) == True\n assert candidate(nums = [10, -10, -20, -30]) == True\n assert candidate(nums = [-100, 0, 100]) == True\n assert candidate(nums = [-100000, 100000]) == True\n assert candidate(nums = [1, 2, 2, 1]) == False\n assert candidate(nums = [1]) == True\n assert candidate(nums = [5, 3, 3, 2, 1]) == True\n assert candidate(nums = [-1, -5, -10, -10]) == True\n assert candidate(nums = [6, 5, 4, 4]) == True\n assert candidate(nums = [100000, -100000, 0]) == False\n assert candidate(nums = [1, 3, 2]) == False\n assert candidate(nums = [100000, -100000]) == True\n assert candidate(nums = [4, 4, 4, 4]) == True\n assert candidate(nums = [-100000, 0, 100000]) == True\n assert candidate(nums = [-1, -2, -3, -4]) == True\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2]) == True\n assert candidate(nums = [100, 90, 90, 80, 70, 60, 50]) == True\n assert candidate(nums = [5, 3, 2, 4, 1]) == False\n assert candidate(nums = [1, 2, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [5]) == True\n assert candidate(nums = [1, 2, 4, 5, 3]) == False\n assert candidate(nums = [1, 3, 5, 4, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [9, 8, 8, 7, 7, 7, 6, 5, 5, 5, 4, 3, 2, 2, 1]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == True\n assert candidate(nums = [1, 2, 2, 3, 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, 5, 5, 5, 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, 2, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 8, 9, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4]) == 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]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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, 0, 1, 0, -1, 0, 1]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500]) == False\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 0, 0, 0, 1, 1, 1]) == False\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996]) == True\n assert candidate(nums = [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000, 0]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6]) == True\n assert candidate(nums = [10, 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]) == True\n assert candidate(nums = [5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == False\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 0]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 10]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [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]) == True\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(nums = [10, 9, 8, 8, 7, 6, 5, 4, 3, 2, 1]) == True\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]) == True\n assert candidate(nums = [4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [100, 100, 100, 100, 100]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 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]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == False\n assert candidate(nums = [4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [100000, 100000, 100000, 99999, 99998, 99997, 99996]) == 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 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == True\n assert candidate(nums = [-50000, -50000, -50000, -50000, -50000, -50000]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == False\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 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, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 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]) == True\n assert candidate(nums = [-50000, -50000, -50000, -50000, -50000]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 10, 10]) == True\n assert candidate(nums = [-1, 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3]) == False\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 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, 9, 9, 9, 9, 10, 10, 10, 10]) == True\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4, -3, -2, -1, 0]) == False\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 1, 2]) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3]) == False\n assert candidate(nums = [-1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1]) == False\n assert candidate(nums = [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]) == True\n assert candidate(nums = [100000, -100000, 0, 0, 0, 0, 100000]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 5, 4, 3, 2, 1, 1, 0, -1, -1, -2, -3, -3, -4, -5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == False\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 5, 5, 5, 6, 7, 8, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [-5, -5, -5, -5, 0, 0, 0, 0, 5, 5, 5, 5]) == True\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [100000, 100000, 100000, 100000]) == True\n assert candidate(nums = [100000, 100000, 99999, 99998, 99997]) == True\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 0, -10000, -20000, -30000, -40000, -50000, -60000, -70000, -80000, -90000, -100000]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]) == True\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2]) == 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, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -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]) == True\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == False\n assert candidate(nums = [-1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10]) == True\n assert candidate(nums = [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, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995]) == True\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990]) == True\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 3, 3, 3]) == True\n assert candidate(nums = [1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3]) == False\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]) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 8, 7, 6, 5, 5, 4, 3, 2, 1]) == True\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]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,2,3]", "[6,5,4,4]", "[1,3,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().isMonotonic", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:27+00:00", "tests_total": 151, "tests_dropped": 0, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def isMonotonic(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "isMonotonic", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 898, "task_id": "bitwise-ors-of-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr.\n\nThe bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray of one integer is that integer.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: arr = [0]\nOutput: 1\nExplanation: There is only one possible result: 0.\n\nExample 2:\n\nInput: arr = [1,1,2]\nOutput: 3\nExplanation: The possible subarrays are [1], [1], [2], [1, 1], [1, 2], [1, 1, 2].\nThese yield the results 1, 1, 2, 1, 3, 3.\nThere are 3 unique values, so the answer is 3.\n\nExample 3:\n\nInput: arr = [1,2,4]\nOutput: 6\nExplanation: The possible results are 1, 2, 3, 4, 6, and 7.\n\nConstraints:\n\n- 1 <= arr.length <= 5 * 10^4\n- 0 <= arr[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [0, 1, 1, 3]) == 3\n assert candidate(arr = [2, 1, 0, 3, 2]) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [8, 16, 32]) == 6\n assert candidate(arr = [1, 1, 2]) == 3\n assert candidate(arr = [10, 20, 30, 40, 50]) == 7\n assert candidate(arr = [0]) == 1\n assert candidate(arr = [8, 16, 32, 64, 128]) == 15\n assert candidate(arr = [1, 0, 1]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 3, 7, 15, 31]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5]) == 6\n assert candidate(arr = [1, 2, 4]) == 6\n assert candidate(arr = [3, 2, 1, 5, 4]) == 6\n assert candidate(arr = [3, 2, 1, 1, 2, 3]) == 3\n assert candidate(arr = [0, 0, 0]) == 1\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(arr = [0, 1, 2, 3, 4]) == 6\n assert candidate(arr = [5, 1, 4, 2, 1]) == 7\n assert candidate(arr = [0, 1, 2, 3]) == 4\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]) == 7\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 11\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 11\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255]) == 8\n assert candidate(arr = [8, 4, 2, 1, 0, 1, 2, 4, 8, 16]) == 16\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128]) == 36\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 11\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 55\n assert candidate(arr = [89, 55, 34, 21, 13, 8, 5, 3, 2, 1, 1]) == 16\n assert candidate(arr = [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\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\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 15\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 15\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1]) == 8\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 16\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 17\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255]) == 8\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 55\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == 9\n assert candidate(arr = [29, 17, 3, 19, 23, 5, 11, 2, 7, 29, 17, 3, 19, 23, 5, 11, 2, 7]) == 11\n assert candidate(arr = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 12\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 78\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 29\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 55\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 10\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == 45\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [0, 1, 3, 7, 15, 31, 63, 127]) == 8\n assert candidate(arr = [0, 1, 3, 7, 15, 31, 63]) == 7\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == 15\n assert candidate(arr = [123, 456, 789, 123, 456, 789, 123, 456, 789, 123]) == 7\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 7\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 24\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255]) == 9\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 210\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127]) == 7\n assert candidate(arr = [1, 3, 2, 7, 6, 14, 13, 31, 30, 29]) == 11\n assert candidate(arr = [99, 88, 77, 66, 55, 44, 33, 22, 11, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 22\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 24\n assert candidate(arr = [13, 7, 14, 13, 7, 14, 13, 7, 14, 13]) == 4\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 10\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 28\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 2\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 15\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 55\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(arr = [0, 1, 3, 7, 15, 31, 63, 127, 255]) == 9\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 91\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 13\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 19\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 55\n assert candidate(arr = [31, 15, 7, 3, 1, 3, 7, 15, 31, 63]) == 6\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 120\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 120\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 1\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 11\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == 9\n assert candidate(arr = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 21\n", "comparison": "exact"}, "public_tests": ["[0]", "[1,1,2]", "[1,2,4]"], "hints": ["Consider the the subarrays that end at index i. The number of unique bitwise OR for these subarrays is limited."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().subarrayBitwiseORs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:32+00:00", "tests_total": 93, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def subarrayBitwiseORs(self, arr: list[int]) -> int:", "container": "Solution", "callable": "subarrayBitwiseORs", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 899, "task_id": "orderly-queue", "difficulty": "Hard", "problem_description": "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.\n\nExample 1:\n\nInput: s = \"cba\", k = 1\nOutput: \"acb\"\nExplanation:\nIn the first move, we move the 1^st character 'c' to the end, obtaining the string \"bac\".\nIn the second move, we move the 1^st character 'b' to the end, obtaining the final result \"acb\".\n\nExample 2:\n\nInput: s = \"baaca\", k = 3\nOutput: \"aaabc\"\nExplanation:\nIn the first move, we move the 1^st character 'b' to the end, obtaining the string \"aacab\".\nIn the second move, we move the 3^rd character 'c' to the end, obtaining the final result \"aaabc\".\n\nConstraints:\n\n- 1 <= k <= s.length <= 1000\n- s consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaab\",k = 1) == \"aaab\"\n assert candidate(s = \"aaa\",k = 3) == \"aaa\"\n assert candidate(s = \"zxy\",k = 3) == \"xyz\"\n assert candidate(s = \"zxy\",k = 1) == \"xyz\"\n assert candidate(s = \"ccccc\",k = 4) == \"ccccc\"\n assert candidate(s = \"abcd\",k = 2) == \"abcd\"\n assert candidate(s = \"cba\",k = 1) == \"acb\"\n assert candidate(s = \"aaa\",k = 1) == \"aaa\"\n assert candidate(s = \"zyx\",k = 2) == \"xyz\"\n assert candidate(s = \"zyx\",k = 1) == \"xzy\"\n assert candidate(s = \"baaca\",k = 3) == \"aaabc\"\n assert candidate(s = \"mississippi\",k = 1) == \"imississipp\"\n assert candidate(s = \"abcdef\",k = 6) == \"abcdef\"\n assert candidate(s = \"aaaabbbbcccc\",k = 3) == \"aaaabbbbcccc\"\n assert candidate(s = \"zzzzzzzzzz\",k = 1) == \"zzzzzzzzzz\"\n assert candidate(s = \"leetcodeleetcode\",k = 6) == \"ccddeeeeeelloott\"\n assert candidate(s = \"mississippi\",k = 4) == \"iiiimppssss\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aabbccddeeff\",k = 1) == \"aabbccddeeff\"\n assert candidate(s = \"xyzxyzxyzxyz\",k = 4) == \"xxxxyyyyzzzz\"\n assert candidate(s = \"pqrsrstp\",k = 1) == \"ppqrsrst\"\n assert candidate(s = \"abcdedcba\",k = 1) == \"aabcdedcb\"\n assert candidate(s = \"pqrsrstp\",k = 3) == \"ppqrrsst\"\n assert candidate(s = \"bananaananab\",k = 2) == \"aaaaaabbnnnn\"\n assert candidate(s = \"cbbca\",k = 2) == \"abbcc\"\n assert candidate(s = \"banana\",k = 2) == \"aaabnn\"\n assert candidate(s = \"leetcode\",k = 4) == \"cdeeelot\"\n assert candidate(s = \"abcdxyz\",k = 5) == \"abcdxyz\"\n assert candidate(s = \"abracadabra\",k = 1) == \"aabracadabr\"\n assert candidate(s = \"mnopqr\",k = 4) == \"mnopqr\"\n assert candidate(s = \"abcdedcba\",k = 9) == \"aabbccdde\"\n assert candidate(s = \"abababab\",k = 2) == \"aaaabbbb\"\n assert candidate(s = \"zyxcba\",k = 1) == \"azyxcb\"\n assert candidate(s = \"aabbccddeeff\",k = 6) == \"aabbccddeeff\"\n assert candidate(s = \"aaaabbbb\",k = 1) == \"aaaabbbb\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 1) == \"azyxwvutsrqponmlkjihgfedcb\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 25) == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"fedcbabcd\",k = 2) == \"abbccddef\"\n assert candidate(s = \"fedcba\",k = 1) == \"afedcb\"\n assert candidate(s = \"banana\",k = 1) == \"abanan\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqr\",k = 4) == \"mmmnnnooopppqqqrrrss\"\n assert candidate(s = \"aaaaabbbbbcccc\",k = 2) == \"aaaaabbbbbcccc\"\n assert candidate(s = \"mnopqrstuvw\",k = 3) == \"mnopqrstuvw\"\n assert candidate(s = \"abababababab\",k = 6) == \"aaaaaabbbbbb\"\n assert candidate(s = \"abcdedcba\",k = 2) == \"aabbccdde\"\n assert candidate(s = \"pqrsqponmlkjihgfedcba\",k = 1) == \"apqrsqponmlkjihgfedcb\"\n assert candidate(s = \"defabc\",k = 1) == \"abcdef\"\n assert candidate(s = \"abcdexyz\",k = 3) == \"abcdexyz\"\n assert candidate(s = \"aaaaaabbbbb\",k = 2) == \"aaaaaabbbbb\"\n assert candidate(s = \"fghijklmnopqrstuvwxyzabcdef\",k = 10) == \"abcdeffghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abababab\",k = 3) == \"aaaabbbb\"\n assert candidate(s = \"rotation\",k = 2) == \"ainoortt\"\n assert candidate(s = \"mnopqr\",k = 6) == \"mnopqr\"\n assert candidate(s = \"acbacbacbacb\",k = 3) == \"aaaabbbbcccc\"\n assert candidate(s = \"kjihgfedcbazyxwvutsrqponml\",k = 5) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaaabbbbcccc\",k = 2) == \"aaaabbbbcccc\"\n assert candidate(s = \"abcabcabc\",k = 3) == \"aaabbbccc\"\n assert candidate(s = \"zzzzzzzzyy\",k = 2) == \"yyzzzzzzzz\"\n assert candidate(s = \"aabbbccccddddeeeeffffgggg\",k = 10) == \"aabbbccccddddeeeeffffgggg\"\n assert candidate(s = \"aaaabbbbcccc\",k = 1) == \"aaaabbbbcccc\"\n assert candidate(s = \"abcdfe\",k = 1) == \"abcdfe\"\n assert candidate(s = \"thisisaverylongstringwithrandomcharacters\",k = 1) == \"actersthisisaverylongstringwithrandomchar\"\n assert candidate(s = \"zzzzzzzzzzzzzzz\",k = 10) == \"zzzzzzzzzzzzzzz\"\n assert candidate(s = \"thisisatest\",k = 4) == \"aehiisssttt\"\n assert candidate(s = \"banana\",k = 3) == \"aaabnn\"\n assert candidate(s = \"rotor\",k = 1) == \"orrot\"\n assert candidate(s = \"fedcba\",k = 2) == \"abcdef\"\n assert candidate(s = \"ppqpp\",k = 2) == \"ppppq\"\n assert candidate(s = \"abcde\",k = 5) == \"abcde\"\n assert candidate(s = \"abcdfe\",k = 3) == \"abcdef\"\n assert candidate(s = \"zzzzzzzzzzyyyyyyyyxxxxxxxxxx\",k = 25) == \"xxxxxxxxxxyyyyyyyyzzzzzzzzzz\"\n assert candidate(s = \"bananaananab\",k = 1) == \"aananabbanan\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdxyz\",k = 2) == \"abcdxyz\"\n assert candidate(s = \"acbxyz\",k = 2) == \"abcxyz\"\n assert candidate(s = \"xyzzyx\",k = 3) == \"xxyyzz\"\n assert candidate(s = \"abcdeabcde\",k = 5) == \"aabbccddee\"\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmikolp\",k = 1) == \"azwsxedcrfvtgbyhnujmikolpq\"\n assert candidate(s = \"abcdabcd\",k = 2) == \"aabbccdd\"\n assert candidate(s = \"rotation\",k = 1) == \"ationrot\"\n assert candidate(s = \"mnopqrstuvwxyz\",k = 13) == \"mnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgg\",k = 4) == \"aabbccddeeffgg\"\n assert candidate(s = \"xyzzyx\",k = 2) == \"xxyyzz\"\n assert candidate(s = \"abcabcabc\",k = 1) == \"abcabcabc\"\n assert candidate(s = \"leetcodeleetcode\",k = 5) == \"ccddeeeeeelloott\"\n assert candidate(s = \"aaabbbccc\",k = 1) == \"aaabbbccc\"\n assert candidate(s = \"abracadabra\",k = 5) == \"aaaaabbcdrr\"\n assert candidate(s = \"fedcba\",k = 3) == \"abcdef\"\n assert candidate(s = \"aaabbbccc\",k = 3) == \"aaabbbccc\"\n assert candidate(s = \"xyzxyzxyz\",k = 3) == \"xxxyyyzzz\"\n assert candidate(s = \"zzzzzzzzzzyyyyyyyyxxxxxxxxxx\",k = 1) == \"xxxxxxxxxxzzzzzzzzzzyyyyyyyy\"\n assert candidate(s = \"leetcodeleetcode\",k = 8) == \"ccddeeeeeelloott\"\n assert candidate(s = \"zyxcba\",k = 5) == \"abcxyz\"\n assert candidate(s = \"qwertyuiop\",k = 5) == \"eiopqrtuwy\"\n assert candidate(s = \"rotation\",k = 6) == \"ainoortt\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abacabadabacaba\",k = 3) == \"aaaaaaaabbbbccd\"\n assert candidate(s = \"bananaappleorange\",k = 7) == \"aaaaabeeglnnnoppr\"\n assert candidate(s = \"abacabadabacaba\",k = 5) == \"aaaaaaaabbbbccd\"\n assert candidate(s = \"abcdefghihgfedcba\",k = 1) == \"aabcdefghihgfedcb\"\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmikolp\",k = 15) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaaaabbbbbaaaa\",k = 2) == \"aaaaaaaaabbbbb\"\n assert candidate(s = \"zzzyyy\",k = 2) == \"yyyzzz\"\n assert candidate(s = \"qwertyuiop\",k = 10) == \"eiopqrtuwy\"\n assert candidate(s = \"xyzxyzxyz\",k = 9) == \"xxxyyyzzz\"\n assert candidate(s = \"abacabadabacaba\",k = 7) == \"aaaaaaaabbbbccd\"\n assert candidate(s = \"racecar\",k = 1) == \"acecarr\"\n assert candidate(s = \"xyzxyzxyz\",k = 2) == \"xxxyyyzzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"zyxzyxzyxzyx\",k = 5) == \"xxxxyyyyzzzz\"\n assert candidate(s = \"thisisaverylongstringwithrandomcharacters\",k = 5) == \"aaaaccdeegghhhiiiilmnnnoorrrrrssssttttvwy\"\n assert candidate(s = \"hellohellohello\",k = 4) == \"eeehhhllllllooo\"\n assert candidate(s = \"mvvuuz\",k = 3) == \"muuvvz\"\n assert candidate(s = \"aabbcc\",k = 1) == \"aabbcc\"\n assert candidate(s = \"abcdexyz\",k = 1) == \"abcdexyz\"\n assert candidate(s = \"aabbcc\",k = 2) == \"aabbcc\"\n", "comparison": "exact"}, "public_tests": ["\"cba\"\n1", "\"baaca\"\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().orderlyQueue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:34+00:00", "tests_total": 118, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "string", "sorting", "lexicographically-minimal-string-rotation"]}, "language": "python", "interface": {"raw_signature": "def orderlyQueue(self, s: str, k: int) -> str:", "container": "Solution", "callable": "orderlyQueue", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 902, "task_id": "numbers-at-most-n-given-digit-set", "difficulty": "Hard", "problem_description": "Given an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'.\n\nReturn the number of positive integers that can be generated that are less than or equal to a given integer n.\n\nExample 1:\n\nInput: digits = [\"1\",\"3\",\"5\",\"7\"], n = 100\nOutput: 20\nExplanation:\nThe 20 numbers that can be written are:\n1, 3, 5, 7, 11, 13, 15, 17, 31, 33, 35, 37, 51, 53, 55, 57, 71, 73, 75, 77.\n\nExample 2:\n\nInput: digits = [\"1\",\"4\",\"9\"], n = 1000000000\nOutput: 29523\nExplanation:\nWe can write 3 one digit numbers, 9 two digit numbers, 27 three digit numbers,\n81 four digit numbers, 243 five digit numbers, 729 six digit numbers,\n2187 seven digit numbers, 6561 eight digit numbers, and 19683 nine digit numbers.\nIn total, this is 29523 integers that can be written using the digits array.\n\nExample 3:\n\nInput: digits = [\"7\"], n = 8\nOutput: 1\n\nConstraints:\n\n- 1 <= digits.length <= 9\n- digits[i].length == 1\n- digits[i] is a digit from '1' to '9'.\n- All the values in digits are unique.\n- digits is sorted in non-decreasing order.\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = ['1', '4', '9'],n = 1000000000) == 29523\n assert candidate(digits = ['7'],n = 8) == 1\n assert candidate(digits = ['1', '2', '3'],n = 123) == 18\n assert candidate(digits = ['2', '3', '5'],n = 250) == 18\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 999) == 819\n assert candidate(digits = ['3', '4', '5'],n = 1000) == 39\n assert candidate(digits = ['1', '3', '5', '7'],n = 100) == 20\n assert candidate(digits = ['1', '2', '3'],n = 123456789) == 14214\n assert candidate(digits = ['1', '3', '5', '7'],n = 100000000) == 87380\n assert candidate(digits = ['2', '4', '6', '8'],n = 5000) == 212\n assert candidate(digits = ['2', '4'],n = 100) == 6\n assert candidate(digits = ['2', '4', '6', '8'],n = 468246824) == 198406\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 1000000000) == 435848049\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 99999) == 3905\n assert candidate(digits = ['1', '5', '9'],n = 99999) == 363\n assert candidate(digits = ['2', '3', '6', '7', '8'],n = 123456789) == 488280\n assert candidate(digits = ['1', '2', '3', '4'],n = 1000) == 84\n assert candidate(digits = ['5', '9'],n = 555555555) == 511\n assert candidate(digits = ['2', '5', '9'],n = 10000) == 120\n assert candidate(digits = ['2', '4', '8'],n = 888888888) == 29523\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 999999999) == 435848049\n assert candidate(digits = ['3', '6', '9'],n = 333699) == 381\n assert candidate(digits = ['1', '2', '3'],n = 10000) == 120\n assert candidate(digits = ['1', '2', '3', '4'],n = 5000) == 340\n assert candidate(digits = ['2', '4', '6', '8'],n = 1000000) == 5460\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 555555555) == 1464843\n assert candidate(digits = ['1', '2', '3', '4', '5'],n = 9999) == 780\n assert candidate(digits = ['4', '5', '6'],n = 456) == 18\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 500000000) == 1269530\n assert candidate(digits = ['1', '2', '5'],n = 100000) == 363\n assert candidate(digits = ['1', '2'],n = 212121212) == 852\n assert candidate(digits = ['1', '2', '3'],n = 111111111) == 9841\n assert candidate(digits = ['2', '3', '7', '8'],n = 5000) == 212\n assert candidate(digits = ['2', '6', '9'],n = 123456789) == 9840\n assert candidate(digits = ['1', '3', '7', '9'],n = 123456789) == 103764\n assert candidate(digits = ['2', '6', '8'],n = 100000) == 363\n assert candidate(digits = ['2', '5', '8'],n = 500) == 21\n assert candidate(digits = ['1', '2', '3', '4', '5'],n = 5000) == 655\n assert candidate(digits = ['8', '9'],n = 999999999) == 1022\n assert candidate(digits = ['1', '2', '3', '4'],n = 43210) == 1252\n assert candidate(digits = ['1', '9'],n = 999999999) == 1022\n assert candidate(digits = ['2', '6', '8'],n = 4500) == 66\n assert candidate(digits = ['1', '3', '5'],n = 555555555) == 29523\n assert candidate(digits = ['1', '4', '7', '9'],n = 123456789) == 103764\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 123456789) == 54481005\n assert candidate(digits = ['5'],n = 1000000000) == 9\n assert candidate(digits = ['1', '9'],n = 1000000000) == 1022\n assert candidate(digits = ['1', '6', '8'],n = 5678) == 66\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 123456789) == 54481005\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 99999) == 3905\n assert candidate(digits = ['2', '4', '6', '8'],n = 888888888) == 349524\n assert candidate(digits = ['1', '2', '3', '4', '5'],n = 100000) == 3905\n assert candidate(digits = ['1', '2', '4', '8'],n = 1024) == 84\n assert candidate(digits = ['1', '2', '3', '4'],n = 987654321) == 349524\n assert candidate(digits = ['1', '5', '7', '9'],n = 1579) == 112\n assert candidate(digits = ['2', '6', '8'],n = 2688) == 57\n assert candidate(digits = ['1', '3', '5', '7'],n = 777777777) == 349524\n assert candidate(digits = ['9'],n = 999999999) == 9\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 111111111) == 48427561\n assert candidate(digits = ['1'],n = 1000000000) == 9\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 563827194) == 1503905\n assert candidate(digits = ['2', '6', '9'],n = 1000000) == 1092\n assert candidate(digits = ['1', '2', '3'],n = 1111) == 40\n assert candidate(digits = ['1', '6', '8'],n = 1000000000) == 29523\n assert candidate(digits = ['5', '7', '9'],n = 100000) == 363\n assert candidate(digits = ['4', '8'],n = 888) == 14\n assert candidate(digits = ['1', '2', '3'],n = 333) == 39\n assert candidate(digits = ['1', '2', '5'],n = 1111) == 40\n assert candidate(digits = ['1', '2'],n = 1024) == 14\n assert candidate(digits = ['5', '8'],n = 5885) == 21\n assert candidate(digits = ['6', '7', '8'],n = 99999) == 363\n assert candidate(digits = ['1', '2', '3', '4'],n = 9999) == 340\n assert candidate(digits = ['3', '5', '7', '9'],n = 1000000) == 5460\n assert candidate(digits = ['2', '3', '5', '7'],n = 777777777) == 349524\n assert candidate(digits = ['1', '2', '3', '4', '5'],n = 12345) == 975\n assert candidate(digits = ['1', '7', '9'],n = 979797) == 1001\n assert candidate(digits = ['1', '2', '3', '4', '5', '6'],n = 654321) == 54121\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 987654321) == 2363280\n assert candidate(digits = ['1', '2', '5'],n = 1000000000) == 29523\n assert candidate(digits = ['1', '4', '9'],n = 100000000) == 9840\n assert candidate(digits = ['1', '5', '9'],n = 1000000000) == 29523\n assert candidate(digits = ['3', '9'],n = 393939) == 84\n assert candidate(digits = ['1', '2'],n = 1024) == 14\n assert candidate(digits = ['1', '5', '9'],n = 999999999) == 29523\n assert candidate(digits = ['1', '3', '5', '7'],n = 777777777) == 349524\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 123456789) == 566405\n assert candidate(digits = ['1', '2', '3', '4', '5'],n = 50000) == 3280\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 20000) == 1405\n assert candidate(digits = ['1', '3', '7'],n = 77777777) == 9840\n assert candidate(digits = ['5', '7', '9'],n = 888888888) == 22962\n assert candidate(digits = ['1', '2', '4', '8'],n = 999999999) == 349524\n assert candidate(digits = ['3', '7', '8'],n = 378378378) == 13626\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 999999999) == 435848049\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 987654321) == 429794605\n assert candidate(digits = ['3', '7', '9'],n = 999999999) == 29523\n assert candidate(digits = ['1', '2', '3'],n = 321) == 34\n assert candidate(digits = ['3', '7', '8'],n = 1234) == 39\n assert candidate(digits = ['1', '5', '9'],n = 987654321) == 27336\n assert candidate(digits = ['1', '3', '5', '7', '9'],n = 999999999) == 2441405\n assert candidate(digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],n = 987654321) == 429794605\n assert candidate(digits = ['2', '3', '7', '8'],n = 8732) == 313\n assert candidate(digits = ['2', '4', '6', '8'],n = 100000000) == 87380\n assert candidate(digits = ['1'],n = 1000000) == 6\n assert candidate(digits = ['3', '5', '7'],n = 100000000) == 9840\n assert candidate(digits = ['2', '6', '7'],n = 10000) == 120\n assert candidate(digits = ['1', '3', '7', '9'],n = 50000) == 852\n assert candidate(digits = ['1', '2', '3', '4', '5'],n = 222222222) == 976562\n assert candidate(digits = ['1', '9'],n = 500000000) == 766\n assert candidate(digits = ['1', '3', '5'],n = 999999999) == 29523\n assert candidate(digits = ['1', '5', '7', '8'],n = 100000) == 1364\n assert candidate(digits = ['1', '9'],n = 1000000000) == 1022\n assert candidate(digits = ['5', '6', '7'],n = 777777777) == 29523\n assert candidate(digits = ['3', '5', '7'],n = 357357) == 504\n", "comparison": "exact"}, "public_tests": ["[\"1\",\"3\",\"5\",\"7\"]\n100", "[\"1\",\"4\",\"9\"]\n1000000000", "[\"7\"]\n8"], "hints": [], "metadata": {"canonical_parameter_names": ["digits", "n"], "leetcode_dataset_entry_point": "Solution().atMostNGivenDigitSet", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:36+00:00", "tests_total": 113, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math", "string", "binary-search", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def atMostNGivenDigitSet(self, digits: list[str], n: int) -> int:", "container": "Solution", "callable": "atMostNGivenDigitSet", "parameters": [{"name": "digits", "type": "list[str]"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 903, "task_id": "valid-permutations-for-di-sequence", "difficulty": "Hard", "problem_description": "You are given a string s of length n where s[i] is either:\n\n- 'D' means decreasing, or\n- 'I' means increasing.\n\nA permutation perm of n + 1 integers of all the integers in the range [0, n] is called a valid permutation if for all valid i:\n\n- If s[i] == 'D', then perm[i] > perm[i + 1], and\n- If s[i] == 'I', then perm[i] < perm[i + 1].\n\nReturn the number of valid permutations perm. Since the answer may be large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: s = \"DID\"\nOutput: 5\nExplanation: The 5 valid permutations of (0, 1, 2, 3) are:\n(1, 0, 3, 2)\n(2, 0, 3, 1)\n(2, 1, 3, 0)\n(3, 0, 2, 1)\n(3, 1, 2, 0)\n\nExample 2:\n\nInput: s = \"D\"\nOutput: 1\n\nConstraints:\n\n- n == s.length\n- 1 <= n <= 200\n- s[i] is either 'I' or 'D'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"DDDDDDDDDDDD\") == 1\n assert candidate(s = \"DII\") == 3\n assert candidate(s = \"IIDII\") == 19\n assert candidate(s = \"DIDDDDDD\") == 35\n assert candidate(s = \"IIIIIIIIIIII\") == 1\n assert candidate(s = \"DDI\") == 3\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDID\") == 398885199\n assert candidate(s = \"IID\") == 3\n assert candidate(s = \"DIDIDIDIDIDIDIDIDID\") == 185644928\n assert candidate(s = \"DDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IIDID\") == 35\n assert candidate(s = \"DIDI\") == 16\n assert candidate(s = \"IIIIIIIIIII\") == 1\n assert candidate(s = \"IIIIIIIIII\") == 1\n assert candidate(s = \"DID\") == 5\n assert candidate(s = \"IDDD\") == 4\n assert candidate(s = \"DIDIDIDIDID\") == 2702765\n assert candidate(s = \"DDDDDDDD\") == 1\n assert candidate(s = \"DDIDI\") == 35\n assert candidate(s = \"DDDDII\") == 15\n assert candidate(s = \"DDDDDDDDDDD\") == 1\n assert candidate(s = \"IIIIII\") == 1\n assert candidate(s = \"D\") == 1\n assert candidate(s = \"IIII\") == 1\n assert candidate(s = \"ID\") == 2\n assert candidate(s = \"DDIDID\") == 155\n assert candidate(s = \"DDDDDDD\") == 1\n assert candidate(s = \"IDIDIDIDIDIDID\") == 903757305\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDID\") == 955348527\n assert candidate(s = \"DDDDDDDDD\") == 1\n assert candidate(s = \"IIIIID\") == 6\n assert candidate(s = \"DIDIDI\") == 272\n assert candidate(s = \"IDIDID\") == 272\n assert candidate(s = \"IIDIDD\") == 90\n assert candidate(s = \"IDII\") == 9\n assert candidate(s = \"IIDIDID\") == 791\n assert candidate(s = \"DIDIDIDID\") == 50521\n assert candidate(s = \"IDIDIDIDI\") == 50521\n assert candidate(s = \"DDID\") == 9\n assert candidate(s = \"IDIDIDIDID\") == 353792\n assert candidate(s = \"DDIDDD\") == 34\n assert candidate(s = \"DD\") == 1\n assert candidate(s = \"IIIIIIIII\") == 1\n assert candidate(s = \"DI\") == 2\n assert candidate(s = \"IIIIIIII\") == 1\n assert candidate(s = \"DIDIDIDI\") == 7936\n assert candidate(s = \"DDIIDD\") == 71\n assert candidate(s = \"II\") == 1\n assert candidate(s = \"DIDIDIDIDIDIDID\") == 391512012\n assert candidate(s = \"IDDDDD\") == 6\n assert candidate(s = \"III\") == 1\n assert candidate(s = \"IDID\") == 16\n assert candidate(s = \"DDDD\") == 1\n assert candidate(s = \"IDIDIDIDIDI\") == 2702765\n assert candidate(s = \"DIDIDIDIDIDID\") == 199360981\n assert candidate(s = \"IDIDIDIDIDIDI\") == 199360981\n assert candidate(s = \"DIII\") == 4\n assert candidate(s = \"IDIDIDIDIDIDIDIDID\") == 884909216\n assert candidate(s = \"DDDDID\") == 20\n assert candidate(s = \"IDIDIDID\") == 7936\n assert candidate(s = \"IIIIIII\") == 1\n assert candidate(s = \"IIIIIIIIIIIII\") == 1\n assert candidate(s = \"IDDDD\") == 5\n assert candidate(s = \"IDI\") == 5\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 372054302\n assert candidate(s = \"DDIIIDDDID\") == 23409\n assert candidate(s = \"DDDDDDDDIIIIIDIDIDID\") == 673511962\n assert candidate(s = \"DDDDDDDDDDID\") == 77\n assert candidate(s = \"IDDDDDDDDDDDDD\") == 14\n assert candidate(s = \"IIIDIDIDIDDD\") == 1222144\n assert candidate(s = \"IIDIIDIIDIID\") == 3052323\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IIIDIIDIIDII\") == 1049476\n assert candidate(s = \"IIDDDDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDD\") == 393265742\n assert candidate(s = \"IIIDDDDDIIIDDDDDIIIDDDD\") == 184972317\n assert candidate(s = \"DDDDIIIIIIII\") == 495\n assert candidate(s = \"IIIIIIDDDDDDIIIIIIDDDDDDIIIIIIDDDDDDIIIIIID\") == 462903546\n assert candidate(s = \"DIIIDIIIDIIIDIIIDIIID\") == 186469344\n assert candidate(s = \"DDDDDDDDID\") == 54\n assert candidate(s = \"DDDDDDDDDIIIIIIIIIIDDDDDDDDDIIIIIIII\") == 441488323\n assert candidate(s = \"IDDDDDDDIDDDDDDDIDDDDDDDIDDDDDDDIDDDDDDDIDDDDDDDIDDDDDDDIDDDDDDDIDDDDDD\") == 89320108\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DDDDDDDDDDIIIIIIIIII\") == 184756\n assert candidate(s = \"DDDDDDDDDID\") == 65\n assert candidate(s = \"DDDDDIDDDDDD\") == 1715\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDIDID\") == 814891\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 68280442\n assert candidate(s = \"IIDDDDDDIIIDDDDDIIIDDDDDIIIDDDDDD\") == 320107597\n assert candidate(s = \"IDIDIDIDIDID\") == 22368256\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 179476197\n assert candidate(s = \"IDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDD\") == 211646917\n assert candidate(s = \"IIIIIIIIIIIDDDDDDD\") == 31824\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDI\") == 312030296\n assert candidate(s = \"IIIIIIIDDDDD\") == 792\n assert candidate(s = \"DDDDIDIDIDIDIDIDID\") == 546532656\n assert candidate(s = \"DDDDIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 916895\n assert candidate(s = \"IIIIIIIIIDDDDDDDDIIIIIIIIIDDDDDDDD\") == 7124320\n assert candidate(s = \"IIIIIDDDDDDDDDIIIIIDDDDDDDDDIIIIIDDDDDDDDDIIII\") == 161680825\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DIDIDIDIDDDD\") == 1681317\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IDDDDDDDDDDDD\") == 13\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIDDDDDDDDDDDDDDDDDDD\") == 978143726\n assert candidate(s = \"DDDDDDIIIIII\") == 924\n assert candidate(s = \"IIIIIIIIIDDDDDDDDD\") == 48620\n assert candidate(s = \"IDIDIDIDDDDDIIIIIIII\") == 673511962\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"DDDDIIIIIIIIIIIDDDDD\") == 19483036\n assert candidate(s = \"IIIDDDIIIDDDIIIDDD\") == 676402828\n assert candidate(s = \"IIDDDDDIDDDDDIDDDDDIDDDDDIDDDDDIDDD\") == 802666207\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"IIIIIDIIIIIDIIIIIDIIIIID\") == 397477620\n assert candidate(s = \"DIDIDIDIDIDIDI\") == 903757305\n assert candidate(s = \"DDIDIDIDIDIDIDID\") == 790362656\n assert candidate(s = \"DDDDDDDIIIIIIII\") == 6435\n assert candidate(s = \"DIDDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 327757655\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 559265847\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIDDDDDDDDDDDD\") == 251400487\n assert candidate(s = \"IIIDIDIDIDIDDD\") == 103980032\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 486231764\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IIIIIIIDDDDDDDIIIIIIIDDDDDDDIIIIIIIDDDDDDD\") == 586971725\n assert candidate(s = \"IIDDIIDDIIDD\") == 2020656\n assert candidate(s = \"DDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IIIIIIIDDDDDDDD\") == 6435\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"IDDDIDDDIDDD\") == 349504\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIIIIDDDDDDDDDDDIIIIIIIIIIIIIIIIII\") == 604465316\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 514024747\n assert candidate(s = \"DDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIIIII\") == 476337793\n assert candidate(s = \"DDDDDDDDDDIDID\") == 6721\n assert candidate(s = \"DIDDDIDDDDDD\") == 23947\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"IIIIIIIDDDDDDDIIIIIIIDDDDDDDIIIIIIIDDDDDDDIIIIIIIDDDDDDDIIIIIIIDDDDDDD\") == 9946124\n assert candidate(s = \"IDDDIIIDDD\") == 11210\n assert candidate(s = \"IIIIIDDDDDIIIIIIIIIIIIIDDDDDDDDDDDIIIIIIIIIIIIIIIDDDDDDDDDDDIIIIII\") == 844233887\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"DIDIDIIDIDID\") == 14253227\n assert candidate(s = \"DDDDDDDDDDIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 469639504\n assert candidate(s = \"IDDDDDDDDDDDDDDDIIIIIIIIIIIIIIIIIII\") == 754901336\n assert candidate(s = \"IDIDIDIIIIIDIDIDIDID\") == 541113001\n assert candidate(s = \"DDDDDDDDDD\") == 1\n assert candidate(s = \"DIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIID\") == 1805\n assert candidate(s = \"DIIIIIIIIIIIIIIIIIIIIIDIIIIIIIIIIIIIIIIIIIIID\") == 444261561\n assert candidate(s = \"DDDDDDDDDIII\") == 220\n assert candidate(s = \"IIDDDIDIDDDI\") == 1231021\n assert candidate(s = \"IIIIIIIIIDDD\") == 220\n assert candidate(s = \"DDIDIDDDII\") == 38160\n assert candidate(s = \"IIDIDIDIDIDIDI\") == 86657396\n assert candidate(s = \"DDDDDDIDDD\") == 329\n assert candidate(s = \"IIIIIIIIID\") == 10\n assert candidate(s = \"IIDDDIIDDDIIDDDIIDDDIIDDDIIDDDIIDDDIIDDD\") == 115670161\n assert candidate(s = \"DIIIDDDDDDDD\") == 1650\n assert candidate(s = \"DDDDDDDDDDIIIIIIII\") == 43758\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDDD\") == 787128653\n assert candidate(s = \"DDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIIIIDDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIII\") == 116643020\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 803806388\n assert candidate(s = \"IIIIIIIIIIIDIIIIIDDD\") == 16458940\n assert candidate(s = \"DDDDDDDIIIIIIIIIDDDDDDIIIIIIIIIDDD\") == 637084962\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 89434740\n assert candidate(s = \"IDDDDDDDID\") == 430\n assert candidate(s = \"DDDDDDDDIIIIIIIIII\") == 43758\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 752033767\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDID\") == 907695790\n assert candidate(s = \"IDDDIDDDIDDDIDDDIDDD\") == 447283659\n assert candidate(s = \"IDDDDDIDID\") == 9470\n assert candidate(s = \"IIIIIIIIIIIIIIIIIDDDDDDDDDDDDDDDDDD\") == 537567622\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 569787174\n assert candidate(s = \"DDIDIDIDIDDD\") == 2983553\n assert candidate(s = \"IIIIIDIIIIIDIIIIIDIIIIIDIIIIIDIIIIIDIIIIIDIIIIIDIIIIID\") == 671217372\n assert candidate(s = \"DDIDIDIDID\") == 201939\n assert candidate(s = \"DDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 827971518\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIID\") == 22\n assert candidate(s = \"DDIDIDIDIDIDDD\") == 253949942\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IDDDDDDDIIII\") == 3795\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDID\") == 252\n assert candidate(s = \"IIIIIDIIID\") == 1838\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDID\") == 616527580\n assert candidate(s = \"IIIDDDDDDD\") == 120\n assert candidate(s = \"DDDDIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 135751\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 634392057\n assert candidate(s = \"DDIIDDDIIDDDIIDDDIIDDDIIDDDIIDDDIIDDDIID\") == 282462203\n assert candidate(s = \"IDDDDDDDDDDD\") == 12\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 595888523\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 399447831\n assert candidate(s = \"DDDDIDIDIDIDIDIDIDID\") == 65867250\n assert candidate(s = \"IIIIIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 210834483\n assert candidate(s = \"IIIIIDIDIDIDIIIIIIII\") == 509306786\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 233702287\n assert candidate(s = \"DDIDIDIDIDID\") == 12767689\n assert candidate(s = \"IIDDDIDDDIII\") == 335765\n assert candidate(s = \"DDDDDDIDDDDDIDDDDDIDDDDD\") == 865768945\n assert candidate(s = \"DIDIDIIDID\") == 226291\n assert candidate(s = \"IIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIII\") == 340633227\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 277061441\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 105648435\n assert candidate(s = \"DDDDDDIIIIIIIID\") == 43043\n assert candidate(s = \"IDIDDDDDDD\") == 320\n assert candidate(s = \"IIIDIDIDIDIDIDID\") == 45651113\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDDDDDDIIIII\") == 945382435\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDD\") == 373242177\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IIIIIDDDDDIIIIIDDDDD\") == 190033974\n assert candidate(s = \"DDDDDIIIIIIIDDDDDIIIIIIIDDDDDIIIIIIIDDDDDII\") == 8516027\n assert candidate(s = \"IDIDIDDDDDIIIIIII\") == 103159144\n assert candidate(s = \"DDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDD\") == 456017217\n assert candidate(s = \"IIIIIIIIIDDDDDDDDDDD\") == 167960\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"DDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIII\") == 553551576\n assert candidate(s = \"IDIDIDIDIDIDIDIDDDDD\") == 256448604\n assert candidate(s = \"IIIIIDDDDDDDDDDDDIIIIIIIIIIIDDDDDDDDDDDDIIIIIIIIIIIDDDDDDDDDDDDIIII\") == 249031970\n assert candidate(s = \"IIIIIIIIIDDDDDDDDIIIIIIIIIDDDDDDDDIIIIIIIIIDDDDDDDD\") == 295177009\n assert candidate(s = \"IIIIIIIIIIIDID\") == 896\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"IIIDDDDDIIIIIII\") == 286077\n assert candidate(s = \"DIIIDDDDDIIID\") == 882155\n assert candidate(s = \"IDDDDDDDDDDIDDDDDDDDIDDDDDDDDIDDDDDDDDIDDDD\") == 383124231\n assert candidate(s = \"DDDDDDIDDDDDIDDDDDIDDDDDIDDDDDIDDDDDIDDDDDIDDDDD\") == 816732003\n assert candidate(s = \"IIDDDDDIDDDDDIII\") == 28546231\n assert candidate(s = \"IIIDDDDDDDDD\") == 220\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 717149364\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"IDDDDDDDDDID\") == 768\n assert candidate(s = \"DDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDDIIIIIDDDDD\") == 840858142\n assert candidate(s = \"IDDDDDDDIIIDDDDDIIIDDDDDIIIDDDDDDID\") == 643652602\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\") == 1\n assert candidate(s = \"IDDDDDDDDD\") == 10\n assert candidate(s = \"IIIIIIIIIIID\") == 12\n assert candidate(s = \"DDDDDDDDIIIIIIIIIIIIII\") == 319770\n assert candidate(s = \"IIDDDDDDDD\") == 45\n assert candidate(s = \"IIDIDIDIDIDI\") == 12767689\n assert candidate(s = \"IIDDDDIDIDDDD\") == 973622\n assert candidate(s = \"IIIIIDDDDDIIIIIIIIIDDDDDDDIIIIIIIIIIIDDDDD\") == 439575343\n assert candidate(s = \"IIIIIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIII\") == 396282384\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 434494262\n assert candidate(s = \"DDDDIIIIIDDDIIIIIDDD\") == 322218808\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\") == 1\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDIIIIIIIIIIIIIIIIIIIIDDDDDDDDD\") == 1623769\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDIDID\") == 437003601\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID\") == 200684441\n", "comparison": "exact"}, "public_tests": ["\"DID\"", "\"D\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numPermsDISequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:38+00:00", "tests_total": 247, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numPermsDISequence(self, s: str) -> int:", "container": "Solution", "callable": "numPermsDISequence", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 904, "task_id": "fruit-into-baskets", "difficulty": "Medium", "problem_description": "You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the i^th tree produces.\n\nYou want to collect as much fruit as possible. However, the owner has some strict rules that you must follow:\n\n- You only have two baskets, and each basket can only hold a single type of fruit. There is no limit on the amount of fruit each basket can hold.\n- Starting from any tree of your choice, you must pick exactly one fruit from every tree (including the start tree) while moving to the right. The picked fruits must fit in one of your baskets.\n- Once you reach a tree with fruit that cannot fit in your baskets, you must stop.\n\nGiven the integer array fruits, return the maximum number of fruits you can pick.\n\nExample 1:\n\nInput: fruits = [1,2,1]\nOutput: 3\nExplanation: We can pick from all 3 trees.\n\nExample 2:\n\nInput: fruits = [0,1,2,2]\nOutput: 3\nExplanation: We can pick from trees [1,2,2].\nIf we had started at the first tree, we would only pick from trees [0,1].\n\nExample 3:\n\nInput: fruits = [1,2,3,2,2]\nOutput: 4\nExplanation: We can pick from trees [2,3,2,2].\nIf we had started at the first tree, we would only pick from trees [1,2].\n\nConstraints:\n\n- 1 <= fruits.length <= 10^5\n- 0 <= fruits[i] < fruits.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(fruits = [0]) == 1\n assert candidate(fruits = [1, 2, 3, 2, 2]) == 4\n assert candidate(fruits = [1, 0, 1, 4, 1, 4, 1, 2, 3]) == 5\n assert candidate(fruits = [0, 0, 1, 1]) == 4\n assert candidate(fruits = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 7\n assert candidate(fruits = [1, 2, 1]) == 3\n assert candidate(fruits = [0, 0, 0, 0, 0]) == 5\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == 9\n assert candidate(fruits = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == 10\n assert candidate(fruits = [3, 3, 3, 1, 2, 1, 1, 2, 3, 3, 4]) == 5\n assert candidate(fruits = [0, 1, 2, 2]) == 3\n assert candidate(fruits = [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(fruits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2]) == 6\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 22\n assert candidate(fruits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2]) == 21\n assert candidate(fruits = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 6\n assert candidate(fruits = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1]) == 20\n assert candidate(fruits = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 3\n assert candidate(fruits = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2]) == 3\n assert candidate(fruits = [1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 3\n assert candidate(fruits = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(fruits = [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]) == 30\n assert candidate(fruits = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 20\n assert candidate(fruits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 2\n assert candidate(fruits = [1, 2, 3, 4, 2, 1, 2, 3, 4]) == 3\n assert candidate(fruits = [1, 2, 3, 4, 5, 5, 5, 4, 4, 4, 3, 3, 2, 2, 1]) == 7\n assert candidate(fruits = [1, 2, 2, 1, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1]) == 10\n assert candidate(fruits = [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]) == 3\n assert candidate(fruits = [5, 5, 5, 6, 6, 5, 6, 5, 5, 5, 7, 7, 7, 5, 5]) == 10\n assert candidate(fruits = [1, 2, 3, 3, 2, 1, 1, 2, 2, 1, 3, 3, 3, 2, 1, 1, 2, 2, 3, 3]) == 6\n assert candidate(fruits = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n assert candidate(fruits = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7]) == 2\n assert candidate(fruits = [3, 3, 3, 1, 2, 1, 1, 2, 3, 3, 3]) == 5\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3]) == 7\n assert candidate(fruits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 1, 2, 2, 3, 3]) == 5\n assert candidate(fruits = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(fruits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(fruits = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(fruits = [1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2]) == 12\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7]) == 6\n assert candidate(fruits = [1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2]) == 20\n assert candidate(fruits = [3, 3, 3, 1, 2, 2, 1, 1, 1, 2, 3, 3, 3]) == 7\n assert candidate(fruits = [1, 2, 1, 2, 1, 3, 3, 3, 2, 2, 2, 1, 1, 1, 2, 2, 2]) == 9\n assert candidate(fruits = [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]) == 29\n assert candidate(fruits = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 10\n assert candidate(fruits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 4\n assert candidate(fruits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(fruits = [1, 2, 3, 3, 3, 2, 1, 1, 1, 2, 3, 3, 3, 1, 2, 1]) == 5\n assert candidate(fruits = [1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2]) == 14\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 18\n assert candidate(fruits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(fruits = [0, 1, 1, 0, 1, 2, 2, 1, 0, 0]) == 5\n assert candidate(fruits = [1, 1, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 1]) == 8\n assert candidate(fruits = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1]) == 6\n assert candidate(fruits = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6]) == 15\n assert candidate(fruits = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == 16\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 46\n assert candidate(fruits = [1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 3\n assert candidate(fruits = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n assert candidate(fruits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(fruits = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2]) == 30\n assert candidate(fruits = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n assert candidate(fruits = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2]) == 18\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 16\n assert candidate(fruits = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 8\n assert candidate(fruits = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2]) == 12\n assert candidate(fruits = [1, 1, 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]) == 62\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 10\n assert candidate(fruits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 12\n assert candidate(fruits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(fruits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4\n assert candidate(fruits = [1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2]) == 24\n assert candidate(fruits = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 3\n assert candidate(fruits = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(fruits = [1, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1]) == 9\n assert candidate(fruits = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(fruits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 31\n assert candidate(fruits = [1, 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, 1]) == 6\n assert candidate(fruits = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3]) == 4\n assert candidate(fruits = [1, 2, 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(fruits = [3, 3, 3, 1, 2, 2, 1, 1, 1, 2, 2, 2]) == 9\n assert candidate(fruits = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1]) == 6\n assert candidate(fruits = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n assert candidate(fruits = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(fruits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(fruits = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 71\n assert candidate(fruits = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3]) == 6\n assert candidate(fruits = [1, 2, 1, 3, 2, 1, 2, 1, 2]) == 5\n assert candidate(fruits = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 2\n assert candidate(fruits = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 12\n assert candidate(fruits = [1, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 4\n", "comparison": "exact"}, "public_tests": ["[1,2,1]", "[0,1,2,2]", "[1,2,3,2,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["fruits"], "leetcode_dataset_entry_point": "Solution().totalFruit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:40+00:00", "tests_total": 98, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def totalFruit(self, fruits: list[int]) -> int:", "container": "Solution", "callable": "totalFruit", "parameters": [{"name": "fruits", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 905, "task_id": "sort-array-by-parity", "difficulty": "Easy", "problem_description": "Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers.\n\nReturn any array that satisfies this condition.\n\nExample 1:\n\nInput: nums = [3,1,2,4]\nOutput: [2,4,3,1]\nExplanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.\n\nExample 2:\n\nInput: nums = [0]\nOutput: [0]\n\nConstraints:\n\n- 1 <= nums.length <= 5000\n- 0 <= nums[i] <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == [0, 8, 6, 4, 2, 9, 7, 5, 3, 1]\n assert candidate(nums = [5, 3, 2, 8, 6, 7, 1, 4]) == [4, 6, 2, 8, 3, 7, 1, 5]\n assert candidate(nums = [2, 1]) == [2, 1]\n assert candidate(nums = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10]\n assert candidate(nums = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 2, 8, 4, 6, 5, 7, 3, 9, 1]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [6, 4, 2, 1, 3, 5]) == [6, 4, 2, 1, 3, 5]\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]\n assert candidate(nums = [2]) == [2]\n assert candidate(nums = [5000, 2500, 4000, 1000, 3000, 1500]) == [5000, 2500, 4000, 1000, 3000, 1500]\n assert candidate(nums = [1, 3, 5, 7, 2, 4, 6, 8]) == [8, 6, 4, 2, 7, 5, 3, 1]\n assert candidate(nums = [0]) == [0]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == [100, 22, 88, 44, 66, 55, 77, 33, 99, 11]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [2, 4, 3, 5, 1]\n assert candidate(nums = [1, 2]) == [2, 1]\n assert candidate(nums = [3, 1, 2, 4]) == [4, 2, 1, 3]\n assert candidate(nums = [2, 4, 6, 8, 1, 3, 5, 7]) == [2, 4, 6, 8, 1, 3, 5, 7]\n assert candidate(nums = [1, 3, 5, 2, 4, 6]) == [6, 4, 2, 5, 3, 1]\n assert candidate(nums = [4, 2, 3, 1, 5, 7]) == [4, 2, 3, 1, 5, 7]\n assert candidate(nums = [2, 4, 6, 8, 0, 1, 3, 5, 7, 9]) == [2, 4, 6, 8, 0, 1, 3, 5, 7, 9]\n assert candidate(nums = [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, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [101, 52, 33, 44, 77, 88, 99, 22, 11, 66]) == [66, 52, 22, 44, 88, 77, 99, 33, 11, 101]\n assert candidate(nums = [42, 7, 3, 19, 8, 5, 12, 17, 22, 1]) == [42, 22, 12, 8, 19, 5, 3, 17, 7, 1]\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == [1000, 1018, 1002, 1016, 1004, 1014, 1006, 1012, 1008, 1010, 1009, 1011, 1007, 1013, 1005, 1015, 1003, 1017, 1001, 1019]\n assert candidate(nums = [1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520]) == [1500, 1520, 1502, 1518, 1504, 1516, 1506, 1514, 1508, 1512, 1510, 1511, 1509, 1513, 1507, 1515, 1505, 1517, 1503, 1519, 1501]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1, 0]) == [5000, 2500, 1250, 0, 312, 156, 78, 2, 4, 9, 19, 39, 1, 625]\n assert candidate(nums = [314, 159, 265, 358, 979, 323, 846, 264, 338, 327, 950, 288, 419, 716, 939, 937, 510, 582, 0, 1]) == [314, 0, 582, 358, 510, 716, 846, 264, 338, 288, 950, 327, 419, 323, 939, 937, 979, 265, 159, 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]) == [100, 2, 98, 4, 96, 6, 94, 8, 92, 10, 90, 12, 88, 14, 86, 16, 84, 18, 82, 20, 80, 22, 78, 24, 76, 26, 74, 28, 72, 30, 70, 32, 68, 34, 66, 36, 64, 38, 62, 40, 60, 42, 58, 44, 56, 46, 54, 48, 52, 50, 51, 49, 53, 47, 55, 45, 57, 43, 59, 41, 61, 39, 63, 37, 65, 35, 67, 33, 69, 31, 71, 29, 73, 27, 75, 25, 77, 23, 79, 21, 81, 19, 83, 17, 85, 15, 87, 13, 89, 11, 91, 9, 93, 7, 95, 5, 97, 3, 99, 1]\n assert candidate(nums = [11, 14, 21, 39, 40, 50, 61, 72, 83, 94]) == [94, 14, 72, 50, 40, 39, 61, 21, 83, 11]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10, 0, 12, 14, 16, 18, 20]) == [20, 18, 8, 6, 2, 16, 4, 14, 12, 10, 0, 9, 1, 7, 3, 5]\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 0, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [0, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(nums = [5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == [5000, 2500, 1250, 2, 312, 156, 78, 4, 19, 9, 39, 625, 1]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 41, 41, 41, 41]) == [42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 41, 41, 41, 41]\n assert candidate(nums = [1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [44, 55, 66, 77, 88, 99, 100, 111, 122, 133, 144, 155, 166, 177, 188, 199, 200, 211, 222, 233, 244, 255]) == [44, 244, 66, 222, 88, 200, 100, 188, 122, 166, 144, 155, 133, 177, 111, 199, 99, 211, 77, 233, 55, 255]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 1, 3, 5, 7, 9]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 1, 3, 5, 7, 9]\n assert candidate(nums = [1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519]) == [1500, 1518, 1502, 1516, 1504, 1514, 1506, 1512, 1508, 1510, 1509, 1511, 1507, 1513, 1505, 1515, 1503, 1517, 1501, 1519]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 2, 4, 6, 8]) == [8, 6, 4, 2, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 7, 5, 3, 1]\n assert candidate(nums = [3000, 2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990]) == [3000, 2990, 2998, 2992, 2996, 2994, 2995, 2993, 2997, 2991, 2999]\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, 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, 1]\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970, 4969, 4968, 4967, 4966, 4965, 4964, 4963, 4962, 4961, 4960, 1, 3, 5, 7, 9]) == [5000, 4960, 4998, 4962, 4996, 4964, 4994, 4966, 4992, 4968, 4990, 4970, 4988, 4972, 4986, 4974, 4984, 4976, 4982, 4978, 4980, 4979, 4981, 4977, 4983, 4975, 4985, 4973, 4987, 4971, 4989, 4969, 4991, 4967, 4993, 4965, 4995, 4963, 4997, 4961, 4999, 1, 3, 5, 7, 9]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [20, 18, 16, 14, 12, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 22, 24, 26, 28, 30]) == [30, 28, 26, 24, 22, 20, 13, 15, 17, 19, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985]) == [5000, 4986, 4998, 4988, 4996, 4990, 4994, 4992, 4993, 4991, 4995, 4989, 4997, 4987, 4999, 4985]\n assert candidate(nums = [2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515]) == [2500, 2514, 2502, 2512, 2504, 2510, 2506, 2508, 2507, 2509, 2505, 2511, 2503, 2513, 2501, 2515]\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == [1000, 1008, 1002, 1006, 1004, 1005, 1003, 1007, 1001, 1009]\n assert candidate(nums = [1499, 1497, 1495, 1493, 1491, 1489, 1487, 1485, 1483, 1481, 1479, 1477, 1475, 1473, 1471, 1469, 1467, 1465, 1463, 1461, 1459, 1457, 1455, 1453, 1451, 1449, 1447, 1445, 1443, 1441, 1439, 1437, 1435, 1433, 1431, 1429, 1427, 1425, 1423, 1421, 1419, 1417, 1415, 1413, 1411, 1409, 1407, 1405, 1403, 1401, 1400, 1398, 1396, 1394, 1392, 1390, 1388, 1386, 1384, 1382, 1380, 1378, 1376, 1374, 1372, 1370, 1368, 1366, 1364, 1362, 1360, 1358, 1356, 1354, 1352, 1350, 1348, 1346, 1344, 1342, 1340, 1338, 1336, 1334, 1332, 1330, 1328, 1326, 1324, 1322, 1320]) == [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, 1417, 1415, 1413, 1411, 1409, 1407, 1405, 1403, 1401, 1419, 1421, 1423, 1425, 1427, 1429, 1431, 1433, 1435, 1437, 1439, 1441, 1443, 1445, 1447, 1449, 1451, 1453, 1455, 1457, 1459, 1461, 1463, 1465, 1467, 1469, 1471, 1473, 1475, 1477, 1479, 1481, 1483, 1485, 1487, 1489, 1491, 1493, 1495, 1497, 1499]\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == [100, 22, 88, 44, 66, 55, 77, 33, 99, 11]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == [100, 114, 102, 112, 104, 110, 106, 108, 107, 109, 105, 111, 103, 113, 101, 115]\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]) == [14, 14, 2, 2, 12, 12, 4, 4, 10, 10, 6, 6, 8, 8, 7, 7, 9, 9, 5, 5, 11, 11, 3, 3, 13, 13, 1, 1, 15, 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, 2, 4, 6, 8, 10]) == [10, 8, 6, 4, 2, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 9, 7, 5, 3, 1]\n assert candidate(nums = [42, 42, 42, 42, 42, 11, 11, 11, 11, 11]) == [42, 42, 42, 42, 42, 11, 11, 11, 11, 11]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [10, 8, 6, 4, 2, 9, 7, 5, 3, 1]\n assert candidate(nums = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481]) == [500, 482, 498, 484, 496, 486, 494, 488, 492, 490, 491, 489, 493, 487, 495, 485, 497, 483, 499, 481]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 8, 2, 6, 4, 5, 3, 7, 1, 9]\n assert candidate(nums = [5000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [5000, 10, 2, 8, 4, 6, 5, 7, 3, 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, 3, 3, 7]) == [4, 8, 4, 8, 2, 0, 2, 6, 2, 8, 4, 6, 2, 6, 4, 2, 8, 3, 3, 9, 7, 9, 5, 3, 3, 3, 3, 5, 7, 9, 5, 9, 5, 1, 1, 3, 1, 9, 7, 1, 3, 3, 7]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [980, 998, 982, 996, 984, 994, 986, 992, 988, 990, 989, 991, 987, 993, 985, 995, 983, 997, 981, 999]\n assert candidate(nums = [4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990]) == [4990, 4998, 4992, 4996, 4994, 4995, 4993, 4997, 4991, 4999]\n assert candidate(nums = [2500, 2400, 2300, 2200, 2100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [2500, 2400, 2300, 2200, 2100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 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]) == [30, 2, 28, 4, 26, 6, 24, 8, 22, 10, 20, 12, 18, 14, 16, 15, 17, 13, 19, 11, 21, 9, 23, 7, 25, 5, 27, 3, 29, 1]\n assert candidate(nums = [14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15]) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040]) == [1000, 1040, 1002, 1038, 1004, 1036, 1006, 1034, 1008, 1032, 1010, 1030, 1012, 1028, 1014, 1026, 1016, 1024, 1018, 1022, 1020, 1021, 1019, 1023, 1017, 1025, 1015, 1027, 1013, 1029, 1011, 1031, 1009, 1033, 1007, 1035, 1005, 1037, 1003, 1039, 1001]\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]) == [2, 28, 4, 26, 6, 24, 8, 22, 10, 20, 12, 18, 14, 16, 15, 17, 13, 19, 11, 21, 9, 23, 7, 25, 5, 27, 3, 29, 1]\n assert candidate(nums = [2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520]) == [2500, 2520, 2502, 2518, 2504, 2516, 2506, 2514, 2508, 2512, 2510, 2511, 2509, 2513, 2507, 2515, 2505, 2517, 2503, 2519, 2501]\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8]) == [8, 6, 4, 2, 0, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 21, 23, 25, 27, 29]\n assert candidate(nums = [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(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991]) == [5000, 4992, 4998, 4994, 4996, 4995, 4997, 4993, 4999, 4991]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 8, 2, 6, 4, 5, 3, 7, 1, 9]\n assert candidate(nums = [3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019]) == [3018, 3002, 3016, 3004, 3014, 3006, 3012, 3008, 3010, 3009, 3011, 3007, 3013, 3005, 3015, 3003, 3017, 3001, 3019]\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, 2, 18, 4, 16, 6, 14, 8, 12, 10, 11, 9, 13, 7, 15, 5, 17, 3, 19, 1]\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 7, 8, 9, 0]) == [0, 2, 8, 6, 4, 5, 7, 1, 9, 3]\n assert candidate(nums = [47, 32, 5, 18, 23, 42, 11, 30, 7, 60, 9, 54, 13, 27, 88, 46, 19, 35]) == [46, 32, 88, 18, 54, 42, 60, 30, 7, 11, 9, 23, 13, 27, 5, 47, 19, 35]\n assert candidate(nums = [42, 13, 56, 78, 91, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111]) == [42, 110, 56, 78, 108, 100, 106, 102, 104, 103, 105, 101, 107, 91, 109, 13, 111]\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, 100]) == [100, 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 = [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, 30, 2, 28, 4, 26, 6, 24, 8, 22, 10, 20, 12, 18, 14, 16, 15, 17, 13, 19, 11, 21, 9, 23, 7, 25, 5, 27, 3, 29, 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]) == [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(nums = [11, 13, 15, 17, 19, 21, 23, 2, 4, 6, 8, 10]) == [10, 8, 6, 4, 2, 21, 23, 19, 17, 15, 13, 11]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(nums = [30, 28, 26, 24, 22, 20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [30, 28, 26, 24, 22, 20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 8, 2, 6, 4, 5, 3, 7, 1, 9]\n assert candidate(nums = [4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984]) == [4984, 4998, 4986, 4996, 4988, 4994, 4990, 4992, 4991, 4993, 4989, 4995, 4987, 4997, 4985, 4999]\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 2, 4, 6, 8, 10]) == [10, 8, 6, 4, 2, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 43, 41, 37, 31, 29]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1000, 2000, 3000, 4000, 5000, 14, 2, 12, 4, 10, 6, 8, 7, 9, 5, 11, 3, 13, 1, 15]\n assert candidate(nums = [4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970, 4969, 4968, 4967, 4966, 4965, 4964, 4963, 4962, 4961, 4960]) == [4960, 4998, 4962, 4996, 4964, 4994, 4966, 4992, 4968, 4990, 4970, 4988, 4972, 4986, 4974, 4984, 4976, 4982, 4978, 4980, 4979, 4981, 4977, 4983, 4975, 4985, 4973, 4987, 4971, 4989, 4969, 4991, 4967, 4993, 4965, 4995, 4963, 4997, 4961, 4999]\n", "comparison": "exact"}, "public_tests": ["[3,1,2,4]", "[0]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sortArrayByParity", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:42+00:00", "tests_total": 98, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sortArrayByParity(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "sortArrayByParity", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 906, "task_id": "super-palindromes", "difficulty": "Hard", "problem_description": "Let's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome.\n\nGiven two positive integers left and right represented as strings, return the number of super-palindromes integers in the inclusive range [left, right].\n\nExample 1:\n\nInput: left = \"4\", right = \"1000\"\nOutput: 4\nExplanation: 4, 9, 121, and 484 are superpalindromes.\nNote that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrome.\n\nExample 2:\n\nInput: left = \"1\", right = \"2\"\nOutput: 1\n\nConstraints:\n\n- 1 <= left.length, right.length <= 18\n- left and right consist of only digits.\n- left and right cannot have leading zeros.\n- left and right represent integers in the range [1, 10^18 - 1].\n- left is less than or equal to right.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(left = \"123\",right = \"456\") == 0\n assert candidate(left = \"50\",right = \"10000\") == 2\n assert candidate(left = \"4\",right = \"1000\") == 4\n assert candidate(left = \"1\",right = \"2\") == 1\n assert candidate(left = \"123\",right = \"456789\") == 6\n assert candidate(left = \"100\",right = \"1000000\") == 7\n assert candidate(left = \"1\",right = \"100000000000000000\") == 70\n assert candidate(left = \"9\",right = \"9\") == 1\n assert candidate(left = \"100000000000000000\",right = \"999999999999999999\") == 0\n assert candidate(left = \"50\",right = \"1000\") == 2\n assert candidate(left = \"999999999999999999\",right = \"999999999999999999\") == 0\n assert candidate(left = \"10\",right = \"100\") == 0\n assert candidate(left = \"123456789\",right = \"987654321\") == 3\n assert candidate(left = \"987654321\",right = \"987654321987654321\") == 49\n assert candidate(left = \"100000000\",right = \"10000000000\") == 8\n assert candidate(left = \"800000000000000000\",right = \"888888888888888888\") == 0\n assert candidate(left = \"987654321098765432\",right = \"999999999999999999\") == 0\n assert candidate(left = \"1000000000000\",right = \"2000000000000\") == 11\n assert candidate(left = \"12345678987654321\",right = \"12345678987654321\") == 1\n assert candidate(left = \"100000000000000\",right = \"1000000000000000\") == 9\n assert candidate(left = \"123456789012345678\",right = \"876543210987654321\") == 0\n assert candidate(left = \"12345678987654321\",right = \"98765432123456789\") == 3\n assert candidate(left = \"2000000000\",right = \"3000000000\") == 0\n assert candidate(left = \"500000000000000000\",right = \"555555555555555555\") == 0\n assert candidate(left = \"333333333333333333\",right = \"444444444444444444\") == 0\n assert candidate(left = \"900000000000000000\",right = \"999999999999999999\") == 0\n assert candidate(left = \"9007199254740992\",right = \"900719925474099200\") == 22\n assert candidate(left = \"10000000000\",right = \"100000000000000000\") == 49\n assert candidate(left = \"1000000000000\",right = \"9999999999999\") == 13\n assert candidate(left = \"500000000\",right = \"600000000\") == 0\n assert candidate(left = \"499\",right = \"501\") == 0\n assert candidate(left = \"123\",right = \"123456789012345678\") == 66\n assert candidate(left = \"1\",right = \"999999999999999999\") == 70\n assert candidate(left = \"99999999999999998\",right = \"999999999999999999\") == 0\n assert candidate(left = \"999999999\",right = \"10000000000\") == 0\n assert candidate(left = \"98000000000000000\",right = \"98100000000000000\") == 0\n assert candidate(left = \"888888888888888888\",right = \"999999999999999999\") == 0\n assert candidate(left = \"123456789123456789\",right = \"987654321987654321\") == 0\n assert candidate(left = \"100000000000000\",right = \"110000000000000\") == 4\n assert candidate(left = \"50000000000\",right = \"60000000000\") == 0\n assert candidate(left = \"12321\",right = \"98789\") == 4\n assert candidate(left = \"111111111\",right = \"222222222\") == 3\n assert candidate(left = \"100000000000000000\",right = \"100000000000000001\") == 0\n assert candidate(left = \"987654321\",right = \"987654321012345678\") == 49\n assert candidate(left = \"1000000\",right = \"100000000\") == 3\n assert candidate(left = \"10000\",right = \"100000000\") == 8\n assert candidate(left = \"10000000000\",right = \"11000000000\") == 2\n assert candidate(left = \"3000000000000\",right = \"4000000000000\") == 0\n assert candidate(left = \"123456789012345678\",right = \"987654321098765432\") == 0\n assert candidate(left = \"123\",right = \"12345678987654321\") == 64\n assert candidate(left = \"1000000000\",right = \"999999999999999999\") == 49\n assert candidate(left = \"100000000000000000\",right = \"900000000000000000\") == 0\n assert candidate(left = \"1000000000\",right = \"1000000000000\") == 5\n assert candidate(left = \"1000000000\",right = \"9999999999\") == 0\n assert candidate(left = \"50000000000000000\",right = \"60000000000000000\") == 0\n assert candidate(left = \"555555555555555555\",right = \"666666666666666666\") == 0\n assert candidate(left = \"100000000000000000\",right = \"18014398509481983\") == 0\n assert candidate(left = \"111111111\",right = \"999999999999999\") == 32\n assert candidate(left = \"800000000000000000\",right = \"899999999999999999\") == 0\n assert candidate(left = \"111111111111111111\",right = \"222222222222222222\") == 0\n assert candidate(left = \"500000000000000000\",right = \"600000000000000000\") == 0\n assert candidate(left = \"484\",right = \"576\") == 1\n assert candidate(left = \"999999999999999\",right = \"999999999999999999\") == 22\n assert candidate(left = \"80000000000\",right = \"90000000000\") == 0\n assert candidate(left = \"1000000\",right = \"1000000000\") == 11\n", "comparison": "exact"}, "public_tests": ["\"4\"\n\"1000\"", "\"1\"\n\"2\""], "hints": [], "metadata": {"canonical_parameter_names": ["left", "right"], "leetcode_dataset_entry_point": "Solution().superpalindromesInRange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:45+00:00", "tests_total": 86, "tests_dropped": 21, "flags": [], "topic_tags": ["math", "string", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def superpalindromesInRange(self, left: str, right: str) -> int:", "container": "Solution", "callable": "superpalindromesInRange", "parameters": [{"name": "left", "type": "str"}, {"name": "right", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 907, "task_id": "sum-of-subarray-minimums", "difficulty": "Medium", "problem_description": "Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 10^9 + 7.\n\nExample 1:\n\nInput: arr = [3,1,2,4]\nOutput: 17\nExplanation:\nSubarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].\nMinimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.\nSum is 17.\n\nExample 2:\n\nInput: arr = [11,81,94,43,3]\nOutput: 444\n\nConstraints:\n\n- 1 <= arr.length <= 3 * 10^4\n- 1 <= arr[i] <= 3 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == 35\n assert candidate(arr = [1, 3, 2, 4, 5, 7, 6, 8, 9]) == 157\n assert candidate(arr = [9, 7, 5, 3, 1]) == 55\n assert candidate(arr = [10, 20, 30, 40, 50]) == 350\n assert candidate(arr = [1, 2, 2, 1]) == 13\n assert candidate(arr = [3, 1, 2, 4, 3]) == 27\n assert candidate(arr = [3, 1, 2, 4, 5]) == 30\n assert candidate(arr = [11, 81, 94, 43, 3]) == 444\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 15\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 220\n assert candidate(arr = [1, 3, 5, 2, 4, 6]) == 49\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 110\n assert candidate(arr = [10000, 9000, 8000, 7000, 6000]) == 110000\n assert candidate(arr = [1, 2, 3, 4, 5]) == 35\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 385\n assert candidate(arr = [3, 1, 2, 4]) == 17\n assert candidate(arr = [3, 3, 3, 3, 3]) == 45\n assert candidate(arr = [1, 3, 5, 7, 9]) == 55\n assert candidate(arr = [30000, 1, 30000, 2, 30000]) == 90016\n assert candidate(arr = [3, 2, 1, 4, 5]) == 29\n assert candidate(arr = [1, 2, 1, 2, 1]) == 17\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 275\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60]) == 700\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 155\n assert candidate(arr = [3, 2, 1, 5, 4]) == 29\n assert candidate(arr = [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]) == 485\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 680\n assert candidate(arr = [30000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30230\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 550000\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 94\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]) == 183\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 210\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 305\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1540\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 199\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]) == 4960\n assert candidate(arr = [5, 4, 3, 2, 1]) == 35\n assert candidate(arr = [30000, 29999, 29998, 29997, 29996, 29995, 29994, 29993, 29992, 29991]) == 1649670\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]) == 22100\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10]) == 550\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 140\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5]) == 2285\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 715\n assert candidate(arr = [1, 3, 2, 4, 5, 4, 3, 2, 1]) == 91\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 95\n assert candidate(arr = [9, 7, 3, 1, 6, 2, 8, 4, 5]) == 107\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 8116\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 204\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 240\n assert candidate(arr = [2, 3, 1, 5, 4, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]) == 4561\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(arr = [2, 3, 1, 1, 3, 2, 2, 1, 3, 1]) == 68\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2200\n assert candidate(arr = [5, 3, 7, 1, 6, 8, 2, 4, 9, 10]) == 136\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 100\n assert candidate(arr = [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]) == 1555\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 540\n assert candidate(arr = [2, 4, 2, 6, 2, 8, 2, 10]) == 92\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 197\n assert candidate(arr = [3, 5, 4, 2, 1, 6, 7, 8, 9, 10]) == 170\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 6800\n assert candidate(arr = [1, 3, 2, 4, 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]) == 516\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1]) == 50050\n assert candidate(arr = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1240\n assert candidate(arr = [1, 3, 2, 3, 1, 2, 1, 3, 2, 1]) == 68\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1]) == 96\n assert candidate(arr = [30000, 15000, 10000, 5000, 1, 5000, 10000, 15000, 30000]) == 220025\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 170\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 1240\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300]) == 9400\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 125\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2870\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 131\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 22000\n assert candidate(arr = [30000, 29999, 29998, 29997, 29996, 29995]) == 629930\n assert candidate(arr = [30000, 1, 30000, 1, 30000, 1, 30000, 1, 30000, 1]) == 150050\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 680\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 600\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 550\n assert candidate(arr = [15000, 10000, 20000, 5000, 25000, 22500, 17500, 27500, 30000, 12500]) == 602500\n", "comparison": "exact"}, "public_tests": ["[3,1,2,4]", "[50]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sumSubarrayMins", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:47+00:00", "tests_total": 93, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "dynamic-programming", "stack", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def sumSubarrayMins(self, arr: list[int]) -> int:", "container": "Solution", "callable": "sumSubarrayMins", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 908, "task_id": "smallest-range-i", "difficulty": "Easy", "problem_description": "You are given an integer array nums and an integer k.\n\nIn one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from the range [-k, k]. You can apply this operation at most once for each index i.\n\nThe score of nums is the difference between the maximum and minimum elements in nums.\n\nReturn the minimum score of nums after applying the mentioned operation at most once for each index in it.\n\nExample 1:\n\nInput: nums = [1], k = 0\nOutput: 0\nExplanation: The score is max(nums) - min(nums) = 1 - 1 = 0.\n\nExample 2:\n\nInput: nums = [0,10], k = 2\nOutput: 6\nExplanation: Change nums to be [2, 8]. The score is max(nums) - min(nums) = 8 - 2 = 6.\n\nExample 3:\n\nInput: nums = [1,3,6], k = 3\nOutput: 0\nExplanation: Change nums to be [4, 4, 4]. The score is max(nums) - min(nums) = 4 - 4 = 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^4\n- 0 <= nums[i] <= 10^4\n- 0 <= k <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 200, 300, 400],k = 100) == 100\n assert candidate(nums = [100, 4, 200, 1, 3, 2],k = 3) == 193\n assert candidate(nums = [1, 10000],k = 10000) == 0\n assert candidate(nums = [5, 5, 5, 5],k = 1) == 0\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 3, 6],k = 3) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(nums = [4, 8, 15, 16, 23, 42],k = 10) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 3\n assert candidate(nums = [10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 7\n assert candidate(nums = [1],k = 0) == 0\n assert candidate(nums = [4, 7, 8, 9],k = 2) == 1\n assert candidate(nums = [10, 10, 10],k = 5) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 150) == 100\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10000) == 0\n assert candidate(nums = [100, 1000, 10000],k = 500) == 8900\n assert candidate(nums = [1, 10000],k = 5000) == 0\n assert candidate(nums = [10, 15, 20, 25, 30],k = 5) == 10\n assert candidate(nums = [10, 15, 20],k = 5) == 0\n assert candidate(nums = [0, 10],k = 2) == 6\n assert candidate(nums = [100, 200, 300, 400, 500],k = 100) == 200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 9\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 100) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 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],k = 7) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 25) == 0\n assert candidate(nums = [1, 5, 9, 13, 17],k = 3) == 10\n assert candidate(nums = [1, 100, 200, 300, 400, 500],k = 150) == 199\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000) == 0\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],k = 200) == 499\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 10) == 8\n assert candidate(nums = [1, 3, 5, 7, 9],k = 4) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 60\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],k = 100) == 500\n assert candidate(nums = [10, 20, 30, 40, 50],k = 0) == 40\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 350) == 200\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],k = 1) == 0\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 1) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 20) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 0\n assert candidate(nums = [1, 1, 1, 1, 2],k = 1) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 300) == 300\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 10) == 8\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000],k = 2500) == 0\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],k = 5) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [1, 1000, 2000, 3000, 4000],k = 500) == 2999\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],k = 250) == 399\n assert candidate(nums = [5, 5, 5, 5, 5],k = 100) == 0\n assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 4\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995],k = 5) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 2500) == 4000\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],k = 20) == 20\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 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],k = 12) == 5\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 = 1) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 150) == 600\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 500) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 450) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 5) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 20) == 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 = 1) == 17\n assert candidate(nums = [1, 10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000],k = 5000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 80\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 8\n assert candidate(nums = [7, 2, 5, 10, 8, 12, 4, 6],k = 3) == 4\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 50\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],k = 15) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50) == 800\n assert candidate(nums = [5, 5, 5, 5, 5],k = 2) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 14\n assert candidate(nums = [5, 10, 15, 20, 25],k = 12) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 1) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 2500) == 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, 2100, 2200, 2300, 2400, 2500],k = 250) == 1900\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 9\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],k = 10000) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10],k = 2) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3) == 19\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 1000) == 7000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 50\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 10\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 5) == 0\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009],k = 500) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1000) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10],k = 1) == 7\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],k = 5000) == 0\n assert candidate(nums = [1, 10000],k = 5000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 300) == 800\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) == 0\n assert candidate(nums = [1, 1000, 2000, 3000, 4000, 5000],k = 2500) == 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 = 25) == 140\n assert candidate(nums = [1, 3, 5, 7, 9],k = 4) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 1) == 2\n assert candidate(nums = [1, 10, 100, 1000, 10000],k = 1000) == 7999\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 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],k = 20) == 150\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 500) == 3000\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == 4\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 2000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 1\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 500) == 8000\n", "comparison": "exact"}, "public_tests": ["[1]\n0", "[0,10]\n2", "[1,3,6]\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().smallestRangeI", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:49+00:00", "tests_total": 126, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def smallestRangeI(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "smallestRangeI", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 909, "task_id": "snakes-and-ladders", "difficulty": "Medium", "problem_description": "You are given an n x n integer matrix board where the cells are labeled from 1 to n^2 in a Boustrophedon style starting from the bottom left of the board (i.e. board[n - 1][0]) and alternating direction each row.\n\nYou start on square 1 of the board. In each move, starting from square curr, do the following:\n\n- Choose a destination square next with a label in the range [curr + 1, min(curr + 6, n^2)].\n - This choice simulates the result of a standard 6-sided die roll: i.e., there are always at most 6 destinations, regardless of the size of the board.\n- If next has a snake or ladder, you must move to the destination of that snake or ladder. Otherwise, you move to next.\n- The game ends when you reach the square n^2.\n\nA board square on row r and column c has a snake or ladder if board[r][c] != -1. The destination of that snake or ladder is board[r][c]. Squares 1 and n^2 are not the starting points of any snake or ladder.\n\nNote that you only take a snake or ladder at most once per dice roll. If the destination to a snake or ladder is the start of another snake or ladder, you do not follow the subsequent snake or ladder.\n\n- For example, suppose the board is [[-1,4],[-1,3]], and on the first move, your destination square is 2. You follow the ladder to square 3, but do not follow the subsequent ladder to 4.\n\nReturn the least number of dice rolls required to reach the square n^2. If it is not possible to reach the square, return -1.\n\nExample 1:\n\nInput: board = [[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]]\nOutput: 4\nExplanation:\nIn the beginning, you start at square 1 (at row 5, column 0).\nYou decide to move to square 2 and must take the ladder to square 15.\nYou then decide to move to square 17 and must take the snake to square 13.\nYou then decide to move to square 14 and must take the ladder to square 35.\nYou then decide to move to square 36, ending the game.\nThis is the lowest possible number of moves to reach the last square, so return 4.\n\nExample 2:\n\nInput: board = [[-1,-1],[-1,3]]\nOutput: 1\n\nConstraints:\n\n- n == board.length == board[i].length\n- 2 <= n <= 20\n- board[i][j] is either -1 or in the range [1, n^2].\n- The squares labeled 1 and n^2 are not the starting points of any snake or ladder.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [[-1, -1], [-1, 3]]) == 1\n assert candidate(board = [[-1, 2, 15, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 34, 3, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 15, -1, -1, -1, -1]]) == 4\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 35, -1, -1, 13, -1], [-1, -1, -1, -1, -1, -1], [-1, 15, -1, -1, -1, -1]]) == 4\n assert candidate(board = [[-1, 1, 2], [-1, 9, 8], [-1, 8, 9]]) == 1\n assert candidate(board = [[1, 2, 3], [-1, -1, -1], [-1, -1, -1]]) == -1\n assert candidate(board = [[-1, -1, 19, 10, -1], [2, -1, -1, 6, -1], [-1, 17, -1, 19, -1], [22, -1, 15, -1, -1], [-1, -1, -1, -1, 15]]) == 3\n assert candidate(board = [[-1, -1, 30, 14, 15, -1], [23, -1, -1, -1, -1, -1], [9, -1, -1, -1, 8, -1], [-1, 22, -1, -1, 19, -1], [33, -1, 15, -1, -1, 35], [-1, -1, -1, -1, -1, 12]]) == 2\n assert candidate(board = [[1, 1, -1], [-1, 1, 1], [-1, -1, -1]]) == 2\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1], [-1, 25, 33, -1, -1, -1, -1], [-1, -1, -1, 29, -1, -1, -1], [-1, -1, 35, -1, -1, -1, 42], [-1, -1, -1, -1, -1, -1, -1], [-1, 17, -1, -1, -1, -1, -1], [-1, -1, -1, 19, -1, -1, -1]]) == 4\n assert candidate(board = [[-1, 15, 13, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, 3, 5, 16], [-1, -1, -1, -1, -1, -1], [25, -1, -1, 19, -1, -1]]) == 4\n assert candidate(board = [[-1, -1, 22, -1, -1, -1], [-1, -1, -1, -1, 8, -1], [-1, -1, 14, -1, -1, -1], [-1, -1, -1, -1, -1, 10], [-1, -1, 2, -1, -1, 6], [-1, -1, -1, -1, -1, -1]]) == 7\n assert candidate(board = [[-1, 2, 3, 4, 5, 6], [7, 8, 9, 10, -1, 12], [-1, 14, 15, 16, 17, 18], [19, 20, 21, -1, 23, 24], [25, 26, 27, 28, 29, 30], [-1, 32, 33, 34, 35, -1]]) == 2\n assert candidate(board = [[-1, -1, -1, -1, -1, 12], [-1, -1, -1, -1, -1, 35], [-1, -1, -1, -1, -1, -1], [-1, -1, 27, -1, -1, -1], [-1, -1, -1, -1, 34, -1], [-1, -1, -1, -1, -1, -1]]) == 3\n assert candidate(board = [[-1, -1, -1, 10, -1, -1], [-1, -1, 17, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 22, -1], [-1, -1, -1, 15, -1, -1], [-1, -1, -1, -1, -1, 28]]) == 3\n assert candidate(board = [[-1, -1, -1, 9, -1, 6], [-1, 13, 5, -1, -1, 3], [10, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 10, -1], [-1, 9, 3, 11, -1, -1], [-1, -1, -1, -1, -1, 1]]) == 7\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, 35, 31, -1, -1], [-1, -1, -1, -1, -1, -1, -1, 17, 16, -1], [-1, -1, -1, -1, 29, -1, -1, -1, -1, 50], [-1, -1, -1, -1, 32, -1, 25, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 36], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 17\n assert candidate(board = [[-1, 14, -1, -1, 24, -1, 3], [-1, -1, -1, 9, -1, -1, -1], [-1, -1, -1, -1, 17, -1, -1], [-1, 28, -1, -1, -1, -1, -1], [-1, -1, -1, 19, -1, -1, -1], [-1, -1, 13, -1, -1, 15, -1], [-1, -1, -1, -1, -1, -1, 36]]) == -1\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [-1, 10, -1, 12, -1, -1], [-1, -1, 17, -1, -1, -1], [-1, -1, -1, 22, -1, 25], [-1, -1, -1, -1, 29, -1], [-1, -1, -1, -1, -1, 36]]) == 1\n assert candidate(board = [[-1, 2, -1, -1, -1, 36], [-1, -1, 35, 18, -1, 27], [-1, -1, -1, 43, -1, -1], [30, 5, -1, -1, 46, -1], [-1, -1, -1, -1, 31, -1], [13, -1, -1, 50, -1, 16]]) == 3\n assert candidate(board = [[-1, -1, -1, -1, -1, 20], [-1, -1, 25, -1, -1, 3], [-1, 13, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [15, -1, -1, -1, 10, -1], [-1, -1, -1, -1, -1, -1]]) == 6\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 15, -1], [-1, 13, -1, -1, -1, 19, -1], [-1, -1, -1, -1, 25, -1, -1], [-1, -1, -1, 11, -1, -1, -1], [-1, -1, -1, -1, -1, -1, 36]]) == 4\n assert candidate(board = [[-1, 17, 29, -1, -1, -1], [2, -1, -1, 20, -1, 15], [-1, -1, -1, -1, -1, -1], [-1, -1, 24, 26, -1, -1], [-1, -1, -1, 29, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 4\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 37], [-1, -1, -1, -1, -1, -1]]) == 6\n assert candidate(board = [[-1, -1, -1, -1, 28, -1], [25, -1, -1, -1, 24, 19], [11, -1, -1, -1, -1, -1], [9, -1, -1, -1, 27, 17], [-1, 21, -1, 20, 16, -1], [-1, -1, -1, 12, -1, -1]]) == 4\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 35, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, 40], [-1, 17, -1, -1, -1, -1, -1, -1], [-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(board = [[-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -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, -1, -1, 13, -1, -1], [-1, -1, -1, 17, -1, -1, -1, -1], [-1, -1, -1, -1, 19, -1, -1, 36]]) == 7\n assert candidate(board = [[-1, 11, -1, -1, 24, -1], [-1, -1, 17, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 15, -1, -1, -1, -1], [-1, -1, 19, -1, -1, -1], [-1, -1, -1, -1, -1, 36]]) == 1\n assert candidate(board = [[-1, -1, 11, 12, -1, 14], [-1, -1, -1, -1, 22, -1], [-1, 17, -1, 19, -1, -1], [22, -1, 15, -1, -1, -1], [-1, 27, -1, -1, -1, -1], [-1, -1, -1, -1, 15, 26]]) == 3\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1, -1, 54], [-1, -1, -1, -1, 58, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 12, -1, -1, -1, -1, 21], [-1, -1, -1, -1, -1, -1, -1, 18, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 17\n assert candidate(board = [[-1, 79, -1, -1, -1, -1, -1, -1, 13, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 87], [-1, -1, -1, -1, -1, -1, -1, -1, -1, 58], [-1, 31, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 17\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, 12], [-1, -1, -1, -1, -1, 23, -1], [-1, -1, -1, -1, -1, 7, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, 27, -1, 20, -1], [-1, -1, -1, 34, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]]) == -1\n assert candidate(board = [[-1, -1, -1, 45, -1, 27], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, 44, -1, 33], [-1, -1, 30, -1, -1, -1], [-1, 47, -1, -1, 25, -1]]) == 3\n assert candidate(board = [[-1, -1, 15, -1, -1, -1, -1, 12], [7, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-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(board = [[-1, 22, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 26, -1, 31, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, 12, -1, -1, -1, 13, -1, -1], [-1, -1, -1, -1, -1, 29, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, 27, -1], [-1, -1, -1, -1, 21, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 13\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 54, -1, 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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, -1]]) == 24\n assert candidate(board = [[-1, 14, -1, -1, -1, -1, 36, 5, -1, -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, 32, -1, 25, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, 50, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 17\n assert candidate(board = [[-1, 13, 6, -1, -1, -1], [-1, 14, -1, -1, -1, 14], [-1, -1, -1, -1, 18, -1], [-1, 10, -1, -1, -1, 18], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 20]]) == 4\n assert candidate(board = [[-1, 10, -1, -1, -1, 13], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 8, -1], [-1, 13, 5, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 16, 18]]) == 4\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, 30, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 16, -1, 20, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, 28, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, 17, -1, -1, -1, -1, -1]]) == 8\n assert candidate(board = [[-1, -1, -1, 29, 4, -1], [-1, 5, -1, 20, -1, 34], [-1, -1, -1, -1, -1, -1], [-1, -1, 33, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 15]]) == 4\n assert candidate(board = [[-1, 7, 3, -1, 12, -1], [14, -1, -1, 9, 5, 20], [-1, -1, -1, -1, -1, -1], [4, 6, -1, -1, 13, -1], [17, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 15, -1]]) == 5\n assert candidate(board = [[-1, 8, 13, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 16, -1, -1, -1, 10], [-1, -1, -1, -1, -1, -1], [-1, 16, 10, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 6\n assert candidate(board = [[-1, -1, 8, -1, -1, 22], [-1, -1, -1, -1, 13, -1], [-1, -1, 24, -1, -1, -1], [27, -1, -1, -1, -1, -1], [-1, -1, -1, 26, -1, -1], [-1, 35, -1, -1, 30, -1]]) == 2\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 9, -1], [-1, 15, -1, -1, -1, -1], [-1, -1, -1, 12, -1, -1], [-1, -1, -1, -1, 22, -1], [-1, -1, -1, -1, -1, 36]]) == 1\n assert candidate(board = [[-1, -1, -1, -1, 50, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, 28, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, 24], [-1, 46, -1, -1, -1, 18, -1, -1, -1], [-1, -1, -1, -1, -1, -1, 15, -1, -1], [-1, -1, 31, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 30, -1, 14, -1], [-1, -1, -1, -1, 27, -1, -1, -1, -1]]) == 9\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [25, 41, 34, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, 36, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 3\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, 40], [-1, -1, -1, -1, -1, -1, 36], [-1, 28, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -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(board = [[-1, 7, 1, 1, 1, -1], [15, -1, 19, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 9, -1, -1, -1, 5], [-1, 22, -1, 1, -1, 9], [-1, -1, -1, -1, -1, 22]]) == 4\n assert candidate(board = [[-1, 7, 31, -1, -1, -1], [-1, -1, -1, 25, 35, 15], [-1, -1, 28, 16, 22, -1], [-1, -1, -1, -1, 17, -1], [-1, 24, -1, 9, -1, -1], [-1, -1, -1, -1, -1, 4]]) == 4\n assert candidate(board = [[-1, -1, -1, 31, -1, -1], [-1, -1, 25, -1, -1, -1], [-1, -1, -1, -1, 24, -1], [-1, -1, -1, -1, -1, 16], [-1, -1, 21, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 5\n assert candidate(board = [[-1, -1, 12, -1, -1, 27], [-1, -1, -1, -1, -1, 20], [-1, 22, -1, 30, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, 15, -1, -1, -1, -1], [-1, -1, -1, 34, -1, -1]]) == 2\n assert candidate(board = [[-1, -1, -1, 12, -1, -1], [-1, -1, -1, -1, -1, 33], [-1, -1, -1, -1, 28, -1], [-1, 30, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [15, -1, 35, -1, -1, 27]]) == 2\n assert candidate(board = [[-1, 49, -1, 19, -1, -1], [-1, -1, -1, -1, -1, 15], [-1, 31, -1, -1, -1, 42], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, 27, -1, -1], [-1, 43, -1, -1, -1, -1]]) == 4\n assert candidate(board = [[-1, -1, -1, -1, 7, -1], [-1, 13, -1, 11, -1, -1], [-1, -1, 15, -1, -1, -1], [-1, -1, -1, -1, -1, 14], [-1, -1, -1, 9, -1, -1], [-1, -1, -1, -1, -1, 36]]) == 1\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, 25, -1, -1, -1, -1, -1], [-1, -1, 17, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 24, -1], [-1, 13, -1, -1, -1, 19, -1], [-1, -1, -1, -1, -1, -1, 36]]) == 4\n assert candidate(board = [[-1, -1, -1, 33, -1, -1, 15], [-1, -1, 24, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [12, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 18, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, 9, -1, -1, -1, -1]]) == -1\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1], [19, -1, -1, -1, -1, -1, 29, -1], [-1, 35, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 21, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1], [12, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, 17, -1], [-1, -1, -1, -1, -1, -1, -1, -1]]) == 10\n assert candidate(board = [[-1, -1, 26, 11, 17, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, 22, 23, -1, -1], [-1, -1, -1, 9, -1, -1], [14, -1, -1, -1, -1, 25], [-1, -1, 13, -1, -1, -1]]) == 3\n assert candidate(board = [[-1, -1, 17, 10, -1, -1, -1], [-1, -1, -1, -1, 22, -1, 31], [-1, -1, -1, -1, -1, -1, -1], [22, -1, 15, -1, -1, -1, -1], [-1, -1, -1, -1, 44, -1, 52], [-1, 60, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]]) == 5\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 32, -1], [-1, -1, -1, -1, -1, 20], [-1, -1, 26, -1, -1, -1], [-1, -1, -1, 15, -1, -1], [-1, -1, -1, -1, -1, 35]]) == 2\n assert candidate(board = [[-1, 10, -1, -1, 22, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, 28, -1, -1], [16, -1, -1, -1, -1, -1], [-1, -1, -1, -1, 9, -1], [-1, -1, -1, -1, -1, 36]]) == 1\n assert candidate(board = [[-1, -1, 38, -1, -1, -1], [-1, -1, -1, -1, -1, 15], [-1, -1, -1, 33, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 20], [-1, -1, -1, -1, -1, -1]]) == 3\n assert candidate(board = [[-1, -1, -1, 24, -1, -1, 7], [-1, -1, -1, -1, 31, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, 43, -1, 17, -1, 35, -1], [-1, -1, -1, -1, -1, 45, -1], [34, -1, -1, 18, -1, -1, -1], [-1, -1, -1, -1, 12, -1, -1]]) == -1\n assert candidate(board = [[-1, -1, 19, 31, 26, -1, 45, 26], [21, 33, -1, -1, -1, -1, -1, -1], [28, -1, -1, -1, 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, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1]]) == 11\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, 41], [-1, -1, -1, -1, 23, -1, -1], [-1, 28, 35, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, 52], [-1, -1, -1, 38, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]]) == 4\n assert candidate(board = [[-1, -1, -1, 18, -1, -1], [-1, -1, 13, -1, 16, 18], [-1, -1, -1, 16, -1, -1], [-1, -1, -1, 16, -1, 12], [-1, -1, 9, -1, -1, 12], [-1, -1, -1, -1, -1, 15]]) == 5\n assert candidate(board = [[-1, -1, -1, 14, 2, -1], [-1, -1, -1, 8, -1, -1], [-1, -1, 15, -1, 10, -1], [18, 7, -1, -1, 13, -1], [-1, 6, -1, -1, -1, -1], [-1, 5, -1, -1, -1, 23]]) == 4\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 15, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, 21, -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, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, 27, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 17\n assert candidate(board = [[-1, -1, -1, -1, -1, -1], [-1, -1, 25, -1, -1, 10], [-1, -1, -1, -1, -1, -1], [-1, -1, 38, -1, -1, 15], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 6\n assert candidate(board = [[-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 14\n assert candidate(board = [[-1, -1, 16, -1, -1, -1], [-1, 32, -1, -1, 29, -1], [-1, 15, -1, 22, -1, -1], [17, -1, -1, -1, -1, -1], [-1, 25, -1, -1, -1, -1], [20, -1, 34, -1, -1, -1]]) == 2\n assert candidate(board = [[-1, 12, -1, 24, -1, 26], [27, -1, -1, 20, -1, -1], [18, -1, 23, -1, -1, -1], [-1, -1, -1, 14, -1, -1], [15, -1, -1, -1, -1, 25], [5, -1, -1, -1, -1, -1]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]]", "[[-1,-1],[-1,3]]"], "hints": [], "metadata": {"canonical_parameter_names": ["board"], "leetcode_dataset_entry_point": "Solution().snakesAndLadders", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:51+00:00", "tests_total": 72, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def snakesAndLadders(self, board: list[list[int]]) -> int:", "container": "Solution", "callable": "snakesAndLadders", "parameters": [{"name": "board", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 910, "task_id": "smallest-range-ii", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k.\n\nFor each index i where 0 <= i < nums.length, change nums[i] to be either nums[i] + k or nums[i] - k.\n\nThe score of nums is the difference between the maximum and minimum elements in nums.\n\nReturn the minimum score of nums after changing the values at each index.\n\nExample 1:\n\nInput: nums = [1], k = 0\nOutput: 0\nExplanation: The score is max(nums) - min(nums) = 1 - 1 = 0.\n\nExample 2:\n\nInput: nums = [0,10], k = 2\nOutput: 6\nExplanation: Change nums to be [2, 8]. The score is max(nums) - min(nums) = 8 - 2 = 6.\n\nExample 3:\n\nInput: nums = [1,3,6], k = 3\nOutput: 3\nExplanation: Change nums to be [4, 6, 3]. The score is max(nums) - min(nums) = 6 - 3 = 3.\n\nConstraints:\n\n- 1 <= nums.length <= 10^4\n- 0 <= nums[i] <= 10^4\n- 0 <= k <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 10],k = 2) == 6\n assert candidate(nums = [1, 5, 8],k = 2) == 3\n assert candidate(nums = [6, 3, 4, 7],k = 3) == 4\n assert candidate(nums = [6, 3, 2, 18, 9, 12, 3, 6, 5, 0],k = 6) == 9\n assert candidate(nums = [4, 9, 6],k = 2) == 2\n assert candidate(nums = [1, 3, 6],k = 3) == 3\n assert candidate(nums = [7, 8, 8, 10],k = 3) == 3\n assert candidate(nums = [1],k = 0) == 0\n assert candidate(nums = [4, 1, 8, 10],k = 2) == 5\n assert candidate(nums = [6, 3, 4, 2],k = 1) == 2\n assert candidate(nums = [100, 200, 300, 400, 500],k = 50) == 300\n assert candidate(nums = [30, 10, 20, 40, 50, 60],k = 15) == 20\n assert candidate(nums = [10, 15, 3, 7, 8, 12],k = 4) == 6\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 1000) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 15) == 80\n assert candidate(nums = [5, 8, 12, 15, 20, 25, 30],k = 10) == 15\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 799\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) == 18\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40],k = 5) == 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],k = 50) == 90\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 20) == 410\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 8\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56],k = 7) == 35\n assert candidate(nums = [8, 10, 15, 17, 20, 22, 30],k = 10) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 70\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 = 5) == 47\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 9\n assert candidate(nums = [100, 200, 300, 400, 500],k = 150) == 200\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000],k = 300) == 1900\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 7\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 100) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 7\n assert candidate(nums = [1, 10, 100, 1000, 10000],k = 500) == 8999\n assert candidate(nums = [8, 23, 45, 12, 19, 32, 55, 60, 48, 37, 28, 17, 7, 5, 3, 1, 2, 4, 6, 9, 11, 13, 15, 18, 20, 21, 22, 24, 25, 26, 27, 29, 30, 31, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50],k = 8) == 43\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 300) == 500\n assert candidate(nums = [15, 10, 5, 0, 20, 25],k = 10) == 15\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 1000) == 9\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997],k = 5000) == 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],k = 10) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 12\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5) == 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],k = 20) == 150\n assert candidate(nums = [100, 50, 200, 150, 250],k = 75) == 100\n assert candidate(nums = [5, 8, 12, 15, 17, 20, 22, 25, 27, 30],k = 10) == 17\n assert candidate(nums = [8, 11, 12, 9, 10],k = 3) == 4\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300],k = 15) == 250\n assert candidate(nums = [15, 22, 35, 14, 7, 30],k = 10) == 13\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 14\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 = 20) == 149\n assert candidate(nums = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 205, 220],k = 10) == 190\n assert candidate(nums = [100, 200, 150, 50, 250, 300],k = 75) == 100\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [10, 10, 10, 10, 10],k = 10) == 0\n assert candidate(nums = [23, 45, 12, 78, 45, 90, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90],k = 30) == 44\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 150) == 600\n assert candidate(nums = [1, 1000, 2000, 3000, 4000, 5000, 6000],k = 100) == 5799\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],k = 4) == 28\n assert candidate(nums = [5, 2, 11, 14, 7],k = 4) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 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],k = 1) == 17\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 = 60) == 120\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 0) == 900\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75],k = 20) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 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 = 5) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 50\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 25) == 90\n assert candidate(nums = [5, 8, 12, 15, 18, 22, 25, 28, 32, 35, 38, 42, 45, 48, 52, 55, 58, 62],k = 10) == 37\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 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],k = 10) == 0\n assert candidate(nums = [7, 17, 27, 37, 47, 57, 67, 77],k = 15) == 40\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 14\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000],k = 1000) == 2000\n assert candidate(nums = [5, 8, 12, 15, 20, 25, 30, 35],k = 3) == 24\n assert candidate(nums = [1, 100, 200, 300, 400, 500],k = 25) == 449\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 5) == 34\n assert candidate(nums = [2, 5, 1, 8, 9, 10, 11, 12, 15, 20],k = 5) == 9\n assert candidate(nums = [10, 15, 1, 2, 11, 5, 7, 3, 13, 9],k = 4) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 9\n assert candidate(nums = [10, 15, 18, 20, 25, 30, 40, 50],k = 5) == 30\n assert candidate(nums = [5, 1, 9, 17, 13, 2, 8],k = 5) == 8\n assert candidate(nums = [100, 200, 300, 400, 500],k = 50) == 300\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],k = 20) == 100\n assert candidate(nums = [1, 100, 200, 300, 400, 500],k = 50) == 399\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 10\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) == 119\n assert candidate(nums = [8, 10, 5, 11, 6, 9, 4, 12, 3, 7],k = 3) == 5\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500],k = 20) == 360\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 63\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 90\n assert candidate(nums = [1000, 500, 300, 200, 400, 600, 700, 800, 900, 100],k = 50) == 800\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 9\n assert candidate(nums = [5, 8, 12, 15, 20, 25, 30, 35, 40, 45, 50],k = 7) == 31\n assert candidate(nums = [2, 8, 15, 18, 3, 5, 7, 10, 12, 14],k = 4) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 60\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 25) == 40\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980],k = 100) == 19\n assert candidate(nums = [4, 8, 15, 16, 23, 42],k = 5) == 28\n assert candidate(nums = [5, 8, 12, 16, 20, 24, 28],k = 7) == 11\n assert candidate(nums = [100, 50, 30, 20, 40, 60, 70, 80, 90, 10],k = 15) == 60\n assert candidate(nums = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2],k = 1) == 7\n assert candidate(nums = [20, 1, 15, 17, 5, 13, 19, 9, 7, 11],k = 5) == 9\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) == 75\n", "comparison": "exact"}, "public_tests": ["[1]\n0", "[0,10]\n2", "[1,3,6]\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().smallestRangeII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:54+00:00", "tests_total": 107, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "math", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def smallestRangeII(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "smallestRangeII", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 913, "task_id": "cat-and-mouse", "difficulty": "Hard", "problem_description": "A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns.\n\nThe graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph.\n\nThe mouse starts at node 1 and goes first, the cat starts at node 2 and goes second, and there is a hole at node 0.\n\nDuring each player's turn, they must travel along one edge of the graph that meets where they are. For example, if the Mouse is at node 1, it must travel to any node in graph[1].\n\nAdditionally, it is not allowed for the Cat to travel to the Hole (node 0).\n\nThen, the game can end in three ways:\n\n- If ever the Cat occupies the same node as the Mouse, the Cat wins.\n- If ever the Mouse reaches the Hole, the Mouse wins.\n- If ever a position is repeated (i.e., the players are in the same position as a previous turn, and it is the same player's turn to move), the game is a draw.\n\nGiven a graph, and assuming both players play optimally, return\n\n- 1 if the mouse wins the game,\n- 2 if the cat wins the game, or\n- 0 if the game is a draw.\n\nExample 1:\n\nInput: graph = [[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]]\nOutput: 0\n\nExample 2:\n\nInput: graph = [[1,3],[0],[3],[0,2]]\nOutput: 1\n\nConstraints:\n\n- 3 <= graph.length <= 50\n- 1 <= graph[i].length < graph.length\n- 0 <= graph[i][j] < graph.length\n- graph[i][j] != i\n- graph[i] is unique.\n- The mouse and the cat can always move.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(graph = [[3, 4], [3, 5], [3], [0, 1, 2], [0], [1]]) == 2\n assert candidate(graph = [[2, 3, 4], [3, 4], [0, 3, 4], [0, 1, 2], [0, 1, 2]]) == 2\n assert candidate(graph = [[6], [4], [9, 6], [5, 6, 7, 9], [1, 5], [3, 4], [0, 2, 3, 7], [3, 8, 9], [7], [2, 3, 6, 7]]) == 2\n assert candidate(graph = [[1, 2, 3], [0], [0], [0]]) == 1\n assert candidate(graph = [[2, 3], [2, 4], [0, 1, 5], [0], [1], [2]]) == 2\n assert candidate(graph = [[2, 5], [3], [0, 4, 5], [1, 4, 5], [2, 3], [0, 2, 3]]) == 0\n assert candidate(graph = [[1, 3], [0], [3], [0, 2]]) == 1\n assert candidate(graph = [[2, 3, 4, 5], [3, 4, 5], [0], [0, 1, 4, 5], [0, 1, 3], [0, 1, 3]]) == 0\n assert candidate(graph = [[1, 4], [0, 2, 3], [1], [1], [0]]) == 1\n assert candidate(graph = [[3, 4, 6], [5], [4, 6, 3], [0, 5, 2], [0, 2], [1, 3], [0, 2]]) == 2\n assert candidate(graph = [[1, 2], [0], [0]]) == 1\n assert candidate(graph = [[2, 3, 4], [3, 4], [0, 3], [0, 1, 4], [0, 1, 3]]) == 0\n assert candidate(graph = [[3, 4], [3, 5], [3], [0, 1, 2, 5], [0], [1, 3]]) == 2\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 1\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 3, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 1\n assert candidate(graph = [[1, 3, 4, 5, 6], [0, 2, 3, 4, 5, 6], [1], [0, 1, 4, 5, 6], [0, 1, 3, 5, 6], [0, 1, 3, 4, 6], [0, 1, 3, 4, 5], [8, 9], [7], [7]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6], [0, 2, 3, 4, 5, 6], [0, 1, 3, 4, 5, 6], [0, 1, 2, 4, 5, 6], [0, 1, 2, 3, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 4, 5]]) == 1\n assert candidate(graph = [[1, 2, 3], [0, 4, 5], [0, 4, 5], [0, 4, 5], [1, 2, 3, 6], [1, 2, 3, 6], [4]]) == 1\n assert candidate(graph = [[1, 3, 5], [0, 2, 4, 6], [1, 3, 5, 7], [0, 2, 4, 6], [1, 3, 5, 7], [0, 2, 4, 6], [1, 3, 5, 7], [2, 4, 6]]) == 1\n assert candidate(graph = [[1, 3, 4, 5, 6], [0, 2, 4, 5, 6], [1, 3, 4, 5, 6], [0, 1, 4, 5, 6], [0, 1, 2, 3, 5, 6], [0, 1, 2, 3, 4, 6], [0, 1, 2, 3, 4, 5]]) == 1\n assert candidate(graph = [[1, 3, 5], [0, 2, 6], [1, 4, 6], [0, 4, 5], [2, 3, 6], [0, 3, 6], [1, 2, 4, 5]]) == 1\n assert candidate(graph = [[1, 3, 5, 7], [0, 2, 4, 6], [1, 3, 5, 8], [0, 2, 4, 7], [1, 3, 5, 8], [0, 2, 4, 6], [1, 5, 7, 8], [0, 4, 6, 8], [2, 4, 6, 7]]) == 1\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 3, 5], [0, 1, 4, 6], [0, 1, 5, 6], [0, 2, 6], [1, 3, 6], [2, 3, 4, 5]]) == 1\n assert candidate(graph = [[1, 3, 5], [0, 2, 4, 6], [1, 3, 5], [0, 2, 4, 6], [1, 3, 5], [0, 2, 4, 6], [1, 3, 5]]) == 1\n assert candidate(graph = [[1, 2, 4, 8], [0, 3, 6], [0, 3, 7, 8], [1, 2, 5], [0, 5, 9], [3, 4, 6, 9], [1, 5, 7], [2, 6], [0, 2], [4, 5]]) == 1\n assert candidate(graph = [[1, 5, 6], [0, 2, 3, 7, 8], [1, 3, 4, 8], [1, 2, 5, 9, 10], [2, 6], [0, 3, 11], [0, 4, 7, 11], [1, 6, 8, 10], [1, 2, 7, 9], [3, 8, 11], [3, 7, 11], [5, 6, 9, 10]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 6, 7, 8], [0, 1, 3, 4, 5, 6, 7, 8], [0, 1, 2, 4, 5, 6, 7, 8], [0, 1, 2, 3, 5, 6, 7, 8], [0, 1, 2, 3, 4, 6, 7, 8], [0, 1, 2, 3, 4, 5, 7, 8], [0, 1, 2, 3, 4, 5, 6, 8], [0, 1, 2, 3, 4, 5, 6, 7]]) == 1\n assert candidate(graph = [[1, 3, 4, 5], [0, 2, 5, 6], [1, 4, 6], [0, 5, 6, 7], [0, 2], [0, 1, 3, 7], [1, 2, 3], [3, 5, 6]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 2, 3, 4, 5, 6, 7, 9], [0, 1, 3, 4, 5, 6, 8, 9], [0, 1, 2, 4, 5, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8], [0, 1, 2, 3, 4, 6, 7, 8], [0, 1, 2, 3, 4, 5, 7, 8], [0, 1, 2, 3, 4, 5, 6, 8], [0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5], [0, 2, 3, 4, 5], [0, 1, 3, 4, 5], [0, 1, 2, 4, 5], [0, 1, 2, 3, 5], [0, 1, 2, 3, 4]]) == 1\n assert candidate(graph = [[1, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1], [0, 1, 4, 5, 6, 7, 8, 9, 10], [0, 1, 3, 5, 6, 7, 8, 9, 10], [0, 1, 3, 4, 6, 7, 8, 9, 10], [0, 1, 3, 4, 5, 7, 8, 9, 10], [0, 1, 3, 4, 5, 6, 8, 9, 10], [0, 1, 3, 4, 5, 6, 7, 9, 10], [0, 1, 3, 4, 5, 6, 7, 8, 10], [0, 1, 3, 4, 5, 6, 7, 8, 9]]) == 1\n assert candidate(graph = [[1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8]]) == 1\n assert candidate(graph = [[2, 5, 6], [3, 6, 5], [0, 3, 5], [1, 2, 5, 4], [3], [0, 1, 2, 3], [0, 1]]) == 1\n assert candidate(graph = [[1, 3, 5, 7, 9], [0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]) == 1\n assert candidate(graph = [[1, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8, 9], [1, 3, 4, 5, 6, 7, 8, 9], [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]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 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]]) == 1\n assert candidate(graph = [[2, 5, 7, 9], [3, 4, 8], [0, 4, 5, 6, 10], [1, 4, 5, 6, 11], [1, 2, 3, 10, 11], [0, 2, 3, 12], [2, 3, 7, 12], [0, 6, 13], [1, 13], [0, 10, 11, 13], [2, 4, 9, 12], [3, 4, 9, 12], [5, 6, 10, 11], [7, 8, 9]]) == 1\n assert candidate(graph = [[1, 2, 3], [0, 4], [0, 5], [0, 6], [1, 5, 7], [2, 4, 6, 7], [3, 5, 7], [4, 5, 6]]) == 1\n assert candidate(graph = [[1, 2, 3], [0, 2, 3, 4, 5], [0, 1, 4, 5], [0, 1, 4, 5], [1, 2, 3, 5, 6], [1, 2, 3, 4, 6], [4, 5]]) == 1\n assert candidate(graph = [[3, 5, 6], [4, 6, 5], [5, 4], [0, 5, 6], [1, 2, 6], [0, 1, 2, 3], [0, 1, 3, 4]]) == 1\n assert candidate(graph = [[1, 2, 5], [0, 3, 4], [0, 3, 4, 6], [1, 2, 5, 6], [1, 2, 6], [0, 3, 6], [2, 3, 4, 5]]) == 1\n assert candidate(graph = [[2, 3, 4, 5, 6], [2, 4, 6], [0, 1, 4, 5], [0, 4, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 2, 4, 6], [0, 1, 3, 4, 7], [3, 4, 6]]) == 1\n assert candidate(graph = [[2, 5, 7], [3, 4], [0, 4, 5, 6], [1, 4, 5, 6], [1, 2, 3], [0, 2, 3], [2, 3, 7], [0, 6]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7], [0, 2, 3, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 4, 5, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 2, 3, 4, 5, 7], [0, 1, 2, 3, 4, 5, 6]]) == 1\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 5], [0, 1, 3, 6], [0, 2, 4, 7], [0, 3, 5, 8], [1, 4, 6, 9], [2, 5, 7, 10], [3, 6, 8, 11], [4, 7, 9, 12], [5, 8, 10, 13], [6, 9, 11, 14], [7, 10, 12, 15], [8, 11, 13, 16], [9, 12, 14, 17], [10, 13, 15, 18], [11, 14, 16, 19], [12, 15, 17, 20], [13, 16, 18, 21], [14, 17, 19, 22], [15, 18, 20, 23], [16, 19, 21, 24], [17, 20, 22, 25], [18, 21, 23, 26], [19, 22, 24, 27], [20, 23, 25, 28], [21, 24, 26, 29], [22, 25, 27, 30], [23, 26, 28, 31], [24, 27, 29, 32], [25, 28, 30, 33], [26, 29, 31, 34], [27, 30, 32, 35], [28, 31, 33, 36], [29, 32, 34, 37], [30, 33, 35, 38], [31, 34, 36, 39], [32, 35, 37, 0], [33, 36, 38, 1], [34, 37, 39, 2], [35, 38, 0, 3], [36, 39, 1, 4], [37, 0, 2, 5], [38, 1, 3, 6], [39, 2, 4, 7]]) == 1\n assert candidate(graph = [[1, 2, 5, 7, 10], [0, 3, 6, 8, 11], [0, 4, 7, 9, 12], [1, 5, 8, 10, 13], [2, 6, 9, 11, 14], [0, 3, 6, 10, 13], [1, 4, 7, 11, 14], [0, 2, 5, 8, 12], [1, 3, 6, 9, 13], [2, 4, 7, 10, 14], [0, 3, 5, 8, 12], [1, 4, 6, 9, 13], [2, 5, 7, 10, 14], [3, 6, 8, 11, 14], [4, 7, 9, 12, 13]]) == 1\n assert candidate(graph = [[1, 5, 6, 7], [0, 2, 3, 4], [1, 3, 4], [1, 2], [1, 2, 5, 7], [0, 4, 6], [0, 5, 7], [0, 4, 6]]) == 1\n assert candidate(graph = [[1, 2, 3, 4], [0, 2, 3, 5], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 4, 5, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 3, 4, 6, 7], [2, 4, 5, 7], [2, 4, 5, 6]]) == 1\n assert candidate(graph = [[1, 4, 7], [0, 2, 5, 8], [1, 3, 6, 9], [2, 4, 7, 10], [3, 5, 8, 11], [4, 6, 9, 12], [5, 7, 10, 13], [6, 8, 11, 14], [7, 9, 12, 15], [8, 10, 13, 16], [9, 11, 14], [10, 12, 15], [11, 13, 16], [12, 14, 15], [13, 15], [14, 16], [15]]) == 1\n assert candidate(graph = [[2, 3, 4, 5, 6, 7], [8, 9, 10], [0, 3, 4, 5, 11, 12], [0, 2, 5, 6, 13], [0, 2, 6, 7, 14], [0, 2, 3, 4, 15], [0, 3, 4, 5, 16], [0, 4, 17], [1, 18], [1, 18], [1, 18], [2, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17]]) == 2\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 15], [2, 15], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 9, 10, 11, 12, 13, 14]]) == 1\n assert candidate(graph = [[1, 4, 5], [0, 2, 6], [1, 3, 7], [2, 4, 8], [0, 3, 9], [0, 6, 9], [1, 5, 10], [2, 8, 10], [3, 7, 10], [4, 5, 11], [6, 7, 8, 11], [9, 10]]) == 1\n assert candidate(graph = [[3, 4, 5, 6], [2, 3, 5], [1], [0, 1, 4, 5, 6, 7], [0, 3, 7], [0, 1, 3, 7, 8], [0, 3, 9], [3, 4, 5, 8, 9], [5, 7], [6, 7]]) == 1\n assert candidate(graph = [[1, 3, 5, 7], [0, 4, 6, 8], [3, 5, 7, 9], [0, 2, 6, 8], [1, 3, 7, 9], [0, 2, 6, 8], [1, 3, 5, 9], [0, 2, 4, 8], [1, 3, 5, 7], [2, 4, 6, 7]]) == 1\n assert candidate(graph = [[2, 5, 7], [3, 6, 8], [0, 4, 7], [1, 5, 9], [2, 6, 8], [0, 3, 7], [1, 4, 8], [0, 2, 5, 9], [1, 4, 6, 9], [3, 7, 8]]) == 0\n assert candidate(graph = [[2, 4, 5], [3, 5, 6], [0, 4, 6], [1, 5, 7], [0, 2], [0, 1, 3, 7], [1, 2, 7], [3, 5, 6]]) == 1\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]]) == 1\n assert candidate(graph = [[3, 4, 6, 8], [5], [4, 6, 3, 7], [0, 5, 2, 9], [0, 2, 8], [1, 3, 9], [0, 2], [2], [0], [3, 5]]) == 2\n assert candidate(graph = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 2, 11, 12, 13, 14, 15, 16, 17, 18], [0, 1, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 11, 12, 13, 14, 15, 16, 17, 18, 19], [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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(graph = [[5, 6, 7], [2, 3], [1, 3, 6, 5, 8], [1, 2, 4], [3, 5, 7], [0, 1, 2, 4, 6, 7], [0, 2, 5], [0, 4, 5], [2]]) == 2\n", "comparison": "exact"}, "public_tests": ["[[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]]", "[[1,3],[0],[3],[0,2]]"], "hints": [], "metadata": {"canonical_parameter_names": ["graph"], "leetcode_dataset_entry_point": "Solution().catMouseGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:03:58+00:00", "tests_total": 63, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["math", "dynamic-programming", "graph", "topological-sort", "memoization", "minimax-algorithm", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def catMouseGame(self, graph: list[list[int]]) -> int:", "container": "Solution", "callable": "catMouseGame", "parameters": [{"name": "graph", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 914, "task_id": "x-of-a-kind-in-a-deck-of-cards", "difficulty": "Easy", "problem_description": "You are given an integer array deck where deck[i] represents the number written on the i^th card.\n\nPartition the cards into one or more groups such that:\n\n- Each group has exactly x cards where x > 1, and\n- All the cards in one group have the same integer written on them.\n\nReturn true if such partition is possible, or false otherwise.\n\nExample 1:\n\nInput: deck = [1,2,3,4,4,3,2,1]\nOutput: true\nExplanation: Possible partition [1,1],[2,2],[3,3],[4,4].\n\nExample 2:\n\nInput: deck = [1,1,1,2,2,2,3,3]\nOutput: false\nExplanation: No possible partition.\n\nConstraints:\n\n- 1 <= deck.length <= 10^4\n- 0 <= deck[i] < 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(deck = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(deck = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(deck = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(deck = [1, 1, 2, 2, 2, 2]) == True\n assert candidate(deck = [1]) == False\n assert candidate(deck = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(deck = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(deck = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3]) == True\n assert candidate(deck = [1, 1, 1, 2, 2, 2, 3, 3]) == False\n assert candidate(deck = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(deck = [1, 1]) == True\n assert candidate(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(deck = [1, 2, 3, 4, 4, 3, 2, 1]) == True\n assert candidate(deck = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(deck = [1, 2, 3, 3, 3, 3, 4, 6, 6, 6, 6, 6, 6]) == False\n assert candidate(deck = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == True\n assert candidate(deck = [0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(deck = [1, 1, 1]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(deck = [100, 101, 100, 101, 102, 102, 103, 103, 103, 104, 104, 104, 104, 105, 105, 105, 105, 105, 106, 106, 106, 106, 106, 106, 107, 107, 107, 107, 107, 107, 107]) == False\n assert candidate(deck = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == True\n assert candidate(deck = [2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == False\n assert candidate(deck = [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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(deck = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == True\n assert candidate(deck = [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, 11, 11, 11, 11, 11, 11, 11]) == True\n assert candidate(deck = [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, 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]) == True\n assert candidate(deck = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 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]) == False\n assert candidate(deck = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9]) == False\n assert candidate(deck = [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(deck = [1, 1, 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(deck = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(deck = [1, 1, 1, 2, 2, 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]) == False\n assert candidate(deck = [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, 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, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(deck = [1, 1, 2, 2, 3, 3, 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, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(deck = [1, 1, 1, 1, 2, 2, 2, 2, 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]) == True\n assert candidate(deck = [1, 1, 2, 2, 3, 3, 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]) == True\n assert candidate(deck = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(deck = [7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(deck = [1000, 1000, 1000, 1000, 1001, 1001, 1001, 1001, 1002, 1002, 1002, 1002, 1003, 1003, 1003, 1003, 1004, 1004, 1004, 1004]) == True\n assert candidate(deck = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(deck = [1000, 1000, 1001, 1001, 1002, 1002, 1003, 1003, 1004, 1004, 1005, 1005, 1006, 1006, 1007, 1007, 1008, 1008, 1009, 1009, 1010, 1010]) == True\n assert candidate(deck = [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]) == False\n assert candidate(deck = [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]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002]) == True\n assert candidate(deck = [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, 3, 3, 3, 3]) == True\n assert candidate(deck = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == True\n assert candidate(deck = [1, 1, 2, 2, 3, 3, 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(deck = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [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(deck = [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]) == True\n assert candidate(deck = [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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == False\n assert candidate(deck = [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]) == False\n assert candidate(deck = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == True\n assert candidate(deck = [1, 1, 2, 2, 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, 7, 7, 7]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [1, 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, 3, 3]) == True\n assert candidate(deck = [1, 1, 1, 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]) == False\n assert candidate(deck = [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]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(deck = [1, 1, 1, 2, 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]) == False\n assert candidate(deck = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(deck = [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]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [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]) == False\n assert candidate(deck = [1, 1, 1, 1, 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]) == False\n assert candidate(deck = [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]) == False\n assert candidate(deck = [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, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == False\n assert candidate(deck = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [1, 1, 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]) == False\n assert candidate(deck = [1, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == False\n assert candidate(deck = [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]) == False\n assert candidate(deck = [1, 2, 3, 4, 5, 6, 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(deck = [1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == False\n assert candidate(deck = [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, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(deck = [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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108]) == True\n assert candidate(deck = [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(deck = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 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]) == False\n assert candidate(deck = [1, 1, 1, 1, 1, 1, 1, 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]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(deck = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(deck = [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]) == True\n assert candidate(deck = [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(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(deck = [1, 1, 1, 2, 2, 2, 2, 2, 2, 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]) == True\n assert candidate(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == True\n assert candidate(deck = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(deck = [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]) == False\n assert candidate(deck = [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]) == True\n assert candidate(deck = [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]) == True\n assert candidate(deck = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9]) == False\n assert candidate(deck = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == True\n assert candidate(deck = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(deck = [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, 3, 3, 3, 3, 3]) == False\n assert candidate(deck = [200, 200, 200, 201, 201, 201, 202, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 204, 204, 204, 205, 205, 205, 205, 205, 205, 205]) == False\n assert candidate(deck = [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, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12]) == True\n assert candidate(deck = [1, 2, 3, 4, 5, 6, 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(deck = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == False\n assert candidate(deck = [1, 1, 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", "comparison": "exact"}, "public_tests": ["[1,2,3,4,4,3,2,1]", "[1,1,1,2,2,2,3,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["deck"], "leetcode_dataset_entry_point": "Solution().hasGroupsSizeX", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:00+00:00", "tests_total": 113, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def hasGroupsSizeX(self, deck: list[int]) -> bool:", "container": "Solution", "callable": "hasGroupsSizeX", "parameters": [{"name": "deck", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 915, "task_id": "partition-array-into-disjoint-intervals", "difficulty": "Medium", "problem_description": "Given an integer array nums, partition it into two (contiguous) subarrays left and right so that:\n\n- Every element in left is less than or equal to every element in right.\n- left and right are non-empty.\n- left has the smallest possible size.\n\nReturn the length of left after such a partitioning.\n\nTest cases are generated such that partitioning exists.\n\nExample 1:\n\nInput: nums = [5,0,3,8,6]\nOutput: 3\nExplanation: left = [5,0,3], right = [8,6]\n\nExample 2:\n\nInput: nums = [1,1,1,0,6,12]\nOutput: 4\nExplanation: left = [1,1,1,0], right = [6,12]\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^6\n- There is at least one valid answer for the given input.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 1\n assert candidate(nums = [1, 2, 3, 0, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 1, 1, 0, 6, 12]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [3, 5, 0, 0, 8, 10, 6, 12, 15]) == 4\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [10, 10, 10, 0, 10, 10, 10, 10]) == 4\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 3, 0, 4, 5, 6, 7, 8]) == 4\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 3, 3, 2, 2]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(nums = [5, 0, 3, 8, 6]) == 3\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 1]) == 11\n assert candidate(nums = [2, 1, 3, 4, 4, 5]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [3, 3, 2, 2, 3, 1, 4, 5, 6]) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(nums = [5, 2, 1, 3, 4, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [2, 1, 3, 4, 3, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 1\n assert candidate(nums = [0, 2, 1, 3, 5, 4, 7, 6, 9, 8]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 20\n assert candidate(nums = [3, 3, 3, 3, 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, 1]) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7]) == 14\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, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 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, 2]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == 10\n assert candidate(nums = [2, 1, 2, 3, 2, 4, 5, 4, 6, 7, 8, 9, 0, 10, 11, 12]) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 15\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6]) == 1\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 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, 2]) == 1\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, 1]) == 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, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]) == 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\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5]) == 11\n assert candidate(nums = [7, 9, 7, 8, 1, 7, 10, 13, 2, 5, 6, 7, 3, 8, 9, 10]) == 16\n assert candidate(nums = [2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 5]) == 9\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [3, 2, 5, 4, 4, 4, 1, 7, 8, 9]) == 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]) == 1\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 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, 0]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 2]) == 11\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 10, 9]) == 5\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10, 11, 12, 13]) == 7\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2]) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9]) == 6\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, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 1\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == 6\n assert candidate(nums = [5, 0, 3, 8, 6, 7, 9, 1, 2, 4, 11, 10, 12, 13, 14]) == 10\n assert candidate(nums = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 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 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 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\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9]) == 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, 2]) == 1\n", "comparison": "exact"}, "public_tests": ["[5,0,3,8,6]", "[1,1,1,0,6,12]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().partitionDisjoint", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:02+00:00", "tests_total": 95, "tests_dropped": 1, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def partitionDisjoint(self, nums: list[int]) -> int:", "container": "Solution", "callable": "partitionDisjoint", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 916, "task_id": "word-subsets", "difficulty": "Medium", "problem_description": "You are given two string arrays words1 and words2.\n\nA string b is a subset of string a if every letter in b occurs in a including multiplicity.\n\n- For example, \"wrr\" is a subset of \"warrior\" but is not a subset of \"world\".\n\nA string a from words1 is universal if for every string b in words2, b is a subset of a.\n\nReturn an array of all the universal strings in words1. You may return the answer in any order.\n\nExample 1:\n\nInput: words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"e\",\"o\"]\nOutput: [\"facebook\",\"google\",\"leetcode\"]\n\nExample 2:\n\nInput: words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"lc\",\"eo\"]\nOutput: [\"leetcode\"]\n\nExample 3:\n\nInput: words1 = [\"acaac\",\"cccbb\",\"aacbb\",\"caacc\",\"bcbbb\"], words2 = [\"c\",\"cc\",\"b\"]\nOutput: [\"cccbb\"]\n\nConstraints:\n\n- 1 <= words1.length, words2.length <= 10^4\n- 1 <= words1[i].length, words2[i].length <= 10\n- words1[i] and words2[i] consist only of lowercase English letters.\n- All the strings of words1 are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(words1=['acaac', 'cccbb', 'aacbb', 'caacc', 'bcbbb'], words2=['c', 'cc', 'b']), ['cccbb'])\n assert answers_match(candidate(words1=['amazon', 'apple', 'facebook', 'google', 'leetcode'], words2=['e', 'o']), ['facebook', 'google', 'leetcode'])\n assert answers_match(candidate(words1=['amazon', 'apple', 'facebook', 'google', 'leetcode'], words2=['lc', 'eo']), ['leetcode'])\n assert answers_match(candidate(words1=['abcdefg', 'bcdefga', 'cdefgab', 'defgabc', 'efgabcd', 'fgabcde', 'gabcdef'], words2=['def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl']), [])\n assert answers_match(candidate(words1=['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij'], words2=['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa']), [])\n assert answers_match(candidate(words1=['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee'], words2=['a', 'b', 'c', 'd', 'e']), [])\n assert answers_match(candidate(words1=['abacax', 'bacaba', 'caxaba', 'axbaca'], words2=['aba', 'bac', 'cab', 'abc']), ['abacax', 'bacaba', 'caxaba', 'axbaca'])\n assert answers_match(candidate(words1=['abcd', 'abdc', 'cabd', 'dabc', 'adbc'], words2=['aabb', 'bbcc', 'ccdd', 'aabbccdd']), [])\n assert answers_match(candidate(words1=['unique', 'strings', 'for', 'testing', 'purposes'], words2=['un', 'iq', 'st', 'ri', 'gs', 'for', 'tes', 'tin', 'ing', 'pur', 'pose']), [])\n assert answers_match(candidate(words1=['zzzzzzzzzz', 'yyyyyyyyyy', 'xxxxxxxxxx', 'wwwwwwwwww', 'vvvvvvvvvv'], words2=['zz', 'yy', 'xx', 'ww', 'vv']), [])\n assert answers_match(candidate(words1=['example', 'samples', 'problems', 'challenges', 'code', 'interview'], words2=['e', 'm', 'p', 'l', 'e', 's', 'a', 'm', 'p', 'l', 'e', 's']), ['samples'])\n assert answers_match(candidate(words1=['aaaaa', 'bbbbbb', 'cccccc', 'dddddddd', 'eeeeeeee'], words2=['aa', 'bb', 'cc', 'dd', 'ee', 'abcd']), [])\n assert answers_match(candidate(words1=['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee', 'ffffffffff', 'gggggggggg', 'hhhhhhhhhh', 'iiiiiiiiii', 'jjjjjjjjjj'], words2=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj']), [])\n assert answers_match(candidate(words1=['quick', 'brown', 'fox', 'jumps', 'over', 'lazy', 'dogs'], words2=['qu', 'ck', 'bro', 'wn', 'fox', 'jum', 'ps', 'ove', 'r', 'laz', 'y', 'dog', 's']), [])\n assert answers_match(candidate(words1=['abacabacab', 'bacabacaba', 'cabcabcabc', 'ababcabcab', 'bcabcabcab'], words2=['abac', 'bcab', 'cabc', 'abcabc']), ['abacabacab', 'bacabacaba', 'cabcabcabc', 'ababcabcab', 'bcabcabcab'])\n assert answers_match(candidate(words1=['abababa', 'bbbbbbb', 'acacaca', 'cacacac', 'abcabcabc'], words2=['aab', 'bb', 'ac', 'aaa']), ['abcabcabc'])\n assert answers_match(candidate(words1=['xylophone', 'piano', 'guitar', 'drum', 'violin'], words2=['x', 'y', 'p', 'i', 'o']), [])\n assert answers_match(candidate(words1=['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee'], words2=['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']), [])\n assert answers_match(candidate(words1=['xyzz', 'xyzy', 'zzxy', 'zyxz', 'xzzy'], words2=['xyz', 'zz', 'xy', 'zyx']), ['xyzz', 'zzxy', 'zyxz', 'xzzy'])\n assert answers_match(candidate(words1=['unique', 'words', 'arrays', 'strings', 'characters'], words2=['unique', 'words', 'strings', 'chars', 'arrays']), [])\n assert answers_match(candidate(words1=['aabb', 'ccdd', 'eefg', 'hhiijj', 'kkll', 'mmnn', 'oopp', 'qqrr', 'sstt', 'uuvv', 'wwxx', 'yyzz'], words2=['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']), [])\n assert answers_match(candidate(words1=['abcd', 'abdc', 'dabc', 'cabd', 'bcad'], words2=['a', 'b', 'c', 'd', 'ab', 'bc', 'cd', 'da', 'ac', 'bd', 'dc', 'ad', 'ba', 'cb']), ['abcd', 'abdc', 'dabc', 'cabd', 'bcad'])\n assert answers_match(candidate(words1=['this', 'is', 'a', 'complex', 'testcase'], words2=['this', 'is', 'a', 'complex', 'test', 'case']), [])\n assert answers_match(candidate(words1=['aabb', 'ccdd', 'eeff', 'gghh', 'iijj', 'kkll', 'mmnn', 'oopp', 'qqrr', 'sstt', 'uuvv', 'wwxx', 'yyzz'], words2=['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz', 'aab', 'ccd', 'eeff', 'gghh', 'iijj', 'kkll', 'mmnn', 'oopp', 'qqrr', 'sstt', 'uuvv', 'wwxx', 'yyzz']), [])\n assert answers_match(candidate(words1=['universe', 'galaxy', 'cosmos', 'planet', 'star', 'nebula'], words2=['u', 'v', 'e', 'r', 's', 'e']), ['universe'])\n assert answers_match(candidate(words1=['zzzzzzzzzz', 'yyyyyyyyyy', 'xxxxxxxxxx', 'wwwwwwwwww', 'vvvvvvvvvv', 'uuuuuuuuuu'], words2=['zzzzz', 'yyyyy', 'xxxxx', 'wwwww', 'vvvvv', 'uuuuu']), [])\n assert answers_match(candidate(words1=['alphabet', 'brazil', 'critical', 'dynamic', 'economic'], words2=['a', 'b', 'c', 'd', 'e']), [])\n assert answers_match(candidate(words1=['abacaxi', 'manga', 'naruto', 'onepiece', 'dragonball'], words2=['aba', 'nan', 'ope', 'dra']), [])\n assert answers_match(candidate(words1=['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee'], words2=['abc', 'bcd', 'cde', 'def', 'efg']), [])\n assert answers_match(candidate(words1=['this', 'is', 'a', 'test', 'of', 'subset', 'matching'], words2=['is', 'a', 'test', 'this', 'of', 'subset', 'matching', 'mm', 'ss', 'tt', 'ee']), [])\n assert answers_match(candidate(words1=['data', 'science', 'machine', 'learning', 'artificial'], words2=['data', 'art', 'sci', 'learn']), [])\n assert answers_match(candidate(words1=['aaaaaaaa', 'bbbbbbbb', 'cccccccc', 'dddddddd', 'eeeeeeee', 'ffffffff'], words2=['a', 'b', 'c', 'd', 'e', 'f', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff']), [])\n assert answers_match(candidate(words1=['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'], words2=['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 answers_match(candidate(words1=['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'], words2=['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 answers_match(candidate(words1=['zzzzzzzzzz', 'zzzzzzzzz', 'zzzzzzzz', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z'], words2=['zzzzzzzzzz', 'zzzzzzzzz', 'zzzzzzzz', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z']), ['zzzzzzzzzz'])\n", "comparison": "unordered"}, "public_tests": ["[\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"]\n[\"e\",\"o\"]", "[\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"]\n[\"lc\",\"eo\"]", "[\"acaac\",\"cccbb\",\"aacbb\",\"caacc\",\"bcbbb\"]\n[\"c\",\"cc\",\"b\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["words1", "words2"], "leetcode_dataset_entry_point": "Solution().wordSubsets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:04+00:00", "tests_total": 69, "tests_dropped": 34, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def wordSubsets(self, words1: list[str], words2: list[str]) -> list[str]:", "container": "Solution", "callable": "wordSubsets", "parameters": [{"name": "words1", "type": "list[str]"}, {"name": "words2", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 917, "task_id": "reverse-only-letters", "difficulty": "Easy", "problem_description": "Given a string s, reverse the string according to the following rules:\n\n- All the characters that are not English letters remain in the same position.\n- All the English letters (lowercase or uppercase) should be reversed.\n\nReturn s after reversing it.\n\nExample 1:\n\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\n\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\n\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists of characters with ASCII values in the range [33, 122].\n- s does not contain '\\\"' or '\\\\'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"s-123-p\") == \"p-123-s\"\n assert candidate(s = \"Test1ng-Leet=code-Q!\") == \"Qedo1ct-eeLg=ntse-T!\"\n assert candidate(s = \"-a-b-\") == \"-b-a-\"\n assert candidate(s = \"a-bC-dEf-ghIj\") == \"j-Ih-gfE-dCba\"\n assert candidate(s = \"A-b-C-d-E\") == \"E-d-C-b-A\"\n assert candidate(s = \"12345\") == \"12345\"\n assert candidate(s = \"!@#$%^&*()\") == \"!@#$%^&*()\"\n assert candidate(s = \"ab-cd\") == \"dc-ba\"\n assert candidate(s = \"abcdefg\") == \"gfedcba\"\n assert candidate(s = \"!@#$%^&*()_+-=[]{}|\\:;'<>,.?/1234567890\") == \"!@#$%^&*()_+-=[]{}|\\:;'<>,.?/1234567890\"\n assert candidate(s = \"P@y-P@l\") == \"l@P-y@P\"\n assert candidate(s = \"UPPERlower123\") == \"rewolREPPU123\"\n assert candidate(s = \"a-bC-dEf-ghIj-kLmNoP-qRsTuV-wXyZ\") == \"Z-yX-wVu-TsRq-PoNmLk-jIhgfE-dCba\"\n assert candidate(s = \"!a-bC-dEf-ghIj!\") == \"!j-Ih-gfE-dCba!\"\n assert candidate(s = \"a-zA-Z0-9\") == \"Z-Az-a0-9\"\n assert candidate(s = \"No lemon, no melon\") == \"no lemon, no meloN\"\n assert candidate(s = \"Z-y-x-W-v-U-t-S-r-Q-p-O-n-M-l-K-j-I-h-G-f-E-d-C-b-A\") == \"A-b-C-d-E-f-G-h-I-j-K-l-M-n-O-p-Q-r-S-t-U-v-W-x-y-Z\"\n assert candidate(s = \"M-r-2-0-D-1-E-3-N-o-5-r-7-L-8-e-9-t-0-s-1-w-2-e-3-r-4-q-5-u-6-i-7-o-8-n-9-D-0\") == \"D-n-2-0-o-1-i-3-u-q-5-r-7-e-8-w-9-s-0-t-1-e-2-L-3-r-4-o-5-N-6-E-7-D-8-r-9-M-0\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"Reverse!This@String#With$Non%Letters^In&It*\") == \"tInIsre!tteL@noNhti#Wgni$rtS%sihTesr^ev&eR*\"\n assert candidate(s = \"a!b@c#d$e%f^g&h*i(j)k-l+m,n/o\\p;q:rt?u.v[w]x{y}z|\") == \"z!y@x#w$v%u^t&s*r(q)p-o+n,m/l\\k;j:ig?f.e[d]c{b}a|\"\n assert candidate(s = \"Hello, World!\") == \"dlroW, olleH!\"\n assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm-=-+=!@#$%^&*()\") == \"1234567890mnbvcxzlkjhgfdsapoiuytrewq-=-+=!@#$%^&*()\"\n assert candidate(s = \"Python3.9\") == \"nohtyP3.9\"\n assert candidate(s = \"aAaAaAaAaA\") == \"AaAaAaAaAa\"\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-y-x-w-v-u-t-s-r-q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a\"\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-Y-X-W-V-U-T-S-R-Q-P-O-N-M-L-K-J-I-H-G-F-E-D-C-B-A\"\n assert candidate(s = \"Ae-IoU-aeiou-1-2-3-4-5-6-7-8-9-0\") == \"uo-iea-UoIeA-1-2-3-4-5-6-7-8-9-0\"\n assert candidate(s = \"P3r#G4m!n@G\") == \"G3n#m4G!r@P\"\n assert candidate(s = \"--aZ--\") == \"--Za--\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"ZYXWVUTSRQPONMLKJIHGFEDCBA-zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"A man, a plan, a canal: Panama\") == \"a man, a Plan, a canal: panamA\"\n assert candidate(s = \"Z-y-x-W-v-U-t-S-r-Q-p-O-n-M-l-K-j-I-h-G-f-E-d-C-b-A-1-2-3\") == \"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-2-3\"\n assert candidate(s = \"No'Matter'How'Hard'You'Try\") == \"yr'TuoYdr'aHw'oHre'tta'MoN\"\n assert candidate(s = \"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\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\"\n assert candidate(s = \"a-bC-dEf-ghIj-kLmNoP\") == \"P-oN-mLk-jIhg-fEdCba\"\n assert candidate(s = \"7_28hT!@#%$q9\") == \"7_28qT!@#%$h9\"\n assert candidate(s = \"---abcXYZ---\") == \"---ZYXcba---\"\n assert candidate(s = \"H2O-is-a-good-solvent\") == \"t2n-ev-l-osdo-ogasiOH\"\n assert candidate(s = \"123-abc-456-def-789\") == \"123-fed-456-cba-789\"\n assert candidate(s = \"Hello-World!!!\") == \"dlroW-olleH!!!\"\n assert candidate(s = \"N0-Sc3n4r10-1-f0r-R3v3rs1ng\") == \"g0-ns3r4v10-1-R0r-f3r3nc1SN\"\n assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm\") == \"1234567890mnbvcxzlkjhgfdsapoiuytrewq\"\n assert candidate(s = \"A1B!C2@D3#E4$F5%G6^H7&I8*J9(L0)\") == \"L1J!I2@H3#G4$F5%E6^D7&C8*B9(A0)\"\n assert candidate(s = \"mIxEd-CaSe-123-!@#\") == \"eSaCd-ExIm-123-!@#\"\n assert candidate(s = \"12345!@#$%\") == \"12345!@#$%\"\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-y-x-w-v-u-t-s-r-q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a!@#$%^&*()\"\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-9-8-7-6-5-4-3-2-1\") == \"z-y-x-w-v-u-t-s-r-q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a-0-9-8-7-6-5-4-3-2-1\"\n assert candidate(s = \"--a--b--\") == \"--b--a--\"\n assert candidate(s = \"rE9-!vA5#xY2$\") == \"Yx9-!Av5#Er2$\"\n assert candidate(s = \"7_8A-9B-10C-11D\") == \"7_8D-9C-10B-11A\"\n assert candidate(s = \"NoLettersHere123\") == \"ereHsretteLoN123\"\n assert candidate(s = \"a1B2C3D4E5F6G7H8I9J0\") == \"J1I2H3G4F5E6D7C8B9a0\"\n assert candidate(s = \"T1h2i3s4I5s6t7h8e9F1i2n3a4l5T6e7s8t9C0a5s6e7\") == \"e1s2a3C4t5s6e7T8l9a1n2i3F4e5h6t7s8I9s0i5h6T7\"\n assert candidate(s = \"P@y-2-P@l-1-O!n-0-G!a-5-p%e+L-4-5-h%6-.\") == \"h@L-2-e@p-1-a!G-0-n!O-5-l%P+y-4-5-P%6-.\"\n assert candidate(s = \"z-a-y-b-x-c-w-d-v-e-u-t-s-r-q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a\") == \"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-e-v-d-w-c-x-b-y-a-z\"\n assert candidate(s = \"M-2y-3r-4o-5p\") == \"p-2o-3r-4y-5M\"\n assert candidate(s = \"M-i-c-r-o-s-o-f-t-2-0-2-3\") == \"t-f-o-s-o-r-c-i-M-2-0-2-3\"\n assert candidate(s = \"A1B2C3D4E5\") == \"E1D2C3B4A5\"\n assert candidate(s = \"p-yt_h-nm_g-f_d-c_b-a\") == \"a-bc_d-fg_m-n_h-t_y-p\"\n assert candidate(s = \"a1B2C3d4E5f6G7H8\") == \"H1G2f3E4d5C6B7a8\"\n assert candidate(s = \"123abc-456def-789ghi\") == \"123ihg-456fed-789cba\"\n assert candidate(s = \"x-89y-76z-54w-32v-10u\") == \"u-89v-76w-54z-32y-10x\"\n assert candidate(s = \"a-bC-dEf-ghIj-kLmNoP-qRstUv-wXyz\") == \"z-yX-wvU-tsRq-PoNmLk-jIhgfE-dCba\"\n assert candidate(s = \"12345-abc-67890\") == \"12345-cba-67890\"\n assert candidate(s = \"!@#$%^&*()_+\") == \"!@#$%^&*()_+\"\n assert candidate(s = \"Z-y-x-w-v-u-t-s-r-q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a-Z\") == \"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(s = \"a1B2c3D4e5F6g7h8i9j0\") == \"j1i2h3g4F5e6D7c8B9a0\"\n assert candidate(s = \"12345-abc!def@gh#ij$kl%mn^op&q*r(s)t+u-v+w,x-y.z/\") == \"12345-zyx!wvu@ts#rq$po%nm^lk&j*i(h)g+f-e+d,c-b.a/\"\n assert candidate(s = \"Zebra-123-Quokka\") == \"akkou-123-QarbeZ\"\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-y-x-w-v-u-t-s-r-q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a-\"\n assert candidate(s = \"NoChangeHere\") == \"ereHegnahCoN\"\n assert candidate(s = \"1234567890\") == \"1234567890\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"--hello-+++world---\") == \"--dlrow-+++olleh---\"\n assert candidate(s = \"M4ng0_Le3t!\") == \"t4eL0_gn3M!\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog. 123\") == \"god yzale htrev osp mujxo fnwo rbk ciuq ehT. 123\"\n assert candidate(s = \"Z-a-Y-b-X-c-W-d-V-e-U-f-T-g-S-h-R-i-Q-j-P-k-L-m-N-o-M-l-K-j-I-h-G-f-E-d-C-b-A\") == \"A-b-C-d-E-f-G-h-I-j-K-l-M-o-N-m-L-k-P-j-Q-i-R-h-S-g-T-f-U-e-V-d-W-c-X-b-Y-a-Z\"\n assert candidate(s = \"12345abc!@#def$%^ghi&*()\") == \"12345ihg!@#fed$%^cba&*()\"\n assert candidate(s = \"a-bC-dEf-ghIj-klMnOp-QrStUv-WxYz\") == \"z-Yx-WvU-tSrQ-pOnMlk-jIhgfE-dCba\"\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!y@x#w$v%u^t&s*r(q)p_o+n-m+l*k*j*i-h*g*f*e*d*c*b*a\"\n assert candidate(s = \"---\") == \"---\"\n assert candidate(s = \"sToP-If-YoU-CaN\") == \"NaCU-oY-fIP-oTs\"\n assert candidate(s = \"Test1ng-Leet=code-Q!!@#\") == \"Qedo1ct-eeLg=ntse-T!!@#\"\n assert candidate(s = \"123-abc-456-def\") == \"123-fed-456-cba\"\n assert candidate(s = \"H-e-l-l-o-,-W-o-r-l-d-!\") == \"d-l-r-o-W-,-o-l-l-e-H-!\"\n assert candidate(s = \"!@#$%^&*()_+-=[]{}|;':,.<>?\") == \"!@#$%^&*()_+-=[]{}|;':,.<>?\"\n assert candidate(s = \"a-bC-dEf-ghIj-kLmNoP-qRsTuVwXyZ\") == \"Z-yX-wVu-TsRq-PoNmLk-jIhgfEdCba\"\n assert candidate(s = \"A-man,a-plan,a-canal-Panama!\") == \"a-man,a-Plan,a-canal-panamA!\"\n assert candidate(s = \"123--abcXYZ!\") == \"123--ZYXcba!\"\n assert candidate(s = \"Python3.8\") == \"nohtyP3.8\"\n assert candidate(s = \"M-k-e-e-t-i-n-g-2-0-2-3\") == \"g-n-i-t-e-e-k-M-2-0-2-3\"\n assert candidate(s = \"a-zA-Z0-9!@#$%^&*()_+=-\") == \"Z-Az-a0-9!@#$%^&*()_+=-\"\n assert candidate(s = \"A1B2C3D4E5F6G7H8I9J0\") == \"J1I2H3G4F5E6D7C8B9A0\"\n assert candidate(s = \"Reverse-This-String-123\") == \"gnirtSs-ihTe-sreveR-123\"\n assert candidate(s = \"M-I-L-O-N\") == \"N-O-L-I-M\"\n", "comparison": "exact"}, "public_tests": ["\"ab-cd\"", "\"a-bC-dEf-ghIj\"", "\"Test1ng-Leet=code-Q!\""], "hints": ["This problem is exactly like reversing a normal string except that there are certain characters that we have to simply skip. That should be easy enough to do if you know how to reverse a string using the two-pointer approach."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().reverseOnlyLetters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:07+00:00", "tests_total": 98, "tests_dropped": 1, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def reverseOnlyLetters(self, s: str) -> str:", "container": "Solution", "callable": "reverseOnlyLetters", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 918, "task_id": "maximum-sum-circular-subarray", "difficulty": "Medium", "problem_description": "Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.\n\nA circular array means the end of the array connects to the beginning of the array. Formally, the next element of nums[i] is nums[(i + 1) % n] and the previous element of nums[i] is nums[(i - 1 + n) % n].\n\nA subarray may only include each element of the fixed buffer nums at most once. Formally, for a subarray nums[i], nums[i + 1], ..., nums[j], there does not exist i <= k1, k2 <= j with k1 % n == k2 % n.\n\nExample 1:\n\nInput: nums = [1,-2,3,-2]\nOutput: 3\nExplanation: Subarray [3] has maximum sum 3.\n\nExample 2:\n\nInput: nums = [5,-3,5]\nOutput: 10\nExplanation: Subarray [5,5] has maximum sum 5 + 5 = 10.\n\nExample 3:\n\nInput: nums = [-3,-2,-3]\nOutput: -2\nExplanation: Subarray [-2] has maximum sum -2.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 3 * 10^4\n- -3 * 10^4 <= nums[i] <= 3 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -2, 3, -2]) == 3\n assert candidate(nums = [10, -2, 5, 1, -4, 3, -1]) == 16\n assert candidate(nums = [2, 3, -4, 5, 7]) == 17\n assert candidate(nums = [5, -3, 5]) == 10\n assert candidate(nums = [3, -1, 2, -1]) == 4\n assert candidate(nums = [2, -2, 2, 7]) == 11\n assert candidate(nums = [-1, -2, -3, 4]) == 4\n assert candidate(nums = [9, -4, 7, 3, -2]) == 17\n assert candidate(nums = [10, 0, 3, 5, -10, 2, 4]) == 24\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-1, -2, -3, -4]) == -1\n assert candidate(nums = [1, -4, 7, 2]) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [9, -4, 7, 2, -1]) == 17\n assert candidate(nums = [-3, -2, -3]) == -2\n assert candidate(nums = [100, -1, -2, -3, -4, -5, -6, -7, -8, -9, 100, 100, -200, 100, 100]) == 455\n assert candidate(nums = [-10, -20, -30, 15, 20, 25, -10, -5]) == 60\n assert candidate(nums = [5, -3, 5, -2, 3, -4, 7, -6, 8, -1]) == 18\n assert candidate(nums = [3, -1, 4, -1, 5, -9, 2, 6, -3, 8]) == 23\n assert candidate(nums = [10, -3, 4, -2, -1, 10, -10, 5, 6, -5, 2]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [2, 4, -2, -3, 8]) == 14\n assert candidate(nums = [1, 2, 3, -6, 4, 5, 6, -10, 7, 8, 9]) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, -20, 1, 2, 3, 4, 5, -20, 1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [3, -2, 2, 5, -3]) == 8\n assert candidate(nums = [1, -10, 3, 4, -2, 5]) == 11\n assert candidate(nums = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 100\n assert candidate(nums = [-2, 4, -3, 5, 1, -5, 3, -1, 2, 4, -5]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, 100, -1, -1, -1, -1]) == 100\n assert candidate(nums = [-5, -1, -8, 2, 6, -3, 4, 2, -8, 3, 7]) == 13\n assert candidate(nums = [-1, 4, -2, 3, -2, 4, -2, 3, -1, 2, -5, 6]) == 14\n assert candidate(nums = [2, 3, -4, 5, 7, 1, -1, -3, 4]) == 18\n assert candidate(nums = [8, -1, 3, -4, 3, 2, -2, 5, 7, -4, 5, -2, 1, 2, -1, 3, 4, -3, 4, -1, -2, 1, 5]) == 37\n assert candidate(nums = [-1, -2, -3, 20, -1, -2, -3, 20, -1, -2, -3, 20]) == 48\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 4\n assert candidate(nums = [1, 2, 3, -5, 6, 7, -8, 9, 10, -11, 12]) == 37\n assert candidate(nums = [3, -2, 2, -3, 4, -1, 2, 1, -5, 4]) == 10\n assert candidate(nums = [5, -3, 5, -3, 5, -3, 5, -3, 5, -3]) == 13\n assert candidate(nums = [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000]) == 5000\n assert candidate(nums = [10000, -1000, 5000, -500, 2000, -300]) == 16200\n assert candidate(nums = [1, -2, 3, -2, 4, -1, 2, 1, -5, 4]) == 10\n assert candidate(nums = [8, -1, 3, -2, 4, -3, 2, 1, -5, 4]) == 16\n assert candidate(nums = [10, -20, 5, 5, -3, 2, -1]) == 18\n assert candidate(nums = [7, 5, -3, 6, -1, 8, -4, 2]) == 24\n assert candidate(nums = [-1, -2, -3, 4, 5, -1, 2, -1]) == 10\n assert candidate(nums = [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, -8]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [-5, 1, 5, 0, -7, 3, -1, 2]) == 6\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 5\n assert candidate(nums = [-2, -3, 4, -1, -2, 1, 5, -3, 2, -5]) == 7\n assert candidate(nums = [-10, 15, -20, 25, -30, 35, -40, 45, -50, 55]) == 75\n assert candidate(nums = [7, 5, -3, 6, -5, 2, -7, 8, -2, 4, 5]) == 30\n assert candidate(nums = [1, -2, 3, -2, 5, 6, -4, 2]) == 13\n assert candidate(nums = [-2, -3, -1, -4, -5, -7, -8, -6, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == -1\n assert candidate(nums = [1, 2, 3, 4, -10, 1, 2, 3, 4]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 6\n assert candidate(nums = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1, -1, -2]) == 15\n assert candidate(nums = [-1, -2, -3, 4, 5, -10, 6, 7]) == 16\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 1000]) == 1000\n assert candidate(nums = [-5, -1, -8, -9, -2, -6, -3, -8, -4, -5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, -5, -10, -15, -20, -25, 50, 100, -50, -100, 150, -200, 250, -300, 350, -400]) == 350\n assert candidate(nums = [3, -1, 2, -1, 4, -2, 5, -3, 6, -4, 7, -5, 8, -6, 9, -7, 10, -8]) == 25\n assert candidate(nums = [3, -2, 2, -3, 4, -1, 2, 1, -5, 4, 3, -2, 2, -3, 4, -1, 2, 1, -5, 4]) == 15\n assert candidate(nums = [-5, 5, -5, 5, -5, 5]) == 5\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(nums = [-2, 4, -3, 4, -1, -2, 1, 5, -3]) == 8\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1000]) == 1500\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -6, 7, 8, 9, 10]) == 49\n assert candidate(nums = [15, -2, 20, 4, -5, -9, -10]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 10]) == 25\n assert candidate(nums = [1, -10, 3, 4, -5, 2, 6, -1, 4]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13]) == 20\n assert candidate(nums = [10, -7, 9, -7, 9, -7, 9, 9, -6, -4, 6]) == 31\n assert candidate(nums = [100, -1, -100, 100, -1, -100, 100, -1, -100, 100]) == 200\n assert candidate(nums = [5, -2, 5, -2, 5, -2, 5, -2]) == 14\n assert candidate(nums = [-10, 2, 3, -2, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(nums = [5, 10, -20, 5, 10, 5]) == 35\n assert candidate(nums = [8, -1, 3, 4, -2, -3, 6, 1]) == 21\n assert candidate(nums = [5, 5, 5, 5, -10, 5, 5, 5, 5]) == 40\n assert candidate(nums = [10, -5, 4, -1, 12, -3, 7, -2, 8, -6]) == 30\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [8, -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]) == 90\n assert candidate(nums = [2, 3, -4, 5, 7, -10, 20, -5, 3, -2, 1, -1, 4, -3, 2, -2, 5, -7, 8, -6]) == 30\n assert candidate(nums = [-1, -2, 3, 4, -5, 6, -7, 8, -9, 10]) == 16\n assert candidate(nums = [1, 2, 3, -6, 1, 2, 3, 4, 5, -10, 1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [-1, -3, -5, 2, 1, -1, -2, 3, 4]) == 7\n assert candidate(nums = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100]) == 200\n assert candidate(nums = [-5, 5, -5, 5, -5, 5, -5, 5]) == 5\n assert candidate(nums = [3, -1, -1, 3, 5, -7, 5]) == 14\n assert candidate(nums = [1, -2, 3, 5, -6, 4, 2]) == 13\n assert candidate(nums = [0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [-5000, -1000, -3000, -2000, -4000, -1500]) == -1000\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [1, 2, 3, -6, 4, 5, 6, -10, 1, 2, 3, 4]) == 25\n assert candidate(nums = [5, -1, 5, -2, 3, 4, -5]) == 14\n assert candidate(nums = [-1, -2, -3, -4, -5, 15, 10, 5, -10, -5, 20, 25, -30]) == 60\n assert candidate(nums = [3, -4, 5, 2, -6, 1, 4, -3, 2, -5]) == 7\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5, -10]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -100, 10, 20, 30, 40, 50]) == 195\n assert candidate(nums = [5, 1, -2, 3, -1, 2]) == 10\n assert candidate(nums = [10, -2, -3, -4, 7, 9, -20, 10, 15]) == 42\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 = [3, -2, 2, 5, -3, 3, 5, -2, 3, 2, 5, -3]) == 21\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 22\n assert candidate(nums = [5, -1, 5, -1, 5, -1, 5, -1, 5, -1]) == 21\n assert candidate(nums = [100, -1, 100, -1, 100, -1, 100, -1, 100]) == 497\n assert candidate(nums = [1, -2, 3, 4, -1, 2, 1, -5, 4]) == 12\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,-2,3,-2]", "[5,-3,5]", "[-3,-2,-3]"], "hints": ["For those of you who are familiar with the Kadane's algorithm, think in terms of that. For the newbies, Kadane's algorithm is used to finding the maximum sum subarray from a given array. This problem is a twist on that idea and it is advisable to read up on that algorithm first before starting this problem. Unless you already have a great algorithm brewing up in your mind in which case, go right ahead!", "What is an alternate way of representing a circular array so that it appears to be a straight array? Essentially, there are two cases of this problem that we need to take care of. Let's look at the figure below to understand those two cases:", "The first case can be handled by the good old Kadane's algorithm. However, is there a smarter way of going about handling the second case as well?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSubarraySumCircular", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:09+00:00", "tests_total": 117, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "divide-and-conquer", "dynamic-programming", "queue", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def maxSubarraySumCircular(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxSubarraySumCircular", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 920, "task_id": "number-of-music-playlists", "difficulty": "Hard", "problem_description": "Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:\n\n- Every song is played at least once.\n- A song can only be played again only if k other songs have been played.\n\nGiven n, goal, and k, return the number of possible playlists that you can create. Since the answer can be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 3, goal = 3, k = 1\nOutput: 6\nExplanation: There are 6 possible playlists: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], and [3, 2, 1].\n\nExample 2:\n\nInput: n = 2, goal = 3, k = 0\nOutput: 6\nExplanation: There are 6 possible playlists: [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], and [1, 2, 2].\n\nExample 3:\n\nInput: n = 2, goal = 3, k = 1\nOutput: 2\nExplanation: There are 2 possible playlists: [1, 2, 1] and [2, 1, 2].\n\nConstraints:\n\n- 0 <= k < n <= goal <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,goal = 5,k = 2) == 120\n assert candidate(n = 3,goal = 4,k = 1) == 18\n assert candidate(n = 4,goal = 6,k = 2) == 168\n assert candidate(n = 3,goal = 3,k = 1) == 6\n assert candidate(n = 2,goal = 3,k = 1) == 2\n assert candidate(n = 10,goal = 10,k = 5) == 3628800\n assert candidate(n = 10,goal = 10,k = 0) == 3628800\n assert candidate(n = 100,goal = 100,k = 99) == 437918130\n assert candidate(n = 7,goal = 8,k = 3) == 50400\n assert candidate(n = 6,goal = 6,k = 3) == 720\n assert candidate(n = 4,goal = 5,k = 2) == 72\n assert candidate(n = 2,goal = 3,k = 0) == 6\n assert candidate(n = 10,goal = 15,k = 5) == 314718922\n assert candidate(n = 5,goal = 5,k = 0) == 120\n assert candidate(n = 5,goal = 6,k = 2) == 720\n assert candidate(n = 1,goal = 1,k = 0) == 1\n assert candidate(n = 60,goal = 80,k = 15) == 735857219\n assert candidate(n = 95,goal = 100,k = 50) == 174977625\n assert candidate(n = 70,goal = 100,k = 40) == 538034361\n assert candidate(n = 8,goal = 20,k = 2) == 930652117\n assert candidate(n = 80,goal = 100,k = 40) == 871833725\n assert candidate(n = 40,goal = 50,k = 10) == 865239591\n assert candidate(n = 50,goal = 75,k = 25) == 937903747\n assert candidate(n = 60,goal = 70,k = 30) == 540386145\n assert candidate(n = 5,goal = 10,k = 2) == 115920\n assert candidate(n = 3,goal = 9,k = 1) == 762\n assert candidate(n = 6,goal = 12,k = 0) == 953029440\n assert candidate(n = 4,goal = 6,k = 1) == 600\n assert candidate(n = 25,goal = 35,k = 12) == 371031271\n assert candidate(n = 80,goal = 100,k = 60) == 978677402\n assert candidate(n = 4,goal = 15,k = 2) == 98280\n assert candidate(n = 30,goal = 40,k = 10) == 300617761\n assert candidate(n = 90,goal = 100,k = 80) == 515779794\n assert candidate(n = 50,goal = 75,k = 20) == 512461610\n assert candidate(n = 8,goal = 16,k = 4) == 655720152\n assert candidate(n = 20,goal = 25,k = 10) == 708676825\n assert candidate(n = 55,goal = 75,k = 25) == 829204517\n assert candidate(n = 30,goal = 100,k = 25) == 238440403\n assert candidate(n = 35,goal = 50,k = 10) == 681866396\n assert candidate(n = 50,goal = 50,k = 25) == 318608048\n assert candidate(n = 15,goal = 25,k = 7) == 357904575\n assert candidate(n = 8,goal = 15,k = 4) == 876639965\n assert candidate(n = 70,goal = 80,k = 40) == 172533607\n assert candidate(n = 40,goal = 50,k = 30) == 292538678\n assert candidate(n = 60,goal = 80,k = 40) == 183945178\n assert candidate(n = 30,goal = 40,k = 5) == 922217496\n assert candidate(n = 40,goal = 100,k = 35) == 953525405\n assert candidate(n = 70,goal = 100,k = 50) == 65098072\n assert candidate(n = 10,goal = 15,k = 3) == 694588868\n assert candidate(n = 80,goal = 90,k = 50) == 237760215\n assert candidate(n = 25,goal = 50,k = 10) == 429087363\n assert candidate(n = 35,goal = 50,k = 5) == 198199125\n assert candidate(n = 50,goal = 100,k = 45) == 838158734\n assert candidate(n = 40,goal = 60,k = 10) == 228726453\n assert candidate(n = 50,goal = 100,k = 1) == 80478639\n assert candidate(n = 60,goal = 80,k = 30) == 601847758\n assert candidate(n = 3,goal = 5,k = 1) == 42\n assert candidate(n = 30,goal = 50,k = 10) == 198995152\n assert candidate(n = 40,goal = 45,k = 15) == 496260317\n assert candidate(n = 7,goal = 12,k = 1) == 904614480\n assert candidate(n = 20,goal = 20,k = 10) == 146326063\n assert candidate(n = 5,goal = 20,k = 3) == 7864200\n assert candidate(n = 3,goal = 10,k = 1) == 1530\n assert candidate(n = 20,goal = 30,k = 10) == 681973277\n assert candidate(n = 20,goal = 30,k = 5) == 252498779\n assert candidate(n = 90,goal = 100,k = 70) == 614582964\n assert candidate(n = 10,goal = 20,k = 5) == 993942190\n assert candidate(n = 25,goal = 50,k = 15) == 325370660\n assert candidate(n = 40,goal = 50,k = 20) == 73692427\n assert candidate(n = 50,goal = 70,k = 25) == 598060511\n assert candidate(n = 50,goal = 100,k = 30) == 226791857\n assert candidate(n = 65,goal = 80,k = 35) == 757952334\n assert candidate(n = 20,goal = 40,k = 15) == 504044110\n assert candidate(n = 30,goal = 40,k = 15) == 213845140\n assert candidate(n = 30,goal = 60,k = 20) == 611199752\n assert candidate(n = 30,goal = 50,k = 15) == 745316193\n assert candidate(n = 45,goal = 60,k = 10) == 447565182\n assert candidate(n = 45,goal = 60,k = 25) == 422620880\n assert candidate(n = 80,goal = 90,k = 40) == 803255223\n assert candidate(n = 7,goal = 30,k = 5) == 557163012\n assert candidate(n = 7,goal = 10,k = 3) == 1764000\n assert candidate(n = 30,goal = 90,k = 15) == 707675175\n assert candidate(n = 50,goal = 75,k = 30) == 167112607\n assert candidate(n = 7,goal = 15,k = 3) == 81965019\n assert candidate(n = 6,goal = 12,k = 2) == 24555600\n assert candidate(n = 40,goal = 60,k = 20) == 833839566\n assert candidate(n = 6,goal = 25,k = 4) == 754974000\n assert candidate(n = 40,goal = 80,k = 25) == 764575926\n", "comparison": "exact"}, "public_tests": ["3\n3\n1", "2\n3\n0", "2\n3\n1"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "goal", "k"], "leetcode_dataset_entry_point": "Solution().numMusicPlaylists", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:11+00:00", "tests_total": 88, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def numMusicPlaylists(self, n: int, goal: int, k: int) -> int:", "container": "Solution", "callable": "numMusicPlaylists", "parameters": [{"name": "n", "type": "int"}, {"name": "goal", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 921, "task_id": "minimum-add-to-make-parentheses-valid", "difficulty": "Medium", "problem_description": "A parentheses string is valid if and only if:\n\n- It is the empty string,\n- It can be written as AB (A concatenated with B), where A and B are valid strings, or\n- It can be written as (A), where A is a valid string.\n\nYou are given a parentheses string s. In one move, you can insert a parenthesis at any position of the string.\n\n- For example, if s = \"()))\", you can insert an opening parenthesis to be \"(()))\" or a closing parenthesis to be \"())))\".\n\nReturn the minimum number of moves required to make s valid.\n\nExample 1:\n\nInput: s = \"())\"\nOutput: 1\n\nExample 2:\n\nInput: s = \"(((\"\nOutput: 3\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s[i] is either '(' or ')'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()))\") == 1\n assert candidate(s = \"())\") == 1\n assert candidate(s = \"()\") == 0\n assert candidate(s = \"((((((()))\") == 4\n assert candidate(s = \"())(()\") == 2\n assert candidate(s = \"((()))\") == 0\n assert candidate(s = \"((\") == 2\n assert candidate(s = \"(()))(\") == 2\n assert candidate(s = \"(())\") == 0\n assert candidate(s = \"(()))(()\") == 2\n assert candidate(s = \"()))((\") == 4\n assert candidate(s = \"))(()()((()(()))))\") == 2\n assert candidate(s = \"()()(()(()))(()(()(()(()))))\") == 0\n assert candidate(s = \"((((((((((()))))))))\") == 2\n assert candidate(s = \"(())))(()\") == 3\n assert candidate(s = \")(()))()()\") == 2\n assert candidate(s = \"(()((())()()))\") == 0\n assert candidate(s = \"((((((())\") == 5\n assert candidate(s = \"()(()(()))\") == 0\n assert candidate(s = \"(()(()))()()(()(()()()(()())())\") == 1\n assert candidate(s = \"((((()()()(()))))\") == 1\n assert candidate(s = \"(()(()(()(()(()())())))\") == 1\n assert candidate(s = \"(()(()))))((()\") == 4\n assert candidate(s = \"(()(()))(()(()(()(()))))\") == 0\n assert candidate(s = \"(()())((()))\") == 0\n assert candidate(s = \"()))(((((()))))())\") == 2\n assert candidate(s = \"(((()(()(()(()))))))\") == 0\n assert candidate(s = \"((()))(())()(()(()))\") == 0\n assert candidate(s = \"(()(()(()(()(()))))())\") == 0\n assert candidate(s = \"(()())(()())(()())\") == 0\n assert candidate(s = \"()()()(()(()))((()))(()(()(()(())))()(()))\") == 0\n assert candidate(s = \"((()))())((())()())\") == 1\n assert candidate(s = \"()()()()()()()()()()()()()()\") == 0\n assert candidate(s = \"(()))(((()))()()(()(()(()))))(())\") == 1\n assert candidate(s = \"((((((((())))))))()()\") == 1\n assert candidate(s = \"((((((()))))\") == 2\n assert candidate(s = \"))(()(()))\") == 2\n assert candidate(s = \"((((((()))))))\") == 0\n assert candidate(s = \"(()((())()(()))\") == 1\n assert candidate(s = \")((((((((((())\") == 10\n assert candidate(s = \"(()(()(()(()))))\") == 0\n assert candidate(s = \"(()(()(()(()(()()))))(()(()(()))))()\") == 0\n assert candidate(s = \"(()(()(()(()))(()(()))))\") == 0\n assert candidate(s = \"((((((())))))))\") == 1\n assert candidate(s = \"(()))(()((()())(()())))\") == 1\n assert candidate(s = \"(()())())\") == 1\n assert candidate(s = \"())()()()(((())))\") == 1\n assert candidate(s = \"(()(()))(()())(()(()))\") == 0\n assert candidate(s = \"(((()))(()(())))\") == 0\n assert candidate(s = \"()()(()))(()((()())))\") == 1\n assert candidate(s = \"((())(()(()(()))))\") == 0\n assert candidate(s = \"(()()(()))(()(()(()))(()(()))))\") == 1\n assert candidate(s = \"(()(()))\") == 0\n assert candidate(s = \")((((((()())\") == 6\n assert candidate(s = \"(((()))(()(()))(()(()))\") == 1\n assert candidate(s = \")()(()))(()\") == 3\n assert candidate(s = \"()()()()\") == 0\n assert candidate(s = \"(((())(())))\") == 0\n assert candidate(s = \"(()(()(()(()(()(()))))))\") == 0\n assert candidate(s = \"((())())(()(()(()))())\") == 0\n assert candidate(s = \"(()(()(()())))\") == 0\n assert candidate(s = \"())(()))(()(()))\") == 2\n assert candidate(s = \"(()(()(()(()(()(()())())))())())\") == 0\n assert candidate(s = \"(()())((()()(())))\") == 0\n assert candidate(s = \"(()(())))\") == 1\n assert candidate(s = \"(()()(()(())))()(()(()))\") == 0\n assert candidate(s = \"(((((())))))()()()(((()(()))))()()\") == 0\n assert candidate(s = \"(()(()(()(()(()(()(()))))))))\") == 1\n assert candidate(s = \"()(()(()(()(()))))\") == 0\n assert candidate(s = \"(()(()))(()(()))\") == 0\n assert candidate(s = \"()(()(()(()())))\") == 0\n assert candidate(s = \"())(((())))\") == 1\n assert candidate(s = \"()())(()(()))(()\") == 2\n assert candidate(s = \")(()(()(()(()(())))))\") == 1\n assert candidate(s = \"((((((((((()))))))))))\") == 0\n assert candidate(s = \"(())))))(((()()()(()(()))))))\") == 5\n assert candidate(s = \")(()(()(()(()))))\") == 1\n assert candidate(s = \"()(()(()))(()(()(()(()))))\") == 0\n assert candidate(s = \"(((((((())))))))\") == 0\n assert candidate(s = \"())(()))(()(()(()())))((()())())\") == 2\n assert candidate(s = \"(((((((())))))\") == 2\n assert candidate(s = \"(((()())()))\") == 0\n assert candidate(s = \"(()(()(()(()))))())\") == 1\n assert candidate(s = \"(()))(()))(())))\") == 4\n assert candidate(s = \"()()()(()()())()()()()\") == 0\n assert candidate(s = \"(()())(()())\") == 0\n assert candidate(s = \"(()(()))(()(()(()(()(())))))\") == 0\n assert candidate(s = \")()()()()()()\") == 1\n assert candidate(s = \"()(()))((())((())())\") == 2\n assert candidate(s = \"())(()(()))\") == 1\n assert candidate(s = \"())())())())())())\") == 6\n assert candidate(s = \"(()))())(()\") == 3\n assert candidate(s = \"()()()()()()()()\") == 0\n assert candidate(s = \"((())(()))\") == 0\n assert candidate(s = \"(())))))()\") == 4\n assert candidate(s = \"()(()((())))()()(()(()))))\") == 2\n assert candidate(s = \"(()(()))()(()(()))\") == 0\n assert candidate(s = \"(()))(()))\") == 2\n assert candidate(s = \"(((()))(()))\") == 0\n assert candidate(s = \"()()()()()()\") == 0\n assert candidate(s = \")()(()()((()())))\") == 1\n assert candidate(s = \"(()))((())(()(())))\") == 1\n assert candidate(s = \"()(()()(()(()())))\") == 0\n assert candidate(s = \"())((())\") == 2\n assert candidate(s = \"(((((((()))())())())(())))))\") == 2\n assert candidate(s = \"(((((())))))()\") == 0\n assert candidate(s = \"))))))))))))\") == 12\n assert candidate(s = \"()()()(((()))))((()))(()(()))(()())\") == 1\n assert candidate(s = \"((())()(()(()))\") == 1\n assert candidate(s = \"())(()()\") == 2\n assert candidate(s = \"(()(((((((((()))))))\") == 4\n assert candidate(s = \"((((()))))\") == 0\n assert candidate(s = \"(((((())))))()(()(()))\") == 0\n assert candidate(s = \"(()(((())))())\") == 0\n", "comparison": "exact"}, "public_tests": ["\"())\"", "\"(((\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minAddToMakeValid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:13+00:00", "tests_total": 115, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "stack", "greedy", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def minAddToMakeValid(self, s: str) -> int:", "container": "Solution", "callable": "minAddToMakeValid", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 922, "task_id": "sort-array-by-parity-ii", "difficulty": "Easy", "problem_description": "Given an array of integers nums, half of the integers in nums are odd, and the other half are even.\n\nSort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even.\n\nReturn any answer array that satisfies this condition.\n\nExample 1:\n\nInput: nums = [4,2,5,7]\nOutput: [4,5,2,7]\nExplanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted.\n\nExample 2:\n\nInput: nums = [2,3]\nOutput: [2,3]\n\nConstraints:\n\n- 2 <= nums.length <= 2 * 10^4\n- nums.length is even.\n- Half of the integers in nums are even.\n- 0 <= nums[i] <= 1000\n\nFollow Up: Could you solve it in-place?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 6, 7]) == [2, 3, 6, 7]\n assert candidate(nums = [2, 3]) == [2, 3]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [8, 11, 6, 9, 5, 10, 7, 2]) == [8, 11, 6, 9, 10, 5, 2, 7]\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4]) == [2, 1, 4, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == [2, 1, 4, 3, 6, 5, 8, 7]\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4]) == [100, 1, 200, 2, 300, 3, 400, 4]\n assert candidate(nums = [8, 13, 6, 3, 10, 5, 7, 2]) == [8, 13, 6, 3, 10, 5, 2, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == [2, 1, 4, 3, 6, 5]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [4, 2, 5, 7]) == [4, 5, 2, 7]\n assert candidate(nums = [6, 1, 4, 3, 2, 5]) == [6, 1, 4, 3, 2, 5]\n assert candidate(nums = [6, 1, 4, 3]) == [6, 1, 4, 3]\n assert candidate(nums = [2, 3, 4, 1]) == [2, 3, 4, 1]\n assert candidate(nums = [1000, 1, 800, 2, 600, 3]) == [1000, 1, 800, 2, 600, 3]\n assert candidate(nums = [1, 3, 2, 4, 5, 6]) == [4, 3, 2, 1, 6, 5]\n assert candidate(nums = [8, 11, 6, 9, 10, 7]) == [8, 11, 6, 9, 10, 7]\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185]) == [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9]) == [8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9]\n assert candidate(nums = [10, 1, 20, 3, 30, 5, 40, 7, 50, 9, 60, 11, 70, 13, 80, 15, 90, 17, 100, 19]) == [10, 1, 20, 3, 30, 5, 40, 7, 50, 9, 60, 11, 70, 13, 80, 15, 90, 17, 100, 19]\n assert candidate(nums = [8, 1, 6, 3, 5, 4, 2, 7]) == [8, 1, 6, 3, 4, 5, 2, 7]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == [888, 999, 666, 777, 444, 555, 222, 333, 0, 111]\n assert candidate(nums = [20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 1, 3, 5, 7, 9, 11]) == [20, 1, 24, 5, 28, 9, 32, 34, 36, 38, 22, 3, 26, 7, 30, 11]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(nums = [800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813]) == [800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511]) == [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511]\n assert candidate(nums = [1000, 1, 998, 3, 996, 5, 994, 7]) == [1000, 1, 998, 3, 996, 5, 994, 7]\n assert candidate(nums = [8, 13, 18, 23, 28, 33, 38, 43, 48, 53]) == [8, 13, 18, 23, 28, 33, 38, 43, 48, 53]\n assert candidate(nums = [5, 8, 6, 3, 4, 7, 2, 9, 1, 10]) == [8, 5, 6, 3, 4, 7, 2, 9, 10, 1]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15]) == [2, 1, 6, 5, 10, 9, 14, 13, 4, 3, 8, 7, 12, 11, 16, 15]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515]) == [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515]\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 = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10]) == [1000, 1, 2, 999, 998, 3, 4, 997, 996, 5, 6, 995, 994, 7, 8, 993, 992, 9, 10, 991]\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 = [1, 3, 2, 4, 5, 6, 7, 8]) == [4, 3, 2, 1, 6, 5, 8, 7]\n assert candidate(nums = [600, 1, 598, 3, 596, 5, 594, 7, 592, 9, 590, 11, 588, 13, 586, 15, 584, 17, 582, 19]) == [600, 1, 598, 3, 596, 5, 594, 7, 592, 9, 590, 11, 588, 13, 586, 15, 584, 17, 582, 19]\n assert candidate(nums = [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [4, 3, 8, 7, 12, 11, 2, 1, 6, 5, 10, 9, 14, 16, 18, 20]\n assert candidate(nums = [2, 1, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17]) == [2, 1, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509]) == [500, 501, 502, 503, 504, 505, 506, 507, 508, 509]\n assert candidate(nums = [1000, 501, 701, 10, 20, 400, 300, 301]) == [1000, 501, 10, 701, 20, 400, 300, 301]\n assert candidate(nums = [31, 28, 33, 30, 35, 32, 37, 34, 39, 36, 41, 38, 43, 40, 45, 42]) == [28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45]\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 = [1, 3, 5, 7, 2, 4, 6, 8]) == [4, 3, 8, 7, 2, 1, 6, 5]\n assert candidate(nums = [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, 14, 15]\n assert candidate(nums = [4, 1, 2, 3, 6, 5, 8, 7]) == [4, 1, 2, 3, 6, 5, 8, 7]\n assert candidate(nums = [8, 6, 4, 2, 7, 5, 3, 1, 10, 9, 12, 11, 14, 13, 16, 15]) == [8, 7, 4, 3, 6, 5, 2, 1, 10, 9, 12, 11, 14, 13, 16, 15]\n assert candidate(nums = [7, 2, 5, 8, 3, 10, 9, 6, 11, 4]) == [2, 7, 8, 5, 10, 3, 6, 9, 4, 11]\n assert candidate(nums = [998, 1, 996, 3, 994, 5, 992, 7, 990, 9, 988, 11, 986, 13, 984, 15]) == [998, 1, 996, 3, 994, 5, 992, 7, 990, 9, 988, 11, 986, 13, 984, 15]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [42, 3, 18, 35, 40, 45, 52, 57, 60, 65, 70, 75, 82, 87, 90, 95, 100, 105, 110, 115]) == [42, 3, 18, 35, 40, 45, 52, 57, 60, 65, 70, 75, 82, 87, 90, 95, 100, 105, 110, 115]\n assert candidate(nums = [1000, 999, 100, 99, 20, 19, 2, 1]) == [1000, 999, 100, 99, 20, 19, 2, 1]\n assert candidate(nums = [1, 3, 2, 4, 7, 6, 9, 8]) == [4, 3, 2, 1, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]\n assert candidate(nums = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491]) == [500, 499, 498, 497, 496, 495, 494, 493, 492, 491]\n assert candidate(nums = [998, 999, 996, 997, 994, 995, 992, 993, 990, 991]) == [998, 999, 996, 997, 994, 995, 992, 993, 990, 991]\n assert candidate(nums = [10, 21, 8, 13, 6, 17, 4, 19]) == [10, 21, 8, 13, 6, 17, 4, 19]\n assert candidate(nums = [500, 1, 498, 3, 496, 5, 494, 7, 492, 9, 490, 11]) == [500, 1, 498, 3, 496, 5, 494, 7, 492, 9, 490, 11]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [44, 1, 3, 2, 10, 5, 8, 7, 6, 9]) == [44, 1, 2, 3, 10, 5, 8, 7, 6, 9]\n assert candidate(nums = [10, 21, 20, 31, 40, 51, 60, 71]) == [10, 21, 20, 31, 40, 51, 60, 71]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]\n assert candidate(nums = [1000, 1, 998, 3, 996, 5, 994, 7, 992, 9, 990, 11, 988, 13, 986, 15]) == [1000, 1, 998, 3, 996, 5, 994, 7, 992, 9, 990, 11, 988, 13, 986, 15]\n assert candidate(nums = [600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629]) == [600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [4, 3, 8, 7, 12, 11, 16, 15, 20, 19, 2, 1, 6, 5, 10, 9, 14, 13, 18, 17]\n assert candidate(nums = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == [102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111, 114, 113, 116, 115, 118, 117, 120, 119]\n assert candidate(nums = [2, 1, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [2, 1, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [1, 3, 5, 2, 4, 6]) == [2, 3, 6, 1, 4, 5]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]\n assert candidate(nums = [1000, 1, 2, 999, 4, 3, 6, 8, 7, 5, 12, 11, 14, 13, 16, 15]) == [1000, 1, 2, 999, 4, 3, 6, 7, 8, 5, 12, 11, 14, 13, 16, 15]\n assert candidate(nums = [999, 997, 995, 993, 991, 989, 987, 985, 0, 2, 4, 6, 8, 10, 12, 14]) == [2, 997, 6, 993, 10, 989, 14, 985, 0, 999, 4, 995, 8, 991, 12, 987]\n assert candidate(nums = [3, 6, 1, 8, 5, 10, 7, 12, 9, 14, 11, 16]) == [6, 3, 8, 1, 10, 5, 12, 7, 14, 9, 16, 11]\n assert candidate(nums = [998, 999, 996, 997, 994, 995, 992, 993]) == [998, 999, 996, 997, 994, 995, 992, 993]\n assert candidate(nums = [998, 999, 1000, 0, 2, 4, 6, 8]) == [998, 999, 1000, 0, 2, 4, 6, 8]\n assert candidate(nums = [800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819]) == [800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45]) == [10, 15, 20, 25, 30, 35, 40, 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]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [8, 1, 4, 3, 6, 5, 2, 7, 10, 9]) == [8, 1, 4, 3, 6, 5, 2, 7, 10, 9]\n", "comparison": "exact"}, "public_tests": ["[4,2,5,7]", "[2,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sortArrayByParityII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:15+00:00", "tests_total": 81, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sortArrayByParityII(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "sortArrayByParityII", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 923, "task_id": "3sum-with-multiplicity", "difficulty": "Medium", "problem_description": "Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.\n\nAs the answer can be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: arr = [1,1,2,2,3,3,4,4,5,5], target = 8\nOutput: 20\nExplanation:\nEnumerating by the values (arr[i], arr[j], arr[k]):\n(1, 2, 5) occurs 8 times;\n(1, 3, 4) occurs 8 times;\n(2, 2, 4) occurs 2 times;\n(2, 3, 3) occurs 2 times.\n\nExample 2:\n\nInput: arr = [1,1,2,2,2,2], target = 5\nOutput: 12\nExplanation:\narr[i] = 1, arr[j] = arr[k] = 2 occurs 12 times:\nWe choose one 1 from [1,1] in 2 ways,\nand two 2s from [2,2,2,2] in 6 ways.\n\nExample 3:\n\nInput: arr = [2,1,3], target = 6\nOutput: 1\nExplanation: (1, 2, 3) occured one time in the array so we return 1.\n\nConstraints:\n\n- 3 <= arr.length <= 3000\n- 0 <= arr[i] <= 100\n- 0 <= target <= 300\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 18) == 11\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],target = 10) == 74\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 15) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 3) == 1140\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 10\n assert candidate(arr = [100, 100, 100],target = 300) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 8) == 20\n assert candidate(arr = [2, 1, 3],target = 6) == 1\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50],target = 150) == 84\n assert candidate(arr = [1, 2, 3, 4, 5],target = 9) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 2],target = 5) == 12\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 120\n assert candidate(arr = [50, 50, 50, 50, 50],target = 150) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 10\n assert candidate(arr = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 7) == 22\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],target = 300) == 120\n assert candidate(arr = [0, 0, 0],target = 0) == 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],target = 9) == 63\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 150) == 45\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 1140\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 36) == 42\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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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 = 30) == 50116\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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 60) == 105\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 4495\n assert candidate(arr = [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],target = 75) == 4060\n assert candidate(arr = [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],target = 12) == 184\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5],target = 7) == 93\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 18) == 88\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10],target = 16) == 224\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 24) == 25\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 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],target = 12) == 628\n assert candidate(arr = [1, 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],target = 9) == 399\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],target = 15) == 1330\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 25) == 38\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 455\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 30) == 0\n assert candidate(arr = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50],target = 90) == 73\n assert candidate(arr = [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],target = 27) == 1078\n assert candidate(arr = [1, 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],target = 18) == 2751\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],target = 15) == 4060\n assert candidate(arr = [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],target = 90) == 3276\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 200) == 74\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 60) == 19\n assert candidate(arr = [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],target = 100) == 632\n assert candidate(arr = [1, 3, 3, 3, 5, 5, 6, 6, 6, 7, 7, 7, 9, 9, 10],target = 17) == 39\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],target = 9) == 49\n assert candidate(arr = [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],target = 45) == 113\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],target = 15) == 253\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10, 10],target = 20) == 210\n assert candidate(arr = [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],target = 12) == 582\n assert candidate(arr = [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10],target = 6) == 99\n assert candidate(arr = [1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30],target = 60) == 98\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 22\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 20825\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],target = 39) == 72\n assert candidate(arr = [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],target = 6) == 525\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],target = 30) == 45\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 18) == 1260\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],target = 35) == 69\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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 = 150) == 0\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],target = 15) == 307\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10],target = 18) == 929\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 5, 5, 5, 6, 6, 7, 8, 9, 10],target = 12) == 34\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 150) == 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],target = 60) == 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],target = 50) == 103\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],target = 60) == 75\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 45\n assert candidate(arr = [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],target = 15) == 277\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 10\n assert candidate(arr = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60],target = 100) == 30\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],target = 60) == 190\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 4060\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 24804\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 4) == 450\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 12) == 46\n assert candidate(arr = [1, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9, 11, 11, 11, 11],target = 18) == 0\n assert candidate(arr = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],target = 150) == 88\n assert candidate(arr = [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, 10, 10, 10, 10, 10, 10],target = 12) == 1082\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],target = 60) == 45\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],target = 6) == 37\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],target = 45) == 105\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],target = 6) == 37\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 15) == 108\n assert candidate(arr = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],target = 10) == 57\n", "comparison": "exact"}, "public_tests": ["[1,1,2,2,3,3,4,4,5,5]\n8", "[1,1,2,2,2,2]\n5", "[2,1,3]\n6"], "hints": [], "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().threeSumMulti", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:18+00:00", "tests_total": 87, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def threeSumMulti(self, arr: list[int], target: int) -> int:", "container": "Solution", "callable": "threeSumMulti", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 924, "task_id": "minimize-malware-spread", "difficulty": "Hard", "problem_description": "You are given a network of n nodes represented as an n x n adjacency matrix graph, where the i^th node is directly connected to the j^th node if graph[i][j] == 1.\n\nSome nodes initial are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.\n\nSuppose M(initial) is the final number of nodes infected with malware in the entire network after the spread of malware stops. We will remove exactly one node from initial.\n\nReturn the node that, if removed, would minimize M(initial). If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.\n\nNote that if a node was removed from the initial list of infected nodes, it might still be infected later due to the malware spread.\n\nExample 1:\n\nInput: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]\nOutput: 0\n\nExample 2:\n\nInput: graph = [[1,0,0],[0,1,0],[0,0,1]], initial = [0,2]\nOutput: 0\n\nExample 3:\n\nInput: graph = [[1,1,1],[1,1,1],[1,1,1]], initial = [1,2]\nOutput: 1\n\nConstraints:\n\n- n == graph.length\n- n == graph[i].length\n- 2 <= n <= 300\n- graph[i][j] is 0 or 1.\n- graph[i][j] == graph[j][i]\n- graph[i][i] == 1\n- 1 <= initial.length <= n\n- 0 <= initial[i] <= n - 1\n- All the integers in initial are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(graph = [[1, 1, 1, 1], [1, 1, 0, 0], [1, 0, 1, 1], [1, 0, 1, 1]],initial = [0, 1, 2, 3]) == 0\n assert candidate(graph = [[1, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 1, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],initial = [0, 2]) == 0\n assert candidate(graph = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],initial = [2, 3]) == 2\n assert candidate(graph = [[1, 1, 0], [1, 1, 0], [0, 0, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1], [0, 0, 1, 1]],initial = [0, 1, 3]) == 0\n assert candidate(graph = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 1, 1], [0, 1, 1, 1]],initial = [1, 2]) == 1\n assert candidate(graph = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 1, 0], [0, 1, 0, 1]],initial = [1, 2, 3]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1]],initial = [0, 1, 4]) == 4\n assert candidate(graph = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],initial = [1, 2]) == 1\n assert candidate(graph = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],initial = [0, 2]) == 0\n assert candidate(graph = [[1, 1, 1, 0], [1, 1, 0, 0], [1, 0, 1, 1], [0, 0, 1, 1]],initial = [2, 3]) == 2\n assert candidate(graph = [[1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 1, 1, 0, 1], [0, 0, 1, 1, 1, 0], [1, 0, 0, 1, 1, 1], [0, 1, 1, 0, 1, 1]],initial = [1, 3, 5]) == 1\n assert candidate(graph = [[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]],initial = [0, 3, 4]) == 0\n assert candidate(graph = [[1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 6, 8]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 7]) == 1\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 6]) == 0\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 3, 5]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1]],initial = [0, 1, 4, 6]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 1, 0, 1]],initial = [1, 2, 4]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 9, 10]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 4]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [0, 1, 1, 0, 0], [0, 1, 0, 1, 1], [0, 0, 0, 1, 1]],initial = [1, 3, 4]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1]],initial = [2, 4, 6, 7]) == 2\n assert candidate(graph = [[1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [0, 1, 0, 1, 1, 0], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 2, 4]) == 0\n assert candidate(graph = [[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]],initial = [0, 1, 4]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6]) == 0\n assert candidate(graph = [[1, 1, 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, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6, 8]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 1]],initial = [1, 3, 5]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 4, 6, 9]) == 1\n assert candidate(graph = [[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 7]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 4, 6]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 8]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 3, 6, 7]) == 2\n assert candidate(graph = [[1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [0, 1, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1]],initial = [2, 3, 5]) == 5\n assert candidate(graph = [[1, 0, 0, 0, 0], [0, 1, 1, 1, 1], [0, 1, 1, 0, 0], [0, 1, 0, 1, 1], [0, 1, 0, 1, 1]],initial = [1, 3]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1], [0, 0, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 1]],initial = [2, 4, 5]) == 2\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 8]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 6]) == 1\n assert candidate(graph = [[1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 4, 7]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [1, 2, 3, 4]) == 1\n assert candidate(graph = [[1, 1, 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, 0, 0, 0], [0, 0, 1, 1, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1]],initial = [1, 3, 5, 8]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [1, 3, 5]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1]],initial = [1, 3, 5, 7, 9]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 1, 0, 1]],initial = [0, 2, 3]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1]],initial = [1, 5, 7]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],initial = [0, 3]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 3, 5]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 1], [0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1]],initial = [0, 1, 5]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 1, 4, 7]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 1, 5]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 3, 5, 8]) == 2\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [0, 1, 1, 0, 0], [0, 1, 0, 1, 1], [0, 0, 0, 1, 1]],initial = [1, 2, 3]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 7]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]],initial = [1, 2, 4]) == 4\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 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, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 9]) == 0\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [1, 4, 5]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 1, 0, 1]],initial = [0, 1, 4]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0], [0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1]],initial = [1, 3, 5]) == 1\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 2, 5]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 6, 9]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6, 8]) == 0\n assert candidate(graph = [[1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]],initial = [0, 1, 3, 5, 6]) == 0\n assert candidate(graph = [[1, 1, 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, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 4, 6, 8]) == 2\n assert candidate(graph = [[1, 1, 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, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5, 8]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 8]) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,1,0],[1,1,0],[0,0,1]]\n[0,1]", "[[1,0,0],[0,1,0],[0,0,1]]\n[0,2]", "[[1,1,1],[1,1,1],[1,1,1]]\n[1,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["graph", "initial"], "leetcode_dataset_entry_point": "Solution().minMalwareSpread", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:20+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def minMalwareSpread(self, graph: list[list[int]], initial: list[int]) -> int:", "container": "Solution", "callable": "minMalwareSpread", "parameters": [{"name": "graph", "type": "list[list[int]]"}, {"name": "initial", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 925, "task_id": "long-pressed-name", "difficulty": "Easy", "problem_description": "Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.\n\nYou examine the typed characters of the keyboard. Return True if it is possible that it was your friends name, with some characters (possibly none) being long pressed.\n\nExample 1:\n\nInput: name = \"alex\", typed = \"aaleex\"\nOutput: true\nExplanation: 'a' and 'e' in 'alex' were long pressed.\n\nExample 2:\n\nInput: name = \"saeed\", typed = \"ssaaedd\"\nOutput: false\nExplanation: 'e' must have been pressed twice, but it was not in the typed output.\n\nConstraints:\n\n- 1 <= name.length, typed.length <= 1000\n- name and typed consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(name = \"zzzzzzzz\",typed = \"zzzzzzzz\") == True\n assert candidate(name = \"abcd\",typed = \"abcde\") == False\n assert candidate(name = \"test\",typed = \"ttest\") == True\n assert candidate(name = \"dfuyalc\",typed = \"fuuyallc\") == False\n assert candidate(name = \"zzzyyyyy\",typed = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(name = \"abcd\",typed = \"abcddcba\") == False\n assert candidate(name = \"alex\",typed = \"aaleexa\") == False\n assert candidate(name = \"kikcxmvzi\",typed = \"kiikcxxmmvvzzz\") == False\n assert candidate(name = \"pyplrz\",typed = \"ppyypllrz\") == True\n assert candidate(name = \"ggggggg\",typed = \"ggggggg\") == True\n assert candidate(name = \"laiden\",typed = \"laiden\") == True\n assert candidate(name = \"saeed\",typed = \"ssaaedd\") == False\n assert candidate(name = \"a\",typed = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(name = \"a\",typed = \"b\") == False\n assert candidate(name = \"abcd\",typed = \"abc\") == False\n assert candidate(name = \"pyplrz\",typed = \"ppyypllr\") == False\n assert candidate(name = \"a\",typed = \"aaaaaa\") == True\n assert candidate(name = \"leelee\",typed = \"lleeelee\") == True\n assert candidate(name = \"zzzaaa\",typed = \"zzzzzaaaa\") == True\n assert candidate(name = \"alex\",typed = \"aaleex\") == True\n assert candidate(name = \"vtkgn\",typed = \"vttkgnn\") == True\n assert candidate(name = \"alex\",typed = \"ale\") == False\n assert candidate(name = \"hello\",typed = \"hheeelllloo\") == True\n assert candidate(name = \"mississippi\",typed = \"miiiiiiissssssippiiiiii\") == False\n assert candidate(name = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",typed = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == True\n assert candidate(name = \"repeated\",typed = \"repeeeaatteedd\") == True\n assert candidate(name = \"testing\",typed = \"testings\") == False\n assert candidate(name = \"mississippi\",typed = \"mmiissssippip\") == False\n assert candidate(name = \"aabbcc\",typed = \"aaabbbccc\") == True\n assert candidate(name = \"abcdefghij\",typed = \"aabbccddeeffgghhiijj\") == True\n assert candidate(name = \"mississippi\",typed = \"mmiiisssssiiiippp\") == False\n assert candidate(name = \"flower\",typed = \"ffflowweerrr\") == True\n assert candidate(name = \"consistent\",typed = \"cccooonnsisstiisstteeennnttt\") == False\n assert candidate(name = \"algorithm\",typed = \"aaalgggggorithm\") == True\n assert candidate(name = \"programming\",typed = \"pprooggrammmiinngg\") == True\n assert candidate(name = \"mississippi\",typed = \"mmiiississipppi\") == True\n assert candidate(name = \"friend\",typed = \"ffriiieeeennnd\") == True\n assert candidate(name = \"longpressed\",typed = \"lllooonngggppprrreeesssppeeeedd\") == False\n assert candidate(name = \"longpressed\",typed = \"lllongggppppreeesssssssedd\") == True\n assert candidate(name = \"polygon\",typed = \"pppollooogooonnnggg\") == False\n assert candidate(name = \"unique\",typed = \"uuunnnnuuuuuuuuqeeeuuuuuuuuuueee\") == False\n assert candidate(name = \"consistent\",typed = \"ccoonnsissssttttiinnnsss\") == False\n assert candidate(name = \"mississippi\",typed = \"mmiississippip\") == False\n assert candidate(name = \"xxyyzz\",typed = \"xxyyzzzxxxyyyzzz\") == False\n assert candidate(name = \"alexandria\",typed = \"aaalllexxaandria\") == True\n assert candidate(name = \"qwert\",typed = \"qqqqwweeeerrrttt\") == True\n assert candidate(name = \"vtkgn\",typed = \"vtttkkkgggnnn\") == True\n assert candidate(name = \"rhinoceros\",typed = \"rrrhhiinnoocceerrrsss\") == False\n assert candidate(name = \"longpressed\",typed = \"lllooonngggpppreesssed\") == True\n assert candidate(name = \"qwerty\",typed = \"qqqwwweeeerrrrttyyyy\") == True\n assert candidate(name = \"xylophone\",typed = \"xxyyylloophooneee\") == True\n assert candidate(name = \"rhythm\",typed = \"rhythm\") == True\n assert candidate(name = \"aabbcc\",typed = \"aaabbcccc\") == True\n assert candidate(name = \"mississippi\",typed = \"miiisiiisssiiipppii\") == False\n assert candidate(name = \"queue\",typed = \"qqquuuuuuuuueee\") == False\n assert candidate(name = \"abcdefghij\",typed = \"aabbbbccccddddeeeeffffgggghhhhiiiijjjj\") == True\n assert candidate(name = \"ababab\",typed = \"aabbababb\") == True\n assert candidate(name = \"qlssqwwfw\",typed = \"qqllssqqwwwwwfwf\") == False\n assert candidate(name = \"aabbcc\",typed = \"aabbbcccc\") == True\n assert candidate(name = \"flower\",typed = \"ffffllllooower\") == True\n assert candidate(name = \"programming\",typed = \"ppprroogrraammmmiinngggg\") == True\n assert candidate(name = \"mississippi\",typed = \"mmyisssssippis\") == False\n assert candidate(name = \"longpress\",typed = \"lloongggppppreeessss\") == True\n assert candidate(name = \"aaaabbbbcccc\",typed = \"aaaabbbbbbcccc\") == True\n assert candidate(name = \"xy\",typed = \"xyxyxyxyxyxyxyxy\") == False\n assert candidate(name = \"unique\",typed = \"uunniiquee\") == True\n assert candidate(name = \"longpressed\",typed = \"lllllooonnggggppprrreeesss\") == False\n assert candidate(name = \"abcdefgh\",typed = \"aabbbcccdddddeeeeeffffffgggghhhh\") == True\n assert candidate(name = \"algorithm\",typed = \"aalllgggggoooooorrrriiitthhhhhmmmmm\") == True\n assert candidate(name = \"kikcxmvzi\",typed = \"kiikcxxmmvvvzzzii\") == True\n assert candidate(name = \"abcde\",typed = \"abcdeabcde\") == False\n assert candidate(name = \"keyboard\",typed = \"kkkkeeyyyboooaarrdd\") == True\n assert candidate(name = \"a\",typed = \"aaaaaaaaaaa\") == True\n assert candidate(name = \"qwerty\",typed = \"qqqqwwwwertyyyyy\") == True\n assert candidate(name = \"leetcode\",typed = \"lleettcoodde\") == True\n assert candidate(name = \"laiden\",typed = \"laidenlaiden\") == False\n assert candidate(name = \"aabbcc\",typed = \"aabbbccc\") == True\n assert candidate(name = \"characters\",typed = \"ccccchaarrrrrttaaaaccchhhhheeeersss\") == False\n assert candidate(name = \"xylophone\",typed = \"xyyylloophooneee\") == True\n assert candidate(name = \"keyboard\",typed = \"kkkkeeyyyboaaaarrrddddd\") == True\n assert candidate(name = \"elephant\",typed = \"eleelphhhaannnttt\") == False\n assert candidate(name = \"longnamehere\",typed = \"lllooonnggnnaaammmeehheerrree\") == True\n assert candidate(name = \"zebra\",typed = \"zzzeebrraaa\") == True\n assert candidate(name = \"function\",typed = \"fffuunncctttiooonnnn\") == True\n assert candidate(name = \"abcdefg\",typed = \"abcdeeeefg\") == True\n assert candidate(name = \"qwertyuiop\",typed = \"qqqwwweerrttyyuuiioopp\") == True\n assert candidate(name = \"hello\",typed = \"heeeelllllooo\") == True\n assert candidate(name = \"robert\",typed = \"rroobbeerrtt\") == True\n assert candidate(name = \"repeated\",typed = \"rrreeeepppeeeaaatteeeedd\") == True\n assert candidate(name = \"rhell\",typed = \"rhellllllll\") == True\n assert candidate(name = \"mississippi\",typed = \"mmiisssssippppi\") == False\n assert candidate(name = \"supercalifragilisticexpialidocious\",typed = \"ssuupercccaliiifffragggiilissticceexpiialiiddoouuusss\") == False\n assert candidate(name = \"triangle\",typed = \"tttriiaanngggllee\") == True\n assert candidate(name = \"variable\",typed = \"vvvvvaaarriiiaabbbblllee\") == True\n assert candidate(name = \"aabbc\",typed = \"aabbbcc\") == True\n assert candidate(name = \"abcd\",typed = \"aabbbccccdddd\") == True\n assert candidate(name = \"hello\",typed = \"heeeelllllllllo\") == True\n assert candidate(name = \"typing\",typed = \"ttypiinggggg\") == True\n assert candidate(name = \"longpressed\",typed = \"lllllonggggppppreeeesssssssppppeeeedd\") == False\n assert candidate(name = \"unique\",typed = \"uunniiqueee\") == True\n assert candidate(name = \"aaab\",typed = \"aaaaaabbbb\") == True\n assert candidate(name = \"elephant\",typed = \"eeelleeeephhhhaaaalllllltttt\") == False\n assert candidate(name = \"ggg\",typed = \"ggggggggggg\") == True\n assert candidate(name = \"abcd\",typed = \"aabbccddeeffgg\") == False\n assert candidate(name = \"testing\",typed = \"testtinngg\") == True\n assert candidate(name = \"abcdef\",typed = \"aabbccddeeffgg\") == False\n assert candidate(name = \"sequence\",typed = \"sseeqqqquuuuuuennnnccccceee\") == True\n assert candidate(name = \"carlosgomez\",typed = \"cccarllloossgggoommezz\") == True\n assert candidate(name = \"elephant\",typed = \"eeellllepphaaannntt\") == True\n assert candidate(name = \"aaaaaa\",typed = \"aaaaaaaaaaaa\") == True\n assert candidate(name = \"programming\",typed = \"ppprroogggrraammmiinnnggg\") == True\n assert candidate(name = \"aaabbbccc\",typed = \"aabbbccc\") == False\n assert candidate(name = \"algorithm\",typed = \"aalllggggorrrrithhhoonnmmm\") == False\n assert candidate(name = \"abcdabcd\",typed = \"aabbccddeeffgg\") == False\n assert candidate(name = \"programming\",typed = \"pprrrooggggrrraaaaammmmmmiiiiinnnggggggggg\") == True\n assert candidate(name = \"sequence\",typed = \"sseeeequuuuueeeennnnncceeeeee\") == True\n assert candidate(name = \"farruh\",typed = \"faaarrrruuhhhh\") == True\n assert candidate(name = \"abcdefghijk\",typed = \"aabbcdddeeeffggghhhiiiijjjkkk\") == True\n assert candidate(name = \"xylophone\",typed = \"xyyyylloophooneee\") == True\n assert candidate(name = \"xylophone\",typed = \"xxxyyylloooophooooneee\") == True\n assert candidate(name = \"abcdefg\",typed = \"abcdddddeeeffffffggg\") == True\n assert candidate(name = \"carlos\",typed = \"cccaaarlllooss\") == True\n assert candidate(name = \"mississippi\",typed = \"miisissiipppi\") == False\n assert candidate(name = \"challenge\",typed = \"chhaalllaannggeee\") == False\n assert candidate(name = \"abcd\",typed = \"aabbccdd\") == True\n assert candidate(name = \"consistent\",typed = \"ccconinnsisttteeennnsssstt\") == False\n assert candidate(name = \"consistent\",typed = \"cccooonnsiisstteeeennnttt\") == True\n assert candidate(name = \"abababa\",typed = \"aabbaabbaabbaaba\") == False\n assert candidate(name = \"mississippi\",typed = \"mmiissssssiiipppp\") == False\n assert candidate(name = \"example\",typed = \"eexxaammmppllee\") == True\n assert candidate(name = \"testcase\",typed = \"tteeeessttccaaase\") == True\n assert candidate(name = \"aaa\",typed = \"aaaaa\") == True\n assert candidate(name = \"friend\",typed = \"frrriieeedd\") == False\n assert candidate(name = \"algorithm\",typed = \"aalllgggggoooooorrriiithhhhhmmmmm\") == True\n assert candidate(name = \"xyz\",typed = \"xxxyyyzzz\") == True\n assert candidate(name = \"xyz\",typed = \"xxyyyzzz\") == True\n assert candidate(name = \"longpressed\",typed = \"lllllooonngggpppprrreeeesssssseeeedd\") == True\n assert candidate(name = \"complexity\",typed = \"cccomppplleexxiittiityyy\") == False\n assert candidate(name = \"zebra\",typed = \"zzzeeebrrraa\") == True\n", "comparison": "exact"}, "public_tests": ["\"alex\"\n\"aaleex\"", "\"saeed\"\n\"ssaaedd\""], "hints": [], "metadata": {"canonical_parameter_names": ["name", "typed"], "leetcode_dataset_entry_point": "Solution().isLongPressedName", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:22+00:00", "tests_total": 140, "tests_dropped": 1, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def isLongPressedName(self, name: str, typed: str) -> bool:", "container": "Solution", "callable": "isLongPressedName", "parameters": [{"name": "name", "type": "str"}, {"name": "typed", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 926, "task_id": "flip-string-to-monotone-increasing", "difficulty": "Medium", "problem_description": "A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none).\n\nYou are given a binary string s. You can flip s[i] changing it from 0 to 1 or from 1 to 0.\n\nReturn the minimum number of flips to make s monotone increasing.\n\nExample 1:\n\nInput: s = \"00110\"\nOutput: 1\nExplanation: We flip the last digit to get 00111.\n\nExample 2:\n\nInput: s = \"010110\"\nOutput: 2\nExplanation: We flip to get 011111, or alternatively 000111.\n\nExample 3:\n\nInput: s = \"00011000\"\nOutput: 2\nExplanation: We flip to get 00000000.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1100110\") == 3\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"101010101\") == 4\n assert candidate(s = \"111000111000\") == 6\n assert candidate(s = \"000100110\") == 2\n assert candidate(s = \"00011000\") == 2\n assert candidate(s = \"0000000001\") == 0\n assert candidate(s = \"1100001111\") == 2\n assert candidate(s = \"0011110000\") == 4\n assert candidate(s = \"00110011001100\") == 6\n assert candidate(s = \"1000000000\") == 1\n assert candidate(s = \"11111\") == 0\n assert candidate(s = \"0011001100\") == 4\n assert candidate(s = \"11001100110011\") == 6\n assert candidate(s = \"010110\") == 2\n assert candidate(s = \"00110\") == 1\n assert candidate(s = \"1010101010\") == 5\n assert candidate(s = \"1100110011\") == 4\n assert candidate(s = \"0101010101\") == 4\n assert candidate(s = \"0100110011\") == 3\n assert candidate(s = \"0111111111\") == 0\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"1111111111111100000000000000\") == 14\n assert candidate(s = \"11111111100000000001111111111111110000000\") == 16\n assert candidate(s = \"101010101010101010\") == 9\n assert candidate(s = \"000111000111000111000\") == 9\n assert candidate(s = \"00110100101100110011000011110011\") == 12\n assert candidate(s = \"0000011111000000111111000000111111000000\") == 17\n assert candidate(s = \"10101010100101010101010101\") == 12\n assert candidate(s = \"100110011001100110\") == 8\n assert candidate(s = \"1101010101010101010101010101010101010101\") == 19\n assert candidate(s = \"0000000000000011111111111111\") == 0\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 25\n assert candidate(s = \"000000000000000000000000000000\") == 0\n assert candidate(s = \"0110110110110110110110110110\") == 9\n assert candidate(s = \"0001000100010001\") == 3\n assert candidate(s = \"000111000111000111000111000111000111000111000111\") == 21\n assert candidate(s = \"00000000111111110000000011111111\") == 8\n assert candidate(s = \"10101010101010101010101010\") == 13\n assert candidate(s = \"001100110011001100110011\") == 10\n assert candidate(s = \"00001111000011110000\") == 8\n assert candidate(s = \"100000000000001\") == 1\n assert candidate(s = \"0011010010011001001100100110\") == 11\n assert candidate(s = \"0000000000011111111111111111\") == 0\n assert candidate(s = \"101010101010101010101010\") == 12\n assert candidate(s = \"110100111001101\") == 6\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100\") == 26\n assert candidate(s = \"00000000000000\") == 0\n assert candidate(s = \"101010001010100010101000101\") == 10\n assert candidate(s = \"011111111111111111110\") == 1\n assert candidate(s = \"11001100110011001100110011001100\") == 16\n assert candidate(s = \"101010101010101010101010101010\") == 15\n assert candidate(s = \"1010101010101010\") == 8\n assert candidate(s = \"111100001111000011110000111100001111\") == 16\n assert candidate(s = \"10000011111111000001111\") == 6\n assert candidate(s = \"000011110000111100001111000011110000\") == 16\n assert candidate(s = \"00011010011101110011\") == 6\n assert candidate(s = \"0000111100001111000011110000\") == 12\n assert candidate(s = \"00110011001100110011001100110011\") == 14\n assert candidate(s = \"11110000111100001111\") == 8\n assert candidate(s = \"01010101010101010101010101\") == 12\n assert candidate(s = \"00001111110000111111000011\") == 8\n assert candidate(s = \"10101000001111110010\") == 6\n assert candidate(s = \"11111111111111111111111\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\") == 24\n assert candidate(s = \"11111111111111111111\") == 0\n assert candidate(s = \"01100110011001100110011001100110011001100110011001\") == 24\n assert candidate(s = \"11111100000000000000111111111111000000\") == 12\n assert candidate(s = \"1001001101100110011001100110\") == 12\n assert candidate(s = \"00000000001111111111111111110000000\") == 7\n assert candidate(s = \"01011001010110011011\") == 8\n assert candidate(s = \"00000000001111111111\") == 0\n assert candidate(s = \"100000000000000000001\") == 1\n assert candidate(s = \"1111111111100000000000000000\") == 11\n assert candidate(s = \"010101010101010101010101010101\") == 14\n assert candidate(s = \"01000000000000000000010\") == 2\n assert candidate(s = \"01010101010101010101010100\") == 12\n assert candidate(s = \"111000111000111000111\") == 9\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11111111110000000000\") == 10\n assert candidate(s = \"01010101010101010101010101010101\") == 15\n assert candidate(s = \"11100000111100001111100000111111000000\") == 18\n assert candidate(s = \"11111111111111110000000000000000000000000000000000\") == 16\n assert candidate(s = \"1010101010101010101010101010\") == 14\n assert candidate(s = \"111000111000111000111000111\") == 12\n assert candidate(s = \"01011001010110011011010101011010\") == 14\n assert candidate(s = \"1111000000111100000011110000001111000000\") == 16\n assert candidate(s = \"00000000011111111110000000001111111111111000000000\") == 18\n assert candidate(s = \"10011001100110011001100110\") == 12\n assert candidate(s = \"0000000001111111111000000000\") == 9\n assert candidate(s = \"1111000011110000111100001111000011110000\") == 20\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001\") == 20\n assert candidate(s = \"11101010101010101010\") == 9\n assert candidate(s = \"1100010100111001\") == 6\n assert candidate(s = \"1100110011001100110011001100\") == 14\n assert candidate(s = \"11110000111100001111000011110000\") == 16\n assert candidate(s = \"01001001001001001001001001001001001001001\") == 13\n assert candidate(s = \"111111000000\") == 6\n assert candidate(s = \"11010101010101\") == 6\n assert candidate(s = \"1100101010110010\") == 8\n assert candidate(s = \"1110001110001110001110001110\") == 13\n assert candidate(s = \"0000011111111110\") == 1\n assert candidate(s = \"111100000001111111100000\") == 9\n assert candidate(s = \"0101010101010101010101010101\") == 13\n assert candidate(s = \"00000000000000000000000\") == 0\n assert candidate(s = \"000111000111000111000111000111\") == 12\n assert candidate(s = \"01010101010101010101010100101010101010101010101010\") == 24\n assert candidate(s = \"111110000011110000111111100000\") == 14\n assert candidate(s = \"00000000000000001111111111\") == 0\n assert candidate(s = \"00000011111111111111000000000000111111\") == 12\n assert candidate(s = \"00001111000011110000111100001111\") == 12\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"111111111111111111111111111111\") == 0\n assert candidate(s = \"10101010101010101010101010101010\") == 16\n assert candidate(s = \"10101010100101010101010101010101010101010101010101\") == 24\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 27\n assert candidate(s = \"000111000111000111000111000\") == 12\n assert candidate(s = \"00000000000000001111111111111111111111111111111111\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 24\n assert candidate(s = \"0101010100100100111100001111000011111111\") == 14\n assert candidate(s = \"01010101010101\") == 6\n assert candidate(s = \"01100110011001100110011001\") == 12\n assert candidate(s = \"00110100101100110011\") == 8\n assert candidate(s = \"100011110001111000111100011110001111\") == 13\n assert candidate(s = \"101010101000000000001111111111111010101010\") == 10\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 20\n assert candidate(s = \"1111000011110000111100001111\") == 12\n assert candidate(s = \"00011100011100011100\") == 8\n assert candidate(s = \"011111111111110\") == 1\n assert candidate(s = \"0001110001110001110000011111\") == 9\n assert candidate(s = \"0000111100001111000011110000111100001111\") == 16\n assert candidate(s = \"10101000001111110010101010100000\") == 14\n assert candidate(s = \"0011001100110011001100110011\") == 12\n assert candidate(s = \"01010101010101010101\") == 9\n assert candidate(s = \"11001011100101100110101011100101\") == 14\n assert candidate(s = \"1001001001001001001001001001\") == 9\n assert candidate(s = \"000110011001100110011001100110011001100110\") == 19\n assert candidate(s = \"11111111111111\") == 0\n assert candidate(s = \"10101010101010101010\") == 10\n assert candidate(s = \"10011001100110011001100110011001100110011001100110\") == 24\n assert candidate(s = \"000000111111000000111111000000\") == 12\n assert candidate(s = \"00001111110000111111000011111100001111110000111111\") == 16\n assert candidate(s = \"11111111111111110000000000\") == 10\n", "comparison": "exact"}, "public_tests": ["\"00110\"", "\"010110\"", "\"00011000\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minFlipsMonoIncr", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:24+00:00", "tests_total": 143, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minFlipsMonoIncr(self, s: str) -> int:", "container": "Solution", "callable": "minFlipsMonoIncr", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 927, "task_id": "three-equal-parts", "difficulty": "Hard", "problem_description": "You are given an array arr which consists of only zeros and ones, divide the array into three non-empty parts such that all of these parts represent the same binary value.\n\nIf it is possible, return any [i, j] with i + 1 < j, such that:\n\n- arr[0], arr[1], ..., arr[i] is the first part,\n- arr[i + 1], arr[i + 2], ..., arr[j - 1] is the second part, and\n- arr[j], arr[j + 1], ..., arr[arr.length - 1] is the third part.\n- All three parts have equal binary values.\n\nIf it is not possible, return [-1, -1].\n\nNote that the entire part is used when considering what binary value it represents. For example, [1,1,0] represents 6 in decimal, not 3. Also, leading zeros are allowed, so [0,1,1] and [1,1] represent the same value.\n\nExample 1:\n\nInput: arr = [1,0,1,0,1]\nOutput: [0,3]\n\nExample 2:\n\nInput: arr = [1,1,0,1,1]\nOutput: [-1,-1]\n\nExample 3:\n\nInput: arr = [1,1,0,0,1]\nOutput: [0,2]\n\nConstraints:\n\n- 3 <= arr.length <= 3 * 10^4\n- arr[i] is 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 0, 1, 0, 1]) == [0, 3]\n assert candidate(arr = [0, 0, 0]) == [0, 2]\n assert candidate(arr = [1, 1, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 0, 0, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 1, 0, 0]) == [2, 6]\n assert candidate(arr = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1]) == [2, 8]\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == [0, 5]\n assert candidate(arr = [1, 0, 1, 1, 0, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 0, 0, 1]) == [0, 2]\n assert candidate(arr = [1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [11, 16]\n assert candidate(arr = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [4, 13]\n assert candidate(arr = [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == [6, 11]\n assert candidate(arr = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == [2, 13]\n assert candidate(arr = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [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]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1]) == [2, 12]\n assert candidate(arr = [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]) == [0, 13]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == [4, 8]\n assert candidate(arr = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) == [5, 11]\n assert candidate(arr = [1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 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]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 1, 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]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [3, 8]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [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, -1]\n assert candidate(arr = [1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == [7, 14]\n assert candidate(arr = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [3, 10]\n assert candidate(arr = [0, 1, 0, 1, 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]\n assert candidate(arr = [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]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == [-1, -1]\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]\n assert candidate(arr = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 19]\n assert candidate(arr = [1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == [2, 9]\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [3, 8]\n assert candidate(arr = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [5, 14]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [2, 7]\n assert candidate(arr = [1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 0, 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, 1, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0]) == [6, 12]\n assert candidate(arr = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]) == [0, 13]\n assert candidate(arr = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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]\n assert candidate(arr = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [6, 15]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 12]\n assert candidate(arr = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]) == [3, 9]\n assert candidate(arr = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]) == [7, 14]\n assert candidate(arr = [1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0]) == [7, 16]\n assert candidate(arr = [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0]) == [-1, -1]\n assert candidate(arr = [0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1]) == [4, 10]\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1]) == [-1, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == [-1, -1]\n assert candidate(arr = [1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) == [-1, -1]\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [5, 12]\n", "comparison": "exact"}, "public_tests": ["[1,0,1,0,1]", "[1,1,0,1,1]", "[1,1,0,0,1]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().threeEqualParts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:26+00:00", "tests_total": 99, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def threeEqualParts(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "threeEqualParts", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 928, "task_id": "minimize-malware-spread-ii", "difficulty": "Hard", "problem_description": "You are given a network of n nodes represented as an n x n adjacency matrix graph, where the i^th node is directly connected to the j^th node if graph[i][j] == 1.\n\nSome nodes initial are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.\n\nSuppose M(initial) is the final number of nodes infected with malware in the entire network after the spread of malware stops.\n\nWe will remove exactly one node from initial, completely removing it and any connections from this node to any other node.\n\nReturn the node that, if removed, would minimize M(initial). If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.\n\nExample 1:\n\nInput: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]\nOutput: 0\n\nExample 2:\n\nInput: graph = [[1,1,0],[1,1,1],[0,1,1]], initial = [0,1]\nOutput: 1\n\nExample 3:\n\nInput: graph = [[1,1,0,0],[1,1,1,0],[0,1,1,1],[0,0,1,1]], initial = [0,1]\nOutput: 1\n\nConstraints:\n\n- n == graph.length\n- n == graph[i].length\n- 2 <= n <= 300\n- graph[i][j] is 0 or 1.\n- graph[i][j] == graph[j][i]\n- graph[i][i] == 1\n- 1 <= initial.length < n\n- 0 <= initial[i] <= n - 1\n- All the integers in initial are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(graph = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1]],initial = [3, 4]) == 3\n assert candidate(graph = [[1, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 1, 1]],initial = [0, 1]) == 1\n assert candidate(graph = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],initial = [2, 3]) == 2\n assert candidate(graph = [[1, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 1, 0, 1]],initial = [3, 4]) == 3\n assert candidate(graph = [[1, 1, 0], [1, 1, 0], [0, 0, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],initial = [0, 1, 3]) == 3\n assert candidate(graph = [[1, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1]],initial = [3, 4]) == 3\n assert candidate(graph = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],initial = [1, 2]) == 1\n assert candidate(graph = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],initial = [0, 1]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6, 8]) == 2\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 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]],initial = [1, 4, 6, 8, 9]) == 1\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 1, 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, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1]],initial = [3, 5, 7]) == 3\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6, 8]) == 8\n assert candidate(graph = [[1, 1, 0, 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, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 7, 9]) == 0\n assert candidate(graph = [[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], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 9, 10]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 2, 4, 5, 7]) == 1\n assert candidate(graph = [[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, 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, 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, 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]],initial = [0, 4, 7, 10, 11]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5, 7]) == 7\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [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, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 4, 6, 7]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1]],initial = [0, 2, 3]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 6]) == 0\n assert candidate(graph = [[1, 1, 1, 1, 0, 0, 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, 1, 1, 0, 0, 0, 0, 0], [0, 1, 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, 0, 1], [0, 0, 0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 0, 1, 1]],initial = [0, 2, 5, 7]) == 0\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [1, 2, 5]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 8]) == 0\n assert candidate(graph = [[1, 0, 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, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 7, 9]) == 9\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5, 7]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 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, 1, 1]],initial = [0, 1, 4, 6]) == 6\n assert candidate(graph = [[1, 1, 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, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 6, 8, 9]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 7]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 1, 1], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0, 1]],initial = [1, 3, 4]) == 4\n assert candidate(graph = [[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, 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, 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, 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]],initial = [1, 3, 5, 7, 9, 11]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1]],initial = [1, 3, 5]) == 1\n assert candidate(graph = [[1, 1, 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, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 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], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1]],initial = [0, 2, 5, 7, 9]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 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, 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, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 5, 8, 10, 11]) == 2\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5]) == 5\n assert candidate(graph = [[1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]],initial = [0, 2, 5]) == 5\n assert candidate(graph = [[1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 3, 4]) == 4\n assert candidate(graph = [[1, 1, 0, 0, 1, 0], [1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1]],initial = [1, 4]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [2, 4, 5]) == 2\n assert candidate(graph = [[1, 1, 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, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 3, 5, 8]) == 2\n assert candidate(graph = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1]],initial = [0, 3, 5]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 5, 7]) == 2\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 3, 5, 7, 9]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 6]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 1, 0, 0, 0], [1, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5, 6]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 3, 5, 8, 10]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6, 8, 10]) == 0\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0, 1, 1], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1]],initial = [2, 4, 6]) == 2\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [1, 4, 5]) == 1\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 1, 5]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 3, 5, 7, 8]) == 2\n assert candidate(graph = [[1, 1, 0, 0, 1, 0], [1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 3, 5]) == 0\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [0, 0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 1]],initial = [1, 3, 4, 5]) == 3\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 7, 8, 10]) == 0\n assert candidate(graph = [[1, 1, 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, 1, 1, 1], [0, 0, 0, 0, 1, 1]],initial = [0, 2, 5]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 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, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]],initial = [1, 3, 4, 6, 8, 10]) == 1\n assert candidate(graph = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]],initial = [2, 3, 4]) == 2\n assert candidate(graph = [[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, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]],initial = [0, 2, 5, 7, 9, 10]) == 0\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 0, 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, 0, 1]],initial = [1, 2, 5]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 0, 1, 1]],initial = [0, 5]) == 5\n assert candidate(graph = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1]],initial = [1, 4, 6]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1]],initial = [1, 3, 5, 8]) == 1\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [0, 4, 8]) == 4\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 4, 7, 9]) == 1\n assert candidate(graph = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [2, 5, 7]) == 7\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1]],initial = [1, 4, 7]) == 1\n assert candidate(graph = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [0, 2, 4, 6]) == 0\n assert candidate(graph = [[1, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1]],initial = [1, 3, 5]) == 5\n assert candidate(graph = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1]],initial = [2, 3, 6]) == 2\n", "comparison": "exact"}, "public_tests": ["[[1,1,0],[1,1,0],[0,0,1]]\n[0,1]", "[[1,1,0],[1,1,1],[0,1,1]]\n[0,1]", "[[1,1,0,0],[1,1,1,0],[0,1,1,1],[0,0,1,1]]\n[0,1]"], "hints": [], "metadata": {"canonical_parameter_names": ["graph", "initial"], "leetcode_dataset_entry_point": "Solution().minMalwareSpread", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:29+00:00", "tests_total": 74, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def minMalwareSpread(self, graph: list[list[int]], initial: list[int]) -> int:", "container": "Solution", "callable": "minMalwareSpread", "parameters": [{"name": "graph", "type": "list[list[int]]"}, {"name": "initial", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 929, "task_id": "unique-email-addresses", "difficulty": "Easy", "problem_description": "Every valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more '.' or '+'.\n\n- For example, in \"alice@leetcode.com\", \"alice\" is the local name, and \"leetcode.com\" is the domain name.\n\nIf you add periods '.' between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names.\n\n- For example, \"alice.z@leetcode.com\" and \"alicez@leetcode.com\" forward to the same email address.\n\nIf you add a plus '+' in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered. Note that this rule does not apply to domain names.\n\n- For example, \"m.y+name@email.com\" will be forwarded to \"my@email.com\".\n\nIt is possible to use both of these rules at the same time.\n\nGiven an array of strings emails where we send one email to each emails[i], return the number of different addresses that actually receive mails.\n\nExample 1:\n\nInput: emails = [\"test.email+alex@leetcode.com\",\"test.e.mail+bob.cathy@leetcode.com\",\"testemail+david@lee.tcode.com\"]\nOutput: 2\nExplanation: \"testemail@leetcode.com\" and \"testemail@lee.tcode.com\" actually receive mails.\n\nExample 2:\n\nInput: emails = [\"a@leetcode.com\",\"b@leetcode.com\",\"c@leetcode.com\"]\nOutput: 3\n\nConstraints:\n\n- 1 <= emails.length <= 100\n- 1 <= emails[i].length <= 100\n- emails[i] consist of lowercase English letters, '+', '.' and '@'.\n- Each emails[i] contains exactly one '@' character.\n- All local and domain names are non-empty.\n- Local names do not start with a '+' character.\n- Domain names end with the \".com\" suffix.\n- Domain names must contain at least one character before \".com\" suffix.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(emails = ['user.name+foo@hostname.com', 'user.name+bar@hostname.com', 'user.name@hostname.com']) == 1\n assert candidate(emails = ['m.y+name@email.com', 'my.name@email.com', 'myname@email.com']) == 2\n assert candidate(emails = ['m.y+name@email.com', 'my@email.com', 'm+y.name@email.com']) == 2\n assert candidate(emails = ['me+alex@leetcode.com', 'me@leetcode.com']) == 1\n assert candidate(emails = ['m.y+name@email.com', 'my@email.com']) == 1\n assert candidate(emails = ['alice.z@leetcode.com', 'alicez@leetcode.com']) == 1\n assert candidate(emails = ['foo@bar.com', 'foo@bar.com', 'foo@bar.com']) == 1\n assert candidate(emails = ['test.email+alex@leetcode.com', 'test.e.mail+bob.cathy@leetcode.com', 'testemail+david@lee.tcode.com']) == 2\n assert candidate(emails = ['a+b@leetcode.com', 'a@leetcode.com+b', 'a+b+c+d@leetcode.com']) == 2\n assert candidate(emails = ['my.email+alex@leetcode.com', 'my.e.mail+alex@leetcode.com', 'myemail+alex@leetcode.com']) == 1\n assert candidate(emails = ['foo@bar.com', 'foo.bar@bar.com', 'foo.bar.baz@bar.com']) == 3\n assert candidate(emails = ['john.doe@example.com', 'john.doe+foo@example.com', 'johndoe@example.com']) == 1\n assert candidate(emails = ['alice+bob.cathy@leetcode.com', 'alice.bob.cathy@leetcode.com', 'alicebobcathy@leetcode.com']) == 2\n assert candidate(emails = ['alice.z@leetcode.com', 'alicez@leetcode.com', 'al.icez@leetcode.com']) == 1\n assert candidate(emails = ['foo@bar.com', 'foo@bar.com']) == 1\n assert candidate(emails = ['alex@leetcode.com', 'alex+alex@leetcode.com', 'alex.alex@leetcode.com']) == 2\n assert candidate(emails = ['a@leetcode.com', 'b@leetcode.com', 'c@leetcode.com']) == 3\n assert candidate(emails = ['user.name+tag+more@domain.co.uk', 'user.name+tag@domain.co.uk', 'user+tag@domain.co.uk', 'user@domain.co.uk']) == 2\n assert candidate(emails = ['email+filter@domain.com', 'email@domain.com', 'email+filter+ignore@domain.com', 'email.filter@domain.com']) == 2\n assert candidate(emails = ['user.name+tag@domain.com', 'user.name.tag@domain.com', 'user.name@domain.com', 'user.name@sub.domain.com', 'user.name+tag@sub.domain.com', 'user.name.tag@sub.domain.com']) == 4\n assert candidate(emails = ['john.doe+newsletter@domain.com', 'johndoe+offers@domain.com', 'johndoe@sub.domain.com', 'john.doe@domain.co.uk']) == 3\n assert candidate(emails = ['user.name+tag@domain.co', 'user.name@domain.co', 'user.name+tag+another.tag@domain.co']) == 1\n assert candidate(emails = ['john.doe+extra.info@company.org', 'john.doe@company.org', 'john.doe+extra+info@company.org', 'john.doe+extra+info+more@company.org']) == 1\n assert candidate(emails = ['alice..bob.cathy@leetcode.com', 'alice+bob.cathy@leetcode.com', 'alice+bob..cathy@leetcode.com']) == 2\n assert candidate(emails = ['a+b+c+d@domain.com', 'a.b.c.d@domain.com', 'abcd@domain.com', 'a..b.c+d.@domain.com']) == 3\n assert candidate(emails = ['user.name+tag+sorting@example.com', 'user.name@example.com', 'user.name+sorting@example.com', 'user+name@example.com', 'user+name+tag@example.com', 'user+name+tag+sorting@example.com']) == 2\n assert candidate(emails = ['john.doe+some.text@domain.com', 'johndoe+some.text@domain.com', 'johndoe@domain.com', 'john.doe@domain.com']) == 1\n assert candidate(emails = ['multiple+dots.here+ignore@sample.com', 'multiple+dots.here@sample.com', 'multiple.dots+here@sample.com', 'multiple.dots.here@sample.com']) == 3\n assert candidate(emails = ['user.name+foo@domain.com', 'user+name@domain.com', 'user.name+foo.bar@domain.com', 'user+name+foo@domain.com', 'user.name+bar.foo@domain.com', 'user+bar.foo@domain.com']) == 2\n assert candidate(emails = ['multiple+parts+in+the+local@name.com', 'multiple.parts.in.the.local@name.com', 'multiple+parts+in.the+local@name.com', 'multiple.parts+in+the.local@name.com', 'multiplepartsinthe.local@name.com']) == 3\n assert candidate(emails = ['my.email+alex@leetcode.com', 'my.e.mail+alex@leetcode.com', 'myemail+alex@leetcode.com', 'my.email+alex@leetcode.co.uk', 'my.e.mail+alex@leetcode.co.uk', 'myemail+alex@leetcode.co.uk']) == 2\n assert candidate(emails = ['a.b.c.d+e@website.com', 'abcd@website.com', 'a.b.c.d@website.com', 'abc.d+efg@website.com', 'a.b.c.d+efg@website.com', 'a.b.c+defg@website.com']) == 2\n assert candidate(emails = ['alice.z@leetcode.com', 'alicez@leetcode.com', 'al.i.c.e+blog@leetcode.com', 'alic.e@leetcode.com']) == 2\n assert candidate(emails = ['user@my+invalid+input.com', 'user.myinvalid+input@com', 'user.my+invalid@input.com', 'user@myinvalidinput+com']) == 4\n assert candidate(emails = ['email.name+suffix@sub.domain.com', 'email+suffix@sub.domain.com', 'email.name@sub.domain.com']) == 2\n assert candidate(emails = ['example.email+alex@leetcode.com', 'e.x.a.m.p.l.e.e.mail+bob.cathy@leetcode.com', 'ex.ampleemail+david@lee.tcode.com', 'ex.ample.email+david@lee.tcode.com']) == 2\n assert candidate(emails = ['alice+bob.cathy@leetcode.com', 'alice.bob.cathy@leetcode.com', 'alice.bob+cathy@leetcode.com', 'alice+bob+cathy@leetcode.com']) == 3\n assert candidate(emails = ['name@domain.com', 'name@sub.domain.com', 'name+suffix@sub.domain.com', 'name.suffix@domain.com']) == 3\n assert candidate(emails = ['my.email+alex@leetcode.com', 'my.e.mail+alex@leetcode.com', 'myemail+alex@leetcode.com', 'my.email+alex@leetcode.co.uk', 'my.e.mail+alex@sub.leetcode.com']) == 3\n assert candidate(emails = ['peter.parker+spiderman@marvel.com', 'peter.parker+spiderman+amazing@marvel.com', 'peter+spiderman@marvel.com', 'spiderman+@marvel.com']) == 3\n assert candidate(emails = ['complex+part.with.dots@complex.com', 'complex.partwithdots@complex.com', 'complexpart+with.dots@complex.com', 'complexpartwithdots@complex.com']) == 3\n assert candidate(emails = ['jane.doe+newsletter@example.com', 'jane.doe@example.com', 'janedoe@example.com', 'jane.doe.+ignore@example.com', 'jane.doe+ignore@example.co.uk', 'jane+doe@example.com']) == 3\n assert candidate(emails = ['long.email.name+with.many.dots.and.tags@longdomain.com', 'long.email+name+with.many.dots.and.tags@longdomain.com', 'longemail+name+with.many.dots.and.tags@longdomain.com', 'longemailname+with.many.dots.and.tags@longdomain.com']) == 2\n assert candidate(emails = ['tom+tommy+tomm@mydomain.com', 'tommy.tom+tom@mydomain.com', 'tom.tommy.tom+tommy@mydomain.com', 'tommy+tom+tommy@mydomain.com', 'tom.tommy@mydomain.com']) == 5\n assert candidate(emails = ['user+ignore@domain.com', 'user+ignore@sub.domain.com', 'user+ignore@subdomain.com', 'user@domain.com', 'user@sub.domain.com', 'user@subdomain.com']) == 3\n assert candidate(emails = ['user.name@sub.domain.com', 'user.name+ignore@sub.domain.com', 'user.name@sub.domain.org', 'user.name+ignore@sub.domain.org']) == 2\n assert candidate(emails = ['user@sub.domain.com', 'user@subdomain.com', 'user.sub@domain.com']) == 3\n assert candidate(emails = ['a.b.c+d.e.f+g.h.i@website.com', 'a.b.c.d.e.f.g.h.i@website.com', 'a+b+c+d+e+f+g+h+i@website.com']) == 3\n assert candidate(emails = ['abc.d.+def@example.com', 'abc.d+def@example.com', 'abc.def@example.com', 'abc.d.@example.com', 'abc.d+@example.com']) == 2\n assert candidate(emails = ['user+ignore.all.this@mydomain.net', 'user@mydomain.net', 'user.name+ignore@mydomain.net', 'user.name@mydomain.net']) == 2\n assert candidate(emails = ['a.b.c.d.e@domain.com', 'a+b+c+d+e@domain.com', 'abcde@domain.com', 'a.b+c.d+e@domain.com', 'a+b.c.d.e@domain.com']) == 3\n assert candidate(emails = ['user@sub.domain.com', 'user@sub.sub.domain.com', 'user.sub@sub.domain.com', 'user@sub.domain.co', 'user@sub.domain.co.uk']) == 5\n assert candidate(emails = ['user.name+foo@sub.domain.com', 'user.name@sub.domain.com', 'user+name@sub.domain.com', 'user@sub.domain.com']) == 2\n assert candidate(emails = ['user.name+foo@domain.com', 'user+name@domain.com', 'user.name+foo.bar@domain.com', 'user+name+foo@domain.com']) == 2\n assert candidate(emails = ['user.name+tag+info@domain.com', 'user.name+tag@domain.com', 'user.name@domain.com', 'user+name@domain.com', 'username@domain.com']) == 2\n assert candidate(emails = ['x+y.z+@example.com', 'x.y.z.@example.com', 'x.y.z@example.com', 'x+y+z@example.com', 'x.y.z+tag@example.com']) == 2\n assert candidate(emails = ['user.name+tag+sorting@example.com', 'user.name@example.com', 'user.name+sorting@example.com', 'user+name@example.com', 'user+name+tag@example.com']) == 2\n assert candidate(emails = ['nested+dot.and.plus@sub.sub.domain.com', 'nested.dot.and.plus@sub.sub.domain.com', 'nested+dot.and+plus@subdomain.com', 'nested.dot.and.plus@subdomain.com']) == 4\n assert candidate(emails = ['alice+bob.cathy+david@leetcode.com', 'alice.david+bob.cathy@leetcode.com', 'alice+david@leetcode.com']) == 2\n assert candidate(emails = ['user.name+tag+more@sub.domain.com', 'user.name+tag@sub.domain.com', 'user+tag@sub.domain.com', 'user@sub.domain.com']) == 2\n assert candidate(emails = ['user@domain.com', 'user+tag@domain.com', 'user+tag+ignore@domain.com', 'user+tag@domain.co.uk', 'user+tag@sub.domain.com']) == 3\n assert candidate(emails = ['nested+dot.dot.dot@domain.org', 'nested.dot+dot.dot@domain.org', 'nested.dot.dot+dot@domain.org', 'nesteddot.dotdot@domain.org', 'nesteddotdotdot@domain.org']) == 4\n assert candidate(emails = ['john.doe+newsletter@tech.com', 'johndoe+news+letter@tech.com', 'john+doe+news@tech.com', 'johndoe@tech.com']) == 2\n assert candidate(emails = ['contact+info@info.contact.org', 'contact.info@info.contact.org', 'contact.info+more@info.contact.org', 'contact+info+more@info.contact.org']) == 2\n assert candidate(emails = ['user.name+ignore.this.part@domain.co.uk', 'user.name@domain.co.uk', 'user+name@domain.co.uk', 'user@domain.co.uk', 'user.name+another.part@domain.co.uk']) == 2\n assert candidate(emails = ['user.name+tag@domain.co.uk', 'user.name@domain.co.uk', 'user+name@domain.co.uk', 'user.name+@domain.co.uk']) == 2\n assert candidate(emails = ['john.doe+newsletter@tech.com', 'johndoe+news+letter@tech.com', 'john+doe+news@tech.com', 'johndoe@tech.com', 'johndoe+ignore@tech.com', 'john.doe+ignore@tech.com']) == 2\n assert candidate(emails = ['email.with+plus.and.dots@website.com', 'emailwith+plusanddots@website.com', 'emailwithplus.anddots@website.com', 'emailwithplusanddots@website.com']) == 2\n assert candidate(emails = ['a.b.c+d@domain.com', 'a.b.c+e+f@domain.com', 'a+b+c+d@domain.com', 'a.b.c.d@domain.com']) == 3\n assert candidate(emails = ['user+name+with+many+pluses@mydomain.com', 'user+name.with+many+pluses@mydomain.com', 'user.name+with+many+pluses@mydomain.com', 'user.name.with+many+pluses@mydomain.com', 'user.name.with.many+pluses@mydomain.com']) == 4\n assert candidate(emails = ['a.b.c+d.e.f@domain.com', 'a.b.c.d.e.f@domain.com', 'a+b.c+d.e.f@domain.com', 'a+b.c.d.e.f@domain.com', 'a.b+c.d.e+f@domain.com']) == 4\n assert candidate(emails = ['test.email+alex@leetcode.com', 'test.e.mail+bob.cathy@leetcode.com', 'testemail+david@lee.tcode.com', 'test.email+david@lee.tcode.com', 'testemail+david+extra@lee.tcode.com']) == 2\n assert candidate(emails = ['a+@domain.com', 'a@domain.com', 'a+very+long+part+here@domain.com', 'a.very.long.part.here@domain.com']) == 2\n assert candidate(emails = ['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@domain.com', '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@domain.com', 'abcdefghijklmnopqrstuvwxyz@domain.com']) == 2\n assert candidate(emails = ['john.doe@example.com', 'john.doe+newsletter@example.com', 'johndoe@example.com', 'john.doe.+ignore@example.com', 'john.doe+ignore@example.co.uk']) == 2\n assert candidate(emails = ['user+filter+ignore@site.com', 'user@site.com', 'user.filter@site.com', 'user+filter@site.com']) == 2\n assert candidate(emails = ['peter.parker+spiderman@marvel.com', 'peter.parker+spiderman+amazing@marvel.com', 'peter+spiderman@marvel.com', 'spiderman+@marvel.com', 'peter.parker@marvel.com', 'peter+spiderman+@marvel.com']) == 3\n assert candidate(emails = ['alice+bob+cathy@domain.com', 'alice+bob.cathy@domain.com', 'alice+bob.cathy@domain.co.uk']) == 2\n assert candidate(emails = ['first.last+middle.name@company.com', 'first.last@company.com', 'first+last@company.com', 'firstlast@company.com', 'first+last+middle@company.com']) == 2\n assert candidate(emails = ['same.name+tag@same.domain.com', 'same.name+another.tag@same.domain.com', 'same.name@same.domain.com', 'same.name+tag@different.domain.com']) == 2\n assert candidate(emails = ['user.name+tag.info@domain.com', 'user.name+taginfo@domain.com', 'user.name+tag+info@domain.co', 'user.name+taginfo@domain.co.uk', 'user.name@domain.com']) == 3\n assert candidate(emails = ['alice.z+ignore@leetcode.com', 'alicez+ignore@leetcode.com', 'alice+ignore@leetcode.com', 'alice.z@leetcode.com', 'alicez@leetcode.com', 'alice@leetcode.com']) == 2\n assert candidate(emails = ['alice.bob.john+foo@mydomain.com', 'alice.bob.john@mydomain.com', 'alice.bob.john+bar@mydomain.com']) == 1\n assert candidate(emails = ['example+ignore.this@domain.net', 'example.ignore.this@domain.net', 'example+ignore+this@domain.net', 'exampleignorethis@domain.net']) == 2\n assert candidate(emails = ['a.b.c.d+e@website.com', 'abcd@website.com', 'a.b.c.d@website.com', 'abc.d+efg@website.com']) == 1\n assert candidate(emails = ['alice.bob+c@site.org', 'alice+offers@site.org', 'alice.bob@site.org', 'alice.b+o+b@site.org']) == 3\n assert candidate(emails = ['complex.email+with+plus@longdomain.com', 'complex.email+with.plus@longdomain.com', 'complex.email@longdomain.com', 'complex+email@longdomain.com']) == 2\n assert candidate(emails = ['user+ignore+ignore@domain.com', 'user.name+ignore+ignore@domain.com', 'user.name+ignore.ignore@domain.com', 'user.name+ignore.ignore+ignore@domain.com']) == 2\n assert candidate(emails = ['user.name+tag+more@domain.com', 'user.name+tag@domain.com', 'user+tag@domain.com', 'user@domain.com']) == 2\n assert candidate(emails = ['x+user.name+y@domain.com', 'user.name+z@domain.com', 'user.name+@domain.com', 'user.name@domain.com']) == 2\n assert candidate(emails = ['user+tag@domain.com', 'user@domain.com', 'user.name@domain.com', 'user+tag.name@domain.com']) == 2\n", "comparison": "exact"}, "public_tests": ["[\"test.email+alex@leetcode.com\",\"test.e.mail+bob.cathy@leetcode.com\",\"testemail+david@lee.tcode.com\"]", "[\"a@leetcode.com\",\"b@leetcode.com\",\"c@leetcode.com\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["emails"], "leetcode_dataset_entry_point": "Solution().numUniqueEmails", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:31+00:00", "tests_total": 104, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def numUniqueEmails(self, emails: list[str]) -> int:", "container": "Solution", "callable": "numUniqueEmails", "parameters": [{"name": "emails", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 930, "task_id": "binary-subarrays-with-sum", "difficulty": "Medium", "problem_description": "Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.\n\nA subarray is a contiguous part of the array.\n\nExample 1:\n\nInput: nums = [1,0,1,0,1], goal = 2\nOutput: 4\nExplanation: The 4 subarrays are bolded and underlined below:\n[1,0,1,0,1]\n[1,0,1,0,1]\n[1,0,1,0,1]\n[1,0,1,0,1]\n\nExample 2:\n\nInput: nums = [0,0,0,0,0], goal = 0\nOutput: 15\n\nConstraints:\n\n- 1 <= nums.length <= 3 * 10^4\n- nums[i] is either 0 or 1.\n- 0 <= goal <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 0, 1, 1, 0],goal = 1) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],goal = 2) == 8\n assert candidate(nums = [0, 0, 0, 0, 0],goal = 0) == 15\n assert candidate(nums = [1, 0, 1, 0, 1],goal = 2) == 4\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0],goal = 4) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],goal = 3) == 3\n assert candidate(nums = [1, 0, 0, 0, 1],goal = 1) == 8\n assert candidate(nums = [0, 1, 0, 1, 0],goal = 1) == 8\n assert candidate(nums = [0, 1, 1, 0, 1, 1],goal = 2) == 7\n assert candidate(nums = [0, 1, 1, 0, 0, 1],goal = 2) == 7\n assert candidate(nums = [0, 1, 0, 1, 0, 1],goal = 2) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 0],goal = 2) == 9\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],goal = 9) == 19\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],goal = 2) == 23\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],goal = 0) == 528\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],goal = 6) == 53\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],goal = 0) == 595\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],goal = 8) == 27\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],goal = 3) == 52\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 15) == 20\n assert candidate(nums = [1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1],goal = 6) == 26\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1],goal = 3) == 21\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],goal = 12) == 6\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],goal = 3) == 60\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],goal = 5) == 22\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],goal = 3) == 22\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],goal = 5) == 34\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],goal = 10) == 12\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],goal = 4) == 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, 1, 0, 1, 0, 1, 0, 1, 0],goal = 8) == 26\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1],goal = 4) == 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, 0, 0, 0, 0, 1],goal = 1) == 62\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],goal = 6) == 20\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1],goal = 3) == 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],goal = 6) == 30\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],goal = 4) == 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],goal = 5) == 45\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],goal = 5) == 12\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0],goal = 5) == 20\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],goal = 25) == 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, 1, 1, 0, 0, 1, 1],goal = 6) == 43\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],goal = 0) == 210\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0],goal = 9) == 28\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],goal = 6) == 50\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],goal = 2) == 56\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],goal = 10) == 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],goal = 15) == 18\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],goal = 7) == 14\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1],goal = 8) == 35\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],goal = 20) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],goal = 30) == 12\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1],goal = 8) == 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, 0],goal = 5) == 24\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],goal = 10) == 2\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],goal = 3) == 89\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],goal = 16) == 8\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],goal = 6) == 24\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, 1],goal = 1) == 66\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],goal = 6) == 27\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 5) == 6\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],goal = 4) == 63\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0],goal = 4) == 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],goal = 5) == 16\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],goal = 20) == 33\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],goal = 3) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 15) == 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],goal = 10) == 11\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 1],goal = 3) == 8\n assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1],goal = 5) == 48\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0],goal = 3) == 88\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],goal = 0) == 1275\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],goal = 25) == 1\n", "comparison": "exact"}, "public_tests": ["[1,0,1,0,1]\n2", "[0,0,0,0,0]\n0"], "hints": ["Can you transform the problem into finding two prefix sums whose difference equals goal?", "While iterating through the array, keep track of how many times each prefix sum has appeared so far.", "If the current prefix sum is curr, how many previous prefix sums equal to curr - goal exist?"], "metadata": {"canonical_parameter_names": ["nums", "goal"], "leetcode_dataset_entry_point": "Solution().numSubarraysWithSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:33+00:00", "tests_total": 72, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numSubarraysWithSum(self, nums: list[int], goal: int) -> int:", "container": "Solution", "callable": "numSubarraysWithSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 931, "task_id": "minimum-falling-path-sum", "difficulty": "Medium", "problem_description": "Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix.\n\nA falling path starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position (row, col) will be (row + 1, col - 1), (row + 1, col), or (row + 1, col + 1).\n\nExample 1:\n\nInput: matrix = [[2,1,3],[6,5,4],[7,8,9]]\nOutput: 13\nExplanation: There are two falling paths with a minimum sum as shown.\n\nExample 2:\n\nInput: matrix = [[-19,57],[-40,-5]]\nOutput: -59\nExplanation: The falling path with a minimum sum is shown.\n\nConstraints:\n\n- n == matrix.length == matrix[i].length\n- 1 <= n <= 100\n- -100 <= matrix[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[100, -100, 100], [-100, 100, -100], [100, -100, 100]]) == -300\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == -18\n assert candidate(matrix = [[-19, 57], [-40, -5]]) == -59\n assert candidate(matrix = [[2, 1, 3], [6, 5, 4], [7, 8, 9]]) == 13\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 12\n assert candidate(matrix = [[10, -10, 10], [-10, 10, -10], [10, -10, 10]]) == -30\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 55\n assert candidate(matrix = [[5, -10, 15, -20], [25, 30, -35, 40], [-45, 50, 55, -60], [-65, 70, -75, 80]]) == -190\n assert candidate(matrix = [[-50, -40, -30, -20, -10], [-10, 0, 10, 20, 30], [30, 20, 10, 0, -10], [-10, -20, -30, -40, -50], [50, 40, 30, 20, 10]]) == -70\n assert candidate(matrix = [[3, 8, 7, 1, 9], [5, 6, 9, 1, 8], [5, 9, 7, 6, 9], [5, 4, 7, 6, 9], [1, 6, 7, 6, 9]]) == 14\n assert candidate(matrix = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2, 0], [0, 3, 6, 9, 12, 15, 18, 21, 24, 27], [27, 24, 21, 18, 15, 12, 9, 6, 3, 0], [0, 4, 8, 12, 16, 20, 24, 28, 32, 36], [36, 32, 28, 24, 20, 16, 12, 8, 4, 0], [0, 5, 10, 15, 20, 25, 30, 35, 40, 45], [45, 40, 35, 30, 25, 20, 15, 10, 5, 0]]) == 120\n assert candidate(matrix = [[-5, -3, -4], [-6, -7, -8], [-9, -2, -3]]) == -21\n assert candidate(matrix = [[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]]) == 15\n assert candidate(matrix = [[-5, -5, -5], [-5, -5, -5], [-5, -5, -5]]) == -15\n assert candidate(matrix = [[10, 15, 20, 25], [30, 35, 40, 45], [50, 55, 60, 65], [70, 75, 80, 85]]) == 160\n assert candidate(matrix = [[3, 8, 1, 9], [1, 6, 7, 8], [1, 5, 8, 9], [1, 9, 1, 8]]) == 6\n assert candidate(matrix = [[1, 3, 1], [1, 5, 1], [4, 2, 1]]) == 3\n assert candidate(matrix = [[3, 5, 1, 2], [8, 1, 3, 7], [2, 9, 4, 6], [4, 6, 8, 3]]) == 8\n assert candidate(matrix = [[1, -1, 1, -1], [-1, 1, -1, 1], [1, -1, 1, -1], [-1, 1, -1, 1]]) == -4\n assert candidate(matrix = [[-10, 100, -20], [0, -50, 30], [10, 20, -40]]) == -110\n assert candidate(matrix = [[-10, -20, 30, 40], [15, 25, -5, 35], [10, 20, 30, -40], [5, -5, 0, 10]]) == -65\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 28\n assert candidate(matrix = [[-10, 10, -10, 10], [-10, 10, -10, 10], [10, -10, 10, -10], [10, -10, 10, -10]]) == -40\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 96\n assert candidate(matrix = [[-10, 5, 10], [-20, 15, -25], [30, -40, 50]]) == -70\n assert candidate(matrix = [[-100, -99, -98], [-97, -96, -95], [-94, -93, -92]]) == -291\n assert candidate(matrix = [[10, -10, 10, -10], [20, -20, 20, -20], [30, -30, 30, -30], [40, -40, 40, -40]]) == -100\n assert candidate(matrix = [[-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]]) == 25\n assert candidate(matrix = [[-10, -20, -30], [-20, -30, -40], [-30, -40, -50]]) == -120\n assert candidate(matrix = [[5, 3, 2, 4, 1], [8, 2, 1, 3, 7], [3, 9, 6, 8, 5], [7, 4, 8, 1, 2], [9, 6, 5, 3, 8]]) == 13\n assert candidate(matrix = [[3, 8, 6, 4], [5, 0, 2, 9], [6, 4, 3, 8], [2, 3, 7, 4]]) == 9\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12], [12, 10, 8, 6, 4, 2]]) == 28\n assert candidate(matrix = [[10, 20, 30], [20, 10, 40], [30, 40, 50]]) == 50\n assert candidate(matrix = [[-1, 2, 3], [4, -5, 6], [7, 8, -9]]) == -15\n assert candidate(matrix = [[-50, -20, 30, 10], [-80, -60, 40, 20], [90, 70, -10, -30], [5, -45, 25, -65]]) == -185\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == -180\n assert candidate(matrix = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 0, -1, -2], [-3, -4, -5, -6]]) == 0\n assert candidate(matrix = [[0, 2, 1, 5], [3, 1, 1, 1], [4, 2, 1, 2], [3, 2, 1, 3]]) == 3\n assert candidate(matrix = [[1, -2, -3, 4, -5], [2, -3, -4, 5, -6], [-1, 0, 1, -1, 0], [5, 3, 4, -2, 1], [-2, -4, 3, 2, -1]]) == -15\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 3, 5, 7, 9]]) == 13\n assert candidate(matrix = [[10, 3, 4], [1, 2, 10], [4, 3, 7]]) == 7\n assert candidate(matrix = [[10, 15, 5, 20], [10, 25, 15, 10], [10, 10, 25, 5], [20, 10, 15, 10]]) == 30\n assert candidate(matrix = [[1, -2, 3, -4], [5, -6, 7, -8], [9, -10, 11, -12], [13, -14, 15, -16]]) == -40\n assert candidate(matrix = [[0, 1, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 0\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 0]]) == 13\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [-1, -11, -21, -31, -41], [-2, -12, -22, -32, -42]]) == -27\n assert candidate(matrix = [[5, 12, -3, -7, 3], [-1, -2, 8, 6, 4], [-10, 1, 7, 2, -1], [8, 9, -5, -3, 6], [4, 3, 0, -2, 1]]) == -11\n assert candidate(matrix = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]]) == -75\n assert candidate(matrix = [[-2, -1, -3], [-6, -5, -4], [-7, -8, -9]]) == -17\n assert candidate(matrix = [[7, 5, 8, 6], [9, 3, 4, 10], [12, 6, 7, 2], [10, 9, 8, 3]]) == 14\n assert candidate(matrix = [[-20, -10, 5, 10], [-30, 0, 0, 30], [-15, -5, 15, 25], [10, 5, -10, -15]]) == -65\n assert candidate(matrix = [[-1, -2, -3, -4], [-4, -3, -2, -1], [-1, 0, 1, 2], [2, 1, 0, -1]]) == -6\n assert candidate(matrix = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 40\n assert candidate(matrix = [[100, 100, 100, 100], [0, 0, 0, 0], [100, 100, 100, 100], [0, 0, 0, 0]]) == 200\n assert candidate(matrix = [[-10, 5, 1], [-5, 2, -3], [8, -1, 10]]) == -16\n assert candidate(matrix = [[5, 10, 15, 20, 25], [10, 15, 20, 25, 30], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45]]) == 75\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]]) == 430\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == -18\n assert candidate(matrix = [[1, -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(matrix = [[-1, 2, -3], [4, -5, 6], [-7, 8, -9]]) == -17\n assert candidate(matrix = [[-1, 2, 9, 4, -5], [7, -3, 0, 1, -9], [3, 5, 1, -4, -6], [-8, -2, -3, -1, -9], [-2, -5, -3, -6, 9]]) == -35\n assert candidate(matrix = [[-10, 5, 3, 12], [-5, -3, 10, -8], [8, -6, -4, 7], [2, 0, 5, -3]]) == -21\n assert candidate(matrix = [[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]]) == 55\n assert candidate(matrix = [[-1, 2, -1, 2, -1], [2, -1, 2, -1, 2], [-1, 2, -1, 2, -1], [2, -1, 2, -1, 2], [-1, 2, -1, 2, -1]]) == -5\n", "comparison": "exact"}, "public_tests": ["[[2,1,3],[6,5,4],[7,8,9]]", "[[-19,57],[-40,-5]]"], "hints": [], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().minFallingPathSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:35+00:00", "tests_total": 79, "tests_dropped": 13, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minFallingPathSum(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "minFallingPathSum", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 932, "task_id": "beautiful-array", "difficulty": "Medium", "problem_description": "An array nums of length n is beautiful if:\n\n- nums is a permutation of the integers in the range [1, n].\n- For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i] + nums[j].\n\nGiven the integer n, return any beautiful array nums of length n. There will be at least one valid answer for the given n.\n\nExample 1:\n\nInput: n = 4\nOutput: [2,1,4,3]\n\nExample 2:\n\nInput: n = 5\nOutput: [3,1,2,5,4]\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 11) == [1, 9, 5, 3, 11, 7, 2, 10, 6, 4, 8]\n assert candidate(n = 15) == [1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8]\n assert candidate(n = 4) == [1, 3, 2, 4]\n assert candidate(n = 64) == [1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 63, 2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 62, 4, 36, 20, 52, 12, 44, 28, 60, 8, 40, 24, 56, 16, 48, 32, 64]\n assert candidate(n = 7) == [1, 5, 3, 7, 2, 6, 4]\n assert candidate(n = 9) == [1, 9, 5, 3, 7, 2, 6, 4, 8]\n assert candidate(n = 32) == [1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 2, 18, 10, 26, 6, 22, 14, 30, 4, 20, 12, 28, 8, 24, 16, 32]\n assert candidate(n = 6) == [1, 5, 3, 2, 6, 4]\n assert candidate(n = 20) == [1, 17, 9, 5, 13, 3, 19, 11, 7, 15, 2, 18, 10, 6, 14, 4, 20, 12, 8, 16]\n assert candidate(n = 2) == [1, 2]\n assert candidate(n = 100) == [1, 65, 33, 97, 17, 81, 49, 9, 73, 41, 25, 89, 57, 5, 69, 37, 21, 85, 53, 13, 77, 45, 29, 93, 61, 3, 67, 35, 99, 19, 83, 51, 11, 75, 43, 27, 91, 59, 7, 71, 39, 23, 87, 55, 15, 79, 47, 31, 95, 63, 2, 66, 34, 98, 18, 82, 50, 10, 74, 42, 26, 90, 58, 6, 70, 38, 22, 86, 54, 14, 78, 46, 30, 94, 62, 4, 68, 36, 100, 20, 84, 52, 12, 76, 44, 28, 92, 60, 8, 72, 40, 24, 88, 56, 16, 80, 48, 32, 96, 64]\n assert candidate(n = 500) == [1, 257, 129, 385, 65, 321, 193, 449, 33, 289, 161, 417, 97, 353, 225, 481, 17, 273, 145, 401, 81, 337, 209, 465, 49, 305, 177, 433, 113, 369, 241, 497, 9, 265, 137, 393, 73, 329, 201, 457, 41, 297, 169, 425, 105, 361, 233, 489, 25, 281, 153, 409, 89, 345, 217, 473, 57, 313, 185, 441, 121, 377, 249, 5, 261, 133, 389, 69, 325, 197, 453, 37, 293, 165, 421, 101, 357, 229, 485, 21, 277, 149, 405, 85, 341, 213, 469, 53, 309, 181, 437, 117, 373, 245, 13, 269, 141, 397, 77, 333, 205, 461, 45, 301, 173, 429, 109, 365, 237, 493, 29, 285, 157, 413, 93, 349, 221, 477, 61, 317, 189, 445, 125, 381, 253, 3, 259, 131, 387, 67, 323, 195, 451, 35, 291, 163, 419, 99, 355, 227, 483, 19, 275, 147, 403, 83, 339, 211, 467, 51, 307, 179, 435, 115, 371, 243, 499, 11, 267, 139, 395, 75, 331, 203, 459, 43, 299, 171, 427, 107, 363, 235, 491, 27, 283, 155, 411, 91, 347, 219, 475, 59, 315, 187, 443, 123, 379, 251, 7, 263, 135, 391, 71, 327, 199, 455, 39, 295, 167, 423, 103, 359, 231, 487, 23, 279, 151, 407, 87, 343, 215, 471, 55, 311, 183, 439, 119, 375, 247, 15, 271, 143, 399, 79, 335, 207, 463, 47, 303, 175, 431, 111, 367, 239, 495, 31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 2, 258, 130, 386, 66, 322, 194, 450, 34, 290, 162, 418, 98, 354, 226, 482, 18, 274, 146, 402, 82, 338, 210, 466, 50, 306, 178, 434, 114, 370, 242, 498, 10, 266, 138, 394, 74, 330, 202, 458, 42, 298, 170, 426, 106, 362, 234, 490, 26, 282, 154, 410, 90, 346, 218, 474, 58, 314, 186, 442, 122, 378, 250, 6, 262, 134, 390, 70, 326, 198, 454, 38, 294, 166, 422, 102, 358, 230, 486, 22, 278, 150, 406, 86, 342, 214, 470, 54, 310, 182, 438, 118, 374, 246, 14, 270, 142, 398, 78, 334, 206, 462, 46, 302, 174, 430, 110, 366, 238, 494, 30, 286, 158, 414, 94, 350, 222, 478, 62, 318, 190, 446, 126, 382, 254, 4, 260, 132, 388, 68, 324, 196, 452, 36, 292, 164, 420, 100, 356, 228, 484, 20, 276, 148, 404, 84, 340, 212, 468, 52, 308, 180, 436, 116, 372, 244, 500, 12, 268, 140, 396, 76, 332, 204, 460, 44, 300, 172, 428, 108, 364, 236, 492, 28, 284, 156, 412, 92, 348, 220, 476, 60, 316, 188, 444, 124, 380, 252, 8, 264, 136, 392, 72, 328, 200, 456, 40, 296, 168, 424, 104, 360, 232, 488, 24, 280, 152, 408, 88, 344, 216, 472, 56, 312, 184, 440, 120, 376, 248, 16, 272, 144, 400, 80, 336, 208, 464, 48, 304, 176, 432, 112, 368, 240, 496, 32, 288, 160, 416, 96, 352, 224, 480, 64, 320, 192, 448, 128, 384, 256]\n assert candidate(n = 1000) == [1, 513, 257, 769, 129, 641, 385, 897, 65, 577, 321, 833, 193, 705, 449, 961, 33, 545, 289, 801, 161, 673, 417, 929, 97, 609, 353, 865, 225, 737, 481, 993, 17, 529, 273, 785, 145, 657, 401, 913, 81, 593, 337, 849, 209, 721, 465, 977, 49, 561, 305, 817, 177, 689, 433, 945, 113, 625, 369, 881, 241, 753, 497, 9, 521, 265, 777, 137, 649, 393, 905, 73, 585, 329, 841, 201, 713, 457, 969, 41, 553, 297, 809, 169, 681, 425, 937, 105, 617, 361, 873, 233, 745, 489, 25, 537, 281, 793, 153, 665, 409, 921, 89, 601, 345, 857, 217, 729, 473, 985, 57, 569, 313, 825, 185, 697, 441, 953, 121, 633, 377, 889, 249, 761, 505, 5, 517, 261, 773, 133, 645, 389, 901, 69, 581, 325, 837, 197, 709, 453, 965, 37, 549, 293, 805, 165, 677, 421, 933, 101, 613, 357, 869, 229, 741, 485, 997, 21, 533, 277, 789, 149, 661, 405, 917, 85, 597, 341, 853, 213, 725, 469, 981, 53, 565, 309, 821, 181, 693, 437, 949, 117, 629, 373, 885, 245, 757, 501, 13, 525, 269, 781, 141, 653, 397, 909, 77, 589, 333, 845, 205, 717, 461, 973, 45, 557, 301, 813, 173, 685, 429, 941, 109, 621, 365, 877, 237, 749, 493, 29, 541, 285, 797, 157, 669, 413, 925, 93, 605, 349, 861, 221, 733, 477, 989, 61, 573, 317, 829, 189, 701, 445, 957, 125, 637, 381, 893, 253, 765, 509, 3, 515, 259, 771, 131, 643, 387, 899, 67, 579, 323, 835, 195, 707, 451, 963, 35, 547, 291, 803, 163, 675, 419, 931, 99, 611, 355, 867, 227, 739, 483, 995, 19, 531, 275, 787, 147, 659, 403, 915, 83, 595, 339, 851, 211, 723, 467, 979, 51, 563, 307, 819, 179, 691, 435, 947, 115, 627, 371, 883, 243, 755, 499, 11, 523, 267, 779, 139, 651, 395, 907, 75, 587, 331, 843, 203, 715, 459, 971, 43, 555, 299, 811, 171, 683, 427, 939, 107, 619, 363, 875, 235, 747, 491, 27, 539, 283, 795, 155, 667, 411, 923, 91, 603, 347, 859, 219, 731, 475, 987, 59, 571, 315, 827, 187, 699, 443, 955, 123, 635, 379, 891, 251, 763, 507, 7, 519, 263, 775, 135, 647, 391, 903, 71, 583, 327, 839, 199, 711, 455, 967, 39, 551, 295, 807, 167, 679, 423, 935, 103, 615, 359, 871, 231, 743, 487, 999, 23, 535, 279, 791, 151, 663, 407, 919, 87, 599, 343, 855, 215, 727, 471, 983, 55, 567, 311, 823, 183, 695, 439, 951, 119, 631, 375, 887, 247, 759, 503, 15, 527, 271, 783, 143, 655, 399, 911, 79, 591, 335, 847, 207, 719, 463, 975, 47, 559, 303, 815, 175, 687, 431, 943, 111, 623, 367, 879, 239, 751, 495, 31, 543, 287, 799, 159, 671, 415, 927, 95, 607, 351, 863, 223, 735, 479, 991, 63, 575, 319, 831, 191, 703, 447, 959, 127, 639, 383, 895, 255, 767, 511, 2, 514, 258, 770, 130, 642, 386, 898, 66, 578, 322, 834, 194, 706, 450, 962, 34, 546, 290, 802, 162, 674, 418, 930, 98, 610, 354, 866, 226, 738, 482, 994, 18, 530, 274, 786, 146, 658, 402, 914, 82, 594, 338, 850, 210, 722, 466, 978, 50, 562, 306, 818, 178, 690, 434, 946, 114, 626, 370, 882, 242, 754, 498, 10, 522, 266, 778, 138, 650, 394, 906, 74, 586, 330, 842, 202, 714, 458, 970, 42, 554, 298, 810, 170, 682, 426, 938, 106, 618, 362, 874, 234, 746, 490, 26, 538, 282, 794, 154, 666, 410, 922, 90, 602, 346, 858, 218, 730, 474, 986, 58, 570, 314, 826, 186, 698, 442, 954, 122, 634, 378, 890, 250, 762, 506, 6, 518, 262, 774, 134, 646, 390, 902, 70, 582, 326, 838, 198, 710, 454, 966, 38, 550, 294, 806, 166, 678, 422, 934, 102, 614, 358, 870, 230, 742, 486, 998, 22, 534, 278, 790, 150, 662, 406, 918, 86, 598, 342, 854, 214, 726, 470, 982, 54, 566, 310, 822, 182, 694, 438, 950, 118, 630, 374, 886, 246, 758, 502, 14, 526, 270, 782, 142, 654, 398, 910, 78, 590, 334, 846, 206, 718, 462, 974, 46, 558, 302, 814, 174, 686, 430, 942, 110, 622, 366, 878, 238, 750, 494, 30, 542, 286, 798, 158, 670, 414, 926, 94, 606, 350, 862, 222, 734, 478, 990, 62, 574, 318, 830, 190, 702, 446, 958, 126, 638, 382, 894, 254, 766, 510, 4, 516, 260, 772, 132, 644, 388, 900, 68, 580, 324, 836, 196, 708, 452, 964, 36, 548, 292, 804, 164, 676, 420, 932, 100, 612, 356, 868, 228, 740, 484, 996, 20, 532, 276, 788, 148, 660, 404, 916, 84, 596, 340, 852, 212, 724, 468, 980, 52, 564, 308, 820, 180, 692, 436, 948, 116, 628, 372, 884, 244, 756, 500, 12, 524, 268, 780, 140, 652, 396, 908, 76, 588, 332, 844, 204, 716, 460, 972, 44, 556, 300, 812, 172, 684, 428, 940, 108, 620, 364, 876, 236, 748, 492, 28, 540, 284, 796, 156, 668, 412, 924, 92, 604, 348, 860, 220, 732, 476, 988, 60, 572, 316, 828, 188, 700, 444, 956, 124, 636, 380, 892, 252, 764, 508, 8, 520, 264, 776, 136, 648, 392, 904, 72, 584, 328, 840, 200, 712, 456, 968, 40, 552, 296, 808, 168, 680, 424, 936, 104, 616, 360, 872, 232, 744, 488, 1000, 24, 536, 280, 792, 152, 664, 408, 920, 88, 600, 344, 856, 216, 728, 472, 984, 56, 568, 312, 824, 184, 696, 440, 952, 120, 632, 376, 888, 248, 760, 504, 16, 528, 272, 784, 144, 656, 400, 912, 80, 592, 336, 848, 208, 720, 464, 976, 48, 560, 304, 816, 176, 688, 432, 944, 112, 624, 368, 880, 240, 752, 496, 32, 544, 288, 800, 160, 672, 416, 928, 96, 608, 352, 864, 224, 736, 480, 992, 64, 576, 320, 832, 192, 704, 448, 960, 128, 640, 384, 896, 256, 768, 512]\n assert candidate(n = 1) == [1]\n assert candidate(n = 10) == [1, 9, 5, 3, 7, 2, 10, 6, 4, 8]\n assert candidate(n = 5) == [1, 5, 3, 2, 4]\n assert candidate(n = 3) == [1, 3, 2]\n assert candidate(n = 63) == [1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 63, 2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 62, 4, 36, 20, 52, 12, 44, 28, 60, 8, 40, 24, 56, 16, 48, 32]\n assert candidate(n = 61) == [1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 4, 36, 20, 52, 12, 44, 28, 60, 8, 40, 24, 56, 16, 48, 32]\n assert candidate(n = 480) == [1, 257, 129, 385, 65, 321, 193, 449, 33, 289, 161, 417, 97, 353, 225, 17, 273, 145, 401, 81, 337, 209, 465, 49, 305, 177, 433, 113, 369, 241, 9, 265, 137, 393, 73, 329, 201, 457, 41, 297, 169, 425, 105, 361, 233, 25, 281, 153, 409, 89, 345, 217, 473, 57, 313, 185, 441, 121, 377, 249, 5, 261, 133, 389, 69, 325, 197, 453, 37, 293, 165, 421, 101, 357, 229, 21, 277, 149, 405, 85, 341, 213, 469, 53, 309, 181, 437, 117, 373, 245, 13, 269, 141, 397, 77, 333, 205, 461, 45, 301, 173, 429, 109, 365, 237, 29, 285, 157, 413, 93, 349, 221, 477, 61, 317, 189, 445, 125, 381, 253, 3, 259, 131, 387, 67, 323, 195, 451, 35, 291, 163, 419, 99, 355, 227, 19, 275, 147, 403, 83, 339, 211, 467, 51, 307, 179, 435, 115, 371, 243, 11, 267, 139, 395, 75, 331, 203, 459, 43, 299, 171, 427, 107, 363, 235, 27, 283, 155, 411, 91, 347, 219, 475, 59, 315, 187, 443, 123, 379, 251, 7, 263, 135, 391, 71, 327, 199, 455, 39, 295, 167, 423, 103, 359, 231, 23, 279, 151, 407, 87, 343, 215, 471, 55, 311, 183, 439, 119, 375, 247, 15, 271, 143, 399, 79, 335, 207, 463, 47, 303, 175, 431, 111, 367, 239, 31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 2, 258, 130, 386, 66, 322, 194, 450, 34, 290, 162, 418, 98, 354, 226, 18, 274, 146, 402, 82, 338, 210, 466, 50, 306, 178, 434, 114, 370, 242, 10, 266, 138, 394, 74, 330, 202, 458, 42, 298, 170, 426, 106, 362, 234, 26, 282, 154, 410, 90, 346, 218, 474, 58, 314, 186, 442, 122, 378, 250, 6, 262, 134, 390, 70, 326, 198, 454, 38, 294, 166, 422, 102, 358, 230, 22, 278, 150, 406, 86, 342, 214, 470, 54, 310, 182, 438, 118, 374, 246, 14, 270, 142, 398, 78, 334, 206, 462, 46, 302, 174, 430, 110, 366, 238, 30, 286, 158, 414, 94, 350, 222, 478, 62, 318, 190, 446, 126, 382, 254, 4, 260, 132, 388, 68, 324, 196, 452, 36, 292, 164, 420, 100, 356, 228, 20, 276, 148, 404, 84, 340, 212, 468, 52, 308, 180, 436, 116, 372, 244, 12, 268, 140, 396, 76, 332, 204, 460, 44, 300, 172, 428, 108, 364, 236, 28, 284, 156, 412, 92, 348, 220, 476, 60, 316, 188, 444, 124, 380, 252, 8, 264, 136, 392, 72, 328, 200, 456, 40, 296, 168, 424, 104, 360, 232, 24, 280, 152, 408, 88, 344, 216, 472, 56, 312, 184, 440, 120, 376, 248, 16, 272, 144, 400, 80, 336, 208, 464, 48, 304, 176, 432, 112, 368, 240, 32, 288, 160, 416, 96, 352, 224, 480, 64, 320, 192, 448, 128, 384, 256]\n assert candidate(n = 125) == [1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121, 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125, 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123, 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122, 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124, 8, 72, 40, 104, 24, 88, 56, 120, 16, 80, 48, 112, 32, 96, 64]\n assert candidate(n = 511) == [1, 257, 129, 385, 65, 321, 193, 449, 33, 289, 161, 417, 97, 353, 225, 481, 17, 273, 145, 401, 81, 337, 209, 465, 49, 305, 177, 433, 113, 369, 241, 497, 9, 265, 137, 393, 73, 329, 201, 457, 41, 297, 169, 425, 105, 361, 233, 489, 25, 281, 153, 409, 89, 345, 217, 473, 57, 313, 185, 441, 121, 377, 249, 505, 5, 261, 133, 389, 69, 325, 197, 453, 37, 293, 165, 421, 101, 357, 229, 485, 21, 277, 149, 405, 85, 341, 213, 469, 53, 309, 181, 437, 117, 373, 245, 501, 13, 269, 141, 397, 77, 333, 205, 461, 45, 301, 173, 429, 109, 365, 237, 493, 29, 285, 157, 413, 93, 349, 221, 477, 61, 317, 189, 445, 125, 381, 253, 509, 3, 259, 131, 387, 67, 323, 195, 451, 35, 291, 163, 419, 99, 355, 227, 483, 19, 275, 147, 403, 83, 339, 211, 467, 51, 307, 179, 435, 115, 371, 243, 499, 11, 267, 139, 395, 75, 331, 203, 459, 43, 299, 171, 427, 107, 363, 235, 491, 27, 283, 155, 411, 91, 347, 219, 475, 59, 315, 187, 443, 123, 379, 251, 507, 7, 263, 135, 391, 71, 327, 199, 455, 39, 295, 167, 423, 103, 359, 231, 487, 23, 279, 151, 407, 87, 343, 215, 471, 55, 311, 183, 439, 119, 375, 247, 503, 15, 271, 143, 399, 79, 335, 207, 463, 47, 303, 175, 431, 111, 367, 239, 495, 31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 511, 2, 258, 130, 386, 66, 322, 194, 450, 34, 290, 162, 418, 98, 354, 226, 482, 18, 274, 146, 402, 82, 338, 210, 466, 50, 306, 178, 434, 114, 370, 242, 498, 10, 266, 138, 394, 74, 330, 202, 458, 42, 298, 170, 426, 106, 362, 234, 490, 26, 282, 154, 410, 90, 346, 218, 474, 58, 314, 186, 442, 122, 378, 250, 506, 6, 262, 134, 390, 70, 326, 198, 454, 38, 294, 166, 422, 102, 358, 230, 486, 22, 278, 150, 406, 86, 342, 214, 470, 54, 310, 182, 438, 118, 374, 246, 502, 14, 270, 142, 398, 78, 334, 206, 462, 46, 302, 174, 430, 110, 366, 238, 494, 30, 286, 158, 414, 94, 350, 222, 478, 62, 318, 190, 446, 126, 382, 254, 510, 4, 260, 132, 388, 68, 324, 196, 452, 36, 292, 164, 420, 100, 356, 228, 484, 20, 276, 148, 404, 84, 340, 212, 468, 52, 308, 180, 436, 116, 372, 244, 500, 12, 268, 140, 396, 76, 332, 204, 460, 44, 300, 172, 428, 108, 364, 236, 492, 28, 284, 156, 412, 92, 348, 220, 476, 60, 316, 188, 444, 124, 380, 252, 508, 8, 264, 136, 392, 72, 328, 200, 456, 40, 296, 168, 424, 104, 360, 232, 488, 24, 280, 152, 408, 88, 344, 216, 472, 56, 312, 184, 440, 120, 376, 248, 504, 16, 272, 144, 400, 80, 336, 208, 464, 48, 304, 176, 432, 112, 368, 240, 496, 32, 288, 160, 416, 96, 352, 224, 480, 64, 320, 192, 448, 128, 384, 256]\n assert candidate(n = 50) == [1, 33, 17, 49, 9, 41, 25, 5, 37, 21, 13, 45, 29, 3, 35, 19, 11, 43, 27, 7, 39, 23, 15, 47, 31, 2, 34, 18, 50, 10, 42, 26, 6, 38, 22, 14, 46, 30, 4, 36, 20, 12, 44, 28, 8, 40, 24, 16, 48, 32]\n assert candidate(n = 300) == [1, 257, 129, 65, 193, 33, 289, 161, 97, 225, 17, 273, 145, 81, 209, 49, 177, 113, 241, 9, 265, 137, 73, 201, 41, 297, 169, 105, 233, 25, 281, 153, 89, 217, 57, 185, 121, 249, 5, 261, 133, 69, 197, 37, 293, 165, 101, 229, 21, 277, 149, 85, 213, 53, 181, 117, 245, 13, 269, 141, 77, 205, 45, 173, 109, 237, 29, 285, 157, 93, 221, 61, 189, 125, 253, 3, 259, 131, 67, 195, 35, 291, 163, 99, 227, 19, 275, 147, 83, 211, 51, 179, 115, 243, 11, 267, 139, 75, 203, 43, 299, 171, 107, 235, 27, 283, 155, 91, 219, 59, 187, 123, 251, 7, 263, 135, 71, 199, 39, 295, 167, 103, 231, 23, 279, 151, 87, 215, 55, 183, 119, 247, 15, 271, 143, 79, 207, 47, 175, 111, 239, 31, 287, 159, 95, 223, 63, 191, 127, 255, 2, 258, 130, 66, 194, 34, 290, 162, 98, 226, 18, 274, 146, 82, 210, 50, 178, 114, 242, 10, 266, 138, 74, 202, 42, 298, 170, 106, 234, 26, 282, 154, 90, 218, 58, 186, 122, 250, 6, 262, 134, 70, 198, 38, 294, 166, 102, 230, 22, 278, 150, 86, 214, 54, 182, 118, 246, 14, 270, 142, 78, 206, 46, 174, 110, 238, 30, 286, 158, 94, 222, 62, 190, 126, 254, 4, 260, 132, 68, 196, 36, 292, 164, 100, 228, 20, 276, 148, 84, 212, 52, 180, 116, 244, 12, 268, 140, 76, 204, 44, 300, 172, 108, 236, 28, 284, 156, 92, 220, 60, 188, 124, 252, 8, 264, 136, 72, 200, 40, 296, 168, 104, 232, 24, 280, 152, 88, 216, 56, 184, 120, 248, 16, 272, 144, 80, 208, 48, 176, 112, 240, 32, 288, 160, 96, 224, 64, 192, 128, 256]\n assert candidate(n = 60) == [1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 4, 36, 20, 52, 12, 44, 28, 60, 8, 40, 24, 56, 16, 48, 32]\n assert candidate(n = 333) == [1, 257, 129, 65, 321, 193, 33, 289, 161, 97, 225, 17, 273, 145, 81, 209, 49, 305, 177, 113, 241, 9, 265, 137, 73, 329, 201, 41, 297, 169, 105, 233, 25, 281, 153, 89, 217, 57, 313, 185, 121, 249, 5, 261, 133, 69, 325, 197, 37, 293, 165, 101, 229, 21, 277, 149, 85, 213, 53, 309, 181, 117, 245, 13, 269, 141, 77, 333, 205, 45, 301, 173, 109, 237, 29, 285, 157, 93, 221, 61, 317, 189, 125, 253, 3, 259, 131, 67, 323, 195, 35, 291, 163, 99, 227, 19, 275, 147, 83, 211, 51, 307, 179, 115, 243, 11, 267, 139, 75, 331, 203, 43, 299, 171, 107, 235, 27, 283, 155, 91, 219, 59, 315, 187, 123, 251, 7, 263, 135, 71, 327, 199, 39, 295, 167, 103, 231, 23, 279, 151, 87, 215, 55, 311, 183, 119, 247, 15, 271, 143, 79, 207, 47, 303, 175, 111, 239, 31, 287, 159, 95, 223, 63, 319, 191, 127, 255, 2, 258, 130, 66, 322, 194, 34, 290, 162, 98, 226, 18, 274, 146, 82, 210, 50, 306, 178, 114, 242, 10, 266, 138, 74, 330, 202, 42, 298, 170, 106, 234, 26, 282, 154, 90, 218, 58, 314, 186, 122, 250, 6, 262, 134, 70, 326, 198, 38, 294, 166, 102, 230, 22, 278, 150, 86, 214, 54, 310, 182, 118, 246, 14, 270, 142, 78, 206, 46, 302, 174, 110, 238, 30, 286, 158, 94, 222, 62, 318, 190, 126, 254, 4, 260, 132, 68, 324, 196, 36, 292, 164, 100, 228, 20, 276, 148, 84, 212, 52, 308, 180, 116, 244, 12, 268, 140, 76, 332, 204, 44, 300, 172, 108, 236, 28, 284, 156, 92, 220, 60, 316, 188, 124, 252, 8, 264, 136, 72, 328, 200, 40, 296, 168, 104, 232, 24, 280, 152, 88, 216, 56, 312, 184, 120, 248, 16, 272, 144, 80, 208, 48, 304, 176, 112, 240, 32, 288, 160, 96, 224, 64, 320, 192, 128, 256]\n assert candidate(n = 30) == [1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 2, 18, 10, 26, 6, 22, 14, 30, 4, 20, 12, 28, 8, 24, 16]\n assert candidate(n = 99) == [1, 65, 33, 97, 17, 81, 49, 9, 73, 41, 25, 89, 57, 5, 69, 37, 21, 85, 53, 13, 77, 45, 29, 93, 61, 3, 67, 35, 99, 19, 83, 51, 11, 75, 43, 27, 91, 59, 7, 71, 39, 23, 87, 55, 15, 79, 47, 31, 95, 63, 2, 66, 34, 98, 18, 82, 50, 10, 74, 42, 26, 90, 58, 6, 70, 38, 22, 86, 54, 14, 78, 46, 30, 94, 62, 4, 68, 36, 20, 84, 52, 12, 76, 44, 28, 92, 60, 8, 72, 40, 24, 88, 56, 16, 80, 48, 32, 96, 64]\n assert candidate(n = 37) == [1, 33, 17, 9, 25, 5, 37, 21, 13, 29, 3, 35, 19, 11, 27, 7, 23, 15, 31, 2, 34, 18, 10, 26, 6, 22, 14, 30, 4, 36, 20, 12, 28, 8, 24, 16, 32]\n assert candidate(n = 16) == [1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16]\n assert candidate(n = 17) == [1, 17, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16]\n assert candidate(n = 257) == [1, 257, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 16, 144, 80, 208, 48, 176, 112, 240, 32, 160, 96, 224, 64, 192, 128, 256]\n assert candidate(n = 23) == [1, 17, 9, 5, 21, 13, 3, 19, 11, 7, 23, 15, 2, 18, 10, 6, 22, 14, 4, 20, 12, 8, 16]\n assert candidate(n = 128) == [1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121, 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125, 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123, 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 127, 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122, 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 126, 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124, 8, 72, 40, 104, 24, 88, 56, 120, 16, 80, 48, 112, 32, 96, 64, 128]\n assert candidate(n = 101) == [1, 65, 33, 97, 17, 81, 49, 9, 73, 41, 25, 89, 57, 5, 69, 37, 101, 21, 85, 53, 13, 77, 45, 29, 93, 61, 3, 67, 35, 99, 19, 83, 51, 11, 75, 43, 27, 91, 59, 7, 71, 39, 23, 87, 55, 15, 79, 47, 31, 95, 63, 2, 66, 34, 98, 18, 82, 50, 10, 74, 42, 26, 90, 58, 6, 70, 38, 22, 86, 54, 14, 78, 46, 30, 94, 62, 4, 68, 36, 100, 20, 84, 52, 12, 76, 44, 28, 92, 60, 8, 72, 40, 24, 88, 56, 16, 80, 48, 32, 96, 64]\n assert candidate(n = 700) == [1, 513, 257, 129, 641, 385, 65, 577, 321, 193, 449, 33, 545, 289, 161, 673, 417, 97, 609, 353, 225, 481, 17, 529, 273, 145, 657, 401, 81, 593, 337, 209, 465, 49, 561, 305, 177, 689, 433, 113, 625, 369, 241, 497, 9, 521, 265, 137, 649, 393, 73, 585, 329, 201, 457, 41, 553, 297, 169, 681, 425, 105, 617, 361, 233, 489, 25, 537, 281, 153, 665, 409, 89, 601, 345, 217, 473, 57, 569, 313, 185, 697, 441, 121, 633, 377, 249, 505, 5, 517, 261, 133, 645, 389, 69, 581, 325, 197, 453, 37, 549, 293, 165, 677, 421, 101, 613, 357, 229, 485, 21, 533, 277, 149, 661, 405, 85, 597, 341, 213, 469, 53, 565, 309, 181, 693, 437, 117, 629, 373, 245, 501, 13, 525, 269, 141, 653, 397, 77, 589, 333, 205, 461, 45, 557, 301, 173, 685, 429, 109, 621, 365, 237, 493, 29, 541, 285, 157, 669, 413, 93, 605, 349, 221, 477, 61, 573, 317, 189, 445, 125, 637, 381, 253, 509, 3, 515, 259, 131, 643, 387, 67, 579, 323, 195, 451, 35, 547, 291, 163, 675, 419, 99, 611, 355, 227, 483, 19, 531, 275, 147, 659, 403, 83, 595, 339, 211, 467, 51, 563, 307, 179, 691, 435, 115, 627, 371, 243, 499, 11, 523, 267, 139, 651, 395, 75, 587, 331, 203, 459, 43, 555, 299, 171, 683, 427, 107, 619, 363, 235, 491, 27, 539, 283, 155, 667, 411, 91, 603, 347, 219, 475, 59, 571, 315, 187, 699, 443, 123, 635, 379, 251, 507, 7, 519, 263, 135, 647, 391, 71, 583, 327, 199, 455, 39, 551, 295, 167, 679, 423, 103, 615, 359, 231, 487, 23, 535, 279, 151, 663, 407, 87, 599, 343, 215, 471, 55, 567, 311, 183, 695, 439, 119, 631, 375, 247, 503, 15, 527, 271, 143, 655, 399, 79, 591, 335, 207, 463, 47, 559, 303, 175, 687, 431, 111, 623, 367, 239, 495, 31, 543, 287, 159, 671, 415, 95, 607, 351, 223, 479, 63, 575, 319, 191, 447, 127, 639, 383, 255, 511, 2, 514, 258, 130, 642, 386, 66, 578, 322, 194, 450, 34, 546, 290, 162, 674, 418, 98, 610, 354, 226, 482, 18, 530, 274, 146, 658, 402, 82, 594, 338, 210, 466, 50, 562, 306, 178, 690, 434, 114, 626, 370, 242, 498, 10, 522, 266, 138, 650, 394, 74, 586, 330, 202, 458, 42, 554, 298, 170, 682, 426, 106, 618, 362, 234, 490, 26, 538, 282, 154, 666, 410, 90, 602, 346, 218, 474, 58, 570, 314, 186, 698, 442, 122, 634, 378, 250, 506, 6, 518, 262, 134, 646, 390, 70, 582, 326, 198, 454, 38, 550, 294, 166, 678, 422, 102, 614, 358, 230, 486, 22, 534, 278, 150, 662, 406, 86, 598, 342, 214, 470, 54, 566, 310, 182, 694, 438, 118, 630, 374, 246, 502, 14, 526, 270, 142, 654, 398, 78, 590, 334, 206, 462, 46, 558, 302, 174, 686, 430, 110, 622, 366, 238, 494, 30, 542, 286, 158, 670, 414, 94, 606, 350, 222, 478, 62, 574, 318, 190, 446, 126, 638, 382, 254, 510, 4, 516, 260, 132, 644, 388, 68, 580, 324, 196, 452, 36, 548, 292, 164, 676, 420, 100, 612, 356, 228, 484, 20, 532, 276, 148, 660, 404, 84, 596, 340, 212, 468, 52, 564, 308, 180, 692, 436, 116, 628, 372, 244, 500, 12, 524, 268, 140, 652, 396, 76, 588, 332, 204, 460, 44, 556, 300, 172, 684, 428, 108, 620, 364, 236, 492, 28, 540, 284, 156, 668, 412, 92, 604, 348, 220, 476, 60, 572, 316, 188, 700, 444, 124, 636, 380, 252, 508, 8, 520, 264, 136, 648, 392, 72, 584, 328, 200, 456, 40, 552, 296, 168, 680, 424, 104, 616, 360, 232, 488, 24, 536, 280, 152, 664, 408, 88, 600, 344, 216, 472, 56, 568, 312, 184, 696, 440, 120, 632, 376, 248, 504, 16, 528, 272, 144, 656, 400, 80, 592, 336, 208, 464, 48, 560, 304, 176, 688, 432, 112, 624, 368, 240, 496, 32, 544, 288, 160, 672, 416, 96, 608, 352, 224, 480, 64, 576, 320, 192, 448, 128, 640, 384, 256, 512]\n assert candidate(n = 250) == [1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 16, 144, 80, 208, 48, 176, 112, 240, 32, 160, 96, 224, 64, 192, 128]\n assert candidate(n = 255) == [1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 16, 144, 80, 208, 48, 176, 112, 240, 32, 160, 96, 224, 64, 192, 128]\n assert candidate(n = 999) == [1, 513, 257, 769, 129, 641, 385, 897, 65, 577, 321, 833, 193, 705, 449, 961, 33, 545, 289, 801, 161, 673, 417, 929, 97, 609, 353, 865, 225, 737, 481, 993, 17, 529, 273, 785, 145, 657, 401, 913, 81, 593, 337, 849, 209, 721, 465, 977, 49, 561, 305, 817, 177, 689, 433, 945, 113, 625, 369, 881, 241, 753, 497, 9, 521, 265, 777, 137, 649, 393, 905, 73, 585, 329, 841, 201, 713, 457, 969, 41, 553, 297, 809, 169, 681, 425, 937, 105, 617, 361, 873, 233, 745, 489, 25, 537, 281, 793, 153, 665, 409, 921, 89, 601, 345, 857, 217, 729, 473, 985, 57, 569, 313, 825, 185, 697, 441, 953, 121, 633, 377, 889, 249, 761, 505, 5, 517, 261, 773, 133, 645, 389, 901, 69, 581, 325, 837, 197, 709, 453, 965, 37, 549, 293, 805, 165, 677, 421, 933, 101, 613, 357, 869, 229, 741, 485, 997, 21, 533, 277, 789, 149, 661, 405, 917, 85, 597, 341, 853, 213, 725, 469, 981, 53, 565, 309, 821, 181, 693, 437, 949, 117, 629, 373, 885, 245, 757, 501, 13, 525, 269, 781, 141, 653, 397, 909, 77, 589, 333, 845, 205, 717, 461, 973, 45, 557, 301, 813, 173, 685, 429, 941, 109, 621, 365, 877, 237, 749, 493, 29, 541, 285, 797, 157, 669, 413, 925, 93, 605, 349, 861, 221, 733, 477, 989, 61, 573, 317, 829, 189, 701, 445, 957, 125, 637, 381, 893, 253, 765, 509, 3, 515, 259, 771, 131, 643, 387, 899, 67, 579, 323, 835, 195, 707, 451, 963, 35, 547, 291, 803, 163, 675, 419, 931, 99, 611, 355, 867, 227, 739, 483, 995, 19, 531, 275, 787, 147, 659, 403, 915, 83, 595, 339, 851, 211, 723, 467, 979, 51, 563, 307, 819, 179, 691, 435, 947, 115, 627, 371, 883, 243, 755, 499, 11, 523, 267, 779, 139, 651, 395, 907, 75, 587, 331, 843, 203, 715, 459, 971, 43, 555, 299, 811, 171, 683, 427, 939, 107, 619, 363, 875, 235, 747, 491, 27, 539, 283, 795, 155, 667, 411, 923, 91, 603, 347, 859, 219, 731, 475, 987, 59, 571, 315, 827, 187, 699, 443, 955, 123, 635, 379, 891, 251, 763, 507, 7, 519, 263, 775, 135, 647, 391, 903, 71, 583, 327, 839, 199, 711, 455, 967, 39, 551, 295, 807, 167, 679, 423, 935, 103, 615, 359, 871, 231, 743, 487, 999, 23, 535, 279, 791, 151, 663, 407, 919, 87, 599, 343, 855, 215, 727, 471, 983, 55, 567, 311, 823, 183, 695, 439, 951, 119, 631, 375, 887, 247, 759, 503, 15, 527, 271, 783, 143, 655, 399, 911, 79, 591, 335, 847, 207, 719, 463, 975, 47, 559, 303, 815, 175, 687, 431, 943, 111, 623, 367, 879, 239, 751, 495, 31, 543, 287, 799, 159, 671, 415, 927, 95, 607, 351, 863, 223, 735, 479, 991, 63, 575, 319, 831, 191, 703, 447, 959, 127, 639, 383, 895, 255, 767, 511, 2, 514, 258, 770, 130, 642, 386, 898, 66, 578, 322, 834, 194, 706, 450, 962, 34, 546, 290, 802, 162, 674, 418, 930, 98, 610, 354, 866, 226, 738, 482, 994, 18, 530, 274, 786, 146, 658, 402, 914, 82, 594, 338, 850, 210, 722, 466, 978, 50, 562, 306, 818, 178, 690, 434, 946, 114, 626, 370, 882, 242, 754, 498, 10, 522, 266, 778, 138, 650, 394, 906, 74, 586, 330, 842, 202, 714, 458, 970, 42, 554, 298, 810, 170, 682, 426, 938, 106, 618, 362, 874, 234, 746, 490, 26, 538, 282, 794, 154, 666, 410, 922, 90, 602, 346, 858, 218, 730, 474, 986, 58, 570, 314, 826, 186, 698, 442, 954, 122, 634, 378, 890, 250, 762, 506, 6, 518, 262, 774, 134, 646, 390, 902, 70, 582, 326, 838, 198, 710, 454, 966, 38, 550, 294, 806, 166, 678, 422, 934, 102, 614, 358, 870, 230, 742, 486, 998, 22, 534, 278, 790, 150, 662, 406, 918, 86, 598, 342, 854, 214, 726, 470, 982, 54, 566, 310, 822, 182, 694, 438, 950, 118, 630, 374, 886, 246, 758, 502, 14, 526, 270, 782, 142, 654, 398, 910, 78, 590, 334, 846, 206, 718, 462, 974, 46, 558, 302, 814, 174, 686, 430, 942, 110, 622, 366, 878, 238, 750, 494, 30, 542, 286, 798, 158, 670, 414, 926, 94, 606, 350, 862, 222, 734, 478, 990, 62, 574, 318, 830, 190, 702, 446, 958, 126, 638, 382, 894, 254, 766, 510, 4, 516, 260, 772, 132, 644, 388, 900, 68, 580, 324, 836, 196, 708, 452, 964, 36, 548, 292, 804, 164, 676, 420, 932, 100, 612, 356, 868, 228, 740, 484, 996, 20, 532, 276, 788, 148, 660, 404, 916, 84, 596, 340, 852, 212, 724, 468, 980, 52, 564, 308, 820, 180, 692, 436, 948, 116, 628, 372, 884, 244, 756, 500, 12, 524, 268, 780, 140, 652, 396, 908, 76, 588, 332, 844, 204, 716, 460, 972, 44, 556, 300, 812, 172, 684, 428, 940, 108, 620, 364, 876, 236, 748, 492, 28, 540, 284, 796, 156, 668, 412, 924, 92, 604, 348, 860, 220, 732, 476, 988, 60, 572, 316, 828, 188, 700, 444, 956, 124, 636, 380, 892, 252, 764, 508, 8, 520, 264, 776, 136, 648, 392, 904, 72, 584, 328, 840, 200, 712, 456, 968, 40, 552, 296, 808, 168, 680, 424, 936, 104, 616, 360, 872, 232, 744, 488, 24, 536, 280, 792, 152, 664, 408, 920, 88, 600, 344, 856, 216, 728, 472, 984, 56, 568, 312, 824, 184, 696, 440, 952, 120, 632, 376, 888, 248, 760, 504, 16, 528, 272, 784, 144, 656, 400, 912, 80, 592, 336, 848, 208, 720, 464, 976, 48, 560, 304, 816, 176, 688, 432, 944, 112, 624, 368, 880, 240, 752, 496, 32, 544, 288, 800, 160, 672, 416, 928, 96, 608, 352, 864, 224, 736, 480, 992, 64, 576, 320, 832, 192, 704, 448, 960, 128, 640, 384, 896, 256, 768, 512]\n assert candidate(n = 375) == [1, 257, 129, 65, 321, 193, 33, 289, 161, 97, 353, 225, 17, 273, 145, 81, 337, 209, 49, 305, 177, 113, 369, 241, 9, 265, 137, 73, 329, 201, 41, 297, 169, 105, 361, 233, 25, 281, 153, 89, 345, 217, 57, 313, 185, 121, 249, 5, 261, 133, 69, 325, 197, 37, 293, 165, 101, 357, 229, 21, 277, 149, 85, 341, 213, 53, 309, 181, 117, 373, 245, 13, 269, 141, 77, 333, 205, 45, 301, 173, 109, 365, 237, 29, 285, 157, 93, 349, 221, 61, 317, 189, 125, 253, 3, 259, 131, 67, 323, 195, 35, 291, 163, 99, 355, 227, 19, 275, 147, 83, 339, 211, 51, 307, 179, 115, 371, 243, 11, 267, 139, 75, 331, 203, 43, 299, 171, 107, 363, 235, 27, 283, 155, 91, 347, 219, 59, 315, 187, 123, 251, 7, 263, 135, 71, 327, 199, 39, 295, 167, 103, 359, 231, 23, 279, 151, 87, 343, 215, 55, 311, 183, 119, 375, 247, 15, 271, 143, 79, 335, 207, 47, 303, 175, 111, 367, 239, 31, 287, 159, 95, 351, 223, 63, 319, 191, 127, 255, 2, 258, 130, 66, 322, 194, 34, 290, 162, 98, 354, 226, 18, 274, 146, 82, 338, 210, 50, 306, 178, 114, 370, 242, 10, 266, 138, 74, 330, 202, 42, 298, 170, 106, 362, 234, 26, 282, 154, 90, 346, 218, 58, 314, 186, 122, 250, 6, 262, 134, 70, 326, 198, 38, 294, 166, 102, 358, 230, 22, 278, 150, 86, 342, 214, 54, 310, 182, 118, 374, 246, 14, 270, 142, 78, 334, 206, 46, 302, 174, 110, 366, 238, 30, 286, 158, 94, 350, 222, 62, 318, 190, 126, 254, 4, 260, 132, 68, 324, 196, 36, 292, 164, 100, 356, 228, 20, 276, 148, 84, 340, 212, 52, 308, 180, 116, 372, 244, 12, 268, 140, 76, 332, 204, 44, 300, 172, 108, 364, 236, 28, 284, 156, 92, 348, 220, 60, 316, 188, 124, 252, 8, 264, 136, 72, 328, 200, 40, 296, 168, 104, 360, 232, 24, 280, 152, 88, 344, 216, 56, 312, 184, 120, 248, 16, 272, 144, 80, 336, 208, 48, 304, 176, 112, 368, 240, 32, 288, 160, 96, 352, 224, 64, 320, 192, 128, 256]\n assert candidate(n = 75) == [1, 65, 33, 17, 49, 9, 73, 41, 25, 57, 5, 69, 37, 21, 53, 13, 45, 29, 61, 3, 67, 35, 19, 51, 11, 75, 43, 27, 59, 7, 71, 39, 23, 55, 15, 47, 31, 63, 2, 66, 34, 18, 50, 10, 74, 42, 26, 58, 6, 70, 38, 22, 54, 14, 46, 30, 62, 4, 68, 36, 20, 52, 12, 44, 28, 60, 8, 72, 40, 24, 56, 16, 48, 32, 64]\n assert candidate(n = 240) == [1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 16, 144, 80, 208, 48, 176, 112, 240, 32, 160, 96, 224, 64, 192, 128]\n assert candidate(n = 875) == [1, 513, 257, 769, 129, 641, 385, 65, 577, 321, 833, 193, 705, 449, 33, 545, 289, 801, 161, 673, 417, 97, 609, 353, 865, 225, 737, 481, 17, 529, 273, 785, 145, 657, 401, 81, 593, 337, 849, 209, 721, 465, 49, 561, 305, 817, 177, 689, 433, 113, 625, 369, 241, 753, 497, 9, 521, 265, 777, 137, 649, 393, 73, 585, 329, 841, 201, 713, 457, 41, 553, 297, 809, 169, 681, 425, 105, 617, 361, 873, 233, 745, 489, 25, 537, 281, 793, 153, 665, 409, 89, 601, 345, 857, 217, 729, 473, 57, 569, 313, 825, 185, 697, 441, 121, 633, 377, 249, 761, 505, 5, 517, 261, 773, 133, 645, 389, 69, 581, 325, 837, 197, 709, 453, 37, 549, 293, 805, 165, 677, 421, 101, 613, 357, 869, 229, 741, 485, 21, 533, 277, 789, 149, 661, 405, 85, 597, 341, 853, 213, 725, 469, 53, 565, 309, 821, 181, 693, 437, 117, 629, 373, 245, 757, 501, 13, 525, 269, 781, 141, 653, 397, 77, 589, 333, 845, 205, 717, 461, 45, 557, 301, 813, 173, 685, 429, 109, 621, 365, 237, 749, 493, 29, 541, 285, 797, 157, 669, 413, 93, 605, 349, 861, 221, 733, 477, 61, 573, 317, 829, 189, 701, 445, 125, 637, 381, 253, 765, 509, 3, 515, 259, 771, 131, 643, 387, 67, 579, 323, 835, 195, 707, 451, 35, 547, 291, 803, 163, 675, 419, 99, 611, 355, 867, 227, 739, 483, 19, 531, 275, 787, 147, 659, 403, 83, 595, 339, 851, 211, 723, 467, 51, 563, 307, 819, 179, 691, 435, 115, 627, 371, 243, 755, 499, 11, 523, 267, 779, 139, 651, 395, 75, 587, 331, 843, 203, 715, 459, 43, 555, 299, 811, 171, 683, 427, 107, 619, 363, 875, 235, 747, 491, 27, 539, 283, 795, 155, 667, 411, 91, 603, 347, 859, 219, 731, 475, 59, 571, 315, 827, 187, 699, 443, 123, 635, 379, 251, 763, 507, 7, 519, 263, 775, 135, 647, 391, 71, 583, 327, 839, 199, 711, 455, 39, 551, 295, 807, 167, 679, 423, 103, 615, 359, 871, 231, 743, 487, 23, 535, 279, 791, 151, 663, 407, 87, 599, 343, 855, 215, 727, 471, 55, 567, 311, 823, 183, 695, 439, 119, 631, 375, 247, 759, 503, 15, 527, 271, 783, 143, 655, 399, 79, 591, 335, 847, 207, 719, 463, 47, 559, 303, 815, 175, 687, 431, 111, 623, 367, 239, 751, 495, 31, 543, 287, 799, 159, 671, 415, 95, 607, 351, 863, 223, 735, 479, 63, 575, 319, 831, 191, 703, 447, 127, 639, 383, 255, 767, 511, 2, 514, 258, 770, 130, 642, 386, 66, 578, 322, 834, 194, 706, 450, 34, 546, 290, 802, 162, 674, 418, 98, 610, 354, 866, 226, 738, 482, 18, 530, 274, 786, 146, 658, 402, 82, 594, 338, 850, 210, 722, 466, 50, 562, 306, 818, 178, 690, 434, 114, 626, 370, 242, 754, 498, 10, 522, 266, 778, 138, 650, 394, 74, 586, 330, 842, 202, 714, 458, 42, 554, 298, 810, 170, 682, 426, 106, 618, 362, 874, 234, 746, 490, 26, 538, 282, 794, 154, 666, 410, 90, 602, 346, 858, 218, 730, 474, 58, 570, 314, 826, 186, 698, 442, 122, 634, 378, 250, 762, 506, 6, 518, 262, 774, 134, 646, 390, 70, 582, 326, 838, 198, 710, 454, 38, 550, 294, 806, 166, 678, 422, 102, 614, 358, 870, 230, 742, 486, 22, 534, 278, 790, 150, 662, 406, 86, 598, 342, 854, 214, 726, 470, 54, 566, 310, 822, 182, 694, 438, 118, 630, 374, 246, 758, 502, 14, 526, 270, 782, 142, 654, 398, 78, 590, 334, 846, 206, 718, 462, 46, 558, 302, 814, 174, 686, 430, 110, 622, 366, 238, 750, 494, 30, 542, 286, 798, 158, 670, 414, 94, 606, 350, 862, 222, 734, 478, 62, 574, 318, 830, 190, 702, 446, 126, 638, 382, 254, 766, 510, 4, 516, 260, 772, 132, 644, 388, 68, 580, 324, 836, 196, 708, 452, 36, 548, 292, 804, 164, 676, 420, 100, 612, 356, 868, 228, 740, 484, 20, 532, 276, 788, 148, 660, 404, 84, 596, 340, 852, 212, 724, 468, 52, 564, 308, 820, 180, 692, 436, 116, 628, 372, 244, 756, 500, 12, 524, 268, 780, 140, 652, 396, 76, 588, 332, 844, 204, 716, 460, 44, 556, 300, 812, 172, 684, 428, 108, 620, 364, 236, 748, 492, 28, 540, 284, 796, 156, 668, 412, 92, 604, 348, 860, 220, 732, 476, 60, 572, 316, 828, 188, 700, 444, 124, 636, 380, 252, 764, 508, 8, 520, 264, 776, 136, 648, 392, 72, 584, 328, 840, 200, 712, 456, 40, 552, 296, 808, 168, 680, 424, 104, 616, 360, 872, 232, 744, 488, 24, 536, 280, 792, 152, 664, 408, 88, 600, 344, 856, 216, 728, 472, 56, 568, 312, 824, 184, 696, 440, 120, 632, 376, 248, 760, 504, 16, 528, 272, 784, 144, 656, 400, 80, 592, 336, 848, 208, 720, 464, 48, 560, 304, 816, 176, 688, 432, 112, 624, 368, 240, 752, 496, 32, 544, 288, 800, 160, 672, 416, 96, 608, 352, 864, 224, 736, 480, 64, 576, 320, 832, 192, 704, 448, 128, 640, 384, 256, 768, 512]\n assert candidate(n = 19) == [1, 17, 9, 5, 13, 3, 19, 11, 7, 15, 2, 18, 10, 6, 14, 4, 12, 8, 16]\n assert candidate(n = 667) == [1, 513, 257, 129, 641, 385, 65, 577, 321, 193, 449, 33, 545, 289, 161, 417, 97, 609, 353, 225, 481, 17, 529, 273, 145, 657, 401, 81, 593, 337, 209, 465, 49, 561, 305, 177, 433, 113, 625, 369, 241, 497, 9, 521, 265, 137, 649, 393, 73, 585, 329, 201, 457, 41, 553, 297, 169, 425, 105, 617, 361, 233, 489, 25, 537, 281, 153, 665, 409, 89, 601, 345, 217, 473, 57, 569, 313, 185, 441, 121, 633, 377, 249, 505, 5, 517, 261, 133, 645, 389, 69, 581, 325, 197, 453, 37, 549, 293, 165, 421, 101, 613, 357, 229, 485, 21, 533, 277, 149, 661, 405, 85, 597, 341, 213, 469, 53, 565, 309, 181, 437, 117, 629, 373, 245, 501, 13, 525, 269, 141, 653, 397, 77, 589, 333, 205, 461, 45, 557, 301, 173, 429, 109, 621, 365, 237, 493, 29, 541, 285, 157, 413, 93, 605, 349, 221, 477, 61, 573, 317, 189, 445, 125, 637, 381, 253, 509, 3, 515, 259, 131, 643, 387, 67, 579, 323, 195, 451, 35, 547, 291, 163, 419, 99, 611, 355, 227, 483, 19, 531, 275, 147, 659, 403, 83, 595, 339, 211, 467, 51, 563, 307, 179, 435, 115, 627, 371, 243, 499, 11, 523, 267, 139, 651, 395, 75, 587, 331, 203, 459, 43, 555, 299, 171, 427, 107, 619, 363, 235, 491, 27, 539, 283, 155, 667, 411, 91, 603, 347, 219, 475, 59, 571, 315, 187, 443, 123, 635, 379, 251, 507, 7, 519, 263, 135, 647, 391, 71, 583, 327, 199, 455, 39, 551, 295, 167, 423, 103, 615, 359, 231, 487, 23, 535, 279, 151, 663, 407, 87, 599, 343, 215, 471, 55, 567, 311, 183, 439, 119, 631, 375, 247, 503, 15, 527, 271, 143, 655, 399, 79, 591, 335, 207, 463, 47, 559, 303, 175, 431, 111, 623, 367, 239, 495, 31, 543, 287, 159, 415, 95, 607, 351, 223, 479, 63, 575, 319, 191, 447, 127, 639, 383, 255, 511, 2, 514, 258, 130, 642, 386, 66, 578, 322, 194, 450, 34, 546, 290, 162, 418, 98, 610, 354, 226, 482, 18, 530, 274, 146, 658, 402, 82, 594, 338, 210, 466, 50, 562, 306, 178, 434, 114, 626, 370, 242, 498, 10, 522, 266, 138, 650, 394, 74, 586, 330, 202, 458, 42, 554, 298, 170, 426, 106, 618, 362, 234, 490, 26, 538, 282, 154, 666, 410, 90, 602, 346, 218, 474, 58, 570, 314, 186, 442, 122, 634, 378, 250, 506, 6, 518, 262, 134, 646, 390, 70, 582, 326, 198, 454, 38, 550, 294, 166, 422, 102, 614, 358, 230, 486, 22, 534, 278, 150, 662, 406, 86, 598, 342, 214, 470, 54, 566, 310, 182, 438, 118, 630, 374, 246, 502, 14, 526, 270, 142, 654, 398, 78, 590, 334, 206, 462, 46, 558, 302, 174, 430, 110, 622, 366, 238, 494, 30, 542, 286, 158, 414, 94, 606, 350, 222, 478, 62, 574, 318, 190, 446, 126, 638, 382, 254, 510, 4, 516, 260, 132, 644, 388, 68, 580, 324, 196, 452, 36, 548, 292, 164, 420, 100, 612, 356, 228, 484, 20, 532, 276, 148, 660, 404, 84, 596, 340, 212, 468, 52, 564, 308, 180, 436, 116, 628, 372, 244, 500, 12, 524, 268, 140, 652, 396, 76, 588, 332, 204, 460, 44, 556, 300, 172, 428, 108, 620, 364, 236, 492, 28, 540, 284, 156, 412, 92, 604, 348, 220, 476, 60, 572, 316, 188, 444, 124, 636, 380, 252, 508, 8, 520, 264, 136, 648, 392, 72, 584, 328, 200, 456, 40, 552, 296, 168, 424, 104, 616, 360, 232, 488, 24, 536, 280, 152, 664, 408, 88, 600, 344, 216, 472, 56, 568, 312, 184, 440, 120, 632, 376, 248, 504, 16, 528, 272, 144, 656, 400, 80, 592, 336, 208, 464, 48, 560, 304, 176, 432, 112, 624, 368, 240, 496, 32, 544, 288, 160, 416, 96, 608, 352, 224, 480, 64, 576, 320, 192, 448, 128, 640, 384, 256, 512]\n assert candidate(n = 77) == [1, 65, 33, 17, 49, 9, 73, 41, 25, 57, 5, 69, 37, 21, 53, 13, 77, 45, 29, 61, 3, 67, 35, 19, 51, 11, 75, 43, 27, 59, 7, 71, 39, 23, 55, 15, 47, 31, 63, 2, 66, 34, 18, 50, 10, 74, 42, 26, 58, 6, 70, 38, 22, 54, 14, 46, 30, 62, 4, 68, 36, 20, 52, 12, 76, 44, 28, 60, 8, 72, 40, 24, 56, 16, 48, 32, 64]\n assert candidate(n = 127) == [1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121, 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125, 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123, 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 127, 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122, 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 126, 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124, 8, 72, 40, 104, 24, 88, 56, 120, 16, 80, 48, 112, 32, 96, 64]\n assert candidate(n = 800) == [1, 513, 257, 769, 129, 641, 385, 65, 577, 321, 193, 705, 449, 33, 545, 289, 161, 673, 417, 97, 609, 353, 225, 737, 481, 17, 529, 273, 785, 145, 657, 401, 81, 593, 337, 209, 721, 465, 49, 561, 305, 177, 689, 433, 113, 625, 369, 241, 753, 497, 9, 521, 265, 777, 137, 649, 393, 73, 585, 329, 201, 713, 457, 41, 553, 297, 169, 681, 425, 105, 617, 361, 233, 745, 489, 25, 537, 281, 793, 153, 665, 409, 89, 601, 345, 217, 729, 473, 57, 569, 313, 185, 697, 441, 121, 633, 377, 249, 761, 505, 5, 517, 261, 773, 133, 645, 389, 69, 581, 325, 197, 709, 453, 37, 549, 293, 165, 677, 421, 101, 613, 357, 229, 741, 485, 21, 533, 277, 789, 149, 661, 405, 85, 597, 341, 213, 725, 469, 53, 565, 309, 181, 693, 437, 117, 629, 373, 245, 757, 501, 13, 525, 269, 781, 141, 653, 397, 77, 589, 333, 205, 717, 461, 45, 557, 301, 173, 685, 429, 109, 621, 365, 237, 749, 493, 29, 541, 285, 797, 157, 669, 413, 93, 605, 349, 221, 733, 477, 61, 573, 317, 189, 701, 445, 125, 637, 381, 253, 765, 509, 3, 515, 259, 771, 131, 643, 387, 67, 579, 323, 195, 707, 451, 35, 547, 291, 163, 675, 419, 99, 611, 355, 227, 739, 483, 19, 531, 275, 787, 147, 659, 403, 83, 595, 339, 211, 723, 467, 51, 563, 307, 179, 691, 435, 115, 627, 371, 243, 755, 499, 11, 523, 267, 779, 139, 651, 395, 75, 587, 331, 203, 715, 459, 43, 555, 299, 171, 683, 427, 107, 619, 363, 235, 747, 491, 27, 539, 283, 795, 155, 667, 411, 91, 603, 347, 219, 731, 475, 59, 571, 315, 187, 699, 443, 123, 635, 379, 251, 763, 507, 7, 519, 263, 775, 135, 647, 391, 71, 583, 327, 199, 711, 455, 39, 551, 295, 167, 679, 423, 103, 615, 359, 231, 743, 487, 23, 535, 279, 791, 151, 663, 407, 87, 599, 343, 215, 727, 471, 55, 567, 311, 183, 695, 439, 119, 631, 375, 247, 759, 503, 15, 527, 271, 783, 143, 655, 399, 79, 591, 335, 207, 719, 463, 47, 559, 303, 175, 687, 431, 111, 623, 367, 239, 751, 495, 31, 543, 287, 799, 159, 671, 415, 95, 607, 351, 223, 735, 479, 63, 575, 319, 191, 703, 447, 127, 639, 383, 255, 767, 511, 2, 514, 258, 770, 130, 642, 386, 66, 578, 322, 194, 706, 450, 34, 546, 290, 162, 674, 418, 98, 610, 354, 226, 738, 482, 18, 530, 274, 786, 146, 658, 402, 82, 594, 338, 210, 722, 466, 50, 562, 306, 178, 690, 434, 114, 626, 370, 242, 754, 498, 10, 522, 266, 778, 138, 650, 394, 74, 586, 330, 202, 714, 458, 42, 554, 298, 170, 682, 426, 106, 618, 362, 234, 746, 490, 26, 538, 282, 794, 154, 666, 410, 90, 602, 346, 218, 730, 474, 58, 570, 314, 186, 698, 442, 122, 634, 378, 250, 762, 506, 6, 518, 262, 774, 134, 646, 390, 70, 582, 326, 198, 710, 454, 38, 550, 294, 166, 678, 422, 102, 614, 358, 230, 742, 486, 22, 534, 278, 790, 150, 662, 406, 86, 598, 342, 214, 726, 470, 54, 566, 310, 182, 694, 438, 118, 630, 374, 246, 758, 502, 14, 526, 270, 782, 142, 654, 398, 78, 590, 334, 206, 718, 462, 46, 558, 302, 174, 686, 430, 110, 622, 366, 238, 750, 494, 30, 542, 286, 798, 158, 670, 414, 94, 606, 350, 222, 734, 478, 62, 574, 318, 190, 702, 446, 126, 638, 382, 254, 766, 510, 4, 516, 260, 772, 132, 644, 388, 68, 580, 324, 196, 708, 452, 36, 548, 292, 164, 676, 420, 100, 612, 356, 228, 740, 484, 20, 532, 276, 788, 148, 660, 404, 84, 596, 340, 212, 724, 468, 52, 564, 308, 180, 692, 436, 116, 628, 372, 244, 756, 500, 12, 524, 268, 780, 140, 652, 396, 76, 588, 332, 204, 716, 460, 44, 556, 300, 172, 684, 428, 108, 620, 364, 236, 748, 492, 28, 540, 284, 796, 156, 668, 412, 92, 604, 348, 220, 732, 476, 60, 572, 316, 188, 700, 444, 124, 636, 380, 252, 764, 508, 8, 520, 264, 776, 136, 648, 392, 72, 584, 328, 200, 712, 456, 40, 552, 296, 168, 680, 424, 104, 616, 360, 232, 744, 488, 24, 536, 280, 792, 152, 664, 408, 88, 600, 344, 216, 728, 472, 56, 568, 312, 184, 696, 440, 120, 632, 376, 248, 760, 504, 16, 528, 272, 784, 144, 656, 400, 80, 592, 336, 208, 720, 464, 48, 560, 304, 176, 688, 432, 112, 624, 368, 240, 752, 496, 32, 544, 288, 800, 160, 672, 416, 96, 608, 352, 224, 736, 480, 64, 576, 320, 192, 704, 448, 128, 640, 384, 256, 768, 512]\n assert candidate(n = 200) == [1, 129, 65, 193, 33, 161, 97, 17, 145, 81, 49, 177, 113, 9, 137, 73, 41, 169, 105, 25, 153, 89, 57, 185, 121, 5, 133, 69, 197, 37, 165, 101, 21, 149, 85, 53, 181, 117, 13, 141, 77, 45, 173, 109, 29, 157, 93, 61, 189, 125, 3, 131, 67, 195, 35, 163, 99, 19, 147, 83, 51, 179, 115, 11, 139, 75, 43, 171, 107, 27, 155, 91, 59, 187, 123, 7, 135, 71, 199, 39, 167, 103, 23, 151, 87, 55, 183, 119, 15, 143, 79, 47, 175, 111, 31, 159, 95, 63, 191, 127, 2, 130, 66, 194, 34, 162, 98, 18, 146, 82, 50, 178, 114, 10, 138, 74, 42, 170, 106, 26, 154, 90, 58, 186, 122, 6, 134, 70, 198, 38, 166, 102, 22, 150, 86, 54, 182, 118, 14, 142, 78, 46, 174, 110, 30, 158, 94, 62, 190, 126, 4, 132, 68, 196, 36, 164, 100, 20, 148, 84, 52, 180, 116, 12, 140, 76, 44, 172, 108, 28, 156, 92, 60, 188, 124, 8, 136, 72, 200, 40, 168, 104, 24, 152, 88, 56, 184, 120, 16, 144, 80, 48, 176, 112, 32, 160, 96, 64, 192, 128]\n assert candidate(n = 960) == [1, 513, 257, 769, 129, 641, 385, 897, 65, 577, 321, 833, 193, 705, 449, 33, 545, 289, 801, 161, 673, 417, 929, 97, 609, 353, 865, 225, 737, 481, 17, 529, 273, 785, 145, 657, 401, 913, 81, 593, 337, 849, 209, 721, 465, 49, 561, 305, 817, 177, 689, 433, 945, 113, 625, 369, 881, 241, 753, 497, 9, 521, 265, 777, 137, 649, 393, 905, 73, 585, 329, 841, 201, 713, 457, 41, 553, 297, 809, 169, 681, 425, 937, 105, 617, 361, 873, 233, 745, 489, 25, 537, 281, 793, 153, 665, 409, 921, 89, 601, 345, 857, 217, 729, 473, 57, 569, 313, 825, 185, 697, 441, 953, 121, 633, 377, 889, 249, 761, 505, 5, 517, 261, 773, 133, 645, 389, 901, 69, 581, 325, 837, 197, 709, 453, 37, 549, 293, 805, 165, 677, 421, 933, 101, 613, 357, 869, 229, 741, 485, 21, 533, 277, 789, 149, 661, 405, 917, 85, 597, 341, 853, 213, 725, 469, 53, 565, 309, 821, 181, 693, 437, 949, 117, 629, 373, 885, 245, 757, 501, 13, 525, 269, 781, 141, 653, 397, 909, 77, 589, 333, 845, 205, 717, 461, 45, 557, 301, 813, 173, 685, 429, 941, 109, 621, 365, 877, 237, 749, 493, 29, 541, 285, 797, 157, 669, 413, 925, 93, 605, 349, 861, 221, 733, 477, 61, 573, 317, 829, 189, 701, 445, 957, 125, 637, 381, 893, 253, 765, 509, 3, 515, 259, 771, 131, 643, 387, 899, 67, 579, 323, 835, 195, 707, 451, 35, 547, 291, 803, 163, 675, 419, 931, 99, 611, 355, 867, 227, 739, 483, 19, 531, 275, 787, 147, 659, 403, 915, 83, 595, 339, 851, 211, 723, 467, 51, 563, 307, 819, 179, 691, 435, 947, 115, 627, 371, 883, 243, 755, 499, 11, 523, 267, 779, 139, 651, 395, 907, 75, 587, 331, 843, 203, 715, 459, 43, 555, 299, 811, 171, 683, 427, 939, 107, 619, 363, 875, 235, 747, 491, 27, 539, 283, 795, 155, 667, 411, 923, 91, 603, 347, 859, 219, 731, 475, 59, 571, 315, 827, 187, 699, 443, 955, 123, 635, 379, 891, 251, 763, 507, 7, 519, 263, 775, 135, 647, 391, 903, 71, 583, 327, 839, 199, 711, 455, 39, 551, 295, 807, 167, 679, 423, 935, 103, 615, 359, 871, 231, 743, 487, 23, 535, 279, 791, 151, 663, 407, 919, 87, 599, 343, 855, 215, 727, 471, 55, 567, 311, 823, 183, 695, 439, 951, 119, 631, 375, 887, 247, 759, 503, 15, 527, 271, 783, 143, 655, 399, 911, 79, 591, 335, 847, 207, 719, 463, 47, 559, 303, 815, 175, 687, 431, 943, 111, 623, 367, 879, 239, 751, 495, 31, 543, 287, 799, 159, 671, 415, 927, 95, 607, 351, 863, 223, 735, 479, 63, 575, 319, 831, 191, 703, 447, 959, 127, 639, 383, 895, 255, 767, 511, 2, 514, 258, 770, 130, 642, 386, 898, 66, 578, 322, 834, 194, 706, 450, 34, 546, 290, 802, 162, 674, 418, 930, 98, 610, 354, 866, 226, 738, 482, 18, 530, 274, 786, 146, 658, 402, 914, 82, 594, 338, 850, 210, 722, 466, 50, 562, 306, 818, 178, 690, 434, 946, 114, 626, 370, 882, 242, 754, 498, 10, 522, 266, 778, 138, 650, 394, 906, 74, 586, 330, 842, 202, 714, 458, 42, 554, 298, 810, 170, 682, 426, 938, 106, 618, 362, 874, 234, 746, 490, 26, 538, 282, 794, 154, 666, 410, 922, 90, 602, 346, 858, 218, 730, 474, 58, 570, 314, 826, 186, 698, 442, 954, 122, 634, 378, 890, 250, 762, 506, 6, 518, 262, 774, 134, 646, 390, 902, 70, 582, 326, 838, 198, 710, 454, 38, 550, 294, 806, 166, 678, 422, 934, 102, 614, 358, 870, 230, 742, 486, 22, 534, 278, 790, 150, 662, 406, 918, 86, 598, 342, 854, 214, 726, 470, 54, 566, 310, 822, 182, 694, 438, 950, 118, 630, 374, 886, 246, 758, 502, 14, 526, 270, 782, 142, 654, 398, 910, 78, 590, 334, 846, 206, 718, 462, 46, 558, 302, 814, 174, 686, 430, 942, 110, 622, 366, 878, 238, 750, 494, 30, 542, 286, 798, 158, 670, 414, 926, 94, 606, 350, 862, 222, 734, 478, 62, 574, 318, 830, 190, 702, 446, 958, 126, 638, 382, 894, 254, 766, 510, 4, 516, 260, 772, 132, 644, 388, 900, 68, 580, 324, 836, 196, 708, 452, 36, 548, 292, 804, 164, 676, 420, 932, 100, 612, 356, 868, 228, 740, 484, 20, 532, 276, 788, 148, 660, 404, 916, 84, 596, 340, 852, 212, 724, 468, 52, 564, 308, 820, 180, 692, 436, 948, 116, 628, 372, 884, 244, 756, 500, 12, 524, 268, 780, 140, 652, 396, 908, 76, 588, 332, 844, 204, 716, 460, 44, 556, 300, 812, 172, 684, 428, 940, 108, 620, 364, 876, 236, 748, 492, 28, 540, 284, 796, 156, 668, 412, 924, 92, 604, 348, 860, 220, 732, 476, 60, 572, 316, 828, 188, 700, 444, 956, 124, 636, 380, 892, 252, 764, 508, 8, 520, 264, 776, 136, 648, 392, 904, 72, 584, 328, 840, 200, 712, 456, 40, 552, 296, 808, 168, 680, 424, 936, 104, 616, 360, 872, 232, 744, 488, 24, 536, 280, 792, 152, 664, 408, 920, 88, 600, 344, 856, 216, 728, 472, 56, 568, 312, 824, 184, 696, 440, 952, 120, 632, 376, 888, 248, 760, 504, 16, 528, 272, 784, 144, 656, 400, 912, 80, 592, 336, 848, 208, 720, 464, 48, 560, 304, 816, 176, 688, 432, 944, 112, 624, 368, 880, 240, 752, 496, 32, 544, 288, 800, 160, 672, 416, 928, 96, 608, 352, 864, 224, 736, 480, 64, 576, 320, 832, 192, 704, 448, 960, 128, 640, 384, 896, 256, 768, 512]\n assert candidate(n = 41) == [1, 33, 17, 9, 41, 25, 5, 37, 21, 13, 29, 3, 35, 19, 11, 27, 7, 39, 23, 15, 31, 2, 34, 18, 10, 26, 6, 38, 22, 14, 30, 4, 36, 20, 12, 28, 8, 40, 24, 16, 32]\n assert candidate(n = 31) == [1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 2, 18, 10, 26, 6, 22, 14, 30, 4, 20, 12, 28, 8, 24, 16]\n assert candidate(n = 400) == [1, 257, 129, 385, 65, 321, 193, 33, 289, 161, 97, 353, 225, 17, 273, 145, 81, 337, 209, 49, 305, 177, 113, 369, 241, 9, 265, 137, 393, 73, 329, 201, 41, 297, 169, 105, 361, 233, 25, 281, 153, 89, 345, 217, 57, 313, 185, 121, 377, 249, 5, 261, 133, 389, 69, 325, 197, 37, 293, 165, 101, 357, 229, 21, 277, 149, 85, 341, 213, 53, 309, 181, 117, 373, 245, 13, 269, 141, 397, 77, 333, 205, 45, 301, 173, 109, 365, 237, 29, 285, 157, 93, 349, 221, 61, 317, 189, 125, 381, 253, 3, 259, 131, 387, 67, 323, 195, 35, 291, 163, 99, 355, 227, 19, 275, 147, 83, 339, 211, 51, 307, 179, 115, 371, 243, 11, 267, 139, 395, 75, 331, 203, 43, 299, 171, 107, 363, 235, 27, 283, 155, 91, 347, 219, 59, 315, 187, 123, 379, 251, 7, 263, 135, 391, 71, 327, 199, 39, 295, 167, 103, 359, 231, 23, 279, 151, 87, 343, 215, 55, 311, 183, 119, 375, 247, 15, 271, 143, 399, 79, 335, 207, 47, 303, 175, 111, 367, 239, 31, 287, 159, 95, 351, 223, 63, 319, 191, 127, 383, 255, 2, 258, 130, 386, 66, 322, 194, 34, 290, 162, 98, 354, 226, 18, 274, 146, 82, 338, 210, 50, 306, 178, 114, 370, 242, 10, 266, 138, 394, 74, 330, 202, 42, 298, 170, 106, 362, 234, 26, 282, 154, 90, 346, 218, 58, 314, 186, 122, 378, 250, 6, 262, 134, 390, 70, 326, 198, 38, 294, 166, 102, 358, 230, 22, 278, 150, 86, 342, 214, 54, 310, 182, 118, 374, 246, 14, 270, 142, 398, 78, 334, 206, 46, 302, 174, 110, 366, 238, 30, 286, 158, 94, 350, 222, 62, 318, 190, 126, 382, 254, 4, 260, 132, 388, 68, 324, 196, 36, 292, 164, 100, 356, 228, 20, 276, 148, 84, 340, 212, 52, 308, 180, 116, 372, 244, 12, 268, 140, 396, 76, 332, 204, 44, 300, 172, 108, 364, 236, 28, 284, 156, 92, 348, 220, 60, 316, 188, 124, 380, 252, 8, 264, 136, 392, 72, 328, 200, 40, 296, 168, 104, 360, 232, 24, 280, 152, 88, 344, 216, 56, 312, 184, 120, 376, 248, 16, 272, 144, 400, 80, 336, 208, 48, 304, 176, 112, 368, 240, 32, 288, 160, 96, 352, 224, 64, 320, 192, 128, 384, 256]\n assert candidate(n = 750) == [1, 513, 257, 129, 641, 385, 65, 577, 321, 193, 705, 449, 33, 545, 289, 161, 673, 417, 97, 609, 353, 225, 737, 481, 17, 529, 273, 145, 657, 401, 81, 593, 337, 209, 721, 465, 49, 561, 305, 177, 689, 433, 113, 625, 369, 241, 497, 9, 521, 265, 137, 649, 393, 73, 585, 329, 201, 713, 457, 41, 553, 297, 169, 681, 425, 105, 617, 361, 233, 745, 489, 25, 537, 281, 153, 665, 409, 89, 601, 345, 217, 729, 473, 57, 569, 313, 185, 697, 441, 121, 633, 377, 249, 505, 5, 517, 261, 133, 645, 389, 69, 581, 325, 197, 709, 453, 37, 549, 293, 165, 677, 421, 101, 613, 357, 229, 741, 485, 21, 533, 277, 149, 661, 405, 85, 597, 341, 213, 725, 469, 53, 565, 309, 181, 693, 437, 117, 629, 373, 245, 501, 13, 525, 269, 141, 653, 397, 77, 589, 333, 205, 717, 461, 45, 557, 301, 173, 685, 429, 109, 621, 365, 237, 749, 493, 29, 541, 285, 157, 669, 413, 93, 605, 349, 221, 733, 477, 61, 573, 317, 189, 701, 445, 125, 637, 381, 253, 509, 3, 515, 259, 131, 643, 387, 67, 579, 323, 195, 707, 451, 35, 547, 291, 163, 675, 419, 99, 611, 355, 227, 739, 483, 19, 531, 275, 147, 659, 403, 83, 595, 339, 211, 723, 467, 51, 563, 307, 179, 691, 435, 115, 627, 371, 243, 499, 11, 523, 267, 139, 651, 395, 75, 587, 331, 203, 715, 459, 43, 555, 299, 171, 683, 427, 107, 619, 363, 235, 747, 491, 27, 539, 283, 155, 667, 411, 91, 603, 347, 219, 731, 475, 59, 571, 315, 187, 699, 443, 123, 635, 379, 251, 507, 7, 519, 263, 135, 647, 391, 71, 583, 327, 199, 711, 455, 39, 551, 295, 167, 679, 423, 103, 615, 359, 231, 743, 487, 23, 535, 279, 151, 663, 407, 87, 599, 343, 215, 727, 471, 55, 567, 311, 183, 695, 439, 119, 631, 375, 247, 503, 15, 527, 271, 143, 655, 399, 79, 591, 335, 207, 719, 463, 47, 559, 303, 175, 687, 431, 111, 623, 367, 239, 495, 31, 543, 287, 159, 671, 415, 95, 607, 351, 223, 735, 479, 63, 575, 319, 191, 703, 447, 127, 639, 383, 255, 511, 2, 514, 258, 130, 642, 386, 66, 578, 322, 194, 706, 450, 34, 546, 290, 162, 674, 418, 98, 610, 354, 226, 738, 482, 18, 530, 274, 146, 658, 402, 82, 594, 338, 210, 722, 466, 50, 562, 306, 178, 690, 434, 114, 626, 370, 242, 498, 10, 522, 266, 138, 650, 394, 74, 586, 330, 202, 714, 458, 42, 554, 298, 170, 682, 426, 106, 618, 362, 234, 746, 490, 26, 538, 282, 154, 666, 410, 90, 602, 346, 218, 730, 474, 58, 570, 314, 186, 698, 442, 122, 634, 378, 250, 506, 6, 518, 262, 134, 646, 390, 70, 582, 326, 198, 710, 454, 38, 550, 294, 166, 678, 422, 102, 614, 358, 230, 742, 486, 22, 534, 278, 150, 662, 406, 86, 598, 342, 214, 726, 470, 54, 566, 310, 182, 694, 438, 118, 630, 374, 246, 502, 14, 526, 270, 142, 654, 398, 78, 590, 334, 206, 718, 462, 46, 558, 302, 174, 686, 430, 110, 622, 366, 238, 750, 494, 30, 542, 286, 158, 670, 414, 94, 606, 350, 222, 734, 478, 62, 574, 318, 190, 702, 446, 126, 638, 382, 254, 510, 4, 516, 260, 132, 644, 388, 68, 580, 324, 196, 708, 452, 36, 548, 292, 164, 676, 420, 100, 612, 356, 228, 740, 484, 20, 532, 276, 148, 660, 404, 84, 596, 340, 212, 724, 468, 52, 564, 308, 180, 692, 436, 116, 628, 372, 244, 500, 12, 524, 268, 140, 652, 396, 76, 588, 332, 204, 716, 460, 44, 556, 300, 172, 684, 428, 108, 620, 364, 236, 748, 492, 28, 540, 284, 156, 668, 412, 92, 604, 348, 220, 732, 476, 60, 572, 316, 188, 700, 444, 124, 636, 380, 252, 508, 8, 520, 264, 136, 648, 392, 72, 584, 328, 200, 712, 456, 40, 552, 296, 168, 680, 424, 104, 616, 360, 232, 744, 488, 24, 536, 280, 152, 664, 408, 88, 600, 344, 216, 728, 472, 56, 568, 312, 184, 696, 440, 120, 632, 376, 248, 504, 16, 528, 272, 144, 656, 400, 80, 592, 336, 208, 720, 464, 48, 560, 304, 176, 688, 432, 112, 624, 368, 240, 496, 32, 544, 288, 160, 672, 416, 96, 608, 352, 224, 736, 480, 64, 576, 320, 192, 704, 448, 128, 640, 384, 256, 512]\n assert candidate(n = 120) == [1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 8, 72, 40, 104, 24, 88, 56, 120, 16, 80, 48, 112, 32, 96, 64]\n assert candidate(n = 499) == [1, 257, 129, 385, 65, 321, 193, 449, 33, 289, 161, 417, 97, 353, 225, 481, 17, 273, 145, 401, 81, 337, 209, 465, 49, 305, 177, 433, 113, 369, 241, 497, 9, 265, 137, 393, 73, 329, 201, 457, 41, 297, 169, 425, 105, 361, 233, 489, 25, 281, 153, 409, 89, 345, 217, 473, 57, 313, 185, 441, 121, 377, 249, 5, 261, 133, 389, 69, 325, 197, 453, 37, 293, 165, 421, 101, 357, 229, 485, 21, 277, 149, 405, 85, 341, 213, 469, 53, 309, 181, 437, 117, 373, 245, 13, 269, 141, 397, 77, 333, 205, 461, 45, 301, 173, 429, 109, 365, 237, 493, 29, 285, 157, 413, 93, 349, 221, 477, 61, 317, 189, 445, 125, 381, 253, 3, 259, 131, 387, 67, 323, 195, 451, 35, 291, 163, 419, 99, 355, 227, 483, 19, 275, 147, 403, 83, 339, 211, 467, 51, 307, 179, 435, 115, 371, 243, 499, 11, 267, 139, 395, 75, 331, 203, 459, 43, 299, 171, 427, 107, 363, 235, 491, 27, 283, 155, 411, 91, 347, 219, 475, 59, 315, 187, 443, 123, 379, 251, 7, 263, 135, 391, 71, 327, 199, 455, 39, 295, 167, 423, 103, 359, 231, 487, 23, 279, 151, 407, 87, 343, 215, 471, 55, 311, 183, 439, 119, 375, 247, 15, 271, 143, 399, 79, 335, 207, 463, 47, 303, 175, 431, 111, 367, 239, 495, 31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 2, 258, 130, 386, 66, 322, 194, 450, 34, 290, 162, 418, 98, 354, 226, 482, 18, 274, 146, 402, 82, 338, 210, 466, 50, 306, 178, 434, 114, 370, 242, 498, 10, 266, 138, 394, 74, 330, 202, 458, 42, 298, 170, 426, 106, 362, 234, 490, 26, 282, 154, 410, 90, 346, 218, 474, 58, 314, 186, 442, 122, 378, 250, 6, 262, 134, 390, 70, 326, 198, 454, 38, 294, 166, 422, 102, 358, 230, 486, 22, 278, 150, 406, 86, 342, 214, 470, 54, 310, 182, 438, 118, 374, 246, 14, 270, 142, 398, 78, 334, 206, 462, 46, 302, 174, 430, 110, 366, 238, 494, 30, 286, 158, 414, 94, 350, 222, 478, 62, 318, 190, 446, 126, 382, 254, 4, 260, 132, 388, 68, 324, 196, 452, 36, 292, 164, 420, 100, 356, 228, 484, 20, 276, 148, 404, 84, 340, 212, 468, 52, 308, 180, 436, 116, 372, 244, 12, 268, 140, 396, 76, 332, 204, 460, 44, 300, 172, 428, 108, 364, 236, 492, 28, 284, 156, 412, 92, 348, 220, 476, 60, 316, 188, 444, 124, 380, 252, 8, 264, 136, 392, 72, 328, 200, 456, 40, 296, 168, 424, 104, 360, 232, 488, 24, 280, 152, 408, 88, 344, 216, 472, 56, 312, 184, 440, 120, 376, 248, 16, 272, 144, 400, 80, 336, 208, 464, 48, 304, 176, 432, 112, 368, 240, 496, 32, 288, 160, 416, 96, 352, 224, 480, 64, 320, 192, 448, 128, 384, 256]\n assert candidate(n = 13) == [1, 9, 5, 13, 3, 11, 7, 2, 10, 6, 4, 12, 8]\n assert candidate(n = 25) == [1, 17, 9, 25, 5, 21, 13, 3, 19, 11, 7, 23, 15, 2, 18, 10, 6, 22, 14, 4, 20, 12, 8, 24, 16]\n", "comparison": "exact"}, "public_tests": ["4", "5"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().beautifulArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:37+00:00", "tests_total": 58, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math", "divide-and-conquer"]}, "language": "python", "interface": {"raw_signature": "def beautifulArray(self, n: int) -> list[int]:", "container": "Solution", "callable": "beautifulArray", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 934, "task_id": "shortest-bridge", "difficulty": "Medium", "problem_description": "You are given an n x n binary matrix grid where 1 represents land and 0 represents water.\n\nAn island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid.\n\nYou may change 0's to 1's to connect the two islands to form one island.\n\nReturn the smallest number of 0's you must flip to connect the two islands.\n\nExample 1:\n\nInput: grid = [[0,1],[1,0]]\nOutput: 1\n\nExample 2:\n\nInput: grid = [[0,1,0],[0,0,0],[0,0,1]]\nOutput: 2\n\nExample 3:\n\nInput: grid = [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]\nOutput: 1\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 2 <= n <= 100\n- grid[i][j] is either 0 or 1.\n- There are exactly two islands in grid.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1], [1, 0]]) == 1\n assert candidate(grid = [[0, 1, 0], [0, 0, 0], [0, 0, 1]]) == 2\n assert candidate(grid = [[0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 0, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 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, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[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, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 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, 0, 0, 0, 0, 0, 0, 1]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 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]]) == 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, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 0]]) == 1\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, 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, 1], [0, 0, 0, 0, 0, 0, 1, 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, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0]]) == 4\n assert candidate(grid = [[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, 1, 1], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1]]) == 3\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, 1], [0, 0, 0, 0, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 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, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 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, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 3\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]) == 1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1], [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], [1, 0, 0, 0, 0, 0, 1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1, 1], [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, 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, 1]]) == 7\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [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]]) == 5\n assert candidate(grid = [[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]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [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]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1, 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, 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]]) == 3\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 1, 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, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == 3\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]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 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, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0]]) == 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [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]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 0, 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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0, 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\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,0]]", "[[0,1,0],[0,0,0],[0,0,1]]", "[[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().shortestBridge", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:40+00:00", "tests_total": 52, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def shortestBridge(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "shortestBridge", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 935, "task_id": "knight-dialer", "difficulty": "Medium", "problem_description": "The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an L). The possible movements of chess knight are shown in this diagram:\n\nA chess knight can move as indicated in the chess diagram below:\n\nWe have a chess knight and a phone pad as shown below, the knight can only stand on a numeric cell (i.e. blue cell).\n\nGiven an integer n, return how many distinct phone numbers of length n we can dial.\n\nYou are allowed to place the knight on any numeric cell initially and then you should perform n - 1 jumps to dial a number of length n. All jumps should be valid knight jumps.\n\nAs the answer may be very large, return the answer modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 1\nOutput: 10\nExplanation: We need to dial a number of length 1, so placing the knight over any numeric cell of the 10 cells is sufficient.\n\nExample 2:\n\nInput: n = 2\nOutput: 20\nExplanation: All the valid number we can dial are [04, 06, 16, 18, 27, 29, 34, 38, 40, 43, 49, 60, 61, 67, 72, 76, 81, 83, 92, 94]\n\nExample 3:\n\nInput: n = 3131\nOutput: 136006598\nExplanation: Please take care of the mod.\n\nConstraints:\n\n- 1 <= n <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 46\n assert candidate(n = 100) == 540641702\n assert candidate(n = 50) == 267287516\n assert candidate(n = 2500) == 851996060\n assert candidate(n = 5000) == 406880451\n assert candidate(n = 2) == 20\n assert candidate(n = 1) == 10\n assert candidate(n = 500) == 84202957\n assert candidate(n = 1000) == 88106097\n assert candidate(n = 10) == 14912\n assert candidate(n = 5) == 240\n assert candidate(n = 3131) == 136006598\n assert candidate(n = 4000) == 315083963\n assert candidate(n = 1600) == 585618181\n assert candidate(n = 4750) == 955420830\n assert candidate(n = 4600) == 152432289\n assert candidate(n = 2000) == 71794716\n assert candidate(n = 3750) == 17358003\n assert candidate(n = 2400) == 248946071\n assert candidate(n = 3333) == 857043783\n assert candidate(n = 3500) == 624537543\n assert candidate(n = 3000) == 447863713\n assert candidate(n = 30) == 986742198\n assert candidate(n = 1200) == 823605881\n assert candidate(n = 4900) == 790356323\n assert candidate(n = 2750) == 49052199\n assert candidate(n = 1800) == 159765442\n assert candidate(n = 2800) == 779464575\n assert candidate(n = 250) == 296754066\n assert candidate(n = 4250) == 12437801\n assert candidate(n = 20) == 58689536\n assert candidate(n = 1250) == 926597988\n assert candidate(n = 3132) == 915594565\n assert candidate(n = 800) == 709497038\n assert candidate(n = 15) == 944000\n assert candidate(n = 4999) == 659158877\n assert candidate(n = 200) == 38950354\n assert candidate(n = 400) == 23117445\n assert candidate(n = 1234) == 758728301\n assert candidate(n = 750) == 185434245\n assert candidate(n = 4500) == 756988614\n assert candidate(n = 1500) == 487569438\n", "comparison": "exact"}, "public_tests": ["1", "2", "3131"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().knightDialer", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:42+00:00", "tests_total": 42, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def knightDialer(self, n: int) -> int:", "container": "Solution", "callable": "knightDialer", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 936, "task_id": "stamping-the-sequence", "difficulty": "Hard", "problem_description": "You are given two strings stamp and target. Initially, there is a string s of length target.length with all s[i] == '?'.\n\nIn one turn, you can place stamp over s and replace every letter in the s with the corresponding letter from stamp.\n\n- For example, if stamp = \"abc\" and target = \"abcba\", then s is \"?????\" initially. In one turn you can:\n - place stamp at index 0 of s to obtain \"abc??\",\n - place stamp at index 1 of s to obtain \"?abc?\", or\n - place stamp at index 2 of s to obtain \"??abc\".\nNote that stamp must be fully contained in the boundaries of s in order to stamp (i.e., you cannot place stamp at index 3 of s).\n\nWe want to convert s to target using at most 10 * target.length turns.\n\nReturn an array of the index of the left-most letter being stamped at each turn. If we cannot obtain target from s within 10 * target.length turns, return an empty array.\n\nExample 1:\n\nInput: stamp = \"abc\", target = \"ababc\"\nOutput: [0,2]\nExplanation: Initially s = \"?????\".\n- Place stamp at index 0 to get \"abc??\".\n- Place stamp at index 2 to get \"ababc\".\n[1,0,2] would also be accepted as an answer, as well as some other answers.\n\nExample 2:\n\nInput: stamp = \"abca\", target = \"aabcaca\"\nOutput: [3,0,1]\nExplanation: Initially s = \"???????\".\n- Place stamp at index 3 to get \"???abca\".\n- Place stamp at index 0 to get \"abcabca\".\n- Place stamp at index 1 to get \"aabcaca\".\n\nConstraints:\n\n- 1 <= stamp.length <= target.length <= 1000\n- stamp and target consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stamp = \"world\",target = \"worldworldworld\") == [9, 8, 7, 6, 4, 3, 2, 1, 10, 5, 0]\n assert candidate(stamp = \"abc\",target = \"abcababcbcababc\") == [11, 9, 8, 6, 4, 2, 1, 10, 7, 3, 12, 5, 0]\n assert candidate(stamp = \"abcde\",target = \"abcdeabcde\") == [4, 3, 2, 1, 5, 0]\n assert candidate(stamp = \"a\",target = \"aaaaaaaa\") == [7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"abcde\",target = \"abcdeabcdeabcde\") == [9, 8, 7, 6, 4, 3, 2, 1, 10, 5, 0]\n assert candidate(stamp = \"hello\",target = \"hellohellohello\") == [9, 8, 7, 6, 4, 3, 2, 1, 10, 5, 0]\n assert candidate(stamp = \"ab\",target = \"abababab\") == [5, 3, 1, 6, 4, 2, 0]\n assert candidate(stamp = \"abcdef\",target = \"abcdefabcdef\") == [5, 4, 3, 2, 1, 6, 0]\n assert candidate(stamp = \"a\",target = \"aaaaaaaaa\") == [8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"abc\",target = \"abcabcabc\") == [5, 4, 2, 1, 6, 3, 0]\n assert candidate(stamp = \"abc\",target = \"abcabc\") == [2, 1, 3, 0]\n assert candidate(stamp = \"a\",target = \"aaaaaaaaaa\") == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"test\",target = \"testtesttest\") == [7, 6, 5, 3, 2, 1, 8, 4, 0]\n assert candidate(stamp = \"abcd\",target = \"abcdabcd\") == [3, 2, 1, 4, 0]\n assert candidate(stamp = \"abca\",target = \"aabcaca\") == [2, 3, 0, 1]\n assert candidate(stamp = \"abc\",target = \"ababc\") == [1, 0, 2]\n assert candidate(stamp = \"xyz\",target = \"xyzxyzxyz\") == [5, 4, 2, 1, 6, 3, 0]\n assert candidate(stamp = \"abc\",target = \"abcabcabcabcabc\") == [11, 10, 8, 7, 5, 4, 2, 1, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"abcde\",target = \"abcde\") == [0]\n assert candidate(stamp = \"abc\",target = \"ababcbababcbababc\") == [11, 9, 5, 3, 13, 10, 7, 4, 1, 12, 6, 0, 14, 8, 2]\n assert candidate(stamp = \"mnopqr\",target = \"mnopqrmnopqrmnopqrmnopqrmnopqr\") == [23, 22, 21, 20, 19, 17, 16, 15, 14, 13, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 24, 18, 12, 6, 0]\n assert candidate(stamp = \"efgh\",target = \"efghefghefghefghefghefghefgh\") == [23, 22, 21, 19, 18, 17, 15, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 24, 20, 16, 12, 8, 4, 0]\n assert candidate(stamp = \"aabbcc\",target = \"aabbccaaabbccaaabbcc\") == [11, 10, 9, 8, 4, 3, 2, 1, 13, 12, 6, 5, 14, 7, 0]\n assert candidate(stamp = \"abcd\",target = \"ddddddddddddddddddddddddddddabcd\") == []\n assert candidate(stamp = \"xyz\",target = \"xyxyxyxyxyxyxyxyxyxy\") == []\n assert candidate(stamp = \"zzz\",target = \"zzzzzzzzzzzzzzzzzzzz\") == [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"abcdef\",target = \"abcdefabcdefabcdefabcdefabcdefabcdef\") == [29, 28, 27, 26, 25, 23, 22, 21, 20, 19, 17, 16, 15, 14, 13, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 30, 24, 18, 12, 6, 0]\n assert candidate(stamp = \"xyz\",target = \"xyxyxyxyxyxyxyxyxyxyxyx\") == []\n assert candidate(stamp = \"abcabc\",target = \"abcabcabcabcabcabcabcd\") == []\n assert candidate(stamp = \"aabbcc\",target = \"aabbccaaabbccaaabbccaaabbcc\") == [18, 17, 16, 15, 11, 10, 9, 8, 4, 3, 2, 1, 20, 19, 13, 12, 6, 5, 21, 14, 7, 0]\n assert candidate(stamp = \"xyz\",target = \"xyzxyzxyzxyzxyz\") == [11, 10, 8, 7, 5, 4, 2, 1, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"abcd\",target = \"abcdabcdeabcdabcd\") == []\n assert candidate(stamp = \"aaaa\",target = \"aaaaaaaaaaaaaaaa\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"abcde\",target = \"abcdeabcdeabcdeabcdef\") == []\n assert candidate(stamp = \"abc\",target = \"xyzabcxyzabcxyz\") == []\n assert candidate(stamp = \"abcd\",target = \"abcdabcdabcdabcd\") == [11, 10, 9, 7, 6, 5, 3, 2, 1, 12, 8, 4, 0]\n assert candidate(stamp = \"xyz\",target = \"xyzxyzxyzxyz\") == [8, 7, 5, 4, 2, 1, 9, 6, 3, 0]\n assert candidate(stamp = \"qrstuv\",target = \"qrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuv\") == [35, 34, 33, 32, 31, 29, 28, 27, 26, 25, 23, 22, 21, 20, 19, 17, 16, 15, 14, 13, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 36, 30, 24, 18, 12, 6, 0]\n assert candidate(stamp = \"aaa\",target = \"aaaaaaaaaaaaaaaaaaaa\") == [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"a\",target = \"aaaaaaaaaaaaaaaaaaaa\") == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(stamp = \"xyzabc\",target = \"xyzabcxyzabcxyzabcxyzabc\") == [17, 16, 15, 14, 13, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 18, 12, 6, 0]\n assert candidate(stamp = \"abcabc\",target = \"abcabcabcabcabcabcabc\") == [14, 13, 11, 10, 8, 7, 5, 4, 2, 1, 15, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"abcde\",target = \"edcbaedcbaedcba\") == []\n assert candidate(stamp = \"abcabc\",target = \"abcabcabcabcabcabcabcabc\") == [17, 16, 14, 13, 11, 10, 8, 7, 5, 4, 2, 1, 18, 15, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"xyz\",target = \"xyzxyzxyzxyzxyzxyz\") == [14, 13, 11, 10, 8, 7, 5, 4, 2, 1, 15, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"qrst\",target = \"qrstqrstqrstqrstqrstqrstqrstqrst\") == [27, 26, 25, 23, 22, 21, 19, 18, 17, 15, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 28, 24, 20, 16, 12, 8, 4, 0]\n assert candidate(stamp = \"mnop\",target = \"mnopmnopmnopmnopmnopmnopmnopmnop\") == [27, 26, 25, 23, 22, 21, 19, 18, 17, 15, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 28, 24, 20, 16, 12, 8, 4, 0]\n assert candidate(stamp = \"abc\",target = \"abcabcabcabcabcabc\") == [14, 13, 11, 10, 8, 7, 5, 4, 2, 1, 15, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"abac\",target = \"abacabacabacabacabac\") == [15, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 16, 12, 8, 4, 0]\n assert candidate(stamp = \"abc\",target = \"aaaaaaaaaaabcabcaaaaaaaaaa\") == []\n assert candidate(stamp = \"ab\",target = \"abababababababababab\") == [17, 15, 13, 11, 9, 7, 5, 3, 1, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(stamp = \"stamp\",target = \"stampstampstamp\") == [9, 8, 7, 6, 4, 3, 2, 1, 10, 5, 0]\n assert candidate(stamp = \"abcdefg\",target = \"abcdefgabcdefgabcdefgabcdefg\") == [20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 21, 14, 7, 0]\n assert candidate(stamp = \"abcde\",target = \"abcdeabcdeabcdeabcdeabc\") == []\n assert candidate(stamp = \"abab\",target = \"abababababababab\") == [11, 9, 7, 5, 3, 1, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(stamp = \"ab\",target = \"abaabaabaab\") == [7, 4, 1, 8, 5, 2, 9, 6, 3, 0]\n assert candidate(stamp = \"hello\",target = \"hellohellohellohello\") == [14, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1, 15, 10, 5, 0]\n assert candidate(stamp = \"mnopqr\",target = \"mnopqrnopqrmonpqrnonqrmpnoqrmnoprqmnopqr\") == []\n assert candidate(stamp = \"abc\",target = \"ababababababababc\") == [1, 3, 0, 5, 2, 7, 4, 9, 6, 11, 8, 13, 10, 12, 14]\n assert candidate(stamp = \"xyzxyz\",target = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == [29, 28, 26, 25, 23, 22, 20, 19, 17, 16, 14, 13, 11, 10, 8, 7, 5, 4, 2, 1, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0]\n assert candidate(stamp = \"hello\",target = \"hellohellohellohelloh\") == []\n assert candidate(stamp = \"abcd\",target = \"abcabcabcabc\") == []\n assert candidate(stamp = \"abcd\",target = \"abcdeabcd\") == []\n assert candidate(stamp = \"mnopqr\",target = \"mnopqrmnopqrmnopqr\") == [11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 12, 6, 0]\n assert candidate(stamp = \"aabbcc\",target = \"aabbccaaabbccaaabbccabc\") == []\n assert candidate(stamp = \"abcdef\",target = \"fedcbafedcbafedcba\") == []\n assert candidate(stamp = \"abcdef\",target = \"abcdefabcdefabcdefabcdef\") == [17, 16, 15, 14, 13, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 18, 12, 6, 0]\n assert candidate(stamp = \"stamp\",target = \"stampstampstampstam\") == []\n assert candidate(stamp = \"abcdefg\",target = \"abcdefgabcdefgabcdefgabcdefgabcdefgabcdefg\") == [34, 33, 32, 31, 30, 29, 27, 26, 25, 24, 23, 22, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 35, 28, 21, 14, 7, 0]\n assert candidate(stamp = \"abcd\",target = \"abcdabcdabcdabcdabcd\") == [15, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 16, 12, 8, 4, 0]\n assert candidate(stamp = \"abcd\",target = \"abcdabcabcd\") == [6, 5, 3, 2, 1, 4, 7, 0]\n assert candidate(stamp = \"xyzyx\",target = \"xyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyxyzyx\") == [67, 66, 65, 63, 62, 61, 59, 58, 57, 55, 54, 53, 51, 50, 49, 47, 46, 45, 43, 42, 41, 39, 38, 37, 35, 34, 33, 31, 30, 29, 27, 26, 25, 23, 22, 21, 19, 18, 17, 15, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 68, 64, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0]\n assert candidate(stamp = \"ab\",target = \"ababababababababababh\") == []\n assert candidate(stamp = \"abcde\",target = \"abcdeabcdeabcdeabcde\") == [14, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1, 15, 10, 5, 0]\n assert candidate(stamp = \"abcd\",target = \"dabcdabc\") == []\n assert candidate(stamp = \"aabbcc\",target = \"aabbccaabbccaaabbccaaabbccaaabbccaaabbcc\") == [31, 30, 29, 28, 24, 23, 22, 21, 17, 16, 15, 14, 10, 9, 8, 7, 33, 32, 26, 25, 19, 18, 12, 11, 5, 4, 3, 2, 1, 34, 27, 20, 13, 6, 0]\n assert candidate(stamp = \"aabbcc\",target = \"aabbccaabbccaabbcc\") == [11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 12, 6, 0]\n assert candidate(stamp = \"abcdef\",target = \"fedcbafedcbafedcbafedcbafedcbafedcbafedcba\") == []\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n\"ababc\"", "\"abca\"\n\"aabcaca\""], "hints": [], "metadata": {"canonical_parameter_names": ["stamp", "target"], "leetcode_dataset_entry_point": "Solution().movesToStamp", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:44+00:00", "tests_total": 88, "tests_dropped": 10, "flags": [], "topic_tags": ["string", "stack", "greedy", "queue"]}, "language": "python", "interface": {"raw_signature": "def movesToStamp(self, stamp: str, target: str) -> list[int]:", "container": "Solution", "callable": "movesToStamp", "parameters": [{"name": "stamp", "type": "str"}, {"name": "target", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 937, "task_id": "reorder-data-in-log-files", "difficulty": "Medium", "problem_description": "You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier.\n\nThere are two types of logs:\n\n- Letter-logs: All words (except the identifier) consist of lowercase English letters.\n- Digit-logs: All words (except the identifier) consist of digits.\n\nReorder these logs so that:\n\n1. The letter-logs come before all digit-logs.\n2. The letter-logs are sorted lexicographically by their contents. If their contents are the same, then sort them lexicographically by their identifiers.\n3. The digit-logs maintain their relative ordering.\n\nReturn the final order of the logs.\n\nExample 1:\n\nInput: logs = [\"dig1 8 1 5 1\",\"let1 art can\",\"dig2 3 6\",\"let2 own kit dig\",\"let3 art zero\"]\nOutput: [\"let1 art can\",\"let3 art zero\",\"let2 own kit dig\",\"dig1 8 1 5 1\",\"dig2 3 6\"]\nExplanation:\nThe letter-log contents are all different, so their ordering is \"art can\", \"art zero\", \"own kit dig\".\nThe digit-logs have a relative order of \"dig1 8 1 5 1\", \"dig2 3 6\".\n\nExample 2:\n\nInput: logs = [\"a1 9 2 3 1\",\"g1 act car\",\"zo4 4 7\",\"ab1 off key dog\",\"a8 act zoo\"]\nOutput: [\"g1 act car\",\"a8 act zoo\",\"ab1 off key dog\",\"a1 9 2 3 1\",\"zo4 4 7\"]\n\nConstraints:\n\n- 1 <= logs.length <= 100\n- 3 <= logs[i].length <= 100\n- All the tokens of logs[i] are separated by a single space.\n- logs[i] is guaranteed to have an identifier and at least one word after the identifier.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = ['dig1 8 1 5 1', 'let1 art can', 'dig2 3 6', 'let2 own kit dig', 'let3 art zero']) == ['let1 art can', 'let3 art zero', 'let2 own kit dig', 'dig1 8 1 5 1', 'dig2 3 6']\n assert candidate(logs = ['a1 9 2 3 1', 'g1 act car', 'zo4 4 7', 'ab1 off key dog', 'a8 act zoo']) == ['g1 act car', 'a8 act zoo', 'ab1 off key dog', 'a1 9 2 3 1', 'zo4 4 7']\n assert candidate(logs = ['x1 2 3', 'y1 2 4', 'z1 2 5', 'a1 act car', 'b1 act zoo', 'c1 off key dog', 'd1 art can', 'e1 8 1 5 1', 'f1 own kit dig', 'g1 art zero', 'h1 3 6', 'i1 act car', 'j1 act zoo', 'k1 off key dog', 'l1 art can', 'm1 8 1 5 1', 'n1 own kit dig', 'o1 art zero', 'p1 3 6']) == ['a1 act car', 'i1 act car', 'b1 act zoo', 'j1 act zoo', 'd1 art can', 'l1 art can', 'g1 art zero', 'o1 art zero', 'c1 off key dog', 'k1 off key dog', 'f1 own kit dig', 'n1 own kit dig', 'x1 2 3', 'y1 2 4', 'z1 2 5', 'e1 8 1 5 1', 'h1 3 6', 'm1 8 1 5 1', 'p1 3 6']\n assert candidate(logs = ['log1 123', 'log2 def', 'log3 def', 'log4 def', 'log5 abc', 'log6 abc', 'log7 abc', 'log8 abc', 'log9 xyz', 'log10 xyz', 'log11 xyz', 'log12 xyz', 'log13 xyz', 'log14 xyz', 'log15 xyz', 'log16 xyz', 'log17 xyz', 'log18 xyz', 'log19 xyz', 'log20 xyz', 'log21 xyz', 'log22 xyz', 'log23 xyz', 'log24 xyz', 'log25 xyz', 'log26 xyz', 'log27 xyz', 'log28 xyz', 'log29 xyz', 'log30 xyz', 'log31 xyz', 'log32 xyz', 'log33 xyz', 'log34 xyz', 'log35 xyz', 'log36 xyz', 'log37 xyz', 'log38 xyz', 'log39 xyz', 'log40 xyz', 'log41 xyz', 'log42 xyz', 'log43 xyz', 'log44 xyz', 'log45 xyz', 'log46 xyz', 'log47 xyz', 'log48 xyz', 'log49 xyz', 'log50 xyz', 'log51 456', 'd1 1', 'd2 2', 'd3 3', 'd4 4', 'd5 5', 'd6 6', 'd7 7', 'd8 8', 'd9 9', 'd10 10']) == ['log5 abc', 'log6 abc', 'log7 abc', 'log8 abc', 'log2 def', 'log3 def', 'log4 def', 'log10 xyz', 'log11 xyz', 'log12 xyz', 'log13 xyz', 'log14 xyz', 'log15 xyz', 'log16 xyz', 'log17 xyz', 'log18 xyz', 'log19 xyz', 'log20 xyz', 'log21 xyz', 'log22 xyz', 'log23 xyz', 'log24 xyz', 'log25 xyz', 'log26 xyz', 'log27 xyz', 'log28 xyz', 'log29 xyz', 'log30 xyz', 'log31 xyz', 'log32 xyz', 'log33 xyz', 'log34 xyz', 'log35 xyz', 'log36 xyz', 'log37 xyz', 'log38 xyz', 'log39 xyz', 'log40 xyz', 'log41 xyz', 'log42 xyz', 'log43 xyz', 'log44 xyz', 'log45 xyz', 'log46 xyz', 'log47 xyz', 'log48 xyz', 'log49 xyz', 'log50 xyz', 'log9 xyz', 'log1 123', 'log51 456', 'd1 1', 'd2 2', 'd3 3', 'd4 4', 'd5 5', 'd6 6', 'd7 7', 'd8 8', 'd9 9', 'd10 10']\n assert candidate(logs = ['f1 10 20 30', 'e2 9 18 27', 'd3 8 16 24', 'c4 7 14 21', 'b5 6 12 18', 'a6 5 10 15', 'z7 4 8 12', 'y8 3 6 9', 'x9 2 4 6', 'w10 1 2 3', 'v11 11 22 33', 'u12 10 20 30']) == ['f1 10 20 30', 'e2 9 18 27', 'd3 8 16 24', 'c4 7 14 21', 'b5 6 12 18', 'a6 5 10 15', 'z7 4 8 12', 'y8 3 6 9', 'x9 2 4 6', 'w10 1 2 3', 'v11 11 22 33', 'u12 10 20 30']\n assert candidate(logs = ['z1 1 1', 'y2 2 2', 'x3 3 3', 'w4 4 4', 'v5 5 5', 'u6 6 6', 't7 7 7', 's8 8 8', 'r9 9 9', 'q10 10 10', 'p11 11 11', 'o12 12 12', 'n13 13 13', 'm14 14 14', 'l15 15 15', 'k16 16 16', 'j17 17 17', 'i18 18 18', 'h19 19 19', 'g20 20 20', 'f21 21 21', 'e22 22 22', 'd23 23 23', 'c24 24 24', 'b25 25 25', 'a26 abc', 'a27 def', 'a28 ghi', 'a29 jkl', 'a30 mno']) == ['a26 abc', 'a27 def', 'a28 ghi', 'a29 jkl', 'a30 mno', 'z1 1 1', 'y2 2 2', 'x3 3 3', 'w4 4 4', 'v5 5 5', 'u6 6 6', 't7 7 7', 's8 8 8', 'r9 9 9', 'q10 10 10', 'p11 11 11', 'o12 12 12', 'n13 13 13', 'm14 14 14', 'l15 15 15', 'k16 16 16', 'j17 17 17', 'i18 18 18', 'h19 19 19', 'g20 20 20', 'f21 21 21', 'e22 22 22', 'd23 23 23', 'c24 24 24', 'b25 25 25']\n assert candidate(logs = ['log6 123 456', 'log5 789', 'log4 abc def', 'log3 xyz', 'log2 mno pqr', 'log1 def ghi', 'log0 def']) == ['log4 abc def', 'log0 def', 'log1 def ghi', 'log2 mno pqr', 'log3 xyz', 'log6 123 456', 'log5 789']\n assert candidate(logs = ['a1 abc def', 'b2 def abc', 'c3 abc abc', 'd1 1 2 3', 'e2 4 5 6', 'f3 7 8 9', 'g4 1 2 3 4', 'h5 5 6 7 8', 'i6 9 0 1 2', 'j7 3 4 5 6', 'k8 7 8 9 0', 'l9 1 2 3 4 5', 'm10 5 6 7 8 9', 'n11 9 0 1 2 3', 'o12 3 4 5 6 7', 'p13 7 8 9 0 1', 'q14 1 2 3 4 5 6', 'r15 5 6 7 8 9 0', 's16 9 0 1 2 3 4', 't17 3 4 5 6 7 8', 'u18 7 8 9 0 1 2', 'v19 1 2 3 4 5 6 7', 'w20 5 6 7 8 9 0 1']) == ['c3 abc abc', 'a1 abc def', 'b2 def abc', 'd1 1 2 3', 'e2 4 5 6', 'f3 7 8 9', 'g4 1 2 3 4', 'h5 5 6 7 8', 'i6 9 0 1 2', 'j7 3 4 5 6', 'k8 7 8 9 0', 'l9 1 2 3 4 5', 'm10 5 6 7 8 9', 'n11 9 0 1 2 3', 'o12 3 4 5 6 7', 'p13 7 8 9 0 1', 'q14 1 2 3 4 5 6', 'r15 5 6 7 8 9 0', 's16 9 0 1 2 3 4', 't17 3 4 5 6 7 8', 'u18 7 8 9 0 1 2', 'v19 1 2 3 4 5 6 7', 'w20 5 6 7 8 9 0 1']\n assert candidate(logs = ['x1 1 2 3', 'x2 1 2 4', 'y1 1 2 3 4', 'y2 1 2 3 5', 'y3 1 2 3 6', 'x3 1 2 3 5', 'x4 1 2 3 7']) == ['x1 1 2 3', 'x2 1 2 4', 'y1 1 2 3 4', 'y2 1 2 3 5', 'y3 1 2 3 6', 'x3 1 2 3 5', 'x4 1 2 3 7']\n assert candidate(logs = ['log12 mix foo', 'log42 12 34', 'log33 bar foo', 'log22 mix bar', 'log55 99 88', 'log11 bar foo']) == ['log11 bar foo', 'log33 bar foo', 'log22 mix bar', 'log12 mix foo', 'log42 12 34', 'log55 99 88']\n assert candidate(logs = ['id1 z', 'id2 y', 'id3 x', 'id4 w', 'id5 v', 'id6 u', 'id7 t', 'id8 s', 'id9 r', 'id10 q', 'id11 p', 'id12 o', 'id13 n', 'id14 m', 'id15 l', 'id16 k', 'id17 j', 'id18 i', 'id19 h', 'id20 g', 'id21 f', 'id22 e', 'id23 d', 'id24 c', 'id25 b', 'id26 a']) == ['id26 a', 'id25 b', 'id24 c', 'id23 d', 'id22 e', 'id21 f', 'id20 g', 'id19 h', 'id18 i', 'id17 j', 'id16 k', 'id15 l', 'id14 m', 'id13 n', 'id12 o', 'id11 p', 'id10 q', 'id9 r', 'id8 s', 'id7 t', 'id6 u', 'id5 v', 'id4 w', 'id3 x', 'id2 y', 'id1 z']\n assert candidate(logs = ['abc1 def ghi', '123 456 789', 'xyz2 jkl mno', 'def3 opq rst', 'uvw4 123 456', 'uvw4 123 456', 'xyz1 jkl mno', 'xyz3 mno pqr']) == ['abc1 def ghi', 'xyz1 jkl mno', 'xyz2 jkl mno', 'xyz3 mno pqr', 'def3 opq rst', '123 456 789', 'uvw4 123 456', 'uvw4 123 456']\n assert candidate(logs = ['d1 2 3', 'l1 xx', 'l2 xx', 'l3 xx a', 'l4 xx b', 'd2 4 5', 'd3 1 2', 'l5 yy', 'l6 yy z', 'l7 zz', 'l8 zz a', 'l9 zz b']) == ['l1 xx', 'l2 xx', 'l3 xx a', 'l4 xx b', 'l5 yy', 'l6 yy z', 'l7 zz', 'l8 zz a', 'l9 zz b', 'd1 2 3', 'd2 4 5', 'd3 1 2']\n assert candidate(logs = ['c1 f k g', 'c2 m g p', 'c3 t e x', 'd1 1 2 3', 'd2 5 6 7', 'c4 g m t', 'c5 a b c', 'd3 9 0 1', 'c6 m g p', 'd4 5 6 7 8 9', 'c7 x y z', 'c8 q w e', 'd5 0 0 0 0', 'c9 t e x', 'd6 1 2 3 4 5', 'c10 a b c', 'd7 5 6 7 8', 'c11 m g p', 'c12 x y z', 'd8 9 0 1 2']) == ['c10 a b c', 'c5 a b c', 'c1 f k g', 'c4 g m t', 'c11 m g p', 'c2 m g p', 'c6 m g p', 'c8 q w e', 'c3 t e x', 'c9 t e x', 'c12 x y z', 'c7 x y z', 'd1 1 2 3', 'd2 5 6 7', 'd3 9 0 1', 'd4 5 6 7 8 9', 'd5 0 0 0 0', 'd6 1 2 3 4 5', 'd7 5 6 7 8', 'd8 9 0 1 2']\n assert candidate(logs = ['c1 hi ho ha', 'd1 0 0 0', 'c2 ab', 'd2 1', 'c3 cd ef', 'c4 gh', 'd3 2 2 2 2', 'c5 ij kl', 'c6 mn', 'd4 3', 'c7 op', 'd5 4 4 4 4 4 4', 'c8 qr st', 'd6 5 5', 'c9 uv', 'd7 6 6 6 6 6 6 6', 'd8 7 7 7 7 7 7 7 7 7', 'd9 8 8 8 8 8 8 8 8 8 8', 'd10 9 9 9 9 9 9 9 9 9 9 9 9 9 9', 'c10 wx yz', 'c11 za', 'c12 zb', 'c13 zc', 'c14 zd']) == ['c2 ab', 'c3 cd ef', 'c4 gh', 'c1 hi ho ha', 'c5 ij kl', 'c6 mn', 'c7 op', 'c8 qr st', 'c9 uv', 'c10 wx yz', 'c11 za', 'c12 zb', 'c13 zc', 'c14 zd', 'd1 0 0 0', 'd2 1', 'd3 2 2 2 2', 'd4 3', 'd5 4 4 4 4 4 4', 'd6 5 5', 'd7 6 6 6 6 6 6 6', 'd8 7 7 7 7 7 7 7 7 7', 'd9 8 8 8 8 8 8 8 8 8 8', 'd10 9 9 9 9 9 9 9 9 9 9 9 9 9 9']\n assert candidate(logs = ['m1 5 5 5', 'm2 4 4 4', 'm3 3 3 3', 'm4 2 2 2', 'm5 1 1 1', 'n1 one two', 'n2 one two', 'n3 one two', 'n4 one two', 'n5 one two', 'o1 three four', 'o2 three four', 'o3 three four', 'o4 three four', 'o5 three four', 'p1 five six', 'p2 five six', 'p3 five six', 'p4 five six', 'p5 five six']) == ['p1 five six', 'p2 five six', 'p3 five six', 'p4 five six', 'p5 five six', 'n1 one two', 'n2 one two', 'n3 one two', 'n4 one two', 'n5 one two', 'o1 three four', 'o2 three four', 'o3 three four', 'o4 three four', 'o5 three four', 'm1 5 5 5', 'm2 4 4 4', 'm3 3 3 3', 'm4 2 2 2', 'm5 1 1 1']\n assert candidate(logs = ['alpha 123', 'beta 456', 'gamma 789', 'delta 101112', 'epsilon 131415', 'zeta 161718', 'eta 192021', 'theta 222324', 'iota 252627', 'kappa 282930', 'lambda 313233', 'mu 343536', 'nu 373839', 'xi 404142', 'omicron 434445', 'pi 464748', 'rho 495051', 'sigma 525354', 'tau 555657', 'upsilon 585960', 'phi 616263', 'chi 646566', 'psi 676869', 'omega 707172', 'digA 1 2 3', 'digB 4 5 6', 'digC 7 8 9', 'digD 10 11 12', 'digE 13 14 15']) == ['alpha 123', 'beta 456', 'gamma 789', 'delta 101112', 'epsilon 131415', 'zeta 161718', 'eta 192021', 'theta 222324', 'iota 252627', 'kappa 282930', 'lambda 313233', 'mu 343536', 'nu 373839', 'xi 404142', 'omicron 434445', 'pi 464748', 'rho 495051', 'sigma 525354', 'tau 555657', 'upsilon 585960', 'phi 616263', 'chi 646566', 'psi 676869', 'omega 707172', 'digA 1 2 3', 'digB 4 5 6', 'digC 7 8 9', 'digD 10 11 12', 'digE 13 14 15']\n assert candidate(logs = ['log1 abc def', 'log2 def abc', 'log3 ghi', 'log4 123 456', 'log5 789', 'log6 ghi jkl', 'log7 111 222', 'log8 abc def', 'log9 def abc', 'log10 ghi jkl']) == ['log1 abc def', 'log8 abc def', 'log2 def abc', 'log9 def abc', 'log3 ghi', 'log10 ghi jkl', 'log6 ghi jkl', 'log4 123 456', 'log5 789', 'log7 111 222']\n assert candidate(logs = ['d1 5 6 7', 'c1 abc def', 'd2 4 3 2', 'c2 abc def ghi', 'd3 1 2 3', 'c3 abc def', 'c4 xyz']) == ['c1 abc def', 'c3 abc def', 'c2 abc def ghi', 'c4 xyz', 'd1 5 6 7', 'd2 4 3 2', 'd3 1 2 3']\n assert candidate(logs = ['log1 one two three', 'log2 abc def', 'log3 123 456', 'log4 ghi jkl', 'log5 mno pqr', 'log6 stu vwx', 'log7 yza abc', 'log8 def ghi', 'log9 jkl mno', 'log10 pqr stu', 'log11 vwx yza', 'log12 abc def', 'log13 ghi jkl', 'log14 mno pqr', 'log15 stu vwx', 'log16 yza abc', 'log17 def ghi', 'log18 jkl mno', 'log19 pqr stu', 'log20 vwx yza', 'log21 456 789', 'log22 123 456', 'log23 789 012', 'log24 321 654', 'log25 654 321', 'log26 012 987']) == ['log12 abc def', 'log2 abc def', 'log17 def ghi', 'log8 def ghi', 'log13 ghi jkl', 'log4 ghi jkl', 'log18 jkl mno', 'log9 jkl mno', 'log14 mno pqr', 'log5 mno pqr', 'log1 one two three', 'log10 pqr stu', 'log19 pqr stu', 'log15 stu vwx', 'log6 stu vwx', 'log11 vwx yza', 'log20 vwx yza', 'log16 yza abc', 'log7 yza abc', 'log3 123 456', 'log21 456 789', 'log22 123 456', 'log23 789 012', 'log24 321 654', 'log25 654 321', 'log26 012 987']\n assert candidate(logs = ['1 a', '2 b', '3 c', '4 d', '5 e', 'f 1', 'g 2', 'h 3', 'i 4', 'j 5', 'k 6', 'l 7', 'm 8', 'n 9', 'o 10']) == ['1 a', '2 b', '3 c', '4 d', '5 e', 'f 1', 'g 2', 'h 3', 'i 4', 'j 5', 'k 6', 'l 7', 'm 8', 'n 9', 'o 10']\n assert candidate(logs = ['d1 0 0', 'd2 0 0 0', 'l1 aa aa', 'l2 aa ab', 'l3 aa aa aa', 'l4 ab aa', 'l5 aa bb', 'd3 0 0', 'l6 aa aa', 'd4 0 0 0 0 0']) == ['l1 aa aa', 'l6 aa aa', 'l3 aa aa aa', 'l2 aa ab', 'l5 aa bb', 'l4 ab aa', 'd1 0 0', 'd2 0 0 0', 'd3 0 0', 'd4 0 0 0 0 0']\n assert candidate(logs = ['d5 4 5 6', 'd4 3 4 5', 'd3 2 3 4', 'd2 1 2 3', 'd1 0 1 2', 'l1 info log', 'l2 info log', 'l3 info log']) == ['l1 info log', 'l2 info log', 'l3 info log', 'd5 4 5 6', 'd4 3 4 5', 'd3 2 3 4', 'd2 1 2 3', 'd1 0 1 2']\n assert candidate(logs = ['x7 1 1 1', 'x6 2 2 2', 'x5 3 3 3', 'x4 4 4 4', 'x3 5 5 5', 'x2 6 6 6', 'x1 7 7 7', 'y1 debug msg', 'y2 debug msg', 'y3 debug msg', 'y4 debug msg']) == ['y1 debug msg', 'y2 debug msg', 'y3 debug msg', 'y4 debug msg', 'x7 1 1 1', 'x6 2 2 2', 'x5 3 3 3', 'x4 4 4 4', 'x3 5 5 5', 'x2 6 6 6', 'x1 7 7 7']\n assert candidate(logs = ['logA 100', 'logB 99', 'logC 98', 'logD 97', 'logE 96', 'logF 95', 'logG 94', 'logH 93', 'logI 92', 'logJ 91', 'logK 90', 'logL 89', 'logM 88', 'logN 87', 'logO 86', 'logP 85', 'logQ 84', 'logR 83', 'logS 82', 'logT 81', 'logU 80', 'logV 79', 'logW 78', 'logX 77', 'logY 76', 'logZ 75', 'a1 abc', 'b2 def', 'c3 ghi', 'd4 jkl']) == ['a1 abc', 'b2 def', 'c3 ghi', 'd4 jkl', 'logA 100', 'logB 99', 'logC 98', 'logD 97', 'logE 96', 'logF 95', 'logG 94', 'logH 93', 'logI 92', 'logJ 91', 'logK 90', 'logL 89', 'logM 88', 'logN 87', 'logO 86', 'logP 85', 'logQ 84', 'logR 83', 'logS 82', 'logT 81', 'logU 80', 'logV 79', 'logW 78', 'logX 77', 'logY 76', 'logZ 75']\n assert candidate(logs = ['a10 9 2 3 1', 'g1 act car', 'zo4 4 7', 'ab1 off key dog', 'a8 act zoo', 'b1 2 2 2', 'c1 1 1 1', 'd1 0 0 0']) == ['g1 act car', 'a8 act zoo', 'ab1 off key dog', 'a10 9 2 3 1', 'zo4 4 7', 'b1 2 2 2', 'c1 1 1 1', 'd1 0 0 0']\n assert candidate(logs = ['z9 9', 'z8 8', 'z7 7', 'z6 6', 'z5 5', 'z4 4', 'z3 3', 'z2 2', 'z1 1', 'a1 1', 'a2 2', 'a3 3', 'a4 4', 'a5 5', 'a6 6', 'a7 7', 'a8 8', 'a9 9']) == ['z9 9', 'z8 8', 'z7 7', 'z6 6', 'z5 5', 'z4 4', 'z3 3', 'z2 2', 'z1 1', 'a1 1', 'a2 2', 'a3 3', 'a4 4', 'a5 5', 'a6 6', 'a7 7', 'a8 8', 'a9 9']\n assert candidate(logs = ['a1 9 2 3 1', 'z1 9 2 3 1', 'g1 act car', 'zo4 4 7', 'ab1 off key dog', 'a8 act zoo', 'z2 1 2 3 4', 'b1 1 2 3 4']) == ['g1 act car', 'a8 act zoo', 'ab1 off key dog', 'a1 9 2 3 1', 'z1 9 2 3 1', 'zo4 4 7', 'z2 1 2 3 4', 'b1 1 2 3 4']\n assert candidate(logs = ['1a 1 2 3', '1z 9 8 7', '1b 5 6', '2c art car', '2d act zoo', '2e off key dog', '2f art can', '2g 8 1 5 1', '2h own kit dig', '2i art zero', '2j 3 6']) == ['2d act zoo', '2f art can', '2c art car', '2i art zero', '2e off key dog', '2h own kit dig', '1a 1 2 3', '1z 9 8 7', '1b 5 6', '2g 8 1 5 1', '2j 3 6']\n assert candidate(logs = ['log001 error found', 'log002 error found', 'log003 warning check', 'log004 info start', 'log005 info start', 'log006 error found', 'log007 warning check', 'log008 debug init', 'log009 debug init', 'log010 info start', 'log011 warning check', 'log012 debug init', 'log013 info start', 'log014 warning check', 'log015 debug init', 'log016 error found', 'log017 warning check', 'log018 debug init', 'log019 info start', 'log020 warning check', 'log021 debug init', 'log022 error found', 'log023 warning check', 'log024 debug init', 'log025 info start', 'log026 warning check', 'log027 debug init', 'log028 error found', 'log029 warning check', 'log030 debug init']) == ['log008 debug init', 'log009 debug init', 'log012 debug init', 'log015 debug init', 'log018 debug init', 'log021 debug init', 'log024 debug init', 'log027 debug init', 'log030 debug init', 'log001 error found', 'log002 error found', 'log006 error found', 'log016 error found', 'log022 error found', 'log028 error found', 'log004 info start', 'log005 info start', 'log010 info start', 'log013 info start', 'log019 info start', 'log025 info start', 'log003 warning check', 'log007 warning check', 'log011 warning check', 'log014 warning check', 'log017 warning check', 'log020 warning check', 'log023 warning check', 'log026 warning check', 'log029 warning check']\n assert candidate(logs = ['zz1 1', 'aa1 1', 'yy1 1', 'xx1 1', 'bb1 act car', 'cc1 act zoo', 'dd1 off key dog', 'ee1 art can', 'ff1 8 1 5 1', 'gg1 own kit dig', 'hh1 art zero', 'ii1 3 6', 'jj1 act car', 'kk1 act zoo', 'll1 off key dog', 'mm1 art can', 'nn1 8 1 5 1', 'oo1 own kit dig', 'pp1 art zero', 'qq1 3 6', 'rr1 4 5', 'ss1 6 7', 'tt1 8 9']) == ['bb1 act car', 'jj1 act car', 'cc1 act zoo', 'kk1 act zoo', 'ee1 art can', 'mm1 art can', 'hh1 art zero', 'pp1 art zero', 'dd1 off key dog', 'll1 off key dog', 'gg1 own kit dig', 'oo1 own kit dig', 'zz1 1', 'aa1 1', 'yy1 1', 'xx1 1', 'ff1 8 1 5 1', 'ii1 3 6', 'nn1 8 1 5 1', 'qq1 3 6', 'rr1 4 5', 'ss1 6 7', 'tt1 8 9']\n assert candidate(logs = ['x1 zzz', 'x2 yyy', 'x3 zzz', 'x4 yyy', 'x5 zzz', 'x6 yyy', 'x7 zzz', 'x8 yyy', 'x9 zzz', 'x10 yyy', 'd1 1 2', 'd2 3 4', 'd3 5 6', 'd4 7 8', 'd5 9 0']) == ['x10 yyy', 'x2 yyy', 'x4 yyy', 'x6 yyy', 'x8 yyy', 'x1 zzz', 'x3 zzz', 'x5 zzz', 'x7 zzz', 'x9 zzz', 'd1 1 2', 'd2 3 4', 'd3 5 6', 'd4 7 8', 'd5 9 0']\n assert candidate(logs = ['x1 100 200', 'y1 abc def', 'x2 300', 'y2 ghi jkl', 'x3 400 500', 'y3 mno pqr', 'y4 def', 'y5 abc', 'x4 600']) == ['y5 abc', 'y1 abc def', 'y4 def', 'y2 ghi jkl', 'y3 mno pqr', 'x1 100 200', 'x2 300', 'x3 400 500', 'x4 600']\n assert candidate(logs = ['a10 9 2 3 1', 'g1 act car', 'zo4 4 7', 'ab1 off key dog', 'a8 act zoo', 'let1 art can', 'dig1 8 1 5 1', 'let2 own kit dig', 'let3 art zero', 'dig2 3 6']) == ['g1 act car', 'a8 act zoo', 'let1 art can', 'let3 art zero', 'ab1 off key dog', 'let2 own kit dig', 'a10 9 2 3 1', 'zo4 4 7', 'dig1 8 1 5 1', 'dig2 3 6']\n assert candidate(logs = ['log5 10 20', 'log2 three', 'log8 nine', 'log1 two', 'log6 30 40', 'log4 four', 'log3 one', 'log7 eight', 'log9 50 60', 'log0 zero']) == ['log7 eight', 'log4 four', 'log8 nine', 'log3 one', 'log2 three', 'log1 two', 'log0 zero', 'log5 10 20', 'log6 30 40', 'log9 50 60']\n assert candidate(logs = ['a1 9 2 3 1', 'g1 act car', 'zo4 4 7', 'ab1 off key dog', 'a8 act zoo', 'b1 act car', 'b2 act car zoo']) == ['b1 act car', 'g1 act car', 'b2 act car zoo', 'a8 act zoo', 'ab1 off key dog', 'a1 9 2 3 1', 'zo4 4 7']\n assert candidate(logs = ['log12 10 20 30', 'log11 1 2 3', 'log10 9 8 7', 'log9 6 5 4', 'log8 3 2 1']) == ['log12 10 20 30', 'log11 1 2 3', 'log10 9 8 7', 'log9 6 5 4', 'log8 3 2 1']\n assert candidate(logs = ['log1 one two three', 'log2 four five', 'log3 six', 'log4 seven eight nine', 'log5 ten eleven twelve', 'log6 thirteen fourteen fifteen', 'log7 1 2', 'log8 3 4 5', 'log9 6 7 8', 'log10 9 10 11', 'log11 12 13 14']) == ['log2 four five', 'log1 one two three', 'log4 seven eight nine', 'log3 six', 'log5 ten eleven twelve', 'log6 thirteen fourteen fifteen', 'log7 1 2', 'log8 3 4 5', 'log9 6 7 8', 'log10 9 10 11', 'log11 12 13 14']\n assert candidate(logs = ['id1 abc def', 'id2 ghi jkl', 'id3 mno pqr', 'id4 stu vwx', 'id5 123 456', 'id6 789 012', 'id7 abc def', 'id8 ghi jkl', 'id9 mno pqr', 'id10 stu vwx', 'id11 321 654']) == ['id1 abc def', 'id7 abc def', 'id2 ghi jkl', 'id8 ghi jkl', 'id3 mno pqr', 'id9 mno pqr', 'id10 stu vwx', 'id4 stu vwx', 'id5 123 456', 'id6 789 012', 'id11 321 654']\n assert candidate(logs = ['log12 456 789', 'abc 123 def', 'xyz 456', 'ghi 789', 'jkl 101', 'log2 456 789', 'mno 123 456', 'pqr 789 012']) == ['log12 456 789', 'abc 123 def', 'xyz 456', 'ghi 789', 'jkl 101', 'log2 456 789', 'mno 123 456', 'pqr 789 012']\n assert candidate(logs = ['x1 abc def', 'x2 abc', 'x3 def', 'x4 def', 'x5 abc', 'x6 def', 'x7 def', 'x8 abc', 'x9 abc', 'x10 abc', 'y1 1 1 1', 'y2 2 2 2', 'y3 3 3 3', 'y4 4 4 4', 'y5 5 5 5', 'y6 6 6 6', 'y7 7 7 7', 'y8 8 8 8', 'y9 9 9 9', 'y10 10 10 10', 'y11 11 11 11', 'y12 12 12 12', 'y13 13 13 13', 'y14 14 14 14', 'y15 15 15 15', 'y16 16 16 16', 'y17 17 17 17', 'y18 18 18 18', 'y19 19 19 19', 'y20 20 20 20', 'z1 abc', 'z2 def', 'z3 ghi', 'z4 jkl', 'z5 mno', 'z6 pqr', 'z7 stu', 'z8 vwx', 'z9 yza', 'z10 bcde']) == ['x10 abc', 'x2 abc', 'x5 abc', 'x8 abc', 'x9 abc', 'z1 abc', 'x1 abc def', 'z10 bcde', 'x3 def', 'x4 def', 'x6 def', 'x7 def', 'z2 def', 'z3 ghi', 'z4 jkl', 'z5 mno', 'z6 pqr', 'z7 stu', 'z8 vwx', 'z9 yza', 'y1 1 1 1', 'y2 2 2 2', 'y3 3 3 3', 'y4 4 4 4', 'y5 5 5 5', 'y6 6 6 6', 'y7 7 7 7', 'y8 8 8 8', 'y9 9 9 9', 'y10 10 10 10', 'y11 11 11 11', 'y12 12 12 12', 'y13 13 13 13', 'y14 14 14 14', 'y15 15 15 15', 'y16 16 16 16', 'y17 17 17 17', 'y18 18 18 18', 'y19 19 19 19', 'y20 20 20 20']\n assert candidate(logs = ['c1 100 200 300', 'd2 hello world', 'b3 hi there', 'a4 hello world', 'e5 test log']) == ['a4 hello world', 'd2 hello world', 'b3 hi there', 'e5 test log', 'c1 100 200 300']\n assert candidate(logs = ['log01 2021 01 01', 'log02 2021 01 02', 'log03 2021 01 03', 'log04 2021 01 04', 'log05 2021 01 05', 'log06 2021 01 06', 'log07 2021 01 07', 'log08 2021 01 08', 'log09 2021 01 09', 'log10 2021 01 10', 'log11 2021 01 11', 'log12 2021 01 12', 'log13 2021 01 13', 'log14 2021 01 14', 'log15 2021 01 15', 'log16 2021 01 16', 'log17 2021 01 17', 'log18 2021 01 18', 'log19 2021 01 19', 'log20 2021 01 20', 'a1 abc', 'a2 def', 'a3 ghi', 'a4 jkl', 'a5 mno', 'a6 pqr', 'a7 stu', 'a8 vwx', 'a9 yza', 'b1 abc def', 'b2 ghi jkl', 'b3 mno pqr', 'b4 stu vwx', 'b5 yza bcd']) == ['a1 abc', 'b1 abc def', 'a2 def', 'a3 ghi', 'b2 ghi jkl', 'a4 jkl', 'a5 mno', 'b3 mno pqr', 'a6 pqr', 'a7 stu', 'b4 stu vwx', 'a8 vwx', 'a9 yza', 'b5 yza bcd', 'log01 2021 01 01', 'log02 2021 01 02', 'log03 2021 01 03', 'log04 2021 01 04', 'log05 2021 01 05', 'log06 2021 01 06', 'log07 2021 01 07', 'log08 2021 01 08', 'log09 2021 01 09', 'log10 2021 01 10', 'log11 2021 01 11', 'log12 2021 01 12', 'log13 2021 01 13', 'log14 2021 01 14', 'log15 2021 01 15', 'log16 2021 01 16', 'log17 2021 01 17', 'log18 2021 01 18', 'log19 2021 01 19', 'log20 2021 01 20']\n assert candidate(logs = ['id001 abc def', 'id002 ghi', 'id003 1 2', 'id004 jkl', 'id005 abc def', 'id006 mno', 'id007 3 4', 'id008 pqr', 'id009 stu', 'id010 5 6', 'id011 vwx', 'id012 yza', 'id013 abc def']) == ['id001 abc def', 'id005 abc def', 'id013 abc def', 'id002 ghi', 'id004 jkl', 'id006 mno', 'id008 pqr', 'id009 stu', 'id011 vwx', 'id012 yza', 'id003 1 2', 'id007 3 4', 'id010 5 6']\n assert candidate(logs = ['z9 2 3 4', 'b2 run let', 'a1 1 2 3', 'x3 jump high', 'y8 run let']) == ['x3 jump high', 'b2 run let', 'y8 run let', 'z9 2 3 4', 'a1 1 2 3']\n assert candidate(logs = ['z9 1 2', 'a9 1 2', 'y9 1 2', 'x9 1 2', 'b9 act car', 'c9 act zoo', 'd9 off key dog', 'e9 art can', 'f9 8 1 5 1', 'g9 own kit dig', 'h9 art zero', 'i9 3 6', 'j9 act car', 'k9 act zoo', 'l9 off key dog', 'm9 art can', 'n9 8 1 5 1', 'o9 own kit dig', 'p9 art zero', 'q9 3 6']) == ['b9 act car', 'j9 act car', 'c9 act zoo', 'k9 act zoo', 'e9 art can', 'm9 art can', 'h9 art zero', 'p9 art zero', 'd9 off key dog', 'l9 off key dog', 'g9 own kit dig', 'o9 own kit dig', 'z9 1 2', 'a9 1 2', 'y9 1 2', 'x9 1 2', 'f9 8 1 5 1', 'i9 3 6', 'n9 8 1 5 1', 'q9 3 6']\n assert candidate(logs = ['logX abc', 'logY abc', 'logZ abc', 'logW abc', 'logV abc', 'logU abc', 'logT abc', 'logS abc', 'logR abc', 'logQ abc', 'logP abc', 'logO abc', 'logN abc', 'logM abc', 'logL abc', 'logK abc', 'logJ abc', 'logI abc', 'logH abc', 'logG abc', 'logF abc', 'logE abc', 'logD abc', 'logC abc', 'logB abc', 'logA abc', 'digX 1 2 3', 'digY 4 5 6', 'digZ 7 8 9', 'digW 10 11 12', 'digV 13 14 15', 'digU 16 17 18', 'digT 19 20 21', 'digS 22 23 24', 'digR 25 26 27', 'digQ 28 29 30', 'digP 31 32 33', 'digO 34 35 36', 'digN 37 38 39', 'digM 40 41 42', 'digL 43 44 45', 'digK 46 47 48', 'digJ 49 50 51', 'digI 52 53 54', 'digH 55 56 57', 'digG 58 59 60', 'digF 61 62 63', 'digE 64 65 66', 'digD 67 68 69', 'digC 70 71 72', 'digB 73 74 75', 'digA 76 77 78']) == ['logA abc', 'logB abc', 'logC abc', 'logD abc', 'logE abc', 'logF abc', 'logG abc', 'logH abc', 'logI abc', 'logJ abc', 'logK abc', 'logL abc', 'logM abc', 'logN abc', 'logO abc', 'logP abc', 'logQ abc', 'logR abc', 'logS abc', 'logT abc', 'logU abc', 'logV abc', 'logW abc', 'logX abc', 'logY abc', 'logZ abc', 'digX 1 2 3', 'digY 4 5 6', 'digZ 7 8 9', 'digW 10 11 12', 'digV 13 14 15', 'digU 16 17 18', 'digT 19 20 21', 'digS 22 23 24', 'digR 25 26 27', 'digQ 28 29 30', 'digP 31 32 33', 'digO 34 35 36', 'digN 37 38 39', 'digM 40 41 42', 'digL 43 44 45', 'digK 46 47 48', 'digJ 49 50 51', 'digI 52 53 54', 'digH 55 56 57', 'digG 58 59 60', 'digF 61 62 63', 'digE 64 65 66', 'digD 67 68 69', 'digC 70 71 72', 'digB 73 74 75', 'digA 76 77 78']\n assert candidate(logs = ['alpha 1 2 3', 'beta 3 2 1', 'gamma 1 1 1', 'delta 4 4 4', 'epsilon 2 2 2', 'zeta 3 3 3', 'eta 1 2 1', 'theta 1 1 2', 'iota 2 1 1', 'kappa 2 1 2']) == ['alpha 1 2 3', 'beta 3 2 1', 'gamma 1 1 1', 'delta 4 4 4', 'epsilon 2 2 2', 'zeta 3 3 3', 'eta 1 2 1', 'theta 1 1 2', 'iota 2 1 1', 'kappa 2 1 2']\n assert candidate(logs = ['d1 1 2', 'l1 act car toy', 'd2 2 3', 'l2 art car toy', 'l3 act zoo', 'd3 3 4', 'l4 zoo act', 'd4 4 5', 'l5 art zoo car']) == ['l1 act car toy', 'l3 act zoo', 'l2 art car toy', 'l5 art zoo car', 'l4 zoo act', 'd1 1 2', 'd2 2 3', 'd3 3 4', 'd4 4 5']\n assert candidate(logs = ['x1 5 7 9', 'y1 abc def', 'x2 3 6 8', 'y2 def abc', 'x3 1 4 7', 'y3 abc def', 'x4 2 5 8', 'y4 def abc', 'y5 abc def', 'x5 6 9 10']) == ['y1 abc def', 'y3 abc def', 'y5 abc def', 'y2 def abc', 'y4 def abc', 'x1 5 7 9', 'x2 3 6 8', 'x3 1 4 7', 'x4 2 5 8', 'x5 6 9 10']\n assert candidate(logs = ['d1 2 3', 'l1 one two three', 'l2 one two', 'l3 one', 'd2 4 5 6', 'l4 two three four', 'd3 7 8 9 10', 'l5 one two three four five']) == ['l3 one', 'l2 one two', 'l1 one two three', 'l5 one two three four five', 'l4 two three four', 'd1 2 3', 'd2 4 5 6', 'd3 7 8 9 10']\n assert candidate(logs = ['x1 1 2 3', 'x2 3 4 5', 'x3 5 6 7', 'x4 7 8 9', 'y1 a b c', 'y2 d e f', 'y3 g h i', 'y4 j k l', 'y5 m n o', 'y6 p q r', 'y7 s t u', 'y8 v w x', 'y9 y z', 'z1 0 0 0']) == ['y1 a b c', 'y2 d e f', 'y3 g h i', 'y4 j k l', 'y5 m n o', 'y6 p q r', 'y7 s t u', 'y8 v w x', 'y9 y z', 'x1 1 2 3', 'x2 3 4 5', 'x3 5 6 7', 'x4 7 8 9', 'z1 0 0 0']\n assert candidate(logs = ['logA 987', 'logB 654', 'logC 321', 'logD 000', 'logE def', 'logF ghi', 'logG jkl', 'logH mno', 'logI pqr', 'logJ stu', 'logK vwx', 'logL yza', 'logM abc', 'logN def', 'logO ghi', 'logP jkl', 'logQ mno', 'logR pqr', 'logS stu', 'logT vwx', 'logU yza', 'logV abc', 'logW def', 'logX ghi', 'logY jkl', 'logZ mno']) == ['logM abc', 'logV abc', 'logE def', 'logN def', 'logW def', 'logF ghi', 'logO ghi', 'logX ghi', 'logG jkl', 'logP jkl', 'logY jkl', 'logH mno', 'logQ mno', 'logZ mno', 'logI pqr', 'logR pqr', 'logJ stu', 'logS stu', 'logK vwx', 'logT vwx', 'logL yza', 'logU yza', 'logA 987', 'logB 654', 'logC 321', 'logD 000']\n", "comparison": "exact"}, "public_tests": ["[\"0 pmz\", \"4 q j\", \"g 89\", \"t v p\", \"w ugr\"]", "[\"2 08\", \"f 09\", \"v wc\", \"o z c\", \"u 14\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().reorderLogFiles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:46+00:00", "tests_total": 53, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def reorderLogFiles(self, logs: list[str]) -> list[str]:", "container": "Solution", "callable": "reorderLogFiles", "parameters": [{"name": "logs", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 939, "task_id": "minimum-area-rectangle", "difficulty": "Medium", "problem_description": "You are given an array of points in the X-Y plane points where points[i] = [x_i, y_i].\n\nReturn the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes. If there is not any such rectangle, return 0.\n\nExample 1:\n\nInput: points = [[1,1],[1,3],[3,1],[3,3],[2,2]]\nOutput: 4\n\nExample 2:\n\nInput: points = [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]\nOutput: 2\n\nConstraints:\n\n- 1 <= points.length <= 500\n- points[i].length == 2\n- 0 <= x_i, y_i <= 4 * 10^4\n- All the given points are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3]]) == 1\n assert candidate(points = [[1, 1], [1, 3], [3, 1], [3, 3], [4, 1], [4, 3]]) == 2\n assert candidate(points = [[1, 1], [1, 3], [3, 1], [3, 3], [2, 2]]) == 4\n assert candidate(points = [[0, 0], [0, 2], [2, 2], [2, 0], [1, 1], [1, 0], [0, 1], [2, 1]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == 0\n assert candidate(points = [[0, 0], [0, 40000], [40000, 0], [40000, 40000], [20000, 20000], [10000, 10000], [30000, 30000], [5000, 5000], [35000, 35000], [15000, 15000], [25000, 25000], [500, 500], [39500, 39500]]) == 1600000000\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7]]) == 100\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(points = [[0, 0], [0, 4], [4, 0], [4, 4], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]) == 1\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]) == 1\n assert candidate(points = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3], [5, 5], [6, 6], [7, 7], [8, 8]]) == 9\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [1, 14], [14, 1], [7, 2]]) == 0\n assert candidate(points = [[1, 1], [3, 1], [1, 3], [3, 3], [2, 2], [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(points = [[0, 0], [0, 20], [20, 0], [20, 20], [5, 5], [5, 15], [15, 5], [15, 15], [10, 10], [10, 15], [15, 10], [5, 10], [10, 5]]) == 25\n assert candidate(points = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [2, 3], [3, 2], [3, 3], [5, 5], [5, 6], [6, 5], [6, 6]]) == 1\n assert candidate(points = [[1, 1], [2, 3], [3, 1], [4, 5], [5, 4], [6, 6], [7, 2], [8, 7], [9, 3], [10, 10]]) == 0\n assert candidate(points = [[0, 0], [0, 2], [0, 4], [2, 0], [2, 2], [2, 4], [4, 0], [4, 2], [4, 4]]) == 4\n assert candidate(points = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [2, 3], [3, 2], [3, 3], [5, 5], [5, 7], [7, 5], [7, 7]]) == 1\n assert candidate(points = [[0, 0], [0, 3], [3, 0], [3, 3], [1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [3, 1]]) == 1\n assert candidate(points = [[1, 2], [1, 5], [2, 1], [2, 6], [3, 3], [3, 8], [4, 4], [4, 9], [5, 5], [5, 10], [6, 6], [6, 11]]) == 0\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 6], [6, 4], [6, 6]]) == 1\n assert candidate(points = [[1, 1], [1, 40], [40, 1], [40, 40], [20, 20], [20, 30], [30, 20], [30, 30], [15, 15], [15, 25], [25, 15], [25, 25]]) == 100\n assert candidate(points = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 2], [2, 1]]) == 1\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [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]]) == 0\n assert candidate(points = [[5, 5], [5, 10], [10, 5], [10, 10], [15, 15], [15, 20], [20, 15], [20, 20], [25, 25], [25, 30], [30, 25], [30, 30]]) == 25\n assert candidate(points = [[1, 1], [1, 10], [10, 1], [10, 10], [5, 5], [2, 2], [2, 8], [8, 2], [8, 8], [3, 3], [3, 6], [6, 3], [6, 6]]) == 9\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [1, 4], [4, 1], [2, 3], [3, 2], [5, 5], [5, 0], [0, 5]]) == 4\n assert candidate(points = [[0, 0], [0, 2], [1, 1], [1, 3], [2, 2], [2, 4], [3, 0], [3, 2], [3, 4], [4, 1], [4, 3]]) == 2\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [3, 3], [3, 4], [4, 3], [4, 4], [2, 2], [2, 6], [6, 2], [6, 6], [7, 7], [8, 8], [9, 9], [1, 9], [9, 1], [1, 7], [7, 1], [1, 8], [8, 1]]) == 1\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]) == 1\n assert candidate(points = [[0, 0], [0, 3], [3, 0], [3, 3], [1, 1], [1, 2], [2, 1], [2, 2], [4, 4], [4, 5], [5, 4], [5, 5]]) == 1\n assert candidate(points = [[0, 0], [0, 5], [5, 0], [5, 5], [1, 2], [1, 3], [4, 2], [4, 3], [2, 1], [2, 4], [3, 1], [3, 4]]) == 3\n assert candidate(points = [[1, 1], [1, 10], [10, 1], [10, 10], [2, 2], [2, 9], [9, 2], [9, 9], [3, 3], [3, 8], [8, 3], [8, 8], [4, 4], [4, 7], [7, 4], [7, 7], [5, 5], [5, 6], [6, 5], [6, 6], [1, 6], [6, 1], [2, 5], [5, 2], [3, 4], [4, 3], [5, 4], [4, 5]]) == 1\n assert candidate(points = [[0, 0], [0, 10000], [10000, 0], [10000, 10000], [5000, 5000], [5000, 6000], [6000, 5000], [6000, 6000]]) == 1000000\n assert candidate(points = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [3, 3], [4, 4], [1, 4], [4, 1]]) == 4\n assert candidate(points = [[0, 0], [40000, 40000], [20000, 20000], [10000, 10000], [30000, 30000], [5000, 5000], [25000, 25000], [15000, 15000], [35000, 35000]]) == 0\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 1\n assert candidate(points = [[1, 1], [1, 4], [1, 7], [4, 1], [4, 4], [4, 7], [7, 1], [7, 4], [7, 7], [10, 10], [11, 11]]) == 9\n assert candidate(points = [[10, 10], [10, 15], [15, 10], [15, 15], [20, 20], [20, 25], [25, 20], [25, 25], [5, 5], [5, 10], [10, 5], [10, 10]]) == 0\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 0\n assert candidate(points = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 2], [3, 2], [2, 3], [3, 3]]) == 1\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 1\n assert candidate(points = [[10000, 10000], [10000, 20000], [20000, 10000], [20000, 20000], [15000, 15000], [5000, 5000], [25000, 25000]]) == 100000000\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [3, 3], [3, 7], [7, 3], [7, 7], [2, 2], [2, 8], [8, 2], [8, 8]]) == 16\n assert candidate(points = [[0, 0], [0, 5], [5, 0], [5, 5], [1, 2], [2, 1], [3, 4], [4, 3]]) == 25\n assert candidate(points = [[0, 0], [5, 0], [0, 5], [5, 5], [2, 2], [3, 3], [4, 4], [7, 7], [8, 8], [9, 9], [10, 10]]) == 25\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [4, 4], [5, 4], [6, 4], [4, 5], [5, 5], [6, 5], [4, 6], [5, 6], [6, 6]]) == 1\n assert candidate(points = [[1, 1], [1, 4], [2, 1], [2, 4], [3, 1], [3, 4], [4, 1], [4, 4], [5, 1], [5, 4]]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 0], [0, 1], [2, 1], [1, 2], [3, 2], [2, 3], [4, 3], [3, 4], [5, 4], [4, 5]]) == 1\n assert candidate(points = [[1000, 2000], [2000, 3000], [1000, 3000], [2000, 2000], [1500, 2500], [1500, 2000], [1000, 2500], [2000, 2500], [1500, 3000]]) == 250000\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(points = [[1, 1], [1, 7], [1, 13], [7, 1], [7, 7], [7, 13], [13, 1], [13, 7], [13, 13], [3, 3], [3, 6], [6, 3], [6, 6], [9, 9], [9, 12], [12, 9], [12, 12]]) == 9\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 4], [4, 2], [4, 4], [3, 3], [3, 6], [6, 3], [6, 6]]) == 4\n assert candidate(points = [[1, 1], [1, 5], [1, 9], [5, 1], [5, 5], [5, 9], [9, 1], [9, 5], [9, 9], [2, 2], [2, 8], [8, 2], [8, 8], [4, 4], [4, 8], [8, 4]]) == 16\n assert candidate(points = [[0, 0], [0, 2], [2, 0], [2, 2], [4, 0], [4, 2], [6, 0], [6, 2], [8, 0], [8, 2]]) == 4\n assert candidate(points = [[0, 0], [0, 50], [50, 0], [50, 50], [25, 25], [25, 35], [35, 25], [35, 35], [10, 10], [10, 40], [40, 10], [40, 40]]) == 100\n assert candidate(points = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 1], [4, 1], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 5]]) == 1\n assert candidate(points = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(points = [[0, 0], [0, 5], [5, 0], [5, 5], [2, 2], [2, 3], [3, 2], [3, 3]]) == 1\n assert candidate(points = [[0, 0], [0, 15], [15, 0], [15, 15], [5, 5], [5, 10], [10, 5], [10, 10], [3, 3], [3, 12], [12, 3], [12, 12]]) == 25\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5]]) == 1\n assert candidate(points = [[5, 5], [5, 8], [8, 5], [8, 8], [10, 10], [10, 15], [15, 10], [15, 15], [3, 3], [3, 6], [6, 3], [6, 6]]) == 9\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3], [1, 4], [2, 4], [3, 4], [4, 4], [1, 5], [2, 5], [3, 5], [4, 5], [1, 6], [2, 6], [3, 6], [4, 6], [1, 7], [2, 7], [3, 7], [4, 7], [1, 8], [2, 8], [3, 8], [4, 8], [1, 9], [2, 9], [3, 9], [4, 9]]) == 1\n assert candidate(points = [[0, 0], [0, 10], [10, 0], [10, 10], [2, 2], [2, 4], [4, 2], [4, 4], [3, 3], [3, 7], [7, 3], [7, 7]]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [15, 25], [25, 15], [25, 25], [5, 5], [5, 25], [25, 5], [15, 10], [10, 15]]) == 25\n assert candidate(points = [[1, 1], [1, 25], [25, 1], [25, 25], [10, 10], [10, 15], [15, 10], [15, 15], [8, 8], [8, 17], [17, 8], [17, 17]]) == 25\n assert candidate(points = [[0, 0], [0, 4], [4, 0], [4, 4], [1, 1], [1, 3], [3, 1], [3, 3]]) == 4\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 4], [4, 2], [4, 4], [3, 3]]) == 4\n assert candidate(points = [[1, 1], [1, 20], [20, 1], [20, 20], [5, 5], [5, 15], [15, 5], [15, 15], [7, 7], [7, 13], [13, 7], [13, 13]]) == 36\n assert candidate(points = [[0, 0], [0, 5], [5, 0], [5, 5], [1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [2, 3], [3, 2], [3, 3]]) == 1\n assert candidate(points = [[0, 0], [4, 4], [1, 2], [2, 1], [3, 3], [2, 3], [3, 2]]) == 0\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 4], [5, 5]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(points = [[0, 0], [0, 2], [2, 0], [2, 2], [4, 4], [4, 6], [6, 4], [6, 6]]) == 4\n assert candidate(points = [[0, 0], [0, 10], [10, 0], [10, 10], [2, 2], [2, 8], [8, 2], [8, 8], [4, 4], [4, 6], [6, 4], [6, 6], [1, 5], [5, 1], [9, 5], [5, 9]]) == 4\n assert candidate(points = [[0, 0], [10, 0], [10, 10], [0, 10], [2, 2], [8, 2], [2, 8], [8, 8], [5, 5], [3, 7], [7, 3], [4, 6], [6, 4]]) == 36\n assert candidate(points = [[0, 0], [0, 30], [30, 0], [30, 30], [10, 10], [10, 20], [20, 10], [20, 20], [6, 6], [6, 24], [24, 6], [24, 24]]) == 100\n assert candidate(points = [[1, 1], [1, 6], [6, 1], [6, 6], [2, 2], [2, 5], [5, 2], [5, 5], [3, 3], [3, 4], [4, 3], [4, 4], [7, 7], [7, 8], [8, 7], [8, 8]]) == 1\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(points = [[0, 0], [0, 10000], [10000, 0], [10000, 10000], [5000, 5000], [2500, 2500], [7500, 7500], [1000, 1000], [9000, 9000], [500, 500], [9500, 9500]]) == 100000000\n", "comparison": "exact"}, "public_tests": ["[[1,1],[1,3],[3,1],[3,3],[2,2]]", "[[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]"], "hints": [], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minAreaRect", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:50+00:00", "tests_total": 81, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "math", "geometry", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minAreaRect(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "minAreaRect", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 940, "task_id": "distinct-subsequences-ii", "difficulty": "Hard", "problem_description": "Given a string s, return the number of distinct non-empty subsequences of s. Since the answer may be very large, return it modulo 10^9 + 7.\n\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 = \"abc\"\nOutput: 7\nExplanation: The 7 distinct subsequences are \"a\", \"b\", \"c\", \"ab\", \"ac\", \"bc\", and \"abc\".\n\nExample 2:\n\nInput: s = \"aba\"\nOutput: 6\nExplanation: The 6 distinct subsequences are \"a\", \"b\", \"ab\", \"aa\", \"ba\", and \"aba\".\n\nExample 3:\n\nInput: s = \"aaa\"\nOutput: 3\nExplanation: The 3 distinct subsequences are \"a\", \"aa\" and \"aaa\".\n\nConstraints:\n\n- 1 <= s.length <= 2000\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 67108863\n assert candidate(s = \"abac\") == 13\n assert candidate(s = \"abababababababababab\") == 28655\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abracadabra\") == 1303\n assert candidate(s = \"zzzz\") == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 402155530\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 552430184\n assert candidate(s = \"aaa\") == 3\n assert candidate(s = \"abcabc\") == 51\n assert candidate(s = \"aabb\") == 8\n assert candidate(s = \"zzzzzzzzzz\") == 10\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 398\n assert candidate(s = \"abc\") == 7\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == 814295\n assert candidate(s = \"abcd\") == 15\n assert candidate(s = \"aba\") == 6\n assert candidate(s = \"aaaaaaaabbbbbbbbcccccccc\") == 728\n assert candidate(s = \"aabbcc\") == 26\n assert candidate(s = \"mississippi\") == 477\n assert candidate(s = \"abcdabc\") == 115\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 865810541\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 67108863\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 174638632\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 100\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 330026179\n assert candidate(s = \"abcdbacdbacdabcdbacdbacdabcdbacdbacdabcdbacdbacdabcdbacdbacdabcdbacdbacdabcdbacdbacdabcdbacdbacd\") == 411786355\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 854978287\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 254\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 136\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n assert candidate(s = \"abacabadabacaba\") == 9426\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 90\n assert candidate(s = \"thisisalongstringthatwilltestthealgorithmwithvariouscharacters\") == 733715667\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 270841387\n assert candidate(s = \"thisisaverylongstringwithrepeatedcharactersandlongsubsequences\") == 484250120\n assert candidate(s = \"longstringthatweneedtogenenatetobemorecomplexandcheckouralgorithmwithaverylongstring\") == 45372177\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 14640\n assert candidate(s = \"racecar\") == 106\n assert candidate(s = \"aabaaabbbaababaabaaabbbabbaabbabbaababaaabbabaaababbabbaabab\") == 330918185\n assert candidate(s = \"aabbccaaaabbccaaaabbcc\") == 41594\n assert candidate(s = \"xyzxyzxyz\") == 325\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 723430077\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 992025290\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddddeeeeeeeeeffffffffggggggggghhhhhhhhhiiiiiiiiiijjjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\") == 627058992\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 580349510\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababab\") == 252403354\n assert candidate(s = \"abcdxyzabcdxyzabcdxyzabcdxyzabcdxyzabcdxyzabcdxyz\") == 843562901\n assert candidate(s = \"ababababababababababababababababababababababababababababababab\") == 680057394\n assert candidate(s = \"repeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeated\") == 462028482\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 208\n assert candidate(s = \"abababababababababababababab\") == 1346267\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\") == 112454975\n", "comparison": "exact"}, "public_tests": ["\"abc\"", "\"aba\"", "\"aaa\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().distinctSubseqII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:53+00:00", "tests_total": 53, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def distinctSubseqII(self, s: str) -> int:", "container": "Solution", "callable": "distinctSubseqII", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 941, "task_id": "valid-mountain-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, return true if and only if it is a valid mountain array.\n\nRecall that arr is a mountain array if and only if:\n\n- arr.length >= 3\n- There exists some i with 0 < i < arr.length - 1 such that:\n - arr[0] < arr[1] < ... < arr[i - 1] < arr[i]\n - arr[i] > arr[i + 1] > ... > arr[arr.length - 1]\n\nExample 1:\n\nInput: arr = [2,1]\nOutput: false\n\nExample 2:\n\nInput: arr = [3,5,5]\nOutput: false\n\nExample 3:\n\nInput: arr = [0,3,2,1]\nOutput: true\n\nConstraints:\n\n- 1 <= arr.length <= 10^4\n- 0 <= arr[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == False\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == False\n assert candidate(arr = [3, 1, 2]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2]) == False\n assert candidate(arr = [0, 2, 3, 3, 2, 1]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [0, 3, 2, 1]) == True\n assert candidate(arr = [0, 1, 2, 1, 2]) == False\n assert candidate(arr = [0, 1, 2, 3, 1]) == True\n assert candidate(arr = [0, 2, 3, 4, 5, 3, 2, 1]) == True\n assert candidate(arr = [1]) == False\n assert candidate(arr = [1, 1, 1, 1, 1]) == False\n assert candidate(arr = [2, 1]) == False\n assert candidate(arr = [0, 1, 2, 3, 1, 0]) == True\n assert candidate(arr = [0, 2, 3, 3, 2, 0]) == False\n assert candidate(arr = [3, 5, 5]) == False\n assert candidate(arr = [1, 2, 3, 4, 5]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(arr = [1, 3, 2]) == True\n assert candidate(arr = [0, 2, 3, 4, 5, 3, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == True\n assert candidate(arr = [0, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 2, 1]) == True\n assert candidate(arr = [0, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1]) == False\n assert candidate(arr = [1, 2, 2, 1]) == False\n assert candidate(arr = [1, 2, 2, 3, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 8, 6, 4, 2, 0]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0]) == True\n assert candidate(arr = [1, 1, 1, 1, 1]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 2, 3, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [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]) == True\n assert candidate(arr = [1, 4, 7, 9, 10, 8, 6, 4, 2]) == True\n assert candidate(arr = [1, 3, 5, 7, 6, 4, 2]) == True\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [1, 4, 7, 9, 11, 10, 8, 6, 4, 2, 0]) == True\n assert candidate(arr = [1, 3, 2, 1, 3, 2, 1]) == False\n assert candidate(arr = [8, 9, 10, 10, 9, 8]) == False\n assert candidate(arr = [1, 3, 2, 1, 2, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == False\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, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(arr = [2, 3, 1, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 3, 5, 4, 3, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == True\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == False\n assert candidate(arr = [1, 5, 4, 3, 2, 1, 0, 2, 3]) == False\n assert candidate(arr = [1, 1, 1, 2, 3, 4, 3, 2, 1, 1, 1]) == False\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 3, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 6, 4, 2]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3]) == True\n assert candidate(arr = [5, 6, 7, 8, 9, 8, 7, 6, 5]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10]) == True\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [1, 2, 3, 2, 3, 4, 3, 2, 1]) == False\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, 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(arr = [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]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 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(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 12, 11, 9, 7, 5, 3, 1]) == True\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, 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(arr = [2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == False\n assert candidate(arr = [0, 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]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 0, 1, 0, 1, 0]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2]) == True\n assert candidate(arr = [1, 3, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 3, 2, 4, 3, 2]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == False\n assert candidate(arr = [1, 3, 2, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 6, 7, 8, 9]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 5, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n", "comparison": "exact"}, "public_tests": ["[2,1]", "[3,5,5]", "[0,3,2,1]"], "hints": ["It's very easy to keep track of a monotonically increasing or decreasing ordering of elements. You just need to be able to determine the start of the valley in the mountain and from that point onwards, it should be a valley i.e. no mini-hills after that. Use this information in regards to the values in the array and you will be able to come up with a straightforward solution."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().validMountainArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:55+00:00", "tests_total": 141, "tests_dropped": 24, "flags": ["has_images"], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def validMountainArray(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "validMountainArray", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 942, "task_id": "di-string-match", "difficulty": "Easy", "problem_description": "A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:\n\n- s[i] == 'I' if perm[i] < perm[i + 1], and\n- s[i] == 'D' if perm[i] > perm[i + 1].\n\nGiven a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them.\n\nExample 1:\n\nInput: s = \"IDID\"\nOutput: [0,4,1,3,2]\n\nExample 2:\n\nInput: s = \"III\"\nOutput: [0,1,2,3]\n\nExample 3:\n\nInput: s = \"DDI\"\nOutput: [3,2,0,1]\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is either 'I' or 'D'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"DDI\") == [3, 2, 0, 1]\n assert candidate(s = \"DDIDDI\") == [6, 5, 0, 4, 3, 1, 2]\n assert candidate(s = \"IDDD\") == [0, 4, 3, 2, 1]\n assert candidate(s = \"DDDDDDDD\") == [8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"I\") == [0, 1]\n assert candidate(s = \"IIIIII\") == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"D\") == [1, 0]\n assert candidate(s = \"IIII\") == [0, 1, 2, 3, 4]\n assert candidate(s = \"IDDDIII\") == [0, 7, 6, 5, 1, 2, 3, 4]\n assert candidate(s = \"DDII\") == [4, 3, 0, 1, 2]\n assert candidate(s = \"IDIDIDIDID\") == [0, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(s = \"IIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(s = \"DDDDDD\") == [6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"III\") == [0, 1, 2, 3]\n assert candidate(s = \"IDID\") == [0, 4, 1, 3, 2]\n assert candidate(s = \"DDDD\") == [4, 3, 2, 1, 0]\n assert candidate(s = \"DDIDDID\") == [7, 6, 0, 5, 4, 1, 3, 2]\n assert candidate(s = \"IDIDIDID\") == [0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"IIDDD\") == [0, 1, 5, 4, 3, 2]\n assert candidate(s = \"DDDII\") == [5, 4, 3, 0, 1, 2]\n assert candidate(s = \"IIIIIIIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(s = \"IDDDDDDDDDDDDD\") == [0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"DDIIIDDDIIID\") == [12, 11, 0, 1, 2, 10, 9, 8, 3, 4, 5, 7, 6]\n assert candidate(s = \"IDDDDDDDII\") == [0, 10, 9, 8, 7, 6, 5, 4, 1, 2, 3]\n assert candidate(s = \"DDDDDDIIIII\") == [11, 10, 9, 8, 7, 6, 0, 1, 2, 3, 4, 5]\n assert candidate(s = \"IDDDDDDDDIIIII\") == [0, 14, 13, 12, 11, 10, 9, 8, 7, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"IIDIIDIIDI\") == [0, 1, 10, 2, 3, 9, 4, 5, 8, 6, 7]\n assert candidate(s = \"DDIDDIDDID\") == [10, 9, 0, 8, 7, 1, 6, 5, 2, 4, 3]\n assert candidate(s = \"DDDDDDIDID\") == [10, 9, 8, 7, 6, 5, 0, 4, 1, 3, 2]\n assert candidate(s = \"DDDDDDDDDIDDDD\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 0, 5, 4, 3, 2, 1]\n assert candidate(s = \"IIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"IDDDDDIIIIII\") == [0, 12, 11, 10, 9, 8, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(s = \"DDDDDDDDDDDDDDDD\") == [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"DDDDDDIII\") == [9, 8, 7, 6, 5, 4, 0, 1, 2, 3]\n assert candidate(s = \"IIDDDDIIIDDD\") == [0, 1, 12, 11, 10, 9, 2, 3, 4, 8, 7, 6, 5]\n assert candidate(s = \"DDDDDDDDDIIIII\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 0, 1, 2, 3, 4, 5]\n assert candidate(s = \"DDDDIIIID\") == [9, 8, 7, 6, 0, 1, 2, 3, 5, 4]\n assert candidate(s = \"IDIDIDIDIDIDID\") == [0, 14, 1, 13, 2, 12, 3, 11, 4, 10, 5, 9, 6, 8, 7]\n assert candidate(s = \"DDDDDDDDDI\") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 1]\n assert candidate(s = \"DDDIDIDIDI\") == [10, 9, 8, 0, 7, 1, 6, 2, 5, 3, 4]\n assert candidate(s = \"DDDDDDDDDID\") == [11, 10, 9, 8, 7, 6, 5, 4, 3, 0, 2, 1]\n assert candidate(s = \"DDDDIDIDIDID\") == [12, 11, 10, 9, 0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"IIDIIIIIIIIDIDDDDD\") == [0, 1, 18, 2, 3, 4, 5, 6, 7, 8, 9, 17, 10, 16, 15, 14, 13, 12, 11]\n assert candidate(s = \"IDDDIIIIIIII\") == [0, 12, 11, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(s = \"DDDDIIIIIIIDIDIDIDIDID\") == [22, 21, 20, 19, 0, 1, 2, 3, 4, 5, 6, 18, 7, 17, 8, 16, 9, 15, 10, 14, 11, 13, 12]\n assert candidate(s = \"IIIIIIIIIIIIID\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 13]\n assert candidate(s = \"IDIDIDIDIDID\") == [0, 12, 1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]\n assert candidate(s = \"IIIIIIIDDDDD\") == [0, 1, 2, 3, 4, 5, 6, 12, 11, 10, 9, 8, 7]\n assert candidate(s = \"IDDDDDDDDDDDID\") == [0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 1, 3, 2]\n assert candidate(s = \"IIDIIIDDD\") == [0, 1, 9, 2, 3, 4, 8, 7, 6, 5]\n assert candidate(s = \"IIIIIIIIIID\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10]\n assert candidate(s = \"IIIIIIIDDD\") == [0, 1, 2, 3, 4, 5, 6, 10, 9, 8, 7]\n assert candidate(s = \"DDDDDDDDDDIIIIIIIIIID\") == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10]\n assert candidate(s = \"IDIDIDIDIDI\") == [0, 11, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]\n assert candidate(s = \"DDDDDDDDDDII\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 0, 1, 2]\n assert candidate(s = \"IDDDIIDDDIIDDDIIII\") == [0, 18, 17, 16, 1, 2, 15, 14, 13, 3, 4, 12, 11, 10, 5, 6, 7, 8, 9]\n assert candidate(s = \"DDDDIIIIDDDD\") == [12, 11, 10, 9, 0, 1, 2, 3, 8, 7, 6, 5, 4]\n assert candidate(s = \"IIIIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(s = \"IDIDIDDDDD\") == [0, 10, 1, 9, 2, 8, 7, 6, 5, 4, 3]\n assert candidate(s = \"IIIIIIIIIIIDDDDDDDDIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 28, 27, 26, 25, 24, 23, 22, 21, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(s = \"IDIDIDIDDDD\") == [0, 11, 1, 10, 2, 9, 3, 8, 7, 6, 5, 4]\n assert candidate(s = \"DDDDDDDDDDDD\") == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"IIIIIDDDDDID\") == [0, 1, 2, 3, 4, 12, 11, 10, 9, 8, 5, 7, 6]\n assert candidate(s = \"IDDDDDDDDDDDDIIIIIIIII\") == [0, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(s = \"IIDIDIDIDI\") == [0, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]\n assert candidate(s = \"IIIIIDDDDDDDDD\") == [0, 1, 2, 3, 4, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5]\n assert candidate(s = \"IIDIDIDIDID\") == [0, 1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]\n assert candidate(s = \"DDDIDIDIDID\") == [11, 10, 9, 0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"IIIDDDIIID\") == [0, 1, 2, 10, 9, 8, 3, 4, 5, 7, 6]\n assert candidate(s = \"IIIIIIIIIIIIIIIIIID\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 18]\n assert candidate(s = \"DDIIDDIDID\") == [10, 9, 0, 1, 8, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"DDDDIDDDDDDD\") == [12, 11, 10, 9, 0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"DDDDDDDDDDDDDDD\") == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"DIIDIDIDID\") == [10, 0, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(s = \"IDDDDDDDDIII\") == [0, 12, 11, 10, 9, 8, 7, 6, 5, 1, 2, 3, 4]\n assert candidate(s = \"DDDDDDDDD\") == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"DDDIDDDDDDDD\") == [12, 11, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"IIIIDDDDIII\") == [0, 1, 2, 3, 11, 10, 9, 8, 4, 5, 6, 7]\n assert candidate(s = \"IIDIDID\") == [0, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"IIIIIIIIIIIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(s = \"IDIDDDIDID\") == [0, 10, 1, 9, 8, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"DDDDDDDDDDDDDDDDDDDD\") == [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 = \"DDDDDDDDDD\") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"DDDDDDDDDDI\") == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 1]\n assert candidate(s = \"IDIDIDIDIDIDIDID\") == [0, 16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]\n assert candidate(s = \"DDDDDDDDDDDII\") == [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 0, 1, 2]\n assert candidate(s = \"IIIIIDIIIIII\") == [0, 1, 2, 3, 4, 12, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(s = \"IIDDDDDDDDDD\") == [0, 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(s = \"IIIIIIIDDDD\") == [0, 1, 2, 3, 4, 5, 6, 11, 10, 9, 8, 7]\n assert candidate(s = \"IIIIDDDDDDID\") == [0, 1, 2, 3, 12, 11, 10, 9, 8, 7, 4, 6, 5]\n assert candidate(s = \"DDDDDIDDDDD\") == [11, 10, 9, 8, 7, 0, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"DDDDIIII\") == [8, 7, 6, 5, 0, 1, 2, 3, 4]\n assert candidate(s = \"IIIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(s = \"IIIIIIIIIIIDDDDDDDDDD\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(s = \"DDDDDDDIIIII\") == [12, 11, 10, 9, 8, 7, 6, 0, 1, 2, 3, 4, 5]\n assert candidate(s = \"IDIDIDIDDDDD\") == [0, 12, 1, 11, 2, 10, 3, 9, 8, 7, 6, 5, 4]\n assert candidate(s = \"DDIDIDIDID\") == [10, 9, 0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"DDIIDDDIIID\") == [11, 10, 0, 1, 9, 8, 7, 2, 3, 4, 6, 5]\n assert candidate(s = \"IIDDDDDDII\") == [0, 1, 10, 9, 8, 7, 6, 5, 2, 3, 4]\n assert candidate(s = \"IIDIDIDID\") == [0, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(s = \"DDDDDDDIIIIIII\") == [14, 13, 12, 11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(s = \"IIIIIIIIIIIIIIDDDDDDDDDDDD\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14]\n assert candidate(s = \"IIIIIDDDDIII\") == [0, 1, 2, 3, 4, 12, 11, 10, 9, 5, 6, 7, 8]\n assert candidate(s = \"DIDIDIDIDIDIDIDIDIDIDIDID\") == [25, 0, 24, 1, 23, 2, 22, 3, 21, 4, 20, 5, 19, 6, 18, 7, 17, 8, 16, 9, 15, 10, 14, 11, 13, 12]\n assert candidate(s = \"DDDDIIIIIIIDDDIIIIIDDDIIII\") == [26, 25, 24, 23, 0, 1, 2, 3, 4, 5, 6, 22, 21, 20, 7, 8, 9, 10, 11, 19, 18, 17, 12, 13, 14, 15, 16]\n assert candidate(s = \"IIIDDDDDDD\") == [0, 1, 2, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(s = \"IIIIIDDDDD\") == [0, 1, 2, 3, 4, 10, 9, 8, 7, 6, 5]\n assert candidate(s = \"DDDDDDDDDDIIII\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 0, 1, 2, 3, 4]\n assert candidate(s = \"IDDDDDDDDDDD\") == [0, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"DDDDIIIIIIIIIIIIDDDDD\") == [21, 20, 19, 18, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 16, 15, 14, 13, 12]\n assert candidate(s = \"IIIIIDDDDDD\") == [0, 1, 2, 3, 4, 11, 10, 9, 8, 7, 6, 5]\n assert candidate(s = \"IIDIIIIIDDDD\") == [0, 1, 12, 2, 3, 4, 5, 6, 11, 10, 9, 8, 7]\n assert candidate(s = \"DDDDDDDDIII\") == [11, 10, 9, 8, 7, 6, 5, 4, 0, 1, 2, 3]\n assert candidate(s = \"DDIDIDIDIDID\") == [12, 11, 0, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(s = \"DDDDDDDDDIDIDID\") == [15, 14, 13, 12, 11, 10, 9, 8, 7, 0, 6, 1, 5, 2, 4, 3]\n assert candidate(s = \"IIIIIIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(s = \"IIDDDIIIDDD\") == [0, 1, 11, 10, 9, 2, 3, 4, 8, 7, 6, 5]\n assert candidate(s = \"DIDIDIDIDI\") == [10, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5]\n assert candidate(s = \"DDDDDDDDDDDDDD\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"DDDDDDIDDDII\") == [12, 11, 10, 9, 8, 7, 0, 6, 5, 4, 1, 2, 3]\n assert candidate(s = \"IDIDDDDDDD\") == [0, 10, 1, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDIDIDID\") == [0, 24, 1, 23, 2, 22, 3, 21, 4, 20, 5, 19, 6, 18, 7, 17, 8, 16, 9, 15, 10, 14, 11, 13, 12]\n assert candidate(s = \"DDDDIIIIIII\") == [11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(s = \"DDDDDDIIID\") == [10, 9, 8, 7, 6, 5, 0, 1, 2, 4, 3]\n assert candidate(s = \"IDIDIDIDIDIDIDIDIDID\") == [0, 20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10]\n assert candidate(s = \"DDDDDDDDDDDDD\") == [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"IIDDDDDDID\") == [0, 1, 10, 9, 8, 7, 6, 5, 2, 4, 3]\n assert candidate(s = \"IIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(s = \"DDDDDDIIII\") == [10, 9, 8, 7, 6, 5, 0, 1, 2, 3, 4]\n assert candidate(s = \"DDDDIIDDII\") == [10, 9, 8, 7, 0, 1, 6, 5, 2, 3, 4]\n assert candidate(s = \"DIDIDIDIDID\") == [11, 0, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(s = \"DDDDDDDDDDDID\") == [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 0, 2, 1]\n assert candidate(s = \"DDDDDDDDDDD\") == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(s = \"DDIIIDDDII\") == [10, 9, 0, 1, 2, 8, 7, 6, 3, 4, 5]\n assert candidate(s = \"DDDDDDDDDIIIIIIIIIIDDDDDDDD\") == [27, 26, 25, 24, 23, 22, 21, 20, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 17, 16, 15, 14, 13, 12, 11, 10]\n assert candidate(s = \"DDDDDIIIIII\") == [11, 10, 9, 8, 7, 0, 1, 2, 3, 4, 5, 6]\n assert candidate(s = \"IIDDDDDIII\") == [0, 1, 10, 9, 8, 7, 6, 2, 3, 4, 5]\n assert candidate(s = \"IDIDDDDDDDDDDD\") == [0, 14, 1, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(s = \"DDDDDDDDDDDDDIIIIIIIIIIIII\") == [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(s = \"IIDDDDIIID\") == [0, 1, 10, 9, 8, 7, 2, 3, 4, 6, 5]\n assert candidate(s = \"IIIIIIIIIIIID\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 12]\n assert candidate(s = \"DDIIDDDIID\") == [10, 9, 0, 1, 8, 7, 6, 2, 3, 5, 4]\n assert candidate(s = \"DIDIDIDID\") == [9, 0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(s = \"IIIIIIIDDDDDDD\") == [0, 1, 2, 3, 4, 5, 6, 14, 13, 12, 11, 10, 9, 8, 7]\n assert candidate(s = \"IDDDDDDDDD\") == [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"IIIIIIIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(s = \"IIIIIIIIIIID\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 11]\n assert candidate(s = \"IDIDIDDDDDD\") == [0, 11, 1, 10, 2, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(s = \"IIDDDDDDDD\") == [0, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(s = \"IIDDDDDDDDID\") == [0, 1, 12, 11, 10, 9, 8, 7, 6, 5, 2, 4, 3]\n assert candidate(s = \"IIIIIIIII\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(s = \"IDDDDDDDDDD\") == [0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(s = \"IIIIIDIDIDIDIDIDIDDD\") == [0, 1, 2, 3, 4, 20, 5, 19, 6, 18, 7, 17, 8, 16, 9, 15, 10, 14, 13, 12, 11]\n assert candidate(s = \"DDDDDDDDDDDDDDDIDDD\") == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 0, 4, 3, 2, 1]\n assert candidate(s = \"DDDDDDDDDDDIII\") == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 0, 1, 2, 3]\n assert candidate(s = \"DIIIDDDIIIID\") == [12, 0, 1, 2, 11, 10, 9, 3, 4, 5, 6, 8, 7]\n assert candidate(s = \"IDDDIDDDID\") == [0, 10, 9, 8, 1, 7, 6, 5, 2, 4, 3]\n", "comparison": "exact"}, "public_tests": ["\"IDID\"", "\"III\"", "\"DDI\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().diStringMatch", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:57+00:00", "tests_total": 157, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["array", "two-pointers", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def diStringMatch(self, s: str) -> list[int]:", "container": "Solution", "callable": "diStringMatch", "parameters": [{"name": "s", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 943, "task_id": "find-the-shortest-superstring", "difficulty": "Hard", "problem_description": "Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return any of them.\n\nYou may assume that no string in words is a substring of another string in words.\n\nExample 1:\n\nInput: words = [\"alex\",\"loves\",\"leetcode\"]\nOutput: \"alexlovesleetcode\"\nExplanation: All permutations of \"alex\",\"loves\",\"leetcode\" would also be accepted.\n\nExample 2:\n\nInput: words = [\"catg\",\"ctaagt\",\"gcta\",\"ttca\",\"atgcatc\"]\nOutput: \"gctaagttcatgcatc\"\n\nConstraints:\n\n- 1 <= words.length <= 12\n- 1 <= words[i].length <= 20\n- words[i] consists of lowercase English letters.\n- All the strings of words are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'ab', 'abc']) == \"abc\"\n assert candidate(words = ['abcde', 'bcdef', 'cdefg']) == \"abcdefg\"\n assert candidate(words = ['a', 'b', 'c']) == \"abc\"\n assert candidate(words = ['shortest', 'superstring', 'string', 'abc']) == \"superstringshortestabc\"\n assert candidate(words = ['abc', 'bcd', 'xyz', 'zyx']) == \"zyxyzabcd\"\n assert candidate(words = ['aaa', 'bbb', 'ccc']) == \"aaabbbccc\"\n assert candidate(words = ['abcd', 'cde', 'efg', 'ghij']) == \"abcdefghij\"\n assert candidate(words = ['catg', 'ctaagt', 'gcta', 'ttca', 'atgcatc']) == \"gctaagttcatgcatc\"\n assert candidate(words = ['apple', 'plea', 'peach']) == \"appleapeach\"\n assert candidate(words = ['unique', 'ness', 'super', 'set']) == \"nessuperuniqueset\"\n assert candidate(words = ['abcd', 'cdab', 'bcda', 'dabc']) == \"bcdabcd\"\n assert candidate(words = ['ab', 'bc', 'cd']) == \"abcd\"\n assert candidate(words = ['hello', 'world', 'abc']) == \"helloworldabc\"\n assert candidate(words = ['alex', 'loves', 'leetcode']) == \"alexlovesleetcode\"\n assert candidate(words = ['abc', 'bcd', 'cde', 'def', 'efg']) == \"abcdefg\"\n assert candidate(words = ['short', 'longer', 'longest']) == \"shortlongerlongest\"\n assert candidate(words = ['one', 'two', 'three', 'four']) == \"twonethreefour\"\n assert candidate(words = ['abc', 'bca', 'cab']) == \"bcabc\"\n assert candidate(words = ['hello', 'world', 'word', 'dlrow', 'row']) == \"wordlroworldhello\"\n assert candidate(words = ['abcd', 'cdef', 'efab', 'fabc']) == \"cdefabcd\"\n assert candidate(words = ['abcd', 'cdabcd', 'bcdaabcd', 'dabcabcd', 'abcdabcd', 'bcabcd', 'cdababcd', 'dababcd', 'abcabcd', 'bcdabc', 'cdabc', 'dabc']) == \"cdababcdabcabcdaabcdabcd\"\n assert candidate(words = ['aaaa', 'bbba', 'abbb', 'baaa']) == \"abbbaaaa\"\n assert candidate(words = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi']) == \"abcdefghi\"\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn']) == \"abcdefghijklmn\"\n assert candidate(words = ['abcd', 'cdab', 'bcda', 'dabc', 'abdc', 'dcba', 'cadb', 'bdac']) == \"bdacadbdabcdabdcba\"\n assert candidate(words = ['abcdefghij', 'bcdefghijk', 'cdefghijkl', 'defghijklm', 'efghijklmn', 'fghijklmno', 'ghijklmnop', 'hijklmnopq', 'ijklmnopqr', 'jklmnopqrs', 'klmnopqrst', 'lmnopqrstu']) == \"abcdefghijklmnopqrstu\"\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == \"sevenineightensixfivefourthreetwone\"\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'ddee', 'eeff', 'ffgg', 'ggaa', 'aacc', 'ccbb', 'ddeeff', 'ffggaa', 'aabbcc']) == \"aaccddeeffggaabbccbb\"\n assert candidate(words = ['abcd', 'cdab', 'bcda', 'dabc', 'abcdabc', 'bcdbcd']) == \"abcdabcdbcdab\"\n assert candidate(words = ['unique', 'words', 'here', 'are', 'some', 'more', 'complex', 'test', 'cases']) == \"casesomeareherewordsuniquemorecomplextest\"\n assert candidate(words = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm']) == \"abcdefghijklm\"\n assert candidate(words = ['ab', 'bc', 'ca', 'ac', 'ba']) == \"bacabc\"\n assert candidate(words = ['xyz', 'yzabc', 'abcde', 'cdefg', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn', 'klmno', 'lmnop']) == \"xyzabcdefghijklmnop\"\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno']) == \"abcdefghijklmno\"\n assert candidate(words = ['overlap', 'lapover', 'lover', 'verlap', 'overla', 'verlapo', 'verlapov', 'overlapov', 'verlapove', 'lapoverla']) == \"loverlapoverlapo\"\n assert candidate(words = ['algorithm', 'rhythm', 'myth', 'throttle', 'thorn', 'horn']) == \"thornrhythmythrottlealgorithm\"\n assert candidate(words = ['aabbccdd', 'bbccddaa', 'ccddaabb', 'ddaaaabb', 'aaaabbbb', 'bbbbaaaa']) == \"ddaaaabbbbaaaabbccddaabb\"\n assert candidate(words = ['prefix', 'refix', 'fix', 'ix', 'x', 'suffix', 'uffix', 'ffix', 'fixy', 'xylophone', 'phone', 'honeymoon']) == \"suffixylophoneymoonprefix\"\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']) == \"twelvelevenineightensevensixfivefourthreetwone\"\n assert candidate(words = ['pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == \"pqrstuvwxyz\"\n assert candidate(words = ['xyz', 'yzw', 'wxy', 'uvw', 'vwxy', 'wxyz', 'xyzu']) == \"xyzuvwxyzw\"\n assert candidate(words = ['overlap', 'laplong', 'longer', 'ergonomic', 'nomics', 'micronix', 'nixos', 'xenon', 'nonya', 'yonder', 'nder', 'derivation']) == \"yonderivationxenonyamicronixosoverlaplongergonomics\"\n assert candidate(words = ['abcdef', 'defghi', 'ghijkl', 'jklmno', 'mnopqr', 'nopqrs']) == \"abcdefghijklmnopqrs\"\n assert candidate(words = ['hello', 'world', 'foobar', 'barfoo', 'foobaz', 'bazfoo', 'bazbar', 'bazoof', 'foobazoo', 'oofbazfo']) == \"bazbarfoobazoofbazfoobarworldhello\"\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']) == \"twelvelevenineightensevensixfivefourthreetwone\"\n assert candidate(words = ['xyz', 'yzab', 'zabc', 'abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij']) == \"xyzabcdefghij\"\n assert candidate(words = ['abcd', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn']) == \"abcdefghijklmn\"\n assert candidate(words = ['abc', 'bca', 'cab', 'acb', 'bac', 'cba', 'ab', 'bc', 'ca', 'ba', 'ac', 'cb']) == \"cbacbcabc\"\n assert candidate(words = ['aabbcc', 'bbccdd', 'ccddee', 'ddeeff', 'eefggh', 'fgghii']) == \"eefgghiiaabbccddeeff\"\n assert candidate(words = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn', 'klmno', 'lmnop']) == \"abcdefghijklmnop\"\n assert candidate(words = ['ab', 'bc', 'cd', 'da']) == \"bcdab\"\n assert candidate(words = ['overlap', 'lapping', 'ping', 'pingpong', 'ong', 'overlaplap', 'laplaplap', 'pingping']) == \"overlaplaplappingpingpong\"\n assert candidate(words = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg', 'eeffgghh']) == \"aabbccddeeffgghh\"\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno']) == \"abcdefghijklmno\"\n assert candidate(words = ['xyz', 'yzx', 'zxy', 'xyx', 'yxy', 'xyy', 'yxx', 'yzy', 'zyz', 'zyx', 'xzy', 'yxz']) == \"yxzyzyxxyxyzxyy\"\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six']) == \"twonethreefourfivesix\"\n assert candidate(words = ['aabbcc', 'bccdda', 'cdddee', 'ddeeff', 'effggg', 'ffgggh', 'ggghhh', 'hhhiii', 'iiiijj', 'jjjkkl', 'kkllmm', 'llmmnn']) == \"cdddeeffggghhhiiiijjjkkllmmnnaabbccdda\"\n assert candidate(words = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn', 'klmno', 'lmnop']) == \"abcdefghijklmnop\"\n assert candidate(words = ['longest', 'string', 'that', 'contains', 'overlapping', 'parts']) == \"longestringthatcontainsoverlappingparts\"\n assert candidate(words = ['abcdef', 'defghi', 'ghijkl', 'ijklmn', 'mnopqr']) == \"abcdefghijklmnopqr\"\n assert candidate(words = ['abcdef', 'defghi', 'ghijkl', 'ijklmn', 'mnopqr']) == \"abcdefghijklmnopqr\"\n assert candidate(words = ['abcdefgh', 'efghijkl', 'ghijklmn', 'ijklmnop', 'jklmnopq', 'klmnopqr', 'mnopqrst', 'nopqrstu', 'opqrstuv', 'pqrstuvw', 'qrstuvwx', 'rstuvxyz']) == \"abcdefghijklmnopqrstuvwxrstuvxyz\"\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk']) == \"abcdefghijk\"\n assert candidate(words = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg', 'effgghh', 'ffgghhiijj', 'gghhiijjkk', 'hhiijjkkll', 'iijjkkllmm', 'jjkkllmmnn', 'kkllmmnnoo', 'llmmnnoopp']) == \"aabbccddeeffgghhiijjkkllmmnnoopp\"\n assert candidate(words = ['overlap', 'lapping', 'ping', 'pingpong', 'ong']) == \"overlappingpong\"\n assert candidate(words = ['pqr', 'qrp', 'rqp', 'prq', 'rpq', 'pqq', 'qqp']) == \"pqrpqqprqp\"\n assert candidate(words = ['abcxyz', 'xyzuvw', 'uvwdef', 'defghj', 'ghjklm', 'klmnop', 'mnopqr']) == \"abcxyzuvwdefghjklmnopqr\"\n assert candidate(words = ['overlap', 'laptime', 'timefly', 'flyby', 'bymy', 'myself']) == \"overlaptimeflybymyself\"\n assert candidate(words = ['rotation', 'otationr', 'tationro', 'ationrot', 'tionrota', 'ionrotat', 'onrotate', 'nrotate', 'rotate']) == \"rotationrotate\"\n assert candidate(words = ['aaa', 'aab', 'aba', 'abb', 'baa', 'bab', 'bba', 'bbb', 'aabbaa', 'bbbaab']) == \"bbababbbaabbaaa\"\n assert candidate(words = ['abcdef', 'defabc', 'bcdefa', 'cdefab']) == \"abcdefabc\"\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg']) == \"abcdefg\"\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll']) == \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllll\"\n assert candidate(words = ['qwerty', 'wertyu', 'ertyui', 'rtyuiop', 'tyuiopq', 'yuiopqr']) == \"qwertyuiopqr\"\n assert candidate(words = ['unique', 'strings', 'for', 'this', 'problem', 'are', 'here', 'and', 'there', 'everywhere']) == \"thereverywhereareproblemforthistringsuniqueand\"\n assert candidate(words = ['abcdef', 'cdefgh', 'efghij', 'ghijkl']) == \"abcdefghijkl\"\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba', 'abba', 'baab']) == \"bababbaabb\"\n assert candidate(words = ['apple', 'pleas', 'please', 'ease', 'asean', 'anean', 'nean', 'east']) == \"appleaseaneaneast\"\n assert candidate(words = ['pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'yza', 'zab']) == \"pqrstuvwxyzab\"\n assert candidate(words = ['abcxyz', 'xyzuvw', 'uvwdef', 'defghi', 'ghijkl', 'jklmno', 'mnopqr', 'nopqrs', 'pqrsuv', 'qrstuv', 'vwxyza']) == \"qrstuvwxyzabcxyzuvwdefghijklmnopqrsuv\"\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']) == \"abcdefghijkl\"\n assert candidate(words = ['aaaa', 'bbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll']) == \"aaaabbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllll\"\n assert candidate(words = ['abcdef', 'defghi', 'ghijkl', 'jklmno', 'mnopqr', 'nopqrs', 'pqrsuv', 'qrstuv']) == \"abcdefghijklmnopqrsuvqrstuv\"\n assert candidate(words = ['abcdef', 'bcdegh', 'cdefij', 'defgkl', 'efghmn', 'fghnop', 'ghnopq', 'hnoqrs', 'noqrst', 'qrstuv', 'rstuvw', 'stuvwx']) == \"bcdeghnoqrstuvwxfghnopqefghmndefgklabcdefij\"\n assert candidate(words = ['ab', 'bc', 'cd', 'de', 'ef', 'fa']) == \"bcdefab\"\n assert candidate(words = ['abcdefgh', 'ghijklmn', 'mnopqrst', 'rstuvwxy', 'xyzabcde']) == \"ghijklmnopqrstuvwxyzabcdefgh\"\n", "comparison": "exact"}, "public_tests": ["[\"alex\",\"loves\",\"leetcode\"]", "[\"catg\",\"ctaagt\",\"gcta\",\"ttca\",\"atgcatc\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().shortestSuperstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:04:59+00:00", "tests_total": 96, "tests_dropped": 10, "flags": ["multiple_answers"], "topic_tags": ["array", "string", "dynamic-programming", "bit-manipulation", "bitmask", "hamiltonian-path"]}, "language": "python", "interface": {"raw_signature": "def shortestSuperstring(self, words: list[str]) -> str:", "container": "Solution", "callable": "shortestSuperstring", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 944, "task_id": "delete-columns-to-make-sorted", "difficulty": "Easy", "problem_description": "You are given an array of n strings strs, all of the same length.\n\nThe strings can be arranged such that there is one on each line, making a grid.\n\n- For example, strs = [\"abc\", \"bce\", \"cae\"] can be arranged as follows:\n\nabc\nbce\ncae\n\nYou want to delete the columns that are not sorted lexicographically. In the above example (0-indexed), columns 0 ('a', 'b', 'c') and 2 ('c', 'e', 'e') are sorted, while column 1 ('b', 'c', 'a') is not, so you would delete column 1.\n\nReturn the number of columns that you will delete.\n\nExample 1:\n\nInput: strs = [\"cba\",\"daf\",\"ghi\"]\nOutput: 1\nExplanation: The grid looks as follows:\n cba\n daf\n ghi\nColumns 0 and 2 are sorted, but column 1 is not, so you only need to delete 1 column.\n\nExample 2:\n\nInput: strs = [\"a\",\"b\"]\nOutput: 0\nExplanation: The grid looks as follows:\n a\n b\nColumn 0 is the only column and is sorted, so you will not delete any columns.\n\nExample 3:\n\nInput: strs = [\"zyx\",\"wvu\",\"tsr\"]\nOutput: 3\nExplanation: The grid looks as follows:\n zyx\n wvu\n tsr\nAll 3 columns are not sorted, so you will delete all 3.\n\nConstraints:\n\n- n == strs.length\n- 1 <= n <= 100\n- 1 <= strs[i].length <= 1000\n- strs[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strs = ['zaz', 'zbz', 'zcz']) == 0\n assert candidate(strs = ['a', 'b']) == 0\n assert candidate(strs = ['zzz', 'zzz', 'zzz']) == 0\n assert candidate(strs = ['xyz', 'yza', 'zab']) == 2\n assert candidate(strs = ['abc', 'bcd', 'cde']) == 0\n assert candidate(strs = ['abc', 'abc', 'abc']) == 0\n assert candidate(strs = ['abcd', 'efgh', 'ijkl']) == 0\n assert candidate(strs = ['cba', 'daf', 'ghi']) == 1\n assert candidate(strs = ['abc', 'bce', 'cae']) == 1\n assert candidate(strs = ['zyx', 'wvu', 'tsr']) == 3\n assert candidate(strs = ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm', 'abcn', 'abco', 'abcp', 'abcq', 'abcr', 'abcs', 'abct', 'abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm', 'abcn', 'abco', 'abcp', 'abcq', 'abcr', 'abcs', 'abct']) == 1\n assert candidate(strs = ['xyz', 'yza', 'zab', 'abc', 'bcd', 'cde']) == 3\n assert candidate(strs = ['xyz', 'uvw', 'rst', 'qpo', 'nml', 'klm', 'jih', 'fed', 'cba']) == 3\n assert candidate(strs = ['qwe', 'wer', 'ert', 'rty', 'tyu', 'yui', 'uio', 'iop', 'opq', 'pqa', 'qaz', 'wsx', 'edc', 'rfv', 'tgb', 'yhn', 'ujm', 'ikl', 'olk', 'pvc', 'bnm']) == 3\n assert candidate(strs = ['xyz', 'xyx', 'xzy']) == 1\n assert candidate(strs = ['zyx', 'yxw', 'xwv', 'uvw']) == 3\n assert candidate(strs = ['abcd', 'dbca', 'efgh', 'hgfj']) == 2\n assert candidate(strs = ['abcd', 'abce', 'abcf', 'abcg', 'abch']) == 0\n assert candidate(strs = ['zz', 'zy', 'yx', 'xz', 'yz', 'zx']) == 2\n assert candidate(strs = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == 4\n assert candidate(strs = ['aabbcc', 'bbccdd', 'ccddee', 'ddeeff']) == 0\n assert candidate(strs = ['zzzz', 'zzzy', 'zzzx', 'zzxw']) == 2\n assert candidate(strs = ['mnop', 'mnoq', 'mnop']) == 1\n assert candidate(strs = ['aabbcc', 'abacbc', 'abcabc', 'acbacb', 'accbab', 'babcac', 'bbacab', 'bbcaab', 'bcabca', 'bcacab', 'bcbaca', 'bcbcaa', 'cacaba', 'cacbaa', 'caacab', 'caacba', 'cababc', 'cabacb', 'cabbac', 'cabcab', 'cabcba', 'cacabc', 'cacbba', 'cbabac', 'cbabca', 'cbacab', 'cbacba', 'cbbaca', 'cbbcaa', 'ccabab', 'ccabac', 'ccabba', 'ccbaab', 'ccbaca', 'ccbacb']) == 5\n assert candidate(strs = ['abcd', 'abdc', 'acdb']) == 1\n assert candidate(strs = ['aaaa', 'aaab', 'aabb', 'abbb']) == 0\n assert candidate(strs = ['abc', 'bac', 'bca', 'cab', 'cba', 'acb']) == 3\n assert candidate(strs = ['same', 'sake', 'sage', 'sage', 'sane', 'sane', 'sane']) == 1\n assert candidate(strs = ['abcdef', 'bcdefg', 'cdefgh', 'defghi']) == 0\n assert candidate(strs = ['abc', 'bac', 'cab', 'cba', 'bca', 'acb']) == 3\n assert candidate(strs = ['cat', 'dog', 'bat', 'rat', 'hat', 'mat', 'eat', 'tat', 'sat', 'pat']) == 3\n assert candidate(strs = ['abcd', 'dcba', 'abcd', 'dcba']) == 4\n assert candidate(strs = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff']) == 0\n assert candidate(strs = ['apple', 'apply', 'appla']) == 1\n assert candidate(strs = ['zzzz', 'zzyx', 'zzyv', 'zzyu', 'zzyt', 'zzyr', 'zzys', 'zzyr', 'zzyp', 'zzyq', 'zzxo', 'zzxn', 'zzxm', 'zzxl', 'zzxk', 'zzxj', 'zzxi', 'zzxh', 'zzxg', 'zzxf', 'zzxe', 'zzxd', 'zzxc', 'zzwb', 'zzwa', 'zzza']) == 2\n assert candidate(strs = ['leetcode', 'loveleetcode', 'leetcodeer', 'leetcodexx']) == 7\n assert candidate(strs = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 0\n assert candidate(strs = ['ab', 'ba', 'ab', 'ba', 'ab']) == 2\n assert candidate(strs = ['hello', 'helpp', 'hells']) == 1\n assert candidate(strs = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk']) == 0\n assert candidate(strs = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yzc']) == 1\n assert candidate(strs = ['mnop', 'qrst', 'uvwx', 'yzab']) == 2\n assert candidate(strs = ['abcd', 'abdc', 'acbd', 'adbc']) == 2\n assert candidate(strs = ['xyzz', 'wvut', 'qrst', 'ponm', 'lkji', 'hgfed', 'cbazyx', 'abcdefgh']) == 4\n assert candidate(strs = ['qrst', 'qrsu', 'qrsu']) == 0\n assert candidate(strs = ['abcd', 'abcf', 'abce', 'abcd', 'abcf', 'abcd']) == 1\n assert candidate(strs = ['qrst', 'abcd', 'mnop', 'efgh']) == 4\n assert candidate(strs = ['abcd', 'dddd', 'abcd', 'dddd']) == 3\n assert candidate(strs = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']) == 1\n assert candidate(strs = ['hello', 'hallo', 'hullo', 'hella']) == 2\n assert candidate(strs = ['aabbccdd', 'bbaaccee', 'ccddeeff', 'ddeeffgg']) == 2\n assert candidate(strs = ['zyxwvu', 'utsrqo', 'ponmlk', 'jihgfed', 'cba']) == 6\n assert candidate(strs = ['abc', 'bca', 'cab', 'acb']) == 3\n assert candidate(strs = ['pqr', 'stu', 'vwx', 'yzp']) == 1\n assert candidate(strs = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']) == 0\n assert candidate(strs = ['mnop', 'mlkj', 'ihgf', 'edcb']) == 4\n assert candidate(strs = ['xyz', 'zyx', 'yzz', 'xzz']) == 2\n assert candidate(strs = ['zzzz', 'yyyy', 'xxxx', 'wwww']) == 4\n assert candidate(strs = ['abcdefg', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'fghijkl', 'ghijklm']) == 0\n assert candidate(strs = ['xyz', 'wxy', 'uvw', 'stu']) == 3\n assert candidate(strs = ['mnop', 'mnop', 'mnop', 'mnop']) == 0\n assert candidate(strs = ['a', 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']) == 1\n assert candidate(strs = ['abcd', 'acbd', 'adbc', 'dabc', 'dbac', 'dcab', 'dcba']) == 3\n assert candidate(strs = ['abcd', 'acfg', 'aegi', 'afih']) == 1\n assert candidate(strs = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg', 'eeffgghh', 'ffgghhii']) == 0\n assert candidate(strs = ['xyz', 'uvw', 'rst', 'qpo']) == 3\n assert candidate(strs = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == 3\n assert candidate(strs = ['abcdefgh', 'hgfedcba', 'abcdefgh', 'hgfedcba', 'abcdefgh', 'hgfedcba']) == 8\n assert candidate(strs = ['mnop', 'mnoq', 'mnop', 'mnop']) == 1\n assert candidate(strs = ['abcd', 'abcf', 'abce', 'abch', 'abcd', 'abci', 'abcd', 'abck']) == 1\n assert candidate(strs = ['aeg', 'bdf', 'cce']) == 2\n assert candidate(strs = ['mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz']) == 4\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg']) == 0\n assert candidate(strs = ['abcdef', 'acdefg', 'aeghij']) == 0\n assert candidate(strs = ['abcd', 'bfgh', 'cgij', 'dhjk']) == 0\n assert candidate(strs = ['banana', 'bandana', 'bananna']) == 2\n assert candidate(strs = ['abcd', 'abdc', 'abcc']) == 2\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz']) == 0\n assert candidate(strs = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg']) == 0\n assert candidate(strs = ['pqr', 'pqs', 'pqt', 'pqu', 'pqv', 'pqw', 'pqx', 'pqy', 'pqz']) == 0\n assert candidate(strs = ['abcdef', 'fghijk', 'lmnopq', 'rstuvw', 'xyzuvw', 'vwxyzw', 'utrewq', 'ponmlk', 'jihgfedcba']) == 6\n assert candidate(strs = ['zyxwv', 'utsrq', 'ponml', 'kjihg', 'fedcba']) == 5\n assert candidate(strs = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz']) == 0\n assert candidate(strs = ['abcdefg', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk']) == 0\n assert candidate(strs = ['water', 'waste', 'wider']) == 3\n assert candidate(strs = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk']) == 0\n assert candidate(strs = ['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']) == 0\n assert candidate(strs = ['abcd', 'acfg', 'aegh']) == 0\n assert candidate(strs = ['zzzzzzzz', 'zzyyyyxx', 'zyxwvutu', 'zyxwvuts']) == 7\n assert candidate(strs = ['xzy', 'uvw', 'rst', 'qpo', 'nml', 'klm', 'jih', 'fed', 'cba', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yzx']) == 3\n assert candidate(strs = ['abc', 'bca', 'cab', 'bac']) == 3\n assert candidate(strs = ['aab', 'aac', 'aab', 'aac']) == 1\n assert candidate(strs = ['abcd', 'bfgh', 'cgij', 'dhkj']) == 0\n assert candidate(strs = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj']) == 0\n assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop']) == 0\n assert candidate(strs = ['abcd', 'bfgh', 'cijj', 'dklm']) == 0\n assert candidate(strs = ['abcdefg', 'bcdefga', 'cdefgab', 'defgabc']) == 3\n assert candidate(strs = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee']) == 0\n", "comparison": "exact"}, "public_tests": ["[\"cba\",\"daf\",\"ghi\"]", "[\"a\",\"b\"]", "[\"zyx\",\"wvu\",\"tsr\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().minDeletionSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:01+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "string", "longest-increasing-subsequence"]}, "language": "python", "interface": {"raw_signature": "def minDeletionSize(self, strs: list[str]) -> int:", "container": "Solution", "callable": "minDeletionSize", "parameters": [{"name": "strs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 945, "task_id": "minimum-increment-to-make-array-unique", "difficulty": "Medium", "problem_description": "You are given an integer array nums. In one move, you can pick an index i where 0 <= i < nums.length and increment nums[i] by 1.\n\nReturn the minimum number of moves to make every value in nums unique.\n\nThe test cases are generated so that the answer fits in a 32-bit integer.\n\nExample 1:\n\nInput: nums = [1,2,2]\nOutput: 1\nExplanation: After 1 move, the array could be [1, 2, 3].\n\nExample 2:\n\nInput: nums = [3,2,1,2,1,7]\nOutput: 6\nExplanation: After 6 moves, the array could be [3, 4, 1, 2, 5, 7].\nIt can be shown that it is impossible for the array to have all unique values with 5 or less moves.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 16\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 45\n assert candidate(nums = [5, 3, 5, 3, 5]) == 4\n assert candidate(nums = [1, 2, 2]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [1, 3, 2, 2, 3, 3, 4]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 21\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 = [1, 3, 2, 2, 3, 1, 4, 4, 5, 5]) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(nums = [0, 0, 0, 0]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [5, 3, 5, 5, 5]) == 6\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 45\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3]) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [3, 2, 1, 2, 1, 7]) == 6\n assert candidate(nums = [10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [100000, 100000, 100000]) == 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]) == 140\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]) == 192\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 45\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]) == 300\n assert candidate(nums = [100, 100, 100, 101, 101, 101, 102, 102, 102, 103, 103, 103]) == 48\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 110\n assert candidate(nums = [20, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28]) == 137\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 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 528\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 170\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 25\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 462\n assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97, 96, 96]) == 25\n assert candidate(nums = [1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15]) == 7\n assert candidate(nums = [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, 100000, 100000, 100000, 100000, 100000]) == 435\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 140\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]) == 225\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 10, 10, 11]) == 163\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 = [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]) == 685\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 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]) == 121\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 89\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]) == 285\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 100\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 15\n assert candidate(nums = [2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16]) == 43\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 160\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 38\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 121\n assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105]) == 36\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]) == 89\n assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 64\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7]) == 45\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 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]) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 163\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 65\n assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 81\n assert candidate(nums = [100, 100, 100, 99, 99, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91]) == 98\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0]) == 50\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 145\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]) == 119\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 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 144\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100, 100, 100, 100]) == 15\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 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]) == 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, 21, 22, 23, 24, 25, 25, 25]) == 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]) == 190\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 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]) == 5\n assert candidate(nums = [2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 94\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [1, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == 99\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]) == 15\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 190\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 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, 2, 2, 3, 3, 4, 4, 5, 5]) == 225\n assert candidate(nums = [1, 3, 2, 3, 2, 4, 5, 4, 6, 7, 8, 9, 9]) == 28\n assert candidate(nums = [5, 3, 2, 2, 3, 3, 4, 4, 4, 5]) == 30\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 60\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4]) == 48\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 180\n assert candidate(nums = [1, 3, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 135\n assert candidate(nums = [5, 3, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 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]) == 147\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]) == 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]) == 250\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n", "comparison": "exact"}, "public_tests": ["[1,2,2]", "[3,2,1,2,1,7]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minIncrementForUnique", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:04+00:00", "tests_total": 104, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def minIncrementForUnique(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minIncrementForUnique", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 946, "task_id": "validate-stack-sequences", "difficulty": "Medium", "problem_description": "Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise.\n\nExample 1:\n\nInput: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]\nOutput: true\nExplanation: We might do the following sequence:\npush(1), push(2), push(3), push(4),\npop() -> 4,\npush(5),\npop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1\n\nExample 2:\n\nInput: pushed = [1,2,3,4,5], popped = [4,3,5,1,2]\nOutput: false\nExplanation: 1 cannot be popped before 2.\n\nConstraints:\n\n- 1 <= pushed.length <= 1000\n- 0 <= pushed[i] <= 1000\n- All the elements of pushed are unique.\n- popped.length == pushed.length\n- popped is a permutation of pushed.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [4, 5, 3, 2, 1]) == True\n assert candidate(pushed = [2, 1, 0],popped = [0, 1, 2]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [1, 3, 2, 5, 4]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [5, 4, 3, 2, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [4, 3, 5, 1, 2]) == False\n assert candidate(pushed = [1],popped = [1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [3, 5, 4, 2, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [2, 1, 5, 4, 3]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [2, 3, 4, 5, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [1, 2, 3, 4, 5]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [3, 2, 1, 5, 4]) == True\n assert candidate(pushed = [1, 2, 3],popped = [1, 3, 2]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [5, 1, 2, 3, 4]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [1, 5, 4, 3, 2]) == True\n assert candidate(pushed = [1, 2, 3],popped = [3, 2, 1]) == True\n assert candidate(pushed = [1, 4, 5, 6, 3, 2],popped = [2, 3, 6, 5, 4, 1]) == True\n assert candidate(pushed = [1, 3, 2, 5, 4, 6, 8, 7, 10, 9],popped = [3, 2, 1, 5, 4, 8, 7, 10, 9, 6]) == True\n assert candidate(pushed = [5, 4, 3, 2, 1],popped = [1, 2, 3, 4, 5]) == True\n assert candidate(pushed = [5, 1, 2, 4, 3],popped = [1, 5, 3, 4, 2]) == True\n assert candidate(pushed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],popped = [2, 4, 6, 8, 10, 12, 14, 16, 18, 1]) == False\n assert candidate(pushed = [1, 3, 2, 4, 5, 6, 7, 8, 9],popped = [3, 1, 4, 2, 5, 6, 7, 8, 9]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 3, 2, 5, 4, 8, 7, 6, 10, 9]) == True\n assert candidate(pushed = [1, 3, 2, 5, 4, 6],popped = [2, 5, 6, 4, 3, 1]) == True\n assert candidate(pushed = [7, 6, 5, 4, 3, 2, 1],popped = [1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 4, 3, 2, 5, 8, 7, 6, 10, 9]) == True\n assert candidate(pushed = [5, 3, 1, 2, 4, 6, 7],popped = [7, 6, 4, 2, 1, 3, 5]) == True\n assert candidate(pushed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],popped = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(pushed = [2, 1, 5, 4, 3, 6],popped = [3, 1, 6, 5, 2, 4]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],popped = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(pushed = [5, 1, 2, 4, 3],popped = [5, 3, 4, 2, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9],popped = [4, 3, 2, 1, 8, 7, 6, 5, 9]) == True\n assert candidate(pushed = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],popped = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [3, 1, 2, 4, 5, 7, 6, 9, 10, 8]) == False\n assert candidate(pushed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],popped = [30, 20, 40, 60, 50, 100, 90, 80, 70, 10]) == True\n assert candidate(pushed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],popped = [1, 3, 2, 5, 4, 8, 7, 6, 10, 9]) == False\n assert candidate(pushed = [4, 3, 5, 1, 2],popped = [1, 5, 2, 4, 3]) == False\n assert candidate(pushed = [1, 5, 3, 2, 4, 6],popped = [2, 3, 1, 5, 4, 6]) == False\n assert candidate(pushed = [5, 3, 2, 1, 4],popped = [3, 1, 2, 4, 5]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [5, 3, 2, 1, 6, 4, 9, 8, 10, 7]) == False\n assert candidate(pushed = [1, 3, 5, 2, 4, 6, 8, 7, 9, 10],popped = [1, 5, 3, 4, 2, 6, 7, 8, 10, 9]) == True\n assert candidate(pushed = [9, 8, 7, 6, 5, 4, 3, 2, 1],popped = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [3, 5, 1, 4, 2, 7, 6, 9, 8, 10]) == False\n assert candidate(pushed = [6, 2, 3, 1, 5, 4],popped = [6, 3, 2, 1, 4, 5]) == True\n assert candidate(pushed = [2, 1, 3, 5, 4, 6],popped = [2, 1, 4, 5, 3, 6]) == True\n assert candidate(pushed = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10],popped = [2, 3, 1, 5, 4, 6, 7, 8, 10, 9]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [10, 9, 8, 7, 6, 5, 2, 4, 3, 1]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [3, 4, 2, 1, 8, 9, 6, 7, 10, 5]) == False\n assert candidate(pushed = [2, 1, 3, 4, 5],popped = [1, 2, 3, 4, 5]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [3, 1, 2, 5, 4, 6, 7, 10, 9, 8]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == True\n assert candidate(pushed = [3, 2, 1, 5, 4, 6],popped = [2, 3, 1, 5, 4, 6]) == True\n assert candidate(pushed = [1, 3, 2, 4, 5],popped = [3, 1, 5, 4, 2]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == True\n assert candidate(pushed = [1, 3, 5, 7, 9, 11],popped = [11, 9, 7, 5, 3, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 5, 4, 3, 2, 6, 7, 8, 10, 9]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(pushed = [1, 3, 2, 5, 4],popped = [2, 3, 1, 5, 4]) == True\n assert candidate(pushed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],popped = [1, 3, 2, 4, 5, 7, 6, 8, 10, 9]) == False\n assert candidate(pushed = [1, 5, 7, 9, 11, 13, 15, 17, 19],popped = [19, 17, 15, 13, 11, 9, 7, 5, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],popped = [7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(pushed = [3, 1, 2, 4, 5],popped = [1, 2, 3, 4, 5]) == True\n assert candidate(pushed = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10],popped = [2, 3, 1, 6, 7, 5, 10, 9, 8, 4]) == True\n assert candidate(pushed = [1, 3, 5, 2, 4, 6],popped = [2, 4, 6, 3, 5, 1]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(pushed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],popped = [30, 50, 100, 90, 80, 70, 60, 40, 20, 10]) == True\n assert candidate(pushed = [1, 2, 5, 3, 4, 6],popped = [2, 1, 5, 6, 4, 3]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == False\n assert candidate(pushed = [5, 1, 3, 4, 2],popped = [1, 2, 3, 4, 5]) == False\n assert candidate(pushed = [1, 4, 3, 2, 5, 6],popped = [2, 3, 4, 1, 6, 5]) == True\n assert candidate(pushed = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],popped = [10, 9, 8, 7, 6, 5, 4, 2, 3, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],popped = [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 14, 13, 12, 11, 10]) == True\n assert candidate(pushed = [1, 3, 2, 5, 4, 6],popped = [2, 3, 4, 5, 6, 1]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5],popped = [5, 3, 4, 1, 2]) == False\n assert candidate(pushed = [10, 20, 30, 40, 50],popped = [20, 10, 50, 30, 40]) == False\n assert candidate(pushed = [1, 3, 2, 4, 5],popped = [2, 3, 1, 5, 4]) == True\n assert candidate(pushed = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],popped = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(pushed = [1, 2, 5, 3, 6, 4, 7, 8, 9, 10],popped = [1, 2, 3, 4, 6, 5, 7, 8, 10, 9]) == True\n assert candidate(pushed = [1, 3, 5, 4, 2],popped = [2, 4, 5, 3, 1]) == True\n assert candidate(pushed = [8, 9, 7, 6, 10, 11, 12, 13, 14],popped = [12, 14, 13, 11, 10, 7, 6, 9, 8]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]) == True\n assert candidate(pushed = [1, 2, 3, 5, 4],popped = [5, 1, 4, 2, 3]) == False\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [3, 1, 2, 5, 4, 7, 6, 8, 10, 9]) == False\n assert candidate(pushed = [7, 8, 9, 10, 11],popped = [9, 11, 10, 8, 7]) == True\n assert candidate(pushed = [1, 4, 5, 3, 2, 6],popped = [2, 3, 4, 5, 1, 6]) == False\n assert candidate(pushed = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],popped = [2, 4, 6, 8, 10, 5, 7, 9, 3, 1]) == False\n assert candidate(pushed = [1, 3, 2, 5, 4, 6],popped = [3, 2, 5, 1, 4, 6]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],popped = [8, 9, 6, 7, 4, 5, 2, 3, 10, 11, 12, 15, 14, 1, 13]) == False\n assert candidate(pushed = [1, 2, 3, 5, 4, 6, 7, 9, 8, 10],popped = [1, 2, 3, 6, 5, 4, 8, 7, 10, 9]) == False\n assert candidate(pushed = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],popped = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == False\n assert candidate(pushed = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],popped = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(pushed = [1, 3, 5, 7, 2, 4, 6, 8],popped = [1, 3, 2, 5, 4, 7, 6, 8]) == False\n assert candidate(pushed = [1, 3, 2, 5, 4],popped = [5, 4, 2, 3, 1]) == True\n assert candidate(pushed = [2, 1, 3, 5, 4],popped = [3, 1, 2, 4, 5]) == True\n assert candidate(pushed = [1, 3, 2, 4, 5],popped = [3, 2, 1, 5, 4]) == True\n assert candidate(pushed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],popped = [6, 5, 4, 3, 2, 1, 10, 9, 8, 7]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]\n[4,5,3,2,1]", "[1,2,3,4,5]\n[4,3,5,1,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["pushed", "popped"], "leetcode_dataset_entry_point": "Solution().validateStackSequences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:06+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def validateStackSequences(self, pushed: list[int], popped: list[int]) -> bool:", "container": "Solution", "callable": "validateStackSequences", "parameters": [{"name": "pushed", "type": "list[int]"}, {"name": "popped", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 947, "task_id": "most-stones-removed-with-same-row-or-column", "difficulty": "Medium", "problem_description": "On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone.\n\nA stone can be removed if it shares either the same row or the same column as another stone that has not been removed.\n\nGiven an array stones of length n where stones[i] = [x_i, y_i] represents the location of the i^th stone, return the largest possible number of stones that can be removed.\n\nExample 1:\n\nInput: stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]\nOutput: 5\nExplanation: One way to remove 5 stones is as follows:\n1. Remove stone [2,2] because it shares the same row as [2,1].\n2. Remove stone [2,1] because it shares the same column as [0,1].\n3. Remove stone [1,2] because it shares the same row as [1,0].\n4. Remove stone [1,0] because it shares the same column as [0,0].\n5. Remove stone [0,1] because it shares the same row as [0,0].\nStone [0,0] cannot be removed since it does not share a row/column with another stone still on the plane.\n\nExample 2:\n\nInput: stones = [[0,0],[0,2],[1,1],[2,0],[2,2]]\nOutput: 3\nExplanation: One way to make 3 moves is as follows:\n1. Remove stone [2,2] because it shares the same row as [2,0].\n2. Remove stone [2,0] because it shares the same column as [0,0].\n3. Remove stone [0,2] because it shares the same row as [0,0].\nStones [0,0] and [1,1] cannot be removed since they do not share a row/column with another stone still on the plane.\n\nExample 3:\n\nInput: stones = [[0,0]]\nOutput: 0\nExplanation: [0,0] is the only stone on the plane, so you cannot remove it.\n\nConstraints:\n\n- 1 <= stones.length <= 1000\n- 0 <= x_i, y_i <= 10^4\n- No two stones are at the same coordinate point.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [[4, 8], [4, 4], [4, 4], [9, 2], [3, 8], [8, 0], [7, 5], [0, 8], [5, 7], [6, 9], [3, 0], [4, 7], [8, 5], [5, 9], [7, 4], [6, 0], [6, 4], [4, 2], [6, 3]]) == 18\n assert candidate(stones = [[0, 0], [0, 2], [1, 1], [2, 0], [2, 2]]) == 3\n assert candidate(stones = [[3, 2], [2, 3], [3, 1], [2, 2]]) == 3\n assert candidate(stones = [[1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(stones = [[4, 0], [4, 2], [1, 1], [0, 0], [0, 2], [2, 0], [2, 2]]) == 5\n assert candidate(stones = [[0, 0]]) == 0\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 2], [2, 1], [2, 2]]) == 5\n assert candidate(stones = [[3, 4], [3, 2], [4, 2], [0, 0], [1, 2]]) == 3\n assert candidate(stones = [[4, 8], [4, 4], [4, 4], [9, 2], [8, 7], [2, 3], [8, 7], [5, 0], [3, 1], [0, 5], [8, 5], [7, 2], [5, 3], [1, 7], [8, 0], [2, 6], [0, 1], [1, 0], [5, 8], [6, 4]]) == 18\n assert candidate(stones = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 0\n assert candidate(stones = [[4, 8], [4, 4], [4, 4], [9, 2], [8, 8], [4, 5], [0, 7], [5, 7], [1, 8], [9, 2], [9, 7], [4, 9], [4, 8]]) == 11\n assert candidate(stones = [[1, 2], [2, 1], [3, 2], [4, 2], [5, 3], [4, 4]]) == 3\n assert candidate(stones = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == 4\n assert candidate(stones = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 2], [3, 3]]) == 4\n assert candidate(stones = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(stones = [[4, 0], [4, 2], [1, 1], [0, 2], [1, 2], [2, 2], [3, 2]]) == 6\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [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(stones = [[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]]) == 0\n assert candidate(stones = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [0, 0], [11, 11]]) == 0\n assert candidate(stones = [[10, 10], [10, 20], [20, 10], [20, 20], [10, 30], [30, 10], [30, 20], [20, 30], [30, 30], [10, 40], [40, 10]]) == 10\n assert candidate(stones = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]) == 8\n assert candidate(stones = [[1, 1], [2, 2], [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\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [1, 3], [2, 3], [3, 1], [1, 2], [2, 1], [3, 2], [2, 4], [4, 2], [3, 4], [4, 3], [4, 4]]) == 13\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2]]) == 5\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 3], [3, 0], [0, 2], [2, 0], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2]]) == 13\n assert candidate(stones = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == 16\n assert candidate(stones = [[1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 7], [7, 6]]) == 10\n assert candidate(stones = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == 15\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 2], [2, 3], [3, 4], [4, 5], [1, 3], [2, 4], [3, 5], [4, 6]]) == 11\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [9, 0]]) == 3\n assert candidate(stones = [[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]]) == 0\n assert candidate(stones = [[0, 0], [0, 2], [2, 0], [2, 2], [4, 4], [4, 6], [6, 4], [6, 6], [8, 8], [8, 10], [10, 8], [10, 10]]) == 9\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 19\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == 9\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 1], [1, 0], [2, 3], [3, 2], [0, 3], [3, 0], [1, 2], [2, 1]]) == 11\n assert candidate(stones = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4]]) == 8\n assert candidate(stones = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [0, 1], [1, 0]]) == 2\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 5], [5, 0]]) == 3\n assert candidate(stones = [[1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 7], [7, 6], [7, 8], [8, 7], [8, 9], [9, 8]]) == 14\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 2], [2, 1], [3, 2], [2, 3]]) == 6\n assert candidate(stones = [[0, 0], [1, 0], [2, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [0, 2], [1, 2], [2, 2], [3, 2]]) == 11\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 1], [1, 0], [2, 1], [1, 2]]) == 6\n assert candidate(stones = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 3\n assert candidate(stones = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == 0\n assert candidate(stones = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1]]) == 14\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [3, 4], [4, 3]]) == 5\n assert candidate(stones = [[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]]) == 0\n assert candidate(stones = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [3, 3], [3, 5], [5, 3]]) == 5\n assert candidate(stones = [[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], [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]]) == 31\n assert candidate(stones = [[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]]) == 15\n assert candidate(stones = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]]) == 6\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 3\n assert candidate(stones = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [1, 4], [2, 4], [3, 4]]) == 11\n assert candidate(stones = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]]) == 0\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == 6\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0]]) == 0\n assert candidate(stones = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == 8\n assert candidate(stones = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3]]) == 7\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == 7\n assert candidate(stones = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5]]) == 11\n assert candidate(stones = [[0, 0], [0, 2], [2, 0], [1, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 2\n assert candidate(stones = [[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], [7, 8], [8, 7], [8, 9], [9, 8]]) == 16\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 0], [3, 3]]) == 6\n assert candidate(stones = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]]) == 0\n assert candidate(stones = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 7], [9, 10], [10, 9]]) == 0\n assert candidate(stones = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 9\n assert candidate(stones = [[1, 1], [1, 3], [1, 5], [1, 7], [2, 2], [2, 4], [2, 6], [2, 8], [3, 1], [3, 3], [3, 5], [3, 7], [4, 2], [4, 4], [4, 6], [4, 8]]) == 14\n assert candidate(stones = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(stones = [[0, 0], [0, 2], [1, 1], [1, 3], [2, 0], [2, 2], [3, 1], [3, 3]]) == 6\n assert candidate(stones = [[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]]) == 12\n assert candidate(stones = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(stones = [[5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7], [7, 5], [7, 6], [7, 7], [8, 8], [8, 9], [9, 8], [9, 9]]) == 11\n assert candidate(stones = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4], [4, 5], [5, 4], [5, 5]]) == 9\n assert candidate(stones = [[0, 1], [1, 2], [2, 0], [2, 3], [3, 1], [3, 4], [4, 2], [4, 5], [5, 3]]) == 6\n assert candidate(stones = [[0, 0], [1, 2], [2, 1], [3, 3], [4, 4], [5, 6], [6, 5], [7, 7]]) == 0\n assert candidate(stones = [[10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6], [16, 7], [17, 8], [18, 9], [19, 10], [10, 19], [11, 18], [12, 17], [13, 16], [14, 15]]) == 5\n assert candidate(stones = [[0, 0], [1, 0], [2, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [0, 2], [1, 2], [2, 2], [3, 2], [0, 3], [1, 3], [2, 3], [3, 3]]) == 15\n assert candidate(stones = [[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, 4], [6, 5], [6, 6]]) == 16\n assert candidate(stones = [[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]]) == 16\n assert candidate(stones = [[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]]) == 14\n assert candidate(stones = [[0, 0], [0, 2], [1, 1], [2, 0], [2, 2], [2, 4], [3, 3], [4, 2], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 6\n assert candidate(stones = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0]]) == 7\n assert candidate(stones = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 2], [2, 0], [3, 3], [4, 4], [5, 5], [3, 4], [4, 5], [5, 3]]) == 10\n assert candidate(stones = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == 6\n assert candidate(stones = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 15\n assert candidate(stones = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1], [3, 3], [3, 4], [4, 3], [4, 4]]) == 9\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 2], [2, 0], [1, 0], [0, 2], [2, 1]]) == 8\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(stones = [[0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == 8\n assert candidate(stones = [[0, 0], [0, 2], [1, 1], [2, 0], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]) == 9\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 20\n assert candidate(stones = [[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [1, 3], [2, 3], [3, 3]]) == 11\n assert candidate(stones = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]) == 15\n assert candidate(stones = [[0, 0], [1, 1], [0, 2], [1, 3], [0, 4], [1, 5], [0, 6], [1, 7]]) == 6\n assert candidate(stones = [[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]]) == 16\n assert candidate(stones = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4], [4, 0], [0, 2], [2, 0], [2, 4], [4, 2], [0, 3], [3, 0], [3, 4], [4, 3]]) == 13\n", "comparison": "exact"}, "public_tests": ["[[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]", "[[0,0],[0,2],[1,1],[2,0],[2,2]]", "[[0,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().removeStones", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:08+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "depth-first-search", "union-find", "graph", "bipartite-graph"]}, "language": "python", "interface": {"raw_signature": "def removeStones(self, stones: list[list[int]]) -> int:", "container": "Solution", "callable": "removeStones", "parameters": [{"name": "stones", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 948, "task_id": "bag-of-tokens", "difficulty": "Medium", "problem_description": "You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] denotes the value of token_i.\n\nYour goal is to maximize the total score by strategically playing these tokens. In one move, you can play an unplayed token in one of the two ways (but not both for the same token):\n\n- Face-up: If your current power is at least tokens[i], you may play token_i, losing tokens[i] power and gaining 1 score.\n- Face-down: If your current score is at least 1, you may play token_i, gaining tokens[i] power and losing 1 score.\n\nReturn the maximum possible score you can achieve after playing any number of tokens.\n\nExample 1:\n\nInput: tokens = [100], power = 50\nOutput: 0\nExplanation: Since your score is 0 initially, you cannot play the token face-down. You also cannot play it face-up since your power (50) is less than tokens[0] (100).\n\nExample 2:\n\nInput: tokens = [200,100], power = 150\nOutput: 1\nExplanation: Play token_1 (100) face-up, reducing your power to 50 and increasing your score to 1.\nThere is no need to play token_0, since you cannot play it face-up to add to your score. The maximum score achievable is 1.\n\nExample 3:\n\nInput: tokens = [100,200,300,400], power = 200\nOutput: 2\nExplanation: Play the tokens in this order to get a score of 2:\n1. Play token_0 (100) face-up, reducing power to 100 and increasing score to 1.\n2. Play token_3 (400) face-down, increasing power to 500 and reducing score to 0.\n3. Play token_1 (200) face-up, reducing power to 300 and increasing score to 1.\n4. Play token_2 (300) face-up, reducing power to 0 and increasing score to 2.\n\nThe maximum score achievable is 2.\n\nConstraints:\n\n- 0 <= tokens.length <= 1000\n- 0 <= tokens[i], power < 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tokens = [100, 200, 300, 400],power = 200) == 2\n assert candidate(tokens = [100, 200, 300, 400],power = 100) == 1\n assert candidate(tokens = [71, 55, 82],power = 54) == 0\n assert candidate(tokens = [100, 200, 300, 400],power = 500) == 2\n assert candidate(tokens = [100],power = 50) == 0\n assert candidate(tokens = [],power = 0) == 0\n assert candidate(tokens = [50, 50, 50, 50, 50],power = 150) == 3\n assert candidate(tokens = [100, 200, 300, 400, 500],power = 250) == 2\n assert candidate(tokens = [50, 100, 150, 200, 250],power = 200) == 2\n assert candidate(tokens = [80, 90, 95],power = 100) == 1\n assert candidate(tokens = [100, 150, 200, 250, 300],power = 100) == 1\n assert candidate(tokens = [100, 200, 300, 400, 500],power = 300) == 2\n assert candidate(tokens = [],power = 1000) == 0\n assert candidate(tokens = [1000, 2000, 3000, 4000],power = 1500) == 1\n assert candidate(tokens = [1, 2, 3, 4, 5],power = 3) == 2\n assert candidate(tokens = [100, 200, 300, 400],power = 300) == 2\n assert candidate(tokens = [200, 100],power = 150) == 1\n assert candidate(tokens = [50, 100, 150, 200, 250],power = 200) == 2\n assert candidate(tokens = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],power = 5) == 5\n assert candidate(tokens = [50, 50, 50, 50],power = 150) == 3\n assert candidate(tokens = [71, 55, 82],power = 54) == 0\n assert candidate(tokens = [500],power = 1000) == 1\n assert candidate(tokens = [200, 100],power = 150) == 1\n assert candidate(tokens = [75, 150, 225, 300, 375, 450],power = 225) == 2\n assert candidate(tokens = [5, 10, 15, 20],power = 50) == 4\n assert candidate(tokens = [],power = 100) == 0\n assert candidate(tokens = [7, 8, 9, 10, 11],power = 20) == 2\n assert candidate(tokens = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],power = 0) == 0\n assert candidate(tokens = [100, 100, 100, 100, 100, 100],power = 300) == 3\n assert candidate(tokens = [1, 2, 3, 4, 5],power = 5) == 3\n assert candidate(tokens = [100, 100, 100, 100],power = 300) == 3\n assert candidate(tokens = [100, 200, 300, 400],power = 400) == 2\n assert candidate(tokens = [100, 200, 300, 400],power = 200) == 2\n assert candidate(tokens = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],power = 10) == 3\n assert candidate(tokens = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],power = 250) == 4\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],power = 1500) == 16\n assert candidate(tokens = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],power = 500) == 4\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],power = 500) == 9\n assert candidate(tokens = [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000],power = 1000) == 8\n assert candidate(tokens = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],power = 200) == 6\n assert candidate(tokens = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],power = 30) == 7\n assert candidate(tokens = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],power = 550) == 4\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],power = 50) == 4\n assert candidate(tokens = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],power = 5000) == 9\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],power = 10) == 6\n assert candidate(tokens = [25, 50, 75, 100, 125, 150, 175, 200],power = 100) == 3\n assert candidate(tokens = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250],power = 100) == 4\n assert candidate(tokens = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],power = 100) == 11\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],power = 1000) == 14\n assert candidate(tokens = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],power = 5) == 5\n assert candidate(tokens = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],power = 1500) == 5\n assert candidate(tokens = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],power = 75) == 9\n assert candidate(tokens = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],power = 1000) == 9\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],power = 100) == 13\n assert candidate(tokens = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],power = 100) == 5\n assert candidate(tokens = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],power = 1000) == 5\n assert candidate(tokens = [5, 10, 20, 25, 50, 100],power = 55) == 4\n assert candidate(tokens = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],power = 50) == 4\n assert candidate(tokens = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],power = 1024) == 10\n assert candidate(tokens = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],power = 500) == 5\n assert candidate(tokens = [5, 7, 8, 10, 12],power = 15) == 2\n assert candidate(tokens = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],power = 25) == 5\n assert candidate(tokens = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],power = 1000) == 9\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],power = 10) == 8\n assert candidate(tokens = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],power = 10) == 5\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],power = 250) == 6\n assert candidate(tokens = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],power = 100) == 4\n assert candidate(tokens = [100, 200, 300, 400, 500],power = 1) == 0\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],power = 75) == 6\n assert candidate(tokens = [300, 200, 100, 400, 500],power = 250) == 2\n assert candidate(tokens = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],power = 200) == 4\n assert candidate(tokens = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],power = 10) == 9\n assert candidate(tokens = [500, 400, 300, 200, 100, 50, 25, 10],power = 1000) == 6\n assert candidate(tokens = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],power = 1023) == 10\n assert candidate(tokens = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],power = 500) == 4\n assert candidate(tokens = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],power = 250) == 10\n assert candidate(tokens = [90, 95, 100, 105, 110, 115, 120, 125, 130, 135],power = 100) == 1\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],power = 70) == 6\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],power = 100) == 6\n assert candidate(tokens = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],power = 100) == 11\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],power = 15) == 5\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],power = 50) == 11\n assert candidate(tokens = [300, 200, 100, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],power = 500) == 5\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],power = 1000) == 13\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],power = 20) == 7\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],power = 10) == 4\n assert candidate(tokens = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],power = 200) == 10\n assert candidate(tokens = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],power = 10) == 4\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],power = 100) == 14\n assert candidate(tokens = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],power = 100) == 6\n assert candidate(tokens = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],power = 100) == 1\n assert candidate(tokens = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],power = 150) == 5\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],power = 5) == 4\n assert candidate(tokens = [300, 200, 400, 100, 500],power = 250) == 2\n assert candidate(tokens = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],power = 25) == 6\n assert candidate(tokens = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],power = 300) == 4\n assert candidate(tokens = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],power = 15) == 6\n assert candidate(tokens = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],power = 200) == 4\n assert candidate(tokens = [500, 200, 300, 100, 400, 600, 700, 800, 900, 1000],power = 400) == 4\n assert candidate(tokens = [300, 200, 100, 400, 500, 600],power = 350) == 2\n", "comparison": "exact"}, "public_tests": ["[100]\n50", "[200,100]\n150", "[100,200,300,400]\n200"], "hints": [], "metadata": {"canonical_parameter_names": ["tokens", "power"], "leetcode_dataset_entry_point": "Solution().bagOfTokensScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:10+00:00", "tests_total": 103, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def bagOfTokensScore(self, tokens: list[int], power: int) -> int:", "container": "Solution", "callable": "bagOfTokensScore", "parameters": [{"name": "tokens", "type": "list[int]"}, {"name": "power", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 949, "task_id": "largest-time-for-given-digits", "difficulty": "Medium", "problem_description": "Given an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once.\n\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.\n\nReturn the latest 24-hour time in \"HH:MM\" format. If no valid time can be made, return an empty string.\n\nExample 1:\n\nInput: arr = [1,2,3,4]\nOutput: \"23:41\"\nExplanation: The valid 24-hour times are \"12:34\", \"12:43\", \"13:24\", \"13:42\", \"14:23\", \"14:32\", \"21:34\", \"21:43\", \"23:14\", and \"23:41\". Of these times, \"23:41\" is the latest.\n\nExample 2:\n\nInput: arr = [5,5,5,5]\nOutput: \"\"\nExplanation: There are no valid 24-hour times as \"55:55\" is not valid.\n\nConstraints:\n\n- arr.length == 4\n- 0 <= arr[i] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 9, 0, 3]) == \"23:09\"\n assert candidate(arr = [1, 9, 6, 0]) == \"19:06\"\n assert candidate(arr = [0, 2, 6, 6]) == \"06:26\"\n assert candidate(arr = [4, 2, 4, 4]) == \"\"\n assert candidate(arr = [2, 2, 9, 6]) == \"\"\n assert candidate(arr = [2, 3, 5, 9]) == \"23:59\"\n assert candidate(arr = [4, 2, 0, 0]) == \"20:40\"\n assert candidate(arr = [1, 9, 9, 9]) == \"\"\n assert candidate(arr = [9, 1, 6, 0]) == \"19:06\"\n assert candidate(arr = [1, 9, 6, 3]) == \"19:36\"\n assert candidate(arr = [5, 5, 5, 5]) == \"\"\n assert candidate(arr = [2, 0, 6, 6]) == \"06:26\"\n assert candidate(arr = [1, 2, 3, 4]) == \"23:41\"\n assert candidate(arr = [0, 4, 0, 0]) == \"04:00\"\n assert candidate(arr = [0, 1, 5, 9]) == \"19:50\"\n assert candidate(arr = [0, 0, 1, 0]) == \"10:00\"\n assert candidate(arr = [0, 9, 5, 7]) == \"09:57\"\n assert candidate(arr = [0, 0, 0, 0]) == \"00:00\"\n assert candidate(arr = [3, 9, 5, 6]) == \"\"\n assert candidate(arr = [1, 9, 6, 8]) == \"\"\n assert candidate(arr = [9, 6, 3, 2]) == \"\"\n assert candidate(arr = [5, 0, 7, 0]) == \"07:50\"\n assert candidate(arr = [3, 0, 7, 0]) == \"07:30\"\n assert candidate(arr = [1, 3, 5, 7]) == \"17:53\"\n assert candidate(arr = [9, 9, 9, 0]) == \"\"\n assert candidate(arr = [9, 0, 4, 3]) == \"09:43\"\n assert candidate(arr = [9, 0, 8, 7]) == \"\"\n assert candidate(arr = [9, 9, 8, 8]) == \"\"\n assert candidate(arr = [1, 2, 8, 9]) == \"19:28\"\n assert candidate(arr = [1, 2, 3, 3]) == \"23:31\"\n assert candidate(arr = [4, 2, 6, 9]) == \"\"\n assert candidate(arr = [2, 2, 3, 4]) == \"23:42\"\n assert candidate(arr = [2, 2, 3, 3]) == \"23:32\"\n assert candidate(arr = [3, 4, 9, 1]) == \"19:43\"\n assert candidate(arr = [2, 9, 3, 4]) == \"23:49\"\n assert candidate(arr = [5, 0, 9, 2]) == \"20:59\"\n assert candidate(arr = [2, 9, 5, 1]) == \"21:59\"\n assert candidate(arr = [6, 6, 6, 6]) == \"\"\n assert candidate(arr = [2, 4, 0, 6]) == \"20:46\"\n assert candidate(arr = [2, 2, 2, 2]) == \"22:22\"\n assert candidate(arr = [4, 5, 9, 8]) == \"\"\n assert candidate(arr = [3, 9, 1, 0]) == \"19:30\"\n assert candidate(arr = [2, 2, 4, 4]) == \"22:44\"\n assert candidate(arr = [0, 1, 2, 3]) == \"23:10\"\n assert candidate(arr = [4, 1, 4, 0]) == \"14:40\"\n assert candidate(arr = [1, 1, 1, 1]) == \"11:11\"\n assert candidate(arr = [8, 4, 2, 1]) == \"21:48\"\n assert candidate(arr = [0, 4, 2, 3]) == \"23:40\"\n assert candidate(arr = [2, 9, 0, 5]) == \"20:59\"\n assert candidate(arr = [3, 8, 4, 1]) == \"18:43\"\n assert candidate(arr = [3, 8, 4, 7]) == \"\"\n assert candidate(arr = [2, 3, 0, 3]) == \"23:30\"\n assert candidate(arr = [3, 5, 0, 7]) == \"07:53\"\n assert candidate(arr = [2, 3, 0, 0]) == \"23:00\"\n assert candidate(arr = [2, 4, 0, 0]) == \"20:40\"\n assert candidate(arr = [1, 2, 5, 9]) == \"21:59\"\n assert candidate(arr = [3, 9, 4, 0]) == \"09:43\"\n assert candidate(arr = [1, 1, 9, 9]) == \"19:19\"\n assert candidate(arr = [1, 8, 8, 8]) == \"\"\n assert candidate(arr = [1, 8, 4, 6]) == \"18:46\"\n assert candidate(arr = [1, 0, 7, 6]) == \"17:06\"\n assert candidate(arr = [2, 0, 6, 4]) == \"20:46\"\n assert candidate(arr = [5, 8, 5, 8]) == \"\"\n assert candidate(arr = [2, 3, 4, 5]) == \"23:54\"\n assert candidate(arr = [8, 7, 7, 9]) == \"\"\n assert candidate(arr = [1, 1, 1, 2]) == \"21:11\"\n assert candidate(arr = [2, 7, 6, 0]) == \"07:26\"\n assert candidate(arr = [0, 2, 6, 4]) == \"20:46\"\n assert candidate(arr = [4, 1, 4, 2]) == \"21:44\"\n assert candidate(arr = [0, 0, 1, 2]) == \"21:00\"\n assert candidate(arr = [5, 9, 5, 9]) == \"\"\n assert candidate(arr = [2, 3, 6, 8]) == \"\"\n assert candidate(arr = [0, 7, 6, 6]) == \"\"\n assert candidate(arr = [4, 1, 3, 5]) == \"15:43\"\n assert candidate(arr = [8, 5, 9, 0]) == \"09:58\"\n assert candidate(arr = [7, 6, 4, 0]) == \"07:46\"\n assert candidate(arr = [2, 3, 2, 3]) == \"23:32\"\n assert candidate(arr = [0, 9, 0, 9]) == \"09:09\"\n assert candidate(arr = [7, 9, 5, 2]) == \"\"\n assert candidate(arr = [1, 0, 0, 0]) == \"10:00\"\n assert candidate(arr = [0, 3, 5, 5]) == \"05:53\"\n assert candidate(arr = [3, 8, 4, 5]) == \"\"\n assert candidate(arr = [0, 5, 9, 6]) == \"09:56\"\n assert candidate(arr = [0, 0, 0, 1]) == \"10:00\"\n assert candidate(arr = [5, 8, 5, 9]) == \"\"\n assert candidate(arr = [1, 1, 1, 1]) == \"11:11\"\n assert candidate(arr = [8, 8, 8, 8]) == \"\"\n assert candidate(arr = [2, 4, 6, 8]) == \"\"\n assert candidate(arr = [3, 3, 3, 3]) == \"\"\n assert candidate(arr = [1, 8, 7, 7]) == \"\"\n assert candidate(arr = [6, 8, 5, 4]) == \"\"\n assert candidate(arr = [6, 6, 9, 0]) == \"\"\n assert candidate(arr = [2, 2, 2, 2]) == \"22:22\"\n assert candidate(arr = [7, 8, 6, 1]) == \"\"\n assert candidate(arr = [5, 3, 6, 0]) == \"06:53\"\n assert candidate(arr = [0, 3, 5, 9]) == \"09:53\"\n assert candidate(arr = [3, 0, 7, 0]) == \"07:30\"\n assert candidate(arr = [5, 9, 6, 4]) == \"\"\n assert candidate(arr = [0, 9, 3, 5]) == \"09:53\"\n assert candidate(arr = [7, 7, 7, 7]) == \"\"\n assert candidate(arr = [2, 3, 3, 2]) == \"23:32\"\n assert candidate(arr = [5, 9, 6, 3]) == \"\"\n assert candidate(arr = [0, 9, 1, 1]) == \"19:10\"\n assert candidate(arr = [5, 0, 5, 2]) == \"20:55\"\n assert candidate(arr = [3, 3, 3, 3]) == \"\"\n assert candidate(arr = [0, 5, 5, 9]) == \"09:55\"\n assert candidate(arr = [1, 2, 8, 9]) == \"19:28\"\n assert candidate(arr = [2, 2, 1, 1]) == \"22:11\"\n assert candidate(arr = [1, 2, 3, 0]) == \"23:10\"\n assert candidate(arr = [0, 4, 0, 0]) == \"04:00\"\n assert candidate(arr = [3, 3, 0, 1]) == \"13:30\"\n assert candidate(arr = [6, 1, 4, 2]) == \"21:46\"\n assert candidate(arr = [0, 4, 4, 5]) == \"05:44\"\n assert candidate(arr = [9, 0, 0, 0]) == \"09:00\"\n assert candidate(arr = [0, 0, 1, 1]) == \"11:00\"\n assert candidate(arr = [5, 6, 7, 8]) == \"\"\n assert candidate(arr = [1, 2, 9, 0]) == \"21:09\"\n assert candidate(arr = [3, 3, 4, 5]) == \"\"\n assert candidate(arr = [9, 9, 9, 9]) == \"\"\n assert candidate(arr = [5, 2, 8, 9]) == \"\"\n assert candidate(arr = [9, 8, 7, 6]) == \"\"\n assert candidate(arr = [9, 9, 9, 9]) == \"\"\n assert candidate(arr = [0, 1, 7, 7]) == \"17:07\"\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[5,5,5,5]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().largestTimeFromDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:13+00:00", "tests_total": 123, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "backtracking", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def largestTimeFromDigits(self, arr: list[int]) -> str:", "container": "Solution", "callable": "largestTimeFromDigits", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 950, "task_id": "reveal-cards-in-increasing-order", "difficulty": "Medium", "problem_description": "You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the i^th card is deck[i].\n\nYou can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck.\n\nYou will do the following steps repeatedly until all cards are revealed:\n\n1. Take the top card of the deck, reveal it, and take it out of the deck.\n2. If there are still cards in the deck then put the next top card of the deck at the bottom of the deck.\n3. If there are still unrevealed cards, go back to step 1. Otherwise, stop.\n\nReturn an ordering of the deck that would reveal the cards in increasing order.\n\nNote that the first entry in the answer is considered to be the top of the deck.\n\nExample 1:\n\nInput: deck = [17,13,11,2,3,5,7]\nOutput: [2,13,3,11,5,17,7]\nExplanation:\nWe get the deck in the order [17,13,11,2,3,5,7] (this order does not matter), and reorder it.\nAfter reordering, the deck starts as [2,13,3,11,5,17,7], where 2 is the top of the deck.\nWe reveal 2, and move 13 to the bottom. The deck is now [3,11,5,17,7,13].\nWe reveal 3, and move 11 to the bottom. The deck is now [5,17,7,13,11].\nWe reveal 5, and move 17 to the bottom. The deck is now [7,13,11,17].\nWe reveal 7, and move 13 to the bottom. The deck is now [11,17,13].\nWe reveal 11, and move 17 to the bottom. The deck is now [13,17].\nWe reveal 13, and move 17 to the bottom. The deck is now [17].\nWe reveal 17.\nSince all the cards revealed are in increasing order, the answer is correct.\n\nExample 2:\n\nInput: deck = [1,1000]\nOutput: [1,1000]\n\nConstraints:\n\n- 1 <= deck.length <= 1000\n- 1 <= deck[i] <= 10^6\n- All the values of deck are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(deck = [10, 1, 6, 7, 8, 2, 3, 4, 5, 9]) == [1, 6, 2, 10, 3, 7, 4, 9, 5, 8]\n assert candidate(deck = [5, 2, 3, 1, 4]) == [1, 5, 2, 4, 3]\n assert candidate(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 6, 2, 10, 3, 7, 4, 9, 5, 8]\n assert candidate(deck = [1, 1000]) == [1, 1000]\n assert candidate(deck = [2, 14, 19, 3, 17, 13, 11, 5, 7]) == [2, 19, 3, 13, 5, 17, 7, 14, 11]\n assert candidate(deck = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 6, 2, 10, 3, 7, 4, 9, 5, 8]\n assert candidate(deck = [5, 4, 3, 2, 1]) == [1, 5, 2, 4, 3]\n assert candidate(deck = [10]) == [10]\n assert candidate(deck = [17, 13, 11, 2, 3, 5, 7]) == [2, 13, 3, 11, 5, 17, 7]\n assert candidate(deck = [3, 2, 1]) == [1, 3, 2]\n assert candidate(deck = [5, 2, 9, 1, 10, 3, 7, 8, 6, 4]) == [1, 6, 2, 10, 3, 7, 4, 9, 5, 8]\n assert candidate(deck = [5]) == [5]\n assert candidate(deck = [2, 14, 4, 13, 1, 6, 7, 10, 3, 8, 11, 12, 9, 5]) == [1, 8, 2, 13, 3, 9, 4, 12, 5, 10, 6, 14, 7, 11]\n assert candidate(deck = [1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3]\n assert candidate(deck = [8, 6, 4, 2, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34]) == [2, 34, 4, 20, 6, 28, 8, 22, 10, 32, 12, 24, 14, 30, 16, 26, 18]\n assert candidate(deck = [500, 250, 750, 375, 875, 125, 625, 312, 937, 187, 468, 974, 25, 687, 343]) == [25, 750, 125, 500, 187, 937, 250, 625, 312, 875, 343, 687, 375, 974, 468]\n assert candidate(deck = [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]) == [1, 51, 2, 76, 3, 52, 4, 99, 5, 53, 6, 77, 7, 54, 8, 89, 9, 55, 10, 78, 11, 56, 12, 95, 13, 57, 14, 79, 15, 58, 16, 90, 17, 59, 18, 80, 19, 60, 20, 98, 21, 61, 22, 81, 23, 62, 24, 91, 25, 63, 26, 82, 27, 64, 28, 96, 29, 65, 30, 83, 31, 66, 32, 92, 33, 67, 34, 84, 35, 68, 36, 100, 37, 69, 38, 85, 39, 70, 40, 93, 41, 71, 42, 86, 43, 72, 44, 97, 45, 73, 46, 87, 47, 74, 48, 94, 49, 75, 50, 88]\n assert candidate(deck = [47, 101, 23, 79, 61, 89, 31, 59, 29, 43, 13, 71, 83, 53, 11, 17, 19, 37, 41, 67, 97]) == [11, 89, 13, 53, 17, 79, 19, 59, 23, 101, 29, 61, 31, 83, 37, 67, 41, 97, 43, 71, 47]\n assert candidate(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == [1, 27, 2, 40, 3, 28, 4, 51, 5, 29, 6, 41, 7, 30, 8, 47, 9, 31, 10, 42, 11, 32, 12, 50, 13, 33, 14, 43, 15, 34, 16, 48, 17, 35, 18, 44, 19, 36, 20, 52, 21, 37, 22, 45, 23, 38, 24, 49, 25, 39, 26, 46]\n assert candidate(deck = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 15, 2, 11, 3, 19, 4, 12, 5, 16, 6, 13, 7, 18, 8, 14, 9, 17, 10]\n assert candidate(deck = [34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657]) == [34, 6765, 55, 1597, 89, 17711, 144, 2584, 233, 10946, 377, 4181, 610, 28657, 987]\n assert candidate(deck = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [10, 60, 20, 100, 30, 70, 40, 90, 50, 80]\n assert candidate(deck = [41, 59, 37, 43, 19, 23, 29, 31, 53, 61, 7, 11, 13, 17, 2, 8]) == [2, 29, 7, 43, 8, 31, 11, 59, 13, 37, 17, 53, 19, 41, 23, 61]\n assert candidate(deck = [5, 1, 9, 14, 3, 10, 12, 7, 6, 8, 4, 13, 11, 15, 2]) == [1, 12, 2, 9, 3, 14, 4, 10, 5, 13, 6, 11, 7, 15, 8]\n assert candidate(deck = [3, 2, 1, 6, 5, 4, 9, 8, 7]) == [1, 9, 2, 6, 3, 8, 4, 7, 5]\n assert candidate(deck = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == [101, 1111, 202, 1616, 303, 1212, 404, 2020, 505, 1313, 606, 1717, 707, 1414, 808, 1919, 909, 1515, 1010, 1818]\n assert candidate(deck = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [100, 1100, 200, 1600, 300, 1200, 400, 2000, 500, 1300, 600, 1700, 700, 1400, 800, 1900, 900, 1500, 1000, 1800]\n assert candidate(deck = [29, 1, 43, 23, 5, 19, 31, 7, 3, 11, 13, 17, 18, 2, 21, 25, 27, 37, 41]) == [1, 29, 2, 21, 3, 43, 5, 23, 7, 31, 11, 25, 13, 41, 17, 27, 18, 37, 19]\n assert candidate(deck = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == [5, 85, 15, 125, 25, 95, 35, 145, 45, 105, 55, 135, 65, 115, 75, 155]\n assert candidate(deck = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99]) == [9, 81, 18, 63, 27, 99, 36, 72, 45, 90, 54]\n assert candidate(deck = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 8, 2, 40, 3, 9, 4, 30, 5, 10, 6, 50, 7, 20]\n assert candidate(deck = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [100, 1200, 200, 900, 300, 1400, 400, 1000, 500, 1300, 600, 1100, 700, 1500, 800]\n assert candidate(deck = [51, 78, 9, 7, 60, 69, 21, 68, 64, 12, 24, 81, 70, 55, 4, 49, 35, 34, 63, 27, 95, 59, 72, 3, 32, 33, 29, 65, 48, 19, 6, 56, 97, 94, 57, 85, 5, 92, 77, 22, 14, 67, 16, 91, 30, 76, 52, 83, 82, 44, 41, 89, 99, 90, 39, 26, 75, 88, 8, 96, 18, 46, 45, 71, 98, 74, 43, 54, 87, 25, 38, 1, 47, 31, 28, 23, 73, 66, 86, 84, 20, 11, 53, 37, 62, 93, 79, 17, 42, 13, 58, 100, 50, 15, 80, 10, 2, 61]) == [1, 52, 2, 99, 3, 53, 4, 77, 5, 54, 6, 89, 7, 55, 8, 78, 9, 56, 10, 95, 11, 57, 12, 79, 13, 58, 14, 90, 15, 59, 16, 80, 17, 60, 18, 98, 19, 61, 20, 81, 21, 62, 22, 91, 23, 63, 24, 82, 25, 64, 26, 96, 27, 65, 28, 83, 29, 66, 30, 92, 31, 67, 32, 84, 33, 68, 34, 100, 35, 69, 37, 85, 38, 70, 39, 93, 41, 71, 42, 86, 43, 72, 44, 97, 45, 73, 46, 87, 47, 74, 48, 94, 49, 75, 50, 88, 51, 76]\n assert candidate(deck = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [980, 990, 981, 995, 982, 991, 983, 999, 984, 992, 985, 996, 986, 993, 987, 998, 988, 994, 989, 997]\n assert candidate(deck = [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]) == [19, 266, 38, 475, 57, 285, 76, 399, 95, 304, 114, 456, 133, 323, 152, 418, 171, 342, 190, 494, 209, 361, 228, 437, 247, 380]\n assert candidate(deck = [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]) == [3, 95, 7, 55, 11, 79, 15, 59, 19, 91, 23, 63, 27, 83, 31, 67, 35, 99, 39, 71, 43, 87, 47, 75, 51]\n assert candidate(deck = [23, 17, 11, 2, 3, 5, 7, 13, 19]) == [2, 23, 3, 13, 5, 19, 7, 17, 11]\n assert candidate(deck = [25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215]) == [25, 125, 35, 175, 45, 135, 55, 215, 65, 145, 75, 185, 85, 155, 95, 205, 105, 165, 115, 195]\n assert candidate(deck = [23, 5, 3, 17, 11, 7, 13, 19, 2, 29, 31, 41, 43, 53, 61, 67, 71]) == [2, 71, 3, 29, 5, 53, 7, 31, 11, 67, 13, 41, 17, 61, 19, 43, 23]\n assert candidate(deck = [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, 26, 2, 49, 3, 27, 4, 39, 5, 28, 6, 45, 7, 29, 8, 40, 9, 30, 10, 48, 11, 31, 12, 41, 13, 32, 14, 46, 15, 33, 16, 42, 17, 34, 18, 50, 19, 35, 20, 43, 21, 36, 22, 47, 23, 37, 24, 44, 25, 38]\n assert candidate(deck = [3, 5, 1, 7, 9, 2, 8, 6, 4]) == [1, 9, 2, 6, 3, 8, 4, 7, 5]\n assert candidate(deck = [23, 47, 2, 19, 31, 53, 7, 13, 41, 59, 11, 61, 17, 29, 37, 43]) == [2, 31, 7, 47, 11, 37, 13, 59, 17, 41, 19, 53, 23, 43, 29, 61]\n assert candidate(deck = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [10, 110, 20, 160, 30, 120, 40, 200, 50, 130, 60, 170, 70, 140, 80, 190, 90, 150, 100, 180]\n assert candidate(deck = [83, 91, 100, 93, 28, 45, 34, 39, 35, 60, 87, 98, 27, 32, 54, 10, 80, 12, 19, 61, 63, 53, 85, 88, 18, 8, 36, 21, 82, 59, 46, 95, 58, 99, 2, 24, 42, 86, 69, 50, 20, 17, 4, 72, 49, 15, 31, 90, 67, 64, 29, 70, 3, 68, 75, 84, 79, 55, 92, 71, 96, 37, 65, 22, 57, 97, 47, 13, 81, 74, 52, 77, 26, 56, 40, 73, 78, 94, 76, 14, 41, 5, 89, 66, 11, 16, 62, 48, 38, 9, 51, 30, 33, 1]) == [1, 54, 2, 89, 3, 55, 4, 78, 5, 56, 8, 95, 9, 57, 10, 79, 11, 58, 12, 90, 13, 59, 14, 80, 15, 60, 16, 98, 17, 61, 18, 81, 19, 62, 20, 91, 21, 63, 22, 82, 24, 64, 26, 96, 27, 65, 28, 83, 29, 66, 30, 92, 31, 67, 32, 84, 33, 68, 34, 100, 35, 69, 36, 85, 37, 70, 38, 93, 39, 71, 40, 86, 41, 72, 42, 97, 45, 73, 46, 87, 47, 74, 48, 94, 49, 75, 50, 88, 51, 76, 52, 99, 53, 77]\n assert candidate(deck = [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, 89, 3, 43, 5, 71, 7, 47, 11, 83, 13, 53, 17, 73, 19, 59, 23, 97, 29, 61, 31, 79, 37, 67, 41]\n assert candidate(deck = [33, 29, 23, 19, 17, 13, 11, 7, 5, 2, 3, 21, 31, 41, 53, 67, 83, 97, 101, 103]) == [2, 29, 3, 67, 5, 31, 7, 103, 11, 33, 13, 83, 17, 41, 19, 101, 21, 53, 23, 97]\n assert candidate(deck = [829, 821, 811, 809, 797, 787, 773, 769, 761, 751, 743, 733, 727, 719, 709, 691, 683, 677, 673, 661, 659, 653, 647, 643, 641, 631, 619, 617, 613, 607, 599, 593, 587, 577, 571, 569, 563, 557, 547, 541, 523, 521, 509, 503, 499, 491, 487, 83]) == [83, 643, 487, 733, 491, 647, 499, 787, 503, 653, 509, 743, 521, 659, 523, 811, 541, 661, 547, 751, 557, 673, 563, 797, 569, 677, 571, 761, 577, 683, 587, 829, 593, 691, 599, 769, 607, 709, 613, 809, 617, 719, 619, 773, 631, 727, 641, 821]\n assert candidate(deck = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == [1, 9, 2, 6, 3, 8, 4, 7, 5]\n assert candidate(deck = [47, 35, 29, 11, 19, 23, 2, 31, 3, 41, 5, 17, 13, 7, 43]) == [2, 35, 3, 23, 5, 43, 7, 29, 11, 41, 13, 31, 17, 47, 19]\n assert candidate(deck = [19, 2, 31, 45, 6, 11, 8, 27, 3, 14, 18, 23, 37, 41, 5, 17, 29, 33, 39, 47]) == [2, 23, 3, 37, 5, 27, 6, 47, 8, 29, 11, 39, 14, 31, 17, 45, 18, 33, 19, 41]\n assert candidate(deck = [47, 29, 18, 63, 41, 35, 22, 58, 30, 7, 54, 67, 8, 4, 6, 37, 3, 26, 31, 15, 13, 27, 62, 55, 33, 23, 57, 12, 43, 59, 20, 50, 65, 9, 39, 60, 61, 45, 21, 38, 32, 44, 16, 24, 51, 48, 49, 68, 56, 53, 10, 46, 42, 25, 14, 5, 11, 19, 40, 28, 17, 34, 36, 52]) == [3, 35, 4, 51, 5, 36, 6, 59, 7, 37, 8, 52, 9, 38, 10, 63, 11, 39, 12, 53, 13, 40, 14, 60, 15, 41, 16, 54, 17, 42, 18, 67, 19, 43, 20, 55, 21, 44, 22, 61, 23, 45, 24, 56, 25, 46, 26, 65, 27, 47, 28, 57, 29, 48, 30, 62, 31, 49, 32, 58, 33, 50, 34, 68]\n assert candidate(deck = [97, 89, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == [2, 41, 3, 67, 5, 43, 7, 79, 11, 47, 13, 71, 17, 53, 19, 97, 23, 59, 29, 73, 31, 61, 37, 89]\n assert candidate(deck = [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]) == [2, 89, 3, 43, 5, 71, 7, 47, 11, 83, 13, 53, 17, 73, 19, 59, 23, 97, 29, 61, 31, 79, 37, 67, 41]\n assert candidate(deck = [500, 250, 750, 125, 375, 625, 875, 63, 126, 189, 252, 315, 378, 441, 504, 567, 630, 693, 756, 819, 882, 945]) == [63, 504, 125, 875, 126, 567, 189, 756, 250, 625, 252, 945, 315, 630, 375, 819, 378, 693, 441, 882, 500, 750]\n assert candidate(deck = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == [101, 606, 202, 1010, 303, 707, 404, 909, 505, 808]\n assert candidate(deck = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, 9, 2, 6, 3, 8, 4, 7, 5]\n assert candidate(deck = [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]) == [2, 52, 4, 98, 6, 54, 8, 78, 10, 56, 12, 90, 14, 58, 16, 80, 18, 60, 20, 96, 22, 62, 24, 82, 26, 64, 28, 92, 30, 66, 32, 84, 34, 68, 36, 100, 38, 70, 40, 86, 42, 72, 44, 94, 46, 74, 48, 88, 50, 76]\n assert candidate(deck = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 12, 2, 9, 3, 14, 4, 10, 5, 13, 6, 11, 7, 15, 8]\n assert candidate(deck = [8, 6, 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]) == [1, 43, 2, 23, 3, 37, 4, 25, 5, 47, 6, 27, 7, 39, 8, 29, 9, 45, 11, 31, 13, 41, 15, 33, 17, 49, 19, 35, 21]\n assert candidate(deck = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == [101, 606, 202, 1010, 303, 707, 404, 909, 505, 808]\n assert candidate(deck = [5, 1, 9, 8, 2, 7, 3, 6, 4]) == [1, 9, 2, 6, 3, 8, 4, 7, 5]\n assert candidate(deck = [45, 21, 33, 67, 19, 2, 89, 53, 7, 100]) == [2, 45, 7, 100, 19, 53, 21, 89, 33, 67]\n assert candidate(deck = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == [15, 38, 16, 55, 17, 39, 18, 50, 19, 40, 20, 58, 21, 41, 22, 51, 23, 42, 24, 56, 25, 43, 26, 52, 27, 44, 28, 60, 29, 45, 30, 53, 31, 46, 32, 57, 33, 47, 34, 54, 35, 48, 36, 59, 37, 49]\n assert candidate(deck = [1000, 500, 250, 125, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == [1, 125, 2, 625, 4, 156, 9, 500, 19, 250, 39, 1000, 78, 312]\n assert candidate(deck = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 256, 2, 64, 4, 1024, 8, 128, 16, 512, 32]\n assert candidate(deck = [37, 56, 42, 8, 29, 13, 71, 23, 31, 99]) == [8, 37, 13, 99, 23, 42, 29, 71, 31, 56]\n assert candidate(deck = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 1000, 300, 700, 400, 900, 500, 800]\n assert candidate(deck = [13, 11, 2, 5, 7, 3, 17, 1, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [1, 53, 2, 23, 3, 41, 5, 29, 7, 47, 11, 31, 13, 43, 17, 37, 19]\n assert candidate(deck = [3, 7, 11, 15, 19, 23, 27, 31]) == [3, 19, 7, 27, 11, 23, 15, 31]\n assert candidate(deck = [503, 251, 757, 1009, 1259, 1511, 1777, 2039, 2293, 2549, 2801, 3059, 3319, 3571, 3823, 4079, 4331, 4583, 4831, 5077, 5333]) == [251, 4831, 503, 3059, 757, 4331, 1009, 3319, 1259, 5333, 1511, 3571, 1777, 4583, 2039, 3823, 2293, 5077, 2549, 4079, 2801]\n assert candidate(deck = [50, 20, 30, 40, 10, 70, 60, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [10, 110, 20, 160, 30, 120, 40, 200, 50, 130, 60, 170, 70, 140, 80, 190, 90, 150, 100, 180]\n assert candidate(deck = [22, 11, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143]) == [11, 132, 22, 88, 33, 121, 44, 99, 55, 143, 66, 110, 77]\n", "comparison": "exact"}, "public_tests": ["[17,13,11,2,3,5,7]", "[1,1000]"], "hints": [], "metadata": {"canonical_parameter_names": ["deck"], "leetcode_dataset_entry_point": "Solution().deckRevealedIncreasing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:15+00:00", "tests_total": 78, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "queue", "sorting", "simulation"]}, "language": "python", "interface": {"raw_signature": "def deckRevealedIncreasing(self, deck: list[int]) -> list[int]:", "container": "Solution", "callable": "deckRevealedIncreasing", "parameters": [{"name": "deck", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 952, "task_id": "largest-component-size-by-common-factor", "difficulty": "Hard", "problem_description": "You are given an integer array of unique positive integers nums. Consider the following graph:\n\n- There are nums.length nodes, labeled nums[0] to nums[nums.length - 1],\n- There is an undirected edge between nums[i] and nums[j] if nums[i] and nums[j] share a common factor greater than 1.\n\nReturn the size of the largest connected component in the graph.\n\nExample 1:\n\nInput: nums = [4,6,15,35]\nOutput: 4\n\nExample 2:\n\nInput: nums = [20,50,9,63]\nOutput: 2\n\nExample 3:\n\nInput: nums = [2,3,6,7,4,12,21,39]\nOutput: 8\n\nConstraints:\n\n- 1 <= nums.length <= 2 * 10^4\n- 1 <= nums[i] <= 10^5\n- All the values of nums are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [20, 50, 9, 63]) == 2\n assert candidate(nums = [2, 3, 6, 7, 4, 12, 21, 39]) == 8\n assert candidate(nums = [30, 60, 20, 5, 15]) == 5\n assert candidate(nums = [5, 7, 11, 13]) == 1\n assert candidate(nums = [30, 42, 70, 28, 10, 5]) == 6\n assert candidate(nums = [30, 42, 66, 55]) == 4\n assert candidate(nums = [7, 3, 5, 23, 31, 37, 41, 43, 47, 53]) == 1\n assert candidate(nums = [4, 6, 15, 35]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [30, 42, 70, 28]) == 4\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 8\n assert candidate(nums = [8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 23\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == 10\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 15\n assert candidate(nums = [105, 210, 315, 420, 525, 630]) == 6\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [45, 90, 120, 135, 180, 225, 270, 315, 360, 405, 450, 495]) == 12\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 11\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240]) == 15\n assert candidate(nums = [100, 150, 200, 250, 300, 350]) == 6\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]) == 11\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 10\n assert candidate(nums = [60, 30, 90, 120, 180, 210, 240, 300]) == 8\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 1\n assert candidate(nums = [28, 49, 98, 147, 196, 245, 294, 343, 392, 441, 490, 539, 588, 637, 686]) == 15\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197]) == 1\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 1\n assert candidate(nums = [44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253]) == 20\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 33, 35, 38, 39, 44, 45, 46, 51, 55, 57, 58, 62, 65, 66, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95, 106]) == 33\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 19\n assert candidate(nums = [21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 12\n assert candidate(nums = [121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 20\n assert candidate(nums = [81, 135, 189, 243, 315, 378, 459, 513, 567, 639, 693, 756, 819, 873, 945]) == 15\n assert candidate(nums = [840, 1680, 2520, 3360, 4200, 5040, 5880, 6720, 7560, 8400, 9240, 10080, 10920, 11760, 12600]) == 15\n assert candidate(nums = [121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140]) == 16\n assert candidate(nums = [961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980]) == 16\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 20\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 8\n assert candidate(nums = [56, 84, 112, 140, 168, 196, 224, 252, 280, 308, 336, 364, 392]) == 13\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 1\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == 9\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]) == 15\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 = [56, 98, 168, 224, 231, 252, 336, 392, 441, 462, 504, 539, 616, 672, 784, 882, 924, 1008, 1092, 1176, 1260, 1344, 1428, 1512, 1596, 1680, 1764, 1848, 1932, 2016, 2100]) == 31\n assert candidate(nums = [2520, 5040, 10080, 20160, 40320]) == 5\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420]) == 20\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108]) == 18\n assert candidate(nums = [36, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255]) == 16\n assert candidate(nums = [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]) == 42\n assert candidate(nums = [30030, 30031, 30032, 30033, 30034, 30035, 30036, 30037, 30038, 30039, 30040, 30041, 30042, 30043, 30044, 30045, 30046, 30047, 30048, 30049, 30050, 30051, 30052, 30053, 30054, 30055]) == 22\n assert candidate(nums = [1000, 1024, 1050, 1080, 1100, 1120, 1140, 1150, 1170, 1190, 1200, 1230, 1260, 1290, 1320, 1350, 1380, 1410, 1440, 1470]) == 20\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1\n assert candidate(nums = [60, 100, 150, 200, 250, 300]) == 6\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 = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 10\n assert candidate(nums = [97, 194, 291, 388, 485, 582, 679, 776, 873, 970, 1067, 1164, 1261, 1358, 1455, 1552, 1649, 1746, 1843, 1940]) == 20\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 15\n assert candidate(nums = [105, 115, 130, 140, 154, 165, 170, 182, 187, 195, 210, 220, 221, 231, 238, 247, 253, 260, 273, 286, 299]) == 21\n assert candidate(nums = [210, 420, 630, 840, 1050, 1260, 1470, 1680, 1890, 2100, 2310, 2520, 2730, 2940, 3150]) == 15\n assert candidate(nums = [99, 121, 143, 165, 187, 209, 231, 253, 275, 297, 319, 330, 352, 374, 396, 418, 440, 462, 484, 506]) == 20\n assert candidate(nums = [210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420, 441, 462, 483, 504, 525, 546, 567, 588, 609]) == 20\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600]) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 16\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [21, 35, 55, 77, 91, 119, 143, 165, 187, 209, 231, 253, 286, 308, 330]) == 15\n assert candidate(nums = [210, 330, 462, 594, 726, 858, 990, 1122, 1254, 1386, 1518, 1650, 1782, 1914, 2046]) == 15\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 = [60, 65, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 143, 154, 165, 182, 210, 231, 252]) == 20\n assert candidate(nums = [44, 66, 100, 121, 143, 165]) == 6\n assert candidate(nums = [60, 100, 140, 210, 280, 350, 420, 500, 560, 630, 700, 770, 840, 910, 980, 1050, 1120, 1190, 1260, 1330, 1400, 1470, 1540, 1610, 1680, 1750, 1820, 1890, 1960, 2030]) == 30\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1\n assert candidate(nums = [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]) == 40\n assert candidate(nums = [840, 924, 1008, 1092, 1176, 1260, 1344, 1428, 1512, 1596, 1680, 1764, 1848, 1932, 2016, 2100, 2184, 2268, 2352, 2436, 2520]) == 21\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 20\n assert candidate(nums = [15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345, 375, 405, 435, 465, 495, 525, 555, 585]) == 20\n assert candidate(nums = [210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420, 441, 462, 483, 504, 525, 546, 567, 588, 609, 630, 651, 672, 693, 714, 735, 756, 777, 798, 819, 840, 861, 882, 903, 924, 945, 966, 987, 1008, 1029]) == 40\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 28, 33, 35, 39, 44, 45, 55, 65, 77, 88, 99, 105, 110]) == 20\n assert candidate(nums = [81, 121, 169, 225, 289, 361, 441, 529, 625, 729]) == 5\n assert candidate(nums = [104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 14\n assert candidate(nums = [100, 102, 105, 108, 110, 112, 114, 115, 117, 119]) == 10\n assert candidate(nums = [3, 5, 15, 25, 45, 75, 105, 125, 135, 175, 225, 245, 315, 375, 525]) == 15\n assert candidate(nums = [44, 88, 132, 176, 220, 264, 308, 352, 396, 440, 484, 528, 572, 616, 660]) == 15\n assert candidate(nums = [210, 231, 252, 273, 294, 315, 336, 357, 378, 399]) == 10\n assert candidate(nums = [100, 102, 104, 105, 106, 108, 110, 112, 114, 115, 117, 119, 121, 122, 123, 124, 126, 128, 130, 132, 133, 134, 135, 136, 138, 140, 141, 142, 143, 145]) == 30\n assert candidate(nums = [100, 105, 110, 115, 120]) == 5\n assert candidate(nums = [154, 308, 462, 616, 770, 924, 1078, 1232, 1386, 1540, 1694, 1848, 2002, 2156, 2310]) == 15\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600]) == 10\n assert candidate(nums = [30, 42, 70, 105, 210]) == 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]) == 20\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157]) == 1\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 10\n assert candidate(nums = [49, 63, 77, 91, 105, 119, 133, 147, 161, 175, 189, 203, 217, 231, 245]) == 15\n assert candidate(nums = [18, 24, 30, 42, 56, 72, 84, 90]) == 8\n assert candidate(nums = [77, 91, 119, 133, 143, 161, 187, 209, 221, 231, 247, 253, 287, 299, 319]) == 15\n", "comparison": "exact"}, "public_tests": ["[4,6,15,35]", "[20,50,9,63]", "[2,3,6,7,4,12,21,39]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().largestComponentSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:19+00:00", "tests_total": 98, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "math", "union-find", "number-theory", "prime-factorization"]}, "language": "python", "interface": {"raw_signature": "def largestComponentSize(self, nums: list[int]) -> int:", "container": "Solution", "callable": "largestComponentSize", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 953, "task_id": "verifying-an-alien-dictionary", "difficulty": "Easy", "problem_description": "In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.\n\nGiven a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographically in this alien language.\n\nExample 1:\n\nInput: words = [\"hello\",\"leetcode\"], order = \"hlabcdefgijkmnopqrstuvwxyz\"\nOutput: true\nExplanation: As 'h' comes before 'l' in this language, then the sequence is sorted.\n\nExample 2:\n\nInput: words = [\"word\",\"world\",\"row\"], order = \"worldabcefghijkmnpqstuvxyz\"\nOutput: false\nExplanation: As 'd' comes after 'l' in this language, then words[0] > words[1], hence the sequence is unsorted.\n\nExample 3:\n\nInput: words = [\"apple\",\"app\"], order = \"abcdefghijklmnopqrstuvwxyz\"\nOutput: false\nExplanation: The first three characters \"app\" match, and the second string is shorter (in size.) According to lexicographical rules \"apple\" > \"app\", because 'l' > '∅', where '∅' is defined as the blank character which is less than any other character (More info).\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 20\n- order.length == 26\n- All characters in words[i] and order are English lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['kuvp', 'q'],order = \"ngxlkthsjuoqcpavbfdermiyzw\") == True\n assert candidate(words = ['zzz', 'zzzz'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['abc', 'ab'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['hello', 'hello', 'hello'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['apple', 'app'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['app', 'apple'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['aaa'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['hello', 'leetcode'],order = \"hlabcdefgijkmnopqrstuvwxyz\") == True\n assert candidate(words = ['zoo', 'zoop'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['a', 'b', 'c'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['abc', 'acb'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['kuvp', 'q'],order = \"ngxlkthsjuoqcpavbfderimyzw\") == True\n assert candidate(words = ['zzz', 'zaz'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['z', 'z'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['aaa', 'aa'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['word', 'world', 'row'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['abc', 'acb', 'bac'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['wrt', 'wrf', 'er', 'ett', 'rftt'],order = \"wertfabcghijklmnopqsudvyxz\") == False\n assert candidate(words = ['banana', 'apple', 'orange'],order = \"zyxcbaedfghijklmnopqrstuvw\") == True\n assert candidate(words = ['abcd', 'abcde', 'abcd'],order = \"fedcbazyxwvutsrqponmlkjhig\") == False\n assert candidate(words = ['aaa', 'aab', 'aac'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['cat', 'dog', 'bird'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['same', 'sake', 'saki'],order = \"askdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['aaa', 'aaab', 'aaac'],order = \"abcdefghijkmnopqrstuvwxyzl\") == True\n assert candidate(words = ['banana', 'bandana', 'bandwidth'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['xyz', 'xyzz', 'xyza'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['short', 'shorter', 'shortest'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['banana', 'bandana', 'bandit'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['a', 'b', 'c', 'd'],order = \"cbaedfghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['xyz', 'xyy', 'xyx'],order = \"xyzabcdefghijklmnopqrstuvw\") == False\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['mismatch', 'mis', 'misleading'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['dog', 'cat'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['abc', 'abz', 'abcde'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['long', 'longer', 'longest'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['app', 'apple', 'apples'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['word', 'world', 'wor'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['apple', 'apples', 'app', 'appl'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['dog', 'cat', 'bird'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['alien', 'algorithm', 'all'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['aa', 'a'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['zebra', 'zebraa'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['banana', 'bandana', 'apple'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['zebra', 'zoo', 'zoom', 'zoology'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['same', 'same', 'same'],order = \"fedcbazyxwvutsrqponmlkjhig\") == True\n assert candidate(words = ['abcd', 'abce', 'abcf'],order = \"acegbdfhijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['aaa', 'aa', 'aaaa', 'aaaaa'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['abc', 'acb', 'bac'],order = \"cbafehidgjklmponqrstuvwxzy\") == False\n assert candidate(words = ['aaa', 'aab', 'aac'],order = \"cbafehidgjklmponqrstuvwxzy\") == False\n assert candidate(words = ['xylophone', 'xylometer', 'xylography'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['abcd', 'abcde', 'abcdeg', 'abcdef', 'abcdefg'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['same', 'same', 'same'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['zebra', 'dog', 'duck', 'dove'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['zz', 'zzz', 'zzzz', 'zzzzz'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['word', 'wor', 'worl', 'world'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['abcd', 'abce', 'abcf'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['short', 'shorter', 'shortest'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['zebra', 'zealot', 'zest'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['zebra', 'zebr', 'zebraa'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['apple', 'apples', 'app'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['xww', 'xwx', 'xw'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['xyz', 'xy', 'x'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['word', 'world', 'wor', 'worl'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['zyx', 'zy', 'zxy'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['xyz', 'xya', 'xyb'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['word', 'world', 'wordly'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['long', 'longer', 'longest'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['aa', 'a'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['longest', 'longer', 'long'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['a', 'b', 'a'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['same', 'same', 'same'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['special', 'spectacular', 'spectacularly'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],order = \"abcdefghijkmnopqrstuvwxyzl\") == False\n assert candidate(words = ['zz', 'z', 'zzz'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['banana', 'bandana', 'band', 'bad'],order = \"badnecghijklmopqrstuvwxyzf\") == False\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],order = \"abcdefghijklmnopqrstuvwxyz\") == 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'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['this', 'thisis', 'thisisatest'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['abc', 'ab', 'abcd'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['jjg', 'jja', 'jj', 'jjb'],order = \"jgfedcbaopqrstuvwxyznhimkl\") == False\n assert candidate(words = ['racecar', 'racecars', 'racecarx'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['abcd', 'abce', 'abcf'],order = \"mnopqrstuvwxyzabcdefghijkl\") == True\n assert candidate(words = ['apple', 'app', 'application'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['zz', 'zzz', 'zzzz', 'zzzzz'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['aaa', 'aa', 'a'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['apple', 'apples', 'banana'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['apple', 'app', 'application'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['abc', 'ab', 'a'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['abc', 'abcd', 'ab'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['abcd', 'abc'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['aaa', 'aa', 'a'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['abc', 'abb', 'aaa'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['abcd', 'abc', 'ab', 'a'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['aaa', 'aab', 'aac', 'aad'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['prefix', 'pre', 'prelude'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['apple', 'apples', 'app'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['apple', 'app', 'application'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['word', 'world', 'wordplay'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['zz', 'za', 'zb'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['z', 'za', 'zb', 'zab'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['ab', 'abc', 'abcd', 'abcde'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['apple', 'apples', 'app'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['zzzz', 'zzz', 'zzzzz'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['longer', 'long', 'lon'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['hello', 'hallo', 'halloween'],order = \"hlabcdefgijkmnopqrstuvwxyz\") == False\n assert candidate(words = ['hello', 'helloo', 'hell', 'hellp'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['interstellar', 'inter', 'intergalactic'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['banana', 'apple', 'orange'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['word', 'world', 'wordld'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['abc', 'ab', 'abcd'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'ddd'],order = \"abcdefgihjklmnopqrstuvwxyz\") == True\n assert candidate(words = ['a', 'b', 'a'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['cba', 'cbcd'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['same', 'sam', 'samesame'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['apple', 'apples', 'application'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['xx', 'xy', 'xz', 'ya', 'yb', 'yc'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['word', 'world', 'row', 'wordz'],order = \"worldabcefghijkmnpqstuvxyz\") == False\n assert candidate(words = ['hello', 'hell', 'he', 'h'],order = \"hlabcdefgijkmnopqrstuvwxyz\") == False\n assert candidate(words = ['aaa', 'aa', 'a'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['hello', 'hell', 'hel', 'he', 'h'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['same', 'same', 'same'],order = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(words = ['zyx', 'zy', 'z'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\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'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],order = \"bacdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['abc', 'abd', 'abcd'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['hello', 'hallo', 'hella'],order = \"hlabcdefgijkmnopqrstuvwxyz\") == False\n assert candidate(words = ['abc', 'abcd', 'ab'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['same', 'some', 'sand'],order = \"samponedcbjklfgtqrhxvziwuy\") == False\n assert candidate(words = ['aaaaa', 'aaaab', 'aaaba'],order = \"abcdefghijklmnopqrstuvwzyx\") == False\n assert candidate(words = ['same', 'samee', 'sameee'],order = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(words = ['abc', 'abb', 'ab'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['xylophone', 'xylo', 'xylophones'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['fgh', 'fg', 'f'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['apple', 'apply', 'app'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(words = ['banana', 'bandana', 'bandanaa'],order = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(words = ['aab', 'aac', 'aaa', 'aad'],order = \"abcdefghijklmnopqrstuvwxyz\") == False\n", "comparison": "exact"}, "public_tests": ["[\"hello\",\"leetcode\"]\n\"hlabcdefgijkmnopqrstuvwxyz\"", "[\"word\",\"world\",\"row\"]\n\"worldabcefghijkmnpqstuvxyz\"", "[\"apple\",\"app\"]\n\"abcdefghijklmnopqrstuvwxyz\""], "hints": [], "metadata": {"canonical_parameter_names": ["words", "order"], "leetcode_dataset_entry_point": "Solution().isAlienSorted", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:22+00:00", "tests_total": 158, "tests_dropped": 20, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def isAlienSorted(self, words: list[str], order: str) -> bool:", "container": "Solution", "callable": "isAlienSorted", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "order", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 954, "task_id": "array-of-doubled-pairs", "difficulty": "Medium", "problem_description": "Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise.\n\nExample 1:\n\nInput: arr = [3,1,3,6]\nOutput: false\n\nExample 2:\n\nInput: arr = [2,1,2,6]\nOutput: false\n\nExample 3:\n\nInput: arr = [4,-2,2,-4]\nOutput: true\nExplanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4].\n\nConstraints:\n\n- 2 <= arr.length <= 3 * 10^4\n- arr.length is even.\n- -10^5 <= arr[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 4, 2, 2]) == True\n assert candidate(arr = [1, 2, 4, 16, 8, 4]) == False\n assert candidate(arr = [-5, -2, -10, -1, -1, -5]) == False\n assert candidate(arr = [5, -3, 3, -2, 2, -4]) == False\n assert candidate(arr = [0, 0]) == True\n assert candidate(arr = [4, -2, 2, -4]) == True\n assert candidate(arr = [1, 2, 3, 6, 4, 8]) == True\n assert candidate(arr = [1, 2, 4, 16, 8, 32]) == True\n assert candidate(arr = [1, 2, 2, 4]) == True\n assert candidate(arr = [2, 1, 2, 6]) == False\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [-2, 4, -2, 4]) == False\n assert candidate(arr = [-1, -2, -3, -6, -6, -12]) == True\n assert candidate(arr = [-2, 4, -8, 16, -32, 64]) == False\n assert candidate(arr = [1, 2, 3, 6, 6, 12]) == True\n assert candidate(arr = [3, 1, 3, 6]) == False\n assert candidate(arr = [1, 2, 3, 6]) == True\n assert candidate(arr = [-1, -2, -2, -4]) == True\n assert candidate(arr = [1, 2, 4, 8]) == True\n assert candidate(arr = [1, 2, 2, 4, 4, 8]) == True\n assert candidate(arr = [1, 2, 3, 6, 5, 10, 15, 30, 4, 8, 12, 24, 20, 40, 60, 120]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 18]) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 18, 15, 12, 6, 10]) == False\n assert candidate(arr = [1, 2, 3, 6, 5, 10, 15, 30, 4, 8, 12, 24, 20, 40, 60, 120, 7, 14, 21, 42]) == True\n assert candidate(arr = [5, 10, 10, 20, 25, 50]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == True\n assert candidate(arr = [5, 2, 1, 10, 5, 20, 2, 4]) == False\n assert candidate(arr = [1, 2, 2, 4, 4, 8, 8, 16]) == True\n assert candidate(arr = [-1, 1, -1, 1, -2, 2, -2, 2, -4, 4, -4, 4]) == False\n assert candidate(arr = [-8, -4, -2, -1, -16, -32, -2, -4]) == True\n assert candidate(arr = [-1, 2, -2, 4, -4, 8]) == False\n assert candidate(arr = [-1, -2, -3, -6, -5, -10, -15, -30, -4, -8, -12, -24, -20, -40, -60, -120, -7, -14, -21, -42]) == True\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [3, 6, 3, 6, 12, 24]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128]) == True\n assert candidate(arr = [-1, 2, -2, 1, -4, 4]) == False\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50]) == False\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000]) == False\n assert candidate(arr = [-100000, 100000, -50000, 50000, -25000, 25000, -12500, 12500]) == True\n assert candidate(arr = [-1, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == False\n assert candidate(arr = [-2, -4, -8, -16, -32, -64, -128, -256]) == True\n assert candidate(arr = [5, -5, 10, -10, 20, -20, 40, -40]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -50]) == False\n assert candidate(arr = [-2, 4, 1, -1, 2, -2, -4, 8]) == True\n assert candidate(arr = [1, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == False\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250]) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32]) == True\n assert candidate(arr = [10, 20, 20, 40, 80, 160, 320, 640]) == True\n assert candidate(arr = [1, 4, 2, 8, 4, 2]) == True\n assert candidate(arr = [1, 3, 5, 7, 2, 6, 10, 14, 4, 12]) == False\n assert candidate(arr = [-3, 3, -6, 6, -12, 12, -24, 24]) == True\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250, 3125, -3125, 15625, -15625, 78125, -78125]) == False\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 100, 150, 200, 250]) == False\n assert candidate(arr = [10, 5, 5, 15, 20, 10]) == False\n assert candidate(arr = [1, 2, 3, 6, 4, 8, 9, 18, 12, 24]) == True\n assert candidate(arr = [-4, -8, -2, -1, -16, -2]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 6, 6, 12, 12]) == False\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60]) == False\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == True\n assert candidate(arr = [5, 10, 5, 20, 10, 40, 20, 80]) == False\n assert candidate(arr = [1, 3, 3, 6, 9, 18, 27, 54]) == False\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 20]) == False\n assert candidate(arr = [3, 6, 1, 2, 18, 9, 27, 54]) == True\n assert candidate(arr = [6, 3, 3, 12, 2, 4]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 40, 5, 15, 30, 60]) == False\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8]) == True\n assert candidate(arr = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64]) == True\n assert candidate(arr = [1, 3, 2, 6, 4, 8, 5, 10, 7, 14, 9, 18, 11, 22, 12, 24]) == True\n assert candidate(arr = [-1, 1, -2, 2, -4, 4, -8, 8]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 4, 8, 16, 32, 64]) == False\n assert candidate(arr = [-1, 2, -2, 1, -4, 4, -8, 8, 16, -16]) == False\n assert candidate(arr = [3, 9, 1, 27, 3, 9, 27, 81]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == False\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64, -128]) == True\n assert candidate(arr = [-1, 2, -2, 1]) == True\n assert candidate(arr = [1, -1, 2, -2, 4, -4, 8, -8]) == True\n assert candidate(arr = [6, 3, 12, 24, 48, 96, 192, 384, 768, 1536, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == True\n assert candidate(arr = [-3, -6, -12, -24, -48, -96, -192, -384, -768, -1536]) == True\n assert candidate(arr = [-1, -2, -4, -8, 1, 2, 4, 8]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == True\n assert candidate(arr = [3, 6, 9, 18, 27, 54]) == True\n assert candidate(arr = [-1, -2, -3, -6, -5, -10, -15, -30, -4, -8, -12, -24, -20, -40, -60, -120]) == True\n assert candidate(arr = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == False\n assert candidate(arr = [1, 1, 1, 2, 2, 4, 4, 8, 8, 16]) == False\n assert candidate(arr = [-5, 5, -10, 10, -20, 20, -40, 40, -80, 80]) == False\n assert candidate(arr = [-5, -10, -20, -2, -4, -8, -1, -2, -4, -8]) == False\n assert candidate(arr = [10, 5, 3, 6, 2, 4, 8, 1]) == True\n assert candidate(arr = [-1, -2, -3, -6, -4, -8, -9, -18, -12, -24]) == True\n assert candidate(arr = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 32, 32, 32, 32]) == False\n assert candidate(arr = [-2, 4, -8, 16, -32, 64, -128, 256]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == False\n assert candidate(arr = [4, 8, 4, 16, 8, 32, 2, 1]) == True\n assert candidate(arr = [-1, -3, -6, -12, -24, -48, -96, -192, -384, -768]) == False\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -6, 6, -12, 12, -24, 24, -48, 48]) == False\n assert candidate(arr = [3, 6, 1, 2, 18, 9, 36, 18]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -18]) == False\n assert candidate(arr = [-1, -2, -3, -6, -3, -6]) == True\n assert candidate(arr = [5, 10, 15, 30, 60, 120, 240, 480]) == True\n assert candidate(arr = [1, 3, 2, 6, 4, 12, 8, 24]) == True\n", "comparison": "exact"}, "public_tests": ["[3,1,3,6]", "[2,1,2,6]", "[4,-2,2,-4]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().canReorderDoubled", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:24+00:00", "tests_total": 112, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def canReorderDoubled(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "canReorderDoubled", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 955, "task_id": "delete-columns-to-make-sorted-ii", "difficulty": "Medium", "problem_description": "You are given an array of n strings strs, all of the same length.\n\nWe may choose any deletion indices, and we delete all the characters in those indices for each string.\n\nFor example, if we have strs = [\"abcdef\",\"uvwxyz\"] and deletion indices {0, 2, 3}, then the final array after deletions is [\"bef\", \"vyz\"].\n\nSuppose we chose a set of deletion indices answer such that after deletions, the final array has its elements in lexicographic order (i.e., strs[0] <= strs[1] <= strs[2] <= ... <= strs[n - 1]). Return the minimum possible value of answer.length.\n\nExample 1:\n\nInput: strs = [\"ca\",\"bb\",\"ac\"]\nOutput: 1\nExplanation:\nAfter deleting the first column, strs = [\"a\", \"b\", \"c\"].\nNow strs is in lexicographic order (ie. strs[0] <= strs[1] <= strs[2]).\nWe require at least 1 deletion since initially strs was not in lexicographic order, so the answer is 1.\n\nExample 2:\n\nInput: strs = [\"xc\",\"yb\",\"za\"]\nOutput: 0\nExplanation:\nstrs is already in lexicographic order, so we do not need to delete anything.\nNote that the rows of strs are not necessarily in lexicographic order:\ni.e., it is NOT necessarily true that (strs[0][0] <= strs[0][1] <= ...)\n\nExample 3:\n\nInput: strs = [\"zyx\",\"wvu\",\"tsr\"]\nOutput: 3\nExplanation: We have to delete every column.\n\nConstraints:\n\n- n == strs.length\n- 1 <= n <= 100\n- 1 <= strs[i].length <= 100\n- strs[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strs = ['ppp', 'qqq', 'rrr']) == 0\n assert candidate(strs = ['az', 'za']) == 0\n assert candidate(strs = ['xc', 'yb', 'za']) == 0\n assert candidate(strs = ['dog', 'cat', 'bat']) == 2\n assert candidate(strs = ['abcdef', 'uvwxyz']) == 0\n assert candidate(strs = ['abcd', 'abce', 'abcf']) == 0\n assert candidate(strs = ['aaa', 'aaa', 'aaa']) == 0\n assert candidate(strs = ['abc', 'bcd', 'cde']) == 0\n assert candidate(strs = ['zzz', 'aaa', 'zzz']) == 3\n assert candidate(strs = ['abc', 'acd', 'acc']) == 1\n assert candidate(strs = ['zyx', 'wvu', 'tsr']) == 3\n assert candidate(strs = ['axz', 'byz', 'cxz']) == 0\n assert candidate(strs = ['abc', 'acd', 'ace']) == 0\n assert candidate(strs = ['a', 'b', 'c']) == 0\n assert candidate(strs = ['abc', 'bca', 'cab']) == 0\n assert candidate(strs = ['zzz', 'zzz', 'zzz', 'zzz']) == 0\n assert candidate(strs = ['dddd', 'ddda', 'dddd', 'dddd']) == 1\n assert candidate(strs = ['aab', 'abc', 'aaa']) == 2\n assert candidate(strs = ['ca', 'bb', 'ac']) == 1\n assert candidate(strs = ['abcd', 'efgh', 'ijkl']) == 0\n assert candidate(strs = ['az', 'by', 'cx']) == 0\n assert candidate(strs = ['cba', 'daf', 'ghi']) == 0\n assert candidate(strs = ['aab', 'aac', 'aba']) == 0\n assert candidate(strs = ['ghi', 'daf', 'cba']) == 3\n assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop']) == 0\n assert candidate(strs = ['aaa', 'bbb', 'ccc']) == 0\n assert candidate(strs = ['a', 'b', 'c', 'd']) == 0\n assert candidate(strs = ['cba', 'bca', 'cab']) == 2\n assert candidate(strs = ['pqrs', 'qrsn', 'rsnp', 'snpq']) == 0\n assert candidate(strs = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']) == 0\n assert candidate(strs = ['aax', 'aba', 'aca', 'ada']) == 0\n assert candidate(strs = ['aab', 'bac', 'aaa']) == 2\n assert candidate(strs = ['xyz', 'yza', 'zab', 'abc', 'bcd']) == 3\n assert candidate(strs = ['xyzz', 'yxzz', 'zxyy', 'zyyx']) == 0\n assert candidate(strs = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 0\n assert candidate(strs = ['abc', 'cab', 'bca', 'bac', 'acb', 'cba']) == 3\n assert candidate(strs = ['fgh', 'ghi', 'hij', 'ijk', 'jkl']) == 0\n assert candidate(strs = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij']) == 0\n assert candidate(strs = ['aaaaa', 'aaabb', 'aabaa', 'aabbb', 'abaaa', 'ababb', 'abaab', 'ababa', 'abbaa', 'abbab', 'abbba', 'abbbb', 'baaaa', 'baaab', 'baaba', 'baabb', 'bbaaa', 'bbaab', 'bbaba', 'bbbaa', 'bbbb', 'caaaa', 'caaab', 'caaba', 'caabb', 'cbaaa', 'cbaab', 'cbaba', 'cbbaa', 'cbbbb', 'daaaa', 'daaab', 'daaba', 'daabb', 'dbaaa', 'dbaab', 'dbaba', 'dbbaa', 'dbbbb', 'eaaaa', 'eaab', 'eaaba', 'eaabb', 'ebaaa', 'ebaab', 'ebaba', 'ebbaa', 'ebbbb', 'faaaa', 'faaab', 'faaba', 'faabb', 'fbaaa', 'fbaab', 'fbaba', 'fbbaa', 'fbbbb']) == 2\n assert candidate(strs = ['zzzzz', 'zzzzx', 'zzzzy', 'zzzzz', 'zzzzz']) == 1\n assert candidate(strs = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi']) == 0\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij']) == 0\n assert candidate(strs = ['abc', 'bac', 'bca', 'cab', 'cba', 'acb']) == 3\n assert candidate(strs = ['banana', 'bandana', 'bandanna']) == 0\n assert candidate(strs = ['zzzzz', 'zzzzz', 'zzzzz', 'zzzzz', 'zzzzz', 'zzzzz', 'zzzzz', 'zzzzz', 'zzzzz']) == 0\n assert candidate(strs = ['qrst', 'prst', 'qrst', 'qrst', 'qrst']) == 1\n assert candidate(strs = ['ghijkl', 'hijklm', 'ijklmn', 'jklmno', 'klmnop']) == 0\n assert candidate(strs = ['random', 'ranbom', 'randam', 'randbm', 'randmm']) == 2\n assert candidate(strs = ['lmno', 'mnop', 'opqr', 'pqrs', 'qrst']) == 0\n assert candidate(strs = ['xyz', 'zyx', 'wxy', 'uvw']) == 3\n assert candidate(strs = ['xyzz', 'yxzz', 'zxyz', 'zzxy', 'zzzx']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'acdb', 'adbc']) == 0\n assert candidate(strs = ['banana', 'banaba', 'banaaa', 'banbaa']) == 1\n assert candidate(strs = ['zzzz', 'zzzy', 'zzzx', 'zzxw', 'zzvw', 'zxvw', 'xvwu']) == 4\n assert candidate(strs = ['pqrst', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz']) == 0\n assert candidate(strs = ['abcd', 'dcba', 'abcd', 'dcba']) == 4\n assert candidate(strs = ['mnopqr', 'zyxwvu', 'tsrqup', 'lkjihg', 'fedcba']) == 6\n assert candidate(strs = ['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd']) == 0\n assert candidate(strs = ['apple', 'apply', 'appla']) == 1\n assert candidate(strs = ['zzzz', 'zzzy', 'zzzx', 'zzxw', 'zzvw', 'zzuv', 'zztu']) == 2\n assert candidate(strs = ['abcd', 'acbd', 'adbc', 'dabc', 'bdac']) == 4\n assert candidate(strs = ['xyz', 'xzy', 'yxz', 'yzx', 'zxy', 'zyx']) == 0\n assert candidate(strs = ['apple', 'apply', 'appla', 'apple', 'applq']) == 1\n assert candidate(strs = ['nmop', 'mnop', 'mnop', 'mnop']) == 1\n assert candidate(strs = ['xyz', 'xyw', 'xyv', 'xyu', 'xyt', 'xys', 'xyr', 'xyp', 'xyo', 'xyn', 'xym', 'xyl', 'xyk', 'xyj', 'xyi', 'xyh', 'xyg', 'xyf', 'xye', 'xyd', 'xyc', 'xyb', 'xya']) == 1\n assert candidate(strs = ['abcde', 'abcdf', 'abcef', 'abceg', 'abcde']) == 2\n assert candidate(strs = ['zzzz', 'zzzy', 'zzyy', 'zyyy', 'yyyy', 'yyyz']) == 4\n assert candidate(strs = ['random', 'randome', 'randomly', 'randomly', 'randomly']) == 0\n assert candidate(strs = ['mnop', 'lmno', 'opqr', 'pqrs', 'qrst']) == 4\n assert candidate(strs = ['aab', 'abc', 'abc']) == 0\n assert candidate(strs = ['qwerty', 'asdfgh', 'zxcvbn']) == 6\n assert candidate(strs = ['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']) == 1\n assert candidate(strs = ['aabbcc', 'aabbbc', 'aabccc', 'aabccc', 'aabccc']) == 1\n assert candidate(strs = ['abc', 'bce', 'cae']) == 0\n assert candidate(strs = ['zebra', 'zaxar', 'zecos', 'zabba']) == 4\n assert candidate(strs = ['abcdef', 'bcdegh', 'cdefgh', 'defghi', 'efghij', 'fghijk']) == 0\n assert candidate(strs = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh']) == 0\n assert candidate(strs = ['apple', 'apply', 'appla', 'apppa']) == 1\n assert candidate(strs = ['abac', 'acba', 'baca', 'bcaa', 'cab', 'cba']) == 0\n assert candidate(strs = ['abcd', 'bcad', 'acbd']) == 1\n assert candidate(strs = ['abcd', 'adcb', 'bacd']) == 0\n assert candidate(strs = ['abcdabcd', 'bcdbcdbd', 'cdcddcdc', 'dedededc', 'eeedeeec']) == 0\n assert candidate(strs = ['aaaa', 'aaab', 'aaba', 'aabb', 'abaa', 'abab', 'abba', 'abbb', 'baaa', 'baab', 'baba', 'babb', 'bbaa', 'bbab', 'bbba', 'bbbb']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'acdb', 'acbd']) == 2\n assert candidate(strs = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == 0\n assert candidate(strs = ['aaaabbbb', 'bbbbaaaa', 'aabbaabb', 'abababab', 'bbaabbaa']) == 8\n assert candidate(strs = ['acbac', 'bcbac', 'cbbac', 'dcbac', 'ecbac', 'fcbac']) == 0\n assert candidate(strs = ['moon', 'moan', 'moon', 'mane']) == 3\n assert candidate(strs = ['aabbcc', 'ababcc', 'aaccbb']) == 2\n assert candidate(strs = ['aabbcc', 'abacbc', 'abcabc', 'aabcbc', 'aacbbc']) == 4\n assert candidate(strs = ['aaa', 'aba', 'aaa', 'aca', 'aaa']) == 1\n assert candidate(strs = ['aa', 'bb', 'aa', 'bb', 'aa', 'bb', 'aa', 'bb', 'aa', 'bb']) == 2\n assert candidate(strs = ['aaaaa', 'aaabb', 'aabaa', 'aabab', 'aaced', 'aacef', 'aaceg', 'aaceh', 'aacei', 'aacej', 'aacek', 'aacei', 'aacej', 'aacek', 'aacei', 'aacej', 'aacek', 'aacei', 'aacej', 'aacek']) == 1\n assert candidate(strs = ['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']) == 0\n assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == 0\n assert candidate(strs = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == 0\n assert candidate(strs = ['abcdef', 'uvwxyz', 'ghijkl']) == 6\n assert candidate(strs = ['aaaa', 'aaab', 'aaac', 'aaba', 'aabb', 'aabc', 'aaca', 'aacb', 'aacc', 'abaa', 'abab', 'abac', 'abba', 'abbb', 'abbc', 'abca', 'abcb', 'abcc', 'acaa', 'acab', 'acac', 'acba', 'acbb', 'acbc', 'acca', 'accb', 'accc', 'baaa', 'baab', 'baac', 'baba', 'babb', 'babc', 'baca', 'bacb', 'bacc', 'bbaa', 'bbab', 'bbac', 'bbba', 'bbbb', 'bbbc', 'bbca', 'bbcb', 'bbcc', 'bcaa', 'bcab', 'bcac', 'bcba', 'bcbb', 'bcbc', 'bccb', 'bccc', 'caaa', 'caab', 'caac', 'caba', 'cabb', 'cabc', 'caca', 'cacb', 'cacc', 'cbaa', 'cbab', 'cbac', 'cbba', 'cbbb', 'cbbc', 'cbca', 'cbcb', 'cbcc', 'ccaa', 'ccab', 'ccac', 'ccba', 'ccbb', 'ccbc', 'ccca', 'cccb', 'cccc']) == 0\n assert candidate(strs = ['mnop', 'mnop', 'mnop', 'mnop', 'mnop']) == 0\n assert candidate(strs = ['pqrs', 'psrq', 'qrst', 'rpsq', 'srqp', 'tqrs']) == 0\n assert candidate(strs = ['aabc', 'abac', 'abca', 'acba', 'acab', 'baca', 'bacb', 'baac', 'bcaa', 'cab', 'cbab', 'caba', 'cbba', 'cbaa']) == 3\n assert candidate(strs = ['lkjihg', 'kjihgf', 'jihgfe', 'ihgfed', 'hgfedc']) == 6\n assert candidate(strs = ['abcdef', 'bcdefa', 'cdefab']) == 0\n assert candidate(strs = ['qwe', 'qaz', 'qwr']) == 2\n assert candidate(strs = ['aaa', 'aab', 'aac', 'aad', 'baa', 'aba', 'aca', 'ada', 'baa', 'aba', 'aca', 'ada', 'baa', 'aba', 'aca', 'ada']) == 3\n assert candidate(strs = ['banana', 'bandana', 'bandanna', 'bandanna']) == 0\n assert candidate(strs = ['zzzz', 'zzyz', 'zzyy', 'zzyx', 'zzyw']) == 2\n assert candidate(strs = ['qwer', 'qweq', 'qwew', 'qwea', 'qwqa', 'qwaq', 'qwaq', 'qwaa', 'qaaa', 'qqaa', 'qqqa', 'qqqw', 'qqqq', 'qwqw', 'qwwq', 'qwqw', 'qqqw']) == 3\n assert candidate(strs = ['abcdefgh', 'hgfedcba', 'abcdefgh', 'hgfedcba']) == 8\n assert candidate(strs = ['aabcc', 'abcab', 'acaba', 'cacab', 'ccaba']) == 0\n assert candidate(strs = ['baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab', 'baab']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'acdb', 'adbc', 'aebc', 'afdc', 'agdb', 'ahbc']) == 0\n assert candidate(strs = ['abcdef', 'bcdegh', 'cdefij']) == 0\n assert candidate(strs = ['abcd', 'abce', 'abcf', 'abcd']) == 1\n assert candidate(strs = ['abcdefg', 'bcdefga', 'cdefgab']) == 0\n assert candidate(strs = ['abcd', 'abce', 'abcf', 'abcg']) == 0\n assert candidate(strs = ['xyz', 'xyw', 'xyv', 'xyu', 'xyt', 'xys', 'xyr', 'xqq', 'xpp', 'xoo', 'xnn', 'xmm', 'xll', 'xkk', 'xjj', 'xii', 'xhh', 'xgg', 'xff', 'xee', 'xed', 'xec', 'xeb', 'xea']) == 2\n assert candidate(strs = ['abcd', 'azxy', 'abcy']) == 2\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg', 'efgh']) == 0\n assert candidate(strs = ['hello', 'hellp', 'helpp', 'helpq']) == 0\n assert candidate(strs = ['qpwoeiruty', 'asdfghjklz', 'xcvbnm']) == 4\n assert candidate(strs = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg', 'eeffgghh', 'ffgghhii', 'gghhiijj', 'hhiijjkk', 'iijjkkll', 'jjkkllmm', 'kkllmmnn', 'llmmnnoo', 'mmnnoopq', 'nnoopqrs', 'oopqrstu', 'pqrstuvw', 'qrstuvwx', 'rstuvwxy', 'stuvwxyz']) == 0\n assert candidate(strs = ['aaaa', 'aaba', 'aabb', 'abaa', 'abab', 'abbb', 'baaa', 'baab', 'baba', 'babb', 'bbaa', 'bbab', 'bbbb']) == 0\n assert candidate(strs = ['abc', 'bca', 'cab', 'bac', 'acb', 'cba']) == 3\n assert candidate(strs = ['dog', 'cat', 'bat']) == 2\n assert candidate(strs = ['aaaa', 'abaa', 'acaa', 'aada', 'abca', 'abda', 'acba', 'acda', 'aaca', 'aada', 'aaca', 'aaba', 'abba', 'abca', 'acca', 'adca', 'aada', 'aaca', 'aaca', 'aaba']) == 2\n assert candidate(strs = ['zebra', 'zorro', 'zebra']) == 3\n assert candidate(strs = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee']) == 0\n assert candidate(strs = ['pqrs', 'qrst', 'rstu', 'stuv']) == 0\n assert candidate(strs = ['ghi', 'ghi', 'ghi']) == 0\n assert candidate(strs = ['leetcode', 'lintcode', 'testcode']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'acbd']) == 0\n assert candidate(strs = ['abcd', 'bcad', 'cdab']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'abcf']) == 2\n assert candidate(strs = ['hello', 'helps', 'helpp']) == 1\n assert candidate(strs = ['xga', 'xfb', 'yfa']) == 1\n assert candidate(strs = ['aab', 'aac', 'aba', 'aca', 'baa', 'bac', 'bba', 'bbc']) == 0\n assert candidate(strs = ['fed', 'efd', 'eef']) == 2\n assert candidate(strs = ['cba', 'bca', 'abc']) == 2\n assert candidate(strs = ['abc', 'def', 'ghi']) == 0\n assert candidate(strs = ['xyz', 'xyw', 'xyv']) == 1\n assert candidate(strs = ['cba', 'bac', 'bca']) == 3\n assert candidate(strs = ['hello', 'helps', 'heroes']) == 0\n assert candidate(strs = ['zzz', 'aaa', 'zzz']) == 3\n assert candidate(strs = ['zyx', 'wvu', 'tsr']) == 3\n assert candidate(strs = ['zzz', 'zyz', 'zxz']) == 1\n assert candidate(strs = ['aab', 'aac', 'abc']) == 0\n assert candidate(strs = ['abcd', 'dcba', 'abdc']) == 4\n assert candidate(strs = ['zzz', 'zyx', 'zyy']) == 2\n assert candidate(strs = ['zzzz', 'zzyy', 'zyzy', 'zyyz']) == 3\n assert candidate(strs = ['aab', 'aac', 'aba', 'aca']) == 0\n assert candidate(strs = ['dog', 'cat', 'bat']) == 2\n assert candidate(strs = ['abcd', 'abdc', 'acdb']) == 0\n assert candidate(strs = ['zyxw', 'zyxv', 'zyxu']) == 1\n assert candidate(strs = ['fed', 'efd', 'gfd']) == 1\n assert candidate(strs = ['a', 'a', 'a', 'a']) == 0\n assert candidate(strs = ['ghi', 'jkl', 'mno']) == 0\n assert candidate(strs = ['zzz', 'zyx', 'zyw']) == 2\n assert candidate(strs = ['abc', 'acd', 'aab']) == 2\n assert candidate(strs = ['zzzz', 'zzzz', 'zzzz']) == 0\n assert candidate(strs = ['zzzz', 'zzyz', 'zzyy', 'zzyx']) == 2\n assert candidate(strs = ['aaa', 'bbb', 'aaa']) == 3\n assert candidate(strs = ['c', 'b', 'a']) == 1\n assert candidate(strs = ['abcd', 'dcba', 'abcd']) == 4\n assert candidate(strs = ['e', 'd', 'c', 'b', 'a']) == 1\n assert candidate(strs = ['abcd', 'abcf', 'abcg']) == 0\n assert candidate(strs = ['zzz', 'zyz', 'zyx']) == 2\n assert candidate(strs = ['apple', 'apricot', 'banana']) == 0\n assert candidate(strs = ['aabbbabbb', 'bbbaabaab', 'aabbbbaab', 'abbbababa', 'bbaaabbbb', 'bbabaabab', 'abababbaa']) == 9\n assert candidate(strs = ['abcd', 'dcba', 'mnop']) == 0\n assert candidate(strs = ['fed', 'cab', 'dba']) == 3\n assert candidate(strs = ['abcd', 'abcf', 'abce']) == 1\n assert candidate(strs = ['cba', 'fed', 'ihg']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'acbd', 'dacb']) == 0\n assert candidate(strs = ['zzz', 'zyz', 'yzz']) == 2\n assert candidate(strs = ['hello', 'helps', 'heaps']) == 1\n assert candidate(strs = ['zzz', 'zzz', 'zzz']) == 0\n assert candidate(strs = ['same', 'same', 'same']) == 0\n assert candidate(strs = ['abc', 'abc', 'abc']) == 0\n assert candidate(strs = ['xyp', 'ypp', 'xyp']) == 2\n assert candidate(strs = ['aab', 'aac', 'aab']) == 1\n assert candidate(strs = ['zz', 'zy', 'zx']) == 1\n assert candidate(strs = ['az', 'za', 'zz', 'aa']) == 2\n assert candidate(strs = ['abcd', 'acbd', 'dabc', 'dbca']) == 0\n assert candidate(strs = ['aaa', 'aab', 'aac']) == 0\n assert candidate(strs = ['cba', 'cab', 'bac']) == 2\n assert candidate(strs = ['hello', 'hilll', 'hillo']) == 0\n assert candidate(strs = ['rrjk', 'furt', 'guzm']) == 1\n assert candidate(strs = ['fed', 'dbc', 'cba']) == 3\n assert candidate(strs = ['a', 'b', 'c', 'd', 'e']) == 0\n assert candidate(strs = ['hello', 'helps', 'hero']) == 0\n assert candidate(strs = ['abc', 'acd', 'aec']) == 0\n assert candidate(strs = ['ghi', 'def', 'abc']) == 3\n assert candidate(strs = ['fedcba', 'fedcba', 'fedcba']) == 0\n assert candidate(strs = ['azx', 'byy', 'czz']) == 0\n assert candidate(strs = ['xc', 'yb', 'za']) == 0\n assert candidate(strs = ['abcd', 'abcc', 'abcb', 'abca']) == 1\n assert candidate(strs = ['xzxbxyzz', 'xzyxzzzx', 'xzyxzzyz', 'zyzzzxzx']) == 1\n assert candidate(strs = ['ca', 'bb', 'ac']) == 1\n assert candidate(strs = ['fed', 'efd', 'efd']) == 1\n assert candidate(strs = ['axb', 'ayb', 'azb']) == 0\n assert candidate(strs = ['pqrs', 'qrst', 'rstu']) == 0\n assert candidate(strs = ['hello', 'helli', 'hellp']) == 1\n assert candidate(strs = ['abc', 'acd', 'aab']) == 2\n assert candidate(strs = ['a', 'b', 'c']) == 0\n", "comparison": "exact"}, "public_tests": ["[\"ca\",\"bb\",\"ac\"]", "[\"xc\",\"yb\",\"za\"]", "[\"zyx\",\"wvu\",\"tsr\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().minDeletionSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:26+00:00", "tests_total": 205, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minDeletionSize(self, strs: list[str]) -> int:", "container": "Solution", "callable": "minDeletionSize", "parameters": [{"name": "strs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 956, "task_id": "tallest-billboard", "difficulty": "Hard", "problem_description": "You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.\n\nYou are given a collection of rods that can be welded together. For example, if you have rods of lengths 1, 2, and 3, you can weld them together to make a support of length 6.\n\nReturn the largest possible height of your billboard installation. If you cannot support the billboard, return 0.\n\nExample 1:\n\nInput: rods = [1,2,3,6]\nOutput: 6\nExplanation: We have two disjoint subsets {1,2,3} and {6}, which have the same sum = 6.\n\nExample 2:\n\nInput: rods = [1,2,3,4,5,6]\nOutput: 10\nExplanation: We have two disjoint subsets {2,3,5} and {4,6}, which have the same sum = 10.\n\nExample 3:\n\nInput: rods = [1,2]\nOutput: 0\nExplanation: The billboard cannot be supported, so we return 0.\n\nConstraints:\n\n- 1 <= rods.length <= 20\n- 1 <= rods[i] <= 1000\n- sum(rods[i]) <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rods = [10, 20, 30, 40]) == 50\n assert candidate(rods = [100, 200, 300]) == 300\n assert candidate(rods = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(rods = [10, 20, 30, 40, 50]) == 70\n assert candidate(rods = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 50\n assert candidate(rods = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(rods = [1, 3, 5, 7, 9]) == 12\n assert candidate(rods = [1]) == 0\n assert candidate(rods = [100, 200, 300, 400, 500]) == 700\n assert candidate(rods = [1, 2, 3, 6]) == 6\n assert candidate(rods = [10, 10, 10, 10, 10, 10, 10, 10]) == 40\n assert candidate(rods = [3, 9, 7, 3, 5, 1, 100]) == 14\n assert candidate(rods = [5, 5, 5, 5, 5, 5]) == 15\n assert candidate(rods = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(rods = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 105\n assert candidate(rods = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10000\n assert candidate(rods = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(rods = [1, 2]) == 0\n assert candidate(rods = [1, 2, 3, 4, 5, 6]) == 10\n assert candidate(rods = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 355\n assert candidate(rods = [10, 21, 32, 43, 54, 65, 76, 87, 98]) == 238\n assert candidate(rods = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 135\n assert candidate(rods = [100, 150, 200, 250, 300, 350, 400]) == 800\n assert candidate(rods = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 55\n assert candidate(rods = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 135\n assert candidate(rods = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == 2500\n assert candidate(rods = [8, 15, 30, 10, 20, 25, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170]) == 785\n assert candidate(rods = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1050\n assert candidate(rods = [12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 396\n assert candidate(rods = [100, 200, 300, 400, 500, 600]) == 1000\n assert candidate(rods = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 210\n assert candidate(rods = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 420\n assert candidate(rods = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285, 305, 325, 345, 365, 385]) == 1950\n assert candidate(rods = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 525\n assert candidate(rods = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 500\n assert candidate(rods = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 9895\n assert candidate(rods = [1, 2, 5, 10, 20, 25]) == 30\n assert candidate(rods = [100, 200, 150, 300, 400, 500, 600, 700]) == 1400\n assert candidate(rods = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 525\n assert candidate(rods = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 105\n assert candidate(rods = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(rods = [1, 10, 100, 1000, 10, 100, 1, 1000, 100, 10]) == 1111\n assert candidate(rods = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 600\n assert candidate(rods = [5, 10, 15, 20, 25, 30, 35, 40]) == 90\n assert candidate(rods = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219]) == 1145\n assert candidate(rods = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495]) == 1980\n assert candidate(rods = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519]) == 5095\n assert candidate(rods = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == 1350\n assert candidate(rods = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2700\n assert candidate(rods = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50]) == 135\n assert candidate(rods = [23, 37, 41, 53, 67, 89, 97, 101, 113, 131, 139, 149, 151, 163, 173, 181, 191, 193, 197, 199]) == 1244\n assert candidate(rods = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 270\n assert candidate(rods = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 112\n assert candidate(rods = [5, 15, 20, 25, 30, 35, 40]) == 85\n assert candidate(rods = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 30\n assert candidate(rods = [100, 200, 150, 50, 300, 400, 250, 100, 50, 150, 400, 300, 200, 100, 50, 150, 250, 300, 400, 100]) == 2000\n assert candidate(rods = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 195\n assert candidate(rods = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 1785\n assert candidate(rods = [50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 2575\n assert candidate(rods = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 195\n assert candidate(rods = [15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 300\n assert candidate(rods = [10, 15, 20, 25, 30, 35, 40, 45, 50]) == 135\n assert candidate(rods = [5, 5, 10, 10, 20, 20, 30, 30, 40, 40]) == 105\n assert candidate(rods = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2700\n assert candidate(rods = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 1155\n assert candidate(rods = [3, 9, 1, 4, 7, 2, 5, 6, 8, 10]) == 27\n assert candidate(rods = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 200\n assert candidate(rods = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 65\n assert candidate(rods = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == 390\n assert candidate(rods = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 270\n assert candidate(rods = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 30\n assert candidate(rods = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 318\n assert candidate(rods = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1050\n assert candidate(rods = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 75, 125, 150, 175, 225, 250, 275, 325, 350]) == 3750\n assert candidate(rods = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 1155\n assert candidate(rods = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 735\n assert candidate(rods = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600]) == 1950\n", "comparison": "exact"}, "public_tests": ["[1,2,3,6]", "[1,2,3,4,5,6]", "[1,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["rods"], "leetcode_dataset_entry_point": "Solution().tallestBillboard", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:28+00:00", "tests_total": 98, "tests_dropped": 21, "flags": [], "topic_tags": ["array", "dynamic-programming", "meet-in-the-middle", "knapsack-problem", "0-1-knapsack"]}, "language": "python", "interface": {"raw_signature": "def tallestBillboard(self, rods: list[int]) -> int:", "container": "Solution", "callable": "tallestBillboard", "parameters": [{"name": "rods", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 957, "task_id": "prison-cells-after-n-days", "difficulty": "Medium", "problem_description": "There are 8 prison cells in a row and each cell is either occupied or vacant.\n\nEach day, whether the cell is occupied or vacant changes according to the following rules:\n\n- If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.\n- Otherwise, it becomes vacant.\n\nNote that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.\n\nYou are given an integer array cells where cells[i] == 1 if the i^th cell is occupied and cells[i] == 0 if the i^th cell is vacant, and you are given an integer n.\n\nReturn the state of the prison after n days (i.e., n such changes described above).\n\nExample 1:\n\nInput: cells = [0,1,0,1,1,0,0,1], n = 7\nOutput: [0,0,1,1,0,0,0,0]\nExplanation: The following table summarizes the state of the prison on each day:\nDay 0: [0, 1, 0, 1, 1, 0, 0, 1]\nDay 1: [0, 1, 1, 0, 0, 0, 0, 0]\nDay 2: [0, 0, 0, 0, 1, 1, 1, 0]\nDay 3: [0, 1, 1, 0, 0, 1, 0, 0]\nDay 4: [0, 0, 0, 0, 0, 1, 0, 0]\nDay 5: [0, 1, 1, 1, 0, 1, 0, 0]\nDay 6: [0, 0, 1, 0, 1, 1, 0, 0]\nDay 7: [0, 0, 1, 1, 0, 0, 0, 0]\n\nExample 2:\n\nInput: cells = [1,0,0,1,0,0,1,0], n = 1000000000\nOutput: [0,0,1,1,1,1,1,0]\n\nConstraints:\n\n- cells.length == 8\n- cells[i] is either 0 or 1.\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cells = [0, 0, 0, 0, 0, 0, 0, 0],n = 5) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 1, 1, 1, 1, 1, 1, 1],n = 2) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [1, 1, 1, 1, 1, 1, 1, 1],n = 15) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [1, 0, 1, 0, 1, 0, 1, 0],n = 1) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 1, 1, 0, 1, 1, 1, 0],n = 2) == [0, 1, 0, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 0, 0, 0, 0, 0, 0, 0],n = 15) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 1, 0, 0, 1, 1],n = 15) == [0, 0, 1, 1, 0, 0, 0, 0]\n assert candidate(cells = [1, 0, 0, 1, 0, 0, 1, 0],n = 1000000000) == [0, 0, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 0, 0, 0, 0, 0, 0, 0],n = 2) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 1, 1, 0, 1, 1, 0, 0],n = 15) == [0, 0, 0, 1, 0, 0, 0, 0]\n assert candidate(cells = [1, 1, 1, 1, 1, 1, 1, 1],n = 3) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 0, 0, 0, 1, 0, 0],n = 5) == [0, 1, 1, 1, 0, 0, 0, 0]\n assert candidate(cells = [1, 1, 1, 1, 1, 1, 1, 1],n = 1) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 1, 1, 1, 1, 1, 1, 0],n = 14) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 1, 0, 1, 1, 0, 0, 1],n = 7) == [0, 0, 1, 1, 0, 0, 0, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 0, 0, 1],n = 30) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 1, 1, 0, 0, 1, 1, 0],n = 20) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 1, 0, 0, 1, 0],n = 28) == [0, 0, 1, 1, 1, 0, 0, 0]\n assert candidate(cells = [1, 1, 0, 1, 0, 1, 0, 1],n = 15) == [0, 0, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 1, 1, 0, 1, 1],n = 7) == [0, 0, 1, 0, 0, 1, 0, 0]\n assert candidate(cells = [0, 1, 1, 1, 1, 1, 1, 0],n = 1000) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(cells = [1, 1, 0, 0, 0, 0, 1, 1],n = 10) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 1, 0, 0, 0, 1, 1],n = 100) == [0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 0, 0, 1],n = 20) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(cells = [0, 1, 0, 0, 1, 0, 0, 1],n = 1000) == [0, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 1, 1, 1, 0, 1, 1, 0],n = 500) == [0, 1, 1, 0, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 1, 0, 0, 1, 0, 0],n = 1000000000) == [0, 0, 1, 0, 0, 1, 0, 0]\n assert candidate(cells = [0, 0, 1, 1, 1, 1, 0, 0],n = 50) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 0, 1, 1, 1, 1, 0],n = 10) == [0, 1, 1, 1, 1, 0, 1, 0]\n assert candidate(cells = [0, 1, 0, 0, 0, 1, 0, 1],n = 300) == [0, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(cells = [1, 0, 1, 1, 0, 0, 1, 0],n = 10) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [0, 0, 0, 1, 1, 1, 0, 0],n = 999999999) == [0, 1, 0, 1, 0, 1, 0, 0]\n assert candidate(cells = [1, 0, 0, 1, 1, 0, 0, 1],n = 1250) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [1, 1, 1, 0, 0, 1, 1, 1],n = 25) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(cells = [0, 1, 1, 1, 0, 1, 1, 0],n = 20) == [0, 0, 0, 0, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 1, 0, 0],n = 1000) == [0, 0, 0, 0, 0, 1, 0, 0]\n assert candidate(cells = [1, 0, 1, 0, 1, 0, 1, 0],n = 1000000000) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 0, 1, 0, 0, 1],n = 1000) == [0, 1, 0, 1, 1, 1, 1, 0]\n assert candidate(cells = [1, 1, 1, 1, 1, 1, 1, 1],n = 1000000) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [1, 1, 1, 0, 1, 0, 1, 1],n = 1000000000) == [0, 1, 1, 1, 0, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 1, 0, 1, 0, 1],n = 5) == [0, 1, 0, 0, 1, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 0, 1, 1, 0, 0],n = 500000000) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 30) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [1, 1, 0, 0, 1, 1, 0, 0],n = 67890) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 200) == [0, 1, 0, 0, 0, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 0, 0, 1],n = 100000000) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 1, 1, 1, 1, 1, 0],n = 100) == [0, 1, 0, 0, 1, 0, 0, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 50) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 0, 0, 0, 0, 0, 0, 0],n = 1000000000) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [0, 1, 1, 1, 1, 1, 1, 0],n = 10000) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 0, 0, 1],n = 1000000000) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(cells = [1, 1, 1, 0, 0, 0, 1, 1],n = 50) == [0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(cells = [1, 1, 1, 1, 0, 0, 0, 0],n = 50) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [0, 0, 1, 0, 0, 1, 0, 0],n = 30) == [0, 0, 1, 0, 0, 1, 0, 0]\n assert candidate(cells = [0, 0, 0, 1, 0, 0, 0, 0],n = 500) == [0, 1, 0, 0, 1, 1, 0, 0]\n assert candidate(cells = [1, 1, 0, 0, 0, 1, 1, 0],n = 15) == [0, 0, 0, 1, 0, 0, 0, 0]\n assert candidate(cells = [1, 1, 0, 0, 0, 1, 0, 0],n = 15) == [0, 0, 0, 1, 0, 1, 0, 0]\n assert candidate(cells = [1, 0, 1, 0, 0, 1, 0, 1],n = 1000000) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [0, 0, 1, 1, 1, 1, 1, 0],n = 50) == [0, 0, 1, 1, 1, 0, 0, 0]\n assert candidate(cells = [1, 1, 0, 1, 0, 1, 0, 1],n = 999999999) == [0, 1, 0, 0, 1, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 0, 1, 1, 0, 1],n = 15) == [0, 0, 0, 0, 0, 0, 1, 0]\n assert candidate(cells = [0, 0, 1, 1, 0, 0, 1, 1],n = 1000) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 1, 0, 1, 0, 1, 0],n = 78654321) == [0, 1, 0, 0, 0, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 0, 0, 1],n = 50) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 1, 1, 0, 1, 0, 1, 0],n = 1000000000) == [0, 0, 0, 1, 0, 0, 0, 0]\n assert candidate(cells = [1, 1, 0, 1, 0, 1, 0, 0],n = 200) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 1, 1, 0, 0, 1],n = 1000000000) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [0, 1, 0, 0, 1, 1, 0, 1],n = 10) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [0, 0, 1, 0, 1, 0, 1, 0],n = 1000000) == [0, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [1, 0, 0, 0, 0, 0, 0, 1],n = 100) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [1, 1, 1, 0, 0, 1, 1, 1],n = 15) == [0, 1, 0, 0, 0, 0, 1, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 14) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 1000) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [1, 0, 1, 0, 1, 0, 1, 0],n = 999999999) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [0, 1, 1, 0, 0, 1, 1, 0],n = 1000) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [0, 1, 0, 0, 1, 0, 1, 0],n = 14) == [0, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 1, 1, 1, 1, 0, 1],n = 10) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(cells = [1, 0, 1, 0, 0, 1, 0, 1],n = 60) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 0, 0, 1, 1, 0, 0, 0],n = 30) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 100) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [0, 1, 0, 1, 0, 1, 0, 1],n = 500000000) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [1, 0, 1, 1, 0, 0, 1, 0],n = 150) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [0, 0, 1, 1, 1, 1, 0, 0],n = 1500) == [0, 1, 0, 0, 0, 0, 1, 0]\n assert candidate(cells = [0, 0, 1, 1, 1, 1, 0, 0],n = 7) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [1, 0, 1, 1, 0, 1, 0, 1],n = 1000000000) == [0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(cells = [1, 0, 1, 1, 0, 0, 1, 1],n = 100000) == [0, 1, 1, 0, 1, 0, 1, 0]\n assert candidate(cells = [1, 1, 0, 0, 0, 0, 1, 1],n = 50) == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 1, 1, 0, 0, 1, 1],n = 30) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 0, 1, 1, 1, 1, 0, 0],n = 20) == [0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(cells = [0, 1, 1, 0, 1, 0, 1, 0],n = 1000000) == [0, 1, 1, 1, 1, 0, 0, 0]\n assert candidate(cells = [1, 1, 0, 1, 0, 1, 0, 1],n = 750) == [0, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [1, 1, 1, 0, 1, 0, 1, 1],n = 12) == [0, 0, 0, 0, 1, 0, 1, 0]\n assert candidate(cells = [1, 1, 1, 1, 1, 1, 1, 1],n = 100) == [0, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(cells = [1, 1, 0, 0, 1, 1, 0, 0],n = 20) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 0, 0, 1, 1, 0, 0, 1],n = 1000) == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(cells = [1, 1, 0, 0, 0, 0, 1, 1],n = 10000) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [1, 1, 0, 0, 0, 0, 0, 1],n = 8) == [0, 0, 1, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 0, 1, 1, 0, 0, 0],n = 500000000) == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(cells = [1, 0, 1, 1, 0, 1, 1, 1],n = 20) == [0, 0, 1, 1, 1, 0, 0, 0]\n assert candidate(cells = [0, 0, 1, 1, 0, 0, 1, 1],n = 100) == [0, 1, 1, 1, 1, 1, 1, 0]\n", "comparison": "exact"}, "public_tests": ["[0,1,0,1,1,0,0,1]\n7", "[1,0,0,1,0,0,1,0]\n1000000000"], "hints": [], "metadata": {"canonical_parameter_names": ["cells", "n"], "leetcode_dataset_entry_point": "Solution().prisonAfterNDays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:30+00:00", "tests_total": 102, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "math", "bit-manipulation", "floyds-cycle-finding-algorithm"]}, "language": "python", "interface": {"raw_signature": "def prisonAfterNDays(self, cells: list[int], n: int) -> list[int]:", "container": "Solution", "callable": "prisonAfterNDays", "parameters": [{"name": "cells", "type": "list[int]"}, {"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 959, "task_id": "regions-cut-by-slashes", "difficulty": "Medium", "problem_description": "An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\\', or blank space ' '. These characters divide the square into contiguous regions.\n\nGiven the grid grid represented as a string array, return the number of regions.\n\nNote that backslash characters are escaped, so a '\\' is represented as '\\\\'.\n\nExample 1:\n\nInput: grid = [\" /\",\"/ \"]\nOutput: 2\n\nExample 2:\n\nInput: grid = [\" /\",\" \"]\nOutput: 1\n\nExample 3:\n\nInput: grid = [\"/\\\\\",\"\\\\/\"]\nOutput: 5\nExplanation: Recall that because \\ characters are escaped, \"\\\\/\" refers to \\/, and \"/\\\\\" refers to /\\.\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 1 <= n <= 30\n- grid[i][j] is either '/', '\\', or ' '.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = ['///', '///', '///']) == 6\n assert candidate(grid = [' /', '/ ']) == 2\n assert candidate(grid = ['/\\\\', '\\\\/']) == 5\n assert candidate(grid = [' /', ' ']) == 1\n assert candidate(grid = [' ', ' ', ' ']) == 1\n assert candidate(grid = ['/\\\\/\\\\', '\\\\/\\\\/', '/\\\\/\\\\', '\\\\/\\\\/']) == 13\n assert candidate(grid = ['\\\\/\\\\', '\\\\/\\\\', '\\\\/\\\\']) == 6\n assert candidate(grid = ['/\\\\/', '\\\\/\\\\', '/\\\\/']) == 8\n assert candidate(grid = ['\\\\/\\\\', '/\\\\/', '\\\\/\\\\']) == 8\n assert candidate(grid = [' ', ' ', ' ', ' ', ' ']) == 1\n assert candidate(grid = [' ', ' ', ' ', ' ']) == 1\n assert candidate(grid = [' / ', '/\\\\/', ' / ']) == 4\n assert candidate(grid = ['/\\\\/', '/\\\\/', '/\\\\/']) == 6\n assert candidate(grid = [' ', ' ', ' ']) == 1\n assert candidate(grid = ['////', '////', '////', '////']) == 8\n assert candidate(grid = ['\\\\/\\\\', '\\\\/\\\\', '\\\\/\\\\']) == 6\n assert candidate(grid = ['///', '///', ' ']) == 3\n assert candidate(grid = ['/\\\\/', ' / ', '\\\\/\\\\']) == 5\n assert candidate(grid = ['\\\\/\\\\/', '\\\\/\\\\/', '\\\\/\\\\/', '\\\\/\\\\/']) == 8\n assert candidate(grid = ['/\\\\/', '\\\\/\\\\', '/\\\\/']) == 8\n", "comparison": "exact"}, "public_tests": ["[\" /\",\"/ \"]", "[\" /\",\" \"]", "[\"/\\\\\",\"\\\\/\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().regionsBySlashes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:50+00:00", "tests_total": 89, "tests_dropped": 69, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "depth-first-search", "breadth-first-search", "union-find", "matrix", "planar-graph"]}, "language": "python", "interface": {"raw_signature": "def regionsBySlashes(self, grid: list[str]) -> int:", "container": "Solution", "callable": "regionsBySlashes", "parameters": [{"name": "grid", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 960, "task_id": "delete-columns-to-make-sorted-iii", "difficulty": "Hard", "problem_description": "You are given an array of n strings strs, all of the same length.\n\nWe may choose any deletion indices, and we delete all the characters in those indices for each string.\n\nFor example, if we have strs = [\"abcdef\",\"uvwxyz\"] and deletion indices {0, 2, 3}, then the final array after deletions is [\"bef\", \"vyz\"].\n\nSuppose we chose a set of deletion indices answer such that after deletions, the final array has every string (row) in lexicographic order. (i.e., (strs[0][0] <= strs[0][1] <= ... <= strs[0][strs[0].length - 1]), and (strs[1][0] <= strs[1][1] <= ... <= strs[1][strs[1].length - 1]), and so on). Return the minimum possible value of answer.length.\n\nExample 1:\n\nInput: strs = [\"babca\",\"bbazb\"]\nOutput: 3\nExplanation: After deleting columns 0, 1, and 4, the final array is strs = [\"bc\", \"az\"].\nBoth these rows are individually in lexicographic order (ie. strs[0][0] <= strs[0][1] and strs[1][0] <= strs[1][1]).\nNote that strs[0] > strs[1] - the array strs is not necessarily in lexicographic order.\n\nExample 2:\n\nInput: strs = [\"edcba\"]\nOutput: 4\nExplanation: If we delete less than 4 columns, the only row will not be lexicographically sorted.\n\nExample 3:\n\nInput: strs = [\"ghi\",\"def\",\"abc\"]\nOutput: 0\nExplanation: All rows are already lexicographically sorted.\n\nConstraints:\n\n- n == strs.length\n- 1 <= n <= 100\n- 1 <= strs[i].length <= 100\n- strs[i] consists of lowercase English letters.\n\n-\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strs = ['zyx', 'zyx', 'zyx']) == 2\n assert candidate(strs = ['rrjk', 'furt', 'guzm']) == 2\n assert candidate(strs = ['axx', 'ggs', 'zzz']) == 0\n assert candidate(strs = ['ghi', 'def', 'abc']) == 0\n assert candidate(strs = ['aaa', 'bbb', 'ccc']) == 0\n assert candidate(strs = ['abc', 'bcd', 'cde']) == 0\n assert candidate(strs = ['abc', 'abc', 'abc']) == 0\n assert candidate(strs = ['a', 'b', 'c', 'd']) == 0\n assert candidate(strs = ['abcdef', 'uvwxyz']) == 0\n assert candidate(strs = ['zzz', 'aaa', 'zzz']) == 0\n assert candidate(strs = ['zyx', 'wvu', 'tsr']) == 2\n assert candidate(strs = ['edcba']) == 4\n assert candidate(strs = ['abcd', 'abdc', 'acdb']) == 1\n assert candidate(strs = ['abcd', 'dbca', 'adcb', 'cbad']) == 3\n assert candidate(strs = ['babca', 'bbazb']) == 3\n assert candidate(strs = ['a', 'b', 'c']) == 0\n assert candidate(strs = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd']) == 2\n assert candidate(strs = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 0\n assert candidate(strs = ['fedcb', 'edcba', 'dcbae', 'cbade', 'baced', 'acbed']) == 4\n assert candidate(strs = ['zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba']) == 25\n assert candidate(strs = ['abcd', 'adbc', 'bacd', 'bdac']) == 2\n assert candidate(strs = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 0\n assert candidate(strs = ['abacabad', 'babacaba', 'cacabada', 'dacabada']) == 5\n assert candidate(strs = ['abcdabcd', 'dcbaabcd', 'abcdabdc', 'abdcabcd', 'abcdcdab', 'cdabcdab', 'abcdabcd', 'cdababcd', 'abcdcdab', 'dcabcdab']) == 6\n assert candidate(strs = ['abcdefgh', 'hgfedcba', 'abcdefgh', 'hgfedcba', 'abcdefgh']) == 7\n assert candidate(strs = ['leetcode', 'leetcoed', 'leetcdeo', 'leetcodeo', 'leetcodeo', 'leetcodeo']) == 5\n assert candidate(strs = ['zyx', 'yxz', 'xyz']) == 2\n assert candidate(strs = ['aabbaa', 'abcabc', 'acbacb', 'bacbac', 'bbacab']) == 4\n assert candidate(strs = ['zzz', 'yyy', 'xxx', 'www', 'vvv', 'uuu']) == 0\n assert candidate(strs = ['abcdefgh', 'bcadegfh', 'cgdbefha', 'dgfbceha', 'egfdcbha', 'fgecadhb']) == 5\n assert candidate(strs = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklnmopqrstuvwxyz']) == 25\n assert candidate(strs = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh']) == 0\n assert candidate(strs = ['zabc', 'zcad', 'zdba', 'zeac', 'zfcd', 'zgda', 'zhec', 'zida', 'zjea', 'zkcf']) == 3\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm']) == 0\n assert candidate(strs = ['azazaz', 'bababa', 'cacaca', 'dadada', 'eaeaea']) == 3\n assert candidate(strs = ['abcdefg', 'bcefgij', 'acdfhij']) == 0\n assert candidate(strs = ['abcd', 'abdc', 'acdb', 'cadb', 'dabc']) == 2\n assert candidate(strs = ['xyz', 'zyx', 'wvu', 'tsr', 'qpo', 'nml', 'kji', 'hgf', 'edc', 'baa']) == 2\n assert candidate(strs = ['aeg', 'bdh', 'cfi', 'egj', 'fhk', 'gjl']) == 0\n assert candidate(strs = ['qrst', 'mnop', 'ijkl', 'efgh', 'abcd', 'mnop', 'qrst', 'efgh', 'ijkl', 'abcd', 'mnop', 'qrst', 'efgh', 'ijkl', 'abcd', 'mnop', 'qrst', 'efgh', 'ijkl', 'abcd']) == 0\n assert candidate(strs = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz']) == 0\n assert candidate(strs = ['zzzzzzzz', 'zzzzzzzy', 'zzzzzzzx', 'zzzzzzyx', 'zzzzzyxy', 'zzzzyxxy', 'zzzyxxyx', 'zzyxxyxy']) == 6\n assert candidate(strs = ['abcdefghij', 'abcdefghik', 'abcdefghij', 'abcdefghim', 'abcdefghin']) == 0\n assert candidate(strs = ['aabbcc', 'bbccaa', 'ccaabb', 'aabbbc']) == 4\n assert candidate(strs = ['abcdefg', 'bceghik', 'acegikm', 'adegimn']) == 0\n assert candidate(strs = ['qwertyuiop', 'asdfghjklz', 'zxcvbnmqwe', 'qwertyuiop', 'asdfghjklz']) == 7\n assert candidate(strs = ['qrst', 'rstu', 'stuv', 'tuvw', 'uvwx']) == 0\n assert candidate(strs = ['aabbccdd', 'bbaaccee', 'ccaabbee', 'ddeebbaa', 'eeccbbdd']) == 6\n assert candidate(strs = ['zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba']) == 25\n assert candidate(strs = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz']) == 0\n assert candidate(strs = ['qwerty', 'wertyq', 'ertyqw', 'rtyqwe', 'tyqwer', 'yqwret']) == 5\n assert candidate(strs = ['cba', 'bca', 'bac', 'acb']) == 2\n assert candidate(strs = ['aebf', 'accf', 'bdgf', 'cddg', 'defh', 'edgh', 'feih', 'gjih', 'hkji']) == 2\n assert candidate(strs = ['aabbcc', 'bbaacc', 'ccabba', 'aababc', 'bbacab', 'abcabc', 'cbaabc', 'abacba', 'bacabc', 'cababc']) == 4\n assert candidate(strs = ['zyxwvu', 'utsrqpon', 'mlkjihgf', 'edcba']) == 5\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']) == 0\n assert candidate(strs = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']) == 0\n assert candidate(strs = ['cba', 'daf', 'gee']) == 2\n assert candidate(strs = ['abc', 'bac', 'cab', 'bca', 'cab', 'cba']) == 2\n assert candidate(strs = ['leetcode', 'leetcede', 'leotcede']) == 5\n assert candidate(strs = ['zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba']) == 25\n assert candidate(strs = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz']) == 0\n assert candidate(strs = ['abcd', 'adcb', 'bacd', 'bdac', 'cabd', 'cdab', 'dcba', 'dcab', 'dabc', 'dacb']) == 3\n assert candidate(strs = ['zzzz', 'zzyz', 'zyyz', 'yzzz', 'yzyz', 'yyyz', 'yyyx', 'yyxx', 'yxxx', 'xxxx']) == 3\n assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == 2\n assert candidate(strs = ['aabbcc', 'bbaacc', 'bbacac', 'aabcbc', 'cababc', 'bcbacc']) == 3\n assert candidate(strs = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff']) == 0\n assert candidate(strs = ['xyz', 'zyx', 'yxz', 'xzy', 'yzx', 'zxy']) == 2\n assert candidate(strs = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl', 'fedcbazyxwvutsrqponmlkjihg']) == 25\n assert candidate(strs = ['mnopqr', 'opqrst', 'pqrstu', 'qrstuv']) == 0\n assert candidate(strs = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn']) == 0\n assert candidate(strs = ['abcd', 'dcba', 'abcd', 'dcba']) == 3\n assert candidate(strs = ['aabbcc', 'bbccaa', 'ccaabb', 'aabbbc', 'bbccaa', 'ccaabb', 'aabbbc']) == 4\n assert candidate(strs = ['abcdefg', 'gfedcba', 'bacdefg', 'ihgfedc', 'jklmnop']) == 6\n assert candidate(strs = ['pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 0\n assert candidate(strs = ['qpwoeiruty', 'qpwoeiruty', 'qpwoeiruty']) == 5\n assert candidate(strs = ['mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz']) == 2\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg']) == 0\n assert candidate(strs = ['aabbcc', 'abbccc', 'abcccc', 'bcccdd', 'cccddd', 'ccdddd', 'cddddd', 'dddddd']) == 0\n assert candidate(strs = ['aabbccddeeff', 'abcdefabcdef', 'fedcbafedcba', 'abcdefabcdef', 'aabbccddeeff']) == 10\n assert candidate(strs = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba']) == 9\n assert candidate(strs = ['zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcba']) == 25\n assert candidate(strs = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz']) == 0\n assert candidate(strs = ['aabbcc', 'bbccdd', 'ccddeeff', 'ddeeffgg']) == 0\n assert candidate(strs = ['abcdabcd', 'bcdbcdcd', 'cdcdcdcd', 'dcdcdcdc', 'efefefef', 'fefefefe', 'gfefefef', 'hfhfhfhf', 'ihihihih']) == 5\n assert candidate(strs = ['xyzuvw', 'wvuxyz', 'uvwxyx', 'vxyzwu', 'uzwvxy', 'zwxyuv', 'yxwvuz', 'zyxuvw', 'wvuzxy', 'uvwxyx', 'vxyzwu', 'uzwvxy', 'zwxyuv', 'yxwvuz', 'zyxuvw', 'wvuzxy', 'uvwxyx', 'vxyzwu', 'uzwvxy', 'zwxyuv', 'yxwvuz', 'zyxuvw']) == 5\n assert candidate(strs = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn']) == 0\n assert candidate(strs = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz']) == 0\n assert candidate(strs = ['ba', 'ab', 'ba', 'ab', 'ba', 'ab']) == 1\n assert candidate(strs = ['zab', 'bac', 'cab', 'dcb']) == 2\n assert candidate(strs = ['abcde', 'edcba', 'fghij', 'jihgf', 'klmno', 'onmlk']) == 4\n assert candidate(strs = ['abcdef', 'fedcba', 'dcbaef', 'bacfed', 'efabcd', 'fedcba']) == 5\n assert candidate(strs = ['aaaaaaaaaa', 'aabbaabbcc', 'aabbaabbcc', 'aabbaabbcc', 'aabbaabbcc', 'aabbaabbcc']) == 2\n assert candidate(strs = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd']) == 3\n assert candidate(strs = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff', 'ggggg', 'hhhhh', 'iiiii', 'jjjjj']) == 0\n assert candidate(strs = ['aabb', 'bbaa', 'abab', 'baba', 'abba', 'baab']) == 3\n assert candidate(strs = ['abcd', 'abdc', 'acbd', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == 3\n assert candidate(strs = ['abcde', 'edcba', 'fghij', 'jihgf', 'klmno', 'onmlk', 'pqrst', 'tsrqp', 'uvwxy', 'yxwvu', 'z', 'z', 'z', 'z', 'z']) == 4\n assert candidate(strs = ['abcd', 'efgh', 'ijkl', 'mnop']) == 0\n assert candidate(strs = ['abcdefg', 'gfedcba', 'hijklmn', 'nmolkji', 'opqrstu', 'utsrqpo']) == 6\n", "comparison": "exact"}, "public_tests": ["[\"babca\",\"bbazb\"]", "[\"edcba\"]", "[\"ghi\",\"def\",\"abc\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().minDeletionSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:52+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minDeletionSize(self, strs: list[str]) -> int:", "container": "Solution", "callable": "minDeletionSize", "parameters": [{"name": "strs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 961, "task_id": "n-repeated-element-in-size-2n-array", "difficulty": "Easy", "problem_description": "You are given an integer array nums with the following properties:\n\n- nums.length == 2 * n.\n- nums contains n + 1 unique values, n of which occur exactly once in the array.\n- Exactly one element of nums is repeated n times.\n\nReturn the element that is repeated n times.\n\nExample 1:\n\nInput: nums = [1,2,3,3]\nOutput: 3\n\nExample 2:\n\nInput: nums = [2,1,2,5,3,2]\nOutput: 2\n\nExample 3:\n\nInput: nums = [5,1,5,2,5,3,5,4]\nOutput: 5\n\nConstraints:\n\n- 2 <= n <= 5000\n- nums.length == 2 * n\n- 0 <= nums[i] <= 10^4\n- nums contains n + 1 unique elements and one of them is repeated exactly n times.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 10, 40, 50]) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9]) == 9\n assert candidate(nums = [21, 22, 23, 24, 21, 25, 26, 27]) == 21\n assert candidate(nums = [14, 15, 16, 17, 18, 19, 14, 20]) == 14\n assert candidate(nums = [35, 36, 37, 38, 39, 40, 35, 41]) == 35\n assert candidate(nums = [100, 200, 300, 400, 100, 500]) == 100\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 999]) == 999\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7]) == 1\n assert candidate(nums = [8, 9, 10, 8, 11, 12, 13, 8]) == 8\n assert candidate(nums = [100, 200, 100, 300, 400, 500, 600, 700]) == 100\n assert candidate(nums = [6, 1, 6, 3, 4, 5, 6, 7]) == 6\n assert candidate(nums = [0, 1, 0, 2, 3, 4]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 100, 700]) == 100\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4]) == 5\n assert candidate(nums = [1234, 5678, 9101, 1112, 1314, 1516, 1234, 1718]) == 1234\n assert candidate(nums = [0, 1, 0, 2]) == 0\n assert candidate(nums = [2, 1, 2, 5, 3, 2]) == 2\n assert candidate(nums = [28, 29, 30, 31, 32, 28, 33, 34]) == 28\n assert candidate(nums = [42, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 42\n assert candidate(nums = [1, 2, 3, 3]) == 3\n assert candidate(nums = [7, 8, 9, 7, 10, 11, 12, 7]) == 7\n assert candidate(nums = [8, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 8\n assert candidate(nums = [7, 8, 9, 7, 10, 11, 12, 13]) == 7\n assert candidate(nums = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2000]) == 2000\n assert candidate(nums = [456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 456]) == 456\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 7]) == 7\n assert candidate(nums = [1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1234]) == 1234\n assert candidate(nums = [9876, 5432, 1234, 8765, 4321, 1234, 9876, 5432, 8765, 4321, 9876, 1234]) == 1234\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 2000, 5000]) == 2000\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 5000]) == 5000\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5000]) == 5000\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == 1000\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1000]) == 1000\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1111, 1000, 9999]) == 1111\n assert candidate(nums = [1234, 5678, 9101, 1121, 1341, 1561, 1781, 1901, 2121, 2341, 2561, 1234]) == 1234\n assert candidate(nums = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 300, 330, 331, 332, 333, 334]) == 300\n assert candidate(nums = [2500, 2499, 2498, 2497, 2496, 2495, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2500]) == 2500\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 900]) == 900\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5000, 5016, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029]) == 5000\n assert candidate(nums = [2499, 2498, 2497, 2496, 2495, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2499]) == 2499\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 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, 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]) == None\n assert candidate(nums = [104, 204, 304, 404, 504, 604, 704, 804, 904, 1004, 1104, 1204, 1304, 1404, 1504, 1604, 1704, 1804, 1904, 2004, 2104, 2204, 2304, 2404, 2504, 104, 2604, 2704, 2804, 2904, 3004, 3104, 3204, 3304, 3404, 3504, 3604, 3704, 3804, 3904, 4004, 4104, 4204, 4304, 4404, 4504, 4604, 4704, 4804, 4904, 5004]) == 104\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9999]) == 9999\n assert candidate(nums = [4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970, 4970]) == 4970\n assert candidate(nums = [5000, 5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986]) == 5000\n assert candidate(nums = [42, 43, 44, 45, 46, 47, 48, 49, 50, 42, 51, 52, 53, 54, 55, 56]) == 42\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 100, 114]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 100]) == 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, 521, 522, 523, 524, 525, 526, 527, 528, 529, 500]) == 500\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 7]) == 7\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9980]) == 9980\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 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\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 100]) == 100\n assert candidate(nums = [2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2500]) == 2500\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 100]) == 100\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 5000]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 1\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 500]) == 500\n assert candidate(nums = [9999, 0, 9998, 1, 9997, 2, 9996, 3, 9995, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 9999]) == 9999\n assert candidate(nums = [4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4000]) == 4000\n assert candidate(nums = [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, 9999]) == 9999\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 20]) == 20\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, 530, 531, 532, 500]) == 500\n assert candidate(nums = [4999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 4999]) == 4999\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 5000]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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\n assert candidate(nums = [4500, 4501, 4502, 4503, 4504, 4505, 4506, 4500, 4507, 4508]) == 4500\n assert candidate(nums = [4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4999]) == 4999\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1004, 1010]) == 1004\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 10000]) == 10000\n assert candidate(nums = [1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1500]) == 1500\n assert candidate(nums = [2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2500]) == 2500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 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\n assert candidate(nums = [2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2500, 2515]) == 2500\n assert candidate(nums = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 42]) == 42\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 100]) == 100\n assert candidate(nums = [42, 42, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]) == 42\n assert candidate(nums = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 42, 54, 55, 56]) == 42\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, 0]) == 0\n assert candidate(nums = [1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1500, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539]) == 1500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 1\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 1000]) == 1000\n assert candidate(nums = [3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3000]) == 3000\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, 100]) == 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, 10]) == 10\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9999]) == 9999\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5000, 5020, 5021, 5022, 5023, 5024]) == 5000\n assert candidate(nums = [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2000, 2013, 2014, 2015, 2016, 2017, 2018]) == 2000\n", "comparison": "exact"}, "public_tests": ["[1,2,3,3]", "[2,1,2,5,3,2]", "[5,1,5,2,5,3,5,4]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().repeatedNTimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:54+00:00", "tests_total": 93, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "pigeonhole-principle"]}, "language": "python", "interface": {"raw_signature": "def repeatedNTimes(self, nums: list[int]) -> int:", "container": "Solution", "callable": "repeatedNTimes", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 962, "task_id": "maximum-width-ramp", "difficulty": "Medium", "problem_description": "A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i.\n\nGiven an integer array nums, return the maximum width of a ramp in nums. If there is no ramp in nums, return 0.\n\nExample 1:\n\nInput: nums = [6,0,8,2,1,5]\nOutput: 4\nExplanation: The maximum width ramp is achieved at (i, j) = (1, 5): nums[1] = 0 and nums[5] = 5.\n\nExample 2:\n\nInput: nums = [9,8,1,0,1,9,4,0,4,1]\nOutput: 7\nExplanation: The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] = 1.\n\nConstraints:\n\n- 2 <= nums.length <= 5 * 10^4\n- 0 <= nums[i] <= 5 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 2, 3, 3, 7, 5, 2, 4]) == 9\n assert candidate(nums = [1, 5, 2, 5, 6, 3, 5, 4]) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [1, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 5, 2, 5, 6, 6, 1, 3, 2, 5]) == 9\n assert candidate(nums = [25, 20, 15, 11, 10, 9, 7, 6, 3, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 4\n assert candidate(nums = [1, 2, 9, 10, 1, 3, 5, 6, 4, 8, 7]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [6, 0, 8, 2, 1, 5]) == 4\n assert candidate(nums = [0, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [6, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums = [8, 1, 5, 2, 3, 4, 8, 7, 2]) == 7\n assert candidate(nums = [9, 8, 1, 0, 1, 9, 4, 0, 4, 1]) == 7\n assert candidate(nums = [1, 3, 6, 7, 9, 10, 11, 15, 20, 25]) == 9\n assert candidate(nums = [1, 2, 3, 2, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 19\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == 19\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 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]) == 19\n assert candidate(nums = [45, 23, 11, 33, 22, 55, 44, 33, 22, 11, 77, 88, 99, 66, 55]) == 14\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 20\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]) == 25\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]) == 50\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 19\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 19\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50000]) == 20\n assert candidate(nums = [0, 10000, 0, 9999, 0, 9998, 0, 9997, 0, 9996, 0, 9995, 0, 9994, 0, 9993, 0, 9992, 0, 9991]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 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]) == 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]) == 19\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == 18\n assert candidate(nums = [4, 8, 6, 5, 1, 0, 5, 9, 10, 11, 12, 13, 14, 15]) == 13\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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]) == 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]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 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, 0]) == 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, 16, 17, 18, 19, 20]) == 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, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 29\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 = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 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]) == 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, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 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]) == 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, 1]) == 20\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\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]) == 29\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 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, 0]) == 29\n assert candidate(nums = [45000, 44999, 44998, 44997, 44996, 44995, 44994, 44993, 44992, 44991, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(nums = [1, 3, 2, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, 11, 9, 12, 10]) == 20\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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, 1]) == 20\n assert candidate(nums = [100, 0, 99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9]) == 18\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 0\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981, 0]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 19\n", "comparison": "exact"}, "public_tests": ["[6,0,8,2,1,5]", "[9,8,1,0,1,9,4,0,4,1]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxWidthRamp", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:56+00:00", "tests_total": 69, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "stack", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def maxWidthRamp(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxWidthRamp", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 963, "task_id": "minimum-area-rectangle-ii", "difficulty": "Medium", "problem_description": "You are given an array of points in the X-Y plane points where points[i] = [x_i, y_i].\n\nReturn the minimum area of any rectangle formed from these points, with sides not necessarily parallel to the X and Y axes. If there is not any such rectangle, return 0.\n\nAnswers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: points = [[1,2],[2,1],[1,0],[0,1]]\nOutput: 2.00000\nExplanation: The minimum area rectangle occurs at [1,2],[2,1],[1,0],[0,1], with an area of 2.\n\nExample 2:\n\nInput: points = [[0,1],[2,1],[1,1],[1,0],[2,0]]\nOutput: 1.00000\nExplanation: The minimum area rectangle occurs at [1,0],[1,1],[2,1],[2,0], with an area of 1.\n\nExample 3:\n\nInput: points = [[0,3],[1,2],[3,1],[1,3],[2,1]]\nOutput: 0\nExplanation: There is no possible rectangle to form from these points.\n\nConstraints:\n\n- 1 <= points.length <= 50\n- points[i].length == 2\n- 0 <= x_i, y_i <= 4 * 10^4\n- All the given points are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(points=[[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 1], [1, 2]]), 1.0)\n assert answers_match(candidate(points=[[4, 10], [2, 8], [5, 3], [3, 0], [0, 5], [7, 1], [1, 2], [2, 6], [8, 0], [9, 7]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]), 0)\n assert answers_match(candidate(points=[[0, 1], [2, 1], [1, 1], [1, 0], [2, 0]]), 1.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 3], [3, 1], [3, 3], [2, 2]]), 4.0)\n assert answers_match(candidate(points=[[0, 3], [1, 2], [3, 1], [1, 3], [2, 1]]), 0)\n assert answers_match(candidate(points=[[1, 2], [2, 1], [1, 0], [0, 1]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[0, 0], [4, 0], [0, 4], [4, 4], [1, 2], [3, 2], [2, 1], [2, 3], [1, 3], [3, 1], [2, 2], [0, 2], [2, 0], [4, 2], [2, 4]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [0, 10], [10, 10], [2, 2], [8, 2], [2, 8], [8, 8], [1, 1], [9, 1], [1, 9], [9, 9], [5, 5], [5, 6], [6, 5], [6, 6]]), 1.0)\n assert answers_match(candidate(points=[[1, 2], [2, 1], [1, 0], [0, 1], [5, 6], [6, 5], [5, 4], [4, 5], [3, 3]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [2, 3], [4, 5], [6, 7], [8, 9]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [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.0)\n assert answers_match(candidate(points=[[2, 4], [4, 2], [4, 6], [6, 4], [8, 8], [6, 8], [8, 6], [10, 10], [8, 10], [10, 8], [12, 12], [10, 12], [12, 10], [14, 14], [12, 14], [14, 12]]), 4.0)\n assert answers_match(candidate(points=[[0, 0], [10, 10], [20, 20], [10, 20], [20, 10], [5, 5], [15, 15], [25, 25], [15, 25], [25, 15]]), 50.00000000000001)\n assert answers_match(candidate(points=[[0, 0], [10, 10], [5, 5], [15, 15], [20, 20], [10, 0], [20, 10], [5, 15]]), 100.00000000000001)\n assert answers_match(candidate(points=[[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [30, 40], [40, 30], [40, 40], [25, 25]]), 100.0)\n assert answers_match(candidate(points=[[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [3, 1], [1, 3], [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]]), 1.0)\n assert answers_match(candidate(points=[[1, 2], [2, 1], [1, 0], [0, 1], [4, 5], [5, 4], [4, 3], [3, 4]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[0, 1], [1, 0], [2, 1], [1, 2], [3, 2], [2, 3], [4, 3], [3, 4], [5, 4], [4, 5]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]]), 1.0)\n assert answers_match(candidate(points=[[5, 5], [5, 6], [6, 5], [6, 6], [8, 8], [8, 9], [9, 8], [9, 9], [10, 10], [10, 11], [11, 10], [11, 11]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[0, 0], [0, 10], [10, 0], [10, 10], [5, 5], [5, 15], [15, 5], [15, 15], [7, 7], [7, 13], [13, 7], [13, 13]]), 36.0)\n assert answers_match(candidate(points=[[0, 1], [1, 0], [2, 1], [1, 2], [0, 3], [1, 4], [2, 3], [3, 2], [3, 1], [4, 0]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 1], [5, 5], [1, 5], [5, 1], [2, 2], [4, 4], [2, 4], [4, 2], [3, 3], [3, 5], [5, 3], [1, 3]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 1], [3, 1], [1, 3], [3, 3], [2, 2], [2, 4], [4, 2], [4, 4], [1, 2], [2, 1], [3, 2], [2, 3]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [1, 2], [2, 1], [8, 8]]), 0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [4, 4], [4, 0], [0, 4], [1, 1], [3, 3], [3, 1], [1, 3]]), 4.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 1], [4, 3], [6, 5], [8, 7], [10, 9]]), 4.000000000000001)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [3, 1], [4, 3], [5, 1], [6, 3], [7, 1]]), 0)\n assert answers_match(candidate(points=[[1, 2], [2, 1], [1, 0], [0, 1], [3, 4], [4, 3], [3, 2], [2, 3]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 9], [9, 1]]), 0)\n assert answers_match(candidate(points=[[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]), 0)\n assert answers_match(candidate(points=[[0, 0], [4, 0], [0, 4], [4, 4], [1, 1], [2, 2], [3, 3], [1, 3], [3, 1]]), 4.0)\n assert answers_match(candidate(points=[[1, 1], [4, 5], [7, 9], [10, 13], [2, 3], [5, 7], [8, 11], [11, 15]]), 0)\n assert answers_match(candidate(points=[[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18]]), 0)\n assert answers_match(candidate(points=[[0, 0], [0, 5], [5, 0], [5, 5], [1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [2, 3], [3, 2], [3, 3], [6, 6], [6, 7], [7, 6], [7, 7]]), 1.0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [0, 1], [1, 0], [2, 1], [1, 2], [3, 2], [2, 3]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [3, 3], [4, 4], [2, 2], [5, 5], [6, 6], [7, 7]]), 0)\n assert answers_match(candidate(points=[[0, 0], [0, 4], [4, 0], [4, 4], [1, 1], [1, 3], [3, 1], [3, 3], [2, 2]]), 4.0)\n assert answers_match(candidate(points=[[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3], [2, 3], [3, 2], [5, 5], [5, 8], [8, 5], [8, 8], [6, 6], [7, 7], [6, 7], [7, 6]]), 1.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]), 0)\n assert answers_match(candidate(points=[[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [15, 25], [25, 15], [25, 25], [12, 12], [12, 18], [18, 12], [18, 18], [14, 14], [14, 16], [16, 14], [16, 16]]), 4.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [1, 4], [4, 1], [2, 3], [3, 2], [5, 5], [5, 6], [6, 5], [6, 6], [1, 5], [5, 1], [3, 6], [6, 3]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [4, 4], [4, 0], [0, 4], [1, 1], [3, 3], [2, 2], [2, 0], [0, 2], [2, 4], [4, 2], [3, 1], [1, 3]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [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.0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [3, 3], [3, 2], [2, 3], [4, 4], [4, 3], [3, 4]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]), 1.0)\n assert answers_match(candidate(points=[[5, 5], [7, 7], [8, 9], [6, 10], [2, 2], [4, 4], [3, 3], [1, 1]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [0, 1], [1, 2], [2, 3], [3, 4], [0, 2], [1, 3], [2, 4], [3, 5], [0, 3], [1, 4], [2, 5], [3, 6]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [5, 0], [10, 5], [15, 10], [20, 15], [25, 20]]), 0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 2], [4, 3], [2, 4], [3, 5], [4, 4], [5, 5]]), 2.0)\n assert answers_match(candidate(points=[[0, 0], [0, 5], [5, 0], [5, 5], [1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [2, 3], [3, 2], [3, 3]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [3, 1], [1, 3], [3, 3], [2, 2], [4, 2], [2, 4], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [0, 5], [5, 0], [5, 5], [1, 2], [2, 1], [4, 3], [3, 4], [2, 3], [3, 2], [1, 4], [4, 1]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]), 1.0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 3], [3, 2], [2, 1], [1, 0], [0, 1]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [2, 3], [4, 5], [6, 7], [8, 9], [3, 5], [5, 7], [7, 9], [9, 11]]), 0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [1, 3], [3, 1]]), 4.000000000000001)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 1], [1, 2], [3, 3], [3, 2], [2, 3]]), 1.0)\n assert answers_match(candidate(points=[[1, 0], [0, 1], [1, 2], [2, 1], [2, 2], [0, 2], [2, 0], [0, 0]]), 2.0)\n assert answers_match(candidate(points=[[10, 10], [11, 11], [12, 10], [11, 9], [14, 14], [15, 15], [16, 14], [15, 13]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[0, 0], [4, 4], [4, 0], [0, 4], [2, 2], [1, 1], [3, 3], [3, 1], [1, 3]]), 4.0)\n assert answers_match(candidate(points=[[0, 0], [4, 0], [4, 4], [0, 4], [1, 1], [3, 1], [3, 3], [1, 3], [2, 2], [5, 5], [9, 5], [9, 9], [5, 9], [7, 7], [7, 3], [3, 7], [10, 10], [14, 10], [14, 14], [10, 14]]), 4.0)\n assert answers_match(candidate(points=[[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]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[0, 0], [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]]), 1.0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [10, 20], [20, 10], [15, 15], [15, 25], [25, 15], [25, 25]]), 50.00000000000001)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [3, 1], [4, 3], [5, 1], [6, 3], [1, 5], [2, 7], [3, 5], [4, 7], [5, 5], [6, 7]]), 8.0)\n assert answers_match(candidate(points=[[0, 0], [4, 0], [2, 2], [0, 4], [4, 4], [2, 6], [6, 2], [6, 6], [1, 1], [3, 3], [5, 5], [7, 7]]), 8.000000000000002)\n assert answers_match(candidate(points=[[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [2, 3], [3, 2], [3, 3], [5, 5], [5, 6], [6, 5], [6, 6]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4], [2, 3], [3, 2], [3, 4], [4, 3]]), 0.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [6, 6], [7, 7], [4, 4]]), 100.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [0, 0], [0, 3], [3, 0]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 0], [1, 2], [2, 2], [0, 2], [2, 1]]), 1.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [0, 1], [1, 0]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [3, 3], [4, 3], [3, 4], [4, 4], [5, 3], [5, 4], [6, 3], [6, 4]]), 1.0)\n assert answers_match(candidate(points=[[5, 5], [6, 5], [5, 6], [6, 6], [7, 7], [8, 7], [7, 8], [8, 8], [9, 9]]), 1.0)\n assert answers_match(candidate(points=[[5, 5], [10, 10], [15, 15], [20, 20], [7, 7], [12, 12], [17, 17], [22, 22]]), 0)\n assert answers_match(candidate(points=[[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [2, 1], [3, 2], [4, 3], [1, 3], [2, 4], [3, 5]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]), 0)\n assert answers_match(candidate(points=[[0, 0], [2, 0], [2, 2], [0, 2], [1, 1], [3, 3], [4, 4], [5, 5]]), 4.0)\n assert answers_match(candidate(points=[[0, 0], [4, 4], [4, 0], [0, 4], [1, 2], [3, 2], [2, 1], [2, 3]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 4], [4, 3], [3, 2], [2, 1]]), 2.0000000000000004)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), 1.0)\n assert answers_match(candidate(points=[[1, 1], [1, 3], [3, 1], [3, 3], [2, 2], [4, 4], [4, 2], [2, 4], [5, 5], [5, 7], [7, 5], [7, 7], [6, 6], [6, 8], [8, 6], [8, 8]]), 2.0000000000000004)\n", "comparison": "float"}, "public_tests": ["[[1,2],[2,1],[1,0],[0,1]]", "[[0,1],[2,1],[1,1],[1,0],[2,0]]", "[[0,3],[1,2],[3,1],[1,3],[2,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minAreaFreeRect", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:05:58+00:00", "tests_total": 100, "tests_dropped": 1, "flags": ["decimal_answer", "has_images"], "topic_tags": ["array", "hash-table", "math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def minAreaFreeRect(self, points: list[list[int]]) -> float:", "container": "Solution", "callable": "minAreaFreeRect", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 964, "task_id": "least-operators-to-express-number", "difficulty": "Hard", "problem_description": "Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /). For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 which is a value of 3.\n\nWhen writing such an expression, we adhere to the following conventions:\n\n- The division operator (/) returns rational numbers.\n- There are no parentheses placed anywhere.\n- We use the usual order of operations: multiplication and division happen before addition and subtraction.\n- It is not allowed to use the unary negation operator (-). For example, \"x - x\" is a valid expression as it only uses subtraction, but \"-x + x\" is not because it uses negation.\n\nWe would like to write an expression with the least number of operators such that the expression equals the given target. Return the least number of operators used.\n\nExample 1:\n\nInput: x = 3, target = 19\nOutput: 5\nExplanation: 3 * 3 + 3 * 3 + 3 / 3.\nThe expression contains 5 operations.\n\nExample 2:\n\nInput: x = 5, target = 501\nOutput: 8\nExplanation: 5 * 5 * 5 * 5 - 5 * 5 * 5 + 5 / 5.\nThe expression contains 8 operations.\n\nExample 3:\n\nInput: x = 100, target = 100000000\nOutput: 3\nExplanation: 100 * 100 * 100 * 100.\nThe expression contains 3 operations.\n\nConstraints:\n\n- 2 <= x <= 100\n- 1 <= target <= 2 * 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 2,target = 123456) == 44\n assert candidate(x = 2,target = 3) == 2\n assert candidate(x = 3,target = 81) == 3\n assert candidate(x = 10,target = 1001) == 4\n assert candidate(x = 2,target = 10) == 3\n assert candidate(x = 2,target = 100) == 12\n assert candidate(x = 4,target = 30) == 7\n assert candidate(x = 5,target = 1) == 1\n assert candidate(x = 5,target = 501) == 8\n assert candidate(x = 4,target = 63) == 4\n assert candidate(x = 10,target = 10000) == 3\n assert candidate(x = 2,target = 127) == 8\n assert candidate(x = 3,target = 19) == 5\n assert candidate(x = 50,target = 1250) == 24\n assert candidate(x = 7,target = 49) == 1\n assert candidate(x = 50,target = 2500) == 1\n assert candidate(x = 100,target = 100000000) == 3\n assert candidate(x = 10,target = 1000) == 2\n assert candidate(x = 10,target = 1000000) == 5\n assert candidate(x = 3,target = 1) == 1\n assert candidate(x = 7,target = 300) == 7\n assert candidate(x = 37,target = 1874161) == 3\n assert candidate(x = 13,target = 31254) == 17\n assert candidate(x = 7,target = 100) == 7\n assert candidate(x = 3,target = 1234567) == 66\n assert candidate(x = 6,target = 999999) == 73\n assert candidate(x = 4,target = 1000000) == 35\n assert candidate(x = 6,target = 7776) == 4\n assert candidate(x = 41,target = 2825761) == 3\n assert candidate(x = 7,target = 343) == 2\n assert candidate(x = 13,target = 169) == 1\n assert candidate(x = 8,target = 512) == 2\n assert candidate(x = 4,target = 1023) == 6\n assert candidate(x = 19,target = 361) == 1\n assert candidate(x = 97,target = 22138067) == 231\n assert candidate(x = 9,target = 6561) == 3\n assert candidate(x = 23,target = 123456) == 60\n assert candidate(x = 25,target = 625) == 1\n assert candidate(x = 7,target = 10000000) == 50\n assert candidate(x = 5,target = 243) == 10\n assert candidate(x = 6,target = 216000) == 32\n assert candidate(x = 20,target = 87654321) == 95\n assert candidate(x = 8,target = 200000) == 28\n assert candidate(x = 25,target = 10000000) == 38\n assert candidate(x = 7,target = 3430) == 12\n assert candidate(x = 8,target = 2048) == 11\n assert candidate(x = 11,target = 1771561) == 5\n assert candidate(x = 4,target = 65536) == 7\n assert candidate(x = 4,target = 65535) == 9\n assert candidate(x = 99,target = 11032558) == 144\n assert candidate(x = 11,target = 121121) == 25\n assert candidate(x = 5,target = 123456) == 45\n assert candidate(x = 10,target = 99999) == 6\n assert candidate(x = 15,target = 1000000) == 61\n assert candidate(x = 30,target = 299999) == 50\n assert candidate(x = 8,target = 32768) == 4\n assert candidate(x = 83,target = 44349085) == 172\n assert candidate(x = 12,target = 1728) == 2\n assert candidate(x = 20,target = 999999) == 40\n assert candidate(x = 2,target = 1048575) == 21\n assert candidate(x = 4,target = 100000000) == 86\n assert candidate(x = 8,target = 5000000) == 60\n assert candidate(x = 17,target = 1444) == 11\n assert candidate(x = 17,target = 2458624) == 72\n assert candidate(x = 17,target = 24137569) == 5\n assert candidate(x = 11,target = 146410) == 8\n assert candidate(x = 29,target = 87654321) == 78\n assert candidate(x = 9,target = 98765) == 34\n assert candidate(x = 7,target = 123456) == 31\n assert candidate(x = 3,target = 1000) == 15\n assert candidate(x = 73,target = 66560103) == 142\n assert candidate(x = 9,target = 81000) == 27\n assert candidate(x = 5,target = 999) == 14\n assert candidate(x = 5,target = 12345) == 16\n assert candidate(x = 25,target = 97654321) == 65\n assert candidate(x = 4,target = 1024) == 4\n assert candidate(x = 8,target = 5000) == 14\n assert candidate(x = 9,target = 8100) == 11\n assert candidate(x = 7,target = 4913) == 15\n assert candidate(x = 25,target = 9765625) == 4\n assert candidate(x = 19,target = 987654) == 65\n assert candidate(x = 6,target = 7777) == 6\n assert candidate(x = 5,target = 123) == 6\n assert candidate(x = 79,target = 55454594) == 233\n assert candidate(x = 19,target = 99999) == 35\n assert candidate(x = 20,target = 200000) == 18\n assert candidate(x = 8,target = 56789) == 31\n assert candidate(x = 6,target = 129600) == 30\n assert candidate(x = 9,target = 87654321) == 59\n assert candidate(x = 3,target = 100000) == 52\n assert candidate(x = 15,target = 123456789) == 99\n assert candidate(x = 13,target = 16913) == 27\n assert candidate(x = 3,target = 4096) == 25\n assert candidate(x = 23,target = 279841) == 3\n assert candidate(x = 9,target = 88888888) == 81\n assert candidate(x = 3,target = 98765) == 41\n assert candidate(x = 9,target = 59049) == 4\n assert candidate(x = 13,target = 16901) == 28\n assert candidate(x = 10,target = 9999999) == 8\n assert candidate(x = 5,target = 100000) == 22\n assert candidate(x = 7,target = 200) == 14\n assert candidate(x = 19,target = 2476099) == 4\n assert candidate(x = 7,target = 499) == 13\n assert candidate(x = 3,target = 40) == 7\n assert candidate(x = 6,target = 46655) == 7\n assert candidate(x = 15,target = 10000000) == 65\n assert candidate(x = 9,target = 88888) == 48\n assert candidate(x = 3,target = 12345) == 29\n assert candidate(x = 19,target = 923521) == 65\n assert candidate(x = 5,target = 123456789) == 101\n assert candidate(x = 3,target = 987654) == 73\n assert candidate(x = 50,target = 123456789) == 185\n assert candidate(x = 5,target = 987654) == 60\n assert candidate(x = 25,target = 625000) == 37\n assert candidate(x = 4,target = 16777216) == 11\n assert candidate(x = 13,target = 13131313) == 69\n assert candidate(x = 31,target = 28829) == 6\n assert candidate(x = 20,target = 123456) == 51\n assert candidate(x = 11,target = 275) == 6\n assert candidate(x = 13,target = 1690) == 8\n assert candidate(x = 89,target = 33243576) == 225\n assert candidate(x = 8,target = 134217728) == 8\n assert candidate(x = 29,target = 40353607) == 64\n assert candidate(x = 25,target = 15625000) == 49\n assert candidate(x = 20,target = 1000000) == 38\n assert candidate(x = 8,target = 1048576) == 23\n assert candidate(x = 71,target = 107606612) == 148\n", "comparison": "exact"}, "public_tests": ["3\n19", "5\n501", "100\n100000000"], "hints": [], "metadata": {"canonical_parameter_names": ["x", "target"], "leetcode_dataset_entry_point": "Solution().leastOpsExpressTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:01+00:00", "tests_total": 161, "tests_dropped": 34, "flags": [], "topic_tags": ["math", "dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def leastOpsExpressTarget(self, x: int, target: int) -> int:", "container": "Solution", "callable": "leastOpsExpressTarget", "parameters": [{"name": "x", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 966, "task_id": "vowel-spellchecker", "difficulty": "Medium", "problem_description": "Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.\n\nFor a given query word, the spell checker handles two categories of spelling mistakes:\n\n- Capitalization: If the query matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the case in the wordlist.\n - Example: wordlist = [\"yellow\"], query = \"YellOw\": correct = \"yellow\"\n - Example: wordlist = [\"Yellow\"], query = \"yellow\": correct = \"Yellow\"\n - Example: wordlist = [\"yellow\"], query = \"yellow\": correct = \"yellow\"\n- Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist.\n - Example: wordlist = [\"YellOw\"], query = \"yollow\": correct = \"YellOw\"\n - Example: wordlist = [\"YellOw\"], query = \"yeellow\": correct = \"\" (no match)\n - Example: wordlist = [\"YellOw\"], query = \"yllw\": correct = \"\" (no match)\n\nIn addition, the spell checker operates under the following precedence rules:\n\n- When the query exactly matches a word in the wordlist (case-sensitive), you should return the same word back.\n- When the query matches a word up to capitalization, you should return the first such match in the wordlist.\n- When the query matches a word up to vowel errors, you should return the first such match in the wordlist.\n- If the query has no matches in the wordlist, you should return the empty string.\n\nGiven some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].\n\nExample 1:\n\nInput: wordlist = [\"KiTe\",\"kite\",\"hare\",\"Hare\"], queries = [\"kite\",\"Kite\",\"KiTe\",\"Hare\",\"HARE\",\"Hear\",\"hear\",\"keti\",\"keet\",\"keto\"]\nOutput: [\"kite\",\"KiTe\",\"KiTe\",\"Hare\",\"hare\",\"\",\"\",\"KiTe\",\"\",\"KiTe\"]\n\nExample 2:\n\nInput: wordlist = [\"yellow\"], queries = [\"YellOw\"]\nOutput: [\"yellow\"]\n\nConstraints:\n\n- 1 <= wordlist.length, queries.length <= 5000\n- 1 <= wordlist[i].length, queries[i].length <= 7\n- wordlist[i] and queries[i] consist only of only English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(wordlist = ['aeiou', 'AEIOU'],queries = ['aeio', 'aeiou', 'AEIOU', 'eioua']) == ['', 'aeiou', 'AEIOU', 'aeiou']\n assert candidate(wordlist = ['aaaaa', 'Aaaaa'],queries = ['Aaaaa', 'aaaaa', 'aaAaa', 'aAaaa', 'AaAaa']) == ['Aaaaa', 'aaaaa', 'aaaaa', 'aaaaa', 'aaaaa']\n assert candidate(wordlist = ['yellow'],queries = ['YellOw']) == ['yellow']\n assert candidate(wordlist = ['apple', 'Apple', 'apples'],queries = ['apples', 'APPLES', 'applesa', 'applee']) == ['apples', 'apples', '', '']\n assert candidate(wordlist = ['KiTe', 'kite', 'hare', 'Hare'],queries = ['kite', 'Kite', 'KiTe', 'Hare', 'HARE', 'Hear', 'hear', 'keti', 'keet', 'keto']) == ['kite', 'KiTe', 'KiTe', 'Hare', 'hare', '', '', 'KiTe', '', 'KiTe']\n assert candidate(wordlist = ['banana', 'Banana', 'BANANA', 'banAnA'],queries = ['banana', 'Banana', 'BANANA', 'banAnA', 'bananA', 'bananaa', 'BANANAS']) == ['banana', 'Banana', 'BANANA', 'banAnA', 'banana', '', '']\n assert candidate(wordlist = ['AbCdE', 'abcdE', 'aBcDe', 'abCDE', 'abcde'],queries = ['AbCdE', 'Abcde', 'abcde', 'aBcDe', 'abCDE', 'ABCDE', 'abcde', 'AbCdF', 'AbCdEe']) == ['AbCdE', 'AbCdE', 'abcde', 'aBcDe', 'abCDE', 'AbCdE', 'abcde', '', '']\n assert candidate(wordlist = ['AbCdE', 'abCDe', 'aBcDe', 'ABCDe', 'abcde', 'aBcde', 'abCde', 'ABCDE'],queries = ['abcde', 'ABCDE', 'AbCdE', 'abcde', 'aBcDe', 'ABcDe', 'abcdef', 'aBcde', 'ABCDe', 'abCDe']) == ['abcde', 'ABCDE', 'AbCdE', 'abcde', 'aBcDe', 'AbCdE', '', 'aBcde', 'ABCDe', 'abCDe']\n assert candidate(wordlist = ['baNana', 'Banana', 'BANANA', 'baNANa'],queries = ['banana', 'BANANA', 'BaNaNa', 'bananA', 'baNANaa', 'bAnanaa']) == ['baNana', 'BANANA', 'baNana', 'baNana', '', '']\n assert candidate(wordlist = ['cAt', 'cAts', 'bAt', 'bat', 'bats', 'cAtBat'],queries = ['cats', 'CATS', 'cat', 'bat', 'bAts', 'CATBAT', 'caTbAt', 'batS', 'CAT', 'bAt']) == ['cAts', 'cAts', 'cAt', 'bat', 'bats', 'cAtBat', 'cAtBat', 'bats', 'cAt', 'bAt']\n assert candidate(wordlist = ['queue', 'Queue', 'QUEUE', 'qUeUe'],queries = ['queue', 'Queue', 'QUEUE', 'qUeUe', 'queuE', 'QUeUe', 'qUEUe', 'QUEue', 'quEUe', 'qUeue']) == ['queue', 'Queue', 'QUEUE', 'qUeUe', 'queue', 'queue', 'queue', 'queue', 'queue', 'queue']\n assert candidate(wordlist = ['kiwi', 'Kiwi', 'KIWI', 'kIWi', 'KiwI'],queries = ['kiwi', 'Kiwi', 'KIWI', 'kIWi', 'KiwI', 'kiw', 'KIW', 'kiwiwi', 'kiwii']) == ['kiwi', 'Kiwi', 'KIWI', 'kIWi', 'KiwI', '', '', '', '']\n assert candidate(wordlist = ['orange', 'Orange', 'ORANGE', 'oRANGE', 'orANGE'],queries = ['orange', 'Orange', 'ORANGE', 'oRANGE', 'orANGE', 'orang', 'ORANG', 'oranje', 'orng']) == ['orange', 'Orange', 'ORANGE', 'oRANGE', 'orANGE', '', '', '', '']\n assert candidate(wordlist = ['apple', 'orange', 'banana', 'grape', 'kiwi'],queries = ['Apple', 'ORANGE', 'BANANA', 'Grape', 'KIWI', 'aple', 'oranje', 'bananna', 'grapee', 'kiwii', 'appl', 'orang', 'banan', 'grap', 'kiw']) == ['apple', 'orange', 'banana', 'grape', 'kiwi', '', '', '', '', '', '', '', '', '', '']\n assert candidate(wordlist = ['grape', 'Grape', 'GRape', 'gRAPE', 'grAPE'],queries = ['grape', 'Grape', 'GRape', 'gRAPE', 'grAPE', 'grapE', 'GrapeS']) == ['grape', 'Grape', 'GRape', 'gRAPE', 'grAPE', 'grape', '']\n assert candidate(wordlist = ['water', 'Water', 'WATER', 'waTer', 'wateR', 'watER', 'wAtEr', 'waTEr'],queries = ['water', 'Water', 'WATER', 'waTer', 'wateR', 'watER', 'wAtEr', 'waTEr', 'wateR', 'waTer', 'watER', 'wAtEr', 'waTEr', 'wAter']) == ['water', 'Water', 'WATER', 'waTer', 'wateR', 'watER', 'wAtEr', 'waTEr', 'wateR', 'waTer', 'watER', 'wAtEr', 'waTEr', 'water']\n assert candidate(wordlist = ['banana', 'Banana', 'BANANA', 'banAna'],queries = ['banana', 'Banana', 'BANANA', 'banAna', 'BaNANA', 'bAnAnA', 'bananA', 'BaNANa']) == ['banana', 'Banana', 'BANANA', 'banAna', 'banana', 'banana', 'banana', 'banana']\n", "comparison": "exact"}, "public_tests": ["[\"KiTe\",\"kite\",\"hare\",\"Hare\"]\n[\"kite\",\"Kite\",\"KiTe\",\"Hare\",\"HARE\",\"Hear\",\"hear\",\"keti\",\"keet\",\"keto\"]", "[\"yellow\"]\n[\"YellOw\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["wordlist", "queries"], "leetcode_dataset_entry_point": "Solution().spellchecker", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:05+00:00", "tests_total": 87, "tests_dropped": 70, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def spellchecker(self, wordlist: list[str], queries: list[str]) -> list[str]:", "container": "Solution", "callable": "spellchecker", "parameters": [{"name": "wordlist", "type": "list[str]"}, {"name": "queries", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 967, "task_id": "numbers-with-same-consecutive-differences", "difficulty": "Medium", "problem_description": "Given two integers n and k, return an array of all the integers of length n where the difference between every two consecutive digits is k. You may return the answer in any order.\n\nNote that the integers should not have leading zeros. Integers as 02 and 043 are not allowed.\n\nExample 1:\n\nInput: n = 3, k = 7\nOutput: [181,292,707,818,929]\nExplanation: Note that 070 is not a valid number, because it has leading zeroes.\n\nExample 2:\n\nInput: n = 2, k = 1\nOutput: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]\n\nConstraints:\n\n- 2 <= n <= 9\n- 0 <= k <= 9\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=3, k=0), [111, 222, 333, 444, 555, 666, 777, 888, 999])\n assert answers_match(candidate(n=9, k=5), [161616161, 272727272, 383838383, 494949494, 505050505, 616161616, 727272727, 838383838, 949494949])\n assert answers_match(candidate(n=2, k=1), [12, 10, 23, 21, 34, 32, 45, 43, 56, 54, 67, 65, 78, 76, 89, 87, 98])\n assert answers_match(candidate(n=9, k=9), [909090909])\n assert answers_match(candidate(n=2, k=9), [90])\n assert answers_match(candidate(n=5, k=5), [16161, 27272, 38383, 49494, 50505, 61616, 72727, 83838, 94949])\n assert answers_match(candidate(n=3, k=2), [135, 131, 246, 242, 202, 357, 353, 313, 468, 464, 424, 420, 579, 575, 535, 531, 686, 646, 642, 797, 757, 753, 868, 864, 979, 975])\n assert answers_match(candidate(n=2, k=0), [11, 22, 33, 44, 55, 66, 77, 88, 99])\n assert answers_match(candidate(n=9, k=1), [123456789, 123456787, 123456767, 123456765, 123456567, 123456565, 123456545, 123456543, 123454567, 123454565, 123454545, 123454543, 123454345, 123454343, 123454323, 123454321, 123434567, 123434565, 123434545, 123434543, 123434345, 123434343, 123434323, 123434321, 123432345, 123432343, 123432323, 123432321, 123432123, 123432121, 123432101, 123234567, 123234565, 123234545, 123234543, 123234345, 123234343, 123234323, 123234321, 123232345, 123232343, 123232323, 123232321, 123232123, 123232121, 123232101, 123212345, 123212343, 123212323, 123212321, 123212123, 123212121, 123212101, 123210123, 123210121, 123210101, 121234567, 121234565, 121234545, 121234543, 121234345, 121234343, 121234323, 121234321, 121232345, 121232343, 121232323, 121232321, 121232123, 121232121, 121232101, 121212345, 121212343, 121212323, 121212321, 121212123, 121212121, 121212101, 121210123, 121210121, 121210101, 121012345, 121012343, 121012323, 121012321, 121012123, 121012121, 121012101, 121010123, 121010121, 121010101, 101234567, 101234565, 101234545, 101234543, 101234345, 101234343, 101234323, 101234321, 101232345, 101232343, 101232323, 101232321, 101232123, 101232121, 101232101, 101212345, 101212343, 101212323, 101212321, 101212123, 101212121, 101212101, 101210123, 101210121, 101210101, 101012345, 101012343, 101012323, 101012321, 101012123, 101012121, 101012101, 101010123, 101010121, 101010101, 234567898, 234567878, 234567876, 234567678, 234567676, 234567656, 234567654, 234565678, 234565676, 234565656, 234565654, 234565456, 234565454, 234565434, 234565432, 234545678, 234545676, 234545656, 234545654, 234545456, 234545454, 234545434, 234545432, 234543456, 234543454, 234543434, 234543432, 234543234, 234543232, 234543212, 234543210, 234345678, 234345676, 234345656, 234345654, 234345456, 234345454, 234345434, 234345432, 234343456, 234343454, 234343434, 234343432, 234343234, 234343232, 234343212, 234343210, 234323456, 234323454, 234323434, 234323432, 234323234, 234323232, 234323212, 234323210, 234321234, 234321232, 234321212, 234321210, 234321012, 234321010, 232345678, 232345676, 232345656, 232345654, 232345456, 232345454, 232345434, 232345432, 232343456, 232343454, 232343434, 232343432, 232343234, 232343232, 232343212, 232343210, 232323456, 232323454, 232323434, 232323432, 232323234, 232323232, 232323212, 232323210, 232321234, 232321232, 232321212, 232321210, 232321012, 232321010, 232123456, 232123454, 232123434, 232123432, 232123234, 232123232, 232123212, 232123210, 232121234, 232121232, 232121212, 232121210, 232121012, 232121010, 232101234, 232101232, 232101212, 232101210, 232101012, 232101010, 212345678, 212345676, 212345656, 212345654, 212345456, 212345454, 212345434, 212345432, 212343456, 212343454, 212343434, 212343432, 212343234, 212343232, 212343212, 212343210, 212323456, 212323454, 212323434, 212323432, 212323234, 212323232, 212323212, 212323210, 212321234, 212321232, 212321212, 212321210, 212321012, 212321010, 212123456, 212123454, 212123434, 212123432, 212123234, 212123232, 212123212, 212123210, 212121234, 212121232, 212121212, 212121210, 212121012, 212121010, 212101234, 212101232, 212101212, 212101210, 212101012, 212101010, 210123456, 210123454, 210123434, 210123432, 210123234, 210123232, 210123212, 210123210, 210121234, 210121232, 210121212, 210121210, 210121012, 210121010, 210101234, 210101232, 210101212, 210101210, 210101012, 210101010, 345678989, 345678987, 345678789, 345678787, 345678767, 345678765, 345676789, 345676787, 345676767, 345676765, 345676567, 345676565, 345676545, 345676543, 345656789, 345656787, 345656767, 345656765, 345656567, 345656565, 345656545, 345656543, 345654567, 345654565, 345654545, 345654543, 345654345, 345654343, 345654323, 345654321, 345456789, 345456787, 345456767, 345456765, 345456567, 345456565, 345456545, 345456543, 345454567, 345454565, 345454545, 345454543, 345454345, 345454343, 345454323, 345454321, 345434567, 345434565, 345434545, 345434543, 345434345, 345434343, 345434323, 345434321, 345432345, 345432343, 345432323, 345432321, 345432123, 345432121, 345432101, 343456789, 343456787, 343456767, 343456765, 343456567, 343456565, 343456545, 343456543, 343454567, 343454565, 343454545, 343454543, 343454345, 343454343, 343454323, 343454321, 343434567, 343434565, 343434545, 343434543, 343434345, 343434343, 343434323, 343434321, 343432345, 343432343, 343432323, 343432321, 343432123, 343432121, 343432101, 343234567, 343234565, 343234545, 343234543, 343234345, 343234343, 343234323, 343234321, 343232345, 343232343, 343232323, 343232321, 343232123, 343232121, 343232101, 343212345, 343212343, 343212323, 343212321, 343212123, 343212121, 343212101, 343210123, 343210121, 343210101, 323456789, 323456787, 323456767, 323456765, 323456567, 323456565, 323456545, 323456543, 323454567, 323454565, 323454545, 323454543, 323454345, 323454343, 323454323, 323454321, 323434567, 323434565, 323434545, 323434543, 323434345, 323434343, 323434323, 323434321, 323432345, 323432343, 323432323, 323432321, 323432123, 323432121, 323432101, 323234567, 323234565, 323234545, 323234543, 323234345, 323234343, 323234323, 323234321, 323232345, 323232343, 323232323, 323232321, 323232123, 323232121, 323232101, 323212345, 323212343, 323212323, 323212321, 323212123, 323212121, 323212101, 323210123, 323210121, 323210101, 321234567, 321234565, 321234545, 321234543, 321234345, 321234343, 321234323, 321234321, 321232345, 321232343, 321232323, 321232321, 321232123, 321232121, 321232101, 321212345, 321212343, 321212323, 321212321, 321212123, 321212121, 321212101, 321210123, 321210121, 321210101, 321012345, 321012343, 321012323, 321012321, 321012123, 321012121, 321012101, 321010123, 321010121, 321010101, 456789898, 456789878, 456789876, 456787898, 456787878, 456787876, 456787678, 456787676, 456787656, 456787654, 456767898, 456767878, 456767876, 456767678, 456767676, 456767656, 456767654, 456765678, 456765676, 456765656, 456765654, 456765456, 456765454, 456765434, 456765432, 456567898, 456567878, 456567876, 456567678, 456567676, 456567656, 456567654, 456565678, 456565676, 456565656, 456565654, 456565456, 456565454, 456565434, 456565432, 456545678, 456545676, 456545656, 456545654, 456545456, 456545454, 456545434, 456545432, 456543456, 456543454, 456543434, 456543432, 456543234, 456543232, 456543212, 456543210, 454567898, 454567878, 454567876, 454567678, 454567676, 454567656, 454567654, 454565678, 454565676, 454565656, 454565654, 454565456, 454565454, 454565434, 454565432, 454545678, 454545676, 454545656, 454545654, 454545456, 454545454, 454545434, 454545432, 454543456, 454543454, 454543434, 454543432, 454543234, 454543232, 454543212, 454543210, 454345678, 454345676, 454345656, 454345654, 454345456, 454345454, 454345434, 454345432, 454343456, 454343454, 454343434, 454343432, 454343234, 454343232, 454343212, 454343210, 454323456, 454323454, 454323434, 454323432, 454323234, 454323232, 454323212, 454323210, 454321234, 454321232, 454321212, 454321210, 454321012, 454321010, 434567898, 434567878, 434567876, 434567678, 434567676, 434567656, 434567654, 434565678, 434565676, 434565656, 434565654, 434565456, 434565454, 434565434, 434565432, 434545678, 434545676, 434545656, 434545654, 434545456, 434545454, 434545434, 434545432, 434543456, 434543454, 434543434, 434543432, 434543234, 434543232, 434543212, 434543210, 434345678, 434345676, 434345656, 434345654, 434345456, 434345454, 434345434, 434345432, 434343456, 434343454, 434343434, 434343432, 434343234, 434343232, 434343212, 434343210, 434323456, 434323454, 434323434, 434323432, 434323234, 434323232, 434323212, 434323210, 434321234, 434321232, 434321212, 434321210, 434321012, 434321010, 432345678, 432345676, 432345656, 432345654, 432345456, 432345454, 432345434, 432345432, 432343456, 432343454, 432343434, 432343432, 432343234, 432343232, 432343212, 432343210, 432323456, 432323454, 432323434, 432323432, 432323234, 432323232, 432323212, 432323210, 432321234, 432321232, 432321212, 432321210, 432321012, 432321010, 432123456, 432123454, 432123434, 432123432, 432123234, 432123232, 432123212, 432123210, 432121234, 432121232, 432121212, 432121210, 432121012, 432121010, 432101234, 432101232, 432101212, 432101210, 432101012, 432101010, 567898989, 567898987, 567898789, 567898787, 567898767, 567898765, 567878989, 567878987, 567878789, 567878787, 567878767, 567878765, 567876789, 567876787, 567876767, 567876765, 567876567, 567876565, 567876545, 567876543, 567678989, 567678987, 567678789, 567678787, 567678767, 567678765, 567676789, 567676787, 567676767, 567676765, 567676567, 567676565, 567676545, 567676543, 567656789, 567656787, 567656767, 567656765, 567656567, 567656565, 567656545, 567656543, 567654567, 567654565, 567654545, 567654543, 567654345, 567654343, 567654323, 567654321, 565678989, 565678987, 565678789, 565678787, 565678767, 565678765, 565676789, 565676787, 565676767, 565676765, 565676567, 565676565, 565676545, 565676543, 565656789, 565656787, 565656767, 565656765, 565656567, 565656565, 565656545, 565656543, 565654567, 565654565, 565654545, 565654543, 565654345, 565654343, 565654323, 565654321, 565456789, 565456787, 565456767, 565456765, 565456567, 565456565, 565456545, 565456543, 565454567, 565454565, 565454545, 565454543, 565454345, 565454343, 565454323, 565454321, 565434567, 565434565, 565434545, 565434543, 565434345, 565434343, 565434323, 565434321, 565432345, 565432343, 565432323, 565432321, 565432123, 565432121, 565432101, 545678989, 545678987, 545678789, 545678787, 545678767, 545678765, 545676789, 545676787, 545676767, 545676765, 545676567, 545676565, 545676545, 545676543, 545656789, 545656787, 545656767, 545656765, 545656567, 545656565, 545656545, 545656543, 545654567, 545654565, 545654545, 545654543, 545654345, 545654343, 545654323, 545654321, 545456789, 545456787, 545456767, 545456765, 545456567, 545456565, 545456545, 545456543, 545454567, 545454565, 545454545, 545454543, 545454345, 545454343, 545454323, 545454321, 545434567, 545434565, 545434545, 545434543, 545434345, 545434343, 545434323, 545434321, 545432345, 545432343, 545432323, 545432321, 545432123, 545432121, 545432101, 543456789, 543456787, 543456767, 543456765, 543456567, 543456565, 543456545, 543456543, 543454567, 543454565, 543454545, 543454543, 543454345, 543454343, 543454323, 543454321, 543434567, 543434565, 543434545, 543434543, 543434345, 543434343, 543434323, 543434321, 543432345, 543432343, 543432323, 543432321, 543432123, 543432121, 543432101, 543234567, 543234565, 543234545, 543234543, 543234345, 543234343, 543234323, 543234321, 543232345, 543232343, 543232323, 543232321, 543232123, 543232121, 543232101, 543212345, 543212343, 543212323, 543212321, 543212123, 543212121, 543212101, 543210123, 543210121, 543210101, 678989898, 678989878, 678989876, 678987898, 678987878, 678987876, 678987678, 678987676, 678987656, 678987654, 678789898, 678789878, 678789876, 678787898, 678787878, 678787876, 678787678, 678787676, 678787656, 678787654, 678767898, 678767878, 678767876, 678767678, 678767676, 678767656, 678767654, 678765678, 678765676, 678765656, 678765654, 678765456, 678765454, 678765434, 678765432, 676789898, 676789878, 676789876, 676787898, 676787878, 676787876, 676787678, 676787676, 676787656, 676787654, 676767898, 676767878, 676767876, 676767678, 676767676, 676767656, 676767654, 676765678, 676765676, 676765656, 676765654, 676765456, 676765454, 676765434, 676765432, 676567898, 676567878, 676567876, 676567678, 676567676, 676567656, 676567654, 676565678, 676565676, 676565656, 676565654, 676565456, 676565454, 676565434, 676565432, 676545678, 676545676, 676545656, 676545654, 676545456, 676545454, 676545434, 676545432, 676543456, 676543454, 676543434, 676543432, 676543234, 676543232, 676543212, 676543210, 656789898, 656789878, 656789876, 656787898, 656787878, 656787876, 656787678, 656787676, 656787656, 656787654, 656767898, 656767878, 656767876, 656767678, 656767676, 656767656, 656767654, 656765678, 656765676, 656765656, 656765654, 656765456, 656765454, 656765434, 656765432, 656567898, 656567878, 656567876, 656567678, 656567676, 656567656, 656567654, 656565678, 656565676, 656565656, 656565654, 656565456, 656565454, 656565434, 656565432, 656545678, 656545676, 656545656, 656545654, 656545456, 656545454, 656545434, 656545432, 656543456, 656543454, 656543434, 656543432, 656543234, 656543232, 656543212, 656543210, 654567898, 654567878, 654567876, 654567678, 654567676, 654567656, 654567654, 654565678, 654565676, 654565656, 654565654, 654565456, 654565454, 654565434, 654565432, 654545678, 654545676, 654545656, 654545654, 654545456, 654545454, 654545434, 654545432, 654543456, 654543454, 654543434, 654543432, 654543234, 654543232, 654543212, 654543210, 654345678, 654345676, 654345656, 654345654, 654345456, 654345454, 654345434, 654345432, 654343456, 654343454, 654343434, 654343432, 654343234, 654343232, 654343212, 654343210, 654323456, 654323454, 654323434, 654323432, 654323234, 654323232, 654323212, 654323210, 654321234, 654321232, 654321212, 654321210, 654321012, 654321010, 789898989, 789898987, 789898789, 789898787, 789898767, 789898765, 789878989, 789878987, 789878789, 789878787, 789878767, 789878765, 789876789, 789876787, 789876767, 789876765, 789876567, 789876565, 789876545, 789876543, 787898989, 787898987, 787898789, 787898787, 787898767, 787898765, 787878989, 787878987, 787878789, 787878787, 787878767, 787878765, 787876789, 787876787, 787876767, 787876765, 787876567, 787876565, 787876545, 787876543, 787678989, 787678987, 787678789, 787678787, 787678767, 787678765, 787676789, 787676787, 787676767, 787676765, 787676567, 787676565, 787676545, 787676543, 787656789, 787656787, 787656767, 787656765, 787656567, 787656565, 787656545, 787656543, 787654567, 787654565, 787654545, 787654543, 787654345, 787654343, 787654323, 787654321, 767898989, 767898987, 767898789, 767898787, 767898767, 767898765, 767878989, 767878987, 767878789, 767878787, 767878767, 767878765, 767876789, 767876787, 767876767, 767876765, 767876567, 767876565, 767876545, 767876543, 767678989, 767678987, 767678789, 767678787, 767678767, 767678765, 767676789, 767676787, 767676767, 767676765, 767676567, 767676565, 767676545, 767676543, 767656789, 767656787, 767656767, 767656765, 767656567, 767656565, 767656545, 767656543, 767654567, 767654565, 767654545, 767654543, 767654345, 767654343, 767654323, 767654321, 765678989, 765678987, 765678789, 765678787, 765678767, 765678765, 765676789, 765676787, 765676767, 765676765, 765676567, 765676565, 765676545, 765676543, 765656789, 765656787, 765656767, 765656765, 765656567, 765656565, 765656545, 765656543, 765654567, 765654565, 765654545, 765654543, 765654345, 765654343, 765654323, 765654321, 765456789, 765456787, 765456767, 765456765, 765456567, 765456565, 765456545, 765456543, 765454567, 765454565, 765454545, 765454543, 765454345, 765454343, 765454323, 765454321, 765434567, 765434565, 765434545, 765434543, 765434345, 765434343, 765434323, 765434321, 765432345, 765432343, 765432323, 765432321, 765432123, 765432121, 765432101, 898989898, 898989878, 898989876, 898987898, 898987878, 898987876, 898987678, 898987676, 898987656, 898987654, 898789898, 898789878, 898789876, 898787898, 898787878, 898787876, 898787678, 898787676, 898787656, 898787654, 898767898, 898767878, 898767876, 898767678, 898767676, 898767656, 898767654, 898765678, 898765676, 898765656, 898765654, 898765456, 898765454, 898765434, 898765432, 878989898, 878989878, 878989876, 878987898, 878987878, 878987876, 878987678, 878987676, 878987656, 878987654, 878789898, 878789878, 878789876, 878787898, 878787878, 878787876, 878787678, 878787676, 878787656, 878787654, 878767898, 878767878, 878767876, 878767678, 878767676, 878767656, 878767654, 878765678, 878765676, 878765656, 878765654, 878765456, 878765454, 878765434, 878765432, 876789898, 876789878, 876789876, 876787898, 876787878, 876787876, 876787678, 876787676, 876787656, 876787654, 876767898, 876767878, 876767876, 876767678, 876767676, 876767656, 876767654, 876765678, 876765676, 876765656, 876765654, 876765456, 876765454, 876765434, 876765432, 876567898, 876567878, 876567876, 876567678, 876567676, 876567656, 876567654, 876565678, 876565676, 876565656, 876565654, 876565456, 876565454, 876565434, 876565432, 876545678, 876545676, 876545656, 876545654, 876545456, 876545454, 876545434, 876545432, 876543456, 876543454, 876543434, 876543432, 876543234, 876543232, 876543212, 876543210, 989898989, 989898987, 989898789, 989898787, 989898767, 989898765, 989878989, 989878987, 989878789, 989878787, 989878767, 989878765, 989876789, 989876787, 989876767, 989876765, 989876567, 989876565, 989876545, 989876543, 987898989, 987898987, 987898789, 987898787, 987898767, 987898765, 987878989, 987878987, 987878789, 987878787, 987878767, 987878765, 987876789, 987876787, 987876767, 987876765, 987876567, 987876565, 987876545, 987876543, 987678989, 987678987, 987678789, 987678787, 987678767, 987678765, 987676789, 987676787, 987676767, 987676765, 987676567, 987676565, 987676545, 987676543, 987656789, 987656787, 987656767, 987656765, 987656567, 987656565, 987656545, 987656543, 987654567, 987654565, 987654545, 987654543, 987654345, 987654343, 987654323, 987654321])\n assert answers_match(candidate(n=5, k=2), [13579, 13575, 13535, 13531, 13135, 13131, 24686, 24646, 24642, 24246, 24242, 24202, 20246, 20242, 20202, 35797, 35757, 35753, 35357, 35353, 35313, 31357, 31353, 31313, 46868, 46864, 46468, 46464, 46424, 46420, 42468, 42464, 42424, 42420, 42024, 42020, 57979, 57975, 57579, 57575, 57535, 57531, 53579, 53575, 53535, 53531, 53135, 53131, 68686, 68646, 68642, 64686, 64646, 64642, 64246, 64242, 64202, 79797, 79757, 79753, 75797, 75757, 75753, 75357, 75353, 75313, 86868, 86864, 86468, 86464, 86424, 86420, 97979, 97975, 97579, 97575, 97535, 97531])\n assert answers_match(candidate(n=4, k=5), [1616, 2727, 3838, 4949, 5050, 6161, 7272, 8383, 9494])\n assert answers_match(candidate(n=4, k=2), [1357, 1353, 1313, 2468, 2464, 2424, 2420, 2024, 2020, 3579, 3575, 3535, 3531, 3135, 3131, 4686, 4646, 4642, 4246, 4242, 4202, 5797, 5757, 5753, 5357, 5353, 5313, 6868, 6864, 6468, 6464, 6424, 6420, 7979, 7975, 7579, 7575, 7535, 7531, 8686, 8646, 8642, 9797, 9757, 9753])\n assert answers_match(candidate(n=3, k=7), [181, 292, 707, 818, 929])\n assert answers_match(candidate(n=5, k=0), [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999])\n assert answers_match(candidate(n=4, k=3), [1474, 1414, 2585, 2525, 3696, 3636, 3630, 3036, 3030, 4747, 4741, 4147, 4141, 5858, 5852, 5258, 5252, 6969, 6963, 6369, 6363, 6303, 7474, 7414, 8585, 8525, 9696, 9636, 9630])\n assert answers_match(candidate(n=9, k=4), [159595959, 159595951, 159595159, 159595151, 159515959, 159515951, 159515159, 159515151, 151595959, 151595951, 151595159, 151595151, 151515959, 151515951, 151515159, 151515151, 262626262, 373737373, 484848484, 484848404, 484840484, 484840404, 484048484, 484048404, 484040484, 484040404, 404848484, 404848404, 404840484, 404840404, 404048484, 404048404, 404040484, 404040404, 595959595, 595959515, 595951595, 595951515, 595159595, 595159515, 595151595, 595151515, 515959595, 515959515, 515951595, 515951515, 515159595, 515159515, 515151595, 515151515, 626262626, 737373737, 848484848, 848484840, 848484048, 848484040, 848404848, 848404840, 848404048, 848404040, 840484848, 840484840, 840484048, 840484040, 840404848, 840404840, 840404048, 840404040, 959595959, 959595951, 959595159, 959595151, 959515959, 959515951, 959515159, 959515151, 951595959, 951595951, 951595159, 951595151, 951515959, 951515951, 951515159, 951515151])\n assert answers_match(candidate(n=4, k=8), [1919, 8080, 9191])\n assert answers_match(candidate(n=6, k=8), [191919, 808080, 919191])\n assert answers_match(candidate(n=2, k=8), [19, 80, 91])\n assert answers_match(candidate(n=6, k=0), [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999])\n assert answers_match(candidate(n=7, k=3), [1474747, 1474741, 1474147, 1474141, 1414747, 1414741, 1414147, 1414141, 2585858, 2585852, 2585258, 2585252, 2525858, 2525852, 2525258, 2525252, 3696969, 3696963, 3696369, 3696363, 3696303, 3636969, 3636963, 3636369, 3636363, 3636303, 3630369, 3630363, 3630303, 3036969, 3036963, 3036369, 3036363, 3036303, 3030369, 3030363, 3030303, 4747474, 4747414, 4741474, 4741414, 4147474, 4147414, 4141474, 4141414, 5858585, 5858525, 5852585, 5852525, 5258585, 5258525, 5252585, 5252525, 6969696, 6969636, 6969630, 6963696, 6963636, 6963630, 6963036, 6963030, 6369696, 6369636, 6369630, 6363696, 6363636, 6363630, 6363036, 6363030, 6303696, 6303636, 6303630, 6303036, 6303030, 7474747, 7474741, 7474147, 7474141, 7414747, 7414741, 7414147, 7414141, 8585858, 8585852, 8585258, 8585252, 8525858, 8525852, 8525258, 8525252, 9696969, 9696963, 9696369, 9696363, 9696303, 9636969, 9636963, 9636369, 9636363, 9636303, 9630369, 9630363, 9630303])\n assert answers_match(candidate(n=7, k=1), [1234567, 1234565, 1234545, 1234543, 1234345, 1234343, 1234323, 1234321, 1232345, 1232343, 1232323, 1232321, 1232123, 1232121, 1232101, 1212345, 1212343, 1212323, 1212321, 1212123, 1212121, 1212101, 1210123, 1210121, 1210101, 1012345, 1012343, 1012323, 1012321, 1012123, 1012121, 1012101, 1010123, 1010121, 1010101, 2345678, 2345676, 2345656, 2345654, 2345456, 2345454, 2345434, 2345432, 2343456, 2343454, 2343434, 2343432, 2343234, 2343232, 2343212, 2343210, 2323456, 2323454, 2323434, 2323432, 2323234, 2323232, 2323212, 2323210, 2321234, 2321232, 2321212, 2321210, 2321012, 2321010, 2123456, 2123454, 2123434, 2123432, 2123234, 2123232, 2123212, 2123210, 2121234, 2121232, 2121212, 2121210, 2121012, 2121010, 2101234, 2101232, 2101212, 2101210, 2101012, 2101010, 3456789, 3456787, 3456767, 3456765, 3456567, 3456565, 3456545, 3456543, 3454567, 3454565, 3454545, 3454543, 3454345, 3454343, 3454323, 3454321, 3434567, 3434565, 3434545, 3434543, 3434345, 3434343, 3434323, 3434321, 3432345, 3432343, 3432323, 3432321, 3432123, 3432121, 3432101, 3234567, 3234565, 3234545, 3234543, 3234345, 3234343, 3234323, 3234321, 3232345, 3232343, 3232323, 3232321, 3232123, 3232121, 3232101, 3212345, 3212343, 3212323, 3212321, 3212123, 3212121, 3212101, 3210123, 3210121, 3210101, 4567898, 4567878, 4567876, 4567678, 4567676, 4567656, 4567654, 4565678, 4565676, 4565656, 4565654, 4565456, 4565454, 4565434, 4565432, 4545678, 4545676, 4545656, 4545654, 4545456, 4545454, 4545434, 4545432, 4543456, 4543454, 4543434, 4543432, 4543234, 4543232, 4543212, 4543210, 4345678, 4345676, 4345656, 4345654, 4345456, 4345454, 4345434, 4345432, 4343456, 4343454, 4343434, 4343432, 4343234, 4343232, 4343212, 4343210, 4323456, 4323454, 4323434, 4323432, 4323234, 4323232, 4323212, 4323210, 4321234, 4321232, 4321212, 4321210, 4321012, 4321010, 5678989, 5678987, 5678789, 5678787, 5678767, 5678765, 5676789, 5676787, 5676767, 5676765, 5676567, 5676565, 5676545, 5676543, 5656789, 5656787, 5656767, 5656765, 5656567, 5656565, 5656545, 5656543, 5654567, 5654565, 5654545, 5654543, 5654345, 5654343, 5654323, 5654321, 5456789, 5456787, 5456767, 5456765, 5456567, 5456565, 5456545, 5456543, 5454567, 5454565, 5454545, 5454543, 5454345, 5454343, 5454323, 5454321, 5434567, 5434565, 5434545, 5434543, 5434345, 5434343, 5434323, 5434321, 5432345, 5432343, 5432323, 5432321, 5432123, 5432121, 5432101, 6789898, 6789878, 6789876, 6787898, 6787878, 6787876, 6787678, 6787676, 6787656, 6787654, 6767898, 6767878, 6767876, 6767678, 6767676, 6767656, 6767654, 6765678, 6765676, 6765656, 6765654, 6765456, 6765454, 6765434, 6765432, 6567898, 6567878, 6567876, 6567678, 6567676, 6567656, 6567654, 6565678, 6565676, 6565656, 6565654, 6565456, 6565454, 6565434, 6565432, 6545678, 6545676, 6545656, 6545654, 6545456, 6545454, 6545434, 6545432, 6543456, 6543454, 6543434, 6543432, 6543234, 6543232, 6543212, 6543210, 7898989, 7898987, 7898789, 7898787, 7898767, 7898765, 7878989, 7878987, 7878789, 7878787, 7878767, 7878765, 7876789, 7876787, 7876767, 7876765, 7876567, 7876565, 7876545, 7876543, 7678989, 7678987, 7678789, 7678787, 7678767, 7678765, 7676789, 7676787, 7676767, 7676765, 7676567, 7676565, 7676545, 7676543, 7656789, 7656787, 7656767, 7656765, 7656567, 7656565, 7656545, 7656543, 7654567, 7654565, 7654545, 7654543, 7654345, 7654343, 7654323, 7654321, 8989898, 8989878, 8989876, 8987898, 8987878, 8987876, 8987678, 8987676, 8987656, 8987654, 8789898, 8789878, 8789876, 8787898, 8787878, 8787876, 8787678, 8787676, 8787656, 8787654, 8767898, 8767878, 8767876, 8767678, 8767676, 8767656, 8767654, 8765678, 8765676, 8765656, 8765654, 8765456, 8765454, 8765434, 8765432, 9898989, 9898987, 9898789, 9898787, 9898767, 9898765, 9878989, 9878987, 9878789, 9878787, 9878767, 9878765, 9876789, 9876787, 9876767, 9876765, 9876567, 9876565, 9876545, 9876543])\n assert answers_match(candidate(n=9, k=8), [191919191, 808080808, 919191919])\n assert answers_match(candidate(n=5, k=1), [12345, 12343, 12323, 12321, 12123, 12121, 12101, 10123, 10121, 10101, 23456, 23454, 23434, 23432, 23234, 23232, 23212, 23210, 21234, 21232, 21212, 21210, 21012, 21010, 34567, 34565, 34545, 34543, 34345, 34343, 34323, 34321, 32345, 32343, 32323, 32321, 32123, 32121, 32101, 45678, 45676, 45656, 45654, 45456, 45454, 45434, 45432, 43456, 43454, 43434, 43432, 43234, 43232, 43212, 43210, 56789, 56787, 56767, 56765, 56567, 56565, 56545, 56543, 54567, 54565, 54545, 54543, 54345, 54343, 54323, 54321, 67898, 67878, 67876, 67678, 67676, 67656, 67654, 65678, 65676, 65656, 65654, 65456, 65454, 65434, 65432, 78989, 78987, 78789, 78787, 78767, 78765, 76789, 76787, 76767, 76765, 76567, 76565, 76545, 76543, 89898, 89878, 89876, 87898, 87878, 87876, 87678, 87676, 87656, 87654, 98989, 98987, 98789, 98787, 98767, 98765])\n assert answers_match(candidate(n=3, k=6), [171, 282, 393, 606, 717, 828, 939])\n assert answers_match(candidate(n=6, k=9), [909090])\n assert answers_match(candidate(n=4, k=0), [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999])\n assert answers_match(candidate(n=2, k=5), [16, 27, 38, 49, 50, 61, 72, 83, 94])\n assert answers_match(candidate(n=7, k=2), [1357979, 1357975, 1357579, 1357575, 1357535, 1357531, 1353579, 1353575, 1353535, 1353531, 1353135, 1353131, 1313579, 1313575, 1313535, 1313531, 1313135, 1313131, 2468686, 2468646, 2468642, 2464686, 2464646, 2464642, 2464246, 2464242, 2464202, 2424686, 2424646, 2424642, 2424246, 2424242, 2424202, 2420246, 2420242, 2420202, 2024686, 2024646, 2024642, 2024246, 2024242, 2024202, 2020246, 2020242, 2020202, 3579797, 3579757, 3579753, 3575797, 3575757, 3575753, 3575357, 3575353, 3575313, 3535797, 3535757, 3535753, 3535357, 3535353, 3535313, 3531357, 3531353, 3531313, 3135797, 3135757, 3135753, 3135357, 3135353, 3135313, 3131357, 3131353, 3131313, 4686868, 4686864, 4686468, 4686464, 4686424, 4686420, 4646868, 4646864, 4646468, 4646464, 4646424, 4646420, 4642468, 4642464, 4642424, 4642420, 4642024, 4642020, 4246868, 4246864, 4246468, 4246464, 4246424, 4246420, 4242468, 4242464, 4242424, 4242420, 4242024, 4242020, 4202468, 4202464, 4202424, 4202420, 4202024, 4202020, 5797979, 5797975, 5797579, 5797575, 5797535, 5797531, 5757979, 5757975, 5757579, 5757575, 5757535, 5757531, 5753579, 5753575, 5753535, 5753531, 5753135, 5753131, 5357979, 5357975, 5357579, 5357575, 5357535, 5357531, 5353579, 5353575, 5353535, 5353531, 5353135, 5353131, 5313579, 5313575, 5313535, 5313531, 5313135, 5313131, 6868686, 6868646, 6868642, 6864686, 6864646, 6864642, 6864246, 6864242, 6864202, 6468686, 6468646, 6468642, 6464686, 6464646, 6464642, 6464246, 6464242, 6464202, 6424686, 6424646, 6424642, 6424246, 6424242, 6424202, 6420246, 6420242, 6420202, 7979797, 7979757, 7979753, 7975797, 7975757, 7975753, 7975357, 7975353, 7975313, 7579797, 7579757, 7579753, 7575797, 7575757, 7575753, 7575357, 7575353, 7575313, 7535797, 7535757, 7535753, 7535357, 7535353, 7535313, 7531357, 7531353, 7531313, 8686868, 8686864, 8686468, 8686464, 8686424, 8686420, 8646868, 8646864, 8646468, 8646464, 8646424, 8646420, 8642468, 8642464, 8642424, 8642420, 8642024, 8642020, 9797979, 9797975, 9797579, 9797575, 9797535, 9797531, 9757979, 9757975, 9757579, 9757575, 9757535, 9757531, 9753579, 9753575, 9753535, 9753531, 9753135, 9753131])\n assert answers_match(candidate(n=4, k=1), [1234, 1232, 1212, 1210, 1012, 1010, 2345, 2343, 2323, 2321, 2123, 2121, 2101, 3456, 3454, 3434, 3432, 3234, 3232, 3212, 3210, 4567, 4565, 4545, 4543, 4345, 4343, 4323, 4321, 5678, 5676, 5656, 5654, 5456, 5454, 5434, 5432, 6789, 6787, 6767, 6765, 6567, 6565, 6545, 6543, 7898, 7878, 7876, 7678, 7676, 7656, 7654, 8989, 8987, 8789, 8787, 8767, 8765, 9898, 9878, 9876])\n assert answers_match(candidate(n=8, k=1), [12345678, 12345676, 12345656, 12345654, 12345456, 12345454, 12345434, 12345432, 12343456, 12343454, 12343434, 12343432, 12343234, 12343232, 12343212, 12343210, 12323456, 12323454, 12323434, 12323432, 12323234, 12323232, 12323212, 12323210, 12321234, 12321232, 12321212, 12321210, 12321012, 12321010, 12123456, 12123454, 12123434, 12123432, 12123234, 12123232, 12123212, 12123210, 12121234, 12121232, 12121212, 12121210, 12121012, 12121010, 12101234, 12101232, 12101212, 12101210, 12101012, 12101010, 10123456, 10123454, 10123434, 10123432, 10123234, 10123232, 10123212, 10123210, 10121234, 10121232, 10121212, 10121210, 10121012, 10121010, 10101234, 10101232, 10101212, 10101210, 10101012, 10101010, 23456789, 23456787, 23456767, 23456765, 23456567, 23456565, 23456545, 23456543, 23454567, 23454565, 23454545, 23454543, 23454345, 23454343, 23454323, 23454321, 23434567, 23434565, 23434545, 23434543, 23434345, 23434343, 23434323, 23434321, 23432345, 23432343, 23432323, 23432321, 23432123, 23432121, 23432101, 23234567, 23234565, 23234545, 23234543, 23234345, 23234343, 23234323, 23234321, 23232345, 23232343, 23232323, 23232321, 23232123, 23232121, 23232101, 23212345, 23212343, 23212323, 23212321, 23212123, 23212121, 23212101, 23210123, 23210121, 23210101, 21234567, 21234565, 21234545, 21234543, 21234345, 21234343, 21234323, 21234321, 21232345, 21232343, 21232323, 21232321, 21232123, 21232121, 21232101, 21212345, 21212343, 21212323, 21212321, 21212123, 21212121, 21212101, 21210123, 21210121, 21210101, 21012345, 21012343, 21012323, 21012321, 21012123, 21012121, 21012101, 21010123, 21010121, 21010101, 34567898, 34567878, 34567876, 34567678, 34567676, 34567656, 34567654, 34565678, 34565676, 34565656, 34565654, 34565456, 34565454, 34565434, 34565432, 34545678, 34545676, 34545656, 34545654, 34545456, 34545454, 34545434, 34545432, 34543456, 34543454, 34543434, 34543432, 34543234, 34543232, 34543212, 34543210, 34345678, 34345676, 34345656, 34345654, 34345456, 34345454, 34345434, 34345432, 34343456, 34343454, 34343434, 34343432, 34343234, 34343232, 34343212, 34343210, 34323456, 34323454, 34323434, 34323432, 34323234, 34323232, 34323212, 34323210, 34321234, 34321232, 34321212, 34321210, 34321012, 34321010, 32345678, 32345676, 32345656, 32345654, 32345456, 32345454, 32345434, 32345432, 32343456, 32343454, 32343434, 32343432, 32343234, 32343232, 32343212, 32343210, 32323456, 32323454, 32323434, 32323432, 32323234, 32323232, 32323212, 32323210, 32321234, 32321232, 32321212, 32321210, 32321012, 32321010, 32123456, 32123454, 32123434, 32123432, 32123234, 32123232, 32123212, 32123210, 32121234, 32121232, 32121212, 32121210, 32121012, 32121010, 32101234, 32101232, 32101212, 32101210, 32101012, 32101010, 45678989, 45678987, 45678789, 45678787, 45678767, 45678765, 45676789, 45676787, 45676767, 45676765, 45676567, 45676565, 45676545, 45676543, 45656789, 45656787, 45656767, 45656765, 45656567, 45656565, 45656545, 45656543, 45654567, 45654565, 45654545, 45654543, 45654345, 45654343, 45654323, 45654321, 45456789, 45456787, 45456767, 45456765, 45456567, 45456565, 45456545, 45456543, 45454567, 45454565, 45454545, 45454543, 45454345, 45454343, 45454323, 45454321, 45434567, 45434565, 45434545, 45434543, 45434345, 45434343, 45434323, 45434321, 45432345, 45432343, 45432323, 45432321, 45432123, 45432121, 45432101, 43456789, 43456787, 43456767, 43456765, 43456567, 43456565, 43456545, 43456543, 43454567, 43454565, 43454545, 43454543, 43454345, 43454343, 43454323, 43454321, 43434567, 43434565, 43434545, 43434543, 43434345, 43434343, 43434323, 43434321, 43432345, 43432343, 43432323, 43432321, 43432123, 43432121, 43432101, 43234567, 43234565, 43234545, 43234543, 43234345, 43234343, 43234323, 43234321, 43232345, 43232343, 43232323, 43232321, 43232123, 43232121, 43232101, 43212345, 43212343, 43212323, 43212321, 43212123, 43212121, 43212101, 43210123, 43210121, 43210101, 56789898, 56789878, 56789876, 56787898, 56787878, 56787876, 56787678, 56787676, 56787656, 56787654, 56767898, 56767878, 56767876, 56767678, 56767676, 56767656, 56767654, 56765678, 56765676, 56765656, 56765654, 56765456, 56765454, 56765434, 56765432, 56567898, 56567878, 56567876, 56567678, 56567676, 56567656, 56567654, 56565678, 56565676, 56565656, 56565654, 56565456, 56565454, 56565434, 56565432, 56545678, 56545676, 56545656, 56545654, 56545456, 56545454, 56545434, 56545432, 56543456, 56543454, 56543434, 56543432, 56543234, 56543232, 56543212, 56543210, 54567898, 54567878, 54567876, 54567678, 54567676, 54567656, 54567654, 54565678, 54565676, 54565656, 54565654, 54565456, 54565454, 54565434, 54565432, 54545678, 54545676, 54545656, 54545654, 54545456, 54545454, 54545434, 54545432, 54543456, 54543454, 54543434, 54543432, 54543234, 54543232, 54543212, 54543210, 54345678, 54345676, 54345656, 54345654, 54345456, 54345454, 54345434, 54345432, 54343456, 54343454, 54343434, 54343432, 54343234, 54343232, 54343212, 54343210, 54323456, 54323454, 54323434, 54323432, 54323234, 54323232, 54323212, 54323210, 54321234, 54321232, 54321212, 54321210, 54321012, 54321010, 67898989, 67898987, 67898789, 67898787, 67898767, 67898765, 67878989, 67878987, 67878789, 67878787, 67878767, 67878765, 67876789, 67876787, 67876767, 67876765, 67876567, 67876565, 67876545, 67876543, 67678989, 67678987, 67678789, 67678787, 67678767, 67678765, 67676789, 67676787, 67676767, 67676765, 67676567, 67676565, 67676545, 67676543, 67656789, 67656787, 67656767, 67656765, 67656567, 67656565, 67656545, 67656543, 67654567, 67654565, 67654545, 67654543, 67654345, 67654343, 67654323, 67654321, 65678989, 65678987, 65678789, 65678787, 65678767, 65678765, 65676789, 65676787, 65676767, 65676765, 65676567, 65676565, 65676545, 65676543, 65656789, 65656787, 65656767, 65656765, 65656567, 65656565, 65656545, 65656543, 65654567, 65654565, 65654545, 65654543, 65654345, 65654343, 65654323, 65654321, 65456789, 65456787, 65456767, 65456765, 65456567, 65456565, 65456545, 65456543, 65454567, 65454565, 65454545, 65454543, 65454345, 65454343, 65454323, 65454321, 65434567, 65434565, 65434545, 65434543, 65434345, 65434343, 65434323, 65434321, 65432345, 65432343, 65432323, 65432321, 65432123, 65432121, 65432101, 78989898, 78989878, 78989876, 78987898, 78987878, 78987876, 78987678, 78987676, 78987656, 78987654, 78789898, 78789878, 78789876, 78787898, 78787878, 78787876, 78787678, 78787676, 78787656, 78787654, 78767898, 78767878, 78767876, 78767678, 78767676, 78767656, 78767654, 78765678, 78765676, 78765656, 78765654, 78765456, 78765454, 78765434, 78765432, 76789898, 76789878, 76789876, 76787898, 76787878, 76787876, 76787678, 76787676, 76787656, 76787654, 76767898, 76767878, 76767876, 76767678, 76767676, 76767656, 76767654, 76765678, 76765676, 76765656, 76765654, 76765456, 76765454, 76765434, 76765432, 76567898, 76567878, 76567876, 76567678, 76567676, 76567656, 76567654, 76565678, 76565676, 76565656, 76565654, 76565456, 76565454, 76565434, 76565432, 76545678, 76545676, 76545656, 76545654, 76545456, 76545454, 76545434, 76545432, 76543456, 76543454, 76543434, 76543432, 76543234, 76543232, 76543212, 76543210, 89898989, 89898987, 89898789, 89898787, 89898767, 89898765, 89878989, 89878987, 89878789, 89878787, 89878767, 89878765, 89876789, 89876787, 89876767, 89876765, 89876567, 89876565, 89876545, 89876543, 87898989, 87898987, 87898789, 87898787, 87898767, 87898765, 87878989, 87878987, 87878789, 87878787, 87878767, 87878765, 87876789, 87876787, 87876767, 87876765, 87876567, 87876565, 87876545, 87876543, 87678989, 87678987, 87678789, 87678787, 87678767, 87678765, 87676789, 87676787, 87676767, 87676765, 87676567, 87676565, 87676545, 87676543, 87656789, 87656787, 87656767, 87656765, 87656567, 87656565, 87656545, 87656543, 87654567, 87654565, 87654545, 87654543, 87654345, 87654343, 87654323, 87654321, 98989898, 98989878, 98989876, 98987898, 98987878, 98987876, 98987678, 98987676, 98987656, 98987654, 98789898, 98789878, 98789876, 98787898, 98787878, 98787876, 98787678, 98787676, 98787656, 98787654, 98767898, 98767878, 98767876, 98767678, 98767676, 98767656, 98767654, 98765678, 98765676, 98765656, 98765654, 98765456, 98765454, 98765434, 98765432])\n assert answers_match(candidate(n=3, k=9), [909])\n assert answers_match(candidate(n=7, k=4), [1595959, 1595951, 1595159, 1595151, 1515959, 1515951, 1515159, 1515151, 2626262, 3737373, 4848484, 4848404, 4840484, 4840404, 4048484, 4048404, 4040484, 4040404, 5959595, 5959515, 5951595, 5951515, 5159595, 5159515, 5151595, 5151515, 6262626, 7373737, 8484848, 8484840, 8484048, 8484040, 8404848, 8404840, 8404048, 8404040, 9595959, 9595951, 9595159, 9595151, 9515959, 9515951, 9515159, 9515151])\n assert answers_match(candidate(n=8, k=2), [13579797, 13579757, 13579753, 13575797, 13575757, 13575753, 13575357, 13575353, 13575313, 13535797, 13535757, 13535753, 13535357, 13535353, 13535313, 13531357, 13531353, 13531313, 13135797, 13135757, 13135753, 13135357, 13135353, 13135313, 13131357, 13131353, 13131313, 24686868, 24686864, 24686468, 24686464, 24686424, 24686420, 24646868, 24646864, 24646468, 24646464, 24646424, 24646420, 24642468, 24642464, 24642424, 24642420, 24642024, 24642020, 24246868, 24246864, 24246468, 24246464, 24246424, 24246420, 24242468, 24242464, 24242424, 24242420, 24242024, 24242020, 24202468, 24202464, 24202424, 24202420, 24202024, 24202020, 20246868, 20246864, 20246468, 20246464, 20246424, 20246420, 20242468, 20242464, 20242424, 20242420, 20242024, 20242020, 20202468, 20202464, 20202424, 20202420, 20202024, 20202020, 35797979, 35797975, 35797579, 35797575, 35797535, 35797531, 35757979, 35757975, 35757579, 35757575, 35757535, 35757531, 35753579, 35753575, 35753535, 35753531, 35753135, 35753131, 35357979, 35357975, 35357579, 35357575, 35357535, 35357531, 35353579, 35353575, 35353535, 35353531, 35353135, 35353131, 35313579, 35313575, 35313535, 35313531, 35313135, 35313131, 31357979, 31357975, 31357579, 31357575, 31357535, 31357531, 31353579, 31353575, 31353535, 31353531, 31353135, 31353131, 31313579, 31313575, 31313535, 31313531, 31313135, 31313131, 46868686, 46868646, 46868642, 46864686, 46864646, 46864642, 46864246, 46864242, 46864202, 46468686, 46468646, 46468642, 46464686, 46464646, 46464642, 46464246, 46464242, 46464202, 46424686, 46424646, 46424642, 46424246, 46424242, 46424202, 46420246, 46420242, 46420202, 42468686, 42468646, 42468642, 42464686, 42464646, 42464642, 42464246, 42464242, 42464202, 42424686, 42424646, 42424642, 42424246, 42424242, 42424202, 42420246, 42420242, 42420202, 42024686, 42024646, 42024642, 42024246, 42024242, 42024202, 42020246, 42020242, 42020202, 57979797, 57979757, 57979753, 57975797, 57975757, 57975753, 57975357, 57975353, 57975313, 57579797, 57579757, 57579753, 57575797, 57575757, 57575753, 57575357, 57575353, 57575313, 57535797, 57535757, 57535753, 57535357, 57535353, 57535313, 57531357, 57531353, 57531313, 53579797, 53579757, 53579753, 53575797, 53575757, 53575753, 53575357, 53575353, 53575313, 53535797, 53535757, 53535753, 53535357, 53535353, 53535313, 53531357, 53531353, 53531313, 53135797, 53135757, 53135753, 53135357, 53135353, 53135313, 53131357, 53131353, 53131313, 68686868, 68686864, 68686468, 68686464, 68686424, 68686420, 68646868, 68646864, 68646468, 68646464, 68646424, 68646420, 68642468, 68642464, 68642424, 68642420, 68642024, 68642020, 64686868, 64686864, 64686468, 64686464, 64686424, 64686420, 64646868, 64646864, 64646468, 64646464, 64646424, 64646420, 64642468, 64642464, 64642424, 64642420, 64642024, 64642020, 64246868, 64246864, 64246468, 64246464, 64246424, 64246420, 64242468, 64242464, 64242424, 64242420, 64242024, 64242020, 64202468, 64202464, 64202424, 64202420, 64202024, 64202020, 79797979, 79797975, 79797579, 79797575, 79797535, 79797531, 79757979, 79757975, 79757579, 79757575, 79757535, 79757531, 79753579, 79753575, 79753535, 79753531, 79753135, 79753131, 75797979, 75797975, 75797579, 75797575, 75797535, 75797531, 75757979, 75757975, 75757579, 75757575, 75757535, 75757531, 75753579, 75753575, 75753535, 75753531, 75753135, 75753131, 75357979, 75357975, 75357579, 75357575, 75357535, 75357531, 75353579, 75353575, 75353535, 75353531, 75353135, 75353131, 75313579, 75313575, 75313535, 75313531, 75313135, 75313131, 86868686, 86868646, 86868642, 86864686, 86864646, 86864642, 86864246, 86864242, 86864202, 86468686, 86468646, 86468642, 86464686, 86464646, 86464642, 86464246, 86464242, 86464202, 86424686, 86424646, 86424642, 86424246, 86424242, 86424202, 86420246, 86420242, 86420202, 97979797, 97979757, 97979753, 97975797, 97975757, 97975753, 97975357, 97975353, 97975313, 97579797, 97579757, 97579753, 97575797, 97575757, 97575753, 97575357, 97575353, 97575313, 97535797, 97535757, 97535753, 97535357, 97535353, 97535313, 97531357, 97531353, 97531313])\n assert answers_match(candidate(n=5, k=7), [18181, 29292, 70707, 81818, 92929])\n assert answers_match(candidate(n=8, k=3), [14747474, 14747414, 14741474, 14741414, 14147474, 14147414, 14141474, 14141414, 25858585, 25858525, 25852585, 25852525, 25258585, 25258525, 25252585, 25252525, 36969696, 36969636, 36969630, 36963696, 36963636, 36963630, 36963036, 36963030, 36369696, 36369636, 36369630, 36363696, 36363636, 36363630, 36363036, 36363030, 36303696, 36303636, 36303630, 36303036, 36303030, 30369696, 30369636, 30369630, 30363696, 30363636, 30363630, 30363036, 30363030, 30303696, 30303636, 30303630, 30303036, 30303030, 47474747, 47474741, 47474147, 47474141, 47414747, 47414741, 47414147, 47414141, 41474747, 41474741, 41474147, 41474141, 41414747, 41414741, 41414147, 41414141, 58585858, 58585852, 58585258, 58585252, 58525858, 58525852, 58525258, 58525252, 52585858, 52585852, 52585258, 52585252, 52525858, 52525852, 52525258, 52525252, 69696969, 69696963, 69696369, 69696363, 69696303, 69636969, 69636963, 69636369, 69636363, 69636303, 69630369, 69630363, 69630303, 63696969, 63696963, 63696369, 63696363, 63696303, 63636969, 63636963, 63636369, 63636363, 63636303, 63630369, 63630363, 63630303, 63036969, 63036963, 63036369, 63036363, 63036303, 63030369, 63030363, 63030303, 74747474, 74747414, 74741474, 74741414, 74147474, 74147414, 74141474, 74141414, 85858585, 85858525, 85852585, 85852525, 85258585, 85258525, 85252585, 85252525, 96969696, 96969636, 96969630, 96963696, 96963636, 96963630, 96963036, 96963030, 96369696, 96369636, 96369630, 96363696, 96363636, 96363630, 96363036, 96363030, 96303696, 96303636, 96303630, 96303036, 96303030])\n assert answers_match(candidate(n=8, k=4), [15959595, 15959515, 15951595, 15951515, 15159595, 15159515, 15151595, 15151515, 26262626, 37373737, 48484848, 48484840, 48484048, 48484040, 48404848, 48404840, 48404048, 48404040, 40484848, 40484840, 40484048, 40484040, 40404848, 40404840, 40404048, 40404040, 59595959, 59595951, 59595159, 59595151, 59515959, 59515951, 59515159, 59515151, 51595959, 51595951, 51595159, 51595151, 51515959, 51515951, 51515159, 51515151, 62626262, 73737373, 84848484, 84848404, 84840484, 84840404, 84048484, 84048404, 84040484, 84040404, 95959595, 95959515, 95951595, 95951515, 95159595, 95159515, 95151595, 95151515])\n assert answers_match(candidate(n=6, k=4), [159595, 159515, 151595, 151515, 262626, 373737, 484848, 484840, 484048, 484040, 404848, 404840, 404048, 404040, 595959, 595951, 595159, 595151, 515959, 515951, 515159, 515151, 626262, 737373, 848484, 848404, 840484, 840404, 959595, 959515, 951595, 951515])\n assert answers_match(candidate(n=8, k=9), [90909090])\n assert answers_match(candidate(n=7, k=7), [1818181, 2929292, 7070707, 8181818, 9292929])\n assert answers_match(candidate(n=8, k=0), [11111111, 22222222, 33333333, 44444444, 55555555, 66666666, 77777777, 88888888, 99999999])\n assert answers_match(candidate(n=7, k=0), [1111111, 2222222, 3333333, 4444444, 5555555, 6666666, 7777777, 8888888, 9999999])\n assert answers_match(candidate(n=9, k=3), [147474747, 147474741, 147474147, 147474141, 147414747, 147414741, 147414147, 147414141, 141474747, 141474741, 141474147, 141474141, 141414747, 141414741, 141414147, 141414141, 258585858, 258585852, 258585258, 258585252, 258525858, 258525852, 258525258, 258525252, 252585858, 252585852, 252585258, 252585252, 252525858, 252525852, 252525258, 252525252, 369696969, 369696963, 369696369, 369696363, 369696303, 369636969, 369636963, 369636369, 369636363, 369636303, 369630369, 369630363, 369630303, 363696969, 363696963, 363696369, 363696363, 363696303, 363636969, 363636963, 363636369, 363636363, 363636303, 363630369, 363630363, 363630303, 363036969, 363036963, 363036369, 363036363, 363036303, 363030369, 363030363, 363030303, 303696969, 303696963, 303696369, 303696363, 303696303, 303636969, 303636963, 303636369, 303636363, 303636303, 303630369, 303630363, 303630303, 303036969, 303036963, 303036369, 303036363, 303036303, 303030369, 303030363, 303030303, 474747474, 474747414, 474741474, 474741414, 474147474, 474147414, 474141474, 474141414, 414747474, 414747414, 414741474, 414741414, 414147474, 414147414, 414141474, 414141414, 585858585, 585858525, 585852585, 585852525, 585258585, 585258525, 585252585, 585252525, 525858585, 525858525, 525852585, 525852525, 525258585, 525258525, 525252585, 525252525, 696969696, 696969636, 696969630, 696963696, 696963636, 696963630, 696963036, 696963030, 696369696, 696369636, 696369630, 696363696, 696363636, 696363630, 696363036, 696363030, 696303696, 696303636, 696303630, 696303036, 696303030, 636969696, 636969636, 636969630, 636963696, 636963636, 636963630, 636963036, 636963030, 636369696, 636369636, 636369630, 636363696, 636363636, 636363630, 636363036, 636363030, 636303696, 636303636, 636303630, 636303036, 636303030, 630369696, 630369636, 630369630, 630363696, 630363636, 630363630, 630363036, 630363030, 630303696, 630303636, 630303630, 630303036, 630303030, 747474747, 747474741, 747474147, 747474141, 747414747, 747414741, 747414147, 747414141, 741474747, 741474741, 741474147, 741474141, 741414747, 741414741, 741414147, 741414141, 858585858, 858585852, 858585258, 858585252, 858525858, 858525852, 858525258, 858525252, 852585858, 852585852, 852585258, 852585252, 852525858, 852525852, 852525258, 852525252, 969696969, 969696963, 969696369, 969696363, 969696303, 969636969, 969636963, 969636369, 969636363, 969636303, 969630369, 969630363, 969630303, 963696969, 963696963, 963696369, 963696363, 963696303, 963636969, 963636963, 963636369, 963636363, 963636303, 963630369, 963630363, 963630303, 963036969, 963036963, 963036369, 963036363, 963036303, 963030369, 963030363, 963030303])\n assert answers_match(candidate(n=8, k=5), [16161616, 27272727, 38383838, 49494949, 50505050, 61616161, 72727272, 83838383, 94949494])\n assert answers_match(candidate(n=9, k=2), [135797979, 135797975, 135797579, 135797575, 135797535, 135797531, 135757979, 135757975, 135757579, 135757575, 135757535, 135757531, 135753579, 135753575, 135753535, 135753531, 135753135, 135753131, 135357979, 135357975, 135357579, 135357575, 135357535, 135357531, 135353579, 135353575, 135353535, 135353531, 135353135, 135353131, 135313579, 135313575, 135313535, 135313531, 135313135, 135313131, 131357979, 131357975, 131357579, 131357575, 131357535, 131357531, 131353579, 131353575, 131353535, 131353531, 131353135, 131353131, 131313579, 131313575, 131313535, 131313531, 131313135, 131313131, 246868686, 246868646, 246868642, 246864686, 246864646, 246864642, 246864246, 246864242, 246864202, 246468686, 246468646, 246468642, 246464686, 246464646, 246464642, 246464246, 246464242, 246464202, 246424686, 246424646, 246424642, 246424246, 246424242, 246424202, 246420246, 246420242, 246420202, 242468686, 242468646, 242468642, 242464686, 242464646, 242464642, 242464246, 242464242, 242464202, 242424686, 242424646, 242424642, 242424246, 242424242, 242424202, 242420246, 242420242, 242420202, 242024686, 242024646, 242024642, 242024246, 242024242, 242024202, 242020246, 242020242, 242020202, 202468686, 202468646, 202468642, 202464686, 202464646, 202464642, 202464246, 202464242, 202464202, 202424686, 202424646, 202424642, 202424246, 202424242, 202424202, 202420246, 202420242, 202420202, 202024686, 202024646, 202024642, 202024246, 202024242, 202024202, 202020246, 202020242, 202020202, 357979797, 357979757, 357979753, 357975797, 357975757, 357975753, 357975357, 357975353, 357975313, 357579797, 357579757, 357579753, 357575797, 357575757, 357575753, 357575357, 357575353, 357575313, 357535797, 357535757, 357535753, 357535357, 357535353, 357535313, 357531357, 357531353, 357531313, 353579797, 353579757, 353579753, 353575797, 353575757, 353575753, 353575357, 353575353, 353575313, 353535797, 353535757, 353535753, 353535357, 353535353, 353535313, 353531357, 353531353, 353531313, 353135797, 353135757, 353135753, 353135357, 353135353, 353135313, 353131357, 353131353, 353131313, 313579797, 313579757, 313579753, 313575797, 313575757, 313575753, 313575357, 313575353, 313575313, 313535797, 313535757, 313535753, 313535357, 313535353, 313535313, 313531357, 313531353, 313531313, 313135797, 313135757, 313135753, 313135357, 313135353, 313135313, 313131357, 313131353, 313131313, 468686868, 468686864, 468686468, 468686464, 468686424, 468686420, 468646868, 468646864, 468646468, 468646464, 468646424, 468646420, 468642468, 468642464, 468642424, 468642420, 468642024, 468642020, 464686868, 464686864, 464686468, 464686464, 464686424, 464686420, 464646868, 464646864, 464646468, 464646464, 464646424, 464646420, 464642468, 464642464, 464642424, 464642420, 464642024, 464642020, 464246868, 464246864, 464246468, 464246464, 464246424, 464246420, 464242468, 464242464, 464242424, 464242420, 464242024, 464242020, 464202468, 464202464, 464202424, 464202420, 464202024, 464202020, 424686868, 424686864, 424686468, 424686464, 424686424, 424686420, 424646868, 424646864, 424646468, 424646464, 424646424, 424646420, 424642468, 424642464, 424642424, 424642420, 424642024, 424642020, 424246868, 424246864, 424246468, 424246464, 424246424, 424246420, 424242468, 424242464, 424242424, 424242420, 424242024, 424242020, 424202468, 424202464, 424202424, 424202420, 424202024, 424202020, 420246868, 420246864, 420246468, 420246464, 420246424, 420246420, 420242468, 420242464, 420242424, 420242420, 420242024, 420242020, 420202468, 420202464, 420202424, 420202420, 420202024, 420202020, 579797979, 579797975, 579797579, 579797575, 579797535, 579797531, 579757979, 579757975, 579757579, 579757575, 579757535, 579757531, 579753579, 579753575, 579753535, 579753531, 579753135, 579753131, 575797979, 575797975, 575797579, 575797575, 575797535, 575797531, 575757979, 575757975, 575757579, 575757575, 575757535, 575757531, 575753579, 575753575, 575753535, 575753531, 575753135, 575753131, 575357979, 575357975, 575357579, 575357575, 575357535, 575357531, 575353579, 575353575, 575353535, 575353531, 575353135, 575353131, 575313579, 575313575, 575313535, 575313531, 575313135, 575313131, 535797979, 535797975, 535797579, 535797575, 535797535, 535797531, 535757979, 535757975, 535757579, 535757575, 535757535, 535757531, 535753579, 535753575, 535753535, 535753531, 535753135, 535753131, 535357979, 535357975, 535357579, 535357575, 535357535, 535357531, 535353579, 535353575, 535353535, 535353531, 535353135, 535353131, 535313579, 535313575, 535313535, 535313531, 535313135, 535313131, 531357979, 531357975, 531357579, 531357575, 531357535, 531357531, 531353579, 531353575, 531353535, 531353531, 531353135, 531353131, 531313579, 531313575, 531313535, 531313531, 531313135, 531313131, 686868686, 686868646, 686868642, 686864686, 686864646, 686864642, 686864246, 686864242, 686864202, 686468686, 686468646, 686468642, 686464686, 686464646, 686464642, 686464246, 686464242, 686464202, 686424686, 686424646, 686424642, 686424246, 686424242, 686424202, 686420246, 686420242, 686420202, 646868686, 646868646, 646868642, 646864686, 646864646, 646864642, 646864246, 646864242, 646864202, 646468686, 646468646, 646468642, 646464686, 646464646, 646464642, 646464246, 646464242, 646464202, 646424686, 646424646, 646424642, 646424246, 646424242, 646424202, 646420246, 646420242, 646420202, 642468686, 642468646, 642468642, 642464686, 642464646, 642464642, 642464246, 642464242, 642464202, 642424686, 642424646, 642424642, 642424246, 642424242, 642424202, 642420246, 642420242, 642420202, 642024686, 642024646, 642024642, 642024246, 642024242, 642024202, 642020246, 642020242, 642020202, 797979797, 797979757, 797979753, 797975797, 797975757, 797975753, 797975357, 797975353, 797975313, 797579797, 797579757, 797579753, 797575797, 797575757, 797575753, 797575357, 797575353, 797575313, 797535797, 797535757, 797535753, 797535357, 797535353, 797535313, 797531357, 797531353, 797531313, 757979797, 757979757, 757979753, 757975797, 757975757, 757975753, 757975357, 757975353, 757975313, 757579797, 757579757, 757579753, 757575797, 757575757, 757575753, 757575357, 757575353, 757575313, 757535797, 757535757, 757535753, 757535357, 757535353, 757535313, 757531357, 757531353, 757531313, 753579797, 753579757, 753579753, 753575797, 753575757, 753575753, 753575357, 753575353, 753575313, 753535797, 753535757, 753535753, 753535357, 753535353, 753535313, 753531357, 753531353, 753531313, 753135797, 753135757, 753135753, 753135357, 753135353, 753135313, 753131357, 753131353, 753131313, 868686868, 868686864, 868686468, 868686464, 868686424, 868686420, 868646868, 868646864, 868646468, 868646464, 868646424, 868646420, 868642468, 868642464, 868642424, 868642420, 868642024, 868642020, 864686868, 864686864, 864686468, 864686464, 864686424, 864686420, 864646868, 864646864, 864646468, 864646464, 864646424, 864646420, 864642468, 864642464, 864642424, 864642420, 864642024, 864642020, 864246868, 864246864, 864246468, 864246464, 864246424, 864246420, 864242468, 864242464, 864242424, 864242420, 864242024, 864242020, 864202468, 864202464, 864202424, 864202420, 864202024, 864202020, 979797979, 979797975, 979797579, 979797575, 979797535, 979797531, 979757979, 979757975, 979757579, 979757575, 979757535, 979757531, 979753579, 979753575, 979753535, 979753531, 979753135, 979753131, 975797979, 975797975, 975797579, 975797575, 975797535, 975797531, 975757979, 975757975, 975757579, 975757575, 975757535, 975757531, 975753579, 975753575, 975753535, 975753531, 975753135, 975753131, 975357979, 975357975, 975357579, 975357575, 975357535, 975357531, 975353579, 975353575, 975353535, 975353531, 975353135, 975353131, 975313579, 975313575, 975313535, 975313531, 975313135, 975313131])\n assert answers_match(candidate(n=9, k=6), [171717171, 282828282, 393939393, 606060606, 717171717, 828282828, 939393939])\n assert answers_match(candidate(n=5, k=3), [14747, 14741, 14147, 14141, 25858, 25852, 25258, 25252, 36969, 36963, 36369, 36363, 36303, 30369, 30363, 30303, 47474, 47414, 41474, 41414, 58585, 58525, 52585, 52525, 69696, 69636, 69630, 63696, 63636, 63630, 63036, 63030, 74747, 74741, 74147, 74141, 85858, 85852, 85258, 85252, 96969, 96963, 96369, 96363, 96303])\n assert answers_match(candidate(n=7, k=5), [1616161, 2727272, 3838383, 4949494, 5050505, 6161616, 7272727, 8383838, 9494949])\n assert answers_match(candidate(n=3, k=8), [191, 808, 919])\n assert answers_match(candidate(n=9, k=7), [181818181, 292929292, 707070707, 818181818, 929292929])\n assert answers_match(candidate(n=6, k=7), [181818, 292929, 707070, 818181, 929292])\n assert answers_match(candidate(n=6, k=3), [147474, 147414, 141474, 141414, 258585, 258525, 252585, 252525, 369696, 369636, 369630, 363696, 363636, 363630, 363036, 363030, 303696, 303636, 303630, 303036, 303030, 474747, 474741, 474147, 474141, 414747, 414741, 414147, 414141, 585858, 585852, 585258, 585252, 525858, 525852, 525258, 525252, 696969, 696963, 696369, 696363, 696303, 636969, 636963, 636369, 636363, 636303, 630369, 630363, 630303, 747474, 747414, 741474, 741414, 858585, 858525, 852585, 852525, 969696, 969636, 969630, 963696, 963636, 963630, 963036, 963030])\n assert answers_match(candidate(n=9, k=0), [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999])\n assert answers_match(candidate(n=5, k=8), [19191, 80808, 91919])\n assert answers_match(candidate(n=8, k=8), [19191919, 80808080, 91919191])\n assert answers_match(candidate(n=5, k=6), [17171, 28282, 39393, 60606, 71717, 82828, 93939])\n assert answers_match(candidate(n=4, k=4), [1595, 1515, 2626, 3737, 4848, 4840, 4048, 4040, 5959, 5951, 5159, 5151, 6262, 7373, 8484, 8404, 9595, 9515])\n assert answers_match(candidate(n=6, k=5), [161616, 272727, 383838, 494949, 505050, 616161, 727272, 838383, 949494])\n assert answers_match(candidate(n=6, k=2), [135797, 135757, 135753, 135357, 135353, 135313, 131357, 131353, 131313, 246868, 246864, 246468, 246464, 246424, 246420, 242468, 242464, 242424, 242420, 242024, 242020, 202468, 202464, 202424, 202420, 202024, 202020, 357979, 357975, 357579, 357575, 357535, 357531, 353579, 353575, 353535, 353531, 353135, 353131, 313579, 313575, 313535, 313531, 313135, 313131, 468686, 468646, 468642, 464686, 464646, 464642, 464246, 464242, 464202, 424686, 424646, 424642, 424246, 424242, 424202, 420246, 420242, 420202, 579797, 579757, 579753, 575797, 575757, 575753, 575357, 575353, 575313, 535797, 535757, 535753, 535357, 535353, 535313, 531357, 531353, 531313, 686868, 686864, 686468, 686464, 686424, 686420, 646868, 646864, 646468, 646464, 646424, 646420, 642468, 642464, 642424, 642420, 642024, 642020, 797979, 797975, 797579, 797575, 797535, 797531, 757979, 757975, 757579, 757575, 757535, 757531, 753579, 753575, 753535, 753531, 753135, 753131, 868686, 868646, 868642, 864686, 864646, 864642, 864246, 864242, 864202, 979797, 979757, 979753, 975797, 975757, 975753, 975357, 975353, 975313])\n assert answers_match(candidate(n=7, k=8), [1919191, 8080808, 9191919])\n assert answers_match(candidate(n=5, k=4), [15959, 15951, 15159, 15151, 26262, 37373, 48484, 48404, 40484, 40404, 59595, 59515, 51595, 51515, 62626, 73737, 84848, 84840, 84048, 84040, 95959, 95951, 95159, 95151])\n", "comparison": "unordered"}, "public_tests": ["3\n7", "2\n1"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().numsSameConsecDiff", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:07+00:00", "tests_total": 61, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["backtracking", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def numsSameConsecDiff(self, n: int, k: int) -> list[int]:", "container": "Solution", "callable": "numsSameConsecDiff", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 969, "task_id": "pancake-sorting", "difficulty": "Medium", "problem_description": "Given an array of integers arr, sort the array by performing a series of pancake flips.\n\nIn one pancake flip we do the following steps:\n\n- Choose an integer k where 1 <= k <= arr.length.\n- Reverse the sub-array arr[0...k-1] (0-indexed).\n\nFor example, if arr = [3,2,1,4] and we performed a pancake flip choosing k = 3, we reverse the sub-array [3,2,1], so arr = [1,2,3,4] after the pancake flip at k = 3.\n\nReturn an array of the k-values corresponding to a sequence of pancake flips that sort arr. Any valid answer that sorts the array within 10 * arr.length flips will be judged as correct.\n\nExample 1:\n\nInput: arr = [3,2,4,1]\nOutput: [4,2,4,3]\nExplanation:\nWe perform 4 pancake flips, with k values 4, 2, 4, and 3.\nStarting state: arr = [3, 2, 4, 1]\nAfter 1st flip (k = 4): arr = [1, 4, 2, 3]\nAfter 2nd flip (k = 2): arr = [4, 1, 2, 3]\nAfter 3rd flip (k = 4): arr = [3, 2, 1, 4]\nAfter 4th flip (k = 3): arr = [1, 2, 3, 4], which is sorted.\n\nExample 2:\n\nInput: arr = [1,2,3]\nOutput: []\nExplanation: The input is already sorted, so there is no need to flip anything.\nNote that other answers, such as [3, 3], would also be accepted.\n\nConstraints:\n\n- 1 <= arr.length <= 100\n- 1 <= arr[i] <= arr.length\n- All integers in arr are unique (i.e. arr is a permutation of the integers from 1 to arr.length).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 1, 3, 4, 5]) == [2]\n assert candidate(arr = [4, 3, 2, 1]) == [4]\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5]\n assert candidate(arr = [3, 1, 2]) == [3, 2]\n assert candidate(arr = [1, 5, 3, 4, 2]) == [2, 5, 2, 4, 2, 3, 2]\n assert candidate(arr = [2, 3, 4, 1, 5]) == [3, 4]\n assert candidate(arr = [1, 2, 3]) == []\n assert candidate(arr = [1, 5, 4, 3, 2]) == [2, 5, 3, 4]\n assert candidate(arr = [1]) == []\n assert candidate(arr = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == [5]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10]\n assert candidate(arr = [2, 1]) == [2]\n assert candidate(arr = [3, 2, 4, 1]) == [3, 4, 2, 3, 2]\n assert candidate(arr = [1, 3, 2]) == [2, 3, 2]\n assert candidate(arr = [6, 3, 5, 1, 2, 4]) == [6, 4, 5, 2, 4]\n assert candidate(arr = [2, 5, 1, 3, 4]) == [2, 5, 4, 2]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [11, 10, 5, 9, 8, 7, 2, 6, 2, 4, 3, 2]\n assert candidate(arr = [3, 1, 4, 2, 6, 5]) == [5, 6, 5, 2, 4, 3, 2]\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15]\n assert candidate(arr = [7, 1, 2, 6, 4, 5, 3]) == [7, 4, 6, 4, 5, 4, 3]\n assert candidate(arr = [1, 10, 3, 5, 7, 9, 2, 4, 8, 6]) == [2, 10, 5, 9, 6, 8, 6, 7, 6, 5, 2, 4, 3, 2]\n assert candidate(arr = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [11]\n assert candidate(arr = [2, 4, 1, 3]) == [2, 4, 3, 2]\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == [6]\n assert candidate(arr = [7, 1, 8, 2, 9, 3, 10, 4, 5, 6]) == [7, 10, 8, 9, 7, 8, 6, 7, 4, 6, 2, 5, 3]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9]\n assert candidate(arr = [8, 5, 10, 9, 3, 7, 6, 4, 2, 1]) == [3, 10, 7, 9, 2, 8, 2, 7, 5, 6, 2, 5, 4, 3, 2]\n assert candidate(arr = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == [10, 8, 9, 7, 8, 6, 7, 5, 6, 4]\n assert candidate(arr = [9, 7, 5, 3, 1, 2, 4, 6, 8]) == [9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(arr = [6, 5, 3, 1, 2, 4]) == [6, 4, 3, 2]\n assert candidate(arr = [2, 1, 4, 3, 6, 5]) == [5, 6, 5, 2, 4, 2]\n assert candidate(arr = [3, 1, 4, 2]) == [3, 4, 2, 3]\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 9]\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7]) == [8, 7, 6, 5, 4, 3, 2]\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8]) == [7]\n assert candidate(arr = [8, 6, 7, 5, 3, 1, 4, 9, 2, 10]) == [8, 9, 2, 8, 5, 7, 2, 6, 5, 2, 4, 3, 2]\n assert candidate(arr = [1, 3, 5, 7, 9, 10, 8, 6, 4, 2]) == [6, 10, 4, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(arr = [7, 10, 4, 8, 5, 9, 1, 6, 2, 3]) == [2, 10, 5, 9, 3, 8, 6, 7, 3, 6, 5, 2, 4, 3]\n assert candidate(arr = [5, 1, 4, 2, 3]) == [5, 3, 4, 2, 3, 2]\n assert candidate(arr = [5, 3, 1, 4, 2]) == [5, 2, 4, 3, 2]\n assert candidate(arr = [10, 2, 1, 3, 5, 4, 7, 6, 9, 8]) == [10, 2, 9, 6, 7, 6, 2, 5, 2]\n assert candidate(arr = [8, 5, 9, 1, 7, 3, 4, 2, 6]) == [3, 9, 7, 8, 6, 7, 3, 6, 2, 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]) == [20]\n assert candidate(arr = [5, 4, 2, 3, 1]) == [5, 2, 3, 2]\n assert candidate(arr = [7, 1, 6, 2, 5, 3, 4]) == [7, 5, 6, 4, 5, 3, 4, 3]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [8, 9, 8, 2, 7, 4, 5, 4, 2, 3]\n assert candidate(arr = [4, 6, 3, 5, 2, 1]) == [2, 6, 3, 5, 4, 2]\n assert candidate(arr = [6, 4, 2, 1, 3, 5]) == [6, 5, 4, 3, 2]\n assert candidate(arr = [2, 7, 4, 1, 8, 3, 6, 5]) == [5, 8, 5, 7, 4, 6, 2, 3]\n assert candidate(arr = [3, 6, 1, 7, 5, 4, 2]) == [4, 7, 5, 6, 4, 5, 3, 2]\n assert candidate(arr = [6, 1, 5, 2, 4, 3]) == [6, 4, 5, 3, 4, 2]\n assert candidate(arr = [1, 4, 3, 2, 5, 6, 7, 8, 9, 10]) == [2, 4, 2, 3]\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1]) == [3, 8, 3, 7, 3, 6, 4, 3]\n assert candidate(arr = [1, 3, 2, 5, 4]) == [4, 5, 4, 2, 3]\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 7, 8, 9]) == [6]\n assert candidate(arr = [1, 3, 2, 4, 6, 5]) == [5, 6, 5, 4, 2, 3, 2]\n assert candidate(arr = [7, 1, 3, 5, 2, 6, 4]) == [7, 2, 6, 3, 5, 4, 3, 2]\n assert candidate(arr = [6, 3, 1, 5, 2, 4]) == [6, 3, 5, 3, 4, 2, 3]\n assert candidate(arr = [10, 2, 8, 6, 4, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 5, 10, 9, 2, 8, 7, 2, 6, 5, 2, 4, 3, 2]\n assert candidate(arr = [8, 1, 7, 3, 6, 2, 5, 4]) == [8, 6, 7, 5, 6, 4, 5, 2, 3]\n assert candidate(arr = [3, 1, 2, 4, 5]) == [3, 2]\n assert candidate(arr = [7, 4, 6, 2, 5, 1, 3]) == [7, 5, 6, 4, 5, 2, 4, 2, 3, 2]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [9]\n assert candidate(arr = [7, 1, 5, 3, 6, 4, 2]) == [7, 3, 6, 2, 5, 4, 2, 3, 2]\n assert candidate(arr = [6, 3, 2, 5, 4, 1]) == [6, 3, 5, 3]\n assert candidate(arr = [5, 2, 3, 1, 4]) == [5, 4, 2, 3]\n assert candidate(arr = [2, 6, 4, 3, 5, 1, 7]) == [2, 6, 2, 5, 2, 4, 2, 3, 2]\n assert candidate(arr = [2, 3, 1, 4, 6, 5]) == [5, 6, 5, 4, 2, 3]\n assert candidate(arr = [3, 5, 4, 1, 2]) == [2, 5, 3, 4, 3]\n assert candidate(arr = [8, 1, 2, 3, 4, 5, 6, 7]) == [8, 7]\n assert candidate(arr = [5, 2, 3, 1, 4, 6, 7, 8, 9, 10]) == [5, 4, 2, 3]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [8, 9, 8, 2, 7, 4, 5, 4, 2, 3]\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15]\n assert candidate(arr = [2, 3, 1, 5, 4]) == [4, 5, 4, 2, 3, 2]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [9]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == [9]\n assert candidate(arr = [3, 5, 4, 1, 2]) == [2, 5, 3, 4, 3]\n assert candidate(arr = [7, 5, 2, 4, 6, 1, 3]) == [7, 3, 6, 5, 3, 4, 2]\n assert candidate(arr = [2, 4, 1, 3, 5]) == [2, 4, 3, 2]\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8]) == [7]\n assert candidate(arr = [5, 1, 3, 2, 4]) == [5, 4, 2, 3, 2]\n assert candidate(arr = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [12]\n assert candidate(arr = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [9, 7, 8, 6, 7, 5, 6, 4, 5, 4]\n assert candidate(arr = [5, 3, 6, 1, 2, 4]) == [3, 6, 4, 5, 2, 4]\n assert candidate(arr = [4, 1, 5, 2, 3, 6]) == [3, 5, 3, 4, 2, 3, 2]\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 9]\n assert candidate(arr = [3, 6, 1, 8, 5, 2, 7, 4]) == [4, 8, 2, 7, 2, 6, 3, 5, 3, 4, 2]\n assert candidate(arr = [1, 3, 5, 2, 4, 6]) == [3, 5, 4, 3, 2]\n assert candidate(arr = [2, 7, 4, 3, 5, 1, 6, 8, 9, 10]) == [2, 7, 6, 4, 5, 3, 4, 3, 2]\n assert candidate(arr = [8, 1, 3, 7, 5, 2, 6, 4]) == [8, 5, 7, 4, 6, 5, 4, 2]\n assert candidate(arr = [11, 2, 9, 3, 8, 4, 7, 5, 10, 6, 1]) == [11, 3, 10, 2, 9, 6, 8, 6, 7, 4, 6, 5, 3, 4, 2, 3, 2]\n assert candidate(arr = [6, 3, 5, 4, 2, 1]) == [6, 4, 5, 3, 2]\n assert candidate(arr = [10, 1, 3, 4, 5, 6, 7, 8, 9, 2]) == [10, 2, 9, 7, 8, 2]\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1]) == [7]\n assert candidate(arr = [9, 7, 5, 3, 1, 8, 6, 4, 2]) == [9, 4, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(arr = [1, 3, 2, 4, 5]) == [2, 3, 2]\n assert candidate(arr = [2, 9, 5, 1, 8, 3, 7, 4, 6]) == [2, 9, 5, 8, 6, 7, 5, 6, 4, 5, 2, 4, 2, 3]\n assert candidate(arr = [5, 1, 9, 7, 3, 10, 2, 4, 8, 6]) == [6, 10, 7, 9, 4, 8, 6, 7, 6, 4, 5, 3, 4, 2]\n", "comparison": "exact"}, "public_tests": ["[3,2,4,1]", "[1,2,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().pancakeSort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:12+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def pancakeSort(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "pancakeSort", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 970, "task_id": "powerful-integers", "difficulty": "Medium", "problem_description": "Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound.\n\nAn integer is powerful if it can be represented as x^i + y^j for some integers i >= 0 and j >= 0.\n\nYou may return the answer in any order. In your answer, each value should occur at most once.\n\nExample 1:\n\nInput: x = 2, y = 3, bound = 10\nOutput: [2,3,4,5,7,9,10]\nExplanation:\n2 = 2^0 + 3^0\n3 = 2^1 + 3^0\n4 = 2^0 + 3^1\n5 = 2^1 + 3^1\n7 = 2^2 + 3^1\n9 = 2^3 + 3^0\n10 = 2^0 + 3^2\n\nExample 2:\n\nInput: x = 3, y = 5, bound = 15\nOutput: [2,4,6,8,10,14]\n\nConstraints:\n\n- 1 <= x, y <= 100\n- 0 <= bound <= 10^6\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(x=3, y=5, bound=15), [2, 4, 6, 8, 10, 14])\n assert answers_match(candidate(x=3, y=1, bound=20), [2, 10, 4])\n assert answers_match(candidate(x=2, y=2, bound=100), [2, 3, 4, 5, 6, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 36, 40, 48, 64, 65, 66, 68, 72, 80, 96])\n assert answers_match(candidate(x=1, y=2, bound=10), [9, 2, 3, 5])\n assert answers_match(candidate(x=2, y=3, bound=10), [2, 3, 4, 5, 7, 9, 10])\n assert answers_match(candidate(x=1, y=1, bound=2), [2])\n assert answers_match(candidate(x=1, y=1, bound=5), [2])\n assert answers_match(candidate(x=100, y=100, bound=1000000), [20000, 2, 101, 200, 10001, 10100])\n assert answers_match(candidate(x=1, y=1, bound=10), [2])\n assert answers_match(candidate(x=5, y=5, bound=100), [2, 6, 10, 50, 26, 30])\n assert answers_match(candidate(x=2, y=2, bound=10), [2, 3, 4, 5, 6, 8, 9, 10])\n assert answers_match(candidate(x=2, y=5, bound=50), [33, 2, 3, 5, 6, 7, 37, 9, 41, 13, 17, 21, 26, 27, 29])\n assert answers_match(candidate(x=99, y=100, bound=10000), [2, 100, 101, 199, 9802, 9901])\n assert answers_match(candidate(x=7, y=11, bound=1000), [128, 2, 354, 8, 170, 12, 464, 18, 50, 344, 122, 60])\n assert answers_match(candidate(x=2, y=1, bound=30), [2, 3, 5, 9, 17])\n assert answers_match(candidate(x=3, y=2, bound=100), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25, 28, 29, 31, 33, 35, 41, 43, 59, 65, 67, 73, 82, 83, 85, 89, 91, 97])\n assert answers_match(candidate(x=3, y=2, bound=20), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19])\n assert answers_match(candidate(x=2, y=3, bound=1000), [129, 2, 3, 4, 5, 259, 7, 131, 9, 10, 11, 137, 13, 257, 265, 521, 17, 145, 19, 275, 513, 25, 793, 155, 28, 29, 283, 31, 515, 33, 539, 35, 41, 43, 307, 59, 65, 67, 73, 209, 82, 83, 337, 85, 593, 89, 730, 731, 91, 733, 857, 985, 737, 97, 745, 113, 371, 244, 245, 499, 247, 755, 761, 251])\n assert answers_match(candidate(x=2, y=1, bound=1000), [33, 2, 3, 65, 5, 129, 257, 513, 9, 17])\n assert answers_match(candidate(x=2, y=5, bound=30), [2, 3, 5, 6, 7, 9, 13, 17, 21, 26, 27, 29])\n assert answers_match(candidate(x=5, y=5, bound=125), [2, 6, 10, 50, 26, 30])\n assert answers_match(candidate(x=3, y=3, bound=100), [2, 4, 36, 6, 10, 12, 82, 18, 84, 54, 90, 28, 30])\n assert answers_match(candidate(x=2, y=5, bound=100), [2, 3, 5, 6, 7, 9, 13, 17, 21, 26, 27, 29, 33, 37, 41, 57, 65, 69, 89])\n assert answers_match(candidate(x=1, y=1, bound=1), [])\n assert answers_match(candidate(x=3, y=2, bound=25), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25])\n assert answers_match(candidate(x=1, y=2, bound=100), [33, 2, 3, 65, 5, 9, 17])\n assert answers_match(candidate(x=2, y=5, bound=1000), [129, 2, 3, 641, 5, 6, 7, 133, 9, 257, 261, 517, 13, 141, 17, 657, 21, 513, 153, 26, 27, 281, 29, 157, 537, 637, 33, 37, 41, 689, 57, 189, 65, 69, 89, 753, 626, 627, 381, 629, 881, 633, 253, 126, 127])\n assert answers_match(candidate(x=5, y=3, bound=20), [2, 4, 6, 8, 10, 14])\n assert answers_match(candidate(x=17, y=29, bound=1000), [318, 2, 290, 842, 46, 18, 858, 30])\n assert answers_match(candidate(x=2, y=3, bound=50), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25, 28, 29, 31, 33, 35, 41, 43])\n assert answers_match(candidate(x=1, y=2, bound=1000), [33, 2, 3, 65, 5, 129, 257, 513, 9, 17])\n assert answers_match(candidate(x=10, y=5, bound=500), [225, 2, 35, 101, 6, 135, 105, 11, 15, 26, 125, 126])\n assert answers_match(candidate(x=99, y=99, bound=10000), [2, 100, 198, 9802, 9900])\n assert answers_match(candidate(x=97, y=97, bound=10000), [9410, 2, 9506, 98, 194])\n assert answers_match(candidate(x=2, y=7, bound=50), [33, 2, 3, 5, 39, 8, 9, 11, 15, 17, 50, 23])\n assert answers_match(candidate(x=7, y=11, bound=200), [128, 2, 8, 170, 12, 18, 50, 122, 60])\n assert answers_match(candidate(x=10, y=10, bound=1000), [2, 101, 200, 11, 110, 20])\n assert answers_match(candidate(x=31, y=37, bound=2000), [32, 2, 962, 68, 38, 998, 1400, 1370])\n assert answers_match(candidate(x=2, y=5, bound=256), [129, 2, 3, 5, 6, 7, 133, 9, 13, 141, 17, 21, 153, 26, 27, 29, 157, 33, 37, 41, 57, 189, 65, 69, 89, 253, 126, 127])\n assert answers_match(candidate(x=3, y=2, bound=1000), [129, 2, 515, 3, 5, 257, 513, 4, 9, 7, 11, 131, 10, 13, 137, 265, 17, 521, 19, 145, 275, 259, 25, 793, 155, 28, 29, 283, 31, 539, 33, 35, 41, 43, 307, 59, 65, 67, 73, 209, 82, 83, 337, 85, 593, 89, 730, 91, 731, 733, 857, 985, 97, 737, 745, 113, 371, 244, 245, 499, 247, 755, 761, 251])\n assert answers_match(candidate(x=5, y=7, bound=500), [32, 2, 132, 6, 8, 74, 12, 174, 368, 50, 468, 54, 344, 26, 348, 126])\n assert answers_match(candidate(x=1, y=100, bound=500), [2, 101])\n assert answers_match(candidate(x=97, y=98, bound=10000), [2, 99, 98, 9605, 195, 9701, 9410, 9507])\n assert answers_match(candidate(x=5, y=2, bound=100), [2, 3, 5, 6, 7, 9, 13, 17, 21, 26, 27, 29, 33, 37, 41, 57, 65, 69, 89])\n assert answers_match(candidate(x=3, y=7, bound=343), [2, 34, 4, 130, 292, 8, 10, 250, 76, 16, 50, 82, 52, 244, 88, 58, 28])\n assert answers_match(candidate(x=50, y=50, bound=5000), [2, 100, 2501, 5000, 51, 2550])\n assert answers_match(candidate(x=100, y=100, bound=100000), [20000, 2, 101, 200, 10001, 10100])\n assert answers_match(candidate(x=100, y=1, bound=500), [2, 101])\n assert answers_match(candidate(x=1, y=1, bound=1000), [2])\n assert answers_match(candidate(x=2, y=10, bound=1024), [129, 2, 3, 132, 5, 257, 513, 9, 138, 11, 12, 266, 14, 522, 17, 18, 26, 33, 164, 42, 65, 74, 228, 101, 102, 356, 104, 1001, 1002, 612, 1004, 108, 1008, 116, 1016])\n assert answers_match(candidate(x=2, y=3, bound=100000), [513, 2, 3, 4, 5, 515, 7, 1025, 9, 10, 11, 521, 13, 1033, 2057, 4105, 17, 8201, 19, 16387, 32771, 65539, 25, 539, 28, 29, 1051, 31, 2075, 33, 6689, 35, 4123, 41, 43, 16393, 16385, 1027, 32777, 65545, 59, 32769, 65, 67, 2049, 73, 2051, 593, 82, 83, 1105, 85, 2129, 4177, 8273, 89, 16465, 91, 33497, 66265, 65537, 97, 113, 129, 131, 75433, 91817, 4097, 85219, 16411, 137, 32795, 2699, 2188, 2189, 3211, 2191, 4235, 145, 4099, 2195, 6283, 2203, 155, 6817, 59561, 59050, 59051, 2219, 59053, 60073, 61097, 63145, 59057, 67241, 59065, 16627, 33011, 59081, 65779, 2251, 209, 22945, 36067, 52451, 1241, 730, 731, 1753, 733, 2777, 4825, 8921, 737, 17113, 20195, 19684, 19685, 20707, 19687, 21731, 745, 59113, 19691, 23779, 39329, 65563, 19699, 244, 245, 755, 247, 1267, 761, 2291, 251, 4339, 18571, 34955, 67723, 257, 259, 19715, 8193, 72097, 265, 2315, 8195, 275, 793, 283, 19747, 59177, 307, 337, 857, 19811, 371, 8219, 2443, 32849, 65617, 7073, 6562, 6563, 7585, 6565, 8609, 10657, 14753, 6569, 59305, 6577, 6593, 8435, 27875, 985, 6625, 19939, 499, 10379])\n assert answers_match(candidate(x=3, y=7, bound=200), [2, 34, 4, 130, 8, 10, 76, 16, 50, 82, 52, 88, 58, 28])\n assert answers_match(candidate(x=1, y=2, bound=1024), [33, 2, 3, 65, 5, 129, 257, 513, 9, 17])\n assert answers_match(candidate(x=17, y=19, bound=300), [2, 290, 36, 18, 20])\n assert answers_match(candidate(x=7, y=4, bound=200), [65, 2, 5, 71, 8, 11, 17, 50, 113, 53, 23])\n assert answers_match(candidate(x=50, y=50, bound=10000), [2, 100, 2501, 5000, 51, 2550])\n assert answers_match(candidate(x=2, y=1, bound=1024), [33, 2, 3, 65, 5, 129, 257, 513, 9, 17])\n assert answers_match(candidate(x=97, y=99, bound=100000), [2, 98, 196, 100, 9410, 9508, 9802, 9898, 19210])\n assert answers_match(candidate(x=5, y=5, bound=50), [2, 6, 10, 50, 26, 30])\n assert answers_match(candidate(x=7, y=5, bound=200), [32, 2, 132, 6, 8, 74, 12, 174, 50, 54, 26, 126])\n assert answers_match(candidate(x=2, y=3, bound=20), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19])\n assert answers_match(candidate(x=3, y=7, bound=300), [2, 34, 4, 130, 292, 8, 10, 250, 76, 16, 50, 82, 52, 244, 88, 58, 28])\n assert answers_match(candidate(x=3, y=7, bound=100), [2, 34, 4, 8, 10, 76, 16, 50, 82, 52, 88, 58, 28])\n assert answers_match(candidate(x=2, y=3, bound=10000), [513, 2, 3, 4, 5, 515, 7, 1025, 9, 10, 11, 521, 13, 1033, 2057, 4105, 17, 8201, 19, 25, 539, 28, 29, 1051, 31, 2075, 33, 6689, 35, 4123, 41, 43, 1027, 59, 65, 67, 2049, 73, 2051, 593, 82, 83, 1105, 85, 2129, 4177, 8273, 89, 91, 97, 113, 129, 131, 4097, 137, 2699, 2188, 2189, 3211, 2191, 4235, 145, 4099, 2195, 6283, 2203, 155, 6817, 2219, 2251, 209, 1241, 730, 731, 1753, 733, 2777, 4825, 8921, 737, 745, 755, 244, 245, 1267, 247, 2291, 761, 4339, 251, 8435, 257, 259, 8193, 265, 2315, 8195, 275, 793, 283, 307, 337, 857, 371, 8219, 2443, 7073, 6562, 6563, 7585, 6565, 8609, 6569, 6577, 6593, 985, 6625, 499])\n assert answers_match(candidate(x=9, y=3, bound=300), [2, 162, 4, 36, 10, 12, 108, 82, 18, 244, 252, 84, 90, 28])\n assert answers_match(candidate(x=3, y=7, bound=50), [2, 34, 4, 8, 10, 16, 50, 28])\n assert answers_match(candidate(x=7, y=11, bound=100), [2, 8, 12, 18, 50, 60])\n assert answers_match(candidate(x=13, y=17, bound=5000), [2, 290, 2214, 170, 458, 14, 302, 4926, 4914, 18, 2198, 2486, 186, 30])\n assert answers_match(candidate(x=5, y=3, bound=100), [32, 2, 34, 4, 6, 8, 10, 14, 82, 52, 86, 26, 28])\n assert answers_match(candidate(x=2, y=3, bound=100), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25, 28, 29, 31, 33, 35, 41, 43, 59, 65, 67, 73, 82, 83, 85, 89, 91, 97])\n assert answers_match(candidate(x=3, y=7, bound=500), [2, 130, 4, 8, 10, 16, 28, 34, 292, 424, 50, 52, 58, 76, 82, 344, 88, 346, 352, 370, 244, 250])\n assert answers_match(candidate(x=10, y=10, bound=10000), [2, 101, 200, 1001, 11, 1100, 110, 2000, 1010, 20])\n assert answers_match(candidate(x=7, y=3, bound=100), [2, 34, 4, 8, 10, 76, 16, 82, 50, 52, 88, 58, 28])\n assert answers_match(candidate(x=3, y=2, bound=50), [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25, 28, 29, 31, 33, 35, 41, 43])\n assert answers_match(candidate(x=7, y=2, bound=100), [33, 2, 3, 65, 5, 39, 8, 9, 71, 11, 15, 17, 50, 51, 81, 53, 23, 57])\n assert answers_match(candidate(x=3, y=3, bound=81), [2, 4, 36, 6, 10, 12, 18, 54, 28, 30])\n assert answers_match(candidate(x=2, y=1, bound=100), [33, 2, 3, 65, 5, 9, 17])\n assert answers_match(candidate(x=5, y=5, bound=200), [2, 130, 6, 10, 50, 150, 30, 26, 126])\n assert answers_match(candidate(x=1, y=2, bound=15), [9, 2, 3, 5])\n assert answers_match(candidate(x=2, y=2, bound=1024), [128, 129, 2, 3, 257, 5, 513, 4, 6, 9, 10, 130, 8, 12, 136, 264, 16, 17, 18, 258, 20, 144, 272, 528, 24, 132, 640, 514, 768, 260, 32, 33, 34, 160, 36, 516, 288, 544, 40, 1024, 256, 48, 520, 64, 65, 66, 192, 68, 320, 576, 384, 72, 80, 512, 96])\n assert answers_match(candidate(x=5, y=5, bound=1000), [2, 130, 6, 10, 650, 250, 750, 626, 50, 630, 30, 150, 26, 126])\n assert answers_match(candidate(x=2, y=2, bound=64), [2, 3, 4, 5, 6, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 36, 40, 48, 64])\n", "comparison": "unordered"}, "public_tests": ["2\n3\n10", "3\n5\n15"], "hints": [], "metadata": {"canonical_parameter_names": ["x", "y", "bound"], "leetcode_dataset_entry_point": "Solution().powerfulIntegers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:14+00:00", "tests_total": 82, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["hash-table", "math", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def powerfulIntegers(self, x: int, y: int, bound: int) -> list[int]:", "container": "Solution", "callable": "powerfulIntegers", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "bound", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 972, "task_id": "equal-rational-numbers", "difficulty": "Hard", "problem_description": "Given two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.\n\nA rational number can be represented using up to three parts: , , and a . The number will be represented in one of the following three ways:\n\n- \n - For example, 12, 0, and 123.\n- <.>\n - For example, 0.5, 1., 2.12, and 123.0001.\n- <.><(><)>\n - For example, 0.1(6), 1.(9), 123.00(1212).\n\nThe repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:\n\n- 1/6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66).\n\nExample 1:\n\nInput: s = \"0.(52)\", t = \"0.5(25)\"\nOutput: true\nExplanation: Because \"0.(52)\" represents 0.52525252..., and \"0.5(25)\" represents 0.52525252525..... , the strings represent the same number.\n\nExample 2:\n\nInput: s = \"0.1666(6)\", t = \"0.166(66)\"\nOutput: true\n\nExample 3:\n\nInput: s = \"0.9(9)\", t = \"1.\"\nOutput: true\nExplanation: \"0.9(9)\" represents 0.999999999... repeated forever, which equals 1. [See this link for an explanation.]\n\"1.\" represents the number 1, which is formed correctly: (IntegerPart) = \"1\" and (NonRepeatingPart) = \"\".\n\nConstraints:\n\n- Each part consists only of digits.\n- The does not have leading zeros (except for the zero itself).\n- 1 <= .length <= 4\n- 0 <= .length <= 4\n- 1 <= .length <= 4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"0.123\",t = \"0.123\") == True\n assert candidate(s = \"0.(9)\",t = \"1\") == True\n assert candidate(s = \"0.0(0)\",t = \"0\") == True\n assert candidate(s = \"0.9(99)\",t = \"1.0\") == True\n assert candidate(s = \"0.00(1)\",t = \"0.01\") == False\n assert candidate(s = \"0.\",t = \"0.(0)\") == True\n assert candidate(s = \"0.(52)\",t = \"0.5(25)\") == True\n assert candidate(s = \"0.5\",t = \"0.5\") == True\n assert candidate(s = \"1.0(0)\",t = \"1.0\") == True\n assert candidate(s = \"0.1666(6)\",t = \"0.166(66)\") == True\n assert candidate(s = \"123.\",t = \"123\") == True\n assert candidate(s = \"0.(123)\",t = \"0.123123\") == False\n assert candidate(s = \"0.5\",t = \"0.50000\") == True\n assert candidate(s = \"123.456\",t = \"123.456(0)\") == True\n assert candidate(s = \"3.(14)\",t = \"3.141414\") == False\n assert candidate(s = \"0.\",t = \"0.0(0)\") == True\n assert candidate(s = \"0.1(1)\",t = \"0.1111\") == False\n assert candidate(s = \"3.14159\",t = \"3.14159\") == True\n assert candidate(s = \"0.0(1)\",t = \"0.0101\") == False\n assert candidate(s = \"0.9(9)\",t = \"1.\") == True\n assert candidate(s = \"2.5(0)\",t = \"2.5\") == True\n assert candidate(s = \"1.\",t = \"1.0\") == True\n assert candidate(s = \"0.(1)\",t = \"0.1111(1)\") == True\n assert candidate(s = \"123.0001\",t = \"123.0(001)\") == False\n assert candidate(s = \"0.1(9)\",t = \"0.2\") == True\n assert candidate(s = \"0.0(5)\",t = \"0.050505\") == False\n assert candidate(s = \"0.(123)\",t = \"0.123(123)\") == True\n assert candidate(s = \"1(0)\",t = \"1.0\") == True\n assert candidate(s = \"3.(3)\",t = \"3.333333(3)\") == True\n assert candidate(s = \"0.(999)\",t = \"1\") == True\n assert candidate(s = \"0.(0)\",t = \"0.000000000000000000000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"0.(111)\",t = \"0.111111111111111\") == True\n assert candidate(s = \"0.(111)\",t = \"0.111(111)\") == True\n assert candidate(s = \"5.0(00)\",t = \"5.0\") == True\n assert candidate(s = \"0.(12)\",t = \"0.121212121212\") == True\n assert candidate(s = \"0.(1)\",t = \"0.11111111111111111111\") == True\n assert candidate(s = \"999.(9)\",t = \"1000\") == True\n assert candidate(s = \"3.14159(26)\",t = \"3.1415926(26)\") == True\n assert candidate(s = \"0.00001(0)\",t = \"0.00001\") == True\n assert candidate(s = \"0.0(0001)\",t = \"0.0001(0001)\") == False\n assert candidate(s = \"0.0(0)\",t = \"0.0\") == True\n assert candidate(s = \"0.1(234)\",t = \"0.1234234\") == False\n assert candidate(s = \"999999.(9)\",t = \"1000000.\") == True\n assert candidate(s = \"0.(012)\",t = \"0.012012012\") == True\n assert candidate(s = \"0.0(9)\",t = \"0.1\") == True\n assert candidate(s = \"4.5(00)\",t = \"4.5\") == True\n assert candidate(s = \"999.999(9)\",t = \"1000.0\") == True\n assert candidate(s = \"123.123(123)\",t = \"123.123123123\") == True\n assert candidate(s = \"2.345(678)\",t = \"2.345678678\") == True\n assert candidate(s = \"2.5(9)\",t = \"2.6\") == True\n assert candidate(s = \"123456789.999(9)\",t = \"123456790.0\") == True\n assert candidate(s = \"0.(1)\",t = \"0.1111111111111111\") == True\n assert candidate(s = \"0.123456(789)\",t = \"0.123456789789\") == True\n assert candidate(s = \"0.000(999)\",t = \"0.001\") == True\n assert candidate(s = \"123.4567(8901)\",t = \"123.45678901(8901)\") == True\n assert candidate(s = \"0.(001)\",t = \"0.001001\") == False\n assert candidate(s = \"0.1(01)\",t = \"0.101(01)\") == True\n assert candidate(s = \"0.00001(0)\",t = \"0.00001(00)\") == True\n assert candidate(s = \"0.111(1)\",t = \"0.1111(1)\") == True\n assert candidate(s = \"0.0(123)\",t = \"0.0123123123\") == True\n assert candidate(s = \"0.1(2)\",t = \"0.121212\") == False\n assert candidate(s = \"0.123(456)\",t = \"0.123456456456\") == True\n assert candidate(s = \"0.(1234)\",t = \"0.123412341234\") == True\n assert candidate(s = \"0.(01)\",t = \"0.010101\") == False\n assert candidate(s = \"12.(34)\",t = \"12.3434(34)\") == True\n assert candidate(s = \"999.999(9)\",t = \"1000\") == True\n assert candidate(s = \"0.(111)\",t = \"0.1111(111)\") == True\n assert candidate(s = \"1.0(0)\",t = \"1\") == True\n assert candidate(s = \"100.(001)\",t = \"100.001001001\") == True\n assert candidate(s = \"0.(0)\",t = \"0\") == True\n assert candidate(s = \"0.123(456)\",t = \"0.123456456\") == True\n assert candidate(s = \"0.12(345)\",t = \"0.12345(345)\") == True\n assert candidate(s = \"100.(0)\",t = \"100\") == True\n assert candidate(s = \"1000.0001(0)\",t = \"1000.0001\") == True\n assert candidate(s = \"0.000(001)\",t = \"0.000001001001001001001001001001001001001001001001001001001001001\") == True\n assert candidate(s = \"0.1(2345)\",t = \"0.123452345\") == True\n assert candidate(s = \"1.23(456)\",t = \"1.23456456\") == False\n assert candidate(s = \"0.5555(5)\",t = \"0.5556(5)\") == False\n assert candidate(s = \"0.(999)\",t = \"1.0\") == True\n assert candidate(s = \"123456789.000(0001)\",t = \"123456789.0000001000100010001\") == True\n assert candidate(s = \"123.(456)\",t = \"123.456456\") == False\n assert candidate(s = \"0.9(99)\",t = \"1\") == True\n assert candidate(s = \"0.(999)\",t = \"1.000\") == True\n assert candidate(s = \"5.0(5)\",t = \"5.05(5)\") == True\n assert candidate(s = \"1.(0)\",t = \"1\") == True\n assert candidate(s = \"0.1(1)\",t = \"0.1111111111111111\") == True\n assert candidate(s = \"0.(12)\",t = \"0.1212121212121212\") == True\n assert candidate(s = \"0.1234(567)\",t = \"0.1234567567\") == True\n assert candidate(s = \"0.1(0)\",t = \"0.1\") == True\n assert candidate(s = \"0.000(0)\",t = \"0\") == True\n assert candidate(s = \"0.5(0)\",t = \"0.5\") == True\n assert candidate(s = \"0.000(009)\",t = \"0.000009009\") == True\n assert candidate(s = \"0.(5)\",t = \"0.5(5)\") == True\n assert candidate(s = \"0.(3)\",t = \"0.333(3)\") == True\n assert candidate(s = \"0.(1)\",t = \"0.111111111111111111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"0.0000001(0)\",t = \"0.0000001\") == True\n assert candidate(s = \"0.00(123)\",t = \"0.00123123123\") == True\n assert candidate(s = \"0.0(999)\",t = \"0.1\") == True\n assert candidate(s = \"0.(01)\",t = \"0.01010101\") == True\n assert candidate(s = \"0.1(2345)\",t = \"0.12345(2345)\") == True\n assert candidate(s = \"0.1(3)\",t = \"0.133333333333333333333333333333333333333333333333333333333333333333333\") == True\n assert candidate(s = \"999.(9)\",t = \"1000.0\") == True\n assert candidate(s = \"0.12345678(9)\",t = \"0.12345678989\") == True\n assert candidate(s = \"10.0(000)\",t = \"10.0\") == True\n assert candidate(s = \"123.(0)\",t = \"123\") == True\n assert candidate(s = \"100.0001(0)\",t = \"100.0001\") == True\n assert candidate(s = \"0.9(9)\",t = \"1\") == True\n assert candidate(s = \"0.999(999)\",t = \"1.000\") == True\n assert candidate(s = \"0.0000(1)\",t = \"0.0001\") == False\n assert candidate(s = \"1.000(0)\",t = \"1\") == True\n assert candidate(s = \"0.0(000)\",t = \"0\") == True\n assert candidate(s = \"0.(111)\",t = \"0.11111111\") == False\n assert candidate(s = \"0.0(001)\",t = \"0.0001(001)\") == True\n assert candidate(s = \"0.00(1)\",t = \"0.001(0)\") == False\n assert candidate(s = \"42.(0)\",t = \"42.0\") == True\n assert candidate(s = \"0.000(9)\",t = \"0.001\") == True\n assert candidate(s = \"0.0000(0001)\",t = \"0.000000010001\") == True\n assert candidate(s = \"0.1(6)\",t = \"0.166666666666\") == True\n assert candidate(s = \"3.0000(0)\",t = \"3.0\") == True\n assert candidate(s = \"0.000(001)\",t = \"0.000001(001)\") == True\n assert candidate(s = \"1.9(9)\",t = \"2.0\") == True\n assert candidate(s = \"123.456(789)\",t = \"123.456789789789\") == True\n assert candidate(s = \"0.12(34)\",t = \"0.12343434\") == False\n assert candidate(s = \"0.5(00)\",t = \"0.5\") == True\n assert candidate(s = \"0.999(9)\",t = \"1.0\") == True\n assert candidate(s = \"0.999(9)\",t = \"0.999999(999)\") == True\n assert candidate(s = \"0.999(9)\",t = \"1\") == True\n assert candidate(s = \"1.0(0)\",t = \"1.00(0)\") == True\n assert candidate(s = \"123.456(789)\",t = \"123.456789789\") == True\n assert candidate(s = \"1.234(567)\",t = \"1.234567(567)\") == True\n assert candidate(s = \"0.(010)\",t = \"0.0101010\") == False\n assert candidate(s = \"0.1234(5678)\",t = \"0.12345678(5678)\") == True\n assert candidate(s = \"0.000(1)\",t = \"0.0001(0)\") == False\n assert candidate(s = \"0.0001(0001)\",t = \"0.000100010001\") == True\n assert candidate(s = \"123.456(7890)\",t = \"123.45678907890\") == True\n assert candidate(s = \"0.(01)\",t = \"0.0101010101\") == True\n assert candidate(s = \"0.999999(9)\",t = \"1.0\") == True\n assert candidate(s = \"0.(001)\",t = \"0.001(001)\") == True\n assert candidate(s = \"0.(12)\",t = \"0.121212\") == False\n assert candidate(s = \"0.0(99)\",t = \"0.1\") == True\n assert candidate(s = \"12.(34)\",t = \"12.34(34)\") == True\n assert candidate(s = \"0.00(9)\",t = \"0.01\") == True\n assert candidate(s = \"0.9(999)\",t = \"1\") == True\n assert candidate(s = \"0.1(234)\",t = \"0.1234(234)\") == True\n assert candidate(s = \"5.000(0)\",t = \"5.0\") == True\n assert candidate(s = \"100.0000(9)\",t = \"100.0001\") == True\n assert candidate(s = \"1234.5678(9)\",t = \"1234.5679(0)\") == True\n assert candidate(s = \"0.5(5)\",t = \"0.55(55)\") == True\n assert candidate(s = \"1.234(5678)\",t = \"1.23456785678\") == True\n assert candidate(s = \"123.456(789)\",t = \"123.456789(789)\") == True\n assert candidate(s = \"0.(0)\",t = \"0.0\") == True\n assert candidate(s = \"0.00(000)\",t = \"0.0\") == True\n assert candidate(s = \"0.123(456)\",t = \"0.123456(456)\") == True\n assert candidate(s = \"0.001(002)\",t = \"0.001002(002)\") == True\n assert candidate(s = \"2.4(9)\",t = \"2.5\") == True\n", "comparison": "exact"}, "public_tests": ["\"0.(52)\"\n\"0.5(25)\"", "\"0.1666(6)\"\n\"0.166(66)\"", "\"0.9(9)\"\n\"1.\""], "hints": [], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().isRationalEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:18+00:00", "tests_total": 155, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def isRationalEqual(self, s: str, t: str) -> bool:", "container": "Solution", "callable": "isRationalEqual", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 973, "task_id": "k-closest-points-to-origin", "difficulty": "Medium", "problem_description": "Given an array of points where points[i] = [x_i, y_i] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).\n\nThe distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x_1 - x_2)^2 + (y_1 - y_2)^2).\n\nYou may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in).\n\nExample 1:\n\nInput: points = [[1,3],[-2,2]], k = 1\nOutput: [[-2,2]]\nExplanation:\nThe distance between (1, 3) and the origin is sqrt(10).\nThe distance between (-2, 2) and the origin is sqrt(8).\nSince sqrt(8) < sqrt(10), (-2, 2) is closer to the origin.\nWe only want the closest k = 1 points from the origin, so the answer is just [[-2,2]].\n\nExample 2:\n\nInput: points = [[3,3],[5,-1],[-2,4]], k = 2\nOutput: [[3,3],[-2,4]]\nExplanation: The answer [[-2,4],[3,3]] would also be accepted.\n\nConstraints:\n\n- 1 <= k <= points.length <= 10^4\n- -10^4 <= x_i, y_i <= 10^4\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], k=3), [[0, 0], [1, 1], [2, 2]])\n assert answers_match(candidate(points=[[3, 3], [5, -1], [-2, 4]], k=2), [[3, 3], [-2, 4]])\n assert answers_match(candidate(points=[[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]], k=4), [[0, 0], [-1, -1], [1, 1], [-2, -2]])\n assert answers_match(candidate(points=[[10000, -10000], [-10000, 10000], [0, 0]], k=2), [[0, 0], [10000, -10000]])\n assert answers_match(candidate(points=[[1, 3], [-2, 2]], k=1), [[-2, 2]])\n assert answers_match(candidate(points=[[1, 3], [2, 4], [3, 1]], k=2), [[1, 3], [3, 1]])\n assert answers_match(candidate(points=[[-1, 0], [2, 0], [-1, 0], [2, 0]], k=3), [[-1, 0], [-1, 0], [2, 0]])\n assert answers_match(candidate(points=[[-10000, -10000], [10000, 10000]], k=1), [[-10000, -10000]])\n assert answers_match(candidate(points=[[-1, 0], [2, 0], [-1, 0], [2, 0]], k=2), [[-1, 0], [-1, 0]])\n assert answers_match(candidate(points=[[0, 1], [1, 0]], k=2), [[0, 1], [1, 0]])\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], k=5), [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]])\n assert answers_match(candidate(points=[[6, 10], [-3, 3], [-2, 5], [0, 2]], k=3), [[0, 2], [-3, 3], [-2, 5]])\n assert answers_match(candidate(points=[[-10000, 10000], [10000, -10000]], k=1), [[-10000, 10000]])\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]], k=5), [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]])\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3]], k=3), [[0, 0], [1, 1], [2, 2]])\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3]], k=2), [[0, 0], [1, 1]])\n assert answers_match(candidate(points=[[-5, 4], [4, -5], [0, 0], [1, 1], [-1, -1], [5, -5], [-5, 5], [2, 2], [-2, -2]], k=5), [[0, 0], [1, 1], [-1, -1], [2, 2], [-2, -2]])\n assert answers_match(candidate(points=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]], k=7), [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0]])\n assert answers_match(candidate(points=[[10000, 0], [0, 10000], [-10000, 0], [0, -10000], [2500, 2500], [2500, -2500], [-2500, 2500], [-2500, -2500], [0, 0]], k=6), [[0, 0], [2500, 2500], [2500, -2500], [-2500, 2500], [-2500, -2500], [10000, 0]])\n assert answers_match(candidate(points=[[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700]], k=5), [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]])\n assert answers_match(candidate(points=[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [-1, 0], [-2, 0], [-3, 0], [-4, 0], [-5, 0], [-6, 0], [-7, 0], [-8, 0], [-9, 0], [-10, 0]], k=10), [[1, 0], [-1, 0], [2, 0], [-2, 0], [3, 0], [-3, 0], [4, 0], [-4, 0], [5, 0], [-5, 0]])\n assert answers_match(candidate(points=[[-1, 0], [0, -1], [1, 0], [0, 1], [-2, 0], [0, -2], [2, 0], [0, 2], [-3, 0], [0, -3], [3, 0], [0, 3], [-4, 0], [0, -4], [4, 0], [0, 4]], k=8), [[-1, 0], [0, -1], [1, 0], [0, 1], [-2, 0], [0, -2], [2, 0], [0, 2]])\n assert answers_match(candidate(points=[[100, 100], [-100, -100], [200, 200], [-200, -200], [300, 300], [-300, -300], [0, 0]], k=4), [[0, 0], [100, 100], [-100, -100], [200, 200]])\n assert answers_match(candidate(points=[[-10, 10], [-20, 20], [-30, 30], [-40, 40], [-50, 50], [-60, 60], [-70, 70], [-80, 80], [-90, 90], [-100, 100]], k=3), [[-10, 10], [-20, 20], [-30, 30]])\n assert answers_match(candidate(points=[[-1, 0], [0, -1], [1, 0], [0, 1], [0, 0]], k=3), [[0, 0], [-1, 0], [0, -1]])\n assert answers_match(candidate(points=[[100, -100], [-100, 100], [200, 200], [-200, -200], [300, -300], [-300, 300], [400, 400], [-400, -400], [500, -500]], k=3), [[100, -100], [-100, 100], [200, 200]])\n assert answers_match(candidate(points=[[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]], k=4), [[100, 100], [200, 200], [300, 300], [400, 400]])\n assert answers_match(candidate(points=[[0, 0], [1, 1], [1, -1], [-1, -1], [-1, 1], [2, 2], [-2, -2]], k=5), [[0, 0], [1, 1], [1, -1], [-1, -1], [-1, 1]])\n assert answers_match(candidate(points=[[-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=6), [[-5, -5], [5, 5], [-6, -6], [6, 6], [-7, -7], [7, 7]])\n assert answers_match(candidate(points=[[10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0], [100, 0]], k=7), [[10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0]])\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], k=5), [[0, 0], [-1, -1], [1, 1], [2, 2], [3, 3]])\n assert answers_match(candidate(points=[[-9999, -9999], [9999, 9999], [5000, 5000], [-5000, -5000], [1000, -1000], [-1000, 1000], [2000, -2000], [-2000, 2000]], k=4), [[1000, -1000], [-1000, 1000], [2000, -2000], [-2000, 2000]])\n assert answers_match(candidate(points=[[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]], k=5), [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5]])\n assert answers_match(candidate(points=[[-8000, 8000], [8000, -8000], [-7000, 7000], [7000, -7000], [-6000, 6000], [6000, -6000], [-5000, 5000], [5000, -5000], [-4000, 4000], [4000, -4000]], k=3), [[-4000, 4000], [4000, -4000], [-5000, 5000]])\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [-1, -1], [-1, 1], [1, -1]], k=6), [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [1, 1]])\n assert answers_match(candidate(points=[[100, -100], [-100, 100], [200, -200], [-200, 200], [300, -300]], k=3), [[100, -100], [-100, 100], [200, -200]])\n assert answers_match(candidate(points=[[-1000, 0], [0, -1000], [1000, 0], [0, 1000], [500, 500], [-500, -500]], k=3), [[500, 500], [-500, -500], [-1000, 0]])\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [-1, -1], [-1, 0], [0, -1]], k=5), [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1]])\n assert answers_match(candidate(points=[[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2], [3, 3], [3, -3], [-3, 3], [-3, -3]], k=6), [[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2]])\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]], k=5), [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]])\n assert answers_match(candidate(points=[[-500, 500], [500, -500], [-100, 100], [100, -100], [0, 0], [200, -200]], k=4), [[0, 0], [-100, 100], [100, -100], [200, -200]])\n assert answers_match(candidate(points=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]], k=8), [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0]])\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]], k=4), [[1, 2], [3, 4], [5, 6], [7, 8]])\n assert answers_match(candidate(points=[[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]], k=1), [[100, 100]])\n assert answers_match(candidate(points=[[-999, -999], [999, 999], [0, 0], [499, 499], [-499, -499], [500, 500], [-500, -500]], k=5), [[0, 0], [499, 499], [-499, -499], [500, 500], [-500, -500]])\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]], k=5), [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])\n assert answers_match(candidate(points=[[-5000, 5000], [-4000, 4000], [-3000, 3000], [-2000, 2000], [-1000, 1000]], k=3), [[-1000, 1000], [-2000, 2000], [-3000, 3000]])\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]], k=8), [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80]])\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]], k=3), [[10, 10], [20, 20], [30, 30]])\n assert answers_match(candidate(points=[[10, 10], [-10, -10], [5, 5], [-5, -5], [0, 0], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4]], k=7), [[0, 0], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4]])\n assert answers_match(candidate(points=[[-100, -100], [100, 100], [-200, -200], [200, 200], [-300, -300], [300, 300], [-400, -400], [400, 400], [-500, -500], [500, 500]], k=7), [[-100, -100], [100, 100], [-200, -200], [200, 200], [-300, -300], [300, 300], [-400, -400]])\n assert answers_match(candidate(points=[[10, 0], [-10, 0], [0, 10], [0, -10], [5, 5], [-5, -5]], k=2), [[5, 5], [-5, -5]])\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]], k=7), [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7]])\n assert answers_match(candidate(points=[[9999, 9999], [-9999, -9999], [0, 0], [5000, 5000], [-5000, -5000], [1, -1], [-1, 1]], k=3), [[0, 0], [1, -1], [-1, 1]])\n assert answers_match(candidate(points=[[-5000, -5000], [-4000, -4000], [-3000, -3000], [-2000, -2000], [-1000, -1000], [0, 0], [1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000], [10000, -10000], [-10000, 10000]], k=6), [[0, 0], [-1000, -1000], [1000, 1000], [-2000, -2000], [2000, 2000], [-3000, -3000]])\n assert answers_match(candidate(points=[[-1, 1], [1, -1], [-2, 2], [2, -2], [-3, 3], [3, -3]], k=3), [[-1, 1], [1, -1], [-2, 2]])\n assert answers_match(candidate(points=[[-5000, 5000], [5000, -5000], [0, 0], [-3000, -3000], [3000, 3000]], k=3), [[0, 0], [-3000, -3000], [3000, 3000]])\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]], k=5), [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]])\n assert answers_match(candidate(points=[[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10], [-10, -11], [-11, -12], [-12, -13], [-13, -14]], k=8), [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9]])\n assert answers_match(candidate(points=[[1, 1], [-1, -1], [0, 0], [2, 2], [-2, -2], [3, 3], [-3, -3]], k=4), [[0, 0], [1, 1], [-1, -1], [2, 2]])\n assert answers_match(candidate(points=[[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [-100, -100], [-200, -200], [-300, -300], [-400, -400], [-500, -500]], k=6), [[100, 100], [-100, -100], [200, 200], [-200, -200], [300, 300], [-300, -300]])\n assert answers_match(candidate(points=[[-1000, 1000], [1000, -1000], [0, 0], [500, 500], [-500, -500], [250, 250], [-250, -250]], k=4), [[0, 0], [250, 250], [-250, -250], [500, 500]])\n assert answers_match(candidate(points=[[-5000, 5000], [5000, -5000], [10000, 0], [0, 10000], [-10000, 0], [0, -10000]], k=3), [[-5000, 5000], [5000, -5000], [10000, 0]])\n assert answers_match(candidate(points=[[-1000, 0], [1000, 0], [0, -1000], [0, 1000], [-500, -500], [500, 500], [-500, 500], [500, -500], [250, 250], [750, 750]], k=6), [[250, 250], [-500, -500], [500, 500], [-500, 500], [500, -500], [-1000, 0]])\n assert answers_match(candidate(points=[[100, 100], [-100, -100], [0, 0], [200, 200], [-200, -200], [50, 50], [-50, -50], [75, 75], [-75, -75]], k=6), [[0, 0], [50, 50], [-50, -50], [75, 75], [-75, -75], [100, 100]])\n assert answers_match(candidate(points=[[-9999, 10000], [10000, -9999], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]], k=5), [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])\n assert answers_match(candidate(points=[[1, -1], [-1, 1], [1, 1], [-1, -1], [0, 0], [2, 2], [-2, -2], [2, -2], [-2, 2]], k=4), [[0, 0], [1, -1], [-1, 1], [1, 1]])\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [-6, 6], [-7, 7], [-8, 8], [-9, 9], [-10, 10]], k=5), [[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5]])\n assert answers_match(candidate(points=[[10000, 10000], [-10000, -10000], [5000, 5000], [-5000, -5000], [0, 0]], k=3), [[0, 0], [5000, 5000], [-5000, -5000]])\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [-1, -1], [-1, 0], [0, -1], [1, -1], [-1, 1], [0, 2], [2, 0]], k=5), [[0, 0], [0, 1], [1, 0], [-1, 0], [0, -1]])\n assert answers_match(candidate(points=[[-5000, -5000], [5000, 5000], [0, 0], [100, 100], [-100, -100]], k=4), [[0, 0], [100, 100], [-100, -100], [-5000, -5000]])\n assert answers_match(candidate(points=[[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0], [0, 1], [1, 0], [0, -1], [-2, 2], [2, -2]], k=5), [[0, 0], [0, 1], [1, 0], [0, -1], [-1, -1]])\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [-2, -2], [0, 1], [1, 0], [-3, -3], [0, 2], [2, 0], [-4, -4]], k=5), [[0, 0], [0, 1], [1, 0], [-1, -1], [1, 1]])\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]], k=5), [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])\n assert answers_match(candidate(points=[[500, 500], [-500, -500], [500, -500], [-500, 500], [0, 0], [1000, 0], [0, 1000], [-1000, 0], [0, -1000]], k=5), [[0, 0], [500, 500], [-500, -500], [500, -500], [-500, 500]])\n assert answers_match(candidate(points=[[-5000, -5000], [-7000, 7000], [8000, -8000], [6000, 6000]], k=2), [[-5000, -5000], [6000, 6000]])\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]], k=3), [[1, 2], [3, 4], [5, 6]])\n assert answers_match(candidate(points=[[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900]], k=6), [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]])\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]], k=4), [[-1, -1], [-2, -2], [-3, -3], [-4, -4]])\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]], k=5), [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]])\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]], k=7), [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7]])\n assert answers_match(candidate(points=[[-9000, 0], [0, -9000], [9000, 0], [0, 9000], [-4500, 4500], [4500, -4500], [-4500, -4500], [4500, 4500]], k=4), [[-4500, 4500], [4500, -4500], [-4500, -4500], [4500, 4500]])\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [0, 0], [-10, -10], [-20, -20], [-30, -30], [-40, -40], [-50, -50]], k=7), [[0, 0], [10, 10], [-10, -10], [20, 20], [-20, -20], [30, 30], [-30, -30]])\n assert answers_match(candidate(points=[[-9999, 9999], [9999, -9999], [1000, 1000], [-1000, -1000]], k=2), [[1000, 1000], [-1000, -1000]])\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]], k=7), [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]])\n assert answers_match(candidate(points=[[0, 10000], [-10000, 0], [10000, 0], [0, -10000], [2500, 2500], [-2500, -2500], [5000, -5000], [-5000, 5000], [7500, 7500]], k=5), [[2500, 2500], [-2500, -2500], [5000, -5000], [-5000, 5000], [0, 10000]])\n assert answers_match(candidate(points=[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]], k=6), [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6]])\n assert answers_match(candidate(points=[[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5]], k=3), [[-5, -5], [-6, -6], [-7, -7]])\n assert answers_match(candidate(points=[[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=15), [[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]])\n assert answers_match(candidate(points=[[-1000, 1000], [1000, -1000], [500, 500], [-500, -500], [750, -750], [-750, 750]], k=4), [[500, 500], [-500, -500], [750, -750], [-750, 750]])\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], k=4), [[1, 2], [2, 3], [3, 4], [4, 5]])\n assert answers_match(candidate(points=[[-8, 6], [5, 0], [3, 1], [-9, 4], [2, -8], [-5, -3], [7, -7], [1, 9], [-4, -10]], k=4), [[3, 1], [5, 0], [-5, -3], [2, -8]])\n assert answers_match(candidate(points=[[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]], k=4), [[0, 0], [1, 2], [2, 4], [3, 6]])\n assert answers_match(candidate(points=[[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000], [6000, 6000], [7000, 7000], [8000, 8000], [9000, 9000], [10000, 10000]], k=5), [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]])\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], k=6), [[0, 0], [-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3]])\n assert answers_match(candidate(points=[[-5, -12], [-10, -24], [-15, -36], [-20, -48], [-25, -60], [-30, -72], [-35, -84], [-40, -96], [-45, -108], [-50, -120]], k=6), [[-5, -12], [-10, -24], [-15, -36], [-20, -48], [-25, -60], [-30, -72]])\n assert answers_match(candidate(points=[[-3, 0], [2, 6], [0, 5], [-4, -4], [8, 3]], k=3), [[-3, 0], [0, 5], [-4, -4]])\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5]], k=4), [[-1, -1], [1, 1], [-2, -2], [2, 2]])\n", "comparison": "unordered"}, "public_tests": ["[[1,3],[-2,2]]\n1", "[[3,3],[5,-1],[-2,4]]\n2"], "hints": [], "metadata": {"canonical_parameter_names": ["points", "k"], "leetcode_dataset_entry_point": "Solution().kClosest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:21+00:00", "tests_total": 98, "tests_dropped": 0, "flags": ["any_order", "has_images"], "topic_tags": ["array", "math", "divide-and-conquer", "geometry", "sorting", "heap-priority-queue", "quickselect", "k-d-tree"]}, "language": "python", "interface": {"raw_signature": "def kClosest(self, points: list[list[int]], k: int) -> list[list[int]]:", "container": "Solution", "callable": "kClosest", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 974, "task_id": "subarray-sums-divisible-by-k", "difficulty": "Medium", "problem_description": "Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [4,5,0,-2,-3,1], k = 5\nOutput: 7\nExplanation: There are 7 subarrays with a sum divisible by k = 5:\n[4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]\n\nExample 2:\n\nInput: nums = [5], k = 9\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length <= 3 * 10^4\n- -10^4 <= nums[i] <= 10^4\n- 2 <= k <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2],k = 6) == 3\n assert candidate(nums = [0, 0, 0, 0],k = 2) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 25\n assert candidate(nums = [-1, 2, -3, 4, -5],k = 2) == 6\n assert candidate(nums = [4, 5, 0, -2, -3, 1],k = 5) == 7\n assert candidate(nums = [2, 2, 2, 2, 2],k = 2) == 15\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == 27\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 7\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == 15\n assert candidate(nums = [-1, -2, -3, 4, 5, 6],k = 2) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7],k = 7) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 17\n assert candidate(nums = [-1, 2, -3, 4, -5, 6],k = 4) == 3\n assert candidate(nums = [-1, -2, -3, 3, 1, 2, 3, -4],k = 3) == 16\n assert candidate(nums = [1, -1, 2, -2, 3, -3],k = 2) == 11\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [5],k = 9) == 0\n assert candidate(nums = [10, 5, 0, 3, -2],k = 7) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 15\n assert candidate(nums = [-1, -2, -3, 4, 5, 6],k = 4) == 3\n assert candidate(nums = [-10, -5, 0, 5, 10],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],k = 4) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 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 = 19) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 27\n assert candidate(nums = [104, -104, 208, -208, 312, -312, 416, -416, 520, -520],k = 104) == 55\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 3) == 34\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 6) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 7) == 55\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 250) == 17\n assert candidate(nums = [-10, 10, -10, 10, -10, 10, -10, 10],k = 5) == 36\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15],k = 11) == 5\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 100) == 55\n assert candidate(nums = [7, 3, 5, 1, 2, 4, 6],k = 7) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 25\n assert candidate(nums = [9999, -9999, 9999, -9999, 9999, -9999],k = 10000) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 55\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 15\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 55\n assert candidate(nums = [1, 0, 2, 1, -1, -1, -1, 0, 1, 2],k = 4) == 11\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 = 3) == 64\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 35\n assert candidate(nums = [3, 1, 2, 5, 3, 2, 3, 1, 2, 3],k = 5) == 9\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],k = 3) == 28\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 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],k = 5) == 34\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) == 210\n assert candidate(nums = [9, -1, -2, 3, 5, -7, 10, -12, 15, -18, 21, -24, 27, -30, 33, -36, 39, -42, 45, -48],k = 15) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 10\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 4) == 14\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],k = 10) == 225\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 100) == 120\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == 21\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == 120\n assert candidate(nums = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991],k = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 13) == 12\n assert candidate(nums = [10, 20, 30, 40, 50],k = 15) == 7\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 1000) == 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],k = 4) == 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 = 13) == 22\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 15) == 7\n assert candidate(nums = [-10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000],k = 10000) == 55\n assert candidate(nums = [15, -15, 30, -30, 45, -45, 60, -60, 75, -75, 90, -90],k = 15) == 78\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 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],k = 3) == 63\n assert candidate(nums = [9999, -9999, 9999, -9999, 9999, -9999, 9999, -9999],k = 9999) == 36\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 106\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10],k = 5) == 45\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5000) == 7\n assert candidate(nums = [2, 3, -5, 6, 1, -7, 8, 9, 10, -11, 12],k = 7) == 12\n assert candidate(nums = [-3, -1, -2, 2, 1, 3],k = 5) == 3\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4],k = 4) == 15\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 2000) == 25\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40],k = 10) == 28\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10000) == 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],k = 6) == 72\n assert candidate(nums = [-10, 10, -10, 10, -10, 10, -10, 10],k = 10) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0],k = 4) == 28\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 120\n assert candidate(nums = [1000, 2000, 3000, -1000, -2000, -3000],k = 1000) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7) == 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 = 7) == 48\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 11) == 5\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000],k = 1000) == 36\n assert candidate(nums = [104, -104, 104, -104, 104, -104, 104, -104, 104, -104],k = 104) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 55\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 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],k = 2) == 225\n assert candidate(nums = [-10, -20, -30, 0, 5, 10, 15, 20],k = 5) == 36\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 = 7) == 210\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 55\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 3) == 55\n assert candidate(nums = [2, -2, 2, -2, 2, -2, 2, -2],k = 4) == 16\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 25\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 27\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144],k = 7) == 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 = 11) == 28\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000],k = 10000) == 15\n assert candidate(nums = [1, 2, 3, -6, 1, 2, 3, 4, 5],k = 7) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 27\n assert candidate(nums = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5],k = 5) == 55\n assert candidate(nums = [2, -2, 2, -4, 6, 5, -1, 3, -3, 4],k = 5) == 8\n", "comparison": "exact"}, "public_tests": ["[4,5,0,-2,-3,1]\n5", "[5]\n9"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().subarraysDivByK", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:23+00:00", "tests_total": 108, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def subarraysDivByK(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "subarraysDivByK", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 975, "task_id": "odd-even-jump", "difficulty": "Hard", "problem_description": "You are given an integer array arr. From some starting index, you can make a series of jumps. The (1^st, 3^rd, 5^th, ...) jumps in the series are called odd-numbered jumps, and the (2^nd, 4^th, 6^th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.\n\nYou may jump forward from index i to index j (with i < j) in the following way:\n\n- During odd-numbered jumps (i.e., jumps 1, 3, 5, ...), you jump to the index j such that arr[i] <= arr[j] and arr[j] is the smallest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.\n- During even-numbered jumps (i.e., jumps 2, 4, 6, ...), you jump to the index j such that arr[i] >= arr[j] and arr[j] is the largest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.\n- It may be the case that for some index i, there are no legal jumps.\n\nA starting index is good if, starting from that index, you can reach the end of the array (index arr.length - 1) by jumping some number of times (possibly 0 or more than once).\n\nReturn the number of good starting indices.\n\nExample 1:\n\nInput: arr = [10,13,12,14,15]\nOutput: 2\nExplanation:\nFrom starting index i = 0, we can make our 1st jump to i = 2 (since arr[2] is the smallest among arr[1], arr[2], arr[3], arr[4] that is greater or equal to arr[0]), then we cannot jump any more.\nFrom starting index i = 1 and i = 2, we can make our 1st jump to i = 3, then we cannot jump any more.\nFrom starting index i = 3, we can make our 1st jump to i = 4, so we have reached the end.\nFrom starting index i = 4, we have reached the end already.\nIn total, there are 2 different starting indices i = 3 and i = 4, where we can reach the end with some number of\njumps.\n\nExample 2:\n\nInput: arr = [2,3,1,1,4]\nOutput: 3\nExplanation:\nFrom starting index i = 0, we make jumps to i = 1, i = 2, i = 3:\nDuring our 1st jump (odd-numbered), we first jump to i = 1 because arr[1] is the smallest value in [arr[1], arr[2], arr[3], arr[4]] that is greater than or equal to arr[0].\nDuring our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because arr[2] is the largest value in [arr[2], arr[3], arr[4]] that is less than or equal to arr[1]. arr[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3\nDuring our 3rd jump (odd-numbered), we jump from i = 2 to i = 3 because arr[3] is the smallest value in [arr[3], arr[4]] that is greater than or equal to arr[2].\nWe can't jump from i = 3 to i = 4, so the starting index i = 0 is not good.\nIn a similar manner, we can deduce that:\nFrom starting index i = 1, we jump to i = 4, so we reach the end.\nFrom starting index i = 2, we jump to i = 3, and then we can't jump anymore.\nFrom starting index i = 3, we jump to i = 4, so we reach the end.\nFrom starting index i = 4, we are already at the end.\nIn total, there are 3 different starting indices i = 1, i = 3, and i = 4, where we can reach the end with some\nnumber of jumps.\n\nExample 3:\n\nInput: arr = [5,1,3,4,2]\nOutput: 3\nExplanation: We can reach the end from starting indices 1, 2, and 4.\n\nConstraints:\n\n- 1 <= arr.length <= 2 * 10^4\n- 0 <= arr[i] < 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [11, 9, 7, 5, 3, 1]) == 1\n assert candidate(arr = [5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 10, 5, 8, 4, 2, 6, 3, 9, 1]) == 8\n assert candidate(arr = [0, 10, 8, 9, 3, 5, 7, 6, 2, 4, 1, 11]) == 11\n assert candidate(arr = [1, 2]) == 2\n assert candidate(arr = [5, 1, 3, 4, 2]) == 3\n assert candidate(arr = [0]) == 1\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6]) == 3\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == 2\n assert candidate(arr = [8, 6, 5, 4, 10, 7, 9, 3, 2, 1]) == 1\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [10, 13, 12, 14, 15]) == 2\n assert candidate(arr = [2, 1]) == 1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5]) == 2\n assert candidate(arr = [1, 2, 3, 2, 1]) == 3\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n assert candidate(arr = [0, 10, 5, 3, 8, 0, 9, 0, 6, 3, 8, 0, 6, 6, 0, 8, 8, 8, 3, 3]) == 13\n assert candidate(arr = [0, 10, 8, 12, 4, 7, 9, 6, 1, 5, 11, 3]) == 9\n assert candidate(arr = [1, 3, 2, 4, 5]) == 2\n assert candidate(arr = [2, 3, 1, 1, 4]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(arr = [1, 2, 2, 1, 2, 1, 2, 1, 2, 1]) == 7\n assert candidate(arr = [50, 40, 30, 20, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50]) == 3\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\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]) == 5\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 4\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 5, 3, 4, 2, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 3\n assert candidate(arr = [15, 13, 14, 11, 10, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(arr = [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]) == 20\n assert candidate(arr = [1, 2, 3, 5, 4, 6, 7, 8, 10, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 2\n assert candidate(arr = [3, 2, 4, 1, 5, 6, 7, 8, 9, 10]) == 2\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]) == 30\n assert candidate(arr = [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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\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]) == 1\n assert candidate(arr = [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]) == 7\n assert candidate(arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 8\n assert candidate(arr = [5, 2, 6, 3, 7, 4, 8, 1, 9]) == 9\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 3\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 3\n assert candidate(arr = [1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 3\n assert candidate(arr = [1, 3, 2, 4, 7, 6, 9, 11, 8, 10]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 9\n assert candidate(arr = [4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 2\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 2\n assert candidate(arr = [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]) == 3\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [20, 18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1]) == 2\n assert candidate(arr = [100, 200, 150, 300, 250, 350, 400, 375, 450, 425]) == 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]) == 2\n assert candidate(arr = [1, 3, 2, 4, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\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, 59]) == 2\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]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 6\n assert candidate(arr = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\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\n assert candidate(arr = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 1\n assert candidate(arr = [5, 2, 6, 4, 1, 7, 8, 3, 9, 0]) == 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]) == 1\n assert candidate(arr = [5, 1, 3, 4, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 4\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 2\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 19, 29, 39, 49, 59, 69, 79, 89]) == 4\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 15\n assert candidate(arr = [1, 5, 2, 4, 3, 6, 8, 7, 9, 10]) == 2\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 20\n assert candidate(arr = [3, 4, 2, 5, 1, 7, 6, 8, 0, 9]) == 10\n assert candidate(arr = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 3\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 2\n assert candidate(arr = [10, 11, 10, 11, 10, 11, 10, 11]) == 6\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, 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]) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(arr = [20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0]) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == 6\n assert candidate(arr = [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]) == 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, 1]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [5, 3, 9, 2, 8, 6, 7, 4, 10, 1]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 38]) == 2\n assert candidate(arr = [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 12\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]) == 12\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(arr = [5, 3, 6, 8, 1, 2, 9, 10, 4, 7]) == 6\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\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]) == 2\n assert candidate(arr = [8, 7, 10, 8, 11, 5, 13, 5, 6, 12]) == 7\n assert candidate(arr = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == 4\n assert candidate(arr = [3, 2, 1, 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]) == 12\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, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 2, 1, 3, 4, 5, 6, 7, 8, 9, 0]) == 18\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 7\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 6, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50]) == 6\n assert candidate(arr = [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]) == 7\n assert candidate(arr = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60]) == 3\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(arr = [1, 5, 2, 3, 4, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [1, 5, 3, 7, 2, 6, 4, 8, 9, 10, 1, 5, 3, 7, 2, 6, 4, 8, 9, 10, 1, 5, 3, 7, 2, 6, 4, 8, 9, 10]) == 5\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3\n assert candidate(arr = [1, 5, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 3\n assert candidate(arr = [10, 20, 30, 20, 10, 40, 50, 60, 70, 80]) == 2\n assert candidate(arr = [7, 2, 5, 1, 6, 3, 4, 8, 9, 0]) == 9\n assert candidate(arr = [5, 3, 8, 6, 9, 1, 7, 4, 2, 10]) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [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]) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(arr = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 7\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 3\n assert candidate(arr = [5, 3, 1, 4, 2, 6]) == 5\n assert candidate(arr = [1, 5, 3, 7, 2, 6, 4, 8, 9, 10, 1, 5, 3, 7, 2, 6, 4, 8, 9, 10]) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 23\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 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]) == 2\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]) == 5\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14, 11, 15, 12, 16, 13, 17, 14, 18, 15, 19, 16, 20]) == 5\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 3\n assert candidate(arr = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\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, 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, 2, 8, 0, 9, 7, 9, 9, 4, 9, 2, 3, 0, 9, 0]) == 54\n assert candidate(arr = [0, 10, 1, 20, 2, 30, 3]) == 4\n assert candidate(arr = [2, 1, 2, 3, 1]) == 4\n assert candidate(arr = [1, 0, 2, 1, 0]) == 3\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 3\n assert candidate(arr = [1, 3, 5, 2, 4, 6]) == 3\n assert candidate(arr = [50, 40, 30, 20, 10]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 6, 7, 8, 9]) == 2\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0]) == 5\n assert candidate(arr = [100, 200, 300, 400, 500]) == 2\n assert candidate(arr = [100, 99, 98, 97, 96, 95]) == 1\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2]) == 4\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 7\n assert candidate(arr = [20, 30, 25, 35, 40, 39, 38, 37, 36, 35]) == 4\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [1, 2, 3, 5, 4, 6, 7]) == 2\n assert candidate(arr = [0, 1, 0, 3, 0, 4, 0, 5, 0, 6]) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 3\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 5\n assert candidate(arr = [2, 2, 2, 2, 2]) == 5\n assert candidate(arr = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(arr = [9, 11, 12]) == 2\n assert candidate(arr = [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 4\n assert candidate(arr = [1, 0, 3, 2, 5, 3, 1, 2, 4]) == 4\n assert candidate(arr = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 8\n assert candidate(arr = [1, 2, 1, 2, 1]) == 4\n assert candidate(arr = [100, 90, 80, 70, 60]) == 1\n assert candidate(arr = [11, 13, 15, 17, 19, 21]) == 2\n assert candidate(arr = [60, 70, 80, 90, 100]) == 2\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 3\n assert candidate(arr = [5, 1, 3, 4, 2, 6, 7, 8, 9, 0]) == 9\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(arr = [10, 20, 30, 40, 50]) == 2\n assert candidate(arr = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [3, 2, 1]) == 1\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 3\n assert candidate(arr = [8, 1, 5, 2, 10, 13, 17, 7, 4, 9, 12]) == 4\n assert candidate(arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 90, 80, 70, 60, 50, 40, 30, 20, 100]) == 9\n assert candidate(arr = [0, 1, 2, 3, 4, 5]) == 2\n assert candidate(arr = [10, 10, 10, 10, 10]) == 5\n assert candidate(arr = [1, 2, 3]) == 2\n assert candidate(arr = [8, 9, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 6\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 8\n assert candidate(arr = [1, 2, 3, 5, 4, 6, 7, 8, 9, 0]) == 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, 21, 22, 23, 24, 25, 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\n assert candidate(arr = [3, 3, 3, 2, 1]) == 1\n assert candidate(arr = [0, 2, 1, 4, 3]) == 3\n assert candidate(arr = [0, 2, 2, 2, 0]) == 3\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [0, 0, 0, 0, 0]) == 5\n", "comparison": "exact"}, "public_tests": ["[10,13,12,14,15]", "[2,3,1,1,4]", "[5,1,3,4,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().oddEvenJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:25+00:00", "tests_total": 205, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "dynamic-programming", "stack", "sorting", "monotonic-stack", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def oddEvenJumps(self, arr: list[int]) -> int:", "container": "Solution", "callable": "oddEvenJumps", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 976, "task_id": "largest-perimeter-triangle", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.\n\nExample 1:\n\nInput: nums = [2,1,2]\nOutput: 5\nExplanation: You can form a triangle with three side lengths: 1, 2, and 2.\n\nExample 2:\n\nInput: nums = [1,2,1,10]\nOutput: 0\nExplanation:\nYou cannot use the side lengths 1, 1, and 2 to form a triangle.\nYou cannot use the side lengths 1, 1, and 10 to form a triangle.\nYou cannot use the side lengths 1, 2, and 10 to form a triangle.\nAs we cannot use any three side lengths to form a triangle of non-zero area, we return 0.\n\nConstraints:\n\n- 3 <= nums.length <= 10^4\n- 1 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 5, 7]) == 22\n assert candidate(nums = [10, 5, 1, 8, 12, 10, 5, 15]) == 37\n assert candidate(nums = [7, 10, 5, 2, 8, 7]) == 25\n assert candidate(nums = [1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [1, 1000000, 1000000]) == 2000001\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [10, 5, 7, 8, 2, 12]) == 30\n assert candidate(nums = [3, 6, 2, 3]) == 8\n assert candidate(nums = [2, 1, 2]) == 5\n assert candidate(nums = [2, 3, 4, 5, 6]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50]) == 120\n assert candidate(nums = [7, 10, 5, 2, 8, 4, 6]) == 25\n assert candidate(nums = [5, 5, 5, 5]) == 15\n assert candidate(nums = [1, 1, 1, 2, 2, 2]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 27\n assert candidate(nums = [2, 3, 3, 4, 5, 6, 7]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [7, 10, 5, 2]) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 15\n assert candidate(nums = [6, 4, 10, 3]) == 13\n assert candidate(nums = [3, 6, 2, 3, 5, 4, 1]) == 15\n assert candidate(nums = [6, 4, 2, 8, 5, 7]) == 21\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8]) == 21\n assert candidate(nums = [6, 6, 6, 10]) == 22\n assert candidate(nums = [1, 2, 1, 10]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [3, 2, 3, 4]) == 10\n assert candidate(nums = [7, 10, 5, 2, 8, 7, 3, 5]) == 25\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 4200\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 2700000\n assert candidate(nums = [3, 6, 2, 3, 5, 4, 8, 7]) == 21\n assert candidate(nums = [5, 5, 5, 1, 1, 1, 10, 10, 10, 20]) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 81\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 2999997\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996, 6, 999995, 7, 999994, 8, 999993]) == 2999997\n assert candidate(nums = [1000000, 999999, 1000000, 1000000, 999998]) == 3000000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 500000, 600000, 700000]) == 2300000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 30\n assert candidate(nums = [999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989]) == 2999991\n assert candidate(nums = [1000000, 999999, 999998, 1, 2, 3]) == 2999997\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 81\n assert candidate(nums = [9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 69\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 3024\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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]) == 29\n assert candidate(nums = [10, 20, 25, 30, 40, 50, 60, 70, 80, 90]) == 240\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30]) == 87\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 3000000\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 84\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]) == 81\n assert candidate(nums = [3, 6, 2, 3, 5, 40, 41]) == 87\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 2999997\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]) == 9\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 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]) == 57\n assert candidate(nums = [7, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 300\n assert candidate(nums = [1000000, 2, 1000000, 3, 1000000, 4, 1000000, 5, 1000000]) == 3000000\n assert candidate(nums = [3, 3, 3, 2, 2, 2, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 200000, 200000, 200000, 200000]) == 600000\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981, 999980]) == 2999994\n assert candidate(nums = [2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 57\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999]) == 2999997\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [5, 10, 25, 40, 50, 60, 70, 80, 90, 100]) == 270\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 51\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 57\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 300000\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 26\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 29\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 12, 14, 15, 18, 20, 21, 24, 25, 28, 30, 32, 33, 36, 39]) == 108\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 4200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 42\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 27\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000]) == 1500000\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [10, 5, 7, 3, 9, 8]) == 27\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1000000]) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 23\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 20\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509]) == 1524\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995]) == 2999997\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 330\n assert candidate(nums = [1000, 2000, 1500, 2500, 1800, 3000, 2200, 3500]) == 9000\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 324\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 = [10, 5, 7, 2, 8, 4, 6]) == 25\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996, 6, 999995, 7, 999994, 8, 999993, 9, 999992]) == 2999997\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == 3600\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]) == 357\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums = [1, 2, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500]) == 1250\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [12, 25, 10, 15, 30, 18, 20, 22, 28, 35, 40]) == 105\n assert candidate(nums = [7, 10, 5, 3, 8, 9, 2, 6, 4, 1]) == 27\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 2999997\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 270\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 27\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109]) == 294\n assert candidate(nums = [1, 1000000, 1000000, 1000000, 1000000]) == 3000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 420\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 17\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]) == 44\n assert candidate(nums = [1000000, 999999, 1000000, 999998, 999997]) == 2999999\n", "comparison": "exact"}, "public_tests": ["[2,1,2]", "[1,2,1,10]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().largestPerimeter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:27+00:00", "tests_total": 114, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "math", "greedy", "sorting", "quicksort", "polygons"]}, "language": "python", "interface": {"raw_signature": "def largestPerimeter(self, nums: list[int]) -> int:", "container": "Solution", "callable": "largestPerimeter", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 977, "task_id": "squares-of-a-sorted-array", "difficulty": "Easy", "problem_description": "Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.\n\nExample 1:\n\nInput: nums = [-4,-1,0,3,10]\nOutput: [0,1,9,16,100]\nExplanation: After squaring, the array becomes [16,1,0,9,100].\nAfter sorting, it becomes [0,1,9,16,100].\n\nExample 2:\n\nInput: nums = [-7,-3,2,3,11]\nOutput: [4,9,9,49,121]\n\nConstraints:\n\n- 1 <= nums.length <= 10^4\n- -10^4 <= nums[i] <= 10^4\n- nums is sorted in non-decreasing order.\n\nFollow up: Squaring each element and sorting the new array is very trivial, could you find an O(n) solution using a different approach?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-2, -1, 0, 1, 2]) == [0, 1, 1, 4, 4]\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [0, 1, 4, 9, 16, 25]\n assert candidate(nums = [-1, -1, 0, 0, 1, 1]) == [0, 0, 1, 1, 1, 1]\n assert candidate(nums = [-1]) == [1]\n assert candidate(nums = [-4, -4, -3, -2, -1, 0, 1, 2, 3, 4]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 16]\n assert candidate(nums = [-3, 0, 3]) == [0, 9, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n assert candidate(nums = [-7, -3, 2, 3, 11]) == [4, 9, 9, 49, 121]\n assert candidate(nums = [-5, -3, -1, 0, 1, 2, 3]) == [0, 1, 1, 4, 9, 9, 25]\n assert candidate(nums = [-10, -5, 0, 5, 10]) == [0, 25, 25, 100, 100]\n assert candidate(nums = [-5, -4, -3, -2, -1]) == [1, 4, 9, 16, 25]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [1, 4, 9, 16, 25]\n assert candidate(nums = [0, 1, 2, 3, 4]) == [0, 1, 4, 9, 16]\n assert candidate(nums = [-9, -7, -5, -3, -1, 2, 4, 6, 8]) == [1, 4, 9, 16, 25, 36, 49, 64, 81]\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n assert candidate(nums = [-8, -6, -4, -2, 0, 1, 3, 5, 7]) == [0, 1, 4, 9, 16, 25, 36, 49, 64]\n assert candidate(nums = [0]) == [0]\n assert candidate(nums = [0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(nums = [-10000, 10000]) == [100000000, 100000000]\n assert candidate(nums = [-5, -3, -1, 0, 2, 4]) == [0, 1, 4, 9, 16, 25]\n assert candidate(nums = [-5, -3, -2, -1]) == [1, 4, 9, 25]\n assert candidate(nums = [-2, -2, 2, 2]) == [4, 4, 4, 4]\n assert candidate(nums = [-10, -8, -6, -4, -2]) == [4, 16, 36, 64, 100]\n assert candidate(nums = [-10000, 0, 10000]) == [0, 100000000, 100000000]\n assert candidate(nums = [-4, -1, 0, 3, 10]) == [0, 1, 9, 16, 100]\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3]) == [0, 1, 1, 4, 4, 9, 9]\n assert candidate(nums = [-5, -3, -1, 0, 1, 3, 5]) == [0, 1, 1, 9, 9, 25, 25]\n assert candidate(nums = [-1, 0, 1]) == [0, 1, 1]\n assert candidate(nums = [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36]\n assert candidate(nums = [-2, -2, -2, -1, 0, 0, 1, 2, 2, 2]) == [0, 0, 1, 1, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36, 49, 49, 64, 64, 81, 81]\n assert candidate(nums = [-3, -2, -1, 0, 0, 0, 1, 2, 3]) == [0, 0, 0, 1, 1, 4, 4, 9, 9]\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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [0, 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, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 98010000, 98029801, 98049604, 98069409, 98089216, 98109025, 98128836, 98148649, 98168464, 98188281, 98208100, 98227921, 98247744, 98267569, 98287396, 98307225, 98327056, 98346889, 98366724, 98386561, 98406400, 98426241, 98446084, 98465929, 98485776, 98505625, 98525476, 98545329, 98565184, 98585041, 98604900, 98624761, 98644624, 98664489, 98684356, 98704225, 98724096, 98743969, 98763844, 98783721, 98803600, 98823481, 98843364, 98863249, 98883136, 98903025, 98922916, 98942809, 98962704, 98982601, 99002500, 99022401, 99042304, 99062209, 99082116, 99102025, 99121936, 99141849, 99161764, 99181681, 99201600, 99221521, 99241444, 99261369, 99281296, 99301225, 99321156, 99341089, 99361024, 99380961, 99400900, 99420841, 99440784, 99460729, 99480676, 99500625, 99520576, 99540529, 99560484, 99580441, 99600400, 99620361, 99640324, 99660289, 99680256, 99700225, 99720196, 99740169, 99760144, 99780121, 99800100, 99820081, 99840064, 99860049, 99880036, 99900025, 99920016, 99940009, 99960004, 99980001, 100000000]\n assert candidate(nums = [-100, -50, -25, -10, -5, 0, 5, 10, 25, 50, 100]) == [0, 25, 25, 100, 100, 625, 625, 2500, 2500, 10000, 10000]\n assert candidate(nums = [-10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 25, 25, 100, 100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]\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]) == [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]\n assert candidate(nums = [-100, -50, -20, -10, -5, -1, 0, 1, 5, 10, 20, 50, 100]) == [0, 1, 1, 25, 25, 100, 100, 400, 400, 2500, 2500, 10000, 10000]\n assert candidate(nums = [-10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000, 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [0, 1000000, 1000000, 4000000, 4000000, 9000000, 9000000, 16000000, 16000000, 25000000, 25000000, 36000000, 36000000, 49000000, 49000000, 64000000, 64000000, 81000000, 81000000, 100000000, 100000000]\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, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36, 49, 49, 64, 64, 81, 81, 100, 100]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, -9990, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == [99800100, 99800100, 99820081, 99820081, 99840064, 99840064, 99860049, 99860049, 99880036, 99880036, 99900025, 99900025, 99920016, 99920016, 99940009, 99940009, 99960004, 99960004, 99980001, 99980001]\n assert candidate(nums = [-1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-1, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [0, 1, 1, 1, 1, 4, 4, 4, 9, 9, 9, 16, 16, 16, 25, 25, 25]\n assert candidate(nums = [-5, -3, -1, 2, 4, 6, 8]) == [1, 4, 9, 16, 25, 36, 64]\n assert candidate(nums = [-10, -5, -1, 0, 1, 5, 10]) == [0, 1, 1, 25, 25, 100, 100]\n assert candidate(nums = [-5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000]) == [0, 1, 1, 25, 25, 100, 100, 2500, 2500, 10000, 10000, 250000, 250000, 1000000, 1000000, 25000000, 25000000]\n assert candidate(nums = [-10000, -9000, -8000, -7000, -6000, -5000, 0, 5000, 6000, 7000, 8000, 9000, 10000]) == [0, 25000000, 25000000, 36000000, 36000000, 49000000, 49000000, 64000000, 64000000, 81000000, 81000000, 100000000, 100000000]\n assert candidate(nums = [-5000, -2500, -1250, -625, -312, -156, -78, -39, 0, 39, 78, 156, 312, 625, 1250, 2500, 5000]) == [0, 1521, 1521, 6084, 6084, 24336, 24336, 97344, 97344, 390625, 390625, 1562500, 1562500, 6250000, 6250000, 25000000, 25000000]\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1]) == [1, 4, 9, 16, 25, 36, 49, 64, 81]\n assert candidate(nums = [-10, -5, -1, 0, 1, 2, 3, 4, 5, 10]) == [0, 1, 1, 4, 9, 16, 25, 25, 100, 100]\n assert candidate(nums = [-1, 0, 1]) == [0, 1, 1]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, -9990, 0, 1, 2, 3, 4, 5]) == [0, 1, 4, 9, 16, 25, 99800100, 99820081, 99840064, 99860049, 99880036, 99900025, 99920016, 99940009, 99960004, 99980001]\n assert candidate(nums = [-20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 25, 25, 100, 100, 225, 225, 400, 400, 625, 900, 1225, 1600, 2025, 2500]\n assert candidate(nums = [-9999, -5000, -1000, -500, -100, -50, -10, -5, -2, -1, 0, 1, 2, 5, 10, 50, 100, 500, 1000, 5000, 9999]) == [0, 1, 1, 4, 4, 25, 25, 100, 100, 2500, 2500, 10000, 10000, 250000, 250000, 1000000, 1000000, 25000000, 25000000, 99980001, 99980001]\n assert candidate(nums = [-2, -2, -2, -1, 0, 0, 0, 1, 2, 2, 2]) == [0, 0, 0, 1, 1, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100]) == [0, 1, 1, 25, 25, 100, 100, 625, 625, 2500, 2500, 10000, 10000]\n assert candidate(nums = [-10000, 0, 10000]) == [0, 100000000, 100000000]\n assert candidate(nums = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991]) == [99820081, 99840064, 99860049, 99880036, 99900025, 99920016, 99940009, 99960004, 99980001, 100000000]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, -9990, -9989, -9988, -9987, -9986, -9985, -9984, -9983, -9982, -9981, -9980, 0, 9980, 9981, 9982, 9983, 9984, 9985, 9986, 9987, 9988, 9989, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == [0, 99600400, 99600400, 99620361, 99620361, 99640324, 99640324, 99660289, 99660289, 99680256, 99680256, 99700225, 99700225, 99720196, 99720196, 99740169, 99740169, 99760144, 99760144, 99780121, 99780121, 99800100, 99800100, 99820081, 99820081, 99840064, 99840064, 99860049, 99860049, 99880036, 99880036, 99900025, 99900025, 99920016, 99920016, 99940009, 99940009, 99960004, 99960004, 99980001, 99980001]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, -9990]) == [99800100, 99820081, 99840064, 99860049, 99880036, 99900025, 99920016, 99940009, 99960004, 99980001]\n assert candidate(nums = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000]) == [0, 1, 1, 25, 25, 100, 100, 2500, 2500, 10000, 10000, 250000, 250000, 1000000, 1000000, 25000000, 25000000, 100000000, 100000000]\n assert candidate(nums = [-20, -15, -10, -5, 0, 5, 10, 15, 20]) == [0, 25, 25, 100, 100, 225, 225, 400, 400]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, 0, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == [0, 99820081, 99820081, 99840064, 99840064, 99860049, 99860049, 99880036, 99880036, 99900025, 99900025, 99920016, 99920016, 99940009, 99940009, 99960004, 99960004, 99980001, 99980001]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, -9990, 0, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == [0, 99800100, 99800100, 99820081, 99820081, 99840064, 99840064, 99860049, 99860049, 99880036, 99880036, 99900025, 99900025, 99920016, 99920016, 99940009, 99940009, 99960004, 99960004, 99980001, 99980001]\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91]) == [8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000]\n assert candidate(nums = [-9999, 0, 9999]) == [0, 99980001, 99980001]\n assert candidate(nums = [-5000, -3000, -1000, 0, 1000, 3000, 5000]) == [0, 1000000, 1000000, 9000000, 9000000, 25000000, 25000000]\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 1, 4, 4, 9, 9, 100, 400, 900, 1600, 2500, 3600, 4900, 6400, 8100, 10000]\n assert candidate(nums = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000]) == [0, 1, 1, 25, 25, 100, 100, 2500, 2500, 10000, 10000, 250000, 250000, 1000000, 1000000]\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 1, 4, 4, 9, 9, 16, 25, 36, 49, 64, 81, 100]\n assert candidate(nums = [-1, -1, -1, 0, 0, 0, 1, 1, 1]) == [0, 0, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]\n assert candidate(nums = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == [1, 1, 4, 4, 9, 9, 16, 16, 25, 25]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991, -9990, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 99800100, 99820081, 99840064, 99860049, 99880036, 99900025, 99920016, 99940009, 99960004, 99980001]\n assert candidate(nums = [-100, -50, -20, -10, -5, 0, 5, 10, 20, 50, 100]) == [0, 25, 25, 100, 100, 400, 400, 2500, 2500, 10000, 10000]\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]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]\n assert candidate(nums = [-100, -50, -25, -10, -5, -2, 0, 2, 5, 10, 25, 50, 100]) == [0, 4, 4, 25, 25, 100, 100, 625, 625, 2500, 2500, 10000, 10000]\n assert candidate(nums = [-1000, -500, -100, -50, -10, -5, -2, -1, 0, 1, 2, 5, 10, 50, 100, 500, 1000]) == [0, 1, 1, 4, 4, 25, 25, 100, 100, 2500, 2500, 10000, 10000, 250000, 250000, 1000000, 1000000]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25]\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]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36, 49, 49, 64, 64, 81, 81, 100, 100]\n assert candidate(nums = [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, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, 1, 4, 4, 9, 9, 16, 25, 36, 49, 64, 81]\n assert candidate(nums = [-1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1]) == [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-50, -40, -30, -20, -10, -5, -1, 0, 1, 5, 10, 20, 30, 40, 50]) == [0, 1, 1, 25, 25, 100, 100, 400, 400, 900, 900, 1600, 1600, 2500, 2500]\n assert candidate(nums = [-10, -10, -10, -10, -10, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36, 49, 49, 64, 64, 81, 81, 100, 100, 121, 121, 144, 144, 169, 169, 196, 196, 225, 225, 256, 256, 289, 289, 324, 324, 361, 361, 400, 400, 441, 441, 484, 484, 529, 529, 576, 576, 625, 625]\n assert candidate(nums = [-5000, -4000, -3000, -2000, -1000, 0, 1000, 2000, 3000, 4000, 5000]) == [0, 1000000, 1000000, 4000000, 4000000, 9000000, 9000000, 16000000, 16000000, 25000000, 25000000]\n assert candidate(nums = [-999, -998, -997, -996, -995, -994, -993, -992, -991, -990, 0, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999]) == [0, 980100, 980100, 982081, 982081, 984064, 984064, 986049, 986049, 988036, 988036, 990025, 990025, 992016, 992016, 994009, 994009, 996004, 996004, 998001, 998001]\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]) == [0, 100, 100, 400, 400, 900, 900, 1600, 1600, 2500, 2500, 3600, 3600, 4900, 4900, 6400, 6400, 8100, 8100, 10000, 10000]\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]) == [0, 10000, 10000, 40000, 40000, 90000, 90000, 160000, 160000, 250000, 250000, 360000, 360000, 490000, 490000, 640000, 640000, 810000, 810000, 1000000, 1000000]\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]) == [0, 1, 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]\n assert candidate(nums = [-10, -5, -1, 0, 2, 5, 8]) == [0, 1, 4, 25, 25, 64, 100]\n assert candidate(nums = [-1, -1, 0, 1, 1]) == [0, 1, 1, 1, 1]\n assert candidate(nums = [-100, -50, -25, -10, -5, 0, 1, 2, 5, 10, 25, 50, 100]) == [0, 1, 4, 25, 25, 100, 100, 625, 625, 2500, 2500, 10000, 10000]\n assert candidate(nums = [-5000, -4000, -3000, -2000, -1000, -500, -100, -50, -10, -1, 0, 1, 10, 50, 100, 500, 1000, 2000, 3000, 4000, 5000]) == [0, 1, 1, 100, 100, 2500, 2500, 10000, 10000, 250000, 250000, 1000000, 1000000, 4000000, 4000000, 9000000, 9000000, 16000000, 16000000, 25000000, 25000000]\n assert candidate(nums = [-3000, -2500, -2000, -1500, -1000, -500, -250, -100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 1500, 2000, 2500, 3000]) == [0, 1, 1, 25, 25, 100, 100, 625, 625, 2500, 2500, 10000, 10000, 62500, 62500, 250000, 250000, 1000000, 1000000, 2250000, 2250000, 4000000, 4000000, 6250000, 6250000, 9000000, 9000000]\n assert candidate(nums = [-1, -1, -1, 0, 0, 0, 1, 1, 1]) == [0, 0, 0, 1, 1, 1, 1, 1, 1]\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]) == [0, 1, 1, 4, 4, 25, 25, 100, 100, 625, 625, 2500, 2500, 10000, 10000, 62500, 62500, 250000, 250000, 1000000, 1000000]\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50]) == [0, 100, 100, 400, 400, 900, 900, 1600, 1600, 2500, 2500]\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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 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, 2116, 2209, 2304, 2401, 2500, 2500, 2601, 2601, 2704, 2704, 2809, 2809, 2916, 2916, 3025, 3025, 3136, 3136, 3249, 3249, 3364, 3364, 3481, 3481, 3600, 3600, 3721, 3721, 3844, 3844, 3969, 3969, 4096, 4096, 4225, 4225, 4356, 4356, 4489, 4489, 4624, 4624, 4761, 4761, 4900, 4900, 5041, 5041, 5184, 5184, 5329, 5329, 5476, 5476, 5625, 5625, 5776, 5776, 5929, 5929, 6084, 6084, 6241, 6241, 6400, 6400, 6561, 6561, 6724, 6724, 6889, 6889, 7056, 7056, 7225, 7225, 7396, 7396, 7569, 7569, 7744, 7744, 7921, 7921, 8100, 8100, 8281, 8281, 8464, 8464, 8649, 8649, 8836, 8836, 9025, 9025, 9216, 9216, 9409, 9409, 9604, 9604, 9801, 9801, 10000, 10000]\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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36, 49, 49, 64, 64, 81, 81, 100, 100, 121, 121, 144, 144, 169, 169, 196, 196, 225, 225, 256, 256, 289, 289, 324, 324, 361, 361, 400, 400, 441, 441, 484, 484, 529, 529, 576, 576, 625, 625, 676, 676, 729, 729, 784, 784, 841, 841, 900, 900, 961, 961, 1024, 1024, 1089, 1089, 1156, 1156, 1225, 1225, 1296, 1296, 1369, 1369, 1444, 1444, 1521, 1521, 1600, 1600, 1681, 1681, 1764, 1764, 1849, 1849, 1936, 1936, 2025, 2025, 2116, 2116, 2209, 2209, 2304, 2304, 2401, 2401, 2500, 2500, 2601, 2601, 2704, 2704, 2809, 2809, 2916, 2916, 3025, 3025, 3136, 3136, 3249, 3249, 3364, 3364, 3481, 3481, 3600, 3600, 3721, 3721, 3844, 3844, 3969, 3969, 4096, 4096, 4225, 4225, 4356, 4356, 4489, 4489, 4624, 4624, 4761, 4761, 4900, 4900, 5041, 5041, 5184, 5184, 5329, 5329, 5476, 5476, 5625, 5625, 5776, 5776, 5929, 5929, 6084, 6084, 6241, 6241, 6400, 6400, 6561, 6561, 6724, 6724, 6889, 6889, 7056, 7056, 7225, 7225, 7396, 7396, 7569, 7569, 7744, 7744, 7921, 7921, 8100, 8100, 8281, 8281, 8464, 8464, 8649, 8649, 8836, 8836, 9025, 9025, 9216, 9216, 9409, 9409, 9604, 9604, 9801, 9801, 10000, 10000]\n assert candidate(nums = [-9, -6, -3, 0, 3, 6, 9]) == [0, 9, 9, 36, 36, 81, 81]\n assert candidate(nums = [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == [1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]\n assert candidate(nums = [-10, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 10]) == [0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 36, 36, 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]) == [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, -2, 0, 2, 2]) == [0, 4, 4, 4, 4]\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [8100, 8100, 8281, 8281, 8464, 8464, 8649, 8649, 8836, 8836, 9025, 9025, 9216, 9216, 9409, 9409, 9604, 9604, 9801, 9801, 10000, 10000]\n assert candidate(nums = [-9, -6, -5, -3, -1, 0, 1, 3, 5, 6, 9, 12, 15, 18, 21]) == [0, 1, 1, 9, 9, 25, 25, 36, 36, 81, 81, 144, 225, 324, 441]\n assert candidate(nums = [-10, -5, -1, 0, 1, 5, 10]) == [0, 1, 1, 25, 25, 100, 100]\n assert candidate(nums = [-10000, -9999, -9998, -9997, -9996, 0, 1, 2, 3, 4, 5]) == [0, 1, 4, 9, 16, 25, 99920016, 99940009, 99960004, 99980001, 100000000]\n assert candidate(nums = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000]) == [982081, 982081, 984064, 984064, 986049, 986049, 988036, 988036, 990025, 990025, 992016, 992016, 994009, 994009, 996004, 996004, 998001, 998001, 1000000, 1000000]\n assert candidate(nums = [-10, -5, -3, -2, -1, 0, 0, 0, 1, 2, 3, 5, 10]) == [0, 0, 0, 1, 1, 4, 4, 9, 9, 25, 25, 100, 100]\n assert candidate(nums = [-25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25]) == [0, 25, 25, 100, 100, 225, 225, 400, 400, 625, 625]\n", "comparison": "exact"}, "public_tests": ["[-4,-1,0,3,10]", "[-7,-3,2,3,11]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sortedSquares", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:29+00:00", "tests_total": 119, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def sortedSquares(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "sortedSquares", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 978, "task_id": "longest-turbulent-subarray", "difficulty": "Medium", "problem_description": "Given an integer array arr, return the length of a maximum size turbulent subarray of arr.\n\nA subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray.\n\nMore formally, a subarray [arr[i], arr[i + 1], ..., arr[j]] of arr is said to be turbulent if and only if:\n\n- For i <= k < j:\n - arr[k] > arr[k + 1] when k is odd, and\n - arr[k] < arr[k + 1] when k is even.\n- Or, for i <= k < j:\n - arr[k] > arr[k + 1] when k is even, and\n - arr[k] < arr[k + 1] when k is odd.\n\nExample 1:\n\nInput: arr = [9,4,2,10,7,8,8,1,9]\nOutput: 5\nExplanation: arr[1] > arr[2] < arr[3] > arr[4] < arr[5]\n\nExample 2:\n\nInput: arr = [4,8,12,16]\nOutput: 2\n\nExample 3:\n\nInput: arr = [100]\nOutput: 1\n\nConstraints:\n\n- 1 <= arr.length <= 4 * 10^4\n- 0 <= arr[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [9, 9]) == 1\n assert candidate(arr = [9, 4, 2, 10, 7, 8, 8, 1, 9]) == 5\n assert candidate(arr = [9, 8, 7, 6, 7, 8, 9, 8, 7, 6]) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 3]) == 8\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == 9\n assert candidate(arr = [9, 4, 2, 10, 7, 8, 7, 1, 9, 4, 2, 10, 7, 8, 8, 1, 9]) == 6\n assert candidate(arr = [10, 9, 4, 5, 4, 8, 9, 3, 5]) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(arr = [1, 2, 2, 1, 2, 2, 1, 2, 2]) == 3\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [0, 8, 45, 88, 48, 68, 28, 55, 17, 24]) == 8\n assert candidate(arr = [100]) == 1\n assert candidate(arr = [8, 8, 8, 8, 8, 8]) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(arr = [4, 8, 12, 16]) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8]) == 9\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5]) == 9\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1]) == 5\n assert candidate(arr = [1, 4, 5, 6, 7, 8, 9, 10, 8, 6, 4, 2, 1]) == 3\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 10]) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == 3\n assert candidate(arr = [5, 3, 8, 6, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15]) == 14\n assert candidate(arr = [5, 3, 8, 1, 4, 7, 2, 6, 9, 0, 11]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(arr = [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]) == 3\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\n assert candidate(arr = [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]) == 27\n assert candidate(arr = [3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4]) == 14\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, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [3, 8, 5, 11, 6, 10, 7, 12, 8, 14, 9, 15]) == 12\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == 19\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 3\n assert candidate(arr = [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]) == 3\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11]) == 21\n assert candidate(arr = [1, 2, 1, 2, 3, 2, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 3, 2, 1, 2]) == 7\n assert candidate(arr = [10, 9, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9, 10, 9, 8, 9]) == 3\n assert candidate(arr = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(arr = [9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9]) == 3\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 4, 5, 6]) == 3\n assert candidate(arr = [1, 2, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4]) == 3\n assert candidate(arr = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25, 35]) == 11\n assert candidate(arr = [8, 9, 6, 7, 4, 5, 2, 3, 0, 1, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10, 9, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 21\n assert candidate(arr = [10, 1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == 20\n assert candidate(arr = [5, 3, 8, 10, 6, 5, 7, 9, 3, 1, 2, 4, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(arr = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 19\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 29\n assert candidate(arr = [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]) == 3\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 20\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(arr = [10, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 6, 4, 3, 4, 2, 1]) == 13\n assert candidate(arr = [1, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 3\n assert candidate(arr = [2, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, 11, 9, 12]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1]) == 3\n assert candidate(arr = [5, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 3\n assert candidate(arr = [10, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4]) == 3\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\n assert candidate(arr = [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]) == 4\n assert candidate(arr = [3, 8, 1, 6, 4, 9, 2, 7, 3, 8, 1, 6, 4, 9, 2, 7, 3, 8]) == 18\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16]) == 2\n assert candidate(arr = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 16\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 2\n assert candidate(arr = [1, 2, 2, 1, 2, 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]) == 26\n assert candidate(arr = [3, 8, 6, 5, 10, 7, 1, 9, 2, 8, 5, 7, 6, 1, 5, 1, 4, 3]) == 8\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [2, 4, 2, 6, 4, 8, 6, 10, 8, 12, 10, 14, 12, 16, 14, 18, 16]) == 17\n assert candidate(arr = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1]) == 18\n assert candidate(arr = [100, 90, 100, 90, 100, 90, 100, 90, 100, 90, 100, 90, 100, 90, 100, 90]) == 16\n assert candidate(arr = [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, 2]) == 3\n assert candidate(arr = [5, 8, 6, 7, 3, 4, 2, 3, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3]) == 11\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 28\n assert candidate(arr = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(arr = [10, 20, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 25, 20, 15, 10]) == 3\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 20\n assert candidate(arr = [3, 5, 4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3]) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 2\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\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\n assert candidate(arr = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2]) == 5\n assert candidate(arr = [1, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 7, 4, 9, 2, 8, 3, 10, 5, 11, 6]) == 11\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6]) == 3\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 3\n assert candidate(arr = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50]) == 11\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6]) == 3\n assert candidate(arr = [9, 3, 8, 3, 8, 3, 9, 3, 9, 3, 8, 3, 8]) == 13\n assert candidate(arr = [5, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18]) == 12\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 2\n assert candidate(arr = [10, 9, 10, 8, 9, 10, 8, 9, 10, 8, 9, 10, 8, 9, 10, 8, 9, 10, 8, 9]) == 5\n assert candidate(arr = [5, 1, 4, 1, 4, 1, 5, 1, 5, 1, 4]) == 11\n assert candidate(arr = [5, 6, 5, 7, 6, 5, 7, 6, 5, 7, 6, 5, 7, 6, 5, 7, 6, 5, 7, 6]) == 5\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 8, 7, 9, 11, 13, 15, 14, 16, 18, 17, 19, 21, 23, 22, 24, 26, 25, 27, 29, 28, 30]) == 4\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]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [4, 5, 6, 1, 2, 3, 7, 8, 9, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\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\n assert candidate(arr = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2]) == 3\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 3\n assert candidate(arr = [8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(arr = [8, 6, 10, 5, 9, 4, 12, 3, 13, 2, 14, 1]) == 12\n assert candidate(arr = [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]) == 4\n assert candidate(arr = [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(arr = [2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 16\n assert candidate(arr = [8, 10, 6, 5, 7, 9, 3, 1, 2, 4, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 3\n assert candidate(arr = [9, 10, 8, 11, 7, 12, 6, 13, 5, 14, 4, 15, 3, 16, 2, 17, 1]) == 17\n assert candidate(arr = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70]) == 15\n assert candidate(arr = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3]) == 32\n assert candidate(arr = [5, 8, 6, 7, 4, 5, 3, 4, 2, 1, 4, 3, 5, 6, 4, 7]) == 9\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 30\n assert candidate(arr = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]) == 2\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 20\n assert candidate(arr = [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\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [3, 1, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == 17\n assert candidate(arr = [10, 5, 15, 0, 10, 5, 15, 0, 10, 5, 15, 0, 10, 5, 15]) == 15\n assert candidate(arr = [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]) == 25\n assert candidate(arr = [5, 3, 1, 4, 2, 6, 4, 8, 6, 10, 8, 12, 10, 14, 12, 16, 14, 18, 16, 20, 18]) == 20\n assert candidate(arr = [2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2]) == 3\n assert candidate(arr = [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, 2, 3, 2, 1, 2, 3]) == 3\n assert candidate(arr = [1, 2, 3, 2, 1, 3, 4, 3, 2, 1, 3, 4, 5, 4, 3, 2, 1, 3, 4, 5, 6, 5, 4, 3, 2, 1, 3, 4]) == 3\n", "comparison": "exact"}, "public_tests": ["[9,4,2,10,7,8,8,1,9]", "[4,8,12,16]", "[100]"], "hints": [], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().maxTurbulenceSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:31+00:00", "tests_total": 150, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "dynamic-programming", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maxTurbulenceSize(self, arr: list[int]) -> int:", "container": "Solution", "callable": "maxTurbulenceSize", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 980, "task_id": "unique-paths-iii", "difficulty": "Hard", "problem_description": "You are given an m x n integer array grid where grid[i][j] could be:\n\n- 1 representing the starting square. There is exactly one starting square.\n- 2 representing the ending square. There is exactly one ending square.\n- 0 representing empty squares we can walk over.\n- -1 representing obstacles that we cannot walk over.\n\nReturn the number of 4-directional walks from the starting square to the ending square, that walk over every non-obstacle square exactly once.\n\nExample 1:\n\nInput: grid = [[1,0,0,0],[0,0,0,0],[0,0,2,-1]]\nOutput: 2\nExplanation: We have the following two paths:\n1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2)\n2. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2)\n\nExample 2:\n\nInput: grid = [[1,0,0,0],[0,0,0,0],[0,0,0,2]]\nOutput: 4\nExplanation: We have the following four paths:\n1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2),(2,3)\n2. (0,0),(0,1),(1,1),(1,0),(2,0),(2,1),(2,2),(1,2),(0,2),(0,3),(1,3),(2,3)\n3. (0,0),(1,0),(2,0),(2,1),(2,2),(1,2),(1,1),(0,1),(0,2),(0,3),(1,3),(2,3)\n4. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2),(2,3)\n\nExample 3:\n\nInput: grid = [[0,1],[2,0]]\nOutput: 0\nExplanation: There is no path that walks over every empty square exactly once.\nNote that the starting and ending square can be anywhere in the grid.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 20\n- 1 <= m * n <= 20\n- -1 <= grid[i][j] <= 2\n- There is exactly one starting cell and one ending cell.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1], [2, 0]]) == 0\n assert candidate(grid = [[0, 0, 0], [1, 0, 0], [0, 2, -1]]) == 0\n assert candidate(grid = [[1, 0, -1, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 2], [-1, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 1], [0, 0, 0], [2, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 0, 2], [-1, 0, -1, -1], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0], [0, 0, 0], [0, 0, 2]]) == 2\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 2, -1]]) == 2\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 2]]) == 4\n assert candidate(grid = [[1, 0], [0, 2]]) == 0\n assert candidate(grid = [[1, 0, -1], [0, 0, 0], [0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, -1, 0], [0, 0, 0, 0], [0, 0, 2, 0]]) == 0\n assert candidate(grid = [[1, 0, 2]]) == 1\n assert candidate(grid = [[1, 0, 0, 2]]) == 1\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 2, 0]]) == 0\n assert candidate(grid = [[1], [0], [0], [2]]) == 1\n assert candidate(grid = [[1, 0, -1, 0, 0], [0, 0, 0, 0, 0], [0, -1, -1, 0, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0], [-1, 0, 0, -1, 0], [0, 0, 0, 0, 0], [0, -1, 0, -1, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, -1, 0], [0, 0, 0, 0, 0], [0, -1, 0, -1, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, -1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, -1, 2]]) == 1\n assert candidate(grid = [[1, 0, 0, -1, 0], [0, 0, 0, 0, 0], [0, -1, -1, 0, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, -1, 0, -1, 0], [0, 0, 0, 0, 0], [0, -1, 2, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [2, -1, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, -1, 0], [0, 0, 0, 0, 0], [0, -1, 0, 0, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, -1], [0, 0, -1, 0], [0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, -1, 0, 0, 0], [0, 0, 0, -1, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, -1, -1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 2, 0, 0]]) == 3\n assert candidate(grid = [[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, 0, -1], [0, 0, 2, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, -1], [0, 0, 2, 0], [0, 0, -1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, -1, 0], [0, 0, 0, -1, 0], [0, 0, 0, -1, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, -1, 0, 0], [0, 0, 0, 0, 0], [0, -1, 2, -1, 0], [0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, -1, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 2, 0]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, -1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 2, 0]]) == 1\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, -1, 0], [0, 0, 0, 0], [0, 0, 0, 2]]) == 4\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 2, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, -1, 0, 0], [0, 0, 0, 0, 0], [0, -1, 0, -1, 0], [0, 0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, -1], [0, 0, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 2], [-1, 0, -1, 0, -1], [0, 0, 0, 0, 0], [0, -1, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, -1, 2, -1], [0, -1, 0, 0]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,0,0,0],[0,0,0,0],[0,0,2,-1]]", "[[1,0,0,0],[0,0,0,0],[0,0,0,2]]", "[[0,1],[2,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().uniquePathsIII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:36+00:00", "tests_total": 85, "tests_dropped": 44, "flags": ["has_images"], "topic_tags": ["array", "backtracking", "bit-manipulation", "matrix", "hamiltonian-path"]}, "language": "python", "interface": {"raw_signature": "def uniquePathsIII(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "uniquePathsIII", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 982, "task_id": "triples-with-bitwise-and-equal-to-zero", "difficulty": "Hard", "problem_description": "Given an integer array nums, return the number of AND triples.\n\nAn AND triple is a triple of indices (i, j, k) such that:\n\n- 0 <= i < nums.length\n- 0 <= j < nums.length\n- 0 <= k < nums.length\n- nums[i] & nums[j] & nums[k] == 0, where & represents the bitwise-AND operator.\n\nExample 1:\n\nInput: nums = [2,1,3]\nOutput: 12\nExplanation: We could choose the following i, j, k triples:\n(i=0, j=0, k=1) : 2 & 2 & 1\n(i=0, j=1, k=0) : 2 & 1 & 2\n(i=0, j=1, k=1) : 2 & 1 & 1\n(i=0, j=1, k=2) : 2 & 1 & 3\n(i=0, j=2, k=1) : 2 & 3 & 1\n(i=1, j=0, k=0) : 1 & 2 & 2\n(i=1, j=0, k=1) : 1 & 2 & 1\n(i=1, j=0, k=2) : 1 & 2 & 3\n(i=1, j=1, k=0) : 1 & 1 & 2\n(i=1, j=2, k=0) : 1 & 3 & 2\n(i=2, j=0, k=1) : 3 & 2 & 1\n(i=2, j=1, k=0) : 3 & 1 & 2\n\nExample 2:\n\nInput: nums = [0,0,0]\nOutput: 27\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 0 <= nums[i] < 2^16\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0]) == 27\n assert candidate(nums = [5, 3, 7, 10]) == 18\n assert candidate(nums = [15, 15, 15, 15]) == 0\n assert candidate(nums = [5, 3, 0, 1, 4]) == 91\n assert candidate(nums = [1, 2, 3, 4]) == 48\n assert candidate(nums = [5, 10, 15, 20]) == 30\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 189\n assert candidate(nums = [1, 2, 4, 8]) == 60\n assert candidate(nums = [2, 1, 3]) == 12\n assert candidate(nums = [16, 32, 48, 64]) == 48\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 = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 631\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 = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255]) == 817\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 210\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 258\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 990\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 1261\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248]) == 0\n assert candidate(nums = [7, 14, 28, 56, 112, 224]) == 132\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255]) == 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, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16231\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1680\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 0\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 943\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0]) == 6760\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 432\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79]) == 0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128]) == 2400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1680\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 180\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56]) == 216\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 = [13, 29, 17, 5, 23, 31, 47, 19, 2, 7, 11, 13, 17, 19, 23, 29, 31]) == 546\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 990\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 = [7, 14, 21, 28, 35]) == 30\n assert candidate(nums = [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, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 3036\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 13830\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127]) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == 217\n assert candidate(nums = [15, 240, 240, 15, 240, 15, 240, 15, 240]) == 540\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 744\n assert candidate(nums = [16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 631\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 504\n assert candidate(nums = [15, 7, 3, 1, 0, 31, 14, 6, 2, 0, 255, 127]) == 872\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 1320\n assert candidate(nums = [15, 20, 25, 30, 35, 40]) == 84\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105]) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 3360\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == 720\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == 672\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170]) == 684\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8]) == 3751\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2401\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 180\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1015\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1440\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 3360\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5064\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2401\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 504\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == 0\n assert candidate(nums = [8, 4, 2, 1, 14, 7, 3, 1, 12, 6, 3, 1, 10, 5, 2, 1]) == 2868\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 3420\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 331\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 0\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == 0\n assert candidate(nums = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 547\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 240\n assert candidate(nums = [15, 240, 10, 100, 5, 60]) == 114\n assert candidate(nums = [85, 170, 51, 204, 68, 136, 34, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1]) == 4285\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 432\n assert candidate(nums = [255, 192, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 192]) == 1897\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208]) == 1638\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 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 1998\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 28791\n assert candidate(nums = [8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == 2352\n assert candidate(nums = [21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == 217\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 469\n", "comparison": "exact"}, "public_tests": ["[2,1,3]", "[0,0,0]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:38+00:00", "tests_total": 91, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def countTriplets(self, nums: list[int]) -> int:", "container": "Solution", "callable": "countTriplets", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 983, "task_id": "minimum-cost-for-tickets", "difficulty": "Medium", "problem_description": "You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365.\n\nTrain tickets are sold in three different ways:\n\n- a 1-day pass is sold for costs[0] dollars,\n- a 7-day pass is sold for costs[1] dollars, and\n- a 30-day pass is sold for costs[2] dollars.\n\nThe passes allow that many days of consecutive travel.\n\n- For example, if we get a 7-day pass on day 2, then we can travel for 7 days: 2, 3, 4, 5, 6, 7, and 8.\n\nReturn the minimum number of dollars you need to travel every day in the given list of days.\n\nExample 1:\n\nInput: days = [1,4,6,7,8,20], costs = [2,7,15]\nOutput: 11\nExplanation: For example, here is one way to buy passes that lets you travel your travel plan:\nOn day 1, you bought a 1-day pass for costs[0] = $2, which covered day 1.\nOn day 3, you bought a 7-day pass for costs[1] = $7, which covered days 3, 4, ..., 9.\nOn day 20, you bought a 1-day pass for costs[0] = $2, which covered day 20.\nIn total, you spent $11 and covered all the days of your travel.\n\nExample 2:\n\nInput: days = [1,2,3,4,5,6,7,8,9,10,30,31], costs = [2,7,15]\nOutput: 17\nExplanation: For example, here is one way to buy passes that lets you travel your travel plan:\nOn day 1, you bought a 30-day pass for costs[2] = $15 which covered days 1, 2, ..., 30.\nOn day 31, you bought a 1-day pass for costs[0] = $2 which covered day 31.\nIn total, you spent $17 and covered all the days of your travel.\n\nConstraints:\n\n- 1 <= days.length <= 365\n- 1 <= days[i] <= 365\n- days is in strictly increasing order.\n- costs.length == 3\n- 1 <= costs[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(days = [1, 50, 100, 200, 300, 365],costs = [5, 10, 20]) == 30\n assert candidate(days = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31],costs = [4, 12, 30]) == 34\n assert candidate(days = [1, 100, 200, 300, 365],costs = [2, 7, 15]) == 10\n assert candidate(days = [1, 2, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25],costs = [3, 8, 25]) == 25\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7],costs = [2, 7, 15]) == 7\n assert candidate(days = [1, 6, 8, 16, 17, 20, 24, 26, 27, 29, 30, 32, 33],costs = [1, 4, 9]) == 10\n assert candidate(days = [365],costs = [2, 7, 15]) == 2\n assert candidate(days = [5, 6, 7, 8, 9, 10, 31, 32, 33, 34, 35, 36],costs = [5, 10, 50]) == 20\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],costs = [1, 4, 20]) == 19\n assert candidate(days = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365],costs = [10, 30, 50]) == 370\n assert candidate(days = [1, 5, 8, 9, 10, 12, 13, 17, 18, 19, 20, 23, 25, 27],costs = [3, 13, 45]) == 38\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],costs = [5, 10, 15]) == 20\n assert candidate(days = [1, 5, 8, 10, 12, 16, 18, 21, 23, 25, 27, 30],costs = [3, 8, 16]) == 16\n assert candidate(days = [1, 100, 200, 300, 365],costs = [5, 10, 15]) == 25\n assert candidate(days = [1, 5, 9, 13, 17, 21, 25, 29, 33, 35],costs = [3, 10, 25]) == 30\n assert candidate(days = [3, 8, 9, 20, 23, 30, 33, 36, 40, 43],costs = [1, 8, 30]) == 10\n assert candidate(days = [1, 5, 8, 10, 14, 18, 21, 23, 25, 26, 27, 28, 30],costs = [4, 10, 29]) == 29\n assert candidate(days = [1, 5, 9, 14, 20, 25],costs = [1, 6, 10]) == 6\n assert candidate(days = [1, 4, 6, 7, 8, 20],costs = [2, 7, 15]) == 11\n assert candidate(days = [1],costs = [2, 7, 15]) == 2\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 30, 31],costs = [2, 7, 15]) == 17\n assert candidate(days = [1, 3, 4, 5, 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],costs = [3, 9, 20]) == 29\n assert candidate(days = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 63, 95, 127, 159, 191, 223, 255, 287, 319, 351, 365],costs = [3, 7, 20]) == 56\n assert candidate(days = [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],costs = [1, 5, 10]) == 40\n assert candidate(days = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70],costs = [5, 20, 50]) == 120\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],costs = [1, 5, 15]) == 30\n assert candidate(days = [1, 4, 6, 9, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],costs = [5, 20, 75]) == 80\n assert candidate(days = [1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27, 32, 33, 34, 35, 40, 41, 42, 43, 48, 49, 50, 51, 56, 57, 58, 59],costs = [3, 15, 60]) == 93\n assert candidate(days = [1, 14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196, 210, 224, 238, 252, 266, 280, 294, 308, 322, 336, 350, 364],costs = [7, 15, 35]) == 189\n assert candidate(days = [1, 4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],costs = [2, 15, 40]) == 48\n assert candidate(days = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365],costs = [1, 5, 10]) == 123\n assert candidate(days = [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],costs = [10, 30, 80]) == 360\n assert candidate(days = [1, 4, 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, 204, 211, 218, 225, 232, 239, 246, 253, 260, 267, 274, 281, 288, 295, 302, 309, 316, 323, 330, 337, 344, 351, 358, 365],costs = [7, 40, 120]) == 378\n assert candidate(days = [1, 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, 104, 108, 112, 116, 120, 124, 128, 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, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320, 324, 328, 332, 336, 340, 344, 348, 352, 356, 360, 364],costs = [2, 10, 30]) == 184\n assert candidate(days = [2, 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185, 191, 197, 203, 209, 215, 221, 227, 233, 239, 245, 251, 257, 263, 269, 275, 281, 287, 293, 299, 305, 311, 317, 323, 329, 335, 341, 347, 353, 359, 365],costs = [3, 15, 60]) == 186\n assert candidate(days = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365],costs = [1, 4, 12]) == 147\n assert candidate(days = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40, 41, 43, 44, 46, 47, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62, 64, 65, 67, 68, 70, 71, 73, 74, 76, 77, 79, 80, 82, 83, 85, 86, 88, 89, 91, 92, 94, 95, 97, 98, 100, 101, 103, 104, 106, 107, 109, 110, 112, 113, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 130, 131, 133, 134, 136, 137, 139, 140, 142, 143, 145, 146, 148, 149, 151, 152, 154, 155, 157, 158, 160, 161, 163, 164, 166, 167, 169, 170, 172, 173, 175, 176, 178, 179, 181, 182, 184, 185, 187, 188, 190, 191, 193, 194, 196, 197, 199, 200, 202, 203, 205, 206, 208, 209, 211, 212, 214, 215, 217, 218, 220, 221, 223, 224, 226, 227, 229, 230, 232, 233, 235, 236, 238, 239, 241, 242, 244, 245, 247, 248, 250, 251, 253, 254, 256, 257, 259, 260, 262, 263, 265, 266, 268, 269, 271, 272, 274, 275, 277, 278, 280, 281, 283, 284, 286, 287, 289, 290, 292, 293, 295, 296, 298, 299, 301, 302, 304, 305, 307, 308, 310, 311, 313, 314, 316, 317, 319, 320, 322, 323, 325, 326, 328, 329, 331, 332, 334, 335, 337, 338, 340, 341, 343, 344, 346, 347, 349, 350, 352, 353, 355, 356, 358, 359, 361, 362, 364, 365],costs = [3, 9, 25]) == 309\n assert candidate(days = [1, 14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196, 210, 224, 238, 252, 266, 280, 294, 308, 322, 336, 350, 364],costs = [4, 15, 40]) == 108\n assert candidate(days = [1, 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, 365],costs = [1, 5, 20]) == 183\n assert candidate(days = [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],costs = [5, 20, 60]) == 185\n assert candidate(days = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],costs = [2, 5, 15]) == 17\n assert candidate(days = [2, 3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 20, 21, 28, 29, 30, 31, 32, 33, 34, 35, 36],costs = [3, 11, 25]) == 36\n assert candidate(days = [3, 4, 7, 9, 14, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 300, 305, 310, 315, 320, 325, 330, 335, 340, 345, 350, 355, 360, 365],costs = [5, 25, 100]) == 375\n assert candidate(days = [1, 3, 4, 5, 6, 7, 15, 16, 17, 18, 19, 20, 30, 31, 32, 33, 34, 35, 36, 37],costs = [3, 8, 20]) == 27\n assert candidate(days = [1, 10, 20, 21, 22, 30, 31, 40, 50, 60, 70, 80, 90, 100],costs = [5, 15, 50]) == 70\n assert candidate(days = [1, 3, 4, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36],costs = [4, 10, 20]) == 30\n assert candidate(days = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 365],costs = [5, 10, 15]) == 90\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],costs = [2, 7, 15]) == 15\n assert candidate(days = [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, 365],costs = [2, 5, 20]) == 53\n assert candidate(days = [1, 2, 3, 10, 11, 12, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52, 60, 61, 62, 70, 71, 72, 80, 81, 82, 90, 91, 92, 100, 101, 102, 110, 111, 112, 120, 121, 122, 130, 131, 132, 140, 141, 142, 150, 151, 152, 160, 161, 162, 170, 171, 172, 180, 181, 182, 190, 191, 192, 200, 201, 202, 210, 211, 212, 220, 221, 222, 230, 231, 232, 240, 241, 242, 250, 251, 252, 260, 261, 262, 270, 271, 272, 280, 281, 282, 290, 291, 292, 300, 301, 302, 310, 311, 312, 320, 321, 322, 330, 331, 332, 340, 341, 342, 350, 351, 352, 360, 361, 362],costs = [2, 8, 20]) == 222\n assert candidate(days = [1, 4, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45],costs = [4, 15, 30]) == 60\n assert candidate(days = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 120, 127, 134, 141, 148, 155, 162],costs = [3, 15, 50]) == 72\n assert candidate(days = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],costs = [3, 10, 20]) == 33\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 35, 36],costs = [2, 9, 30]) == 39\n assert candidate(days = [1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58, 60, 61, 62, 64, 65, 66, 68, 69, 70, 72, 73, 74, 76, 77, 78, 80, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 116, 117, 118, 120, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 146, 148, 149, 150, 152, 153, 154, 156, 157, 158, 160, 161, 162, 164, 165, 166, 168, 169, 170, 172, 173, 174, 176, 177, 178, 180, 181, 182, 184, 185, 186, 188, 189, 190, 192, 193, 194, 196, 197, 198, 200, 201, 202, 204, 205, 206, 208, 209, 210, 212, 213, 214, 216, 217, 218, 220, 221, 222, 224, 225, 226, 228, 229, 230, 232, 233, 234, 236, 237, 238, 240, 241, 242, 244, 245, 246, 248, 249, 250, 252, 253, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 268, 269, 270, 272, 273, 274, 276, 277, 278, 280, 281, 282, 284, 285, 286, 288, 289, 290, 292, 293, 294, 296, 297, 298, 300, 301, 302, 304, 305, 306, 308, 309, 310, 312, 313, 314, 316, 317, 318, 320, 321, 322, 324, 325, 326, 328, 329, 330, 332, 333, 334, 336, 337, 338, 340, 341, 342, 344, 345, 346, 348, 349, 350, 352, 353, 354, 356, 357, 358, 360, 361, 362, 364, 365],costs = [4, 12, 40]) == 488\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],costs = [1, 6, 12]) == 18\n assert candidate(days = [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, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 365],costs = [1, 4, 10]) == 92\n assert candidate(days = [10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 30, 31, 32, 33, 34, 40, 41, 42, 43, 44, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 70, 71, 72, 73, 74, 80, 81, 82, 83, 84, 90, 91, 92, 93, 94],costs = [4, 25, 90]) == 180\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],costs = [4, 15, 30]) == 90\n assert candidate(days = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],costs = [3, 12, 45]) == 93\n assert candidate(days = [1, 2, 8, 9, 10, 16, 17, 18, 24, 25, 26, 32, 33, 34, 40, 41, 42, 48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74, 80, 81, 82, 88, 89, 90, 96, 97, 98, 104, 105, 106, 112, 113, 114, 120, 121, 122, 128, 129, 130, 136, 137, 138, 144, 145, 146, 152, 153, 154, 160, 161, 162, 168, 169, 170, 176, 177, 178, 184, 185, 186, 192, 193, 194, 200, 201, 202, 208, 209, 210],costs = [2, 7, 25]) == 160\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],costs = [2, 10, 25]) == 50\n assert candidate(days = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365],costs = [6, 18, 50]) == 222\n assert candidate(days = [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, 365],costs = [6, 15, 30]) == 228\n assert candidate(days = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365],costs = [1, 5, 10]) == 123\n assert candidate(days = [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],costs = [5, 20, 50]) == 185\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 20, 21, 28, 29, 30, 31, 32, 33, 34, 35, 36],costs = [1, 10, 30]) == 24\n assert candidate(days = [1, 3, 4, 6, 7, 9, 10, 11, 14, 15, 16, 17, 20, 21, 22, 23, 24, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39],costs = [4, 10, 25]) == 39\n assert candidate(days = [1, 5, 8, 10, 12, 16, 18, 21, 23, 25, 27, 30, 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],costs = [3, 10, 20]) == 40\n assert candidate(days = [1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33, 40, 41, 42, 43, 50, 51, 52, 53, 60],costs = [5, 12, 30]) == 60\n assert candidate(days = [1, 4, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],costs = [3, 10, 25]) == 34\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],costs = [3, 12, 30]) == 60\n assert candidate(days = [1, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 365],costs = [5, 12, 30]) == 130\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],costs = [2, 7, 15]) == 17\n assert candidate(days = [1, 7, 14, 15, 16, 17, 21, 28, 29, 30, 31, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],costs = [4, 20, 50]) == 88\n assert candidate(days = [1, 2, 5, 6, 7, 8, 9, 10, 14, 15, 16, 17, 18, 19, 23, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 37, 38, 39, 40],costs = [2, 12, 40]) == 54\n assert candidate(days = [1, 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],costs = [5, 20, 50]) == 265\n assert candidate(days = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],costs = [2, 8, 20]) == 22\n assert candidate(days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360],costs = [4, 10, 20]) == 68\n", "comparison": "exact"}, "public_tests": ["[1,4,6,7,8,20]\n[2,7,15]", "[1,2,3,4,5,6,7,8,9,10,30,31]\n[2,7,15]"], "hints": [], "metadata": {"canonical_parameter_names": ["days", "costs"], "leetcode_dataset_entry_point": "Solution().mincostTickets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:40+00:00", "tests_total": 79, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def mincostTickets(self, days: list[int], costs: list[int]) -> int:", "container": "Solution", "callable": "mincostTickets", "parameters": [{"name": "days", "type": "list[int]"}, {"name": "costs", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 984, "task_id": "string-without-aaa-or-bbb", "difficulty": "Medium", "problem_description": "Given two integers a and b, return any string s such that:\n\n- s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters,\n- The substring 'aaa' does not occur in s, and\n- The substring 'bbb' does not occur in s.\n\nExample 1:\n\nInput: a = 1, b = 2\nOutput: \"abb\"\nExplanation: \"abb\", \"bab\" and \"bba\" are all correct answers.\n\nExample 2:\n\nInput: a = 4, b = 1\nOutput: \"aabaa\"\n\nConstraints:\n\n- 0 <= a, b <= 100\n- It is guaranteed such an s exists for the given a and b.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 0,b = 5) == \"bbbbb\"\n assert candidate(a = 10,b = 10) == \"abababababababababab\"\n assert candidate(a = 6,b = 4) == \"aabaababab\"\n assert candidate(a = 7,b = 7) == \"ababababababab\"\n assert candidate(a = 4,b = 1) == \"aabaa\"\n assert candidate(a = 7,b = 2) == \"aabaabaaa\"\n assert candidate(a = 4,b = 6) == \"bbabbaabab\"\n assert candidate(a = 1,b = 2) == \"bba\"\n assert candidate(a = 5,b = 5) == \"ababababab\"\n assert candidate(a = 5,b = 0) == \"aaaaa\"\n assert candidate(a = 0,b = 0) == \"\"\n assert candidate(a = 5,b = 2) == \"aabaaba\"\n assert candidate(a = 2,b = 2) == \"abab\"\n assert candidate(a = 2,b = 7) == \"bbabbabbb\"\n assert candidate(a = 3,b = 3) == \"ababab\"\n assert candidate(a = 33,b = 67) == \"bbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbab\"\n assert candidate(a = 15,b = 5) == \"aabaabaabaabaabaaaaa\"\n assert candidate(a = 30,b = 70) == \"bbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbbbbbbbbb\"\n assert candidate(a = 33,b = 34) == \"bbaabababababababababababababababababababababababababababababababab\"\n assert candidate(a = 30,b = 25) == \"aabaabaabaabaababababababababababababababababababababab\"\n assert candidate(a = 100,b = 100) == \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 0,b = 100) == \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 27,b = 3) == \"aabaabaabaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 100,b = 0) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 8,b = 1) == \"aabaaaaaa\"\n assert candidate(a = 1,b = 100) == \"bbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 100,b = 1) == \"aabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 30,b = 30) == \"abababababababababababababababababababababababababababababab\"\n assert candidate(a = 30,b = 10) == \"aabaabaabaabaabaabaabaabaabaabaaaaaaaaaa\"\n assert candidate(a = 20,b = 30) == \"bbabbabbabbabbabbabbabbabbabbaabababababababababab\"\n assert candidate(a = 25,b = 25) == \"ababababababababababababababababababababababababab\"\n assert candidate(a = 20,b = 20) == \"abababababababababababababababababababab\"\n assert candidate(a = 50,b = 51) == \"bbaababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 33,b = 33) == \"ababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 10,b = 90) == \"bbabbabbabbabbabbabbabbabbabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 15,b = 15) == \"ababababababababababababababab\"\n assert candidate(a = 85,b = 15) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 99,b = 1) == \"aabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 45,b = 55) == \"bbabbabbabbabbabbabbabbabbabbaababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 1,b = 99) == \"bbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 49,b = 1) == \"aabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 35,b = 40) == \"bbabbabbabbabbaabababababababababababababababababababababababababababababab\"\n assert candidate(a = 70,b = 30) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaaaaaaaaaa\"\n assert candidate(a = 7,b = 3) == \"aabaabaaba\"\n assert candidate(a = 25,b = 30) == \"bbabbabbabbabbaabababababababababababababababababababab\"\n assert candidate(a = 75,b = 25) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 34,b = 33) == \"aababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 51,b = 50) == \"aabababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 1,b = 49) == \"bbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 90,b = 10) == \"aabaabaabaabaabaabaabaabaabaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 80,b = 20) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(a = 30,b = 20) == \"aabaabaabaabaabaabaabaabaabaababababababababababab\"\n assert candidate(a = 40,b = 60) == \"bbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbaabababababababababababababababababababab\"\n assert candidate(a = 50,b = 50) == \"abababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 3,b = 7) == \"bbabbabbab\"\n assert candidate(a = 60,b = 40) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababababababababababababababababababababab\"\n assert candidate(a = 8,b = 25) == \"bbabbabbabbabbabbabbabbabbbbbbbbb\"\n assert candidate(a = 1,b = 8) == \"bbabbbbbb\"\n assert candidate(a = 20,b = 15) == \"aabaabaabaabaababababababababababab\"\n assert candidate(a = 15,b = 35) == \"bbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbbbb\"\n assert candidate(a = 25,b = 75) == \"bbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 3,b = 10) == \"bbabbabbabbbb\"\n assert candidate(a = 20,b = 80) == \"bbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n assert candidate(a = 55,b = 45) == \"aabaabaabaabaabaabaabaabaabaabababababababababababababababababababababababababababababababababababab\"\n", "comparison": "exact"}, "public_tests": ["1\n2", "4\n1"], "hints": [], "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().strWithout3a3b", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:43+00:00", "tests_total": 64, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def strWithout3a3b(self, a: int, b: int) -> str:", "container": "Solution", "callable": "strWithout3a3b", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 985, "task_id": "sum-of-even-numbers-after-queries", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an array queries where queries[i] = [val_i, index_i].\n\nFor each query i, first, apply nums[index_i] = nums[index_i] + val_i, then print the sum of the even values of nums.\n\nReturn an integer array answer where answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: nums = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]]\nOutput: [8,6,2,4]\nExplanation: At the beginning, the array is [1,2,3,4].\nAfter adding 1 to nums[0], the array is [2,2,3,4], and the sum of even values is 2 + 2 + 4 = 8.\nAfter adding -3 to nums[1], the array is [2,-1,3,4], and the sum of even values is 2 + 4 = 6.\nAfter adding -4 to nums[0], the array is [-2,-1,3,4], and the sum of even values is -2 + 4 = 2.\nAfter adding 2 to nums[3], the array is [-2,-1,3,6], and the sum of even values is -2 + 6 = 4.\n\nExample 2:\n\nInput: nums = [1], queries = [[4,0]]\nOutput: [0]\n\nConstraints:\n\n- 1 <= nums.length <= 10^4\n- -10^4 <= nums[i] <= 10^4\n- 1 <= queries.length <= 10^4\n- -10^4 <= val_i <= 10^4\n- 0 <= index_i < nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 4, 6, 8],queries = [[1, 0], [2, 1], [3, 2], [4, 3]]) == [18, 20, 14, 18]\n assert candidate(nums = [2, 4, 6, 8],queries = [[-2, 0], [2, 1], [-4, 2], [4, 3]]) == [18, 20, 16, 20]\n assert candidate(nums = [0, 0, 0, 0],queries = [[1, 0], [1, 1], [1, 2], [1, 3]]) == [0, 0, 0, 0]\n assert candidate(nums = [10, 20, 30, 40],queries = [[-10, 0], [-20, 1], [-30, 2], [-40, 3]]) == [90, 70, 40, 0]\n assert candidate(nums = [1, 2, 3, 4],queries = [[1, 0], [-3, 1], [-4, 0], [2, 3]]) == [8, 6, 2, 4]\n assert candidate(nums = [1],queries = [[4, 0]]) == [0]\n assert candidate(nums = [1, 3, 5, 7],queries = [[2, 0], [4, 1], [6, 2], [8, 3]]) == [0, 0, 0, 0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[-1, 0], [-3, 1], [-5, 2], [-7, 3], [-9, 4], [-11, 5], [-13, 6], [-15, 7], [-17, 8], [-19, 9]]) == [108, 104, 98, 90, 80, 68, 54, 38, 20, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5],queries = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4]]) == [-6, -4, -4, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4], [12, 5]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[10, 0], [20, 1], [30, 2], [40, 3], [50, 4], [60, 5], [70, 6], [80, 7], [90, 8], [100, 9]]) == [560, 580, 610, 650, 700, 760, 830, 910, 1000, 1100]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4], [2, 0], [4, 1], [6, 2], [8, 3], [10, 4]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[-2, 0], [-4, 1], [-6, 2], [-8, 3], [-10, 4], [-12, 5], [-14, 6], [-16, 7], [-18, 8], [-20, 9]]) == [108, 104, 98, 90, 80, 68, 54, 38, 20, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],queries = [[5, 0], [-10, 1], [15, 2], [-20, 3], [25, 4], [-30, 5]]) == [70, 60, 90, 70, 120, 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],queries = [[1, 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]]) == [112, 110, 116, 112, 122, 116, 130, 122, 140, 130, 152, 140, 166, 152, 182, 166, 200, 182, 220, 200]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0], [-1, 1], [2, 2], [-2, 3], [3, 4], [-3, 5], [4, 6], [-4, 7], [5, 8]]) == [30, 22, 22, 20, 28, 24, 24, 20, 26]\n assert candidate(nums = [0, -2, 4, -6, 8],queries = [[2, 0], [-4, 1], [6, 2], [-8, 3], [10, 4]]) == [6, 2, 8, 0, 10]\n assert candidate(nums = [0, 0, 0, 0, 0],queries = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1],queries = [[1, 0], [-1, 1], [1, 2], [-1, 3], [1, 4], [-1, 5], [1, 6], [-1, 7]]) == [2, 0, 2, 0, 2, 0, 2, 0]\n assert candidate(nums = [-1, -3, -5, -7, -9],queries = [[1, 0], [3, 1], [5, 2], [7, 3], [9, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9]]) == [540, 538, 508, 504, 454, 448, 378, 370, 280, 270]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[-1, 0], [1, 1], [-1, 2], [1, 3], [-1, 4], [1, 5], [-1, 6], [1, 7], [-1, 8], [1, 9]]) == [0, 2, 2, 4, 4, 6, 6, 8, 8, 10]\n assert candidate(nums = [0, 0, 0, 0, 0],queries = [[2, 0], [-2, 1], [3, 2], [-3, 3], [4, 4]]) == [2, 0, 0, 0, 4]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],queries = [[-5, 0], [5, 1], [10, 2], [-10, 3], [15, 4], [-15, 5]]) == [60, 50, 50, 40, 80, 50]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [-2, 0], [-2, 1], [-2, 2], [-2, 3], [-2, 4]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9]]) == [20, 20, 18, 18, 14, 14, 8, 8, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],queries = [[-500, 0], [-1500, 1], [-2500, 2], [-3500, 3], [-4500, 4], [500, 0], [1500, 1], [2500, 2], [3500, 3], [4500, 4]]) == [14500, 13000, 10500, 7000, 2500, 3000, 4500, 7000, 10500, 15000]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[-10, 0], [-20, 1], [-30, 2], [-40, 3], [-50, 4], [-60, 5], [-70, 6], [-80, 7], [-90, 8], [-100, 9], [10, 0], [20, 1], [30, 2], [40, 3], [50, 4], [60, 5], [70, 6], [80, 7], [90, 8], [100, 9]]) == [5490, 5470, 5440, 5400, 5350, 5290, 5220, 5140, 5050, 4950, 4960, 4980, 5010, 5050, 5100, 5160, 5230, 5310, 5400, 5500]\n assert candidate(nums = [0, 0, 0, 0],queries = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 0], [1, 1], [1, 2], [1, 3]]) == [0, 0, 0, 0, 2, 4, 6, 8]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4], [12, 5], [14, 6], [16, 7], [18, 8], [20, 9]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6],queries = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]) == [-12, -10, -10, -6, -6, 0]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[-50, 0], [-100, 1], [-150, 2], [-200, 3], [-250, 4], [50, 0], [100, 1], [150, 2], [200, 3], [250, 4]]) == [1450, 1350, 1200, 1000, 750, 800, 900, 1050, 1250, 1500]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[-100, 0], [100, 1], [-200, 2], [200, 3], [-300, 4], [300, 0], [-400, 1], [400, 2], [-500, 3], [500, 4]]) == [1400, 1500, 1300, 1500, 1200, 1500, 1100, 1500, 1000, 1500]\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, 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]]) == [60, 60, 58, 56, 58, 60, 56, 52, 56, 60, 54, 48, 56, 64, 56, 48, 58, 68, 58, 48]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],queries = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 0], [12, 1], [13, 2], [14, 3], [15, 4], [16, 5], [17, 6], [18, 7], [19, 8], [20, 9]]) == [-30, -28, -28, -24, -24, -18, -18, -10, -10, 0, 0, 12, 12, 26, 26, 42, 42, 60, 60, 80]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9]]) == [30, 28, 28, 24, 24, 18, 18, 10, 10, 0]\n assert candidate(nums = [1000, -1000, 2000, -2000],queries = [[500, 0], [-500, 1], [1000, 2], [-1000, 3]]) == [500, 0, 1000, 0]\n assert candidate(nums = [10000, -10000, 5000, -5000, 2500],queries = [[-10000, 0], [10000, 1], [-5000, 2], [5000, 3], [-2500, 4]]) == [-7500, 2500, -2500, 2500, 0]\n assert candidate(nums = [0, -1, -2, 3, 5, 7, 9, 11],queries = [[2, 0], [5, 1], [-3, 2], [4, 3], [-1, 4], [10, 5], [15, 6], [20, 7]]) == [0, 4, 6, 6, 10, 10, 34, 34]\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, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == [110, 108, 108, 104, 104, 98, 98, 90, 90, 80, 92, 94, 110, 114, 134, 140, 164, 172, 200, 210]\n assert candidate(nums = [0, 0, 0, 0],queries = [[1, 0], [2, 1], [3, 2], [4, 3]]) == [0, 2, 2, 6]\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9]]) == [4020, 4020, 3018, 3018, 2014, 2014, 1008, 1008, 0, 0]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[-50, 0], [50, 1], [-100, 2], [100, 3], [-150, 4]]) == [1450, 1500, 1400, 1500, 1350]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9]]) == [108, 106, 100, 96, 86, 80, 66, 58, 40, 30]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000],queries = [[-500, 0], [500, 1], [-1000, 2], [1000, 3], [-1500, 4], [1500, 5]]) == [-500, 0, -1000, 0, -1500, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000],queries = [[-500, 0], [-1500, 1], [2000, 2], [3500, 3]]) == [9500, 8000, 10000, 13500]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[1, 0], [-1, 1], [2, 2], [-2, 3], [3, 4], [-3, 5], [4, 6], [-4, 7], [5, 8], [-5, 9]]) == [90, 80, 82, 80, 70, 60, 64, 60, 50, 40]\n assert candidate(nums = [5000, -5000, 5000, -5000],queries = [[10000, 0], [10000, 1], [10000, 2], [10000, 3]]) == [10000, 20000, 30000, 40000]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],queries = [[-2000, 0], [-3000, 1], [-4000, 2], [-5000, 3], [-6000, 4]]) == [13000, 10000, 6000, 1000, -5000]\n assert candidate(nums = [-1, -2, -3, -4, -5],queries = [[1, 0], [-1, 1], [2, 2], [-2, 3], [3, 4]]) == [-6, -4, -4, -6, -8]\n assert candidate(nums = [-9999, -9998, -9997, -9996, -9995],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4]]) == [-29994, -29996, -39996, -40000, -50000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],queries = [[-1000, 0], [-2000, 1], [-3000, 2], [-4000, 3], [-5000, 4]]) == [14000, 12000, 9000, 5000, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == [110, 108, 108, 104, 104, 98, 98, 90, 90, 80, 92, 94, 110, 114, 134, 140, 164, 172, 200, 210]\n assert candidate(nums = [100, -100, 200, -200, 300],queries = [[-50, 0], [50, 1], [-100, 2], [100, 3], [-150, 4]]) == [250, 300, 200, 300, 150]\n assert candidate(nums = [100, 200, 300, 400, 500, 600],queries = [[-100, 0], [-200, 1], [-300, 2], [-400, 3], [-500, 4], [-600, 5]]) == [2000, 1800, 1500, 1100, 600, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[-1, 0], [1, 1], [-2, 2], [2, 3], [-3, 4], [3, 5], [-4, 6], [4, 7], [-5, 8], [5, 9]]) == [20, 22, 20, 20, 16, 24, 20, 20, 12, 26]\n assert candidate(nums = [9999, -9999, 9999, -9999, 9999],queries = [[10000, 0], [-10000, 1], [10000, 2], [-10000, 3], [10000, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9999, -9999, 9999, -9999, 9999],queries = [[10000, 0], [-10000, 1], [10000, 2], [-10000, 3], [10000, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4], [12, 5], [14, 6], [16, 7]]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 15, 25, 35, 45],queries = [[-5, 0], [10, 1], [-15, 2], [20, 3], [25, 4]]) == [0, 0, 10, 10, 80]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[-100, 0], [-200, 1], [-300, 2], [-400, 3], [-500, 4], [-600, 5], [-700, 6], [-800, 7], [-900, 8], [-1000, 9]]) == [5400, 5200, 4900, 4500, 4000, 3400, 2700, 1900, 1000, 0]\n assert candidate(nums = [5, 8, 12, 15, 20],queries = [[3, 1], [-5, 0], [10, 4], [7, 3]]) == [32, 32, 42, 64]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [9999, -9999, 9998, -9998],queries = [[1, 0], [-1, 1], [2, 2], [-2, 3]]) == [10000, 0, 2, 0]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],queries = [[-100, 0], [-200, 1], [-300, 2], [-400, 3], [-500, 4], [-600, 5], [-700, 6], [-800, 7], [-900, 8], [-1000, 9]]) == [9900, 9700, 9400, 9000, 8500, 7900, 7200, 6400, 5500, 4500]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0],queries = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 15, 25, 35, 45],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9]]) == [108, 106, 100, 96, 86, 80, 66, 58, 40, 30]\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995],queries = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4]]) == [29994, 29996, 39996, 40000, 50000]\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 = [[2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19]]) == [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, 3, 5, 7, 9, 11],queries = [[2, 0], [4, 1], [6, 2], [8, 3], [10, 4], [12, 5]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, -2, 4, -6, 8, -10],queries = [[1, 0], [-1, 1], [2, 2], [-2, 3], [3, 4], [-3, 5]]) == [-6, -4, -2, -4, -12, -2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[-1, 0], [-2, 1], [-3, 2], [-4, 3], [-5, 4], [-6, 5], [-7, 6], [-8, 7], [-9, 8], [-10, 9]]) == [30, 28, 28, 24, 24, 18, 18, 10, 10, 0]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[-100, 0], [-200, 1], [-300, 2], [-400, 3], [-500, 4]]) == [1400, 1200, 900, 500, 0]\n assert candidate(nums = [-10, 15, -20, 25, -30],queries = [[10, 0], [-15, 1], [20, 2], [-25, 3], [30, 4]]) == [-50, -50, -30, -30, 0]\n assert candidate(nums = [-2, -4, -6, -8, -10],queries = [[3, 0], [-5, 1], [7, 2], [-9, 3], [11, 4]]) == [-28, -24, -18, -10, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],queries = [[2, 0], [4, 1], [8, 2], [16, 3], [32, 4], [64, 5], [128, 6], [256, 7]]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[-5, 0], [-10, 1], [-15, 2], [-20, 3], [-25, 4], [-30, 5], [-35, 6], [-40, 7], [-45, 8], [-50, 9]]) == [150, 140, 140, 120, 120, 90, 90, 50, 50, 0]\n assert candidate(nums = [-1, -2, -3, -4],queries = [[1, 0], [-2, 1], [3, 2], [-4, 3]]) == [-6, -8, -8, -12]\n assert candidate(nums = [2, 3, 5, 7, 11],queries = [[4, 0], [6, 1], [8, 2], [10, 3], [12, 4], [14, 0], [-14, 1]]) == [6, 6, 6, 6, 6, 20, 20]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[-50, 0], [100, 1], [-150, 2], [200, 3], [-250, 4]]) == [1450, 1550, 1400, 1600, 1350]\n assert candidate(nums = [5, 15, 25, 35, 45],queries = [[-5, 0], [10, 1], [15, 2], [20, 3], [25, 4]]) == [0, 0, 40, 40, 110]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[-2, 0], [-4, 1], [-6, 2], [-8, 3], [-10, 4], [-12, 5], [-14, 6], [-16, 7], [-18, 8], [-20, 9]]) == [108, 104, 98, 90, 80, 68, 54, 38, 20, 0]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n[[1,0],[-3,1],[-4,0],[2,3]]", "[1]\n[[4,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().sumEvenAfterQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:45+00:00", "tests_total": 88, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def sumEvenAfterQueries(self, nums: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "sumEvenAfterQueries", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 986, "task_id": "interval-list-intersections", "difficulty": "Medium", "problem_description": "You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [start_i, end_i] and secondList[j] = [start_j, end_j]. Each list of intervals is pairwise disjoint and in sorted order.\n\nReturn the intersection of these two interval lists.\n\nA closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b.\n\nThe intersection of two closed intervals is a set of real numbers that are either empty or represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].\n\nExample 1:\n\nInput: firstList = [[0,2],[5,10],[13,23],[24,25]], secondList = [[1,5],[8,12],[15,24],[25,26]]\nOutput: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]\n\nExample 2:\n\nInput: firstList = [[1,3],[5,9]], secondList = []\nOutput: []\n\nConstraints:\n\n- 0 <= firstList.length, secondList.length <= 1000\n- firstList.length + secondList.length >= 1\n- 0 <= start_i < end_i <= 10^9\n- end_i < start_{i+1}\n- 0 <= start_j < end_j <= 10^9\n- end_j < start_{j+1}\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(firstList = [[1, 2], [3, 5], [6, 7]],secondList = [[2, 3], [5, 6]]) == [[2, 2], [3, 3], [5, 5], [6, 6]]\n assert candidate(firstList = [[1, 5]],secondList = [[2, 3]]) == [[2, 3]]\n assert candidate(firstList = [],secondList = [[1, 5], [8, 12]]) == []\n assert candidate(firstList = [[1, 5]],secondList = [[2, 3], [6, 7]]) == [[2, 3]]\n assert candidate(firstList = [[5, 10]],secondList = [[1, 5], [5, 10]]) == [[5, 5], [5, 10]]\n assert candidate(firstList = [[1, 3], [4, 5], [6, 7]],secondList = [[2, 3], [5, 6], [8, 9]]) == [[2, 3], [5, 5], [6, 6]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6]],secondList = [[2, 3], [5, 7]]) == [[2, 2], [3, 3], [5, 6]]\n assert candidate(firstList = [[1, 10]],secondList = [[5, 5]]) == [[5, 5]]\n assert candidate(firstList = [[1, 3], [5, 9]],secondList = []) == []\n assert candidate(firstList = [[0, 2], [5, 10], [13, 23], [24, 25]],secondList = [[1, 5], [8, 12], [15, 24], [25, 26]]) == [[1, 2], [5, 5], [8, 10], [15, 23], [24, 24], [25, 25]]\n assert candidate(firstList = [],secondList = [[1, 5], [8, 12], [15, 24], [25, 26]]) == []\n assert candidate(firstList = [[0, 2]],secondList = [[1, 2]]) == [[1, 2]]\n assert candidate(firstList = [[1, 5], [10, 14]],secondList = [[3, 6], [7, 9]]) == [[3, 5]]\n assert candidate(firstList = [[1, 3], [3, 7], [8, 10]],secondList = [[2, 4], [6, 8], [10, 12]]) == [[2, 3], [3, 4], [6, 7], [8, 8], [10, 10]]\n assert candidate(firstList = [[5, 10], [15, 20], [25, 30]],secondList = [[3, 7], [12, 18], [23, 28]]) == [[5, 7], [15, 18], [25, 28]]\n assert candidate(firstList = [[1, 500000000], [500000001, 1000000000]],secondList = [[250000000, 750000000], [750000001, 1250000000]]) == [[250000000, 500000000], [500000001, 750000000], [750000001, 1000000000]]\n assert candidate(firstList = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],secondList = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [[1, 2], [2, 2], [2, 3], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6]]\n assert candidate(firstList = [[0, 5], [10, 15], [20, 25], [30, 35]],secondList = [[2, 7], [12, 17], [22, 27], [29, 34]]) == [[2, 5], [12, 15], [22, 25], [30, 34]]\n assert candidate(firstList = [[1, 3], [6, 9]],secondList = [[2, 5], [7, 10], [11, 15]]) == [[2, 3], [7, 9]]\n assert candidate(firstList = [[0, 5], [10, 15], [20, 25], [30, 35]],secondList = [[5, 10], [15, 20], [25, 30]]) == [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30]]\n assert candidate(firstList = [[1, 2], [4, 8], [10, 15], [17, 22]],secondList = [[3, 5], [6, 10], [12, 18], [20, 25]]) == [[4, 5], [6, 8], [10, 10], [12, 15], [17, 18], [20, 22]]\n assert candidate(firstList = [[1, 2], [4, 5], [7, 8], [10, 11]],secondList = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 2], [4, 4], [5, 5], [7, 8]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25], [30, 35]],secondList = [[6, 10], [11, 20], [21, 30], [31, 35]]) == [[10, 10], [11, 15], [20, 20], [21, 25], [30, 30], [31, 35]]\n assert candidate(firstList = [[1, 3], [5, 7], [9, 11]],secondList = [[2, 4], [6, 8], [10, 12]]) == [[2, 3], [6, 7], [10, 11]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8]],secondList = [[2, 3], [4, 5], [6, 7], [8, 9]]) == [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]\n assert candidate(firstList = [[1, 10], [20, 30], [40, 50], [60, 70]],secondList = [[15, 25], [35, 45], [55, 65], [65, 75]]) == [[20, 25], [40, 45], [60, 65], [65, 70]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6]],secondList = [[1, 6], [3, 5], [5, 7]]) == [[1, 2], [3, 4], [5, 6], [5, 5], [5, 6]]\n assert candidate(firstList = [[0, 10], [20, 30], [40, 50], [60, 70]],secondList = [[10, 20], [30, 40], [50, 60], [70, 80]]) == [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70]]\n assert candidate(firstList = [[1, 10], [15, 20], [25, 30]],secondList = [[5, 12], [17, 22], [27, 32]]) == [[5, 10], [17, 20], [27, 30]]\n assert candidate(firstList = [[5, 10], [15, 20], [25, 30]],secondList = [[5, 10], [15, 20], [25, 30]]) == [[5, 10], [15, 20], [25, 30]]\n assert candidate(firstList = [[1, 3], [4, 7], [8, 10], [11, 13]],secondList = [[2, 4], [5, 6], [9, 12]]) == [[2, 3], [4, 4], [5, 6], [9, 10], [11, 12]]\n assert candidate(firstList = [[1, 2]],secondList = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1, 2], [2, 2]]\n assert candidate(firstList = [[1, 1000000000]],secondList = [[500000000, 1000000000]]) == [[500000000, 1000000000]]\n assert candidate(firstList = [[0, 10], [20, 30], [40, 50]],secondList = [[15, 25], [35, 45], [55, 65]]) == [[20, 25], [40, 45]]\n assert candidate(firstList = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],secondList = [[1, 3], [3, 5], [5, 7]]) == [[1, 2], [2, 3], [3, 3], [3, 4], [4, 5], [5, 5], [5, 6]]\n assert candidate(firstList = [[1, 10]],secondList = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(firstList = [[1, 2], [4, 5], [7, 8], [10, 11]],secondList = [[2, 3], [5, 6], [8, 9], [11, 12]]) == [[2, 2], [5, 5], [8, 8], [11, 11]]\n assert candidate(firstList = [[1, 100], [200, 300], [400, 500]],secondList = [[50, 150], [250, 350], [450, 550]]) == [[50, 100], [250, 300], [450, 500]]\n assert candidate(firstList = [[1, 20], [25, 30], [35, 40]],secondList = [[5, 15], [20, 25], [30, 35]]) == [[5, 15], [20, 20], [25, 25], [30, 30], [35, 35]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25], [30, 35]],secondList = [[5, 10], [15, 20], [25, 30], [35, 40]]) == [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]\n assert candidate(firstList = [[1, 2]],secondList = [[1, 2], [2, 3], [3, 4]]) == [[1, 2], [2, 2]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25], [30, 35]],secondList = [[0, 5], [10, 20], [25, 35]]) == [[1, 5], [10, 15], [20, 20], [25, 25], [30, 35]]\n assert candidate(firstList = [[1, 2], [2, 3], [3, 4]],secondList = [[1, 2], [2, 3], [3, 4]]) == [[1, 2], [2, 2], [2, 3], [3, 3], [3, 4]]\n assert candidate(firstList = [[1, 3], [3, 5], [5, 7], [7, 9]],secondList = [[2, 4], [4, 6], [6, 8], [8, 10]]) == [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]\n assert candidate(firstList = [[1, 10], [11, 20], [21, 30]],secondList = [[5, 15], [25, 35], [35, 45]]) == [[5, 10], [11, 15], [25, 30]]\n assert candidate(firstList = [[1, 3], [6, 9]],secondList = [[2, 5], [7, 10]]) == [[2, 3], [7, 9]]\n assert candidate(firstList = [[1, 2], [4, 5], [7, 8], [10, 11]],secondList = [[0, 1], [3, 4], [6, 7], [9, 10]]) == [[1, 1], [4, 4], [7, 7], [10, 10]]\n assert candidate(firstList = [[5, 10], [15, 20], [25, 30]],secondList = [[10, 15], [20, 25], [30, 35]]) == [[10, 10], [15, 15], [20, 20], [25, 25], [30, 30]]\n assert candidate(firstList = [[1, 15], [20, 25], [30, 35]],secondList = [[10, 18], [22, 27], [33, 38]]) == [[10, 15], [22, 25], [33, 35]]\n assert candidate(firstList = [[1, 50], [100, 150], [200, 250], [300, 350]],secondList = [[25, 75], [125, 175], [225, 275], [325, 375]]) == [[25, 50], [125, 150], [225, 250], [325, 350]]\n assert candidate(firstList = [[1, 2], [4, 6], [8, 10]],secondList = [[3, 5], [7, 9], [11, 13]]) == [[4, 5], [8, 9]]\n assert candidate(firstList = [[1, 3], [6, 9], [12, 15], [18, 21], [24, 27]],secondList = [[2, 4], [7, 10], [13, 16], [19, 22], [25, 28]]) == [[2, 3], [7, 9], [13, 15], [19, 21], [25, 27]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25]],secondList = [[2, 6], [12, 18], [22, 27]]) == [[2, 5], [12, 15], [22, 25]]\n assert candidate(firstList = [[1, 3], [6, 9], [12, 15], [18, 21]],secondList = [[2, 4], [7, 10], [13, 17], [20, 23]]) == [[2, 3], [7, 9], [13, 15], [20, 21]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8]],secondList = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [[1, 1], [1, 2], [2, 2], [3, 3], [3, 4], [4, 4], [5, 5], [5, 6], [6, 6], [7, 7], [7, 8]]\n assert candidate(firstList = [[1, 1000000000]],secondList = [[500000000, 500000001]]) == [[500000000, 500000001]]\n assert candidate(firstList = [[1, 5], [6, 10], [11, 15], [16, 20]],secondList = [[2, 4], [7, 9], [12, 14], [17, 19]]) == [[2, 4], [7, 9], [12, 14], [17, 19]]\n assert candidate(firstList = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],secondList = [[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]]\n assert candidate(firstList = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19]],secondList = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]]) == [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25]],secondList = [[1, 5], [10, 15], [20, 25]]) == [[1, 5], [10, 15], [20, 25]]\n assert candidate(firstList = [[10, 15], [20, 25], [30, 35], [40, 45]],secondList = [[5, 10], [15, 20], [25, 30], [35, 40]]) == [[10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40]]\n assert candidate(firstList = [[1, 5], [6, 10], [11, 15], [16, 20]],secondList = [[0, 2], [4, 6], [8, 12], [14, 18]]) == [[1, 2], [4, 5], [6, 6], [8, 10], [11, 12], [14, 15], [16, 18]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],secondList = [[2, 3], [4, 5], [6, 7], [8, 9]]) == [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]\n assert candidate(firstList = [[1, 2], [4, 5], [7, 8], [10, 11]],secondList = [[2, 4], [5, 7], [8, 10], [11, 13]]) == [[2, 2], [4, 4], [5, 5], [7, 7], [8, 8], [10, 10], [11, 11]]\n assert candidate(firstList = [[1, 500], [600, 800], [900, 1000]],secondList = [[100, 300], [400, 650], [750, 950]]) == [[100, 300], [400, 500], [600, 650], [750, 800], [900, 950]]\n assert candidate(firstList = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]],secondList = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15]]) == [[2, 2], [5, 5], [8, 8], [11, 11], [14, 14]]\n assert candidate(firstList = [[0, 100], [150, 200], [300, 350]],secondList = [[50, 120], [160, 180], [280, 330]]) == [[50, 100], [160, 180], [300, 330]]\n assert candidate(firstList = [[1, 3], [6, 9]],secondList = [[2, 5], [7, 10], [11, 13]]) == [[2, 3], [7, 9]]\n assert candidate(firstList = [[1, 3], [6, 9], [12, 15], [18, 21]],secondList = [[2, 4], [8, 10], [14, 17], [20, 22]]) == [[2, 3], [8, 9], [14, 15], [20, 21]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],secondList = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(firstList = [[1, 2], [4, 6], [8, 10], [12, 14]],secondList = [[1, 1], [3, 5], [7, 9], [11, 13], [15, 16]]) == [[1, 1], [4, 5], [8, 9], [12, 13]]\n assert candidate(firstList = [[1, 20], [30, 40], [50, 60]],secondList = [[5, 15], [25, 35], [45, 55]]) == [[5, 15], [30, 35], [50, 55]]\n assert candidate(firstList = [[1, 3], [3, 5], [5, 7], [7, 9]],secondList = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25]],secondList = [[2, 3], [8, 12], [18, 22]]) == [[2, 3], [10, 12], [20, 22]]\n assert candidate(firstList = [[5, 10], [15, 20], [25, 30]],secondList = [[3, 7], [12, 17], [22, 27]]) == [[5, 7], [15, 17], [25, 27]]\n assert candidate(firstList = [[1, 2], [2, 3], [3, 4], [4, 5]],secondList = [[1, 2]]) == [[1, 2]]\n assert candidate(firstList = [[1, 5], [5, 10]],secondList = [[3, 7], [8, 12]]) == [[3, 5], [5, 7], [8, 10]]\n assert candidate(firstList = [[10, 20], [30, 40], [50, 60]],secondList = [[5, 25], [35, 45], [55, 65]]) == [[10, 20], [35, 40], [55, 60]]\n assert candidate(firstList = [[1, 3], [6, 9], [11, 15], [20, 25]],secondList = [[2, 4], [8, 10], [16, 22], [23, 30]]) == [[2, 3], [8, 9], [20, 22], [23, 25]]\n assert candidate(firstList = [[0, 100], [200, 300], [400, 500]],secondList = [[50, 150], [250, 350], [450, 550]]) == [[50, 100], [250, 300], [450, 500]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8]],secondList = [[1, 8]]) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(firstList = [[2, 5], [11, 16], [21, 26], [31, 36]],secondList = [[3, 7], [13, 18], [23, 28], [33, 38]]) == [[3, 5], [13, 16], [23, 26], [33, 36]]\n assert candidate(firstList = [[1, 1000000000]],secondList = [[500000000, 600000000], [800000000, 900000000]]) == [[500000000, 600000000], [800000000, 900000000]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25]],secondList = [[3, 7], [12, 18], [23, 29]]) == [[3, 5], [12, 15], [23, 25]]\n assert candidate(firstList = [[1, 10], [12, 20], [22, 30]],secondList = [[5, 15], [18, 25], [28, 35]]) == [[5, 10], [12, 15], [18, 20], [22, 25], [28, 30]]\n assert candidate(firstList = [[1, 1000000000]],secondList = [[500000000, 600000000]]) == [[500000000, 600000000]]\n assert candidate(firstList = [[1, 2], [2, 3], [3, 4]],secondList = [[1, 2]]) == [[1, 2]]\n assert candidate(firstList = [[1, 2], [4, 5], [7, 8]],secondList = [[3, 4], [5, 6], [7, 8], [9, 10]]) == [[4, 4], [5, 5], [7, 8]]\n assert candidate(firstList = [[1, 3], [4, 7], [8, 11], [14, 17]],secondList = [[2, 5], [6, 9], [10, 13], [15, 18]]) == [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [15, 17]]\n assert candidate(firstList = [[1, 50], [60, 110], [120, 170], [180, 230]],secondList = [[25, 75], [85, 135], [145, 195], [205, 255]]) == [[25, 50], [60, 75], [85, 110], [120, 135], [145, 170], [180, 195], [205, 230]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],secondList = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]\n assert candidate(firstList = [[5, 10], [15, 20], [25, 30], [35, 40]],secondList = [[1, 100], [50, 55], [60, 65], [70, 75]]) == [[5, 10], [15, 20], [25, 30], [35, 40]]\n assert candidate(firstList = [[1, 3], [6, 9], [12, 15]],secondList = [[2, 5], [7, 10], [13, 18]]) == [[2, 3], [7, 9], [13, 15]]\n assert candidate(firstList = [[0, 10], [20, 30], [40, 50]],secondList = [[5, 15], [25, 35], [45, 55]]) == [[5, 10], [25, 30], [45, 50]]\n assert candidate(firstList = [[1, 5], [10, 15], [20, 25]],secondList = [[5, 10], [15, 20], [25, 30]]) == [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]\n assert candidate(firstList = [[1, 3], [4, 7], [8, 10], [11, 14]],secondList = [[2, 4], [6, 8], [10, 12], [13, 15]]) == [[2, 3], [4, 4], [6, 7], [8, 8], [10, 10], [11, 12], [13, 14]]\n assert candidate(firstList = [[1, 100]],secondList = [[50, 150], [200, 300]]) == [[50, 100]]\n assert candidate(firstList = [[100, 200], [300, 400], [500, 600]],secondList = [[150, 250], [350, 450], [550, 650]]) == [[150, 200], [350, 400], [550, 600]]\n assert candidate(firstList = [[1, 1000000000]],secondList = [[500000000, 1500000000]]) == [[500000000, 1000000000]]\n assert candidate(firstList = [[1, 10], [20, 30], [40, 50]],secondList = [[5, 15], [25, 35], [45, 55]]) == [[5, 10], [25, 30], [45, 50]]\n assert candidate(firstList = [[1, 10], [15, 20], [25, 30]],secondList = [[5, 15], [20, 25], [30, 35]]) == [[5, 10], [15, 15], [20, 20], [25, 25], [30, 30]]\n assert candidate(firstList = [[1, 2], [4, 6], [8, 10], [12, 14]],secondList = [[3, 5], [7, 9], [11, 13]]) == [[4, 5], [8, 9], [12, 13]]\n assert candidate(firstList = [[1, 2], [3, 4], [5, 6], [7, 8]],secondList = [[2, 3], [6, 7]]) == [[2, 2], [3, 3], [6, 6], [7, 7]]\n assert candidate(firstList = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90]],secondList = [[5, 15], [25, 35], [45, 55], [65, 75], [85, 95]]) == [[5, 10], [25, 30], [45, 50], [65, 70], [85, 90]]\n", "comparison": "exact"}, "public_tests": ["[[0,2],[5,10],[13,23],[24,25]]\n[[1,5],[8,12],[15,24],[25,26]]", "[[1,3],[5,9]]\n[]"], "hints": [], "metadata": {"canonical_parameter_names": ["firstList", "secondList"], "leetcode_dataset_entry_point": "Solution().intervalIntersection", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:47+00:00", "tests_total": 107, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "sweep-line"]}, "language": "python", "interface": {"raw_signature": "def intervalIntersection(self, firstList: list[list[int]], secondList: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "intervalIntersection", "parameters": [{"name": "firstList", "type": "list[list[int]]"}, {"name": "secondList", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 989, "task_id": "add-to-array-form-of-integer", "difficulty": "Easy", "problem_description": "The array-form of an integer num is an array representing its digits in left to right order.\n\n- For example, for num = 1321, the array form is [1,3,2,1].\n\nGiven num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.\n\nExample 1:\n\nInput: num = [1,2,0,0], k = 34\nOutput: [1,2,3,4]\nExplanation: 1200 + 34 = 1234\n\nExample 2:\n\nInput: num = [2,7,4], k = 181\nOutput: [4,5,5]\nExplanation: 274 + 181 = 455\n\nExample 3:\n\nInput: num = [2,1,5], k = 806\nOutput: [1,0,2,1]\nExplanation: 215 + 806 = 1021\n\nConstraints:\n\n- 1 <= num.length <= 10^4\n- 0 <= num[i] <= 9\n- num does not contain any leading zeros except for the zero itself.\n- 1 <= k <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = [1],k = 9) == [1, 0]\n assert candidate(num = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(num = [0],k = 10000) == [1, 0, 0, 0, 0]\n assert candidate(num = [2, 1, 5],k = 806) == [1, 0, 2, 1]\n assert candidate(num = [1, 2, 3, 4],k = 6789) == [8, 0, 2, 3]\n assert candidate(num = [9, 9, 9, 9],k = 1) == [1, 0, 0, 0, 0]\n assert candidate(num = [0],k = 23) == [2, 3]\n assert candidate(num = [5, 6, 7],k = 456) == [1, 0, 2, 3]\n assert candidate(num = [0],k = 256) == [2, 5, 6]\n assert candidate(num = [2, 7, 4],k = 181) == [4, 5, 5]\n assert candidate(num = [1, 2, 0, 0],k = 34) == [1, 2, 3, 4]\n assert candidate(num = [9, 9, 9],k = 1000) == [1, 9, 9, 9]\n assert candidate(num = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == [0, 0, 0, 0, 0, 0, 0, 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(num = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == [9, 8, 7, 6, 5, 4, 3, 2, 2]\n assert candidate(num = [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],k = 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]\n assert candidate(num = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 1) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(num = [9, 9, 9, 9, 9, 9, 9, 9, 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 = 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(num = [5, 0, 0, 5],k = 5005) == [1, 0, 0, 1, 0]\n assert candidate(num = [0, 0, 0, 1],k = 9999) == [1, 0, 0, 0, 0]\n assert candidate(num = [1, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 1) == [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(num = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 1) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(num = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 5]\n assert candidate(num = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 0]\n assert candidate(num = [9, 9, 9, 9, 9],k = 9999) == [1, 0, 9, 9, 9, 8]\n assert candidate(num = [5],k = 5) == [1, 0]\n assert candidate(num = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(num = [9, 9, 9, 9, 9, 9, 9, 9],k = 1) == [1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(num = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(num = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 2) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(num = [9],k = 9999) == [1, 0, 0, 0, 8]\n assert candidate(num = [0, 0, 0, 0],k = 9999) == [9, 9, 9, 9]\n", "comparison": "exact"}, "public_tests": ["[1,2,0,0]\n34", "[2,7,4]\n181", "[2,1,5]\n806"], "hints": [], "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().addToArrayForm", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:54+00:00", "tests_total": 75, "tests_dropped": 44, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def addToArrayForm(self, num: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "addToArrayForm", "parameters": [{"name": "num", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 990, "task_id": "satisfiability-of-equality-equations", "difficulty": "Medium", "problem_description": "You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: \"x_i==y_i\" or \"x_i!=y_i\".Here, x_i and y_i are lowercase letters (not necessarily different) that represent one-letter variable names.\n\nReturn true if it is possible to assign integers to variable names so as to satisfy all the given equations, or false otherwise.\n\nExample 1:\n\nInput: equations = [\"a==b\",\"b!=a\"]\nOutput: false\nExplanation: If we assign say, a = 1 and b = 1, then the first equation is satisfied, but not the second.\nThere is no way to assign the variables to satisfy both equations.\n\nExample 2:\n\nInput: equations = [\"b==a\",\"a==b\"]\nOutput: true\nExplanation: We could assign a = 1 and b = 1 to satisfy both equations.\n\nConstraints:\n\n- 1 <= equations.length <= 500\n- equations[i].length == 4\n- equations[i][0] is a lowercase letter.\n- equations[i][1] is either '=' or '!'.\n- equations[i][2] is '='.\n- equations[i][3] is a lowercase letter.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(equations = ['a!=a']) == False\n assert candidate(equations = ['a==b', 'c==d', 'e==f', 'g==h']) == True\n assert candidate(equations = ['c==c', 'b==d', 'x!=z']) == True\n assert candidate(equations = ['a==b', 'b==c', 'a!=c']) == False\n assert candidate(equations = ['a==a', 'b==b', 'c==c']) == True\n assert candidate(equations = ['a==b', 'b!=a', 'a==c', 'c==b']) == False\n assert candidate(equations = ['a!=b', 'b!=c', 'c!=a']) == True\n assert candidate(equations = ['a!=b', 'b!=c', 'a!=c']) == True\n assert candidate(equations = ['a==b', 'b!=c', 'c==a']) == False\n assert candidate(equations = ['b==a', 'a==b']) == True\n assert candidate(equations = ['f==g', 'g==f', 'f!=g']) == False\n assert candidate(equations = ['a==b', 'b!=a']) == False\n assert candidate(equations = ['a==b', 'b==c', 'a==c']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==a', 'a!=b', 'b!=c', 'c!=a']) == False\n assert candidate(equations = ['a==b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z==a']) == True\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a', 'a!=b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a', 'a!=b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z==w', 'w==x']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c!=a', 'a==d', 'd!=b', 'b!=c']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==a', 'e==f', 'f!=g', 'g==h', 'h==i', 'i!=j', 'j==k', 'k==l', 'l==m', 'm==n', 'n!=o', 'o==p', 'p==q', 'q==r', 'r==s', 's!=t', 't==u', 'u==v', 'v==w', 'w==x', 'x!=y', 'y!=z']) == True\n assert candidate(equations = ['x==y', 'y==z', 'z==w', 'w==x', 'x!=y']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=d', 'd==e', 'e==f', 'f!=g', 'g==h', 'h==i', 'i==j', 'j!=k', 'k==l', 'l==m', 'm==n', 'n!=o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z!=a']) == True\n assert candidate(equations = ['x==y', 'y==z', 'z==w', 'w!=x', 'p==q', 'q==r', 'r!=s', 's==t', 't!=u', 'u==v', 'v!=w', 'w==x', 'x==y', 'y!=z', 'z==a', 'a==b', 'b!=c', 'c==d', 'd!=e', 'e==f', 'f!=g', 'g==h']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z==x', 'x!=y', 'y!=z', 'z!=x']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==a', 'a!=g']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==m', 'm!=n']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=d', 'd!=e', 'e==f', 'f==g', 'g!=h', 'h!=i', 'i==j', 'j==k', 'k!=l', 'l!=m', 'm==n', 'n==o', 'o!=p', 'p!=q', 'q==r', 'r==s', 's!=t', 't!=u', 'u==v', 'v==w', 'w!=x', 'x!=y', 'y==z', 'z!=a']) == True\n assert candidate(equations = ['x==y', 'y==z', 'x!=z', 'w==x', 'w==y', 'w!=z']) == False\n assert candidate(equations = ['a==b', 'b==a', 'c!=d', 'd!=c', 'e==f', 'f!=e']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z!=a']) == False\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==t', 't==p', 'p!=r']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=d', 'd==e', 'e==f', 'f!=g', 'g==h', 'h!=i', 'i==j', 'j!=k', 'k==l', 'l!=m', 'm==n', 'n!=o']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a!=b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a']) == False\n assert candidate(equations = ['a==b', 'b==c', 'a==c', 'a!=b', 'b!=c', 'a!=c']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'a!=d']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z==x', 'u==v', 'v==w', 'w==u', 'x!=u']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a']) == True\n assert candidate(equations = ['p==q', 'q!=r', 'r==s', 's!=t', 't==u', 'u==p']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==a', 'c==d', 'd==c', 'e==f', 'f==e', 'g==h', 'h==g', 'i==j', 'j==i', 'k==l', 'l==k', 'm==n', 'n==m', 'o==p', 'p==o', 'q==r', 'r==q', 's==t', 't==s', 'u==v', 'v==u', 'w==x', 'x==w', 'y==z', 'z==y', 'a!=a']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a!=b']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=d', 'd==e', 'e==f', 'f!=g', 'g==h', 'h==i', 'i!=j', 'j==k', 'k==l', 'l!=m', 'm==n', 'n==o', 'o!=p', 'p==q', 'q==r', 'r!=s', 's==t', 't==u', 'u!=v', 'v==w', 'w==x', 'x!=y', 'y==z', 'z!=a', 'a==b']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a!=b']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=d', 'd==e', 'e==f', 'f!=a']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'a!=d', 'b!=c', 'd!=a']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z==w', 'w!=x']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==a', 'a==d', 'd==e', 'e==f', 'f==a', 'a!=b']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a!=c']) == False\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==p', 'p!=q']) == False\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==p', 'p!=q']) == False\n assert candidate(equations = ['a==b', 'b==c', 'a!=c', 'd==e', 'e==f', 'd!=f']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==a', 'a==d', 'b==e', 'c==f', 'd==e', 'e==f', 'f==d', 'a!=d', 'b!=e', 'c!=f']) == False\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==t', 't==p', 'p!=q']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'a!=d']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a', 'a!=b', 'b!=m']) == False\n assert candidate(equations = ['a==b', 'b!=c', 'c==d', 'd!=e', 'e==f', 'f==g', 'g!=h', 'h==i', 'i!=j', 'j==k', 'k!=l', 'l==m', 'm==n', 'n!=o', 'o==p', 'p!=q', 'q==r', 'r==s', 's!=t', 't==u', 'u!=v', 'v==w', 'w==x', 'x!=y', 'y==z']) == True\n assert candidate(equations = ['x==y', 'y==z', 'z==w', 'w==x', 'x!=y', 'y!=z', 'z!=w', 'w!=x']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z==x', 'x!=y']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=a', 'd==e', 'e==f', 'f!=d', 'g==h', 'h==i', 'i!=g', 'j==k', 'k==l', 'l!=j', 'm==n', 'n==o', 'o!=m']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c!=d', 'd==e', 'e==f', 'f!=g', 'g==h', 'h!=i', 'i==j', 'j!=k', 'k==l', 'l!=m', 'm==n', 'n==o', 'o!=p']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==a']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==a', 'a!=d', 'd!=e', 'e!=f', 'f!=a', 'a==b']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'a!=d', 'b==e', 'e!=f', 'f==g', 'g!=h', 'h==i', 'i!=j', 'j==k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=a']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==a', 'a!=b']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a']) == True\n assert candidate(equations = ['a==b', 'b==a', 'c==d', 'd==c', 'e==f', 'f==e', 'g==h', 'h==g', 'i==j', 'j==i', 'k==l', 'l==k', 'm==n', 'n==m', 'o==p', 'p==o', 'q==r', 'r==q', 's==t', 't==s', 'u==v', 'v==u', 'w==x', 'x==w', 'y==z', 'z==y']) == True\n assert candidate(equations = ['m==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==m', 'm!=n']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'a==d', 'a!=d']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==a', 'a!=b']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z!=x']) == False\n assert candidate(equations = ['x==y', 'y==z', 'z==w', 'w==v', 'v==u', 'u==x', 'x!=y']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o!=p', 'p==q', 'q==r', 'r!=s', 's==t', 't==u', 'u==v', 'v!=w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b!=c']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c!=a', 'd==e', 'e==f', 'f!=d', 'g==h', 'h==i', 'i!=g', 'j==k', 'k==l', 'l!=j', 'm==n', 'n==o', 'o!=m', 'p==q', 'q==r', 'r!=p', 's==t', 't==u', 'u!=s', 'v==w', 'w==x', 'x!=v', 'y==z', 'z==a', 'a!=y']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a!=b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a', 'a!=b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l!=m', 'm!=n', 'n!=o', 'o!=p', 'p!=q', 'q!=r', 'r!=s', 's!=t', 't!=u', 'u!=v', 'v!=w', 'w!=x', 'x!=y', 'y!=z', 'z!=a']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o!=p', 'p!=q', 'q==r', 'r==s', 's!=t', 't!=u', 'u==v', 'v==w', 'w!=x', 'x!=y', 'y==z', 'z==a', 'a!=b', 'b!=c', 'c!=d', 'd!=e', 'e!=f', 'f!=g', 'g!=h']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e!=f', 'f!=g', 'g!=h', 'h!=i', 'i!=j', 'j!=k', 'k!=l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a']) == True\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==t', 't==p', 'p!=t']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==d', 'd==e', 'e==f', 'f==g', 'g==h', 'h==i', 'i==j', 'j==k', 'k==l', 'l==m', 'm==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==a', 'a!=b']) == False\n assert candidate(equations = ['a==b', 'b==c', 'c==a', 'a!=d', 'd!=e', 'e!=a']) == True\n assert candidate(equations = ['a==b', 'b==c', 'c==a', 'a!=b']) == False\n assert candidate(equations = ['p==q', 'q==r', 'r==s', 's==t', 't==p', 'p!=q']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==m', 'm!=n']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==u', 'u==v', 'v==w', 'w==x', 'x==y', 'y==z', 'z==m', 'm!=n']) == False\n assert candidate(equations = ['m==n', 'n==o', 'o==p', 'p==q', 'q==r', 'r==s', 's==t', 't==m', 'm!=o']) == False\n", "comparison": "exact"}, "public_tests": ["[\"a==b\",\"b!=a\"]", "[\"b==a\",\"a==b\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["equations"], "leetcode_dataset_entry_point": "Solution().equationsPossible", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:56+00:00", "tests_total": 83, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "string", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def equationsPossible(self, equations: list[str]) -> bool:", "container": "Solution", "callable": "equationsPossible", "parameters": [{"name": "equations", "type": "list[str]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 991, "task_id": "broken-calculator", "difficulty": "Medium", "problem_description": "There is a broken calculator that has the integer startValue on its display initially. In one operation, you can:\n\n- multiply the number on display by 2, or\n- subtract 1 from the number on display.\n\nGiven two integers startValue and target, return the minimum number of operations needed to display target on the calculator.\n\nExample 1:\n\nInput: startValue = 2, target = 3\nOutput: 2\nExplanation: Use double operation and then decrement operation {2 -> 4 -> 3}.\n\nExample 2:\n\nInput: startValue = 5, target = 8\nOutput: 2\nExplanation: Use decrement and then double {5 -> 4 -> 8}.\n\nExample 3:\n\nInput: startValue = 3, target = 10\nOutput: 3\nExplanation: Use double, decrement and double {3 -> 6 -> 5 -> 10}.\n\nConstraints:\n\n- 1 <= startValue, target <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startValue = 2,target = 3) == 2\n assert candidate(startValue = 1000000000,target = 1) == 999999999\n assert candidate(startValue = 7,target = 15) == 6\n assert candidate(startValue = 2,target = 1) == 1\n assert candidate(startValue = 3,target = 10) == 3\n assert candidate(startValue = 100,target = 99) == 1\n assert candidate(startValue = 10,target = 1) == 9\n assert candidate(startValue = 1,target = 2) == 1\n assert candidate(startValue = 1,target = 1000000000) == 39\n assert candidate(startValue = 5,target = 8) == 2\n assert candidate(startValue = 1,target = 1) == 0\n assert candidate(startValue = 4,target = 7) == 2\n assert candidate(startValue = 100,target = 100) == 0\n assert candidate(startValue = 7,target = 19) == 5\n assert candidate(startValue = 8,target = 16) == 1\n assert candidate(startValue = 9,target = 28) == 4\n assert candidate(startValue = 1000000,target = 1000000) == 0\n assert candidate(startValue = 123456,target = 654321) == 41671\n assert candidate(startValue = 1000,target = 1001) == 501\n assert candidate(startValue = 15,target = 1) == 14\n assert candidate(startValue = 1000000,target = 999999) == 1\n assert candidate(startValue = 2,target = 1024) == 9\n assert candidate(startValue = 1024,target = 1) == 1023\n assert candidate(startValue = 2,target = 1023) == 10\n assert candidate(startValue = 10,target = 11) == 6\n assert candidate(startValue = 50,target = 1000) == 25\n assert candidate(startValue = 7,target = 128) == 8\n assert candidate(startValue = 3,target = 1023) == 11\n assert candidate(startValue = 23,target = 17) == 6\n assert candidate(startValue = 500,target = 1000000) == 26\n assert candidate(startValue = 2,target = 100) == 9\n assert candidate(startValue = 50,target = 101) == 28\n assert candidate(startValue = 15,target = 20) == 6\n assert candidate(startValue = 12,target = 32) == 6\n assert candidate(startValue = 3,target = 33) == 8\n assert candidate(startValue = 1000000,target = 1000001) == 500001\n assert candidate(startValue = 500,target = 1023) == 247\n assert candidate(startValue = 7,target = 47) == 5\n assert candidate(startValue = 13,target = 1) == 12\n assert candidate(startValue = 15,target = 97) == 8\n assert candidate(startValue = 123456789,target = 987654321) == 61728401\n assert candidate(startValue = 25,target = 24) == 1\n assert candidate(startValue = 2345678,target = 8765432) == 154322\n assert candidate(startValue = 256,target = 2048) == 3\n assert candidate(startValue = 12345,target = 54321) == 5560\n assert candidate(startValue = 20,target = 25) == 9\n assert candidate(startValue = 6,target = 9) == 3\n assert candidate(startValue = 500000000,target = 750000000) == 125000001\n assert candidate(startValue = 15,target = 10) == 5\n assert candidate(startValue = 1000,target = 500) == 500\n assert candidate(startValue = 9,target = 18) == 1\n assert candidate(startValue = 7,target = 1000) == 13\n assert candidate(startValue = 31,target = 15) == 16\n assert candidate(startValue = 15,target = 300) == 12\n assert candidate(startValue = 2,target = 2048) == 10\n assert candidate(startValue = 10,target = 15) == 4\n assert candidate(startValue = 5,target = 1023) == 10\n assert candidate(startValue = 25,target = 100) == 2\n assert candidate(startValue = 20,target = 5) == 15\n assert candidate(startValue = 15,target = 31) == 10\n assert candidate(startValue = 7,target = 1) == 6\n assert candidate(startValue = 8,target = 20) == 5\n assert candidate(startValue = 7,target = 100) == 6\n assert candidate(startValue = 999999999,target = 1000000000) == 500000000\n assert candidate(startValue = 64,target = 32) == 32\n assert candidate(startValue = 8,target = 1000) == 9\n assert candidate(startValue = 15,target = 7) == 8\n assert candidate(startValue = 12345,target = 67890) == 3863\n assert candidate(startValue = 3,target = 123456789) == 39\n assert candidate(startValue = 5,target = 123) == 8\n assert candidate(startValue = 1024,target = 512) == 512\n assert candidate(startValue = 1000000,target = 10000000) == 375004\n assert candidate(startValue = 12345,target = 98765) == 6178\n assert candidate(startValue = 10,target = 31) == 5\n assert candidate(startValue = 1,target = 1000000) == 28\n assert candidate(startValue = 8,target = 1) == 7\n assert candidate(startValue = 123,target = 456) == 11\n assert candidate(startValue = 100,target = 1) == 99\n assert candidate(startValue = 2,target = 1025) == 20\n assert candidate(startValue = 3456,target = 6789) == 63\n assert candidate(startValue = 500000000,target = 1000000000) == 1\n assert candidate(startValue = 1023,target = 1024) == 512\n assert candidate(startValue = 8,target = 15) == 2\n assert candidate(startValue = 7,target = 101) == 7\n assert candidate(startValue = 31,target = 8) == 23\n assert candidate(startValue = 3,target = 9) == 4\n assert candidate(startValue = 500,target = 250) == 250\n assert candidate(startValue = 987654321,target = 123456789) == 864197532\n assert candidate(startValue = 500,target = 1024) == 246\n assert candidate(startValue = 7,target = 150) == 9\n assert candidate(startValue = 8,target = 64) == 3\n assert candidate(startValue = 6,target = 32) == 5\n assert candidate(startValue = 10,target = 1023) == 10\n assert candidate(startValue = 13,target = 169) == 9\n assert candidate(startValue = 8,target = 1024) == 7\n", "comparison": "exact"}, "public_tests": ["2\n3", "5\n8", "3\n10"], "hints": [], "metadata": {"canonical_parameter_names": ["startValue", "target"], "leetcode_dataset_entry_point": "Solution().brokenCalc", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:06:58+00:00", "tests_total": 96, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def brokenCalc(self, startValue: int, target: int) -> int:", "container": "Solution", "callable": "brokenCalc", "parameters": [{"name": "startValue", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 992, "task_id": "subarrays-with-k-different-integers", "difficulty": "Hard", "problem_description": "Given an integer array nums and an integer k, return the number of good subarrays of nums.\n\nA good array is an array where the number of different integers in that array is exactly k.\n\n- For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [1,2,1,2,3], k = 2\nOutput: 7\nExplanation: Subarrays formed with exactly 2 different integers: [1,2], [2,1], [1,2], [2,3], [1,2,1], [2,1,2], [1,2,1,2]\n\nExample 2:\n\nInput: nums = [1,2,1,3,4], k = 3\nOutput: 3\nExplanation: Subarrays formed with exactly 3 different integers: [1,2,1,3], [2,1,3], [1,3,4].\n\nConstraints:\n\n- 1 <= nums.length <= 2 * 10^4\n- 1 <= nums[i], k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 4],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 55\n assert candidate(nums = [1, 2, 2, 1, 1, 3],k = 2) == 10\n assert candidate(nums = [1, 2, 3],k = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 3) == 4\n assert candidate(nums = [1, 2],k = 1) == 2\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 4],k = 3) == 9\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [1, 2, 1, 2, 3],k = 2) == 7\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == 15\n assert candidate(nums = [1, 2, 2, 1, 1],k = 2) == 8\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 6\n assert candidate(nums = [1, 2, 2, 1, 3],k = 2) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 15\n assert candidate(nums = [1, 2, 2, 1, 2],k = 2) == 9\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],k = 2) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3],k = 2) == 8\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 55\n assert candidate(nums = [1, 2, 3, 2, 2, 3, 1, 2, 3],k = 3) == 22\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 2) == 18\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 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],k = 3) == 253\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 = 4) == 21\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 6, 7, 8, 9],k = 5) == 143\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 11\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 91\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 210\n assert candidate(nums = [1, 2, 2, 1, 3, 1, 4, 2],k = 3) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 26\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],k = 2) == 13\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 3) == 18\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 3) == 19\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 3) == 35\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 = 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 = 10) == 66\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 = 10) == 237\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1],k = 2) == 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, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 10) == 44\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4],k = 2) == 9\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 2, 3, 1, 4],k = 3) == 14\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 2, 1, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 29\n assert candidate(nums = [1, 1, 2, 3, 2, 3, 3, 4, 4, 4, 4, 4],k = 3) == 23\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3],k = 4) == 18\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 3, 2, 1],k = 2) == 11\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2],k = 2) == 100\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 2) == 14\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 5) == 0\n assert candidate(nums = [1, 1, 2, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 75\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 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, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 7) == 24\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],k = 3) == 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],k = 5) == 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],k = 4) == 36\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 136\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 4) == 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 = 3) == 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],k = 4) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 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],k = 2) == 378\n assert candidate(nums = [1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1],k = 2) == 21\n assert candidate(nums = [1, 2, 1, 2, 3, 3, 4, 4, 5, 5],k = 3) == 12\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 120\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, 1, 2, 3, 4, 5],k = 5) == 253\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) == 136\n assert candidate(nums = [1, 2, 2, 1, 1, 3, 4, 3, 2, 1],k = 2) == 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) == 190\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 3) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 16\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 190\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2],k = 2) == 28\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 3) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 0\n assert candidate(nums = [1, 2, 2, 1, 3, 2, 4, 5, 3],k = 3) == 10\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],k = 3) == 48\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 2) == 36\n assert candidate(nums = [1, 2, 3, 2, 2, 3, 1, 1, 2, 3, 3, 3, 2, 1],k = 2) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 3) == 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 = 5) == 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],k = 4) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 66\n assert candidate(nums = [4, 2, 4, 4, 2, 2, 3, 1, 1, 4],k = 2) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 4) == 20\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 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],k = 5) == 93\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 4) == 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],k = 5) == 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, 1, 2, 3],k = 2) == 29\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 = 5) == 32\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1],k = 2) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 4) == 22\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 2, 1, 4, 4, 5, 5, 5, 5, 5],k = 3) == 27\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 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) == 11\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, 10, 10, 10, 1, 1, 2, 2, 3, 3],k = 4) == 72\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) == 72\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 = 5) == 106\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 2, 1, 1, 1],k = 3) == 162\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 2, 1, 4, 4, 3, 2, 1],k = 2) == 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, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 5) == 80\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 4) == 24\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 3) == 36\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 45\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 2, 1, 4, 4, 3, 2, 1, 5, 5, 4, 3, 2, 1, 6, 6, 5, 4, 3, 2, 1, 7, 7, 6, 5, 4, 3, 2, 1, 8, 8, 7, 6, 5, 4, 3, 2, 1, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 541\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) == 21\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 2],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, 1, 2, 3, 4, 5],k = 5) == 21\n", "comparison": "exact"}, "public_tests": ["[1,2,1,2,3]\n2", "[1,2,1,3,4]\n3"], "hints": ["Try generating all possible subarrays and check for the number of unique integers. Increment the count accordingly.", "How about using a map to store the count of integers?", "Think about the Sliding Window and 2-pointer approach."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().subarraysWithKDistinct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:00+00:00", "tests_total": 119, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "sliding-window", "counting"]}, "language": "python", "interface": {"raw_signature": "def subarraysWithKDistinct(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "subarraysWithKDistinct", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 994, "task_id": "rotting-oranges", "difficulty": "Medium", "problem_description": "You are given an m x n grid where each cell can have one of three values:\n\n- 0 representing an empty cell,\n- 1 representing a fresh orange, or\n- 2 representing a rotten orange.\n\nEvery minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.\n\nReturn the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1.\n\nExample 1:\n\nInput: grid = [[2,1,1],[1,1,0],[0,1,1]]\nOutput: 4\n\nExample 2:\n\nInput: grid = [[2,1,1],[0,1,1],[1,0,1]]\nOutput: -1\nExplanation: The orange in the bottom left corner (row 2, column 0) is never rotten, because rotting only happens 4-directionally.\n\nExample 3:\n\nInput: grid = [[0,2]]\nOutput: 0\nExplanation: Since there are already no fresh oranges at minute 0, the answer is just 0.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 10\n- grid[i][j] is 0, 1, or 2.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == -1\n assert candidate(grid = [[1, 2, 1, 1, 2, 1, 1]]) == 2\n assert candidate(grid = [[2, 2, 2], [2, 1, 2], [2, 2, 2]]) == 1\n assert candidate(grid = [[2, 1, 1], [0, 1, 1], [1, 0, 1]]) == -1\n assert candidate(grid = [[2, 1, 1], [1, 1, 0], [0, 1, 1]]) == 4\n assert candidate(grid = [[1], [2]]) == 1\n assert candidate(grid = [[0, 2]]) == 0\n assert candidate(grid = [[2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 0]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [0, 1, 2]]) == 4\n assert candidate(grid = [[2, 1, 0], [0, 1, 1], [1, 0, 2]]) == -1\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[2, 1, 1, 1], [1, 1, 1, 1], [1, 1, 2, 1], [1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 0, 2, 0, 1], [1, 0, 1, 2, 1], [0, 2, 1, 1, 0], [1, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[2, 1, 1, 1, 1, 1], [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\n assert candidate(grid = [[1, 1, 0, 1, 0], [1, 1, 0, 1, 1], [0, 1, 2, 0, 1], [1, 0, 1, 1, 2], [1, 1, 2, 1, 1]]) == 4\n assert candidate(grid = [[2, 1, 0, 1, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 1, 2]]) == -1\n assert candidate(grid = [[1, 2, 1, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 2, 1, 1, 1]]) == 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, 2, 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(grid = [[2, 1, 1, 0, 1], [1, 0, 1, 1, 1], [0, 1, 2, 1, 1], [1, 1, 1, 1, 0], [1, 0, 1, 1, 2]]) == 4\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, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 2]]) == -1\n assert candidate(grid = [[1, 1, 1, 1], [2, 1, 0, 2], [1, 0, 1, 1], [0, 2, 1, 1]]) == 2\n assert candidate(grid = [[2, 0, 1, 1, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 0, 1]]) == 13\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 2, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 11\n assert candidate(grid = [[2, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 2]]) == -1\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 2]]) == 5\n assert candidate(grid = [[1, 2, 1, 1, 2, 1, 1], [1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 2, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[2, 1, 1, 2, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 1]]) == 3\n assert candidate(grid = [[2, 1, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1], [0, 1, 0, 1, 1, 0]]) == -1\n assert candidate(grid = [[2, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1], [2, 1, 1, 1, 2]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 2]]) == -1\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 0, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 0\n assert candidate(grid = [[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]]) == 5\n assert candidate(grid = [[2, 1, 1, 1, 1], [1, 1, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 2]]) == 4\n assert candidate(grid = [[2, 2, 1, 1, 2], [1, 2, 0, 1, 2], [2, 1, 2, 0, 2], [1, 2, 2, 2, 1], [2, 1, 1, 1, 2]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 2, 1, 1, 1, 1], [1, 1, 1, 1, 2, 1, 1], [1, 2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 1], [1, 1, 1, 2, 1, 1, 1]]) == 3\n assert candidate(grid = [[2, 1, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 2, 0, 1], [1, 0, 1, 1, 2], [1, 1, 2, 1, 1]]) == 3\n assert candidate(grid = [[2, 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, 2]]) == 1\n assert candidate(grid = [[2, 1, 1, 1, 2], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [2, 1, 1, 1, 2]]) == 4\n assert candidate(grid = [[2, 1, 1, 1, 1, 2], [1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 2]]) == 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, 2]]) == 10\n assert candidate(grid = [[2, 1, 1, 0], [1, 1, 0, 0], [0, 0, 1, 1], [1, 2, 1, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 2, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 2], [1, 0, 1, 1, 0, 1], [2, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 1]]) == 4\n assert candidate(grid = [[2, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[2, 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 = [[1, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 1]]) == -1\n assert candidate(grid = [[2, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 1], [0, 0, 0, 2, 0, 0], [1, 0, 0, 0, 0, 1], [0, 1, 0, 1, 0, 2]]) == -1\n assert candidate(grid = [[2, 0, 1, 0, 2], [0, 1, 1, 1, 0], [1, 1, 2, 1, 1], [0, 1, 1, 1, 0], [2, 0, 1, 0, 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, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 2]]) == 12\n assert candidate(grid = [[2, 1, 0, 1, 2], [1, 0, 1, 0, 2], [2, 1, 2, 0, 2], [1, 2, 2, 2, 1], [2, 1, 1, 1, 2]]) == 1\n assert candidate(grid = [[2, 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, 1], [0, 0, 0, 0, 0, 1, 2]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 2, 0, 1], [1, 0, 0, 0, 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\n assert candidate(grid = [[1, 2, 1, 1, 2], [1, 1, 1, 2, 1], [2, 1, 1, 1, 1], [1, 2, 2, 1, 1], [1, 1, 1, 2, 1]]) == 2\n assert candidate(grid = [[2, 1, 1], [1, 1, 1], [1, 2, 1], [2, 1, 1], [1, 1, 2]]) == 2\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 0, 1, 2], [1, 0, 0, 0, 1], [2, 1, 2, 1, 2]]) == 1\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 1, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 1], [0, 1, 0, 1, 0, 0], [1, 0, 1, 0, 1, 2], [1, 1, 0, 1, 0, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 2, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 2, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 2, 2]]) == -1\n assert candidate(grid = [[2, 1, 1, 0, 1], [1, 0, 1, 1, 2], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [2, 1, 1, 1, 2]]) == 3\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 2, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[2, 1, 1, 1, 2], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [2, 1, 1, 1, 2]]) == -1\n assert candidate(grid = [[2, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 2], [0, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 2]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 2, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[0, 2, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 2, 1, 1, 2], [1, 1, 0, 1, 1], [0, 1, 1, 1, 1], [2, 1, 1, 1, 0]]) == 3\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 2], [1, 1, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 2]]) == 6\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 1, 2, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 2, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 1, 2, 1], [1, 0, 0, 1, 1], [1, 1, 0, 1, 2], [0, 1, 1, 1, 0], [1, 2, 0, 2, 1]]) == 2\n assert candidate(grid = [[2, 1, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 1, 1, 2]]) == -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, 2]]) == 1\n assert candidate(grid = [[2, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 2], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1], [2, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[2, 1, 0, 1], [0, 0, 0, 0], [1, 0, 1, 2], [0, 1, 2, 0], [1, 2, 0, 1]]) == -1\n assert candidate(grid = [[2, 1, 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 = [[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 = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 2, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[2, 1, 1, 0, 0], [1, 0, 1, 1, 1], [0, 1, 1, 1, 2], [0, 0, 0, 1, 1], [0, 1, 2, 1, 2]]) == 3\n assert candidate(grid = [[1, 2, 0, 2, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1]]) == -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, 2, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 0, 1, 2, 1, 1], [1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1, 2]]) == -1\n assert candidate(grid = [[1, 0, 2, 0, 1], [0, 1, 0, 1, 0], [2, 0, 1, 0, 2], [0, 1, 0, 1, 0], [1, 0, 2, 0, 1]]) == -1\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 2, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == -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, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[2, 1, 1, 2, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 2]]) == 4\n assert candidate(grid = [[1, 2, 1, 0, 1, 2], [1, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 1], [2, 1, 1, 1, 1, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[2, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [0, 1, 1, 1, 2]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[2,1,1],[1,1,0],[0,1,1]]", "[[2,1,1],[0,1,1],[1,0,1]]", "[[0,2]]"], "hints": [], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().orangesRotting", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:04+00:00", "tests_total": 96, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def orangesRotting(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "orangesRotting", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 995, "task_id": "minimum-number-of-k-consecutive-bit-flips", "difficulty": "Hard", "problem_description": "You are given a binary array nums and an integer k.\n\nA k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.\n\nReturn the minimum number of k-bit flips required so that there is no 0 in the array. If it is not possible, return -1.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [0,1,0], k = 1\nOutput: 2\nExplanation: Flip nums[0], then flip nums[2].\n\nExample 2:\n\nInput: nums = [1,1,0], k = 2\nOutput: -1\nExplanation: No matter how we flip subarrays of size 2, we cannot make the array become [1,1,1].\n\nExample 3:\n\nInput: nums = [0,0,0,1,0,1,1,0], k = 3\nOutput: 3\nExplanation:\nFlip nums[0],nums[1],nums[2]: nums becomes [1,1,1,1,0,1,1,0]\nFlip nums[4],nums[5],nums[6]: nums becomes [1,1,1,1,1,0,0,0]\nFlip nums[5],nums[6],nums[7]: nums becomes [1,1,1,1,1,1,1,1]\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 1, 0, 1, 0],k = 2) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 4\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1],k = 4) == -1\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [1, 1, 0],k = 2) == -1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 1],k = 2) == -1\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == -1\n assert candidate(nums = [0, 0, 0, 1, 0, 1, 1, 0],k = 3) == 3\n assert candidate(nums = [1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(nums = [1, 0, 1, 1, 0, 0, 1, 1, 1, 0],k = 4) == -1\n assert candidate(nums = [0, 0, 0, 0, 0],k = 5) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0],k = 2) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0],k = 2) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0],k = 4) == -1\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 0, 0, 1, 1],k = 3) == 4\n assert candidate(nums = [0, 1, 0],k = 1) == 2\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1],k = 2) == 3\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],k = 8) == 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],k = 20) == 0\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 3) == 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],k = 3) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],k = 6) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == 0\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0],k = 4) == 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],k = 5) == 6\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 0, 0, 1],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 = 5) == 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],k = 15) == -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],k = 5) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],k = 5) == -1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 4) == -1\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],k = 5) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == -1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 8) == -1\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1],k = 5) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0],k = 3) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],k = 5) == -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],k = 5) == 10\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1],k = 4) == -1\n assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0],k = 5) == 9\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0],k = 5) == -1\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 1, 0, 0],k = 3) == -1\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 4) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 6\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],k = 4) == 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],k = 6) == -1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],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, 1],k = 2) == 10\n assert candidate(nums = [0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0],k = 3) == 8\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 8\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],k = 6) == -1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 7) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],k = 6) == -1\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0],k = 7) == -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, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 15) == -1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 4) == -1\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 10) == -1\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 0, 1, 0, 0],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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 0\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1],k = 4) == 3\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0],k = 5) == -1\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 3) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == -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],k = 7) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],k = 4) == 2\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0],k = 5) == -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],k = 7) == 21\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 5) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 10) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 7) == -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],k = 2) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == -1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 3) == -1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1],k = 8) == -1\n assert candidate(nums = [1, 1, 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],k = 6) == -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],k = 9) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 4\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 = 10) == 3\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1],k = 4) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == -1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1],k = 3) == -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],k = 7) == 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 = 7) == 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],k = 4) == -1\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 6) == -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],k = 8) == -1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 2) == 4\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == -1\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 3) == 6\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 0, 0, 1],k = 3) == -1\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0],k = 7) == -1\n", "comparison": "exact"}, "public_tests": ["[0,1,0]\n1", "[1,1,0]\n2", "[0,0,0,1,0,1,1,0]\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minKBitFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:07+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "bit-manipulation", "queue", "sliding-window", "prefix-sum", "brute-force-search"]}, "language": "python", "interface": {"raw_signature": "def minKBitFlips(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "minKBitFlips", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 996, "task_id": "number-of-squareful-arrays", "difficulty": "Hard", "problem_description": "An array is squareful if the sum of every pair of adjacent elements is a perfect square.\n\nGiven an integer array nums, return the number of permutations of nums that are squareful.\n\nTwo permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i].\n\nExample 1:\n\nInput: nums = [1,17,8]\nOutput: 2\nExplanation: [1,8,17] and [17,8,1] are the valid permutations.\n\nExample 2:\n\nInput: nums = [2,2,2]\nOutput: 1\n\nConstraints:\n\n- 1 <= nums.length <= 12\n- 0 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 0, 16, 25, 36]) == 0\n assert candidate(nums = [2, 2, 2]) == 1\n assert candidate(nums = [1, 17, 8]) == 2\n assert candidate(nums = [9, 0, 9]) == 1\n assert candidate(nums = [0, 0, 0]) == 1\n assert candidate(nums = [4, 6, 15, 33, 50]) == 0\n assert candidate(nums = [0, 1, 1, 0]) == 3\n assert candidate(nums = [16, 9, 4, 0, 25]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [4, 6, 15, 33]) == 0\n assert candidate(nums = [9, 0, 4, 10, 9]) == 0\n assert candidate(nums = [0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 2, 3, 6, 10]) == 0\n assert candidate(nums = [25, 10, 5, 15, 20]) == 0\n assert candidate(nums = [9, 4, 1, 4, 9]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9]) == 0\n assert candidate(nums = [2, 8, 10, 18, 26]) == 0\n assert candidate(nums = [1, 2, 5, 10, 17, 26, 37, 50, 65, 82]) == 0\n assert candidate(nums = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]) == 12\n assert candidate(nums = [0, 4, 9, 16, 25, 36, 49]) == 0\n assert candidate(nums = [2, 7, 8, 18, 20, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45]) == 4\n assert candidate(nums = [4, 6, 9, 11, 14, 16, 19, 21, 25, 27, 30, 32]) == 0\n assert candidate(nums = [100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 0\n assert candidate(nums = [2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156]) == 0\n assert candidate(nums = [10, 15, 21, 26, 30, 35, 40]) == 0\n assert candidate(nums = [16, 9, 0, 4, 25, 1]) == 0\n assert candidate(nums = [25, 36, 49, 64, 81, 100, 121]) == 0\n assert candidate(nums = [4, 6, 9, 10, 15, 21, 30, 36, 45, 55]) == 0\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 0\n assert candidate(nums = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 0\n assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169]) == 0\n assert candidate(nums = [18, 20, 22, 24, 26, 28, 30, 32, 34, 36]) == 0\n assert candidate(nums = [4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169]) == 0\n assert candidate(nums = [1, 2, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100]) == 0\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98]) == 0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 0\n assert candidate(nums = [5, 13, 29, 34, 37, 41, 50, 53, 61, 65, 72, 74]) == 0\n assert candidate(nums = [2, 3, 6, 11, 15, 20]) == 0\n assert candidate(nums = [0, 2, 8, 18, 32, 50, 72, 98, 128, 162, 200, 242]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 0\n assert candidate(nums = [4, 1, 3, 0, 9, 16, 25, 36, 49]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(nums = [25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256]) == 0\n assert candidate(nums = [2, 7, 11, 15, 20, 25]) == 0\n assert candidate(nums = [81, 180, 144, 121, 100, 25, 0]) == 0\n assert candidate(nums = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]) == 12\n assert candidate(nums = [1, 2, 3, 6, 10, 15, 21]) == 0\n assert candidate(nums = [81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 121]) == 0\n assert candidate(nums = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68]) == 0\n assert candidate(nums = [8, 17, 28, 39, 50, 61, 72, 83]) == 0\n assert candidate(nums = [2, 3, 6, 7, 8, 15, 21, 30, 35, 42, 48, 55]) == 0\n assert candidate(nums = [5, 7, 8, 12, 13, 16, 17, 24, 25, 28, 32, 33]) == 0\n assert candidate(nums = [1, 16, 81, 144, 121, 100, 25]) == 0\n assert candidate(nums = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600]) == 0\n assert candidate(nums = [1, 16, 9, 4, 0, 36, 25, 10]) == 0\n assert candidate(nums = [49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82]) == 0\n assert candidate(nums = [4, 6, 9, 10, 15, 21, 25]) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == 0\n assert candidate(nums = [0, 0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25]) == 0\n assert candidate(nums = [4, 6, 9, 13, 15, 17, 21, 25, 27, 31]) == 0\n assert candidate(nums = [5, 13, 25, 41, 61, 85, 113, 145, 181, 221, 265]) == 0\n assert candidate(nums = [8, 15, 18, 23, 26, 32, 35, 38, 41]) == 0\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121]) == 0\n assert candidate(nums = [2, 3, 6, 5, 9, 10]) == 0\n assert candidate(nums = [8, 7, 15, 1, 28, 25, 24]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21]) == 0\n assert candidate(nums = [1, 2, 2, 3, 6, 10]) == 0\n assert candidate(nums = [144, 169, 196, 225, 256, 289, 324, 361]) == 0\n assert candidate(nums = [3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 0\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 108, 118]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78]) == 12\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49]) == 0\n assert candidate(nums = [8, 7, 3, 12, 5, 13, 25, 16, 9]) == 0\n assert candidate(nums = [16, 9, 4, 1, 0, 25, 36, 49, 64, 81]) == 0\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49]) == 0\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]) == 0\n assert candidate(nums = [36, 100, 144, 196, 256, 324, 400, 484, 576, 676, 784, 900]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 120]) == 0\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [4, 6, 9, 10, 13, 15, 16, 18, 19, 20, 25, 28]) == 0\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 0\n assert candidate(nums = [3, 12, 27, 48, 75, 108, 147, 192, 243, 300, 363, 432]) == 0\n assert candidate(nums = [49, 36, 25, 16, 9, 4, 1, 0, 81, 64, 49, 36]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(nums = [10, 21, 35, 51, 70, 92, 117, 144, 173, 204, 237]) == 0\n assert candidate(nums = [2, 3, 6, 11, 19, 20]) == 0\n assert candidate(nums = [8, 15, 24, 35, 46, 57, 68, 79, 90, 101, 112, 123]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 0\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == 0\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81]) == 0\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [1, 17, 8, 2, 18, 20, 32, 50, 33, 6]) == 0\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100]) == 0\n assert candidate(nums = [50, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324]) == 0\n assert candidate(nums = [10, 15, 21, 26, 35, 40, 51, 56, 65, 70, 85, 90]) == 0\n assert candidate(nums = [0, 1, 4, 9, 16, 25, 36, 49]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78]) == 12\n", "comparison": "exact"}, "public_tests": ["[1,17,8]", "[2,2,2]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numSquarefulPerms", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:09+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "math", "dynamic-programming", "backtracking", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def numSquarefulPerms(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numSquarefulPerms", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 997, "task_id": "find-the-town-judge", "difficulty": "Easy", "problem_description": "In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge.\n\nIf the town judge exists, then:\n\n1. The town judge trusts nobody.\n2. Everybody (except for the town judge) trusts the town judge.\n3. There is exactly one person that satisfies properties 1 and 2.\n\nYou are given an array trust where trust[i] = [a_i, b_i] representing that the person labeled a_i trusts the person labeled b_i. If a trust relationship does not exist in trust array, then such a trust relationship does not exist.\n\nReturn the label of the town judge if the town judge exists and can be identified, or return -1 otherwise.\n\nExample 1:\n\nInput: n = 2, trust = [[1,2]]\nOutput: 2\n\nExample 2:\n\nInput: n = 3, trust = [[1,3],[2,3]]\nOutput: 3\n\nExample 3:\n\nInput: n = 3, trust = [[1,3],[2,3],[3,1]]\nOutput: -1\n\nConstraints:\n\n- 1 <= n <= 1000\n- 0 <= trust.length <= 10^4\n- trust[i].length == 2\n- All the pairs of trust are unique.\n- a_i != b_i\n- 1 <= a_i, b_i <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,trust = [[1, 3], [1, 4], [2, 3], [2, 4], [4, 3]]) == 3\n assert candidate(n = 1,trust = []) == 1\n assert candidate(n = 5,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 3,trust = [[1, 3], [2, 3], [3, 1]]) == -1\n assert candidate(n = 4,trust = [[1, 2], [1, 3], [1, 4]]) == -1\n assert candidate(n = 3,trust = [[1, 3], [2, 3]]) == 3\n assert candidate(n = 2,trust = [[1, 2]]) == 2\n assert candidate(n = 3,trust = [[1, 2], [2, 1], [1, 3], [3, 1]]) == -1\n assert candidate(n = 8,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == -1\n assert candidate(n = 5,trust = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 8,trust = [[1, 3], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3]]) == 3\n assert candidate(n = 15,trust = [[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]]) == 15\n assert candidate(n = 6,trust = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 5]]) == -1\n assert candidate(n = 10,trust = [[1, 3], [2, 3], [3, 5], [4, 5], [5, 7], [6, 7], [7, 9], [8, 9], [9, 10], [10, 1]]) == -1\n assert candidate(n = 5,trust = [[1, 4], [2, 4], [3, 4], [5, 4]]) == 4\n assert candidate(n = 8,trust = [[1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8]]) == 8\n assert candidate(n = 10,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 5\n assert candidate(n = 7,trust = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == 7\n assert candidate(n = 5,trust = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 1], [4, 2], [5, 1], [5, 3]]) == -1\n assert candidate(n = 11,trust = [[1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]]) == 11\n assert candidate(n = 5,trust = [[1, 5], [2, 5], [3, 5], [4, 5]]) == 5\n assert candidate(n = 6,trust = [[1, 4], [2, 4], [3, 4], [5, 4], [6, 4], [4, 6]]) == -1\n assert candidate(n = 9,trust = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == -1\n assert candidate(n = 13,trust = [[1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13]]) == 13\n assert candidate(n = 9,trust = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7]]) == 7\n assert candidate(n = 6,trust = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 1]]) == -1\n assert candidate(n = 9,trust = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == 9\n assert candidate(n = 6,trust = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 6\n assert candidate(n = 10,trust = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(n = 5,trust = [[1, 2], [2, 3], [3, 4], [4, 5]]) == -1\n assert candidate(n = 6,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 2]]) == -1\n assert candidate(n = 7,trust = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == -1\n assert candidate(n = 10,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == -1\n assert candidate(n = 5,trust = [[1, 3], [2, 3], [4, 5], [5, 4]]) == -1\n assert candidate(n = 7,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [5, 1]]) == -1\n assert candidate(n = 5,trust = [[1, 3], [2, 3], [4, 3], [5, 3], [1, 5], [2, 5], [4, 5]]) == 3\n assert candidate(n = 9,trust = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [9, 1]]) == -1\n assert candidate(n = 10,trust = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 1]]) == -1\n assert candidate(n = 5,trust = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 4]]) == -1\n assert candidate(n = 10,trust = [[1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [9, 8], [10, 8]]) == 8\n assert candidate(n = 12,trust = [[1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 1]]) == 12\n assert candidate(n = 12,trust = [[1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12]]) == 12\n assert candidate(n = 6,trust = [[1, 3], [2, 3], [3, 1], [4, 5], [5, 4], [1, 5], [2, 6], [6, 2], [3, 4]]) == -1\n assert candidate(n = 8,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [5, 8]]) == -1\n assert candidate(n = 10,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == -1\n assert candidate(n = 10,trust = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == -1\n assert candidate(n = 10,trust = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [10, 1]]) == -1\n assert candidate(n = 8,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5]]) == 5\n assert candidate(n = 9,trust = [[1, 2], [1, 3], [2, 3], [3, 1], [4, 5], [4, 6], [5, 6], [6, 4], [7, 8], [7, 9], [8, 9], [9, 7]]) == -1\n assert candidate(n = 7,trust = [[1, 4], [2, 4], [3, 4], [5, 4], [6, 4], [7, 4]]) == 4\n assert candidate(n = 8,trust = [[1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 7]]) == -1\n assert candidate(n = 11,trust = [[1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 11\n assert candidate(n = 12,trust = [[1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 10]]) == -1\n assert candidate(n = 10,trust = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == -1\n assert candidate(n = 5,trust = [[1, 2], [2, 1], [3, 4], [4, 3]]) == -1\n assert candidate(n = 10,trust = [[2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 1\n assert candidate(n = 8,trust = [[1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [8, 7], [8, 1]]) == -1\n assert candidate(n = 8,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 2], [8, 3]]) == -1\n assert candidate(n = 5,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == -1\n assert candidate(n = 6,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == -1\n assert candidate(n = 9,trust = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1]]) == 9\n assert candidate(n = 5,trust = [[1, 3], [2, 3], [4, 3], [5, 3]]) == 3\n assert candidate(n = 20,trust = [[1, 20], [2, 20], [3, 20], [4, 20], [5, 20], [6, 20], [7, 20], [8, 20], [9, 20], [10, 20], [11, 20], [12, 20], [13, 20], [14, 20], [15, 20], [16, 20], [17, 20], [18, 20], [19, 20], [1, 2], [2, 3], [3, 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]]) == 20\n assert candidate(n = 10,trust = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9], [1, 10]]) == -1\n assert candidate(n = 5,trust = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5]]) == 5\n assert candidate(n = 6,trust = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6]]) == 6\n assert candidate(n = 8,trust = [[1, 8], [2, 8], [3, 8], [4, 8], [5, 8], [6, 8], [7, 8], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 8\n assert candidate(n = 7,trust = [[1, 4], [2, 4], [3, 4], [5, 4], [6, 4], [1, 5], [2, 5], [3, 5], [5, 6], [6, 7]]) == -1\n assert candidate(n = 6,trust = [[1, 3], [2, 3], [3, 1], [3, 4], [4, 5], [5, 6], [6, 4]]) == -1\n assert candidate(n = 9,trust = [[1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == 9\n assert candidate(n = 5,trust = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 4]]) == -1\n assert candidate(n = 7,trust = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 7\n assert candidate(n = 7,trust = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 1]]) == -1\n assert candidate(n = 6,trust = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6]]) == -1\n assert candidate(n = 5,trust = [[1, 3], [2, 3], [3, 1], [4, 5], [5, 4]]) == -1\n assert candidate(n = 8,trust = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [7, 6], [8, 6]]) == 6\n assert candidate(n = 12,trust = [[1, 12], [2, 12], [3, 12], [4, 12], [5, 12], [6, 12], [7, 12], [8, 12], [9, 12], [10, 12], [11, 12], [12, 1]]) == -1\n assert candidate(n = 6,trust = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 2], [2, 1], [3, 4], [4, 3]]) == 6\n assert candidate(n = 10,trust = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]]) == 10\n assert candidate(n = 10,trust = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == -1\n assert candidate(n = 5,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1]]) == -1\n assert candidate(n = 100,trust = [[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, 100]]) == 100\n assert candidate(n = 6,trust = [[1, 4], [2, 4], [3, 4], [5, 4], [6, 4]]) == 4\n assert candidate(n = 7,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5]]) == 5\n assert candidate(n = 10,trust = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [9, 5], [1, 10], [2, 10], [3, 10], [4, 10]]) == -1\n assert candidate(n = 10,trust = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == -1\n", "comparison": "exact"}, "public_tests": ["2\n[[1,2]]", "3\n[[1,3],[2,3]]", "3\n[[1,3],[2,3],[3,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "trust"], "leetcode_dataset_entry_point": "Solution().findJudge", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:11+00:00", "tests_total": 86, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "graph"]}, "language": "python", "interface": {"raw_signature": "def findJudge(self, n: int, trust: list[list[int]]) -> int:", "container": "Solution", "callable": "findJudge", "parameters": [{"name": "n", "type": "int"}, {"name": "trust", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 999, "task_id": "available-captures-for-rook", "difficulty": "Easy", "problem_description": "You are given an 8 x 8 matrix representing a chessboard. There is exactly one white rook represented by 'R', some number of white bishops 'B', and some number of black pawns 'p'. Empty squares are represented by '.'.\n\nA rook can move any number of squares horizontally or vertically (up, down, left, right) until it reaches another piece or the edge of the board. A rook is attacking a pawn if it can move to the pawn's square in one move.\n\nNote: A rook cannot move through other pieces, such as bishops or pawns. This means a rook cannot attack a pawn if there is another piece blocking the path.\n\nReturn the number of pawns the white rook is attacking.\n\nExample 1:\n\nInput: board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"R\",\".\",\".\",\".\",\"p\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]\nOutput: 3\nExplanation:\nIn this example, the rook is attacking all the pawns.\n\nExample 2:\n\nInput: board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\"p\",\"p\",\"p\",\"p\",\"p\",\".\",\".\"],[\".\",\"p\",\"p\",\"B\",\"p\",\"p\",\".\",\".\"],[\".\",\"p\",\"B\",\"R\",\"B\",\"p\",\".\",\".\"],[\".\",\"p\",\"p\",\"B\",\"p\",\"p\",\".\",\".\"],[\".\",\"p\",\"p\",\"p\",\"p\",\"p\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]\nOutput: 0\nExplanation:\nThe bishops are blocking the rook from attacking any of the pawns.\n\nExample 3:\n\nInput: board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\"p\",\"p\",\".\",\"R\",\".\",\"p\",\"B\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]\nOutput: 3\nExplanation:\nThe rook is attacking the pawns at positions b5, d6, and f5.\n\nConstraints:\n\n- board.length == 8\n- board[i].length == 8\n- board[i][j] is either 'R', '.', 'B', or 'p'\n- There is exactly one cell with board[i][j] == 'R'\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['p', 'p', '.', 'R', '.', 'p', 'B', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 3\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'p', 'p', 'p', 'p', '.', '.'], ['.', 'p', 'p', 'B', 'p', 'p', '.', '.'], ['.', 'p', 'B', 'R', 'B', 'p', '.', '.'], ['.', 'p', 'p', 'B', 'p', 'p', '.', '.'], ['.', 'p', 'p', 'p', 'p', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 3\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', 'p', 'p', '.', '.', '.'], ['p', '.', 'B', 'R', '.', 'B', 'p', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'R', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', 'p'], ['.', '.', '.', '.', '.', '.', '.', 'p']]) == 0\n assert candidate(board = [['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['p', '.', '.', '.', '.', '.', 'p', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', 'p', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'R', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', 'p', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', 'p', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', 'R', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', '.', 'R', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', 'p', '.', 'p', '.'], ['.', '.', 'B', '.', '.', '.', '.', '.'], ['.', 'p', '.', 'R', '.', 'p', '.', '.'], ['.', '.', '.', '.', 'B', '.', '.', '.'], ['.', 'p', '.', '.', 'p', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'R', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', 'p']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['p', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', 'B', '.', '.', 'B', '.', '.'], ['.', '.', '.', 'p', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', 'p', '.', 'B', '.', 'p', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', 'p', '.', 'B', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', 'p', '.', '.', 'p', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', 'p', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'B', '.', '.', '.', 'B', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'B', 'p', 'R', 'p', 'B', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', 'R', 'p', '.', '.', '.'], ['.', '.', 'B', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 3\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['p', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', 'B', 'p', '.'], ['.', '.', 'p', '.', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', 'B', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'p', 'R', 'p', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'B', '.', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', '.', 'p', '.', '.', '.', 'p']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'R', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', 'p']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', '.', 'p', '.', '.', '.'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['p', '.', '.', '.', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', 'p']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'p', 'p', 'p', 'p', 'p', 'p']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', 'R', '.', 'B', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', 'p', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', 'p', '.'], ['p', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', 'p', '.', 'B', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', 'R', '.', '.', 'p', '.'], ['.', '.', 'B', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', 'B', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['p', '.', '.', 'R', '.', '.', 'p', '.'], ['.', 'p', '.', '.', 'p', '.', '.', '.'], ['.', '.', 'B', '.', '.', 'B', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.']]) == 3\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', 'R', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', 'p', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'R', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', 'p', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', '.', '.', 'p', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', 'p', '.', 'p']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', 'p', 'p', 'p', 'p', 'p']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', 'p', '.'], ['B', '.', '.', '.', '.', '.', '.', 'B'], ['.', 'p', '.', '.', '.', '.', 'p', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'R', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', 'p', 'p', 'p']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'B', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', 'p', '.', '.', '.', 'B', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', 'p', '.', 'p', '.', 'p', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', 'p', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.']]) == 3\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', 'p'], ['.', 'p', '.', 'R', '.', 'p', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', 'B', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 3\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'B', 'p', 'p', 'B', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 1\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'R', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', '.']]) == 0\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', '.', '.', '.', '.', '.', '.'], ['p', '.', '.', 'R', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', 'B', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', 'p', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'B', 'p', 'R', 'p', 'B', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 2\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', 'p', '.', 'p', '.', 'p', '.', 'p']]) == 1\n assert candidate(board = [['.', '.', 'p', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'R', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', 'p', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 0\n", "comparison": "exact"}, "public_tests": ["[[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"R\",\".\",\".\",\".\",\"p\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]", "[[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\"p\",\"p\",\"p\",\"p\",\"p\",\".\",\".\"],[\".\",\"p\",\"p\",\"B\",\"p\",\"p\",\".\",\".\"],[\".\",\"p\",\"B\",\"R\",\"B\",\"p\",\".\",\".\"],[\".\",\"p\",\"p\",\"B\",\"p\",\"p\",\".\",\".\"],[\".\",\"p\",\"p\",\"p\",\"p\",\"p\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]", "[[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\"p\",\"p\",\".\",\"R\",\".\",\"p\",\"B\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]"], "hints": [], "metadata": {"canonical_parameter_names": ["board"], "leetcode_dataset_entry_point": "Solution().numRookCaptures", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:16+00:00", "tests_total": 58, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def numRookCaptures(self, board: list[list[str]]) -> int:", "container": "Solution", "callable": "numRookCaptures", "parameters": [{"name": "board", "type": "list[list[str]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1000, "task_id": "minimum-cost-to-merge-stones", "difficulty": "Hard", "problem_description": "There are n piles of stones arranged in a row. The i^th pile has stones[i] stones.\n\nA move consists of merging exactly k consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these k piles.\n\nReturn the minimum cost to merge all piles of stones into one pile. If it is impossible, return -1.\n\nExample 1:\n\nInput: stones = [3,2,4,1], k = 2\nOutput: 20\nExplanation: We start with [3, 2, 4, 1].\nWe merge [3, 2] for a cost of 5, and we are left with [5, 4, 1].\nWe merge [4, 1] for a cost of 5, and we are left with [5, 5].\nWe merge [5, 5] for a cost of 10, and we are left with [10].\nThe total cost was 20, and this is the minimum possible.\n\nExample 2:\n\nInput: stones = [3,2,4,1], k = 3\nOutput: -1\nExplanation: After any merge operation, there are 2 piles left, and we can't merge anymore. So the task is impossible.\n\nExample 3:\n\nInput: stones = [3,5,1,2,6], k = 3\nOutput: 25\nExplanation: We start with [3, 5, 1, 2, 6].\nWe merge [5, 1, 2] for a cost of 8, and we are left with [3, 8, 6].\nWe merge [3, 8, 6] for a cost of 17, and we are left with [17].\nThe total cost was 25, and this is the minimum possible.\n\nConstraints:\n\n- n == stones.length\n- 1 <= n <= 30\n- 1 <= stones[i] <= 100\n- 2 <= k <= 30\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == 135\n assert candidate(stones = [3, 2, 4, 1],k = 3) == -1\n assert candidate(stones = [1, 2, 3, 4, 5],k = 3) == 21\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == -1\n assert candidate(stones = [4, 3, 2],k = 2) == 14\n assert candidate(stones = [10, 20, 30, 40, 50],k = 2) == 330\n assert candidate(stones = [4, 4, 4, 4, 4],k = 2) == 48\n assert candidate(stones = [15, 10, 5, 10, 15],k = 2) == 125\n assert candidate(stones = [3, 2, 1],k = 3) == 6\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11],k = 2) == 85\n assert candidate(stones = [7, 3, 8, 1, 12, 10, 6],k = 3) == 87\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 88\n assert candidate(stones = [4, 4, 4, 4],k = 2) == 32\n assert candidate(stones = [3, 2, 4, 1],k = 2) == 20\n assert candidate(stones = [5, 1, 2, 4, 3],k = 2) == 33\n assert candidate(stones = [1, 2, 3, 4, 5, 6],k = 3) == -1\n assert candidate(stones = [3, 5, 1, 2, 6],k = 3) == 25\n assert candidate(stones = [10, 20, 30, 40, 50],k = 5) == 150\n assert candidate(stones = [5, 17, 19, 8, 45, 30],k = 3) == -1\n assert candidate(stones = [7, 7, 7, 7, 7, 7],k = 3) == -1\n assert candidate(stones = [10, 15, 20, 25],k = 2) == 140\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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) == -1\n assert candidate(stones = [5, 17, 9, 4, 13, 8, 11],k = 3) == 123\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 4) == -1\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 910\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 6) == -1\n assert candidate(stones = [22, 15, 33, 11, 7, 19, 25, 28],k = 4) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 5) == 269\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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) == -1\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == -1\n assert candidate(stones = [5, 5, 5, 5, 5, 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) == 450\n assert candidate(stones = [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 = 10) == -1\n assert candidate(stones = [1, 3, 2, 5, 4, 6, 9, 8, 7, 10, 13, 12, 11, 14, 17, 16, 15, 18, 21, 20, 19, 22, 25, 24, 23, 26, 29, 28, 27, 30],k = 3) == -1\n assert candidate(stones = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 3) == 535\n assert candidate(stones = [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],k = 4) == -1\n assert candidate(stones = [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 = 4) == -1\n assert candidate(stones = [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 = 2) == 2175\n assert candidate(stones = [5, 3, 8, 6, 2, 7, 4, 9, 1, 12, 11, 10, 15, 13, 14, 19, 17, 18, 23, 21, 22, 27, 25, 26, 31, 29, 30, 35, 33, 34],k = 7) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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) == -1\n assert candidate(stones = [1, 1, 1, 1, 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) == -1\n assert candidate(stones = [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) == -1\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 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 = 4) == -1\n assert candidate(stones = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 5) == -1\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 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 = 4) == -1\n assert candidate(stones = [5, 3, 8, 1, 9, 2, 6, 4, 7, 10],k = 4) == 91\n assert candidate(stones = [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 = 4) == -1\n assert candidate(stones = [7, 13, 8, 9, 12, 5, 6, 3, 1, 4],k = 3) == -1\n assert candidate(stones = [3, 4, 5, 6, 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) == 1092\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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) == -1\n assert candidate(stones = [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 = 3) == -1\n assert candidate(stones = [14, 29, 10, 21, 3, 16, 24, 20, 30],k = 3) == 334\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 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) == -1\n assert candidate(stones = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],k = 7) == -1\n assert candidate(stones = [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],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 164\n assert candidate(stones = [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) == -1\n assert candidate(stones = [3, 8, 3, 9, 3, 8, 3, 9, 3, 8, 3, 9, 3, 8, 3, 9, 3, 8, 3, 9],k = 3) == -1\n assert candidate(stones = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],k = 3) == -1\n assert candidate(stones = [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 = 3) == -1\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 135\n assert candidate(stones = [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],k = 3) == -1\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 5) == 600\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == -1\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70],k = 3) == 490\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 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 = 2) == 296\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 60\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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) == 2175\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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) == -1\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 455\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 7) == -1\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == -1\n assert candidate(stones = [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 = 6) == -1\n assert candidate(stones = [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],k = 2) == 296\n assert candidate(stones = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 9) == -1\n assert candidate(stones = [9, 5, 7, 3, 8, 6, 2, 4, 1, 10],k = 2) == 177\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 4) == -1\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 34\n assert candidate(stones = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27],k = 5) == -1\n assert candidate(stones = [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, 9],k = 2) == 193\n assert candidate(stones = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],k = 5) == 515\n assert candidate(stones = [4, 8, 15, 16, 23, 42, 7, 11, 18, 29, 37, 45, 1, 3, 6, 10, 14, 19],k = 4) == -1\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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) == 148\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 4) == -1\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 87\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7) == -1\n assert candidate(stones = [15, 10, 5, 1, 20, 30, 25, 35, 40, 45, 50, 55],k = 5) == -1\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 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 = 5) == -1\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == -1\n assert candidate(stones = [5, 15, 10, 25, 30, 20, 5, 10, 40],k = 3) == 310\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40],k = 4) == -1\n assert candidate(stones = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95],k = 3) == -1\n assert candidate(stones = [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 = 6) == -1\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 91\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == -1\n assert candidate(stones = [7, 1, 4, 5, 6],k = 2) == 51\n assert candidate(stones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == -1\n assert candidate(stones = [7, 7, 7, 7, 7, 7, 7],k = 2) == 140\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == -1\n assert candidate(stones = [7, 7, 7, 7, 7, 7, 7, 7],k = 2) == 168\n assert candidate(stones = [7, 7, 7, 7, 7, 7],k = 3) == -1\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == 1730\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 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 = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15],k = 4) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6],k = 2) == 51\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15],k = 3) == -1\n assert candidate(stones = [3, 2, 4, 1],k = 3) == -1\n assert candidate(stones = [5, 3, 8, 12, 6],k = 3) == 50\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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) == 148\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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(stones = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == -1\n assert candidate(stones = [1, 3, 2, 1, 2, 3, 1],k = 3) == 25\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == -1\n assert candidate(stones = [10, 4, 3, 5, 1],k = 2) == 49\n assert candidate(stones = [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 = 4) == -1\n assert candidate(stones = [10, 20, 30, 40, 50, 60],k = 3) == -1\n assert candidate(stones = [10, 10, 10, 10],k = 2) == 80\n assert candidate(stones = [10, 22, 9, 33, 21, 50, 41, 60, 80],k = 3) == 613\n assert candidate(stones = [1, 3, 3, 3, 2, 4, 1],k = 3) == 31\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 2) == 136\n assert candidate(stones = [8, 32, 25, 35, 25, 32, 25, 32, 31, 21, 34, 35, 31, 30, 29, 35, 32, 29, 29, 26, 30, 24, 26, 33, 38, 29, 21, 20, 34, 31],k = 3) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 173\n assert candidate(stones = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 2) == 68\n assert candidate(stones = [7, 4, 5, 9, 2],k = 2) == 63\n assert candidate(stones = [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],k = 4) == -1\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 2) == 136\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 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) == -1\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 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 = 3) == -1\n assert candidate(stones = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == -1\n assert candidate(stones = [5, 3, 8, 3, 5, 3, 8, 5],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 310\n assert candidate(stones = [5, 3, 8, 3, 8, 3, 8, 3, 8, 3],k = 4) == 93\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == 87\n assert candidate(stones = [10, 20, 30, 40, 50],k = 5) == 150\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 3) == 870\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2],k = 3) == 26\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 173\n assert candidate(stones = [4, 4, 4, 4, 4, 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 = 4) == -1\n assert candidate(stones = [7, 8, 9, 10, 11, 12],k = 3) == -1\n assert candidate(stones = [5, 5, 5, 5, 5, 5],k = 3) == -1\n assert candidate(stones = [10, 12, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 126\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 51\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 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 = 2) == 740\n assert candidate(stones = [5, 5, 5, 5, 5, 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) == 315\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 2) == 1730\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1],k = 2) == 20\n assert candidate(stones = [5, 3, 3, 3, 5],k = 2) == 44\n assert candidate(stones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 5) == -1\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == -1\n assert candidate(stones = [7, 8, 9, 10, 11, 12, 13],k = 3) == 127\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 4],k = 2) == 80\n assert candidate(stones = [5, 3, 8, 1, 9, 2, 7, 4, 6],k = 3) == 90\n assert candidate(stones = [7, 3, 2, 1, 8],k = 3) == 27\n assert candidate(stones = [10, 4, 3, 5, 10, 7, 9, 6],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9],k = 4) == -1\n assert candidate(stones = [15, 10, 20, 5, 25],k = 3) == 110\n assert candidate(stones = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 3) == -1\n assert candidate(stones = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 4) == -1\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 135\n assert candidate(stones = [8, 8, 8, 8, 8, 8, 8, 8],k = 4) == -1\n assert candidate(stones = [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],k = 3) == 4644\n assert candidate(stones = [5, 17, 100, 11],k = 2) == 266\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 29\n assert candidate(stones = [1, 3, 2, 4, 5],k = 2) == 34\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18],k = 5) == 120\n assert candidate(stones = [4, 4, 4, 4, 4, 4],k = 3) == -1\n assert candidate(stones = [10, 4, 3, 5, 1],k = 2) == 49\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 34\n assert candidate(stones = [5, 17, 23, 26, 32, 48],k = 2) == 369\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == 135\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17],k = 3) == 96\n assert candidate(stones = [1, 2, 3, 4, 5, 6],k = 2) == 51\n assert candidate(stones = [10, 10, 10, 10, 10, 10, 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 = 2) == 1480\n assert candidate(stones = [1, 2, 3],k = 4) == -1\n assert candidate(stones = [4, 3, 6, 7, 8, 2, 4, 1, 2, 3],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30],k = 5) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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 = 29) == -1\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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) == -1\n assert candidate(stones = [8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 4) == -1\n assert candidate(stones = [1, 3, 1, 3, 1, 3],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30],k = 2) == 958\n assert candidate(stones = [3, 2, 4, 1],k = 2) == 20\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 4) == 182\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 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 = 2) == 444\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 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) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 91\n assert candidate(stones = [7, 8, 9, 10, 11, 12],k = 4) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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) == 2175\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 346\n assert candidate(stones = [10, 4, 3, 5, 3, 3, 9, 4, 8, 7, 7, 2, 2, 4, 1, 6, 5],k = 3) == 213\n assert candidate(stones = [3, 5, 1, 2, 6],k = 3) == 25\n assert candidate(stones = [4, 4, 4, 4, 4, 4],k = 2) == 64\n assert candidate(stones = [10, 5, 10, 15, 20],k = 2) == 135\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == -1\n assert candidate(stones = [10, 4, 3, 5, 9],k = 2) == 69\n assert candidate(stones = [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],k = 3) == 176\n assert candidate(stones = [9, 9, 9, 9, 9, 9, 9, 9, 9],k = 3) == 162\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 3) == 523\n assert candidate(stones = [5, 17, 100, 11],k = 3) == -1\n assert candidate(stones = [1, 3, 5, 7, 9],k = 2) == 54\n assert candidate(stones = [5, 17, 19, 19, 5, 19, 8, 13, 18, 3, 18, 1, 17, 1, 11, 17, 1, 20, 18, 3, 18, 17, 1, 20, 20, 9, 2, 11, 17, 2],k = 3) == -1\n assert candidate(stones = [5, 17, 12, 2, 9, 13, 11, 16, 1, 12, 18, 10, 20, 8],k = 2) == 583\n assert candidate(stones = [4, 4, 4, 4, 4, 4, 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 = 2) == 592\n assert candidate(stones = [7, 1, 5, 9, 3, 2, 4, 6],k = 3) == -1\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5],k = 5) == -1\n assert candidate(stones = [15, 18, 6, 11, 13, 18, 5, 12, 8],k = 3) == 212\n assert candidate(stones = [10, 5, 9, 1],k = 2) == 50\n assert candidate(stones = [4, 10, 3, 5],k = 2) == 44\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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", "comparison": "exact"}, "public_tests": ["[3,2,4,1]\n2", "[3,2,4,1]\n3", "[3,5,1,2,6]\n3"], "hints": [], "metadata": {"canonical_parameter_names": ["stones", "k"], "leetcode_dataset_entry_point": "Solution().mergeStones", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:18+00:00", "tests_total": 235, "tests_dropped": 19, "flags": [], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def mergeStones(self, stones: list[int], k: int) -> int:", "container": "Solution", "callable": "mergeStones", "parameters": [{"name": "stones", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1001, "task_id": "grid-illumination", "difficulty": "Hard", "problem_description": "There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off.\n\nYou are given a 2D array of lamp positions lamps, where lamps[i] = [row_i, col_i] indicates that the lamp at grid[row_i][col_i] is turned on. Even if the same lamp is listed more than once, it is turned on.\n\nWhen a lamp is turned on, it illuminates its cell and all other cells in the same row, column, or diagonal.\n\nYou are also given another 2D array queries, where queries[j] = [row_j, col_j]. For the j^th query, determine whether grid[row_j][col_j] is illuminated or not. After answering the j^th query, turn off the lamp at grid[row_j][col_j] and its 8 adjacent lamps if they exist. A lamp is adjacent if its cell shares either a side or corner with grid[row_j][col_j].\n\nReturn an array of integers ans, where ans[j] should be 1 if the cell in the j^th query was illuminated, or 0 if the lamp was not.\n\nExample 1:\n\nInput: n = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]\nOutput: [1,0]\nExplanation: We have the initial grid with all lamps turned off. In the above picture we see the grid after turning on the lamp at grid[0][0] then turning on the lamp at grid[4][4].\nThe 0^th query asks if the lamp at grid[1][1] is illuminated or not (the blue square). It is illuminated, so set ans[0] = 1. Then, we turn off all lamps in the red square.\n\nThe 1^st query asks if the lamp at grid[1][0] is illuminated or not (the blue square). It is not illuminated, so set ans[1] = 0. Then, we turn off all lamps in the red rectangle.\n\nExample 2:\n\nInput: n = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,1]]\nOutput: [1,1]\n\nExample 3:\n\nInput: n = 5, lamps = [[0,0],[0,4]], queries = [[0,4],[0,1],[1,4]]\nOutput: [1,1,0]\n\nConstraints:\n\n- 1 <= n <= 10^9\n- 0 <= lamps.length <= 20000\n- 0 <= queries.length <= 20000\n- lamps[i].length == 2\n- 0 <= row_i, col_i < n\n- queries[j].length == 2\n- 0 <= row_j, col_j < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,lamps = [[0, 0], [4, 4]],queries = [[1, 1], [1, 1]]) == [1, 1]\n assert candidate(n = 5,lamps = [[0, 0], [0, 4]],queries = [[0, 4], [0, 1], [1, 4]]) == [1, 1, 0]\n assert candidate(n = 5,lamps = [[0, 0], [4, 4]],queries = [[1, 1], [1, 0]]) == [1, 0]\n assert candidate(n = 10,lamps = [[0, 0], [9, 9], [5, 5], [2, 7], [7, 2]],queries = [[1, 1], [8, 8], [4, 4], [3, 6], [6, 3]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[5, 5]],queries = [[4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [6, 4], [6, 5], [6, 6]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 500,lamps = [[100, 100], [200, 200], [300, 300], [400, 400], [499, 499]],queries = [[100, 100], [200, 200], [400, 400]]) == [1, 1, 1]\n assert candidate(n = 15,lamps = [[3, 3], [6, 6], [9, 9], [12, 12]],queries = [[3, 3], [6, 6], [9, 9], [12, 12], [7, 7], [8, 8], [10, 10], [11, 11]]) == [1, 1, 1, 1, 0, 0, 0, 0]\n assert candidate(n = 2000,lamps = [[1000, 1000], [500, 500], [1500, 1500], [200, 200], [1800, 1800]],queries = [[1000, 1000], [500, 500], [1500, 1500], [200, 200], [1800, 1800]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 9], [9, 0], [5, 5]],queries = [[0, 9], [9, 0], [5, 5], [4, 4], [6, 6], [3, 3], [7, 7]]) == [1, 1, 1, 0, 0, 0, 0]\n assert candidate(n = 10,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[1, 1], [3, 3], [5, 5], [7, 7]]) == [1, 1, 1, 1]\n assert candidate(n = 1000,lamps = [[500, 500], [501, 501], [499, 499], [502, 502], [498, 498]],queries = [[500, 500], [501, 501], [499, 499]]) == [1, 1, 1]\n assert candidate(n = 6,lamps = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2], [3, 3]],queries = [[2, 2], [1, 1], [1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2], [3, 3]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,lamps = [[5, 5], [5, 6], [6, 5], [6, 6], [10, 10], [11, 11], [12, 12], [13, 13]],queries = [[5, 5], [10, 10], [15, 15]]) == [1, 1, 1]\n assert candidate(n = 15,lamps = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[0, 0], [19, 19], [0, 19], [19, 0], [10, 10], [9, 9], [11, 11]],queries = [[10, 10], [10, 10], [9, 9], [11, 11], [5, 5], [10, 0]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(n = 1000,lamps = [[500, 500], [250, 250], [750, 750], [100, 100], [900, 900]],queries = [[500, 500], [250, 250], [750, 750], [100, 100], [900, 900]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[10, 10], [10, 11], [10, 12], [11, 10], [11, 11], [11, 12], [12, 10], [12, 11], [12, 12]],queries = [[9, 9], [9, 10], [9, 11], [10, 9], [10, 10], [10, 11], [11, 9], [11, 10], [11, 11]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]],queries = [[5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(n = 12,lamps = [[0, 0], [0, 11], [11, 0], [11, 11], [5, 5], [6, 6], [7, 7]],queries = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1], [2, 2], [4, 4], [4, 5], [4, 6], [5, 4], [5, 6], [6, 4], [6, 5], [6, 6]],queries = [[1, 1], [1, 2], [2, 1], [3, 3], [4, 4], [6, 6]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 5,lamps = [[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, 1], [4, 2], [4, 3], [4, 4]],queries = [[2, 2], [2, 1], [2, 3], [1, 2], [3, 2]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[2, 2], [3, 3], [5, 5], [7, 7]],queries = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 10,lamps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]],queries = [[0, 0], [9, 9], [4, 4], [3, 3], [5, 5], [1, 1], [8, 8], [2, 2], [7, 7], [6, 6]]) == [1, 1, 1, 1, 0, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 1, 1, 1, 0]\n assert candidate(n = 100,lamps = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],queries = [[50, 50], [45, 45], [55, 55]]) == [1, 1, 1]\n assert candidate(n = 4,lamps = [[0, 0], [0, 3], [3, 0], [3, 3]],queries = [[1, 1], [1, 2], [2, 1], [2, 2]]) == [1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [9, 9], [0, 9], [9, 0], [5, 5], [5, 4], [4, 5]],queries = [[5, 5], [5, 4], [4, 5], [5, 0], [9, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],queries = [[10, 10], [9, 9], [11, 11], [8, 8], [12, 12], [7, 7], [13, 13], [6, 6], [14, 14], [5, 5]]) == [1, 1, 1, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 50,lamps = [[0, 0], [25, 25], [49, 49], [24, 24], [26, 26]],queries = [[25, 25], [24, 24], [26, 26], [0, 0], [49, 49], [1, 1], [48, 48], [23, 23], [27, 27], [25, 24]]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(n = 10,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[0, 0], [1, 2], [3, 3], [5, 5], [9, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [1, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 10,lamps = [[1, 1], [2, 2], [3, 3], [4, 4]],queries = [[1, 1], [2, 2], [3, 3], [4, 4]]) == [1, 1, 1, 0]\n assert candidate(n = 7,lamps = [[1, 1], [1, 5], [5, 1], [5, 5]],queries = [[3, 3], [3, 2], [2, 3], [3, 4], [4, 3]]) == [1, 0, 0, 0, 0]\n assert candidate(n = 7,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 9,lamps = [[0, 0], [0, 8], [8, 0], [8, 8], [4, 4]],queries = [[4, 4], [4, 5], [4, 3], [5, 4], [3, 4]]) == [1, 0, 0, 0, 0]\n assert candidate(n = 10,lamps = [[0, 0], [0, 9], [9, 0], [9, 9]],queries = [[4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[0, 0], [0, 19], [19, 0], [19, 19], [10, 10]],queries = [[10, 10], [5, 5], [15, 15], [0, 0], [19, 19]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0]]) == [1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]],queries = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == [1, 1, 1, 1, 1, 0, 0, 0, 0]\n assert candidate(n = 10,lamps = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]],queries = [[1, 1], [0, 0], [1, 0], [0, 1], [1, 2], [2, 1], [2, 2], [2, 0], [0, 2]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,lamps = [[50, 50], [50, 51], [50, 52], [51, 50], [51, 51], [51, 52], [52, 50], [52, 51], [52, 52]],queries = [[49, 49], [49, 50], [49, 51], [50, 49], [50, 50], [50, 51], [51, 49], [51, 50], [51, 51]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 10,lamps = [[0, 0], [2, 2], [5, 5], [7, 7], [9, 9]],queries = [[1, 1], [3, 3], [4, 4], [6, 6], [8, 8]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 100,lamps = [[0, 0], [0, 99], [99, 0], [99, 99], [50, 50]],queries = [[25, 25], [50, 50], [75, 75], [0, 0], [99, 99]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 100,lamps = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,lamps = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],queries = [[1, 1], [2, 2], [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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 12,lamps = [[2, 2], [5, 5], [8, 8], [11, 11]],queries = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 50,lamps = [[25, 25], [25, 26], [25, 27], [26, 25], [26, 26], [26, 27], [27, 25], [27, 26], [27, 27]],queries = [[24, 24], [24, 25], [24, 26], [25, 24], [25, 25], [25, 26], [26, 24], [26, 25], [26, 26]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [2, 2], [3, 3], [5, 5], [8, 8]],queries = [[1, 1], [2, 2], [5, 5], [9, 9]]) == [1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [2, 2], [4, 4], [6, 6], [8, 8]],queries = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]]) == [1, 1, 1, 1, 0]\n assert candidate(n = 20,lamps = [[5, 5], [10, 10], [15, 15], [5, 15], [15, 5]],queries = [[5, 5], [10, 10], [15, 15], [5, 15], [15, 5], [0, 0], [19, 19], [2, 2], [18, 18], [9, 9], [11, 11]]) == [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,lamps = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [51, 51], [49, 49]]) == [1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 50,lamps = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30]],queries = [[10, 10], [20, 20], [30, 30]]) == [1, 1, 1]\n assert candidate(n = 50,lamps = [[0, 0], [49, 49], [25, 25], [10, 10], [35, 35]],queries = [[0, 0], [49, 49], [25, 25], [10, 10], [35, 35], [26, 26], [24, 24]]) == [1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 8,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == [1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 9,lamps = [[1, 1], [1, 7], [7, 1], [7, 7], [4, 4], [5, 5]],queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[1, 1], [2, 3], [5, 5], [8, 8], [9, 9]]) == [1, 1, 1, 1, 0]\n assert candidate(n = 6,lamps = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]],queries = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]) == [1, 1, 1, 1, 1, 0]\n assert candidate(n = 10,lamps = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 25,lamps = [[5, 5], [10, 10], [15, 15], [20, 20], [24, 24], [20, 5], [5, 20], [15, 10], [10, 15]],queries = [[5, 5], [10, 10], [15, 15], [20, 20], [24, 24], [20, 5], [5, 20], [15, 10], [10, 15]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[10, 10], [10, 11], [10, 12], [11, 10], [11, 11], [11, 12], [12, 10], [12, 11], [12, 12]],queries = [[11, 11], [10, 10], [10, 11], [10, 12], [11, 10], [11, 11], [11, 12], [12, 10], [12, 11], [12, 12]]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 1000,lamps = [[500, 500], [501, 501], [499, 499], [502, 502], [498, 498]],queries = [[500, 500], [501, 501], [499, 499], [502, 502], [498, 498], [500, 498], [498, 500]]) == [1, 1, 1, 0, 0, 0, 0]\n assert candidate(n = 15,lamps = [[3, 3], [3, 12], [12, 3], [12, 12], [7, 7], [4, 8], [8, 4], [4, 4], [8, 8]],queries = [[7, 7], [3, 3], [12, 12], [4, 4], [8, 8]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[5, 5], [5, 15], [15, 5], [15, 15], [10, 10]],queries = [[5, 5], [15, 15], [10, 10], [15, 5], [5, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 20,lamps = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],queries = [[5, 5], [10, 10], [15, 15], [2, 2], [18, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 250,lamps = [[125, 125], [126, 126], [124, 124], [127, 127], [123, 123]],queries = [[125, 125], [126, 126], [124, 124]]) == [1, 1, 1]\n assert candidate(n = 10,lamps = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],queries = [[2, 2], [1, 1], [3, 3], [1, 3], [2, 3]]) == [1, 0, 0, 0, 0]\n assert candidate(n = 10,lamps = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 6,lamps = [[0, 0], [0, 5], [5, 0], [5, 5], [2, 2], [3, 3]],queries = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(n = 8,lamps = [[0, 0], [0, 7], [7, 0], [7, 7], [3, 3], [4, 4]],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(n = 50,lamps = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]],queries = [[0, 0], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(n = 100,lamps = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]],queries = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == [1, 1, 1, 1, 1, 0, 0, 0, 0]\n assert candidate(n = 30,lamps = [[10, 10], [20, 20], [5, 5], [25, 25], [15, 15]],queries = [[10, 10], [20, 20], [5, 5], [25, 25], [15, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]],queries = [[0, 0], [9, 9], [4, 4], [3, 3], [5, 5]]) == [1, 1, 1, 1, 0]\n assert candidate(n = 10,lamps = [[0, 0], [0, 9], [9, 0], [9, 9], [4, 4], [5, 5]],queries = [[4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,lamps = [[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, 0]],queries = [[7, 7], [8, 6], [9, 5]]) == [1, 1, 1]\n assert candidate(n = 100,lamps = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,lamps = [[3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5]],queries = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == [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]\n assert candidate(n = 1000,lamps = [[0, 0], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]],queries = [[0, 0], [100, 100], [500, 500], [900, 900], [450, 450]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 10,lamps = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]],queries = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == [1, 1, 1, 1, 1, 0, 0, 0, 0]\n assert candidate(n = 100,lamps = [[0, 0], [99, 99], [49, 49], [25, 25], [75, 75]],queries = [[50, 50], [25, 25], [49, 49], [75, 75], [99, 99], [0, 0]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(n = 1000,lamps = [[500, 500], [501, 501], [499, 499], [500, 501], [501, 500], [499, 500], [500, 499], [501, 499], [499, 501]],queries = [[499, 499], [500, 500], [501, 501], [499, 501], [501, 499], [499, 500], [500, 499], [501, 500], [500, 501]]) == [1, 1, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 10,lamps = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == [1, 1, 1, 1, 1, 0, 0]\n assert candidate(n = 15,lamps = [[0, 0], [0, 14], [14, 0], [14, 14], [7, 7]],queries = [[7, 7], [0, 0], [14, 14], [0, 14], [14, 0]]) == [1, 1, 1, 1, 1]\n", "comparison": "exact"}, "public_tests": ["5\n[[0,0],[4,4]]\n[[1,1],[1,0]]", "5\n[[0,0],[4,4]]\n[[1,1],[1,1]]", "5\n[[0,0],[0,4]]\n[[0,4],[0,1],[1,4]]"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "lamps", "queries"], "leetcode_dataset_entry_point": "Solution().gridIllumination", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:20+00:00", "tests_total": 85, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def gridIllumination(self, n: int, lamps: list[list[int]], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "gridIllumination", "parameters": [{"name": "n", "type": "int"}, {"name": "lamps", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1002, "task_id": "find-common-characters", "difficulty": "Easy", "problem_description": "Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order.\n\nExample 1:\n\nInput: words = [\"bella\",\"label\",\"roller\"]\nOutput: [\"e\",\"l\",\"l\"]\n\nExample 2:\n\nInput: words = [\"cool\",\"lock\",\"cook\"]\nOutput: [\"c\",\"o\"]\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 100\n- words[i] consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(words=['abc', 'abc', 'abc']), ['a', 'b', 'c'])\n assert answers_match(candidate(words=['bella', 'label', 'roller']), ['e', 'l', 'l'])\n assert answers_match(candidate(words=['python', 'java', 'javascript']), [])\n assert answers_match(candidate(words=['hello', 'world', 'hold']), ['l', 'o'])\n assert answers_match(candidate(words=['aabbcc', 'aabbc', 'abc']), ['a', 'b', 'c'])\n assert answers_match(candidate(words=['cool', 'lock', 'cook']), ['c', 'o'])\n assert answers_match(candidate(words=['a', 'a', 'a', 'a']), ['a'])\n assert answers_match(candidate(words=['apple', 'apricot', 'peach']), ['a', 'p'])\n assert answers_match(candidate(words=['happy', 'happy', 'happy']), ['h', 'a', 'p', 'p', 'y'])\n assert answers_match(candidate(words=['a', 'a', 'a']), ['a'])\n assert answers_match(candidate(words=['flower', 'flow', 'flight']), ['f', 'l'])\n assert answers_match(candidate(words=['a', 'b', 'c']), [])\n assert answers_match(candidate(words=['common', 'commons', 'commonground']), ['c', 'o', 'o', 'm', 'm', 'n'])\n assert answers_match(candidate(words=['sophistication', 'sophisticated', 'sophisticating']), ['s', 's', 'o', 'p', 'h', 'i', 'i', 't', 't', 'c', 'a'])\n assert answers_match(candidate(words=['encyclopedia', 'encyclopedia', 'encyclopedic']), ['e', 'e', 'n', 'c', 'c', 'y', 'l', 'o', 'p', 'd', 'i'])\n assert answers_match(candidate(words=['abracadabra', 'abrakadabrac', 'abrakadabracd']), ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'r', 'r', 'c', 'd'])\n assert answers_match(candidate(words=['multifaceted', 'multimodal', 'multiplicity']), ['m', 'u', 'l', 't', 'i'])\n assert answers_match(candidate(words=['encyclopedia', 'encyclopedic', 'encyclopediae']), ['e', 'e', 'n', 'c', 'c', 'y', 'l', 'o', 'p', 'd', 'i'])\n assert answers_match(candidate(words=['repetition', 'perception', 'competition']), ['e', 'p', 't', 'i', 'o', 'n'])\n assert answers_match(candidate(words=['algorithm', 'logarithm', 'rhythm', 'harmony']), ['r', 'h', 'm'])\n assert answers_match(candidate(words=['xylophone', 'zoo', 'ozone']), ['o', 'o'])\n assert answers_match(candidate(words=['banana', 'bandana', 'panama']), ['a', 'a', 'a', 'n'])\n assert answers_match(candidate(words=['algorithm', 'logarithm', 'altruism']), ['a', 'l', 'r', 'i', 't', 'm'])\n assert answers_match(candidate(words=['floccinaucinihilipilification', 'pneumonoultramicroscopicsilicovolcanoconiosis', 'supercalifragilisticexpialidocious']), ['l', 'l', 'l', 'o', 'o', 'c', 'c', 'c', 'i', 'i', 'i', 'i', 'i', 'i', 'a', 'a', 'u', 'p', 't'])\n assert answers_match(candidate(words=['environment', 'venture', 'ambient']), ['e', 'n', 't'])\n assert answers_match(candidate(words=['algorithm', 'algorithms', 'algebra']), ['a', 'l', 'g', 'r'])\n assert answers_match(candidate(words=['repetition', 'replication', 'repetitive']), ['r', 'e', 'p', 't', 'i', 'i'])\n assert answers_match(candidate(words=['characterization', 'character', 'charisma']), ['c', 'h', 'a', 'a', 'r'])\n assert answers_match(candidate(words=['repetition', 'petition', 'portion']), ['p', 't', 'i', 'o', 'n'])\n assert answers_match(candidate(words=['unbelievable', 'believable', 'believability']), ['b', 'b', 'e', 'e', 'l', 'l', 'i', 'v', 'a'])\n assert answers_match(candidate(words=['xylophone', 'xylophones', 'xylophonist']), ['x', 'y', 'l', 'o', 'o', 'p', 'h', 'n'])\n assert answers_match(candidate(words=['environment', 'ambient', 'administrate']), ['e', 'n', 'i', 'm', 't'])\n assert answers_match(candidate(words=['environment', 'environments', 'environmental']), ['e', 'e', 'n', 'n', 'n', 'v', 'i', 'r', 'o', 'm', 't'])\n assert answers_match(candidate(words=['intersection', 'intersects', 'intercept']), ['i', 'n', 't', 't', 'e', 'e', 'r', 'c'])\n assert answers_match(candidate(words=['abracadabra', 'abrakadabras', 'abrakadabratic']), ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'r', 'r', 'd'])\n assert answers_match(candidate(words=['intersection', 'interact', 'interstellar']), ['i', 'n', 't', 't', 'e', 'r'])\n assert answers_match(candidate(words=['fantastic', 'fantasy', 'fantasia']), ['f', 'a', 'a', 'n', 't', 's'])\n assert answers_match(candidate(words=['mississippi', 'missouri', 'missile']), ['m', 'i', 'i', 's', 's'])\n assert answers_match(candidate(words=['reducibility', 'reductiveness', 'reductive']), ['r', 'e', 'd', 'u', 'c', 'i', 't'])\n assert answers_match(candidate(words=['alphabet', 'alphabetic', 'alphanumeric']), ['a', 'a', 'l', 'p', 'h', 'e'])\n assert answers_match(candidate(words=['repetition', 'petition', 'representation']), ['e', 'p', 't', 't', 'i', 'o', 'n'])\n assert answers_match(candidate(words=['congratulations', 'congratulate', 'congratulatory']), ['c', 'o', 'n', 'g', 'r', 'a', 'a', 't', 't', 'u', 'l'])\n assert answers_match(candidate(words=['zzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzz']), ['z', 'z', 'z', 'z', 'z', 'z'])\n assert answers_match(candidate(words=['programming', 'program', 'pro']), ['p', 'r', 'o'])\n assert answers_match(candidate(words=['environment', 'environmental', 'environments']), ['e', 'e', 'n', 'n', 'n', 'v', 'i', 'r', 'o', 'm', 't'])\n assert answers_match(candidate(words=['abbreviation', 'abbreviate', 'abbreviations']), ['a', 'a', 'b', 'b', 'r', 'e', 'v', 'i', 't'])\n assert answers_match(candidate(words=['intersection', 'interior', 'interesting']), ['i', 'i', 'n', 't', 'e', 'r'])\n assert answers_match(candidate(words=['abcdefghij', 'jihgfedcba', 'fedcba', 'abcdefghij']), ['a', 'b', 'c', 'd', 'e', 'f'])\n assert answers_match(candidate(words=['supercalifragilisticexpialidocious', 'supercalifragilistic', 'supercalifragilisticexpialidos']), ['s', 's', 'u', 'p', 'e', 'r', 'r', 'c', 'c', 'a', 'a', 'l', 'l', 'i', 'i', 'i', 'i', 'f', 'g', 't'])\n assert answers_match(candidate(words=['development', 'delivery', 'department']), ['d', 'e', 'e'])\n assert answers_match(candidate(words=['mississippi', 'missionary', 'pessimism']), ['m', 'i', 'i', 's', 's'])\n assert answers_match(candidate(words=['programming', 'gramming', 'paring']), ['r', 'g', 'a', 'i', 'n'])\n assert answers_match(candidate(words=['zzzzzzzzzz', 'zzzzzzzzz', 'zzzzzzzz', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z']), ['z'])\n assert answers_match(candidate(words=['programming', 'programmer', 'program']), ['p', 'r', 'r', 'o', 'g', 'a', 'm'])\n assert answers_match(candidate(words=['xylophone', 'xylography', 'xylophonist']), ['x', 'y', 'l', 'o', 'p', 'h'])\n assert answers_match(candidate(words=['characterization', 'characterization', 'characterize']), ['c', 'c', 'h', 'a', 'a', 'r', 'r', 't', 'e', 'i', 'z'])\n assert answers_match(candidate(words=['orchestration', 'orchestrated', 'orchestrator']), ['o', 'r', 'r', 'c', 'h', 'e', 's', 't', 't', 'a'])\n assert answers_match(candidate(words=['characterization', 'character', 'characterization']), ['c', 'c', 'h', 'a', 'a', 'r', 'r', 't', 'e'])\n assert answers_match(candidate(words=['intersectionality', 'interact', 'interstellar']), ['i', 'n', 't', 't', 'e', 'r', 'a'])\n assert answers_match(candidate(words=['abracadabra', 'academia', 'barbara']), ['a', 'a', 'a'])\n assert answers_match(candidate(words=['aabbcc', 'bbaacc', 'ccaabb', 'aabbc', 'abbcc', 'aaccb', 'abcabc']), ['a', 'b', 'c'])\n assert answers_match(candidate(words=['abacaxi', 'bacana', 'cabana']), ['a', 'a', 'a', 'b', 'c'])\n assert answers_match(candidate(words=['intersection', 'interact', 'interactive']), ['i', 'n', 't', 't', 'e', 'r', 'c'])\n assert answers_match(candidate(words=['programming', 'programmer', 'programmatic']), ['p', 'r', 'r', 'o', 'g', 'a', 'm', 'm'])\n assert answers_match(candidate(words=['exemplification', 'exemplary', 'exemplify']), ['e', 'e', 'x', 'm', 'p', 'l'])\n assert answers_match(candidate(words=['congratulations', 'congratulate', 'congratulations']), ['c', 'o', 'n', 'g', 'r', 'a', 'a', 't', 't', 'u', 'l'])\n assert answers_match(candidate(words=['abracadabra', 'alakazam', 'alchemy']), ['a'])\n assert answers_match(candidate(words=['mississippi', 'missouri', 'missed']), ['m', 'i', 's', 's'])\n assert answers_match(candidate(words=['aaa', 'aa', 'a']), ['a'])\n assert answers_match(candidate(words=['xylophone', 'xylophones', 'xylophonist', 'xylophonists']), ['x', 'y', 'l', 'o', 'o', 'p', 'h', 'n'])\n assert answers_match(candidate(words=['mississippi', 'misstep', 'misspell']), ['m', 'i', 's', 's', 'p'])\n assert answers_match(candidate(words=['bookkeeper', 'bookstore', 'keeper']), ['k', 'e', 'r'])\n assert answers_match(candidate(words=['multifaceted', 'multifarious', 'multitude']), ['m', 'u', 'l', 't', 'i'])\n assert answers_match(candidate(words=['multiple', 'multiplication', 'multiplicity']), ['m', 'u', 'l', 'l', 't', 'i', 'p'])\n assert answers_match(candidate(words=['aabbccddeeff', 'bbaacceeddff', 'ccaabbeeffdd', 'aabbeeffccdd', 'aabbccdde', 'bbccddeeff', 'aaccbbeeff']), ['b', 'b', 'c', 'c', 'e'])\n assert answers_match(candidate(words=['xylophone', 'xenon', 'xerox', 'xylography']), ['x', 'o'])\n assert answers_match(candidate(words=['repetition', 'repetitions', 'repetitive']), ['r', 'e', 'e', 'p', 't', 't', 'i', 'i'])\n assert answers_match(candidate(words=['mississippi', 'missouri', 'missisipi']), ['m', 'i', 'i', 's', 's'])\n assert answers_match(candidate(words=['beautiful', 'beautify', 'beautification']), ['b', 'e', 'a', 'u', 't', 'i', 'f'])\n assert answers_match(candidate(words=['algorithm', 'algebra', 'alignment']), ['a', 'l', 'g'])\n assert answers_match(candidate(words=['intersection', 'interact', 'interaction']), ['i', 'n', 't', 't', 'e', 'r', 'c'])\n assert answers_match(candidate(words=['exceedingly', 'excellent', 'exceptional']), ['e', 'e', 'x', 'c', 'n', 'l'])\n assert answers_match(candidate(words=['abracadabra', 'cadabra', 'abraca']), ['a', 'a', 'a', 'b', 'r', 'c'])\n assert answers_match(candidate(words=['algorithm', 'logarithm', 'rhythm']), ['r', 't', 'h', 'm'])\n assert answers_match(candidate(words=['quizzing', 'quizzes', 'quizzed']), ['q', 'u', 'i', 'z', 'z'])\n assert answers_match(candidate(words=['sophisticated', 'sophistication', 'sophistry']), ['s', 's', 'o', 'p', 'h', 'i', 't'])\n assert answers_match(candidate(words=['strength', 'strengths', 'stressed']), ['s', 't', 'r', 'e'])\n assert answers_match(candidate(words=['encyclopedia', 'encyclopediae', 'encyclopedias']), ['e', 'e', 'n', 'c', 'c', 'y', 'l', 'o', 'p', 'd', 'i', 'a'])\n assert answers_match(candidate(words=['repetition', 'petition', 'competition']), ['e', 'p', 't', 't', 'i', 'i', 'o', 'n'])\n assert answers_match(candidate(words=['unbelievable', 'unbeliever', 'unbelievably']), ['u', 'n', 'b', 'e', 'e', 'l', 'i', 'v'])\n assert answers_match(candidate(words=['interpolation', 'interpretation', 'internationalization']), ['i', 'i', 'n', 'n', 't', 't', 'e', 'r', 'o', 'a'])\n assert answers_match(candidate(words=['intersection', 'intercept', 'interstellar']), ['i', 'n', 't', 't', 'e', 'e', 'r'])\n assert answers_match(candidate(words=['abcd', 'bcde', 'cdef', 'defg']), ['d'])\n assert answers_match(candidate(words=['pterodactyl', 'pterodactyl', 'pterodactyls']), ['p', 't', 't', 'e', 'r', 'o', 'd', 'a', 'c', 'y', 'l'])\n assert answers_match(candidate(words=['mississippi', 'missouri', 'missed', 'missives']), ['m', 'i', 's', 's'])\n assert answers_match(candidate(words=['repetition', 'replicate', 'repetitive']), ['r', 'e', 'e', 'p', 't', 'i'])\n assert answers_match(candidate(words=['algorithm', 'algorithmic', 'algorithms']), ['a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm'])\n assert answers_match(candidate(words=['encyclopedia', 'encyclopedia', 'encyclopedia']), ['e', 'e', 'n', 'c', 'c', 'y', 'l', 'o', 'p', 'd', 'i', 'a'])\n assert answers_match(candidate(words=['banana', 'bandana', 'bananas']), ['b', 'a', 'a', 'a', 'n', 'n'])\n assert answers_match(candidate(words=['repetition', 'perpetuation', 'petition']), ['e', 'p', 't', 't', 'i', 'o', 'n'])\n assert answers_match(candidate(words=['algorithm', 'logarithm', 'anthology']), ['a', 'l', 'g', 'o', 't', 'h'])\n assert answers_match(candidate(words=['intersection', 'interview', 'interstellar']), ['i', 'n', 't', 'e', 'e', 'r'])\n assert answers_match(candidate(words=['mississippi', 'missouri', 'dismiss']), ['m', 'i', 'i', 's', 's'])\n", "comparison": "unordered"}, "public_tests": ["[\"bella\",\"label\",\"roller\"]", "[\"cool\",\"lock\",\"cook\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().commonChars", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:22+00:00", "tests_total": 103, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def commonChars(self, words: list[str]) -> list[str]:", "container": "Solution", "callable": "commonChars", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1003, "task_id": "check-if-word-is-valid-after-substitutions", "difficulty": "Medium", "problem_description": "Given a string s, determine if it is valid.\n\nA string s is valid if, starting with an empty string t = \"\", you can transform t into s after performing the following operation any number of times:\n\n- Insert string \"abc\" into any position in t. More formally, t becomes t_left + \"abc\" + t_right, where t == t_left + t_right. Note that t_left and t_right may be empty.\n\nReturn true if s is a valid string, otherwise, return false.\n\nExample 1:\n\nInput: s = \"aabcbc\"\nOutput: true\nExplanation:\n\"\" -> \"abc\" -> \"aabcbc\"\nThus, \"aabcbc\" is valid.\n\nExample 2:\n\nInput: s = \"abcabcababcc\"\nOutput: true\nExplanation:\n\"\" -> \"abc\" -> \"abcabc\" -> \"abcabcabc\" -> \"abcabcababcc\"\nThus, \"abcabcababcc\" is valid.\n\nExample 3:\n\nInput: s = \"abccba\"\nOutput: false\nExplanation: It is impossible to get \"abccba\" using the operation.\n\nConstraints:\n\n- 1 <= s.length <= 2 * 10^4\n- s consists of letters 'a', 'b', and 'c'\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == False\n assert candidate(s = \"aababcbccabc\") == False\n assert candidate(s = \"cababc\") == False\n assert candidate(s = \"abcabcabc\") == True\n assert candidate(s = \"aababcbabc\") == False\n assert candidate(s = \"abcabcabcabc\") == True\n assert candidate(s = \"aabcbc\") == True\n assert candidate(s = \"abcabc\") == True\n assert candidate(s = \"abcabcababcc\") == True\n assert candidate(s = \"bcaabc\") == False\n assert candidate(s = \"aabcabcabc\") == False\n assert candidate(s = \"bca\") == False\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"aabababc\") == False\n assert candidate(s = \"abcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabcabacbc\") == False\n assert candidate(s = \"ababcabcababcc\") == False\n assert candidate(s = \"abccba\") == False\n assert candidate(s = \"cab\") == False\n assert candidate(s = \"aabbcc\") == False\n assert candidate(s = \"aabcbcababc\") == False\n assert candidate(s = \"aabcbabcbabc\") == False\n assert candidate(s = \"aabcbabcbabccba\") == False\n assert candidate(s = \"aababababababcabcabcabcabcabc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"aababababababcabcababc\") == False\n assert candidate(s = \"aabcbcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"ababcabcabcababcabcababcabc\") == False\n assert candidate(s = \"abcabcabababcabc\") == False\n assert candidate(s = \"ababcabcabcabcababc\") == False\n assert candidate(s = \"ababcababcababcababcababcc\") == False\n assert candidate(s = \"abcabababcababcabc\") == False\n assert candidate(s = \"aababababcbcbcbc\") == False\n assert candidate(s = \"aabbbccabcabcabcabcabcabcab\") == False\n assert candidate(s = \"aabbabccbababc\") == False\n assert candidate(s = \"aaaabbbbcccc\") == False\n assert candidate(s = \"abcabababababababc\") == False\n assert candidate(s = \"aababcabcbaabc\") == False\n assert candidate(s = \"aabcbabcbabcbabcbabcbabc\") == False\n assert candidate(s = \"abcabababababababcababababababc\") == False\n assert candidate(s = \"abcabccbaabc\") == False\n assert candidate(s = \"abcabcababababcabc\") == False\n assert candidate(s = \"aabcbcaabcab\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"aabcbabcababcabcba\") == False\n assert candidate(s = \"aabcbcababcbcababc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"aabcbabcabcbabcabcbabcabcbabcabcbabcabc\") == False\n assert candidate(s = \"abccabccabccabccabccabccabccabccabcc\") == False\n assert candidate(s = \"aababcababcabcabcabcabcababcc\") == False\n assert candidate(s = \"aabcbcaabcbcaabcbcaabcbcaabc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabcabcabcabcabcab\") == False\n assert candidate(s = \"abababcabcabcabc\") == False\n assert candidate(s = \"abababcabcabcabcabc\") == False\n assert candidate(s = \"abccababccababcc\") == False\n assert candidate(s = \"ababcabcababcabcabcabcabc\") == False\n assert candidate(s = \"abccbaabccbaabccba\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"aabcbcabcabcabcabcbcaabbcc\") == False\n assert candidate(s = \"aabababababababcabcabc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"aabcbcababcbcababccba\") == False\n assert candidate(s = \"ababababcabcabc\") == False\n assert candidate(s = \"ababababababcabcabcababc\") == False\n assert candidate(s = \"abccabccabccabccabccabcc\") == False\n assert candidate(s = \"aabcbabcbababc\") == False\n assert candidate(s = \"abcabcababccabcabcab\") == False\n assert candidate(s = \"aabcbcabcabababcabcabcabababcabcab\") == False\n assert candidate(s = \"aabcbcaabcbcaabcbcaabc\") == False\n assert candidate(s = \"aabcbabcabcbabcabcbabcabc\") == False\n assert candidate(s = \"abcabababcabababc\") == False\n assert candidate(s = \"ababababababcabcabcabcabcabc\") == False\n assert candidate(s = \"aaabbbcccaabbbcccaabbbcccabcabcabc\") == False\n assert candidate(s = \"abcababccbaabc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabccbaabccba\") == False\n assert candidate(s = \"aabcbabababcabcabc\") == False\n assert candidate(s = \"aabcbcababccbaabcbcbcabcababcababcbc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabccba\") == False\n assert candidate(s = \"abcababababcabab\") == False\n assert candidate(s = \"abcababcababcababc\") == False\n assert candidate(s = \"aabcbcababccbaabccba\") == False\n assert candidate(s = \"abababababcabababcabc\") == False\n assert candidate(s = \"aabcbcababcbcababcbcabababcabcabccba\") == False\n assert candidate(s = \"aabcbabcbabcbabcbabcbabcbabcbabc\") == False\n assert candidate(s = \"aababababababababcabcababcababcc\") == False\n assert candidate(s = \"aabbccabcabcabcabcabcabcabc\") == False\n assert candidate(s = \"abababababababababababcabcabcabcabcabcabc\") == False\n assert candidate(s = \"aabcbcabcabcabcabcabccbaabc\") == False\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == False\n assert candidate(s = \"abababababababababababc\") == False\n assert candidate(s = \"abababababababababababcabcabc\") == False\n assert candidate(s = \"aabcaabbccabcabcabc\") == False\n assert candidate(s = \"ababcababcababcababcababcababcababcabcabcc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabababababababababababababcabcabcababcabc\") == False\n assert candidate(s = \"abcabcabcabcabccba\") == False\n assert candidate(s = \"aabcbcababccbaabcbcbcabcababcababcbcababccba\") == False\n assert candidate(s = \"abcabcababcabcabcabababc\") == False\n assert candidate(s = \"aaabbbbcccc\") == False\n assert candidate(s = \"abcabababcababababc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"ababababcabcabcababc\") == False\n assert candidate(s = \"abccabccabccabccabccabccabccabccabccabccabcc\") == False\n assert candidate(s = \"ababcababcababcababcababcababcababcababc\") == False\n assert candidate(s = \"abcababababababababababababcabcabcab\") == False\n assert candidate(s = \"abababababababababababababcabcabcabcabcabcabcabc\") == False\n assert candidate(s = \"abccabccabccabcabcabc\") == False\n assert candidate(s = \"aababcababcababcababcab\") == False\n assert candidate(s = \"abcabcabcabccbaabc\") == False\n assert candidate(s = \"aababcabcabcababcc\") == False\n assert candidate(s = \"aabcbcaabcbcaabc\") == False\n assert candidate(s = \"abcabcabcabababcababc\") == False\n assert candidate(s = \"abcababcababcababcababcab\") == False\n assert candidate(s = \"abcabcabcabcababcabc\") == False\n assert candidate(s = \"abacbabcbacbabcbabc\") == False\n assert candidate(s = \"aabccbaabcabcabc\") == False\n assert candidate(s = \"abccbaabcabcabcabcabc\") == False\n assert candidate(s = \"abababababcabcabcabc\") == False\n assert candidate(s = \"aabbabccbababcabcabc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabcabcabcabcabccba\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabcababcababc\") == False\n assert candidate(s = \"aabcbcababcbcababcbcababcabc\") == False\n assert candidate(s = \"ababababababababc\") == False\n assert candidate(s = \"aabcbabcbabcbabc\") == False\n assert candidate(s = \"ababcababcababcababcababcababcabcabc\") == False\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"aabcbcabcabcabcabcabcabcabcabcabcabcabc\") == True\n assert candidate(s = \"abcabcabcababccbaabc\") == False\n assert candidate(s = \"abcababababcabcabcab\") == False\n assert candidate(s = \"aabcbcabcabcabcabcabcabcabcbc\") == False\n assert candidate(s = \"aabababababababababababababababcabcabc\") == False\n assert candidate(s = \"aabcbcbcbcabcabcabc\") == False\n assert candidate(s = \"abccabcabcabcabcab\") == False\n assert candidate(s = \"abababababababababababababababababababcabcabc\") == False\n assert candidate(s = \"aabcbcababccbaabcbcbc\") == False\n", "comparison": "exact"}, "public_tests": ["\"aabcbc\"", "\"abcabcababcc\"", "\"abccba\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().isValid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:24+00:00", "tests_total": 140, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "stack"]}, "language": "python", "interface": {"raw_signature": "def isValid(self, s: str) -> bool:", "container": "Solution", "callable": "isValid", "parameters": [{"name": "s", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1004, "task_id": "max-consecutive-ones-iii", "difficulty": "Medium", "problem_description": "Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.\n\nExample 1:\n\nInput: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2\nOutput: 6\nExplanation: [1,1,1,0,0,1,1,1,1,1,1]\nBolded numbers were flipped from 0 to 1. The longest subarray is underlined.\n\nExample 2:\n\nInput: nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3\nOutput: 10\nExplanation: [0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1]\nBolded numbers were flipped from 0 to 1. The longest subarray is underlined.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- nums[i] is either 0 or 1.\n- 0 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],k = 2) == 4\n assert candidate(nums = [0, 0, 0, 0],k = 2) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 5\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1],k = 3) == 10\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 10\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 = 5) == 5\n assert candidate(nums = [0, 0, 0, 0, 0],k = 3) == 3\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0],k = 2) == 6\n assert candidate(nums = [1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1],k = 4) == 14\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 8) == 37\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0],k = 5) == 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],k = 20) == 41\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 20) == 32\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == 20\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, 1, 1],k = 3) == 15\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],k = 10) == 22\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],k = 7) == 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],k = 10) == 21\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],k = 15) == 31\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],k = 8) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],k = 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, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],k = 3) == 8\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 15) == 31\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 6) == 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 = 5) == 20\n assert candidate(nums = [0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1],k = 6) == 14\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 14\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 10) == 16\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 13\n assert candidate(nums = [0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],k = 15) == 51\n assert candidate(nums = [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],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],k = 0) == 20\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],k = 8) == 17\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 21\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 4) == 10\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 12) == 19\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],k = 5) == 25\n assert candidate(nums = [1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1],k = 7) == 17\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],k = 15) == 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],k = 0) == 32\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 6) == 15\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0],k = 7) == 19\n assert candidate(nums = [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, 1, 1, 1],k = 4) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 30\n assert candidate(nums = [1, 1, 0, 1, 1, 1, 0, 1, 0, 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],k = 10) == 42\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],k = 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, 1, 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 = 12) == 45\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1],k = 3) == 11\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 = 15) == 15\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0],k = 5) == 18\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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],k = 10) == 32\n assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0],k = 3) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 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, 1],k = 2) == 3\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1],k = 4) == 11\n assert candidate(nums = [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],k = 7) == 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],k = 0) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],k = 3) == 8\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0],k = 5) == 18\n assert candidate(nums = [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],k = 3) == 12\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) == 3\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 20\n assert candidate(nums = [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, 0, 0, 0, 0, 0],k = 10) == 35\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 4) == 7\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],k = 30) == 61\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],k = 15) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0],k = 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 15\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1],k = 4) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 15\n", "comparison": "exact"}, "public_tests": ["[1,1,1,0,0,0,1,1,1,1,0]\n2", "[0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1]\n3"], "hints": ["One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window!", "Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we can never have > K zeros, right?", "We don't have a fixed size window in this case. The window size can grow and shrink depending upon the number of zeros we have (we don't actually have to flip the zeros here!).", "The way to shrink or expand a window would be based on the number of zeros that can still be flipped and so on."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().longestOnes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:26+00:00", "tests_total": 77, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def longestOnes(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "longestOnes", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1005, "task_id": "maximize-sum-of-array-after-k-negations", "difficulty": "Easy", "problem_description": "Given an integer array nums and an integer k, modify the array in the following way:\n\n- choose an index i and replace nums[i] with -nums[i].\n\nYou should apply this process exactly k times. You may choose the same index i multiple times.\n\nReturn the largest possible sum of the array after modifying it in this way.\n\nExample 1:\n\nInput: nums = [4,2,3], k = 1\nOutput: 5\nExplanation: Choose index 1 and nums becomes [4,-2,3].\n\nExample 2:\n\nInput: nums = [3,-1,0,2], k = 3\nOutput: 6\nExplanation: Choose indices (1, 2, 2) and nums becomes [3,1,0,2].\n\nExample 3:\n\nInput: nums = [2,-3,-1,5,-4], k = 2\nOutput: 13\nExplanation: Choose indices (1, 4) and nums becomes [2,3,-1,5,4].\n\nConstraints:\n\n- 1 <= nums.length <= 10^4\n- -100 <= nums[i] <= 100\n- 1 <= k <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-5, -4, -3, -2, -1],k = 5) == 15\n assert candidate(nums = [0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [4, 2, 3],k = 1) == 5\n assert candidate(nums = [100, -100, 50, -50],k = 3) == 200\n assert candidate(nums = [1, 2, 3, 4],k = 2) == 10\n assert candidate(nums = [100, -100, 50, -50],k = 5) == 200\n assert candidate(nums = [2, -3, -1, 5, -4],k = 2) == 13\n assert candidate(nums = [3, -1, 0, 2],k = 3) == 6\n assert candidate(nums = [-1, -2, -3, -4],k = 2) == 4\n assert candidate(nums = [0, 0, 0, 0],k = 4) == 0\n assert candidate(nums = [1, 2, 3],k = 6) == 6\n assert candidate(nums = [-1, 0, 1],k = 1) == 2\n assert candidate(nums = [-1, -2, -3, -4],k = 4) == 10\n assert candidate(nums = [0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 13\n assert candidate(nums = [1, -1, 2, -2],k = 4) == 6\n assert candidate(nums = [1, 2, 3, 4],k = 4) == 10\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4],k = 10) == 20\n assert candidate(nums = [1, -1, 2, -2, 3, -3],k = 9) == 12\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91],k = 10) == 955\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 53\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 53\n assert candidate(nums = [-7, 3, -5, 2, -1],k = 6) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 53\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 15) == 8\n assert candidate(nums = [-1, 1, -1, 1, -1],k = 8) == 3\n assert candidate(nums = [-10, 20, -30, 40, -50],k = 5) == 150\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 13\n assert candidate(nums = [99, -99, 50, -50, 25, -25],k = 10) == 298\n assert candidate(nums = [1, 2, 3, 4, 5],k = 20) == 15\n assert candidate(nums = [100, -100, 100, -100, 100],k = 100) == 500\n assert candidate(nums = [-1, -2, -3, -4],k = 10) == 10\n assert candidate(nums = [-10, -9, -8, -7, -6],k = 10) == 28\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 15) == 150\n assert candidate(nums = [-10, 20, -30, 40, -50],k = 15) == 150\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40],k = 6) == 250\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 15) == 550\n assert candidate(nums = [1, -1, 1, -1],k = 7) == 2\n assert candidate(nums = [5, -3, 8, -2, 9, -4],k = 3) == 31\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 10) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9999) == 8\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4],k = 15) == 20\n assert candidate(nums = [99, -99, 50, -50, 1],k = 10000) == 299\n assert candidate(nums = [1, -2, 3, -4, 5, -6],k = 5) == 21\n assert candidate(nums = [-1, -2, -3, -4],k = 3) == 8\n assert candidate(nums = [-1, 0, 1],k = 2) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 8\n assert candidate(nums = [0, 1, -2, 3, -4, 5, -6],k = 7) == 21\n assert candidate(nums = [1, -1, 1, -1, 1, -1],k = 100) == 4\n assert candidate(nums = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95],k = 15) == 970\n assert candidate(nums = [-10, -20, -30, -40],k = 6) == 100\n assert candidate(nums = [-1, 0, 1],k = 3) == 2\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 11) == 55\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0],k = 9) == 45\n assert candidate(nums = [-50, 50, 25, -25, 12, -12, 6, -6, 3, -3],k = 12) == 186\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 7) == 55\n assert candidate(nums = [10, 20, 30, 40, 50],k = 3) == 130\n assert candidate(nums = [0, 0, 0, 0],k = 7) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3],k = 5) == 12\n assert candidate(nums = [2, 4, 6, 8, 10],k = 1) == 26\n assert candidate(nums = [-10, 10, -20, 20, -30, 30],k = 6) == 100\n assert candidate(nums = [5, -3, 7, -2, 1],k = 3) == 16\n assert candidate(nums = [0, 0, 0, 0, 0],k = 1000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 53\n assert candidate(nums = [-1, -2, -3, -4],k = 10) == 10\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 15) == 55\n assert candidate(nums = [0, 0, 0, 0],k = 100) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == 25\n assert candidate(nums = [100, 50, 25, 12, 6, 3],k = 7) == 190\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 45\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 20) == 110\n assert candidate(nums = [5, -5, 15, -15, 25, -25],k = 11) == 90\n assert candidate(nums = [100, 100, 100, 100, 100],k = 10000) == 500\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3],k = 7) == 12\n assert candidate(nums = [10, -10, 20, -20, 30, -30],k = 6) == 100\n assert candidate(nums = [100, -50, 25, -10, 5],k = 3) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 53\n assert candidate(nums = [99, -99, 50, -50, 25, -25],k = 7) == 348\n assert candidate(nums = [-1, -2, -3, 4, 5, 6],k = 4) == 19\n assert candidate(nums = [1, -1, 1, -1, 1, -1],k = 10) == 4\n assert candidate(nums = [1, 2, 3, -4, -5, -6],k = 3) == 21\n assert candidate(nums = [10, -10, 20, -20, 30, -30],k = 9) == 120\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 20) == 200\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4],k = 8) == 20\n assert candidate(nums = [0, 0, 0, 0, 0],k = 100) == 0\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40],k = 14) == 250\n assert candidate(nums = [-1, 0, 1],k = 5) == 2\n assert candidate(nums = [-99, -98, -97, -96, -95],k = 10) == 295\n assert candidate(nums = [10, -10, 20, -20, 30, -30],k = 7) == 120\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 46\n assert candidate(nums = [100, 100, 100, 100, 100],k = 3) == 300\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1000) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1],k = 15) == 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],k = 20) == 100\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 20) == 280\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 10) == 55\n assert candidate(nums = [5, -5, 5, -5, 5, -5],k = 6) == 20\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0],k = 8) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 53\n assert candidate(nums = [5, -1, -2, -3, -4],k = 6) == 15\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4],k = 8) == 20\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 8) == 53\n assert candidate(nums = [-100, -50, 0, 50, 100],k = 3) == 300\n assert candidate(nums = [10, -20, 30, -40, 50, -60],k = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 53\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 10) == 10\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 3) == 90\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 8) == 53\n assert candidate(nums = [-100, -50, -25, -12, -6, -3],k = 8) == 196\n assert candidate(nums = [-10, -20, 0, 20, 10],k = 5) == 60\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 20) == 130\n assert candidate(nums = [-1, 0, 1],k = 1) == 2\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 6) == 130\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6],k = 20) == 374\n", "comparison": "exact"}, "public_tests": ["[4,2,3]\n1", "[3,-1,0,2]\n3", "[2,-3,-1,5,-4]\n2"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().largestSumAfterKNegations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:29+00:00", "tests_total": 121, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def largestSumAfterKNegations(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "largestSumAfterKNegations", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1006, "task_id": "clumsy-factorial", "difficulty": "Medium", "problem_description": "The factorial of a positive integer n is the product of all positive integers less than or equal to n.\n\n- For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.\n\nWe make a clumsy factorial using the integers in decreasing order by swapping out the multiply operations for a fixed rotation of operations with multiply '*', divide '/', add '+', and subtract '-' in this order.\n\n- For example, clumsy(10) = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1.\n\nHowever, these operations are still applied using the usual order of operations of arithmetic. We do all multiplication and division steps before any addition or subtraction steps, and multiplication and division steps are processed left to right.\n\nAdditionally, the division that we use is floor division such that 10 * 9 / 8 = 90 / 8 = 11.\n\nGiven an integer n, return the clumsy factorial of n.\n\nExample 1:\n\nInput: n = 4\nOutput: 7\nExplanation: 7 = 4 * 3 / 2 + 1\n\nExample 2:\n\nInput: n = 10\nOutput: 12\nExplanation: 12 = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 9\n assert candidate(n = 3) == 6\n assert candidate(n = 100) == 101\n assert candidate(n = 4) == 7\n assert candidate(n = 10000) == 10001\n assert candidate(n = 9) == 11\n assert candidate(n = 5000) == 5001\n assert candidate(n = 6) == 8\n assert candidate(n = 2) == 2\n assert candidate(n = 9999) == 9998\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 1001\n assert candidate(n = 7) == 6\n assert candidate(n = 10) == 12\n assert candidate(n = 5) == 7\n assert candidate(n = 12) == 13\n assert candidate(n = 21) == 23\n assert candidate(n = 2000) == 2001\n assert candidate(n = 7500) == 7501\n assert candidate(n = 104) == 105\n assert candidate(n = 50) == 52\n assert candidate(n = 300) == 301\n assert candidate(n = 28) == 29\n assert candidate(n = 30) == 32\n assert candidate(n = 99) == 98\n assert candidate(n = 6666) == 6668\n assert candidate(n = 17) == 19\n assert candidate(n = 999) == 998\n assert candidate(n = 18) == 20\n assert candidate(n = 20) == 21\n assert candidate(n = 24) == 25\n assert candidate(n = 7777) == 7779\n assert candidate(n = 11) == 10\n assert candidate(n = 15) == 14\n assert candidate(n = 14) == 16\n assert candidate(n = 31) == 30\n assert candidate(n = 500) == 501\n assert candidate(n = 25) == 27\n", "comparison": "exact"}, "public_tests": ["4", "10"], "hints": [], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().clumsy", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:31+00:00", "tests_total": 38, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def clumsy(self, n: int) -> int:", "container": "Solution", "callable": "clumsy", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1007, "task_id": "minimum-domino-rotations-for-equal-row", "difficulty": "Medium", "problem_description": "In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the i^th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)\n\nWe may rotate the i^th domino, so that tops[i] and bottoms[i] swap values.\n\nReturn the minimum number of rotations so that all the values in tops are the same, or all the values in bottoms are the same.\n\nIf it cannot be done, return -1.\n\nExample 1:\n\nInput: tops = [2,1,2,4,2,2], bottoms = [5,2,6,2,3,2]\nOutput: 2\nExplanation:\nThe first figure represents the dominoes as given by tops and bottoms: before we do any rotations.\nIf we rotate the second and fourth dominoes, we can make every value in the top row equal to 2, as indicated by the second figure.\n\nExample 2:\n\nInput: tops = [3,5,1,2,3], bottoms = [3,6,3,3,4]\nOutput: -1\nExplanation:\nIn this case, it is not possible to rotate the dominoes to make one row of values equal.\n\nConstraints:\n\n- 2 <= tops.length <= 2 * 10^4\n- bottoms.length == tops.length\n- 1 <= tops[i], bottoms[i] <= 6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tops = [2, 3, 2, 2],bottoms = [1, 2, 2, 2]) == 1\n assert candidate(tops = [2, 3, 2, 1, 2],bottoms = [1, 2, 3, 2, 2]) == 2\n assert candidate(tops = [6, 6, 6, 6, 6, 6],bottoms = [6, 6, 6, 6, 6, 6]) == 0\n assert candidate(tops = [3, 5, 1, 2, 3],bottoms = [3, 6, 3, 3, 4]) == -1\n assert candidate(tops = [1, 1, 1, 1],bottoms = [1, 1, 1, 1]) == 0\n assert candidate(tops = [1, 2, 3, 4, 5, 6],bottoms = [6, 5, 4, 3, 2, 1]) == -1\n assert candidate(tops = [5, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 5]) == 0\n assert candidate(tops = [2, 1, 2, 4, 2, 2],bottoms = [5, 2, 6, 2, 3, 2]) == 2\n assert candidate(tops = [1, 2, 1, 1],bottoms = [2, 1, 2, 2]) == 1\n assert candidate(tops = [3, 3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 2]) == 0\n assert candidate(tops = [3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3]) == 0\n assert candidate(tops = [1, 2, 1, 2],bottoms = [2, 1, 2, 1]) == 2\n assert candidate(tops = [1, 1, 2, 2],bottoms = [2, 2, 1, 1]) == 2\n assert candidate(tops = [2, 3, 2, 4, 2],bottoms = [3, 2, 2, 2, 2]) == 1\n assert candidate(tops = [1, 2, 1, 1, 1, 2, 2, 2],bottoms = [2, 1, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(tops = [1, 3, 4, 1, 4, 3, 4, 1, 4, 3],bottoms = [3, 1, 1, 3, 1, 4, 1, 3, 1, 4]) == -1\n assert candidate(tops = [1, 5, 5, 5, 5, 5],bottoms = [5, 5, 1, 5, 5, 5]) == 1\n assert candidate(tops = [1, 1, 2, 2, 1, 1],bottoms = [2, 2, 1, 1, 2, 2]) == 2\n assert candidate(tops = [2, 2, 3, 3, 4, 4, 5, 5],bottoms = [5, 5, 4, 4, 3, 3, 2, 2]) == -1\n assert candidate(tops = [6, 1, 6, 6, 6, 6, 6, 6, 6, 6],bottoms = [1, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 1\n assert candidate(tops = [1, 6, 1, 6, 1, 6],bottoms = [6, 1, 6, 1, 6, 1]) == 3\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],bottoms = [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]) == -1\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],bottoms = [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]) == -1\n assert candidate(tops = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bottoms = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(tops = [1, 1, 2, 2, 3, 3, 4, 4],bottoms = [4, 4, 3, 3, 2, 2, 1, 1]) == -1\n assert candidate(tops = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6],bottoms = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(tops = [3, 3, 3, 4, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(tops = [5, 5, 6, 5, 5, 5, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(tops = [1, 2, 2, 1, 1, 2, 1, 2],bottoms = [2, 1, 1, 2, 2, 1, 2, 1]) == 4\n assert candidate(tops = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(tops = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],bottoms = [6, 6, 6, 6, 6, 6, 6, 6, 6, 5]) == 0\n assert candidate(tops = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bottoms = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(tops = [4, 5, 6, 6, 5, 4],bottoms = [4, 5, 6, 6, 5, 4]) == -1\n assert candidate(tops = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bottoms = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(tops = [5, 5, 5, 5, 5, 1],bottoms = [1, 5, 5, 5, 5, 5]) == 1\n assert candidate(tops = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bottoms = [6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5]) == 0\n assert candidate(tops = [3, 3, 3, 3, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 3, 3, 3, 3]) == 4\n assert candidate(tops = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],bottoms = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4],bottoms = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3]) == -1\n assert candidate(tops = [1, 2, 3, 4, 1, 2],bottoms = [2, 3, 4, 1, 2, 3]) == -1\n assert candidate(tops = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2],bottoms = [2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 7\n assert candidate(tops = [3, 1, 3, 3, 3, 3, 3, 3, 3, 3],bottoms = [3, 3, 1, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(tops = [1, 1, 1, 2, 2, 2, 2, 2],bottoms = [2, 2, 2, 1, 1, 1, 1, 1]) == 3\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],bottoms = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(tops = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],bottoms = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(tops = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(tops = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2],bottoms = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(tops = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],bottoms = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(tops = [3, 6, 3, 3, 3, 3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 3, 3, 3, 3, 6]) == 1\n assert candidate(tops = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1]) == 0\n assert candidate(tops = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],bottoms = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == -1\n assert candidate(tops = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],bottoms = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1]) == 0\n assert candidate(tops = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],bottoms = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 1\n assert candidate(tops = [5, 5, 2, 5, 5, 5],bottoms = [5, 5, 5, 5, 5, 2]) == 1\n assert candidate(tops = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],bottoms = [6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == -1\n assert candidate(tops = [2, 2, 2, 2, 2, 2, 2, 2, 2, 1],bottoms = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(tops = [1, 2, 2, 3, 3, 3],bottoms = [3, 3, 3, 2, 2, 1]) == 3\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4],bottoms = [4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(tops = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],bottoms = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 10\n assert candidate(tops = [5, 6, 5, 5, 6, 5, 6, 5, 6, 5, 5, 6, 5, 5, 5, 5, 5, 6, 5, 5],bottoms = [5, 5, 6, 5, 5, 6, 5, 6, 5, 5, 6, 5, 5, 6, 5, 5, 5, 5, 5, 6]) == 6\n assert candidate(tops = [4, 1, 4, 1, 4, 1, 4, 1, 4, 1],bottoms = [1, 4, 1, 4, 1, 4, 1, 4, 1, 4]) == 5\n assert candidate(tops = [1, 3, 1, 2, 1, 1],bottoms = [2, 1, 2, 1, 2, 2]) == 2\n assert candidate(tops = [5, 5, 5, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(tops = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],bottoms = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(tops = [1, 1, 1, 2, 2, 2, 1, 1, 1],bottoms = [1, 2, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(tops = [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, 1, 1, 1, 1, 1, 1],bottoms = [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\n assert candidate(tops = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],bottoms = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(tops = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],bottoms = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4]) == 0\n assert candidate(tops = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2],bottoms = [2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(tops = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bottoms = [1, 1, 1, 1, 1, 1, 1, 1, 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(tops = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],bottoms = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == -1\n assert candidate(tops = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5],bottoms = [5, 4, 3, 2, 1, 6, 5, 4, 3, 2]) == -1\n assert candidate(tops = [6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5],bottoms = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 10\n assert candidate(tops = [1, 6, 1, 6, 1, 6, 1, 6, 1, 6],bottoms = [6, 1, 6, 1, 6, 1, 6, 1, 6, 1]) == 5\n assert candidate(tops = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(tops = [3, 3, 2, 5, 3, 3, 3, 3, 3, 3],bottoms = [5, 3, 3, 5, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(tops = [2, 2, 2, 2, 2, 2, 2, 2],bottoms = [1, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(tops = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bottoms = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(tops = [5, 5, 5, 5, 5, 1],bottoms = [1, 1, 1, 1, 1, 5]) == 1\n assert candidate(tops = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bottoms = [1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(tops = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],bottoms = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(tops = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5],bottoms = [5, 5, 5, 5, 4, 4, 4, 3, 3, 2, 2, 1]) == -1\n assert candidate(tops = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],bottoms = [1, 1, 2, 2, 3, 3, 4, 4, 4, 4]) == -1\n assert candidate(tops = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(tops = [1, 3, 5, 3, 5, 3, 5, 3, 5, 3],bottoms = [3, 1, 3, 5, 3, 5, 3, 5, 3, 5]) == 5\n assert candidate(tops = [2, 3, 2, 3, 2, 3],bottoms = [3, 2, 3, 2, 3, 2]) == 3\n assert candidate(tops = [1, 2, 3, 1, 2, 3],bottoms = [3, 2, 1, 3, 2, 1]) == -1\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],bottoms = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(tops = [1, 1, 1, 1, 1, 1, 1, 1],bottoms = [1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(tops = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bottoms = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 5\n assert candidate(tops = [1, 1, 1, 2, 2, 2],bottoms = [2, 2, 2, 1, 1, 1]) == 3\n assert candidate(tops = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],bottoms = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(tops = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bottoms = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(tops = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],bottoms = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == -1\n assert candidate(tops = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],bottoms = [4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == -1\n assert candidate(tops = [1, 2, 2, 3, 4, 5, 6],bottoms = [6, 5, 4, 3, 2, 1, 2]) == -1\n assert candidate(tops = [3, 3, 3, 3, 3, 3],bottoms = [3, 3, 3, 3, 3, 3]) == 0\n assert candidate(tops = [2, 3, 4, 2, 3, 4],bottoms = [4, 3, 2, 4, 3, 2]) == -1\n assert candidate(tops = [1, 6, 1, 6, 1, 6, 1, 6],bottoms = [6, 1, 6, 1, 6, 1, 6, 1]) == 4\n assert candidate(tops = [1, 2, 2, 3, 3, 4, 4, 5, 5],bottoms = [5, 5, 4, 4, 3, 3, 2, 2, 1]) == -1\n assert candidate(tops = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],bottoms = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == -1\n", "comparison": "exact"}, "public_tests": ["[2,1,2,4,2,2]\n[5,2,6,2,3,2]", "[3,5,1,2,3]\n[3,6,3,3,4]"], "hints": [], "metadata": {"canonical_parameter_names": ["tops", "bottoms"], "leetcode_dataset_entry_point": "Solution().minDominoRotations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:33+00:00", "tests_total": 112, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minDominoRotations(self, tops: list[int], bottoms: list[int]) -> int:", "container": "Solution", "callable": "minDominoRotations", "parameters": [{"name": "tops", "type": "list[int]"}, {"name": "bottoms", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1009, "task_id": "complement-of-base-10-integer", "difficulty": "Easy", "problem_description": "The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.\n\n- For example, The integer 5 is \"101\" in binary and its complement is \"010\" which is the integer 2.\n\nGiven an integer n, return its complement.\n\nExample 1:\n\nInput: n = 5\nOutput: 2\nExplanation: 5 is \"101\" in binary, with complement \"010\" in binary, which is 2 in base-10.\n\nExample 2:\n\nInput: n = 7\nOutput: 0\nExplanation: 7 is \"111\" in binary, with complement \"000\" in binary, which is 0 in base-10.\n\nExample 3:\n\nInput: n = 10\nOutput: 5\nExplanation: 10 is \"1010\" in binary, with complement \"0101\" in binary, which is 5 in base-10.\n\nConstraints:\n\n- 0 <= n < 10^9\n\nNote: This question is the same as 476: https://leetcode.com/problems/number-complement/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 1\n assert candidate(n = 8) == 7\n assert candidate(n = 100) == 27\n assert candidate(n = 15) == 0\n assert candidate(n = 31) == 0\n assert candidate(n = 123456789) == 10760938\n assert candidate(n = 1) == 0\n assert candidate(n = 7) == 0\n assert candidate(n = 10) == 5\n assert candidate(n = 5) == 2\n assert candidate(n = 123) == 4\n assert candidate(n = 894567890) == 179173933\n assert candidate(n = 890123456) == 183618367\n assert candidate(n = 131071) == 0\n assert candidate(n = 897543210) == 176198613\n assert candidate(n = 67108863) == 0\n assert candidate(n = 67890) == 63181\n assert candidate(n = 32767) == 0\n assert candidate(n = 134217727) == 0\n assert candidate(n = 891011121) == 182730702\n assert candidate(n = 1024) == 1023\n assert candidate(n = 16777215) == 0\n assert candidate(n = 2048) == 2047\n assert candidate(n = 255) == 0\n assert candidate(n = 1023) == 0\n assert candidate(n = 65535) == 0\n assert candidate(n = 987654321) == 86087502\n assert candidate(n = 1048575) == 0\n assert candidate(n = 500000000) == 36870911\n assert candidate(n = 536870911) == 0\n assert candidate(n = 543210987) == 530530836\n assert candidate(n = 33554431) == 0\n assert candidate(n = 54321) == 11214\n", "comparison": "exact"}, "public_tests": ["5", "7", "10"], "hints": ["A binary number plus its complement will equal 111....111 in binary. Also, N = 0 is a corner case."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().bitwiseComplement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:37+00:00", "tests_total": 37, "tests_dropped": 4, "flags": [], "topic_tags": ["bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def bitwiseComplement(self, n: int) -> int:", "container": "Solution", "callable": "bitwiseComplement", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1010, "task_id": "pairs-of-songs-with-total-durations-divisible-by-60", "difficulty": "Medium", "problem_description": "You are given a list of songs where the i^th song has a duration of time[i] seconds.\n\nReturn the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.\n\nExample 1:\n\nInput: time = [30,20,150,100,40]\nOutput: 3\nExplanation: Three pairs have a total duration divisible by 60:\n(time[0] = 30, time[2] = 150): total duration 180\n(time[1] = 20, time[3] = 100): total duration 120\n(time[1] = 20, time[4] = 40): total duration 60\n\nExample 2:\n\nInput: time = [60,60,60]\nOutput: 3\nExplanation: All three pairs have a total duration of 120, which is divisible by 60.\n\nConstraints:\n\n- 1 <= time.length <= 6 * 10^4\n- 1 <= time[i] <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(time = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(time = [40, 20, 50, 30, 10]) == 2\n assert candidate(time = [60, 120, 180, 240, 300]) == 10\n assert candidate(time = [37, 123, 45, 20, 7, 30]) == 0\n assert candidate(time = [30, 60, 90, 120, 150]) == 4\n assert candidate(time = [10, 20, 30, 40, 50]) == 2\n assert candidate(time = [37, 49, 58, 37, 17]) == 0\n assert candidate(time = [60, 60, 60]) == 3\n assert candidate(time = [30, 20, 150, 100, 40]) == 3\n assert candidate(time = [15, 60, 75, 90, 105]) == 2\n assert candidate(time = [5, 10, 15, 20, 25, 30]) == 0\n assert candidate(time = [59, 61, 59, 61, 59, 61]) == 9\n assert candidate(time = [10, 50, 90, 150, 210]) == 4\n assert candidate(time = [59, 1, 59, 2, 59, 3, 59, 4, 59, 5]) == 5\n assert candidate(time = [59, 1, 59, 2, 58, 3, 57, 4, 56, 5, 55, 6, 54, 7, 53, 8, 52, 9, 51, 10, 50]) == 11\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 30\n assert candidate(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, 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]) == 29\n assert candidate(time = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240]) == 28\n assert candidate(time = [1, 119, 2, 118, 3, 117, 4, 116, 5, 115]) == 5\n assert candidate(time = [59, 61, 119, 121, 179, 181, 239, 241, 299, 301]) == 25\n assert candidate(time = [29, 31, 17, 43, 13, 47, 7, 53, 19, 41]) == 5\n assert candidate(time = [40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480]) == 22\n assert candidate(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, 26, 27, 28, 29, 30]) == 0\n assert candidate(time = [5, 15, 25, 35, 45, 55, 105, 115, 125, 135, 145, 155]) == 12\n assert candidate(time = [14, 26, 38, 50, 2, 18, 30, 42, 54, 6]) == 2\n assert candidate(time = [59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59]) == 0\n assert candidate(time = [35, 25, 55, 35, 25, 55, 35, 25, 55, 35, 25, 55, 35, 25, 55, 35, 25, 55, 35, 25, 55, 35, 25, 55, 35, 25, 55]) == 81\n assert candidate(time = [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]) == 70\n assert candidate(time = [35, 25, 55, 15, 45, 5, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 75\n assert candidate(time = [53, 5, 3, 17, 57, 23, 59, 41, 37, 19, 49, 11]) == 4\n assert candidate(time = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165]) == 10\n assert candidate(time = [37, 123, 45, 20, 7, 30, 23, 37, 123, 45, 20, 7, 30, 23, 37, 123, 45, 20, 7, 30]) == 9\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 16\n assert candidate(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, 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]) == 29\n assert candidate(time = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 300]) == 145\n assert candidate(time = [59, 59, 59, 59, 59, 1, 1, 1, 1, 1]) == 25\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 16\n assert candidate(time = [33, 27, 42, 18, 24, 36, 6, 54, 12, 48]) == 5\n assert candidate(time = [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]) == 60\n assert candidate(time = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 9\n assert candidate(time = [1, 59, 2, 58, 3, 57, 4, 56, 5, 55, 6, 54, 7, 53, 8, 52, 9, 51, 10, 50]) == 10\n assert candidate(time = [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]) == 200\n assert candidate(time = [1, 2, 3, 4, 5, 55, 56, 57, 58, 59]) == 5\n assert candidate(time = [1, 61, 2, 62, 3, 63, 4, 64, 5, 65, 6, 66, 7, 67, 8, 68, 9, 69, 10, 70]) == 0\n assert candidate(time = [1, 2, 3, 4, 5, 58, 59, 60, 61, 62, 63, 118, 119, 120, 121, 122, 178, 179, 180, 181, 182]) == 27\n assert candidate(time = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 10\n assert candidate(time = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 36\n assert candidate(time = [58, 59, 1, 2, 57, 56, 3, 4, 55, 54, 5, 6, 53, 52, 7, 8, 51, 50, 9, 10, 49, 48, 11, 12, 47, 46, 13, 14, 45, 44, 15, 16, 43, 42, 17, 18, 41, 40, 19, 20, 39, 38, 21, 22, 37, 36, 23, 24, 35, 34, 25, 26, 33, 32, 27, 28, 31, 30, 29]) == 29\n assert candidate(time = [29, 31, 59, 1, 58, 2, 57, 3, 56, 4, 55, 5, 54, 6, 53, 7, 52, 8, 51, 9, 50, 10, 49, 11, 48, 12, 47, 13, 46, 14, 45, 15, 44, 16, 43, 17, 42, 18, 41, 19, 40, 20, 39, 21, 38, 22, 37, 23, 36, 24, 35, 25, 34, 26, 33, 27, 32, 28]) == 29\n assert candidate(time = [40, 20, 60, 80, 100, 120, 140, 160, 180, 200]) == 15\n assert candidate(time = [1, 2, 3, 4, 5, 58, 59, 60, 61, 62, 118, 119, 120, 121, 122]) == 13\n assert candidate(time = [31, 29, 1, 59, 2, 58, 3, 57, 4, 56, 5, 55, 6, 54, 7, 53, 8, 52, 9, 51]) == 10\n assert candidate(time = [40, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20, 20]) == 36\n assert candidate(time = [59, 1, 59, 1, 59, 1, 59, 1]) == 16\n assert candidate(time = [1, 59, 2, 58, 3, 57, 4, 56, 5, 55, 6, 54, 7, 53]) == 7\n assert candidate(time = [3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93, 102, 111, 120, 129, 138, 147, 156, 165, 174]) == 9\n assert candidate(time = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 45\n assert candidate(time = [11, 22, 33, 44, 55, 11, 22, 33, 44, 55, 11, 22, 33, 44, 55, 11, 22, 33, 44, 55]) == 0\n assert candidate(time = [42, 18, 78, 36, 12, 24, 30, 60, 120, 180]) == 6\n assert candidate(time = [40, 20, 50, 30, 10, 70, 110, 90]) == 6\n assert candidate(time = [51, 9, 42, 18, 27, 33, 6, 54, 12, 48]) == 5\n assert candidate(time = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 0\n assert candidate(time = [61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == 0\n assert candidate(time = [1, 2, 3, 4, 5, 58, 59, 118, 119, 178, 179, 238, 239, 298, 299]) == 10\n assert candidate(time = [45, 90, 135, 180, 225, 270, 315, 360, 405, 450]) == 10\n assert candidate(time = [15, 25, 35, 45, 55, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 19\n assert candidate(time = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == 20\n assert candidate(time = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144]) == 13\n assert candidate(time = [14, 44, 23, 32, 56, 33, 92, 88, 31, 29]) == 3\n assert candidate(time = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360]) == 30\n assert candidate(time = [47, 47, 47, 47, 47, 13, 13, 13, 13, 13]) == 25\n assert candidate(time = [37, 37, 37, 37, 37, 23, 23, 23, 23, 23, 13, 13, 13, 13, 13]) == 25\n assert candidate(time = [37, 123, 45, 20, 7, 30, 60, 120, 180, 240]) == 6\n", "comparison": "exact"}, "public_tests": ["[30,20,150,100,40]", "[60,60,60]"], "hints": ["We only need to consider each song length modulo 60.", "We can count the number of songs having same (length % 60), and store that in an array of size 60."], "metadata": {"canonical_parameter_names": ["time"], "leetcode_dataset_entry_point": "Solution().numPairsDivisibleBy60", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:40+00:00", "tests_total": 89, "tests_dropped": 15, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def numPairsDivisibleBy60(self, time: list[int]) -> int:", "container": "Solution", "callable": "numPairsDivisibleBy60", "parameters": [{"name": "time", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1011, "task_id": "capacity-to-ship-packages-within-d-days", "difficulty": "Medium", "problem_description": "A conveyor belt has packages that must be shipped from one port to another within days days.\n\nThe i^th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.\n\nReturn the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within days days.\n\nExample 1:\n\nInput: weights = [1,2,3,4,5,6,7,8,9,10], days = 5\nOutput: 15\nExplanation: A ship capacity of 15 is the minimum to ship all the packages in 5 days like this:\n1st day: 1, 2, 3, 4, 5\n2nd day: 6, 7\n3rd day: 8\n4th day: 9\n5th day: 10\n\nNote that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed.\n\nExample 2:\n\nInput: weights = [3,2,2,4,1,4], days = 3\nOutput: 6\nExplanation: A ship capacity of 6 is the minimum to ship all the packages in 3 days like this:\n1st day: 3, 2\n2nd day: 2, 4\n3rd day: 1, 4\n\nExample 3:\n\nInput: weights = [1,2,3,1,1], days = 4\nOutput: 3\nExplanation:\n1st day: 1\n2nd day: 2\n3rd day: 3\n4th day: 1, 1\n\nConstraints:\n\n- 1 <= days <= weights.length <= 5 * 10^4\n- 1 <= weights[i] <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(weights = [10, 50, 100, 100, 50, 10],days = 2) == 160\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = 5) == 15\n assert candidate(weights = [10, 50, 100, 100, 50, 10],days = 3) == 160\n assert candidate(weights = [3, 2, 2, 4, 1, 4],days = 3) == 6\n assert candidate(weights = [1, 2, 3, 1, 1],days = 4) == 3\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = 5) == 2\n assert candidate(weights = [5, 5, 5, 5, 5],days = 2) == 15\n assert candidate(weights = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],days = 5) == 83\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],days = 4) == 170\n assert candidate(weights = [4, 3, 2, 5, 8, 2, 3, 5, 6, 1, 2, 4, 3, 7, 5],days = 8) == 10\n assert candidate(weights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],days = 5) == 52\n assert candidate(weights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],days = 6) == 48\n assert candidate(weights = [9, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = 3) == 39\n assert candidate(weights = [450, 450, 450, 450, 450, 450, 450, 450, 450, 450],days = 2) == 2250\n assert candidate(weights = [30, 40, 20, 5, 10, 80, 25, 45, 60, 35, 50, 20, 40, 30, 50, 15],days = 8) == 90\n assert candidate(weights = [300, 300, 300, 300, 300, 300, 300, 300, 300, 300],days = 3) == 1200\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],days = 7) == 23\n assert candidate(weights = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],days = 4) == 850\n assert candidate(weights = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],days = 5) == 1000\n assert candidate(weights = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],days = 5) == 750\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],days = 3) == 210\n assert candidate(weights = [3, 5, 8, 4, 2, 10, 1, 7, 6, 9, 11, 13, 15, 12, 14],days = 6) == 26\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],days = 15) == 7\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],days = 3) == 42\n assert candidate(weights = [1, 5, 9, 14, 20, 25, 30, 35, 40, 45, 50],days = 10) == 50\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],days = 15) == 20\n assert candidate(weights = [30, 50, 20, 40, 60, 10, 90, 80, 70, 100, 120, 130, 110, 140],days = 6) == 240\n assert candidate(weights = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50],days = 4) == 90\n assert candidate(weights = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = 6) == 500\n assert candidate(weights = [5, 10, 20, 30, 25, 40, 15, 10, 5, 30],days = 3) == 65\n assert candidate(weights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],days = 10) == 20\n assert candidate(weights = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100],days = 5) == 500\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],days = 5) == 28\n assert candidate(weights = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],days = 30) == 100\n assert candidate(weights = [47, 2, 20, 7, 2, 19, 23, 30, 6, 12, 9, 4, 30, 26, 8, 7],days = 10) == 47\n assert candidate(weights = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],days = 5) == 30\n assert candidate(weights = [10, 15, 10, 15, 10, 15, 10, 15],days = 6) == 25\n assert candidate(weights = [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],days = 5) == 155\n assert candidate(weights = [1, 2, 3, 100, 200, 300, 100, 200, 300, 1, 2, 3, 100, 200, 300, 100, 200, 300, 1, 2, 3],days = 7) == 500\n assert candidate(weights = [30, 50, 20, 100, 5, 75, 30, 25, 10, 60, 40, 80, 90, 10, 20],days = 7) == 120\n assert candidate(weights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],days = 2) == 28\n assert candidate(weights = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1],days = 5) == 500\n assert candidate(weights = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],days = 2) == 500\n assert candidate(weights = [300, 200, 100, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1, 1, 1],days = 7) == 300\n assert candidate(weights = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],days = 10) == 500\n assert candidate(weights = [10, 5, 1, 7, 8, 12, 4, 7],days = 6) == 12\n assert candidate(weights = [300, 200, 100, 200, 300, 100, 200, 300, 100, 200],days = 4) == 600\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],days = 3) == 420\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = 4) == 57\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],days = 7) == 23\n assert candidate(weights = [4, 3, 5, 6, 8, 10, 3, 1, 5, 6],days = 5) == 13\n assert candidate(weights = [48, 99, 37, 11, 37, 42, 46, 20, 7, 13, 11, 50, 88, 33, 60, 10],days = 7) == 103\n assert candidate(weights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = 3) == 70\n assert candidate(weights = [9, 8, 7, 6, 5, 4, 3, 2, 1],days = 5) == 11\n assert candidate(weights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = 5) == 40\n assert candidate(weights = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = 15) == 10\n assert candidate(weights = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],days = 10) == 3\n assert candidate(weights = [10, 5, 2, 7, 3, 4, 11, 6, 9],days = 4) == 15\n assert candidate(weights = [300, 200, 100, 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],days = 15) == 470\n assert candidate(weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = 20) == 1\n assert candidate(weights = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],days = 10) == 6\n assert candidate(weights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],days = 10) == 15\n assert candidate(weights = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],days = 15) == 100\n assert candidate(weights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],days = 7) == 100\n assert candidate(weights = [25, 47, 42, 77, 72, 46, 42, 44, 63, 59, 51, 55, 53, 91, 93, 95, 97, 99],days = 10) == 149\n assert candidate(weights = [91, 41, 54, 63, 17, 5, 58, 57, 98, 46],days = 10) == 98\n assert candidate(weights = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],days = 5) == 32\n assert candidate(weights = [450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450],days = 15) == 900\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = 10) == 28\n assert candidate(weights = [450, 450, 450, 450, 450, 450, 450, 450, 450, 450],days = 5) == 900\n assert candidate(weights = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],days = 10) == 1000\n assert candidate(weights = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = 10) == 27\n assert candidate(weights = [150, 100, 50, 200, 250, 300, 100, 50, 200, 150],days = 3) == 550\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = 9) == 31\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6,7,8,9,10]\n5", "[3,2,2,4,1,4]\n3", "[1,2,3,1,1]\n4"], "hints": ["Binary search on the answer. We need a function possible(capacity) which returns true if and only if we can do the task in D days."], "metadata": {"canonical_parameter_names": ["weights", "days"], "leetcode_dataset_entry_point": "Solution().shipWithinDays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:42+00:00", "tests_total": 80, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def shipWithinDays(self, weights: list[int], days: int) -> int:", "container": "Solution", "callable": "shipWithinDays", "parameters": [{"name": "weights", "type": "list[int]"}, {"name": "days", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1012, "task_id": "numbers-with-repeated-digits", "difficulty": "Hard", "problem_description": "Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.\n\nExample 1:\n\nInput: n = 20\nOutput: 1\nExplanation: The only positive number (<= 20) with at least 1 repeated digit is 11.\n\nExample 2:\n\nInput: n = 100\nOutput: 10\nExplanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.\n\nExample 3:\n\nInput: n = 1000\nOutput: 262\n\nConstraints:\n\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 99999) == 67509\n assert candidate(n = 999999999) == 994388229\n assert candidate(n = 9999999) == 9287109\n assert candidate(n = 100) == 10\n assert candidate(n = 56789) == 37493\n assert candidate(n = 1000) == 262\n assert candidate(n = 50) == 4\n assert candidate(n = 300) == 66\n assert candidate(n = 10000) == 4726\n assert candidate(n = 101) == 11\n assert candidate(n = 100000) == 67510\n assert candidate(n = 999) == 261\n assert candidate(n = 9999) == 4725\n assert candidate(n = 20) == 1\n assert candidate(n = 1000000000) == 994388230\n assert candidate(n = 987654321) == 982042551\n assert candidate(n = 1234) == 431\n assert candidate(n = 1000000) == 831430\n assert candidate(n = 123456789) == 121064705\n assert candidate(n = 1) == 0\n assert candidate(n = 10) == 0\n assert candidate(n = 222222222) == 219432852\n assert candidate(n = 567890) == 465294\n assert candidate(n = 111111) == 76941\n assert candidate(n = 746384741) == 741672419\n assert candidate(n = 23456) == 14387\n assert candidate(n = 100100100) == 97754250\n assert candidate(n = 234567890) == 231766695\n assert candidate(n = 23456789) == 22516226\n assert candidate(n = 876543210) == 871340553\n assert candidate(n = 101010101) == 98664251\n assert candidate(n = 200000000) == 197291270\n assert candidate(n = 900000000) == 894751110\n assert candidate(n = 10000000) == 9287110\n assert candidate(n = 987654319) == 982042551\n assert candidate(n = 99999999) == 97654149\n assert candidate(n = 314159265) == 311036535\n assert candidate(n = 543210987) == 539235633\n assert candidate(n = 899899) == 746449\n assert candidate(n = 555555555) == 551556585\n assert candidate(n = 271828182) == 268868772\n assert candidate(n = 111111111) == 108724941\n assert candidate(n = 888888888) == 883680318\n assert candidate(n = 11111) == 5501\n assert candidate(n = 987654320) == 982042551\n assert candidate(n = 500000) == 407030\n assert candidate(n = 98765) == 66275\n assert candidate(n = 500000000) == 496202630\n assert candidate(n = 88888888) == 86744638\n assert candidate(n = 1234567) == 1058291\n assert candidate(n = 999999) == 831429\n assert candidate(n = 123456) == 89039\n assert candidate(n = 87654321) == 85513027\n assert candidate(n = 54321) == 35467\n assert candidate(n = 100000000) == 97654150\n", "comparison": "exact"}, "public_tests": ["20", "100", "1000"], "hints": ["How many numbers with no duplicate digits? How many numbers with K digits and no duplicates?", "How many numbers with same length as N? How many numbers with same prefix as N?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numDupDigitsAtMostN", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:44+00:00", "tests_total": 59, "tests_dropped": 4, "flags": [], "topic_tags": ["math", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numDupDigitsAtMostN(self, n: int) -> int:", "container": "Solution", "callable": "numDupDigitsAtMostN", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1013, "task_id": "partition-array-into-three-parts-with-equal-sum", "difficulty": "Easy", "problem_description": "Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums.\n\nFormally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1])\n\nExample 1:\n\nInput: arr = [0,2,1,-6,6,-7,9,1,2,0,1]\nOutput: true\nExplanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1\n\nExample 2:\n\nInput: arr = [0,2,1,-6,6,7,9,-1,2,0,1]\nOutput: false\n\nExample 3:\n\nInput: arr = [3,3,6,5,-2,2,5,1,-9,4]\nOutput: true\nExplanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4\n\nConstraints:\n\n- 3 <= arr.length <= 5 * 10^4\n- -10^4 <= arr[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == False\n assert candidate(arr = [10, -10, 10, -10, 10, -10, 10, -10]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(arr = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [-10000, 10000, -10000, 10000, -10000, 10000]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 3]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n assert candidate(arr = [1, 2, 3, 0, 0, 0, 1, 2, 3]) == False\n assert candidate(arr = [3, 3, 6, 5, -2, 2, 5, 1, -9, 4]) == True\n assert candidate(arr = [0, 2, 1, -6, 6, 7, 9, -1, 2, 0, 1]) == False\n assert candidate(arr = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [0, 2, 1, -6, 6, -7, 9, 1, 2, 0, 1]) == True\n assert candidate(arr = [1, 2, 3, 6, 2, 3, 6, 2, 3, 6]) == False\n assert candidate(arr = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 15]) == False\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(arr = [1, 2, 3, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0]) == False\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\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]) == False\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]) == False\n assert candidate(arr = [3, 6, -3, 6, -6, 3, 6, -3, 6, -6, 3, 6, -3, 6, -6]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -66, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == False\n assert candidate(arr = [-1, -1, -1, 3, 2, 0, 1, 1, -2, -1, 1, 1, 1, 1]) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -15, 5, 10, 15, -30]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, -15, 1, 2, 3, 4, 5, -15, 1, 2, 3, 4, 5]) == False\n assert candidate(arr = [-5, 10, -15, 20, -25, 30, -35, 40, -45, 50, -55, 60, -65, 70, -75]) == False\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, 2, 2, 2, 2, 2, 2, 2]) == False\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, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 6, 0, 0, 6, 3, 2, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -210, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(arr = [3, 6, 5, 2, 2, 5, 1, 2, 2, 3]) == False\n assert candidate(arr = [3, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\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]) == False\n assert candidate(arr = [10, 20, 30, 40, 50, -150, 60, 70, 80, 90, 100]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, -5, -10, -15, 30]) == False\n assert candidate(arr = [100, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50]) == False\n assert candidate(arr = [3, 1, -2, 1, 5, -4, 2, -1, 2, 1, 3, -1, -2, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55, 11, 12, 13, 14]) == False\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == False\n assert candidate(arr = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100]) == True\n assert candidate(arr = [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]) == False\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == True\n assert candidate(arr = [7, 2, 19, 5, 1, 13, 1, 5, 3, 100, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -120, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -210, 21]) == False\n assert candidate(arr = [10, 10, -10, 10, 10, -20, 10, 10, 10, -30, 10, 10, 10, 10, 10]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == True\n assert candidate(arr = [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, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == True\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, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == False\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == False\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == True\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300]) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 55, -11, -12, -13, -14, -15, -16, -17, -18, -19]) == False\n assert candidate(arr = [5, 5, 5, 5, -15, 5, 5, 5, 5, 5, 5, 5, -15, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [100, -50, 50, -25, 25, -12, 12, -6, 6, -3, 3, -1, 1, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(arr = [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]) == False\n assert candidate(arr = [-1, 2, -2, 3, -3, 4, -4, 5, -5, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == False\n assert candidate(arr = [1000, 2000, 3000, -1000, -2000, -3000, 1000, 2000, 3000, -1000, -2000, -3000, 1000, 2000, 3000]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10]) == False\n assert candidate(arr = [7, -5, 3, 2, -4, 4, -1, 0, 1, -2, 1, 2, -3, 3]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -210]) == False\n", "comparison": "exact"}, "public_tests": ["[0,2,1,-6,6,-7,9,1,2,0,1]", "[0,2,1,-6,6,7,9,-1,2,0,1]", "[3,3,6,5,-2,2,5,1,-9,4]"], "hints": ["If we have three parts with the same sum, what is the sum of each? If you can find the first part, can you find the second part?"], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().canThreePartsEqualSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:46+00:00", "tests_total": 77, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def canThreePartsEqualSum(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "canThreePartsEqualSum", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1014, "task_id": "best-sightseeing-pair", "difficulty": "Medium", "problem_description": "You are given an integer array values where values[i] represents the value of the i^th sightseeing spot. Two sightseeing spots i and j have a distance j - i between them.\n\nThe score of a pair (i < j) of sightseeing spots is values[i] + values[j] + i - j: the sum of the values of the sightseeing spots, minus the distance between them.\n\nReturn the maximum score of a pair of sightseeing spots.\n\nExample 1:\n\nInput: values = [8,1,5,2,6]\nOutput: 11\nExplanation: i = 0, j = 2, values[i] + values[j] + i - j = 8 + 5 + 0 - 2 = 11\n\nExample 2:\n\nInput: values = [1,2]\nOutput: 2\n\nConstraints:\n\n- 2 <= values.length <= 5 * 10^4\n- 1 <= values[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1998\n assert candidate(values = [1, 3, 5, 7, 9, 11]) == 19\n assert candidate(values = [10, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 10\n assert candidate(values = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 198\n assert candidate(values = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(values = [8, 1, 5, 2, 6]) == 11\n assert candidate(values = [1000, 1, 1000, 1, 1000]) == 1998\n assert candidate(values = [10, 5, 1, 7, 2]) == 14\n assert candidate(values = [50, 40, 30, 20, 10]) == 89\n assert candidate(values = [3, 7, 2, 5]) == 10\n assert candidate(values = [10, 20, 30, 40, 50]) == 89\n assert candidate(values = [10, 5, 1, 2, 6, 3, 8, 1, 9, 4]) == 15\n assert candidate(values = [5, 5, 5, 5, 5]) == 9\n assert candidate(values = [1, 999, 999, 1, 999, 999, 1, 999, 999, 1]) == 1997\n assert candidate(values = [3, 7, 2, 5, 10]) == 14\n assert candidate(values = [1, 2]) == 2\n assert candidate(values = [1, 1000, 2, 999, 3, 998, 4, 997]) == 1997\n assert candidate(values = [9, 7, 5, 3, 1]) == 15\n assert candidate(values = [9, 4, 3, 2]) == 12\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(values = [5, 3, 5, 7, 1, 9, 2, 6]) == 14\n assert candidate(values = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5]) == 197\n assert candidate(values = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 198\n assert candidate(values = [1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 1998\n assert candidate(values = [1, 999, 2, 998, 3, 997, 4, 996, 5, 995]) == 1995\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 38\n assert candidate(values = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 16\n assert candidate(values = [500, 400, 300, 200, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 899\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 189\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(values = [1, 2, 3, 4, 5, 1000, 6, 7, 8, 9]) == 1005\n assert candidate(values = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == 188\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, 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]) == 98\n assert candidate(values = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 199\n assert candidate(values = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 398\n assert candidate(values = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100, 110, 120]) == 229\n assert candidate(values = [5, 4, 3, 2, 1, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 1998\n assert candidate(values = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1000\n assert candidate(values = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11]) == 28\n assert candidate(values = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == 197\n assert candidate(values = [10, 1, 20, 3, 30, 5, 40, 7, 50, 9, 60, 11, 70, 13, 80]) == 148\n assert candidate(values = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == 1998\n assert candidate(values = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 1996\n assert candidate(values = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 999\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000]) == 1008\n assert candidate(values = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 8\n assert candidate(values = [1, 5, 2, 9, 3, 8, 4, 7, 5, 6, 2, 8, 4, 6, 1, 3, 5, 2, 8, 7, 4, 6, 1, 3, 5, 2, 8, 7, 4, 6]) == 15\n assert candidate(values = [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]) == 1996\n assert candidate(values = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(values = [500, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 991\n assert candidate(values = [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]) == 1996\n assert candidate(values = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 19\n assert candidate(values = [100, 1, 200, 3, 400, 5, 600, 7, 800, 9]) == 1398\n assert candidate(values = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6]) == 1997\n assert candidate(values = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1000\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 389\n assert candidate(values = [500, 10, 300, 20, 500, 10, 300, 20]) == 996\n assert candidate(values = [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]) == 98\n assert candidate(values = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(values = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 100\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(values = [1, 2, 3, 100, 2, 3, 100, 2, 3, 100, 2, 3, 100, 2, 3]) == 197\n assert candidate(values = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 898\n assert candidate(values = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 1999\n assert candidate(values = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5]) == 1995\n assert candidate(values = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1998\n assert candidate(values = [800, 100, 900, 50, 10, 200, 300, 400, 500, 600]) == 1698\n assert candidate(values = [2, 3, 5, 5, 6, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 30\n assert candidate(values = [1, 1000, 1, 999, 1, 998, 1, 997, 1, 996]) == 1997\n assert candidate(values = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 18\n assert candidate(values = [10, 1, 10, 1, 10, 1, 10, 1, 10]) == 18\n assert candidate(values = [5, 5, 5, 5, 5, 5, 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(values = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 1997\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1000]) == 1004\n assert candidate(values = [1, 5, 3, 7, 9, 2, 8, 6, 4, 10]) == 15\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 28\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]) == 48\n assert candidate(values = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520]) == 1038\n assert candidate(values = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50]) == 1899\n assert candidate(values = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 1998\n assert candidate(values = [500, 400, 300, 200, 100, 50, 25, 10, 5, 1]) == 899\n assert candidate(values = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8]) == 1997\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1990\n assert candidate(values = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 1997\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, 1000]) == 1000\n assert candidate(values = [10, 50, 15, 20, 80, 30, 40, 60, 25, 70]) == 145\n assert candidate(values = [800, 900, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 1791\n assert candidate(values = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491]) == 998\n assert candidate(values = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10, 989, 11, 988, 12, 987, 13, 986, 14, 985, 15, 984, 16, 983]) == 1995\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1008\n assert candidate(values = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 1998\n assert candidate(values = [1, 2, 3, 4, 5, 100, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n assert candidate(values = [1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10, 990, 11, 989, 12, 988, 13, 987, 14, 986, 15, 985, 16, 984]) == 1995\n assert candidate(values = [1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000, 7, 1000, 8, 1000, 9, 1000, 10, 1000]) == 1998\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 189\n assert candidate(values = [500, 400, 300, 200, 100, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 899\n assert candidate(values = [500, 1, 500, 1, 500, 1, 500, 1, 500, 1]) == 998\n assert candidate(values = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 99\n assert candidate(values = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(values = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 1998\n", "comparison": "exact"}, "public_tests": ["[8,1,5,2,6]", "[1,2]"], "hints": ["Can you tell the best sightseeing spot in one pass (ie. as you iterate over the input?) What should we store or keep track of as we iterate to do this?"], "metadata": {"canonical_parameter_names": ["values"], "leetcode_dataset_entry_point": "Solution().maxScoreSightseeingPair", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:48+00:00", "tests_total": 106, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maxScoreSightseeingPair(self, values: list[int]) -> int:", "container": "Solution", "callable": "maxScoreSightseeingPair", "parameters": [{"name": "values", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1015, "task_id": "smallest-integer-divisible-by-k", "difficulty": "Medium", "problem_description": "Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1.\n\nReturn the length of n. If there is no such n, return -1.\n\nNote: n may not fit in a 64-bit signed integer.\n\nExample 1:\n\nInput: k = 1\nOutput: 1\nExplanation: The smallest answer is n = 1, which has length 1.\n\nExample 2:\n\nInput: k = 2\nOutput: -1\nExplanation: There is no such positive integer n divisible by 2.\n\nExample 3:\n\nInput: k = 3\nOutput: 3\nExplanation: The smallest answer is n = 111, which has length 3.\n\nConstraints:\n\n- 1 <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 29) == 28\n assert candidate(k = 101) == 4\n assert candidate(k = 83) == 41\n assert candidate(k = 43) == 21\n assert candidate(k = 89) == 44\n assert candidate(k = 17) == 16\n assert candidate(k = 73) == 8\n assert candidate(k = 67) == 33\n assert candidate(k = 53) == 13\n assert candidate(k = 7) == 6\n assert candidate(k = 99) == 18\n assert candidate(k = 31) == 15\n assert candidate(k = 13) == 6\n assert candidate(k = 71) == 35\n assert candidate(k = 2) == -1\n assert candidate(k = 59) == 58\n assert candidate(k = 99999) == 45\n assert candidate(k = 97) == 96\n assert candidate(k = 37) == 3\n assert candidate(k = 61) == 60\n assert candidate(k = 1) == 1\n assert candidate(k = 79) == 13\n assert candidate(k = 103) == 34\n assert candidate(k = 107) == 53\n assert candidate(k = 3) == 3\n assert candidate(k = 9) == 9\n assert candidate(k = 109) == 108\n assert candidate(k = 113) == 112\n assert candidate(k = 23) == 22\n assert candidate(k = 11) == 2\n assert candidate(k = 41) == 5\n assert candidate(k = 100000) == -1\n assert candidate(k = 19) == 18\n assert candidate(k = 47) == 46\n assert candidate(k = 5) == -1\n assert candidate(k = 77777) == 30\n assert candidate(k = 4567) == 4566\n assert candidate(k = 24680) == -1\n assert candidate(k = 999) == 27\n assert candidate(k = 99991) == 49995\n assert candidate(k = 199) == 99\n assert candidate(k = 827) == 413\n assert candidate(k = 81) == 81\n assert candidate(k = 7919) == 3959\n assert candidate(k = 34567) == 2658\n assert candidate(k = 99997) == 7866\n assert candidate(k = 54321) == 8568\n assert candidate(k = 12345) == -1\n assert candidate(k = 57) == 18\n assert candidate(k = 59999) == 29999\n assert candidate(k = 76543) == 25514\n assert candidate(k = 13579) == 366\n assert candidate(k = 89753) == 89752\n assert candidate(k = 123) == 15\n assert candidate(k = 65537) == 65536\n assert candidate(k = 99998) == -1\n assert candidate(k = 89999) == 462\n assert candidate(k = 50003) == 6045\n assert candidate(k = 333) == 9\n assert candidate(k = 88889) == 14654\n assert candidate(k = 1001) == 6\n assert candidate(k = 89765) == -1\n assert candidate(k = 98765) == -1\n assert candidate(k = 313) == 312\n assert candidate(k = 75321) == 37656\n assert candidate(k = 137) == 8\n assert candidate(k = 79999) == 13333\n assert candidate(k = 23456) == -1\n assert candidate(k = 11111) == 5\n assert candidate(k = 997) == 166\n", "comparison": "exact"}, "public_tests": ["1", "2", "3"], "hints": ["11111 = 1111 * 10 + 1 We only need to store remainders modulo K.", "If we never get a remainder of 0, why would that happen, and how would we know that?"], "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().smallestRepunitDivByK", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:51+00:00", "tests_total": 90, "tests_dropped": 20, "flags": [], "topic_tags": ["hash-table", "math", "pigeonhole-principle"]}, "language": "python", "interface": {"raw_signature": "def smallestRepunitDivByK(self, k: int) -> int:", "container": "Solution", "callable": "smallestRepunitDivByK", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1016, "task_id": "binary-string-with-substrings-representing-1-to-n", "difficulty": "Medium", "problem_description": "Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"0110\", n = 3\nOutput: true\n\nExample 2:\n\nInput: s = \"0110\", n = 4\nOutput: false\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s[i] is either '0' or '1'.\n- 1 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"0110\",n = 3) == True\n assert candidate(s = \"1111111111\",n = 10) == False\n assert candidate(s = \"0000000000\",n = 1) == False\n assert candidate(s = \"0110\",n = 4) == False\n assert candidate(s = \"000000\",n = 1) == False\n assert candidate(s = \"101010\",n = 5) == False\n assert candidate(s = \"0000000000\",n = 2) == False\n assert candidate(s = \"110100101101001011010010110100101101001011010010110100101101001011010010110100101101001011010010110100101101001\",n = 200) == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\",n = 20) == False\n assert candidate(s = \"10010010010010010010\",n = 25) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\",n = 1000) == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\",n = 64) == False\n assert candidate(s = \"111000111000111000111000\",n = 8) == False\n assert candidate(s = \"10100101001010010100101001\",n = 10) == False\n assert candidate(s = \"10110100101100101101\",n = 25) == False\n assert candidate(s = \"001001001001001001001001\",n = 9) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",n = 20) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010\",n = 256) == False\n assert candidate(s = \"01010101010101010101\",n = 22) == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\",n = 50) == False\n assert candidate(s = \"1100101001110110100010101100101001110110100010101100\",n = 30) == False\n assert candidate(s = \"111000111000111000\",n = 12) == False\n assert candidate(s = \"01010101010101010101\",n = 15) == False\n assert candidate(s = \"10101010101010101010\",n = 64) == False\n assert candidate(s = \"111100001111000011110000\",n = 50) == False\n assert candidate(s = \"10100101001010010100101001010010100101001\",n = 40) == False\n assert candidate(s = \"11011011011011011011\",n = 25) == False\n assert candidate(s = \"01010101010101010101\",n = 31) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\",n = 25) == False\n assert candidate(s = \"10101010101010101010101010101010\",n = 20) == False\n assert candidate(s = \"00000000000000000000\",n = 1) == False\n assert candidate(s = \"111000111000111000\",n = 15) == False\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111\",n = 15) == False\n assert candidate(s = \"0101010101010101010101\",n = 7) == False\n assert candidate(s = \"1100111100001111111100000000111111111111000000000000\",n = 127) == False\n assert candidate(s = \"10101010101010101010\",n = 15) == False\n assert candidate(s = \"11001100110011001100\",n = 20) == False\n assert candidate(s = \"11001100110011001100110011001100\",n = 9) == False\n assert candidate(s = \"0000111100001111000011110000111100001111000011110000\",n = 15) == False\n assert candidate(s = \"111000011100001110000111000011100001110000111000011100001110000\",n = 150) == False\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\",n = 60) == False\n assert candidate(s = \"10010010010010010010\",n = 16) == False\n assert candidate(s = \"010101010101010101010101010101010101\",n = 30) == False\n assert candidate(s = \"10101010101010101010\",n = 5) == False\n assert candidate(s = \"10010010010010010010\",n = 8) == False\n assert candidate(s = \"01010101010101010101\",n = 5) == False\n assert candidate(s = \"11001100110011001100110011001100\",n = 25) == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",n = 30) == False\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100\",n = 30) == False\n assert candidate(s = \"111000111000111000111000111000111000\",n = 32) == False\n assert candidate(s = \"00000000000000000000000000000000\",n = 8) == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010101010101010\",n = 100) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\",n = 20) == False\n assert candidate(s = \"00000000000000000000\",n = 5) == False\n assert candidate(s = \"11111111111111111111\",n = 1000) == False\n assert candidate(s = \"00011111110000001110\",n = 100) == False\n assert candidate(s = \"11111111111111111111111111111111\",n = 255) == False\n assert candidate(s = \"00001111000011110000\",n = 25) == False\n assert candidate(s = \"101001010010100101001010010100101001010010100101001010010100101001010010100101001010010100101001010010100101001010010100101001010010100101001\",n = 175) == False\n assert candidate(s = \"1111000011110000111100001111000011110000\",n = 50) == False\n assert candidate(s = \"01101101101101101101101101101101\",n = 12) == False\n assert candidate(s = \"1000100010001000100010001000\",n = 35) == False\n assert candidate(s = \"00110011001100110011001100110011\",n = 100) == False\n assert candidate(s = \"11111111111111111111111111111111\",n = 100) == False\n assert candidate(s = \"11011011011011011011\",n = 150) == False\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\",n = 1) == False\n assert candidate(s = \"11011011011011011011\",n = 30) == False\n assert candidate(s = \"00110011001100110011\",n = 16) == False\n assert candidate(s = \"10000000000000000000\",n = 5) == False\n assert candidate(s = \"0001111000111100011110001111\",n = 16) == False\n assert candidate(s = \"11100011100011100011\",n = 7) == False\n assert candidate(s = \"10101010101010101010101010101010\",n = 50) == False\n assert candidate(s = \"10011001100110011001100110011001\",n = 18) == False\n assert candidate(s = \"10101010101010101010101010101010\",n = 100) == False\n assert candidate(s = \"111100001111000011110000\",n = 15) == False\n assert candidate(s = \"0100100100100100100100100100100100100100100100100100\",n = 200) == False\n assert candidate(s = \"1101110101001101010011010100110101001101010011010100\",n = 50) == False\n assert candidate(s = \"001001001001001001001001001001001001001\",n = 35) == False\n assert candidate(s = \"11001100110011001100\",n = 6) == False\n assert candidate(s = \"11110000111100001111\",n = 20) == False\n assert candidate(s = \"00101010100101010100101010100101010100101010100101010100101010100101010100101010100101010100101010100101010100101010100101010\",n = 125) == False\n assert candidate(s = \"00001111000011110000\",n = 50) == False\n assert candidate(s = \"11011011011011011011\",n = 10) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",n = 5) == False\n assert candidate(s = \"01001001001001001001001001\",n = 20) == False\n assert candidate(s = \"11100001110000111000011100001110000111000011100001110000\",n = 100) == False\n assert candidate(s = \"00000000000000000000000000000000\",n = 1) == False\n assert candidate(s = \"01010101010101010101\",n = 30) == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\",n = 25) == False\n assert candidate(s = \"10101010101010101010\",n = 20) == False\n assert candidate(s = \"11110000111100001111\",n = 30) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010\",n = 75) == False\n assert candidate(s = \"0110011001100110011001100110011001100110011001100110\",n = 63) == False\n assert candidate(s = \"0011001100110011001100110011001100110011001100110011\",n = 128) == False\n assert candidate(s = \"11110000111100001111\",n = 125) == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010101010\",n = 50) == False\n", "comparison": "exact"}, "public_tests": ["\"0110\"\n3", "\"0110\"\n4"], "hints": ["We only need to check substrings of length at most 30, because 10^9 has 30 bits."], "metadata": {"canonical_parameter_names": ["s", "n"], "leetcode_dataset_entry_point": "Solution().queryString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:53+00:00", "tests_total": 96, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def queryString(self, s: str, n: int) -> bool:", "container": "Solution", "callable": "queryString", "parameters": [{"name": "s", "type": "str"}, {"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1017, "task_id": "convert-to-base-2", "difficulty": "Medium", "problem_description": "Given an integer n, return a binary string representing its representation in base -2.\n\nNote that the returned string should not have leading zeros unless the string is \"0\".\n\nExample 1:\n\nInput: n = 2\nOutput: \"110\"\nExplantion: (-2)^2 + (-2)^1 = 2\n\nExample 2:\n\nInput: n = 3\nOutput: \"111\"\nExplantion: (-2)^2 + (-2)^1 + (-2)^0 = 3\n\nExample 3:\n\nInput: n = 4\nOutput: \"100\"\nExplantion: (-2)^2 = 4\n\nConstraints:\n\n- 0 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == \"111\"\n assert candidate(n = 104730) == \"1101110100101101110\"\n assert candidate(n = 100) == \"110100100\"\n assert candidate(n = 1000) == \"10000111000\"\n assert candidate(n = 5) == \"101\"\n assert candidate(n = 4) == \"100\"\n assert candidate(n = 16) == \"10000\"\n assert candidate(n = 10000) == \"111101100010000\"\n assert candidate(n = 2) == \"110\"\n assert candidate(n = 1024) == \"10000000000\"\n assert candidate(n = 0) == \"0\"\n assert candidate(n = 8) == \"11000\"\n assert candidate(n = 1023) == \"10000000011\"\n assert candidate(n = 1000000000) == \"1001100111011111101111000000000\"\n assert candidate(n = 104729) == \"1101110100101101001\"\n assert candidate(n = 15) == \"10011\"\n assert candidate(n = 9) == \"11001\"\n assert candidate(n = 6) == \"11010\"\n assert candidate(n = 1) == \"1\"\n assert candidate(n = 7) == \"11011\"\n assert candidate(n = 10) == \"11110\"\n assert candidate(n = 999999992) == \"1001100111011111101111000001000\"\n assert candidate(n = 999999999) == \"1001100111011111101111000000011\"\n assert candidate(n = 999999996) == \"1001100111011111101111000001100\"\n assert candidate(n = 32767) == \"11000000000000011\"\n assert candidate(n = 511) == \"11000000011\"\n assert candidate(n = 536870912) == \"1100000000000000000000000000000\"\n assert candidate(n = 524288) == \"110000000000000000000\"\n assert candidate(n = 2047) == \"1100000000011\"\n assert candidate(n = 16383) == \"100000000000011\"\n assert candidate(n = 999999998) == \"1001100111011111101111000000010\"\n assert candidate(n = 134217728) == \"11000000000000000000000000000\"\n assert candidate(n = 800000000) == \"1110000111100110001100000000000\"\n assert candidate(n = 333333333) == \"10100001000100100011101010101\"\n assert candidate(n = 4095) == \"1000000000011\"\n assert candidate(n = 999999995) == \"1001100111011111101111000001111\"\n assert candidate(n = 999999994) == \"1001100111011111101111000001110\"\n assert candidate(n = 999999991) == \"1001100111011111101111000001011\"\n assert candidate(n = 1048576) == \"100000000000000000000\"\n assert candidate(n = 8192) == \"110000000000000\"\n assert candidate(n = 255) == \"100000011\"\n assert candidate(n = 8191) == \"110000000000011\"\n assert candidate(n = 65536) == \"10000000000000000\"\n assert candidate(n = 262144) == \"1000000000000000000\"\n assert candidate(n = 65535) == \"10000000000000011\"\n assert candidate(n = 131072) == \"1100000000000000000\"\n assert candidate(n = 127) == \"110000011\"\n assert candidate(n = 999999993) == \"1001100111011111101111000001001\"\n assert candidate(n = 987654321) == \"1001111001000111011100111110001\"\n assert candidate(n = 894752631) == \"1110101010101010010100010001011\"\n assert candidate(n = 897410135) == \"1001010100000101010010110101011\"\n assert candidate(n = 500000) == \"110001110000101100000\"\n assert candidate(n = 32768) == \"11000000000000000\"\n assert candidate(n = 999999997) == \"1001100111011111101111000001101\"\n assert candidate(n = 1048575) == \"100000000000000000011\"\n assert candidate(n = 500000000) == \"1100010110100101010010100000000\"\n assert candidate(n = 31) == \"1100011\"\n assert candidate(n = 1000000) == \"100110100011001000000\"\n assert candidate(n = 123456789) == \"11000101011001101110100010101\"\n assert candidate(n = 999999) == \"100110100011001000011\"\n assert candidate(n = 531441) == \"110000110110000110001\"\n", "comparison": "exact"}, "public_tests": ["2", "3", "4"], "hints": ["Figure out whether you need the ones digit placed or not, then shift by two."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().baseNeg2", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:55+00:00", "tests_total": 69, "tests_dropped": 8, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def baseNeg2(self, n: int) -> str:", "container": "Solution", "callable": "baseNeg2", "parameters": [{"name": "n", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1018, "task_id": "binary-prefix-divisible-by-5", "difficulty": "Easy", "problem_description": "You are given a binary array nums (0-indexed).\n\nWe define x_i as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-bit).\n\n- For example, if nums = [1,0,1], then x_0 = 1, x_1 = 2, and x_2 = 5.\n\nReturn an array of booleans answer where answer[i] is true if x_i is divisible by 5.\n\nExample 1:\n\nInput: nums = [0,1,1]\nOutput: [true,false,false]\nExplanation: The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10.\nOnly the first number is divisible by 5, so answer[0] is true.\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: [false,false,false]\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- nums[i] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == [False]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [True, False, False, True, True, False, False, True, True, False]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [False, False, False, True, False, False, False, True, False, False]\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0]) == [False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [False, False, False, False, True, False, False, False, False, False]\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == [False, False, True, True, False, False]\n assert candidate(nums = [1, 1, 1]) == [False, False, False]\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == [False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False]\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [False, False, True, True, False, False, True, True, False, False]\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0]) == [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [True, True, True, True, True]\n assert candidate(nums = [0, 1, 1]) == [True, False, 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]) == [False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False]\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1]) == [False, False, False, False, False, False, False, False, False, True, False, False, True, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, True, False]\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, 0, 1, 0, 1, 0, 1, 0]) == [False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False]\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == [True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False]\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]) == [False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False]\n assert candidate(nums = [1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1]) == [False, False, True, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, True, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, True, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, True, False, False]\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1]) == [True, False, False, False, False, False, False, False, False, False, True, False, False, True, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [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, 1, 1, 0, 1, 0, 1]) == [False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False]\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]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\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]) == [False, False, False, True, True, True, True, True, False, False, False, True, True, True, True, True, False, False, False, True, True, True, True, True, False, False, False, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False]\n assert candidate(nums = [1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1]) == [True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False]\n assert candidate(nums = [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]) == [False, False, True, False, False, True, False, False, True, False, False, True, False, False, True, False, False, True, False, False, True, False, False, True, False, False, True, False, False, True]\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]) == [True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, 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]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1]) == [False, False, False, False, False, False, False, False, False, True, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False]\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]) == [False, False, False, True, True, True, True, True, False, False, False, True, True, True, True, True, False, False, False, True, True, True, True, True, False, False, False, True, True, True, True]\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]) == [False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True]\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, 1, 0, 0, 1, 1, 0, 0, 1]) == [False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False]\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]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == [False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False]\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]) == [False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False]\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]) == [True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False, False, False]\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 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]) == [False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False]\n assert candidate(nums = [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, 0, 0]) == [True, False, False, False, True, True, True, True, True, False, False, False, True, True, True, True, True, False, False, False, True, True, True, True, True, False, False, False, True, True, True]\n assert candidate(nums = [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]) == [False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False]\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1]) == [False, False, False, False, False, False, True, True, False, False, False, False, False, False, True, True, True, False, False, False, False, True, True, False, False, False, False, False, False, False]\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == [True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False]\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == [False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False]\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == [False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, 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]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == [False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False]\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]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True]\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False]\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]) == [True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False]\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, 1]) == [False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False]\n assert candidate(nums = [1, 0, 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, 1, 1, 0, 1]) == [False, False, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, True, True, False, False, False, False]\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]) == [True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False]\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]) == [False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True]\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, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False]\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]) == [False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False]\n assert candidate(nums = [0, 0, 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, 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, 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, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0]) == [True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, True, False, False, True, True, False, False, False, False, False]\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == [False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True]\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]) == [False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False]\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]) == [False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False, False, False]\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]) == [False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True]\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]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [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]) == [True, True, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False]\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]) == [True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False, True, True, False, False]\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [True, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, False, False, False]\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]) == [False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, True, False, False, False, 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]) == [False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False]\n", "comparison": "exact"}, "public_tests": ["[0,1,1]", "[1,1,1]"], "hints": ["If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().prefixesDivBy5", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:07:57+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def prefixesDivBy5(self, nums: list[int]) -> list[bool]:", "container": "Solution", "callable": "prefixesDivBy5", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1020, "task_id": "number-of-enclaves", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell.\n\nA move consists of walking from one land cell to another adjacent (4-directionally) land cell or walking off the boundary of the grid.\n\nReturn the number of land cells in grid for which we cannot walk off the boundary of the grid in any number of moves.\n\nExample 1:\n\nInput: grid = [[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]\nOutput: 3\nExplanation: There are three 1s that are enclosed by 0s, and one 1 that is not enclosed because its on the boundary.\n\nExample 2:\n\nInput: grid = [[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]\nOutput: 0\nExplanation: All 1s are either on the boundary or can reach the boundary.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 500\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) == 0\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]]) == 8\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, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0], [0, 0, 1, 0], [0, 1, 1, 0], [0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 1], [1, 0, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1], [1, 1, 0, 0, 0, 1], [0, 1, 1, 1, 1, 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, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 20\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]]) == 8\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 1, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 1, 0]]) == 17\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 10\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], [0, 1, 0, 1, 0, 0]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0]]) == 7\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, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 1]]) == 14\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 0, 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]]) == 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]]) == 36\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 17\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0, 1, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 20\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], [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]]) == 18\n assert candidate(grid = [[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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 6\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]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == 4\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, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 55\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, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 0\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, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 36\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[1, 1, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 30\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0, 0, 0, 1, 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], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [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, 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, 1, 0, 0, 0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[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, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 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, 0]]) == 33\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 1, 1, 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, 1, 0, 1, 0, 1], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == 5\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 3\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]]) == 17\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 1, 0, 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], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid = [[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, 0, 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, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 0, 1, 1, 1]]) == 14\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 15\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]]) == 6\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1, 1, 0, 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]]) == 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, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 25\n assert candidate(grid = [[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, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 1, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 36\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 21\n assert candidate(grid = [[1, 0, 1, 1, 1, 0, 1, 0, 1, 1], [0, 0, 1, 0, 0, 1, 0, 1, 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, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 7\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, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 32\n", "comparison": "exact"}, "public_tests": ["[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]", "[[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]"], "hints": ["Can you model this problem as a graph problem? Create n * m + 1 nodes where n * m nodes represents each cell of the map and one extra node to represent the exterior of the map.", "In the map add edges between neighbors on land cells. And add edges between the exterior and land nodes which are in the boundary. Return as answer the number of nodes that are not reachable from the exterior node."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().numEnclaves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:01+00:00", "tests_total": 67, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def numEnclaves(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "numEnclaves", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1021, "task_id": "remove-outermost-parentheses", "difficulty": "Easy", "problem_description": "A valid parentheses string is either empty \"\", \"(\" + A + \")\", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.\n\n- For example, \"\", \"()\", \"(())()\", and \"(()(()))\" are all valid parentheses strings.\n\nA valid parentheses string s is primitive if it is nonempty, and there does not exist a way to split it into s = A + B, with A and B nonempty valid parentheses strings.\n\nGiven a valid parentheses string s, consider its primitive decomposition: s = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings.\n\nReturn s after removing the outermost parentheses of every primitive string in the primitive decomposition of s.\n\nExample 1:\n\nInput: s = \"(()())(())\"\nOutput: \"()()()\"\nExplanation:\nThe input string is \"(()())(())\", with primitive decomposition \"(()())\" + \"(())\".\nAfter removing outer parentheses of each part, this is \"()()\" + \"()\" = \"()()()\".\n\nExample 2:\n\nInput: s = \"(()())(())(()(()))\"\nOutput: \"()()()()(())\"\nExplanation:\nThe input string is \"(()())(())(()(()))\", with primitive decomposition \"(()())\" + \"(())\" + \"(()(()))\".\nAfter removing outer parentheses of each part, this is \"()()\" + \"()\" + \"()(())\" = \"()()()()(())\".\n\nExample 3:\n\nInput: s = \"()()\"\nOutput: \"\"\nExplanation:\nThe input string is \"()()\", with primitive decomposition \"()\" + \"()\".\nAfter removing outer parentheses of each part, this is \"\" + \"\" = \"\".\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is either '(' or ')'.\n- s is a valid parentheses string.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()(()))()\") == \"()(())\"\n assert candidate(s = \"()\") == \"\"\n assert candidate(s = \"()(()())\") == \"()()\"\n assert candidate(s = \"(()())(())\") == \"()()()\"\n assert candidate(s = \"((()))\") == \"(())\"\n assert candidate(s = \"()()\") == \"\"\n assert candidate(s = \"(())(())\") == \"()()\"\n assert candidate(s = \"(())\") == \"()\"\n assert candidate(s = \"((())())\") == \"(())()\"\n assert candidate(s = \"(()(()))(()(()))\") == \"()(())()(())\"\n assert candidate(s = \"(()())(())(()(()))\") == \"()()()()(())\"\n assert candidate(s = \"((()))()(())((()))\") == \"(())()(())\"\n assert candidate(s = \"((()))()(())\") == \"(())()\"\n assert candidate(s = \"()(())((()))()(())\") == \"()(())()\"\n assert candidate(s = \"(())(())(())(())\") == \"()()()()\"\n assert candidate(s = \"(()(()(()(()(())))))\") == \"()(()(()(()(()))))\"\n assert candidate(s = \"()(()())(())()()\") == \"()()()\"\n assert candidate(s = \"(())()((()))(())\") == \"()(())()\"\n assert candidate(s = \"(()())(()(()))(()(()))\") == \"()()()(())()(())\"\n assert candidate(s = \"(()())()(()())\") == \"()()()()\"\n assert candidate(s = \"()(()(()))\") == \"()(())\"\n assert candidate(s = \"(((()())))\") == \"((()()))\"\n assert candidate(s = \"((())()(()))\") == \"(())()(())\"\n assert candidate(s = \"(((((())))))\") == \"((((()))))\"\n assert candidate(s = \"((())((())))\") == \"(())((()))\"\n assert candidate(s = \"(()()())\") == \"()()()\"\n assert candidate(s = \"((((())())()))\") == \"(((())())())\"\n assert candidate(s = \"((())(()))((()))\") == \"(())(())(())\"\n assert candidate(s = \"((()()(())))\") == \"(()()(()))\"\n assert candidate(s = \"(()())(()())(()())\") == \"()()()()()()\"\n assert candidate(s = \"((()))(())((()))\") == \"(())()(())\"\n assert candidate(s = \"()(())((()()))\") == \"()(()())\"\n assert candidate(s = \"()(())(())(())\") == \"()()()\"\n assert candidate(s = \"()()()()()\") == \"\"\n assert candidate(s = \"()(()(()))()((()))\") == \"()(())(())\"\n assert candidate(s = \"((())())(()(()(())))\") == \"(())()()(()(()))\"\n assert candidate(s = \"(()(()(()(()))))\") == \"()(()(()(())))\"\n assert candidate(s = \"((()))(())(()())\") == \"(())()()()\"\n assert candidate(s = \"((()()()()))\") == \"(()()()())\"\n assert candidate(s = \"((()()))(()(()))\") == \"(()())()(())\"\n assert candidate(s = \"()(()(()))((()))\") == \"()(())(())\"\n assert candidate(s = \"(()(()))(()(()))()()\") == \"()(())()(())\"\n assert candidate(s = \"(((()))(()(()(()))))\") == \"((()))(()(()(())))\"\n assert candidate(s = \"((()))((())())(()())\") == \"(())(())()()()\"\n assert candidate(s = \"(((()))(()(())))\") == \"((()))(()(()))\"\n assert candidate(s = \"((()))((()))((()))\") == \"(())(())(())\"\n assert candidate(s = \"(())()((()))\") == \"()(())\"\n assert candidate(s = \"((()))(())()(()())\") == \"(())()()()\"\n assert candidate(s = \"(()(()(()(()(()())))))\") == \"()(()(()(()(()()))))\"\n assert candidate(s = \"((()))((()))\") == \"(())(())\"\n assert candidate(s = \"(()(()))()((())())\") == \"()(())(())()\"\n assert candidate(s = \"(()(()(()(()))))(()(()(())))\") == \"()(()(()(())))()(()(()))\"\n assert candidate(s = \"((()))(())(())\") == \"(())()()\"\n assert candidate(s = \"(((())()))((()))\") == \"((())())(())\"\n assert candidate(s = \"(((()))())((()))\") == \"((()))()(())\"\n assert candidate(s = \"()()()()\") == \"\"\n assert candidate(s = \"(()(()(()())))\") == \"()(()(()()))\"\n assert candidate(s = \"(()(()(())))\") == \"()(()(()))\"\n assert candidate(s = \"((())(()))(()(()))\") == \"(())(())()(())\"\n assert candidate(s = \"((())()())((()()))\") == \"(())()()(()())\"\n assert candidate(s = \"(())()(())(())()\") == \"()()()\"\n assert candidate(s = \"((()()))(()(()(()())))\") == \"(()())()(()(()()))\"\n assert candidate(s = \"((((()())))((())))\") == \"(((()())))((()))\"\n assert candidate(s = \"((()())(()))\") == \"(()())(())\"\n assert candidate(s = \"(()())(()(()))(()(()(())))\") == \"()()()(())()(()(()))\"\n assert candidate(s = \"((()))(()(()))((()))\") == \"(())()(())(())\"\n assert candidate(s = \"((()()))(())(()(()))\") == \"(()())()()(())\"\n assert candidate(s = \"()(()(()(()())))\") == \"()(()(()()))\"\n assert candidate(s = \"()()(((())))()\") == \"((()))\"\n assert candidate(s = \"(((())))\") == \"((()))\"\n assert candidate(s = \"(()((()))(())())\") == \"()((()))(())()\"\n assert candidate(s = \"(())(())(())\") == \"()()()\"\n assert candidate(s = \"(()((())))\") == \"()((()))\"\n assert candidate(s = \"((())(()(()())))((()))\") == \"(())(()(()()))(())\"\n assert candidate(s = \"((())())(())\") == \"(())()()\"\n assert candidate(s = \"()((()))()(())\") == \"(())()\"\n assert candidate(s = \"(()(()(()(()))))(()(()(()(()(()))))(()(()(()(()))))\") == \"()(()(()(())))()(()(()(()(()))))(()(()(()(()))))\"\n assert candidate(s = \"()(()(()(())))()\") == \"()(()(()))\"\n assert candidate(s = \"()((())(()))()()\") == \"(())(())\"\n assert candidate(s = \"((()()())())\") == \"(()()())()\"\n assert candidate(s = \"()(()(()))()(()())\") == \"()(())()()\"\n assert candidate(s = \"((()))(((()())))\") == \"(())((()()))\"\n assert candidate(s = \"((()))(()(()))\") == \"(())()(())\"\n assert candidate(s = \"()()()()()()()()\") == \"\"\n assert candidate(s = \"((())(()))\") == \"(())(())\"\n assert candidate(s = \"(()())((()))()\") == \"()()(())\"\n assert candidate(s = \"(())(()(()))()\") == \"()()(())\"\n assert candidate(s = \"((())())(()(()))\") == \"(())()()(())\"\n assert candidate(s = \"(()(()))(()(()))(()(()))\") == \"()(())()(())()(())\"\n assert candidate(s = \"(((()))(()))\") == \"((()))(())\"\n assert candidate(s = \"()()()()()()\") == \"\"\n assert candidate(s = \"(()(()())(()))\") == \"()(()())(())\"\n assert candidate(s = \"((()())(()()))\") == \"(()())(()())\"\n assert candidate(s = \"((()))(()(()))(()(()))\") == \"(())()(())()(())\"\n assert candidate(s = \"((()((()))))\") == \"(()((())))\"\n assert candidate(s = \"(((())))(((())))\") == \"((()))((()))\"\n assert candidate(s = \"((((()))))\") == \"(((())))\"\n assert candidate(s = \"(()(()))((())(()(()())))\") == \"()(())(())(()(()()))\"\n assert candidate(s = \"(()())(())(()(()))(()(()))\") == \"()()()()(())()(())\"\n assert candidate(s = \"((())())((()))\") == \"(())()(())\"\n assert candidate(s = \"()(()())(()(()))(()(()))\") == \"()()()(())()(())\"\n assert candidate(s = \"((()(()))(()))\") == \"(()(()))(())\"\n", "comparison": "exact"}, "public_tests": ["\"(()())(())\"", "\"(()())(())(()(()))\"", "\"()()\""], "hints": ["Can you find the primitive decomposition? The number of ( and ) characters must be equal."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removeOuterParentheses", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:04+00:00", "tests_total": 103, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "stack", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def removeOuterParentheses(self, s: str) -> str:", "container": "Solution", "callable": "removeOuterParentheses", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1023, "task_id": "camelcase-matching", "difficulty": "Medium", "problem_description": "Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.\n\nA query word queries[i] matches pattern if you can insert lowercase English letters into the pattern so that it equals the query. You may insert a character at any position in pattern or you may choose not to insert any characters at all.\n\nExample 1:\n\nInput: queries = [\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"], pattern = \"FB\"\nOutput: [true,false,true,true,false]\nExplanation: \"FooBar\" can be generated like this \"F\" + \"oo\" + \"B\" + \"ar\".\n\"FootBall\" can be generated like this \"F\" + \"oot\" + \"B\" + \"all\".\n\"FrameBuffer\" can be generated like this \"F\" + \"rame\" + \"B\" + \"uffer\".\n\nExample 2:\n\nInput: queries = [\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"], pattern = \"FoBa\"\nOutput: [true,false,true,false,false]\nExplanation: \"FooBar\" can be generated like this \"Fo\" + \"o\" + \"Ba\" + \"r\".\n\"FootBall\" can be generated like this \"Fo\" + \"ot\" + \"Ba\" + \"ll\".\n\nExample 3:\n\nInput: queries = [\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"], pattern = \"FoBaT\"\nOutput: [false,true,false,false,false]\nExplanation: \"FooBarTest\" can be generated like this \"Fo\" + \"o\" + \"Ba\" + \"r\" + \"T\" + \"est\".\n\nConstraints:\n\n- 1 <= pattern.length, queries.length <= 100\n- 1 <= queries[i].length <= 100\n- queries[i] and pattern consist of English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = ['FooBar', 'FooBarTest', 'FootBall', 'FrameBuffer', 'ForceFeedBack'],pattern = \"FB\") == [True, False, True, True, False]\n assert candidate(queries = ['FooBar', 'FooBarTest', 'FootBall', 'FrameBuffer', 'ForceFeedBack'],pattern = \"FoBa\") == [True, False, True, False, False]\n assert candidate(queries = ['FooBar', 'FooBarTest', 'FootBall', 'FrameBuffer', 'ForceFeedBack'],pattern = \"FoBaT\") == [False, True, False, False, False]\n assert candidate(queries = ['Interleaving', 'InTerLeaVing', 'InterLeaving', 'InterLEAVING'],pattern = \"InLeV\") == [False, False, False, False]\n assert candidate(queries = ['MixedCASE', 'MxCs', 'MxCASE', 'MixCsE', 'MxCsECASE'],pattern = \"MxCsE\") == [False, False, False, True, False]\n assert candidate(queries = ['AaAaAaAaAa', 'aAaAaAaAa', 'AaAaAaA', 'AaAa', 'Aa'],pattern = \"Aa\") == [False, False, False, False, True]\n assert candidate(queries = ['samePattern', 'samePatternEverywhere', 'same', 'pattern'],pattern = \"sP\") == [True, False, False, False]\n assert candidate(queries = ['ComplexPattern', 'CompPat', 'ComplexPatt', 'ComplPtn', 'CompPattn'],pattern = \"CompPtn\") == [True, False, False, True, True]\n assert candidate(queries = ['SoftwareEngineering', 'softwareENGINEERING', 'SoftWaReEnGiNeErInG', 'SOFTWAREENGINEERING'],pattern = \"SWE\") == [False, False, False, False]\n assert candidate(queries = ['PatternMatching', 'Pattern', 'Pat', 'PatMatch', 'PatternMatchInString'],pattern = \"Pat\") == [False, True, True, False, False]\n assert candidate(queries = ['xYzAbCdEfG', 'xYzAbCdEfGhI', 'xYzAbCd', 'xYzAbCdEfGhIjK', 'xYzAbCdEfGhIjKlM'],pattern = \"xYzAbCd\") == [False, False, True, False, False]\n assert candidate(queries = ['ComplexPattern', 'ComplexPatternQuery', 'ComplexPatternMatch', 'ComplexPatternMismatch', 'ComplexPatternCase'],pattern = \"CPM\") == [False, False, True, True, False]\n assert candidate(queries = ['ComplexPatternMatching', 'ComplexPattern', 'ComplexMatch', 'PatternMatching', 'PatternMatch'],pattern = \"CPM\") == [True, False, False, False, False]\n assert candidate(queries = ['Java', 'JavaScript', 'JavaS', 'JavaScr', 'JavaScriptAndMore'],pattern = \"JS\") == [False, True, True, True, False]\n assert candidate(queries = ['CamelCase', 'CamelCasePattern', 'Camel', 'Case'],pattern = \"CCP\") == [False, True, False, False]\n assert candidate(queries = ['MultipleUpperCaseLetters', 'MultipleLowerCaseLetters', 'MixOfUpperAndLowerCase', 'OnlyUpperCase', 'OnlyLowerCase'],pattern = \"MUCL\") == [True, False, False, False, False]\n assert candidate(queries = ['LongPatternMatchingExample', 'LongPattern', 'Long', 'LongPatternExample', 'LongPatternMatchingExampleInPython'],pattern = \"Long\") == [False, False, True, False, False]\n assert candidate(queries = ['CamelHump', 'CamelHumpQuery', 'CamelHouse', 'CamelHousekeeping', 'CamelHorseRace'],pattern = \"CH\") == [True, False, True, True, False]\n assert candidate(queries = ['EdgeCase', 'EdgeCaseQuery', 'EdgeCaseMatch', 'EdgeCaseMismatch', 'EdgeCaseCase'],pattern = \"ECMc\") == [False, False, True, True, False]\n assert candidate(queries = ['ABcDeFgHiJkLmNoPqRsTuVwXyZ', 'abcdefgHIJKLmnopQRstUVwxYZ', 'AbCdEfGhIjKlMnOpQrStUvWxYz'],pattern = \"AbCdEfG\") == [False, False, False]\n assert candidate(queries = ['MixedCasePattern', 'Mixed', 'Case', 'Pattern', 'MixedPatternCase'],pattern = \"Mix\") == [False, True, False, False, False]\n assert candidate(queries = ['ExamplePattern', 'Ex', 'ExPat', 'Example', 'PatternExample'],pattern = \"Ex\") == [False, True, False, True, False]\n assert candidate(queries = ['DeepLearning', 'deepLEARNING', 'DeEpLeArNiNg', 'DEEPLEARNING'],pattern = \"DL\") == [True, False, False, False]\n assert candidate(queries = ['veryComplexPattern', 'veryComplexPat', 'veryComp', 'very'],pattern = \"vCP\") == [True, True, False, False]\n assert candidate(queries = ['ComplexPatternMatching', 'Complex', 'Pat', 'ComplexPat', 'PatternComplex'],pattern = \"Com\") == [False, True, False, False, False]\n assert candidate(queries = ['aAaAaAaA', 'AAAAAAAA', 'aAaAaAa', 'AaAaAaAaAaAaAaAa', 'aAaAaAaAaAaAaAaAa', 'AaAaAaAaAaAaAaAaAaAa', 'AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa'],pattern = \"aAaAaAaA\") == [True, False, False, False, False, False, False]\n assert candidate(queries = ['CamelCase', 'camelCase', 'Camelcase', 'camelCASE'],pattern = \"Camel\") == [False, False, True, False]\n assert candidate(queries = ['CamelCaseExample', 'CamelCase', 'CamelExample', 'ExampleCamel', 'Camel'],pattern = \"CamEx\") == [False, False, True, False, False]\n assert candidate(queries = ['CamelCase', 'Camel', 'CamelCasePattern', 'CamelPattern', 'PatternCamel'],pattern = \"Cam\") == [False, True, False, False, False]\n assert candidate(queries = ['Match', 'MaTch', 'MatCh', 'MatcH', 'MatchiNg'],pattern = \"Match\") == [True, False, False, False, False]\n assert candidate(queries = ['aAbBcC', 'aabbcc', 'aaBbCc', 'aAaBbCc', 'aAbbcC'],pattern = \"abc\") == [False, True, False, False, False]\n assert candidate(queries = ['VariableLength', 'VarLen', 'VarLenPattern', 'VL', 'VariablePatLen'],pattern = \"VarPatLen\") == [False, False, False, False, True]\n assert candidate(queries = ['lowerCasePattern', 'lowercasepattern', 'LOWERCASEPATTERN', 'lowerCASE'],pattern = \"lCP\") == [True, False, False, False]\n assert candidate(queries = ['Python', 'PythoN', 'PythOn', 'PyThOn', 'PYTHOn', 'PYTHOnS'],pattern = \"PyTh\") == [False, False, False, False, False, False]\n assert candidate(queries = ['aAbBcCdDeEfF', 'aabbccddeeff', 'Aabbccddeeff', 'aAbbccddeeff'],pattern = \"aBcDeF\") == [False, False, False, False]\n assert candidate(queries = ['Programming', 'PrograMMing', 'PROGRAMMING', 'programming'],pattern = \"PrM\") == [False, False, False, False]\n assert candidate(queries = ['helloWorld', 'HELLOworld', 'hElLoWoRlD', 'HeLLoWoRLd', 'HELLOWORLD'],pattern = \"hELo\") == [False, False, False, False, False]\n assert candidate(queries = ['aAbB', 'aabb', 'AABB', 'aAaA'],pattern = \"aAbB\") == [True, False, False, False]\n assert candidate(queries = ['aAbBcCdDeE', 'aabbccddeeff', 'AaBbCcDdEeFf', 'AABBCCDDEEFF'],pattern = \"aBcDeF\") == [False, False, False, False]\n assert candidate(queries = ['AlGoRiThM', 'algoRiThm', 'AlgorIthM', 'Algorithm'],pattern = \"AlGoRiThM\") == [True, False, False, False]\n assert candidate(queries = ['ThisIsJustARandomQuery', 'ThisIsJustAQuery', 'ThisIsARandomQuery', 'ThisJustARandomQuery', 'ThisIsJustARandomQ'],pattern = \"TIJARQ\") == [True, False, False, False, True]\n assert candidate(queries = ['QuantumComputing', 'quantumCOMPUTING', 'QuAnTuMCoMpUtInG', 'QUANTUMCOMPUTING'],pattern = \"QC\") == [True, False, False, False]\n assert candidate(queries = ['ComplexPattern', 'complexPattern', 'ComplexPATTERN', 'complexpATTERN', 'ComplexpAtTeRn'],pattern = \"CP\") == [True, False, False, False, False]\n assert candidate(queries = ['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'],pattern = \"a\") == [True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(queries = ['aBcDeFgHiJ', 'aBcDeFgHiJkLmNoPqR', 'aBcDeFgHiJkL', 'aBcDeFgHiJkLmNoP', 'aBcDeFgHiJkLmNoPqRsTuVwXyZ'],pattern = \"aBcDeFgHiJ\") == [True, False, False, False, False]\n assert candidate(queries = ['EdgeCase', 'EdgeCaseQuery', 'EdgeCaseMatch', 'EdgeCaseMismatch', 'EdgeCaseCase'],pattern = \"ECq\") == [False, False, False, False, False]\n assert candidate(queries = ['EdgeCase', 'EdgeCaseQuery', 'EdgeCaseMatch', 'EdgeCaseMismatch', 'EdgeCaseCase'],pattern = \"ECM\") == [False, False, True, True, False]\n assert candidate(queries = ['ArtificialIntelligence', 'artificialINTELLIGENCE', 'ArTiFiCiAlInTeLlIgEnCe', 'ARTIFICIALINTELLIGENCE'],pattern = \"AI\") == [True, False, False, False]\n assert candidate(queries = ['ComplexPattern', 'ComplexPatternQuery', 'ComplexPatternMatch', 'ComplexPatternMismatch', 'ComplexPatternCase'],pattern = \"CPMc\") == [False, False, True, True, False]\n assert candidate(queries = ['camelMatch', 'CamelMatch', 'camelMATCH', 'CamelMATCH', 'camelMatchTEST'],pattern = \"CMt\") == [False, True, False, False, False]\n assert candidate(queries = ['MiXeDcAsE', 'MiXeDcAsEc', 'MiXeDcAsEcc', 'MiXeDcAsEcce', 'MiXeDcAsEcces', 'MiXeDcAsEccese'],pattern = \"MiXeDcAsEcces\") == [False, False, False, False, True, True]\n assert candidate(queries = ['upperCASE', 'UpperCASE', 'upperCase', 'UPPERcase', 'uPPERCase'],pattern = \"uPR\") == [False, False, False, False, False]\n assert candidate(queries = ['AbCdEfGh', 'AbCdEfGhIj', 'AbCdEfGhIjKl', 'AbCdEfGhIjKlMn'],pattern = \"ACEGIK\") == [False, False, True, False]\n assert candidate(queries = ['SubsequenceMatching', 'SubseqMatch', 'SubSeqMatch', 'SbqMtch', 'SubsqMtch'],pattern = \"SbqMtch\") == [True, True, False, True, True]\n assert candidate(queries = ['TestPattern', 'TestPatternQuery', 'TestPatternMatch', 'TestPatternMismatch', 'TestPatternCase'],pattern = \"TPq\") == [False, False, False, False, False]\n assert candidate(queries = ['xYzXyZ', 'xyzyxzyx', 'XYXYXY', 'xyXyXy'],pattern = \"XyZ\") == [False, False, False, False]\n assert candidate(queries = ['multipleUpperCases', 'multipleUPPERCASES', 'MULTIPLEUPPERCASES', 'multipleUPPER'],pattern = \"mUC\") == [True, False, False, False]\n assert candidate(queries = ['CamelMatch', 'camelMatch', 'CaMeLmAtCh', 'CAMELMATCH', 'camelMATCH'],pattern = \"CaM\") == [True, False, False, False, False]\n assert candidate(queries = ['PatternMatching', 'PatternMATching', 'PatternMATCHing', 'PatternMATCHINg'],pattern = \"PatternMATCHINg\") == [False, False, False, True]\n assert candidate(queries = ['ComplexPattern', 'ComplexPatternQuery', 'ComplexPatternMatch', 'ComplexPatternMismatch', 'ComplexPatternCase'],pattern = \"CPq\") == [False, False, False, False, False]\n assert candidate(queries = ['XyZ', 'XYZabc', 'xYzAbC', 'xyZabc', 'XyZABC'],pattern = \"XyZ\") == [True, False, False, False, False]\n assert candidate(queries = ['MachineLearning', 'machineLEARNING', 'MaChInELeArNiNg', 'MACHINELEARNING'],pattern = \"ML\") == [True, False, False, False]\n assert candidate(queries = ['aBcDeFgHiJ', 'aBcDeFgHiJkL', 'aBcDeFgHiJkLmN', 'aBcDeFgHiJkLmNoP', 'aBcDeFgHiJkLmNoPqR'],pattern = \"aBcFj\") == [False, False, False, False, False]\n assert candidate(queries = ['CamelCasePatternMatching', 'camelCasePatternMatching', 'CamelCasePattern', 'CamelCasePatternMatch', 'CamelCasePatt'],pattern = \"CCPM\") == [True, False, False, True, False]\n assert candidate(queries = ['AbCdEfG', 'AbcDeFG', 'AbCDefg', 'AbcDefgHiJk', 'AbCdEfGhIjk'],pattern = \"ACEG\") == [True, False, False, False, False]\n assert candidate(queries = ['TestPattern', 'TestPatternQuery', 'TestPatternMatch', 'TestPatternMismatch', 'TestPatternCase'],pattern = \"TPM\") == [False, False, True, True, False]\n assert candidate(queries = ['CamelCase', 'camelCase', 'CamelCASE', 'CAMELcase'],pattern = \"CaC\") == [True, False, False, False]\n assert candidate(queries = ['aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ', 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'aBcDeFgHiJkLmNoPqRsTuVwXyZ', 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'],pattern = \"aBcEfHjLpTz\") == [False, False, False, False, False]\n assert candidate(queries = ['OneTwoThreeFourFiveSixSevenEightNineTen', 'OneTwoThreeFourFiveSixSevenEightNine', 'OneTwoThreeFourFiveSixSevenEight', 'OneTwoThreeFourFiveSixSeven', 'OneTwoThreeFourFiveSix'],pattern = \"OTFSF\") == [False, False, False, False, False]\n assert candidate(queries = ['CamelCasePatternMatching', 'camelCasePatternMatching', 'CAMELCASEPATTERNMATCHING', 'camelcasepatternmatching'],pattern = \"CamElCaSePaTtErNmAtChInG\") == [False, False, False, False]\n assert candidate(queries = ['aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ', 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY'],pattern = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == [False, False]\n assert candidate(queries = ['AnotherExample', 'Another', 'An', 'AnotherExampleString', 'ExampleAnotherString'],pattern = \"An\") == [False, True, True, False, False]\n assert candidate(queries = ['TestCase', 'Test', 'TestCasePattern', 'TestPattern', 'PatternTest'],pattern = \"Tes\") == [False, True, False, False, False]\n assert candidate(queries = ['PatternMatching', 'PatternMatchingExample', 'PatMatch', 'PatMatchEx'],pattern = \"PM\") == [True, False, True, False]\n assert candidate(queries = ['abAB', 'abab', 'ABab', 'abABab', 'abABAB'],pattern = \"abAB\") == [True, False, False, True, False]\n assert candidate(queries = ['PatternMatchingIsFun', 'PatternMatching', 'PatternMatchingIs', 'PatternIsFun', 'PatternMatchingFun'],pattern = \"PMIF\") == [True, False, False, False, False]\n assert candidate(queries = ['AlGoRiThM', 'algoR', 'alGOrIthM', 'aLGOrIth', 'AlgOrIthM'],pattern = \"aGI\") == [False, False, False, False, False]\n assert candidate(queries = ['aBcDeFgHiJ', 'aBcDeFgHiJkL', 'aBcDeFgHiJkLmN', 'aBcDeFgHiJkLmNoP', 'aBcDeFgHiJkLmNoPqR'],pattern = \"aBcDFgHj\") == [False, False, False, False, False]\n assert candidate(queries = ['aBCdEf', 'abcdef', 'abDef', 'aBcDE', 'aBcDeF', 'aBcDEf'],pattern = \"aBcEf\") == [False, False, False, False, False, False]\n assert candidate(queries = ['TestCasesWithDifferentLengths', 'TestCasesWithDifferentLength', 'TestCasesWithDifferent', 'TestCasesWith', 'TestCases'],pattern = \"TCWDL\") == [True, True, False, False, False]\n assert candidate(queries = ['Pattern', 'pattern', 'PatternMatch', 'PAtTERNmAtCH', 'PaTtErNmAtCh'],pattern = \"PaT\") == [False, False, False, False, False]\n assert candidate(queries = ['ComputerVision', 'computerVISION', 'CoMpUtErViSiOn', 'COMPUTERVISION'],pattern = \"CV\") == [True, False, False, False]\n assert candidate(queries = ['Xylophone', 'xylophone', 'XyLopHone', 'XyLoPhone', 'xyLoPhOnE'],pattern = \"XyLoPhOnE\") == [False, False, False, False, False]\n assert candidate(queries = ['CoMpLeXqUeRiEs', 'complexqueries', 'CoMpLeXqUeRiE', 'CoMpLeXqUeRiEz', 'CoMpLeXqUeRiEsZ', 'CoMpLeXqUeRiEsZz'],pattern = \"CoMpLeXqUeRiEs\") == [True, False, False, False, False, False]\n assert candidate(queries = ['CamelHump', 'CamelHumpQuery', 'CamelHouse', 'CamelHousekeeping', 'CamelHorseRace'],pattern = \"CHq\") == [False, False, False, False, False]\n assert candidate(queries = ['looongPattern', 'looongPattern', 'longPattern', 'lOnGPattern', 'LoNgPatTerN'],pattern = \"LoNgPat\") == [False, False, False, False, False]\n assert candidate(queries = ['Algorithm', 'AlgoRhythm', 'AlGoRiThM', 'ALGORITHM'],pattern = \"AlGM\") == [False, False, False, False]\n assert candidate(queries = ['TestString', 'TestingString', 'TeststrIng', 'TstStr', 'TestStrng'],pattern = \"TstStr\") == [True, True, False, True, True]\n assert candidate(queries = ['OneTwoThreeFour', 'OTFT', 'OneTwoF', 'OneTwoThrFor', 'OTFTF'],pattern = \"OTFT\") == [False, True, False, False, False]\n assert candidate(queries = ['qWeRtY', 'qwerty', 'QwErTy', 'QwErTyUiOp'],pattern = \"qWeRtY\") == [True, False, False, False]\n assert candidate(queries = ['TestPattern', 'TestPatternQuery', 'TestPatternMatch', 'TestPatternMismatch', 'TestPatternCase'],pattern = \"TPMc\") == [False, False, True, True, False]\n assert candidate(queries = ['NaturalLanguageProcessing', 'naturalLANGUAGEPROCESSING', 'NaTuRaLlAnGuAgEPrOcEsSiNg', 'NATURALLANGUAGEPROCESSING'],pattern = \"NLP\") == [True, False, False, False]\n assert candidate(queries = ['MIXEDcase', 'MiXEDcase', 'MiXeDCase', 'MIXeDCase', 'MiXEdCASE'],pattern = \"MXc\") == [False, False, False, False, False]\n assert candidate(queries = ['MiXeDcASe', 'MiXeDCase', 'MiXeD', 'MiX', 'MixeDCase'],pattern = \"MiX\") == [False, False, False, True, False]\n assert candidate(queries = ['aAaAaA', 'aaaaaa', 'Aaaaaa', 'aAaaaa', 'aaaaAa'],pattern = \"aAa\") == [False, False, False, True, True]\n assert candidate(queries = ['CamelHump', 'CamelHumpQuery', 'CamelHouse', 'CamelHousekeeping', 'CamelHorseRace'],pattern = \"CHH\") == [False, False, False, False, False]\n assert candidate(queries = ['PatternMatching', 'PatMat', 'PatrnMtch', 'PatternMtching', 'PatMatch'],pattern = \"PtnMtch\") == [True, False, True, True, False]\n assert candidate(queries = ['AlphabetPattern', 'Al', 'Alpha', 'Pattern', 'AlphabetPatternInString'],pattern = \"Al\") == [False, True, True, False, False]\n assert candidate(queries = ['lowercase', 'Lowercase', 'LOWERCASE', 'lowerCASE', 'lowERCASE'],pattern = \"lwr\") == [True, False, False, False, False]\n assert candidate(queries = ['aAbBcCdDeEfFgG', 'aBcDeFg', 'aBcD', 'aB', 'a'],pattern = \"aBcD\") == [False, False, True, False, False]\n assert candidate(queries = ['AlGoRiThM', 'algorithm', 'AlGoRiThMs', 'AlGoRiThMuS', 'algorithms', 'AlGoRiThmSUs', 'AlGoRiThMuSiC'],pattern = \"AlGoRiThMuS\") == [False, False, False, True, False, False, False]\n assert candidate(queries = ['exampleQuery', 'ExampleQUERY', 'exampleQUERY', 'exampleQueryTest', 'exampleQueryTestTest'],pattern = \"eQ\") == [True, False, False, False, False]\n assert candidate(queries = ['DataStructure', 'dataStructure', 'DataSTRUCTURE', 'DATAstructure'],pattern = \"DtS\") == [True, False, False, False]\n", "comparison": "exact"}, "public_tests": ["[\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"]\n\"FB\"", "[\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"]\n\"FoBa\"", "[\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"]\n\"FoBaT\""], "hints": ["Given a single pattern and word, how can we solve it?", "One way to do it is using a DP (pos1, pos2) where pos1 is a pointer to the word and pos2 to the pattern and returns true if we can match the pattern with the given word.", "We have two scenarios: The first one is when `word[pos1] == pattern[pos2]`, then the transition will be just DP(pos1 + 1, pos2 + 1). The second scenario is when `word[pos1]` is lowercase then we can add this character to the pattern so that the transition is just DP(pos1 + 1, pos2) The case base is `if (pos1 == n && pos2 == m) return true;` Where n and m are the sizes of the strings word and pattern respectively."], "metadata": {"canonical_parameter_names": ["queries", "pattern"], "leetcode_dataset_entry_point": "Solution().camelMatch", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:08+00:00", "tests_total": 114, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "two-pointers", "string", "trie", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def camelMatch(self, queries: list[str], pattern: str) -> list[bool]:", "container": "Solution", "callable": "camelMatch", "parameters": [{"name": "queries", "type": "list[str]"}, {"name": "pattern", "type": "str"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1024, "task_id": "video-stitching", "difficulty": "Medium", "problem_description": "You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths.\n\nEach video clip is described by an array clips where clips[i] = [start_i, end_i] indicates that the ith clip started at start_i and ended at end_i.\n\nWe can cut these clips into segments freely.\n\n- For example, a clip [0, 7] can be cut into segments [0, 1] + [1, 3] + [3, 7].\n\nReturn the minimum number of clips needed so that we can cut the clips into segments that cover the entire sporting event [0, time]. If the task is impossible, return -1.\n\nExample 1:\n\nInput: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10\nOutput: 3\nExplanation: We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.\nThen, we can reconstruct the sporting event as follows:\nWe cut [1,9] into segments [1,2] + [2,8] + [8,9].\nNow we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 10].\n\nExample 2:\n\nInput: clips = [[0,1],[1,2]], time = 5\nOutput: -1\nExplanation: We cannot cover [0,5] with only [0,1] and [1,2].\n\nExample 3:\n\nInput: clips = [[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]], time = 9\nOutput: 3\nExplanation: We can take clips [0,4], [4,7], and [6,9].\n\nConstraints:\n\n- 1 <= clips.length <= 100\n- 0 <= start_i <= end_i <= 100\n- 1 <= time <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(clips = [[0, 5], [0, 7], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 10], [7, 9], [8, 10], [9, 10]],time = 10) == 2\n assert candidate(clips = [[0, 2], [4, 6], [8, 10], [1, 9], [1, 5], [5, 9]],time = 10) == 3\n assert candidate(clips = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 10) == 10\n assert candidate(clips = [[0, 10]],time = 10) == 1\n assert candidate(clips = [[0, 5], [0, 7], [0, 8], [1, 5], [2, 4], [4, 5], [5, 8], [5, 10], [6, 8], [7, 10], [8, 10], [9, 10]],time = 10) == 2\n assert candidate(clips = [[0, 1], [1, 3], [3, 4], [4, 6], [6, 7], [7, 9], [9, 10]],time = 10) == 7\n assert candidate(clips = [[0, 1], [1, 2]],time = 5) == -1\n assert candidate(clips = [[0, 0], [6, 8], [0, 4], [0, 7], [7, 9], [8, 10], [9, 10], [9, 12], [4, 5], [4, 4], [0, 3], [6, 7], [0, 6], [0, 6], [0, 2], [7, 10], [7, 9], [9, 10]],time = 9) == 2\n assert candidate(clips = [[0, 1], [6, 8], [0, 2], [5, 6], [0, 4], [0, 3], [6, 7], [1, 3], [4, 7], [1, 4], [2, 5], [2, 6], [3, 4], [4, 5], [5, 7], [6, 9]],time = 9) == 3\n assert candidate(clips = [[0, 5], [1, 5], [1, 6], [3, 4], [3, 5]],time = 5) == 1\n assert candidate(clips = [[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, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]],time = 30) == 15\n assert candidate(clips = [[0, 20], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15], [6, 14], [7, 13], [8, 12], [9, 11]],time = 20) == 1\n assert candidate(clips = [[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]],time = 15) == 15\n assert candidate(clips = [[0, 50], [25, 75], [50, 100], [0, 25], [25, 50], [50, 75], [75, 100], [0, 100]],time = 100) == 1\n assert candidate(clips = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],time = 10) == 1\n assert candidate(clips = [[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]],time = 39) == -1\n assert candidate(clips = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],time = 55) == 11\n assert candidate(clips = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 10) == -1\n assert candidate(clips = [[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]],time = 22) == 11\n assert candidate(clips = [[0, 2], [1, 5], [3, 7], [4, 9], [6, 11], [8, 13], [10, 15], [12, 17], [14, 19], [16, 21], [18, 23], [20, 25]],time = 25) == 7\n assert candidate(clips = [[0, 10], [2, 8], [3, 5], [4, 6], [6, 9], [8, 10], [1, 4], [5, 7]],time = 10) == 1\n assert candidate(clips = [[0, 10], [5, 20], [15, 30], [10, 25], [20, 35], [25, 40], [0, 5], [5, 15], [15, 25], [25, 35], [30, 40], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]],time = 40) == 3\n assert candidate(clips = [[0, 4], [4, 8], [8, 12], [12, 16], [16, 20], [20, 24], [24, 28], [28, 32], [0, 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]],time = 32) == 8\n assert candidate(clips = [[0, 50], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],time = 100) == 6\n assert candidate(clips = [[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]],time = 25) == -1\n assert candidate(clips = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],time = 50) == 5\n assert candidate(clips = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]],time = 19) == 2\n assert candidate(clips = [[0, 10], [2, 20], [5, 30], [7, 25], [10, 40], [12, 50], [15, 35], [20, 60], [25, 45], [30, 70]],time = 60) == 3\n assert candidate(clips = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [18, 20]],time = 20) == 10\n assert candidate(clips = [[0, 100], [0, 50], [50, 75], [75, 100], [0, 25], [25, 50], [50, 75], [75, 100]],time = 100) == 1\n assert candidate(clips = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]],time = 15) == 3\n assert candidate(clips = [[0, 10], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55]],time = 55) == 6\n assert candidate(clips = [[0, 15], [5, 20], [10, 25], [15, 30], [20, 35], [25, 40], [30, 45], [35, 50], [40, 55], [45, 60], [50, 65], [55, 70], [60, 75], [65, 80], [70, 85], [75, 90], [80, 95], [85, 100]],time = 100) == 7\n assert candidate(clips = [[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]],time = 13) == 13\n assert candidate(clips = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 11) == -1\n assert candidate(clips = [[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, 10], [10, 20], [20, 30]],time = 30) == 3\n assert candidate(clips = [[0, 20], [5, 10], [10, 15], [15, 20], [2, 4], [4, 6], [6, 8], [8, 10], [12, 14], [14, 16], [16, 18], [18, 20]],time = 20) == 1\n assert candidate(clips = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]],time = 49) == 10\n assert candidate(clips = [[0, 100], [0, 50], [50, 100], [25, 75], [75, 100], [50, 75], [25, 50]],time = 100) == 1\n assert candidate(clips = [[0, 50], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35], [30, 35], [35, 40], [40, 45], [45, 50], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50]],time = 50) == 1\n assert candidate(clips = [[5, 10], [10, 15], [0, 5], [15, 20], [20, 25], [0, 25], [25, 30], [0, 15], [15, 25], [0, 30]],time = 30) == 1\n assert candidate(clips = [[0, 10], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50]],time = 45) == 5\n assert candidate(clips = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]],time = 20) == -1\n assert candidate(clips = [[0, 1], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],time = 20) == -1\n assert candidate(clips = [[0, 20], [5, 15], [10, 25], [0, 10], [15, 20], [20, 30]],time = 25) == 2\n assert candidate(clips = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]],time = 50) == 10\n assert candidate(clips = [[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, 5], [5, 10], [10, 15], [15, 20]],time = 20) == 4\n assert candidate(clips = [[0, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = 11) == 10\n assert candidate(clips = [[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]],time = 15) == 1\n assert candidate(clips = [[0, 2], [1, 4], [2, 6], [3, 5], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 26], [24, 27], [25, 28], [26, 29], [27, 30]],time = 30) == 10\n assert candidate(clips = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]],time = 100) == 2\n assert candidate(clips = [[0, 30], [3, 20], [5, 25], [7, 15], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]],time = 30) == 1\n assert candidate(clips = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12]],time = 12) == 4\n assert candidate(clips = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],time = 1) == 1\n assert candidate(clips = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]],time = 20) == -1\n assert candidate(clips = [[0, 1], [1, 100]],time = 100) == 2\n assert candidate(clips = [[0, 100], [1, 99], [2, 98], [3, 97], [4, 96], [5, 95], [6, 94], [7, 93], [8, 92], [9, 91]],time = 100) == 1\n assert candidate(clips = [[0, 20], [15, 30], [25, 40], [10, 25], [30, 45], [5, 15], [0, 10], [20, 30], [10, 20], [40, 50]],time = 50) == 4\n assert candidate(clips = [[0, 1], [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], [0, 5], [5, 10], [10, 15], [15, 20]],time = 20) == 4\n assert candidate(clips = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21]],time = 21) == -1\n assert candidate(clips = [[0, 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]],time = 30) == 15\n assert candidate(clips = [[0, 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]],time = 30) == 1\n assert candidate(clips = [[0, 5], [0, 10], [0, 15], [0, 20], [0, 25], [0, 30], [0, 35], [0, 40], [0, 45], [0, 50]],time = 50) == 1\n assert candidate(clips = [[0, 1], [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]],time = 40) == -1\n assert candidate(clips = [[0, 3], [4, 9], [5, 11], [13, 14], [10, 14], [11, 14], [12, 15], [15, 16], [6, 13], [1, 6], [3, 8], [7, 8], [9, 10], [10, 12], [8, 9], [14, 15], [1, 2], [0, 1]],time = 16) == 5\n assert candidate(clips = [[0, 10], [2, 5], [5, 15], [10, 20], [15, 25], [20, 30], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [1, 4], [4, 7], [7, 10], [10, 13], [13, 16], [16, 19], [19, 22], [22, 25], [25, 28], [28, 30]],time = 30) == 3\n assert candidate(clips = [[0, 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, 16], [15, 17], [16, 18], [17, 19], [18, 20]],time = 20) == 11\n assert candidate(clips = [[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]],time = 95) == 1\n assert candidate(clips = [[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]],time = 55) == -1\n assert candidate(clips = [[0, 10], [2, 20], [4, 30], [6, 40], [8, 50], [10, 60], [12, 70], [14, 80], [16, 90], [18, 100]],time = 100) == 3\n assert candidate(clips = [[0, 5], [1, 9], [2, 11], [3, 13], [4, 15], [5, 17], [6, 19], [7, 21], [8, 23], [9, 25]],time = 25) == 3\n assert candidate(clips = [[0, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]],time = 11) == 6\n assert candidate(clips = [[0, 50], [1, 49], [2, 48], [3, 47], [4, 46], [5, 45], [6, 44], [7, 43], [8, 42], [9, 41]],time = 50) == 1\n assert candidate(clips = [[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]],time = 20) == 20\n assert candidate(clips = [[0, 3], [1, 7], [2, 8], [3, 11], [5, 10], [7, 15], [8, 16], [12, 18], [14, 20], [16, 22], [18, 25]],time = 25) == 5\n assert candidate(clips = [[0, 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]],time = 40) == 20\n assert candidate(clips = [[0, 10], [5, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60]],time = 60) == 6\n assert candidate(clips = [[0, 5], [2, 8], [4, 10], [6, 12], [8, 14], [10, 16], [12, 18], [14, 20], [16, 22], [18, 24], [20, 25]],time = 25) == 5\n assert candidate(clips = [[0, 3], [1, 6], [2, 7], [3, 10], [4, 8], [5, 9], [6, 11], [7, 12], [8, 13], [9, 14]],time = 14) == 3\n assert candidate(clips = [[0, 10], [1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [0, 30], [15, 30], [30, 40], [35, 45], [40, 50], [35, 50], [0, 25], [25, 45]],time = 50) == 3\n assert candidate(clips = [[0, 1], [1, 3], [2, 5], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [18, 20], [20, 22]],time = 22) == 12\n assert candidate(clips = [[0, 30], [10, 20], [20, 30], [5, 15], [15, 25], [25, 35], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50]],time = 45) == 3\n assert candidate(clips = [[0, 3], [4, 7], [8, 12], [5, 9], [1, 4], [2, 6], [3, 5], [6, 10], [7, 11], [0, 1], [9, 13]],time = 13) == 4\n assert candidate(clips = [[0, 1], [0, 3], [0, 5], [0, 7], [0, 9], [1, 2], [1, 4], [1, 6], [1, 8], [1, 10], [2, 3], [2, 5], [2, 7], [2, 9], [3, 4], [3, 6], [3, 8], [3, 10], [4, 5], [4, 7], [4, 9], [5, 6], [5, 8], [5, 10], [6, 7], [6, 9], [7, 8], [7, 10], [8, 9]],time = 10) == 2\n assert candidate(clips = [[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]],time = 100) == 1\n assert candidate(clips = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],time = 100) == 10\n", "comparison": "exact"}, "public_tests": ["[[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]]\n10", "[[0,1],[1,2]]\n5", "[[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]]\n9"], "hints": ["What if we sort the intervals? Considering the sorted intervals, how can we solve the problem with dynamic programming?", "Let's consider a DP(pos, limit) where pos represents the position of the current interval we are gonna take the decision and limit is the current covered area from [0 - limit]. This DP returns the minimum number of taken intervals or infinite if it's not possible to cover the [0 - T] section."], "metadata": {"canonical_parameter_names": ["clips", "time"], "leetcode_dataset_entry_point": "Solution().videoStitching", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:10+00:00", "tests_total": 95, "tests_dropped": 9, "flags": [], "topic_tags": ["array", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def videoStitching(self, clips: list[list[int]], time: int) -> int:", "container": "Solution", "callable": "videoStitching", "parameters": [{"name": "clips", "type": "list[list[int]]"}, {"name": "time", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1025, "task_id": "divisor-game", "difficulty": "Easy", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\n\nInitially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of:\n\n- Choosing any integer x with 0 < x < n and n % x == 0.\n- Replacing the number n on the chalkboard with n - x.\n\nAlso, if a player cannot make a move, they lose the game.\n\nReturn true if and only if Alice wins the game, assuming both players play optimally.\n\nExample 1:\n\nInput: n = 2\nOutput: true\nExplanation: Alice chooses 1, and Bob has no more moves.\n\nExample 2:\n\nInput: n = 3\nOutput: false\nExplanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == True\n assert candidate(n = 3) == False\n assert candidate(n = 4) == True\n assert candidate(n = 9) == False\n assert candidate(n = 6) == True\n assert candidate(n = 2) == True\n assert candidate(n = 1000) == True\n assert candidate(n = 7) == False\n assert candidate(n = 10) == True\n assert candidate(n = 5) == False\n assert candidate(n = 625) == False\n assert candidate(n = 576) == True\n assert candidate(n = 729) == False\n assert candidate(n = 49) == False\n assert candidate(n = 50) == True\n assert candidate(n = 300) == True\n assert candidate(n = 99) == False\n assert candidate(n = 64) == True\n assert candidate(n = 17) == False\n assert candidate(n = 649) == False\n assert candidate(n = 23) == False\n assert candidate(n = 343) == False\n assert candidate(n = 640) == True\n assert candidate(n = 819) == False\n assert candidate(n = 128) == True\n assert candidate(n = 299) == False\n assert candidate(n = 777) == False\n assert candidate(n = 701) == False\n assert candidate(n = 999) == False\n assert candidate(n = 129) == False\n assert candidate(n = 18) == True\n assert candidate(n = 32) == True\n assert candidate(n = 256) == True\n assert candidate(n = 997) == False\n assert candidate(n = 768) == True\n assert candidate(n = 127) == False\n assert candidate(n = 81) == False\n assert candidate(n = 150) == True\n assert candidate(n = 503) == False\n assert candidate(n = 24) == True\n assert candidate(n = 15) == False\n assert candidate(n = 400) == True\n assert candidate(n = 512) == True\n assert candidate(n = 31) == False\n assert candidate(n = 377) == False\n assert candidate(n = 499) == False\n assert candidate(n = 1) == False\n assert candidate(n = 500) == True\n assert candidate(n = 420) == True\n assert candidate(n = 13) == False\n", "comparison": "exact"}, "public_tests": ["2", "3"], "hints": ["If the current number is even, we can always subtract a 1 to make it odd. If the current number is odd, we must subtract an odd number to make it even."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().divisorGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:12+00:00", "tests_total": 51, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "dynamic-programming", "brainteaser", "game-theory", "impartial-game"]}, "language": "python", "interface": {"raw_signature": "def divisorGame(self, n: int) -> bool:", "container": "Solution", "callable": "divisorGame", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1027, "task_id": "longest-arithmetic-subsequence", "difficulty": "Medium", "problem_description": "Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.\n\nNote that:\n\n- A 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- A sequence seq is arithmetic if seq[i + 1] - seq[i] are all the same value (for 0 <= i < seq.length - 1).\n\nExample 1:\n\nInput: nums = [3, 6, 9, 12]\nOutput: 4\nExplanation: The whole array is already an arithmetic sequence with a common difference of 3, so the longest arithmetic subsequence is [3, 6, 9, 12], of length 4.\n\nExample 2:\n\nInput: nums = [9, 4, 7, 2, 10]\nOutput: 3\nExplanation: The longest arithmetic subsequence is [4, 7, 10] (indices 1, 2, 4), with a common difference of 3. There is no arithmetic subsequence of length 4.\n\nExample 3:\n\nInput: nums = [20, 1, 15, 3, 10, 5, 8]\nOutput: 4\nExplanation: The longest arithmetic subsequence is [20, 15, 10, 5] (indices 0, 2, 4, 5), with a common difference of -5.\n\nConstraints:\n\n- 2 <= nums.length <= 1500\n- 0 <= nums[i] <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 11, 11, 11, 15]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 8\n assert candidate(nums = [83, 20, 17, 43, 52, 78, 68, 45]) == 2\n assert candidate(nums = [8, 12, 16, 20, 24, 28]) == 6\n assert candidate(nums = [2, 4, 6, 8, 10, 14, 18]) == 5\n assert candidate(nums = [8, 12, 16, 4, 0, 20]) == 4\n assert candidate(nums = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [3, 6, 9, 12]) == 4\n assert candidate(nums = [20, 1, 15, 3, 10, 5, 8]) == 4\n assert candidate(nums = [500, 0, 500, 0, 500, 0]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [9, 4, 7, 2, 10]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == 7\n assert candidate(nums = [7, 7, 7, 7, 10, 10, 10, 10]) == 4\n assert candidate(nums = [500, 500, 500, 500, 500]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [0, 2, 2, 2, 4, 6, 8, 10]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [44, 46, 22, 68, 45, 66, 43, 96, 29, 37]) == 2\n assert candidate(nums = [10, 9, 4, 5, 4, 8, 6]) == 3\n assert candidate(nums = [1, 2, 3, 8, 9, 10]) == 3\n assert candidate(nums = [1, 7, 10, 15, 27, 29]) == 3\n assert candidate(nums = [100, 100, 100, 100, 101]) == 4\n assert candidate(nums = [5, 14, 13, 8, 12]) == 3\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == 17\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61]) == 20\n assert candidate(nums = [4, 1, 3, 2, 5, 10, 8, 14, 18, 22, 26, 30]) == 6\n assert candidate(nums = [8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 14\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500]) == 3\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == 10\n assert candidate(nums = [100, 101, 104, 109, 115, 122, 130, 139, 149, 160, 172, 185, 199]) == 3\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]) == 26\n assert candidate(nums = [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, 3, 5, 7, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 11\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]) == 11\n assert candidate(nums = [1, 7, 10, 15, 27, 29, 33, 18]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(nums = [10, 20, 15, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 13\n assert candidate(nums = [7, 9, 11, 7, 9, 11, 7, 9, 11, 7, 9, 11, 7, 9, 11, 7, 9, 11]) == 6\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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [1, 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 = [10, 20, 30, 15, 25, 35, 20, 30, 40, 25, 35, 45, 30, 40, 50, 35, 45, 55, 40, 50, 60, 45, 55, 65]) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 11\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 10\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18]) == 6\n assert candidate(nums = [5, 10, 15, 25, 35, 40, 45, 50]) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [1, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41]) == 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, 41, 43, 45, 47, 49]) == 25\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == 12\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 15\n assert candidate(nums = [1, 5, 7, 11, 13, 17, 19, 23, 29, 31, 35, 37, 41]) == 7\n assert candidate(nums = [1, 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 = [100, 200, 150, 250, 300, 350, 400, 450]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 13\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]) == 24\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 11\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\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\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]) == 21\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 45, 60, 70, 65, 80, 90, 85, 100]) == 10\n assert candidate(nums = [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]) == 25\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]) == 25\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32]) == 10\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57]) == 15\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 = [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 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, 84, 88, 92, 96, 100]) == 25\n assert candidate(nums = [10, 20, 15, 25, 35, 40, 45, 55, 65, 75, 85, 95]) == 9\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 10\n assert candidate(nums = [4, 12, 16, 20, 28, 32, 36, 40, 44]) == 6\n assert candidate(nums = [1, 7, 10, 15, 27, 29, 33]) == 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 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 3\n assert candidate(nums = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486]) == 15\n assert candidate(nums = [100, 50, 75, 100, 125, 150, 175, 200, 225, 250]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 12\n assert candidate(nums = [10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70]) == 7\n assert candidate(nums = [4, 1, 3, 2, 5, 7, 6, 9, 8, 10]) == 5\n assert candidate(nums = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == 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]) == 40\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, 77, 80, 83, 86, 89, 92, 95, 98]) == 33\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]) == 40\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 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]) == 25\n assert candidate(nums = [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]) == 28\n assert candidate(nums = [2, 4, 6, 8, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50]) == 13\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190]) == 3\n assert candidate(nums = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 11\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 15\n assert candidate(nums = [3, 5, 6, 7, 8, 10, 12, 14, 15, 18, 20, 22, 24, 25, 27, 29, 30]) == 6\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89]) == 15\n assert candidate(nums = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46]) == 15\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]) == 24\n assert candidate(nums = [1, 5, 7, 10, 15, 16, 21, 26, 31, 36, 41]) == 6\n assert candidate(nums = [5, 8, 11, 14, 13, 12, 15, 18, 21, 24, 27]) == 6\n assert candidate(nums = [1, 7, 10, 13, 14, 18, 21, 22, 25, 28]) == 4\n assert candidate(nums = [25, 29, 33, 37, 41, 45, 49, 53, 57, 61]) == 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]) == 20\n assert candidate(nums = [7, 11, 5, 13, 17, 3, 19, 23, 29, 37, 43, 47, 53, 59, 67, 71, 79, 83, 89]) == 4\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 15\n assert candidate(nums = [5, 3, 1, 4, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 13\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40]) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3]) == 8\n assert candidate(nums = [1, 7, 10, 15, 27, 29, 33, 37, 41, 54, 69]) == 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]) == 20\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57]) == 15\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 15\n assert candidate(nums = [5, 10, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums = [10, 9, 4, 5, 4, 8, 6]) == 3\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 = [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]) == 25\n assert candidate(nums = [2, 4, 6, 8, 10, 14, 18, 22, 26, 30, 34, 38, 42]) == 11\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 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]) == 20\n assert candidate(nums = [4, 12, 10, 9, 8, 6, 5, 3, 1]) == 4\n assert candidate(nums = [10, 5, 10, 15, 20, 25, 30, 35, 40, 45]) == 9\n assert candidate(nums = [100, 200, 50, 150, 250, 300, 350, 400, 450, 500]) == 7\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 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, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 30\n assert candidate(nums = [2, 6, 8, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74]) == 19\n assert candidate(nums = [3, 1, 2, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 13\n assert candidate(nums = [8, 12, 16, 4, 0, 20, 24, 28]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100]) == 12\n assert candidate(nums = [4, 14, 24, 34, 44, 54, 49, 64, 59, 74, 69, 84, 79, 94, 89, 104]) == 11\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55]) == 3\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 20\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 18\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]) == 11\n assert candidate(nums = [20, 30, 25, 35, 40, 50, 45, 55, 60]) == 5\n", "comparison": "exact"}, "public_tests": ["[3,6,9,12]", "[9,4,7,2,10]", "[20,1,15,3,10,5,8]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestArithSeqLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:17+00:00", "tests_total": 159, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def longestArithSeqLength(self, nums: list[int]) -> int:", "container": "Solution", "callable": "longestArithSeqLength", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1029, "task_id": "two-city-scheduling", "difficulty": "Medium", "problem_description": "A company is planning to interview 2n people. Given the array costs where costs[i] = [aCost_i, bCost_i], the cost of flying the i^th person to city a is aCost_i, and the cost of flying the i^th person to city b is bCost_i.\n\nReturn the minimum cost to fly every person to a city such that exactly n people arrive in each city.\n\nExample 1:\n\nInput: costs = [[10,20],[30,200],[400,50],[30,20]]\nOutput: 110\nExplanation:\nThe first person goes to city A for a cost of 10.\nThe second person goes to city A for a cost of 30.\nThe third person goes to city B for a cost of 50.\nThe fourth person goes to city B for a cost of 20.\n\nThe total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city.\n\nExample 2:\n\nInput: costs = [[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]]\nOutput: 1859\n\nExample 3:\n\nInput: costs = [[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]]\nOutput: 3086\n\nConstraints:\n\n- 2 * n == costs.length\n- 2 <= costs.length <= 100\n- costs.length is even.\n- 1 <= aCost_i, bCost_i <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(costs = [[30, 20], [200, 300], [50, 400], [20, 30]]) == 300\n assert candidate(costs = [[10, 20], [30, 200], [400, 50], [30, 20]]) == 110\n assert candidate(costs = [[515, 563], [451, 713], [537, 709], [343, 819], [855, 779], [457, 60], [650, 359], [631, 42]]) == 3086\n assert candidate(costs = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 18\n assert candidate(costs = [[259, 770], [448, 54], [926, 667], [184, 139], [840, 118], [577, 469]]) == 1859\n assert candidate(costs = [[100, 200], [200, 100], [300, 400], [400, 300], [500, 600], [600, 500], [700, 800], [800, 700]]) == 3200\n assert candidate(costs = [[450, 440], [300, 400], [350, 420], [400, 380], [250, 410], [410, 420], [270, 300], [430, 450]]) == 2860\n assert candidate(costs = [[100, 200], [250, 150], [300, 400], [50, 500], [450, 350], [200, 300], [150, 450], [350, 250], [500, 600], [650, 550]]) == 2700\n assert candidate(costs = [[100, 200], [150, 250], [300, 100], [400, 150], [500, 500], [250, 350], [100, 400], [200, 500], [350, 250], [500, 450]]) == 2250\n assert candidate(costs = [[888, 111], [777, 222], [666, 333], [555, 444], [444, 555], [333, 666], [222, 777], [111, 888]]) == 2220\n assert candidate(costs = [[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]]) == 3263\n assert candidate(costs = [[10, 20], [30, 200], [400, 50], [30, 20], [10, 20], [30, 200], [400, 50], [30, 20]]) == 220\n assert candidate(costs = [[50, 1000], [200, 300], [400, 600], [300, 800], [700, 100], [100, 750], [600, 550], [800, 400]]) == 2200\n assert candidate(costs = [[101, 99], [99, 101], [102, 98], [98, 102], [103, 97], [97, 103], [104, 96], [96, 104], [105, 95], [95, 105], [106, 94], [94, 106], [107, 93], [93, 107], [108, 92], [92, 108], [109, 91], [91, 109]]) == 1710\n assert candidate(costs = [[999, 1], [1, 999], [998, 2], [2, 998], [997, 3], [3, 997], [996, 4], [4, 996], [995, 5], [5, 995], [994, 6], [6, 994], [993, 7], [7, 993], [992, 8], [8, 992]]) == 72\n assert candidate(costs = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993]]) == 3988\n assert candidate(costs = [[500, 400], [250, 600], [1000, 500], [300, 200], [600, 700], [100, 100], [400, 300], [350, 450], [700, 600], [800, 200]]) == 3600\n assert candidate(costs = [[1, 1000], [1000, 1], [2, 999], [999, 2], [3, 998], [998, 3], [4, 997], [997, 4], [5, 996], [996, 5], [6, 995], [995, 6]]) == 42\n assert candidate(costs = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550]]) == 2600\n assert candidate(costs = [[100, 900], [900, 100], [200, 800], [800, 200], [300, 700], [700, 300], [400, 600], [600, 400]]) == 2000\n assert candidate(costs = [[100, 900], [900, 100], [150, 650], [700, 300], [200, 800], [800, 200], [400, 500], [600, 400]]) == 1850\n assert candidate(costs = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]) == 300\n assert candidate(costs = [[500, 100], [200, 400], [600, 300], [700, 200], [100, 500], [400, 600], [300, 700], [200, 100]]) == 1700\n assert candidate(costs = [[100, 900], [900, 100], [200, 800], [800, 200], [300, 700], [700, 300], [400, 600], [600, 400], [500, 500], [500, 500], [400, 600], [600, 400], [300, 700], [700, 300], [200, 800], [800, 200], [100, 900], [900, 100]]) == 5000\n assert candidate(costs = [[1, 999], [1, 998], [1, 997], [1, 996], [1, 995], [1, 994], [1, 993], [1, 992]]) == 3978\n assert candidate(costs = [[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]]) == 1610\n assert candidate(costs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 36\n assert candidate(costs = [[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]]) == 128\n assert candidate(costs = [[10, 1000], [15, 995], [20, 990], [25, 985], [30, 980], [35, 975], [40, 970], [45, 965], [50, 960], [55, 955], [60, 950], [65, 945], [70, 940], [75, 935], [80, 930], [85, 925], [90, 920], [95, 915], [100, 910], [105, 905]]) == 9600\n assert candidate(costs = [[900, 1000], [800, 800], [700, 900], [600, 700], [500, 600], [400, 500], [300, 400], [200, 300], [100, 200], [50, 100]]) == 4900\n assert candidate(costs = [[150, 300], [250, 200], [350, 250], [100, 200], [200, 150], [150, 250], [300, 100], [200, 350]]) == 1300\n assert candidate(costs = [[120, 600], [300, 1000], [400, 800], [500, 900], [1000, 200], [700, 750], [600, 600], [800, 500]]) == 3370\n assert candidate(costs = [[1, 999], [999, 1], [2, 998], [998, 2], [3, 997], [997, 3], [4, 996], [996, 4], [5, 995], [995, 5]]) == 30\n assert candidate(costs = [[200, 500], [300, 400], [100, 600], [250, 350], [150, 450], [50, 550], [350, 250], [600, 100]]) == 1600\n assert candidate(costs = [[123, 456], [456, 123], [789, 321], [321, 789], [234, 567], [567, 234], [890, 123], [123, 890]]) == 1602\n assert candidate(costs = [[100, 1000], [200, 900], [300, 800], [400, 700], [500, 600], [600, 500], [700, 400], [800, 300]]) == 2800\n assert candidate(costs = [[343, 819], [855, 779], [457, 60], [650, 359], [631, 42], [515, 563], [451, 713], [537, 709]]) == 3086\n assert candidate(costs = [[50, 200], [150, 100], [200, 50], [100, 150], [250, 200], [200, 250], [300, 350], [350, 300], [400, 450], [450, 400], [500, 550], [550, 500], [600, 650], [650, 600], [700, 750], [750, 700]]) == 5700\n assert candidate(costs = [[150, 200], [100, 150], [120, 170], [110, 160], [130, 180], [140, 190], [160, 210], [170, 220], [180, 230], [190, 240], [200, 250], [210, 260], [220, 270], [230, 280]]) == 2660\n assert candidate(costs = [[550, 500], [500, 550], [450, 520], [520, 450], [600, 470], [470, 600], [650, 480], [480, 650]]) == 3800\n assert candidate(costs = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80]]) == 360\n assert candidate(costs = [[500, 600], [400, 300], [200, 100], [800, 700], [600, 500], [900, 1000], [300, 400], [700, 800]]) == 4000\n assert candidate(costs = [[200, 100], [100, 200], [300, 200], [200, 300], [400, 300], [300, 400], [500, 400], [400, 500]]) == 2000\n assert candidate(costs = [[1, 999], [999, 1], [100, 900], [900, 100], [50, 950], [950, 50], [150, 850], [850, 150]]) == 602\n assert candidate(costs = [[100, 200], [200, 300], [300, 100], [400, 200], [500, 400], [600, 300], [700, 500], [800, 600], [900, 700], [1000, 800]]) == 4400\n assert candidate(costs = [[999, 1], [1, 999], [998, 2], [2, 998], [997, 3], [3, 997], [996, 4], [4, 996]]) == 20\n assert candidate(costs = [[10, 20], [30, 200], [400, 50], [30, 20], [5, 25], [35, 15], [25, 5], [15, 30], [100, 200], [300, 400], [40, 500], [50, 40]]) == 640\n assert candidate(costs = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600], [550, 650], [600, 700], [650, 750]]) == 5100\n assert candidate(costs = [[1, 1000], [1000, 1], [2, 999], [999, 2], [3, 998], [998, 3], [4, 997], [997, 4], [5, 996], [996, 5], [6, 995], [995, 6], [7, 994], [994, 7], [8, 993], [993, 8]]) == 72\n assert candidate(costs = [[800, 8], [700, 7], [600, 6], [500, 5], [400, 4], [300, 3], [200, 2], [100, 1]]) == 1026\n assert candidate(costs = [[500, 1], [1, 500], [250, 2], [2, 250], [125, 3], [3, 125], [625, 4], [4, 625]]) == 20\n assert candidate(costs = [[100, 150], [200, 250], [300, 350], [400, 450], [500, 550], [600, 650], [700, 750], [800, 850]]) == 3800\n assert candidate(costs = [[200, 300], [100, 400], [300, 200], [500, 400], [100, 500], [200, 600], [300, 300], [400, 100], [500, 200], [600, 300], [700, 400], [800, 500]]) == 3100\n assert candidate(costs = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8]]) == 1026\n assert candidate(costs = [[100, 100], [101, 99], [99, 101], [98, 102], [102, 98], [103, 97], [97, 103], [96, 104]]) == 784\n assert candidate(costs = [[50, 100], [75, 125], [25, 50], [100, 200], [150, 175], [200, 300], [350, 450], [400, 500], [450, 600], [550, 700]]) == 2600\n", "comparison": "exact"}, "public_tests": ["[[10,20],[30,200],[400,50],[30,20]]", "[[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]]", "[[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]]"], "hints": [], "metadata": {"canonical_parameter_names": ["costs"], "leetcode_dataset_entry_point": "Solution().twoCitySchedCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:22+00:00", "tests_total": 68, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "greedy", "sorting", "hungarian-algorithm", "successive-shortest-path-algorithm"]}, "language": "python", "interface": {"raw_signature": "def twoCitySchedCost(self, costs: list[list[int]]) -> int:", "container": "Solution", "callable": "twoCitySchedCost", "parameters": [{"name": "costs", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1030, "task_id": "matrix-cells-in-distance-order", "difficulty": "Easy", "problem_description": "You are given four integers row, cols, rCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter).\n\nReturn the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from the smallest distance to the largest distance. You may return the answer in any order that satisfies this condition.\n\nThe distance between two cells (r_1, c_1) and (r_2, c_2) is |r_1 - r_2| + |c_1 - c_2|.\n\nExample 1:\n\nInput: rows = 1, cols = 2, rCenter = 0, cCenter = 0\nOutput: [[0,0],[0,1]]\nExplanation: The distances from (0, 0) to other cells are: [0,1]\n\nExample 2:\n\nInput: rows = 2, cols = 2, rCenter = 0, cCenter = 1\nOutput: [[0,1],[0,0],[1,1],[1,0]]\nExplanation: The distances from (0, 1) to other cells are: [0,1,1,2]\nThe answer [[0,1],[1,1],[0,0],[1,0]] would also be accepted as correct.\n\nExample 3:\n\nInput: rows = 2, cols = 3, rCenter = 1, cCenter = 2\nOutput: [[1,2],[0,2],[1,1],[0,1],[1,0],[0,0]]\nExplanation: The distances from (1, 2) to other cells are: [0,1,1,2,2,3]\nThere are other answers that would also be accepted as correct, such as [[1,2],[1,1],[0,2],[1,0],[0,1],[0,0]].\n\nConstraints:\n\n- 1 <= rows, cols <= 100\n- 0 <= rCenter < rows\n- 0 <= cCenter < cols\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rows = 5,cols = 7,rCenter = 3,cCenter = 4) == [[3, 4], [2, 4], [3, 5], [4, 4], [3, 3], [1, 4], [2, 5], [2, 3], [3, 6], [4, 5], [4, 3], [3, 2], [0, 4], [1, 5], [1, 3], [2, 6], [2, 2], [4, 6], [4, 2], [3, 1], [0, 5], [0, 3], [1, 6], [1, 2], [2, 1], [4, 1], [3, 0], [0, 6], [0, 2], [1, 1], [2, 0], [4, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 2,cols = 3,rCenter = 1,cCenter = 2) == [[1, 2], [0, 2], [1, 1], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 3,cols = 4,rCenter = 1,cCenter = 1) == [[1, 1], [0, 1], [1, 2], [2, 1], [1, 0], [0, 2], [0, 0], [1, 3], [2, 2], [2, 0], [0, 3], [2, 3]]\n assert candidate(rows = 4,cols = 4,rCenter = 2,cCenter = 2) == [[2, 2], [1, 2], [2, 3], [3, 2], [2, 1], [0, 2], [1, 3], [1, 1], [3, 3], [3, 1], [2, 0], [0, 3], [0, 1], [1, 0], [3, 0], [0, 0]]\n assert candidate(rows = 5,cols = 5,rCenter = 2,cCenter = 2) == [[2, 2], [1, 2], [2, 3], [3, 2], [2, 1], [0, 2], [1, 3], [1, 1], [2, 4], [3, 3], [4, 2], [3, 1], [2, 0], [0, 3], [0, 1], [1, 4], [1, 0], [3, 4], [4, 3], [4, 1], [3, 0], [0, 4], [0, 0], [4, 4], [4, 0]]\n assert candidate(rows = 1,cols = 2,rCenter = 0,cCenter = 0) == [[0, 0], [0, 1]]\n assert candidate(rows = 4,cols = 4,rCenter = 0,cCenter = 0) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [0, 3], [1, 2], [2, 1], [3, 0], [1, 3], [2, 2], [3, 1], [2, 3], [3, 2], [3, 3]]\n assert candidate(rows = 3,cols = 3,rCenter = 2,cCenter = 2) == [[2, 2], [1, 2], [2, 1], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 10,cols = 10,rCenter = 5,cCenter = 5) == [[5, 5], [4, 5], [5, 6], [6, 5], [5, 4], [3, 5], [4, 6], [4, 4], [5, 7], [6, 6], [7, 5], [6, 4], [5, 3], [2, 5], [3, 6], [3, 4], [4, 7], [4, 3], [5, 8], [6, 7], [7, 6], [8, 5], [7, 4], [6, 3], [5, 2], [1, 5], [2, 6], [2, 4], [3, 7], [3, 3], [4, 8], [4, 2], [5, 9], [6, 8], [7, 7], [8, 6], [9, 5], [8, 4], [7, 3], [6, 2], [5, 1], [0, 5], [1, 6], [1, 4], [2, 7], [2, 3], [3, 8], [3, 2], [4, 9], [4, 1], [6, 9], [7, 8], [8, 7], [9, 6], [9, 4], [8, 3], [7, 2], [6, 1], [5, 0], [0, 6], [0, 4], [1, 7], [1, 3], [2, 8], [2, 2], [3, 9], [3, 1], [4, 0], [7, 9], [8, 8], [9, 7], [9, 3], [8, 2], [7, 1], [6, 0], [0, 7], [0, 3], [1, 8], [1, 2], [2, 9], [2, 1], [3, 0], [8, 9], [9, 8], [9, 2], [8, 1], [7, 0], [0, 8], [0, 2], [1, 9], [1, 1], [2, 0], [9, 9], [9, 1], [8, 0], [0, 9], [0, 1], [1, 0], [9, 0], [0, 0]]\n assert candidate(rows = 2,cols = 2,rCenter = 0,cCenter = 1) == [[0, 1], [1, 1], [0, 0], [1, 0]]\n assert candidate(rows = 3,cols = 3,rCenter = 1,cCenter = 1) == [[1, 1], [0, 1], [1, 2], [2, 1], [1, 0], [0, 2], [0, 0], [2, 2], [2, 0]]\n assert candidate(rows = 3,cols = 3,rCenter = 0,cCenter = 0) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [1, 2], [2, 1], [2, 2]]\n assert candidate(rows = 4,cols = 7,rCenter = 3,cCenter = 0) == [[3, 0], [2, 0], [3, 1], [1, 0], [2, 1], [3, 2], [0, 0], [1, 1], [2, 2], [3, 3], [0, 1], [1, 2], [2, 3], [3, 4], [0, 2], [1, 3], [2, 4], [3, 5], [0, 3], [1, 4], [2, 5], [3, 6], [0, 4], [1, 5], [2, 6], [0, 5], [1, 6], [0, 6]]\n assert candidate(rows = 50,cols = 30,rCenter = 25,cCenter = 15) == [[25, 15], [24, 15], [25, 16], [26, 15], [25, 14], [23, 15], [24, 16], [24, 14], [25, 17], [26, 16], [27, 15], [26, 14], [25, 13], [22, 15], [23, 16], [23, 14], [24, 17], [24, 13], [25, 18], [26, 17], [27, 16], [28, 15], [27, 14], [26, 13], [25, 12], [21, 15], [22, 16], [22, 14], [23, 17], [23, 13], [24, 18], [24, 12], [25, 19], [26, 18], [27, 17], [28, 16], [29, 15], [28, 14], [27, 13], [26, 12], [25, 11], [20, 15], [21, 16], [21, 14], [22, 17], [22, 13], [23, 18], [23, 12], [24, 19], [24, 11], [25, 20], [26, 19], [27, 18], [28, 17], [29, 16], [30, 15], [29, 14], [28, 13], [27, 12], [26, 11], [25, 10], [19, 15], [20, 16], [20, 14], [21, 17], [21, 13], [22, 18], [22, 12], [23, 19], [23, 11], [24, 20], [24, 10], [25, 21], [26, 20], [27, 19], [28, 18], [29, 17], [30, 16], [31, 15], [30, 14], [29, 13], [28, 12], [27, 11], [26, 10], [25, 9], [18, 15], [19, 16], [19, 14], [20, 17], [20, 13], [21, 18], [21, 12], [22, 19], [22, 11], [23, 20], [23, 10], [24, 21], [24, 9], [25, 22], [26, 21], [27, 20], [28, 19], [29, 18], [30, 17], [31, 16], [32, 15], [31, 14], [30, 13], [29, 12], [28, 11], [27, 10], [26, 9], [25, 8], [17, 15], [18, 16], [18, 14], [19, 17], [19, 13], [20, 18], [20, 12], [21, 19], [21, 11], [22, 20], [22, 10], [23, 21], [23, 9], [24, 22], [24, 8], [25, 23], [26, 22], [27, 21], [28, 20], [29, 19], [30, 18], [31, 17], [32, 16], [33, 15], [32, 14], [31, 13], [30, 12], [29, 11], [28, 10], [27, 9], [26, 8], [25, 7], [16, 15], [17, 16], [17, 14], [18, 17], [18, 13], [19, 18], [19, 12], [20, 19], [20, 11], [21, 20], [21, 10], [22, 21], [22, 9], [23, 22], [23, 8], [24, 23], [24, 7], [25, 24], [26, 23], [27, 22], [28, 21], [29, 20], [30, 19], [31, 18], [32, 17], [33, 16], [34, 15], [33, 14], [32, 13], [31, 12], [30, 11], [29, 10], [28, 9], [27, 8], [26, 7], [25, 6], [15, 15], [16, 16], [16, 14], [17, 17], [17, 13], [18, 18], [18, 12], [19, 19], [19, 11], [20, 20], [20, 10], [21, 21], [21, 9], [22, 22], [22, 8], [23, 23], [23, 7], [24, 24], [24, 6], [25, 25], [26, 24], [27, 23], [28, 22], [29, 21], [30, 20], [31, 19], [32, 18], [33, 17], [34, 16], [35, 15], [34, 14], [33, 13], [32, 12], [31, 11], [30, 10], [29, 9], [28, 8], [27, 7], [26, 6], [25, 5], [14, 15], [15, 16], [15, 14], [16, 17], [16, 13], [17, 18], [17, 12], [18, 19], [18, 11], [19, 20], [19, 10], [20, 21], [20, 9], [21, 22], [21, 8], [22, 23], [22, 7], [23, 24], [23, 6], [24, 25], [24, 5], [25, 26], [26, 25], [27, 24], [28, 23], [29, 22], [30, 21], [31, 20], [32, 19], [33, 18], [34, 17], [35, 16], [36, 15], [35, 14], [34, 13], [33, 12], [32, 11], [31, 10], [30, 9], [29, 8], [28, 7], [27, 6], [26, 5], [25, 4], [13, 15], [14, 16], [14, 14], [15, 17], [15, 13], [16, 18], [16, 12], [17, 19], [17, 11], [18, 20], [18, 10], [19, 21], [19, 9], [20, 22], [20, 8], [21, 23], [21, 7], [22, 24], [22, 6], [23, 25], [23, 5], [24, 26], [24, 4], [25, 27], [26, 26], [27, 25], [28, 24], [29, 23], [30, 22], [31, 21], [32, 20], [33, 19], [34, 18], [35, 17], [36, 16], [37, 15], [36, 14], [35, 13], [34, 12], [33, 11], [32, 10], [31, 9], [30, 8], [29, 7], [28, 6], [27, 5], [26, 4], [25, 3], [12, 15], [13, 16], [13, 14], [14, 17], [14, 13], [15, 18], [15, 12], [16, 19], [16, 11], [17, 20], [17, 10], [18, 21], [18, 9], [19, 22], [19, 8], [20, 23], [20, 7], [21, 24], [21, 6], [22, 25], [22, 5], [23, 26], [23, 4], [24, 27], [24, 3], [25, 28], [26, 27], [27, 26], [28, 25], [29, 24], [30, 23], [31, 22], [32, 21], [33, 20], [34, 19], [35, 18], [36, 17], [37, 16], [38, 15], [37, 14], [36, 13], [35, 12], [34, 11], [33, 10], [32, 9], [31, 8], [30, 7], [29, 6], [28, 5], [27, 4], [26, 3], [25, 2], [11, 15], [12, 16], [12, 14], [13, 17], [13, 13], [14, 18], [14, 12], [15, 19], [15, 11], [16, 20], [16, 10], [17, 21], [17, 9], [18, 22], [18, 8], [19, 23], [19, 7], [20, 24], [20, 6], [21, 25], [21, 5], [22, 26], [22, 4], [23, 27], [23, 3], [24, 28], [24, 2], [25, 29], [26, 28], [27, 27], [28, 26], [29, 25], [30, 24], [31, 23], [32, 22], [33, 21], [34, 20], [35, 19], [36, 18], [37, 17], [38, 16], [39, 15], [38, 14], [37, 13], [36, 12], [35, 11], [34, 10], [33, 9], [32, 8], [31, 7], [30, 6], [29, 5], [28, 4], [27, 3], [26, 2], [25, 1], [10, 15], [11, 16], [11, 14], [12, 17], [12, 13], [13, 18], [13, 12], [14, 19], [14, 11], [15, 20], [15, 10], [16, 21], [16, 9], [17, 22], [17, 8], [18, 23], [18, 7], [19, 24], [19, 6], [20, 25], [20, 5], [21, 26], [21, 4], [22, 27], [22, 3], [23, 28], [23, 2], [24, 29], [24, 1], [26, 29], [27, 28], [28, 27], [29, 26], [30, 25], [31, 24], [32, 23], [33, 22], [34, 21], [35, 20], [36, 19], [37, 18], [38, 17], [39, 16], [40, 15], [39, 14], [38, 13], [37, 12], [36, 11], [35, 10], [34, 9], [33, 8], [32, 7], [31, 6], [30, 5], [29, 4], [28, 3], [27, 2], [26, 1], [25, 0], [9, 15], [10, 16], [10, 14], [11, 17], [11, 13], [12, 18], [12, 12], [13, 19], [13, 11], [14, 20], [14, 10], [15, 21], [15, 9], [16, 22], [16, 8], [17, 23], [17, 7], [18, 24], [18, 6], [19, 25], [19, 5], [20, 26], [20, 4], [21, 27], [21, 3], [22, 28], [22, 2], [23, 29], [23, 1], [24, 0], [27, 29], [28, 28], [29, 27], [30, 26], [31, 25], [32, 24], [33, 23], [34, 22], [35, 21], [36, 20], [37, 19], [38, 18], [39, 17], [40, 16], [41, 15], [40, 14], [39, 13], [38, 12], [37, 11], [36, 10], [35, 9], [34, 8], [33, 7], [32, 6], [31, 5], [30, 4], [29, 3], [28, 2], [27, 1], [26, 0], [8, 15], [9, 16], [9, 14], [10, 17], [10, 13], [11, 18], [11, 12], [12, 19], [12, 11], [13, 20], [13, 10], [14, 21], [14, 9], [15, 22], [15, 8], [16, 23], [16, 7], [17, 24], [17, 6], [18, 25], [18, 5], [19, 26], [19, 4], [20, 27], [20, 3], [21, 28], [21, 2], [22, 29], [22, 1], [23, 0], [28, 29], [29, 28], [30, 27], [31, 26], [32, 25], [33, 24], [34, 23], [35, 22], [36, 21], [37, 20], [38, 19], [39, 18], [40, 17], [41, 16], [42, 15], [41, 14], [40, 13], [39, 12], [38, 11], [37, 10], [36, 9], [35, 8], [34, 7], [33, 6], [32, 5], [31, 4], [30, 3], [29, 2], [28, 1], [27, 0], [7, 15], [8, 16], [8, 14], [9, 17], [9, 13], [10, 18], [10, 12], [11, 19], [11, 11], [12, 20], [12, 10], [13, 21], [13, 9], [14, 22], [14, 8], [15, 23], [15, 7], [16, 24], [16, 6], [17, 25], [17, 5], [18, 26], [18, 4], [19, 27], [19, 3], [20, 28], [20, 2], [21, 29], [21, 1], [22, 0], [29, 29], [30, 28], [31, 27], [32, 26], [33, 25], [34, 24], [35, 23], [36, 22], [37, 21], [38, 20], [39, 19], [40, 18], [41, 17], [42, 16], [43, 15], [42, 14], [41, 13], [40, 12], [39, 11], [38, 10], [37, 9], [36, 8], [35, 7], [34, 6], [33, 5], [32, 4], [31, 3], [30, 2], [29, 1], [28, 0], [6, 15], [7, 16], [7, 14], [8, 17], [8, 13], [9, 18], [9, 12], [10, 19], [10, 11], [11, 20], [11, 10], [12, 21], [12, 9], [13, 22], [13, 8], [14, 23], [14, 7], [15, 24], [15, 6], [16, 25], [16, 5], [17, 26], [17, 4], [18, 27], [18, 3], [19, 28], [19, 2], [20, 29], [20, 1], [21, 0], [30, 29], [31, 28], [32, 27], [33, 26], [34, 25], [35, 24], [36, 23], [37, 22], [38, 21], [39, 20], [40, 19], [41, 18], [42, 17], [43, 16], [44, 15], [43, 14], [42, 13], [41, 12], [40, 11], [39, 10], [38, 9], [37, 8], [36, 7], [35, 6], [34, 5], [33, 4], [32, 3], [31, 2], [30, 1], [29, 0], [5, 15], [6, 16], [6, 14], [7, 17], [7, 13], [8, 18], [8, 12], [9, 19], [9, 11], [10, 20], [10, 10], [11, 21], [11, 9], [12, 22], [12, 8], [13, 23], [13, 7], [14, 24], [14, 6], [15, 25], [15, 5], [16, 26], [16, 4], [17, 27], [17, 3], [18, 28], [18, 2], [19, 29], [19, 1], [20, 0], [31, 29], [32, 28], [33, 27], [34, 26], [35, 25], [36, 24], [37, 23], [38, 22], [39, 21], [40, 20], [41, 19], [42, 18], [43, 17], [44, 16], [45, 15], [44, 14], [43, 13], [42, 12], [41, 11], [40, 10], [39, 9], [38, 8], [37, 7], [36, 6], [35, 5], [34, 4], [33, 3], [32, 2], [31, 1], [30, 0], [4, 15], [5, 16], [5, 14], [6, 17], [6, 13], [7, 18], [7, 12], [8, 19], [8, 11], [9, 20], [9, 10], [10, 21], [10, 9], [11, 22], [11, 8], [12, 23], [12, 7], [13, 24], [13, 6], [14, 25], [14, 5], [15, 26], [15, 4], [16, 27], [16, 3], [17, 28], [17, 2], [18, 29], [18, 1], [19, 0], [32, 29], [33, 28], [34, 27], [35, 26], [36, 25], [37, 24], [38, 23], [39, 22], [40, 21], [41, 20], [42, 19], [43, 18], [44, 17], [45, 16], [46, 15], [45, 14], [44, 13], [43, 12], [42, 11], [41, 10], [40, 9], [39, 8], [38, 7], [37, 6], [36, 5], [35, 4], [34, 3], [33, 2], [32, 1], [31, 0], [3, 15], [4, 16], [4, 14], [5, 17], [5, 13], [6, 18], [6, 12], [7, 19], [7, 11], [8, 20], [8, 10], [9, 21], [9, 9], [10, 22], [10, 8], [11, 23], [11, 7], [12, 24], [12, 6], [13, 25], [13, 5], [14, 26], [14, 4], [15, 27], [15, 3], [16, 28], [16, 2], [17, 29], [17, 1], [18, 0], [33, 29], [34, 28], [35, 27], [36, 26], [37, 25], [38, 24], [39, 23], [40, 22], [41, 21], [42, 20], [43, 19], [44, 18], [45, 17], [46, 16], [47, 15], [46, 14], [45, 13], [44, 12], [43, 11], [42, 10], [41, 9], [40, 8], [39, 7], [38, 6], [37, 5], [36, 4], [35, 3], [34, 2], [33, 1], [32, 0], [2, 15], [3, 16], [3, 14], [4, 17], [4, 13], [5, 18], [5, 12], [6, 19], [6, 11], [7, 20], [7, 10], [8, 21], [8, 9], [9, 22], [9, 8], [10, 23], [10, 7], [11, 24], [11, 6], [12, 25], [12, 5], [13, 26], [13, 4], [14, 27], [14, 3], [15, 28], [15, 2], [16, 29], [16, 1], [17, 0], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [39, 24], [40, 23], [41, 22], [42, 21], [43, 20], [44, 19], [45, 18], [46, 17], [47, 16], [48, 15], [47, 14], [46, 13], [45, 12], [44, 11], [43, 10], [42, 9], [41, 8], [40, 7], [39, 6], [38, 5], [37, 4], [36, 3], [35, 2], [34, 1], [33, 0], [1, 15], [2, 16], [2, 14], [3, 17], [3, 13], [4, 18], [4, 12], [5, 19], [5, 11], [6, 20], [6, 10], [7, 21], [7, 9], [8, 22], [8, 8], [9, 23], [9, 7], [10, 24], [10, 6], [11, 25], [11, 5], [12, 26], [12, 4], [13, 27], [13, 3], [14, 28], [14, 2], [15, 29], [15, 1], [16, 0], [35, 29], [36, 28], [37, 27], [38, 26], [39, 25], [40, 24], [41, 23], [42, 22], [43, 21], [44, 20], [45, 19], [46, 18], [47, 17], [48, 16], [49, 15], [48, 14], [47, 13], [46, 12], [45, 11], [44, 10], [43, 9], [42, 8], [41, 7], [40, 6], [39, 5], [38, 4], [37, 3], [36, 2], [35, 1], [34, 0], [0, 15], [1, 16], [1, 14], [2, 17], [2, 13], [3, 18], [3, 12], [4, 19], [4, 11], [5, 20], [5, 10], [6, 21], [6, 9], [7, 22], [7, 8], [8, 23], [8, 7], [9, 24], [9, 6], [10, 25], [10, 5], [11, 26], [11, 4], [12, 27], [12, 3], [13, 28], [13, 2], [14, 29], [14, 1], [15, 0], [36, 29], [37, 28], [38, 27], [39, 26], [40, 25], [41, 24], [42, 23], [43, 22], [44, 21], [45, 20], [46, 19], [47, 18], [48, 17], [49, 16], [49, 14], [48, 13], [47, 12], [46, 11], [45, 10], [44, 9], [43, 8], [42, 7], [41, 6], [40, 5], [39, 4], [38, 3], [37, 2], [36, 1], [35, 0], [0, 16], [0, 14], [1, 17], [1, 13], [2, 18], [2, 12], [3, 19], [3, 11], [4, 20], [4, 10], [5, 21], [5, 9], [6, 22], [6, 8], [7, 23], [7, 7], [8, 24], [8, 6], [9, 25], [9, 5], [10, 26], [10, 4], [11, 27], [11, 3], [12, 28], [12, 2], [13, 29], [13, 1], [14, 0], [37, 29], [38, 28], [39, 27], [40, 26], [41, 25], [42, 24], [43, 23], [44, 22], [45, 21], [46, 20], [47, 19], [48, 18], [49, 17], [49, 13], [48, 12], [47, 11], [46, 10], [45, 9], [44, 8], [43, 7], [42, 6], [41, 5], [40, 4], [39, 3], [38, 2], [37, 1], [36, 0], [0, 17], [0, 13], [1, 18], [1, 12], [2, 19], [2, 11], [3, 20], [3, 10], [4, 21], [4, 9], [5, 22], [5, 8], [6, 23], [6, 7], [7, 24], [7, 6], [8, 25], [8, 5], [9, 26], [9, 4], [10, 27], [10, 3], [11, 28], [11, 2], [12, 29], [12, 1], [13, 0], [38, 29], [39, 28], [40, 27], [41, 26], [42, 25], [43, 24], [44, 23], [45, 22], [46, 21], [47, 20], [48, 19], [49, 18], [49, 12], [48, 11], [47, 10], [46, 9], [45, 8], [44, 7], [43, 6], [42, 5], [41, 4], [40, 3], [39, 2], [38, 1], [37, 0], [0, 18], [0, 12], [1, 19], [1, 11], [2, 20], [2, 10], [3, 21], [3, 9], [4, 22], [4, 8], [5, 23], [5, 7], [6, 24], [6, 6], [7, 25], [7, 5], [8, 26], [8, 4], [9, 27], [9, 3], [10, 28], [10, 2], [11, 29], [11, 1], [12, 0], [39, 29], [40, 28], [41, 27], [42, 26], [43, 25], [44, 24], [45, 23], [46, 22], [47, 21], [48, 20], [49, 19], [49, 11], [48, 10], [47, 9], [46, 8], [45, 7], [44, 6], [43, 5], [42, 4], [41, 3], [40, 2], [39, 1], [38, 0], [0, 19], [0, 11], [1, 20], [1, 10], [2, 21], [2, 9], [3, 22], [3, 8], [4, 23], [4, 7], [5, 24], [5, 6], [6, 25], [6, 5], [7, 26], [7, 4], [8, 27], [8, 3], [9, 28], [9, 2], [10, 29], [10, 1], [11, 0], [40, 29], [41, 28], [42, 27], [43, 26], [44, 25], [45, 24], [46, 23], [47, 22], [48, 21], [49, 20], [49, 10], [48, 9], [47, 8], [46, 7], [45, 6], [44, 5], [43, 4], [42, 3], [41, 2], [40, 1], [39, 0], [0, 20], [0, 10], [1, 21], [1, 9], [2, 22], [2, 8], [3, 23], [3, 7], [4, 24], [4, 6], [5, 25], [5, 5], [6, 26], [6, 4], [7, 27], [7, 3], [8, 28], [8, 2], [9, 29], [9, 1], [10, 0], [41, 29], [42, 28], [43, 27], [44, 26], [45, 25], [46, 24], [47, 23], [48, 22], [49, 21], [49, 9], [48, 8], [47, 7], [46, 6], [45, 5], [44, 4], [43, 3], [42, 2], [41, 1], [40, 0], [0, 21], [0, 9], [1, 22], [1, 8], [2, 23], [2, 7], [3, 24], [3, 6], [4, 25], [4, 5], [5, 26], [5, 4], [6, 27], [6, 3], [7, 28], [7, 2], [8, 29], [8, 1], [9, 0], [42, 29], [43, 28], [44, 27], [45, 26], [46, 25], [47, 24], [48, 23], [49, 22], [49, 8], [48, 7], [47, 6], [46, 5], [45, 4], [44, 3], [43, 2], [42, 1], [41, 0], [0, 22], [0, 8], [1, 23], [1, 7], [2, 24], [2, 6], [3, 25], [3, 5], [4, 26], [4, 4], [5, 27], [5, 3], [6, 28], [6, 2], [7, 29], [7, 1], [8, 0], [43, 29], [44, 28], [45, 27], [46, 26], [47, 25], [48, 24], [49, 23], [49, 7], [48, 6], [47, 5], [46, 4], [45, 3], [44, 2], [43, 1], [42, 0], [0, 23], [0, 7], [1, 24], [1, 6], [2, 25], [2, 5], [3, 26], [3, 4], [4, 27], [4, 3], [5, 28], [5, 2], [6, 29], [6, 1], [7, 0], [44, 29], [45, 28], [46, 27], [47, 26], [48, 25], [49, 24], [49, 6], [48, 5], [47, 4], [46, 3], [45, 2], [44, 1], [43, 0], [0, 24], [0, 6], [1, 25], [1, 5], [2, 26], [2, 4], [3, 27], [3, 3], [4, 28], [4, 2], [5, 29], [5, 1], [6, 0], [45, 29], [46, 28], [47, 27], [48, 26], [49, 25], [49, 5], [48, 4], [47, 3], [46, 2], [45, 1], [44, 0], [0, 25], [0, 5], [1, 26], [1, 4], [2, 27], [2, 3], [3, 28], [3, 2], [4, 29], [4, 1], [5, 0], [46, 29], [47, 28], [48, 27], [49, 26], [49, 4], [48, 3], [47, 2], [46, 1], [45, 0], [0, 26], [0, 4], [1, 27], [1, 3], [2, 28], [2, 2], [3, 29], [3, 1], [4, 0], [47, 29], [48, 28], [49, 27], [49, 3], [48, 2], [47, 1], [46, 0], [0, 27], [0, 3], [1, 28], [1, 2], [2, 29], [2, 1], [3, 0], [48, 29], [49, 28], [49, 2], [48, 1], [47, 0], [0, 28], [0, 2], [1, 29], [1, 1], [2, 0], [49, 29], [49, 1], [48, 0], [0, 29], [0, 1], [1, 0], [49, 0], [0, 0]]\n assert candidate(rows = 6,cols = 6,rCenter = 3,cCenter = 0) == [[3, 0], [2, 0], [3, 1], [4, 0], [1, 0], [2, 1], [3, 2], [4, 1], [5, 0], [0, 0], [1, 1], [2, 2], [3, 3], [4, 2], [5, 1], [0, 1], [1, 2], [2, 3], [3, 4], [4, 3], [5, 2], [0, 2], [1, 3], [2, 4], [3, 5], [4, 4], [5, 3], [0, 3], [1, 4], [2, 5], [4, 5], [5, 4], [0, 4], [1, 5], [5, 5], [0, 5]]\n assert candidate(rows = 40,cols = 40,rCenter = 0,cCenter = 0) == [[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], [5, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0], [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], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [11, 2], [12, 1], [13, 0], [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, 0], [0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [8, 7], [9, 6], [10, 5], [11, 4], [12, 3], [13, 2], [14, 1], [15, 0], [0, 16], [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, 0], [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], [0, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [9, 9], [10, 8], [11, 7], [12, 6], [13, 5], [14, 4], [15, 3], [16, 2], [17, 1], [18, 0], [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], [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], [20, 0], [0, 21], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1], [21, 0], [0, 22], [1, 21], [2, 20], [3, 19], [4, 18], [5, 17], [6, 16], [7, 15], [8, 14], [9, 13], [10, 12], [11, 11], [12, 10], [13, 9], [14, 8], [15, 7], [16, 6], [17, 5], [18, 4], [19, 3], [20, 2], [21, 1], [22, 0], [0, 23], [1, 22], [2, 21], [3, 20], [4, 19], [5, 18], [6, 17], [7, 16], [8, 15], [9, 14], [10, 13], [11, 12], [12, 11], [13, 10], [14, 9], [15, 8], [16, 7], [17, 6], [18, 5], [19, 4], [20, 3], [21, 2], [22, 1], [23, 0], [0, 24], [1, 23], [2, 22], [3, 21], [4, 20], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15], [10, 14], [11, 13], [12, 12], [13, 11], [14, 10], [15, 9], [16, 8], [17, 7], [18, 6], [19, 5], [20, 4], [21, 3], [22, 2], [23, 1], [24, 0], [0, 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], [13, 12], [14, 11], [15, 10], [16, 9], [17, 8], [18, 7], [19, 6], [20, 5], [21, 4], [22, 3], [23, 2], [24, 1], [25, 0], [0, 26], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [13, 13], [14, 12], [15, 11], [16, 10], [17, 9], [18, 8], [19, 7], [20, 6], [21, 5], [22, 4], [23, 3], [24, 2], [25, 1], [26, 0], [0, 27], [1, 26], [2, 25], [3, 24], [4, 23], [5, 22], [6, 21], [7, 20], [8, 19], [9, 18], [10, 17], [11, 16], [12, 15], [13, 14], [14, 13], [15, 12], [16, 11], [17, 10], [18, 9], [19, 8], [20, 7], [21, 6], [22, 5], [23, 4], [24, 3], [25, 2], [26, 1], [27, 0], [0, 28], [1, 27], [2, 26], [3, 25], [4, 24], [5, 23], [6, 22], [7, 21], [8, 20], [9, 19], [10, 18], [11, 17], [12, 16], [13, 15], [14, 14], [15, 13], [16, 12], [17, 11], [18, 10], [19, 9], [20, 8], [21, 7], [22, 6], [23, 5], [24, 4], [25, 3], [26, 2], [27, 1], [28, 0], [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], [15, 14], [16, 13], [17, 12], [18, 11], [19, 10], [20, 9], [21, 8], [22, 7], [23, 6], [24, 5], [25, 4], [26, 3], [27, 2], [28, 1], [29, 0], [0, 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, 15], [16, 14], [17, 13], [18, 12], [19, 11], [20, 10], [21, 9], [22, 8], [23, 7], [24, 6], [25, 5], [26, 4], [27, 3], [28, 2], [29, 1], [30, 0], [0, 31], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16], [16, 15], [17, 14], [18, 13], [19, 12], [20, 11], [21, 10], [22, 9], [23, 8], [24, 7], [25, 6], [26, 5], [27, 4], [28, 3], [29, 2], [30, 1], [31, 0], [0, 32], [1, 31], [2, 30], [3, 29], [4, 28], [5, 27], [6, 26], [7, 25], [8, 24], [9, 23], [10, 22], [11, 21], [12, 20], [13, 19], [14, 18], [15, 17], [16, 16], [17, 15], [18, 14], [19, 13], [20, 12], [21, 11], [22, 10], [23, 9], [24, 8], [25, 7], [26, 6], [27, 5], [28, 4], [29, 3], [30, 2], [31, 1], [32, 0], [0, 33], [1, 32], [2, 31], [3, 30], [4, 29], [5, 28], [6, 27], [7, 26], [8, 25], [9, 24], [10, 23], [11, 22], [12, 21], [13, 20], [14, 19], [15, 18], [16, 17], [17, 16], [18, 15], [19, 14], [20, 13], [21, 12], [22, 11], [23, 10], [24, 9], [25, 8], [26, 7], [27, 6], [28, 5], [29, 4], [30, 3], [31, 2], [32, 1], [33, 0], [0, 34], [1, 33], [2, 32], [3, 31], [4, 30], [5, 29], [6, 28], [7, 27], [8, 26], [9, 25], [10, 24], [11, 23], [12, 22], [13, 21], [14, 20], [15, 19], [16, 18], [17, 17], [18, 16], [19, 15], [20, 14], [21, 13], [22, 12], [23, 11], [24, 10], [25, 9], [26, 8], [27, 7], [28, 6], [29, 5], [30, 4], [31, 3], [32, 2], [33, 1], [34, 0], [0, 35], [1, 34], [2, 33], [3, 32], [4, 31], [5, 30], [6, 29], [7, 28], [8, 27], [9, 26], [10, 25], [11, 24], [12, 23], [13, 22], [14, 21], [15, 20], [16, 19], [17, 18], [18, 17], [19, 16], [20, 15], [21, 14], [22, 13], [23, 12], [24, 11], [25, 10], [26, 9], [27, 8], [28, 7], [29, 6], [30, 5], [31, 4], [32, 3], [33, 2], [34, 1], [35, 0], [0, 36], [1, 35], [2, 34], [3, 33], [4, 32], [5, 31], [6, 30], [7, 29], [8, 28], [9, 27], [10, 26], [11, 25], [12, 24], [13, 23], [14, 22], [15, 21], [16, 20], [17, 19], [18, 18], [19, 17], [20, 16], [21, 15], [22, 14], [23, 13], [24, 12], [25, 11], [26, 10], [27, 9], [28, 8], [29, 7], [30, 6], [31, 5], [32, 4], [33, 3], [34, 2], [35, 1], [36, 0], [0, 37], [1, 36], [2, 35], [3, 34], [4, 33], [5, 32], [6, 31], [7, 30], [8, 29], [9, 28], [10, 27], [11, 26], [12, 25], [13, 24], [14, 23], [15, 22], [16, 21], [17, 20], [18, 19], [19, 18], [20, 17], [21, 16], [22, 15], [23, 14], [24, 13], [25, 12], [26, 11], [27, 10], [28, 9], [29, 8], [30, 7], [31, 6], [32, 5], [33, 4], [34, 3], [35, 2], [36, 1], [37, 0], [0, 38], [1, 37], [2, 36], [3, 35], [4, 34], [5, 33], [6, 32], [7, 31], [8, 30], [9, 29], [10, 28], [11, 27], [12, 26], [13, 25], [14, 24], [15, 23], [16, 22], [17, 21], [18, 20], [19, 19], [20, 18], [21, 17], [22, 16], [23, 15], [24, 14], [25, 13], [26, 12], [27, 11], [28, 10], [29, 9], [30, 8], [31, 7], [32, 6], [33, 5], [34, 4], [35, 3], [36, 2], [37, 1], [38, 0], [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], [20, 19], [21, 18], [22, 17], [23, 16], [24, 15], [25, 14], [26, 13], [27, 12], [28, 11], [29, 10], [30, 9], [31, 8], [32, 7], [33, 6], [34, 5], [35, 4], [36, 3], [37, 2], [38, 1], [39, 0], [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, 20], [21, 19], [22, 18], [23, 17], [24, 16], [25, 15], [26, 14], [27, 13], [28, 12], [29, 11], [30, 10], [31, 9], [32, 8], [33, 7], [34, 6], [35, 5], [36, 4], [37, 3], [38, 2], [39, 1], [2, 39], [3, 38], [4, 37], [5, 36], [6, 35], [7, 34], [8, 33], [9, 32], [10, 31], [11, 30], [12, 29], [13, 28], [14, 27], [15, 26], [16, 25], [17, 24], [18, 23], [19, 22], [20, 21], [21, 20], [22, 19], [23, 18], [24, 17], [25, 16], [26, 15], [27, 14], [28, 13], [29, 12], [30, 11], [31, 10], [32, 9], [33, 8], [34, 7], [35, 6], [36, 5], [37, 4], [38, 3], [39, 2], [3, 39], [4, 38], [5, 37], [6, 36], [7, 35], [8, 34], [9, 33], [10, 32], [11, 31], [12, 30], [13, 29], [14, 28], [15, 27], [16, 26], [17, 25], [18, 24], [19, 23], [20, 22], [21, 21], [22, 20], [23, 19], [24, 18], [25, 17], [26, 16], [27, 15], [28, 14], [29, 13], [30, 12], [31, 11], [32, 10], [33, 9], [34, 8], [35, 7], [36, 6], [37, 5], [38, 4], [39, 3], [4, 39], [5, 38], [6, 37], [7, 36], [8, 35], [9, 34], [10, 33], [11, 32], [12, 31], [13, 30], [14, 29], [15, 28], [16, 27], [17, 26], [18, 25], [19, 24], [20, 23], [21, 22], [22, 21], [23, 20], [24, 19], [25, 18], [26, 17], [27, 16], [28, 15], [29, 14], [30, 13], [31, 12], [32, 11], [33, 10], [34, 9], [35, 8], [36, 7], [37, 6], [38, 5], [39, 4], [5, 39], [6, 38], [7, 37], [8, 36], [9, 35], [10, 34], [11, 33], [12, 32], [13, 31], [14, 30], [15, 29], [16, 28], [17, 27], [18, 26], [19, 25], [20, 24], [21, 23], [22, 22], [23, 21], [24, 20], [25, 19], [26, 18], [27, 17], [28, 16], [29, 15], [30, 14], [31, 13], [32, 12], [33, 11], [34, 10], [35, 9], [36, 8], [37, 7], [38, 6], [39, 5], [6, 39], [7, 38], [8, 37], [9, 36], [10, 35], [11, 34], [12, 33], [13, 32], [14, 31], [15, 30], [16, 29], [17, 28], [18, 27], [19, 26], [20, 25], [21, 24], [22, 23], [23, 22], [24, 21], [25, 20], [26, 19], [27, 18], [28, 17], [29, 16], [30, 15], [31, 14], [32, 13], [33, 12], [34, 11], [35, 10], [36, 9], [37, 8], [38, 7], [39, 6], [7, 39], [8, 38], [9, 37], [10, 36], [11, 35], [12, 34], [13, 33], [14, 32], [15, 31], [16, 30], [17, 29], [18, 28], [19, 27], [20, 26], [21, 25], [22, 24], [23, 23], [24, 22], [25, 21], [26, 20], [27, 19], [28, 18], [29, 17], [30, 16], [31, 15], [32, 14], [33, 13], [34, 12], [35, 11], [36, 10], [37, 9], [38, 8], [39, 7], [8, 39], [9, 38], [10, 37], [11, 36], [12, 35], [13, 34], [14, 33], [15, 32], [16, 31], [17, 30], [18, 29], [19, 28], [20, 27], [21, 26], [22, 25], [23, 24], [24, 23], [25, 22], [26, 21], [27, 20], [28, 19], [29, 18], [30, 17], [31, 16], [32, 15], [33, 14], [34, 13], [35, 12], [36, 11], [37, 10], [38, 9], [39, 8], [9, 39], [10, 38], [11, 37], [12, 36], [13, 35], [14, 34], [15, 33], [16, 32], [17, 31], [18, 30], [19, 29], [20, 28], [21, 27], [22, 26], [23, 25], [24, 24], [25, 23], [26, 22], [27, 21], [28, 20], [29, 19], [30, 18], [31, 17], [32, 16], [33, 15], [34, 14], [35, 13], [36, 12], [37, 11], [38, 10], [39, 9], [10, 39], [11, 38], [12, 37], [13, 36], [14, 35], [15, 34], [16, 33], [17, 32], [18, 31], [19, 30], [20, 29], [21, 28], [22, 27], [23, 26], [24, 25], [25, 24], [26, 23], [27, 22], [28, 21], [29, 20], [30, 19], [31, 18], [32, 17], [33, 16], [34, 15], [35, 14], [36, 13], [37, 12], [38, 11], [39, 10], [11, 39], [12, 38], [13, 37], [14, 36], [15, 35], [16, 34], [17, 33], [18, 32], [19, 31], [20, 30], [21, 29], [22, 28], [23, 27], [24, 26], [25, 25], [26, 24], [27, 23], [28, 22], [29, 21], [30, 20], [31, 19], [32, 18], [33, 17], [34, 16], [35, 15], [36, 14], [37, 13], [38, 12], [39, 11], [12, 39], [13, 38], [14, 37], [15, 36], [16, 35], [17, 34], [18, 33], [19, 32], [20, 31], [21, 30], [22, 29], [23, 28], [24, 27], [25, 26], [26, 25], [27, 24], [28, 23], [29, 22], [30, 21], [31, 20], [32, 19], [33, 18], [34, 17], [35, 16], [36, 15], [37, 14], [38, 13], [39, 12], [13, 39], [14, 38], [15, 37], [16, 36], [17, 35], [18, 34], [19, 33], [20, 32], [21, 31], [22, 30], [23, 29], [24, 28], [25, 27], [26, 26], [27, 25], [28, 24], [29, 23], [30, 22], [31, 21], [32, 20], [33, 19], [34, 18], [35, 17], [36, 16], [37, 15], [38, 14], [39, 13], [14, 39], [15, 38], [16, 37], [17, 36], [18, 35], [19, 34], [20, 33], [21, 32], [22, 31], [23, 30], [24, 29], [25, 28], [26, 27], [27, 26], [28, 25], [29, 24], [30, 23], [31, 22], [32, 21], [33, 20], [34, 19], [35, 18], [36, 17], [37, 16], [38, 15], [39, 14], [15, 39], [16, 38], [17, 37], [18, 36], [19, 35], [20, 34], [21, 33], [22, 32], [23, 31], [24, 30], [25, 29], [26, 28], [27, 27], [28, 26], [29, 25], [30, 24], [31, 23], [32, 22], [33, 21], [34, 20], [35, 19], [36, 18], [37, 17], [38, 16], [39, 15], [16, 39], [17, 38], [18, 37], [19, 36], [20, 35], [21, 34], [22, 33], [23, 32], [24, 31], [25, 30], [26, 29], [27, 28], [28, 27], [29, 26], [30, 25], [31, 24], [32, 23], [33, 22], [34, 21], [35, 20], [36, 19], [37, 18], [38, 17], [39, 16], [17, 39], [18, 38], [19, 37], [20, 36], [21, 35], [22, 34], [23, 33], [24, 32], [25, 31], [26, 30], [27, 29], [28, 28], [29, 27], [30, 26], [31, 25], [32, 24], [33, 23], [34, 22], [35, 21], [36, 20], [37, 19], [38, 18], [39, 17], [18, 39], [19, 38], [20, 37], [21, 36], [22, 35], [23, 34], [24, 33], [25, 32], [26, 31], [27, 30], [28, 29], [29, 28], [30, 27], [31, 26], [32, 25], [33, 24], [34, 23], [35, 22], [36, 21], [37, 20], [38, 19], [39, 18], [19, 39], [20, 38], [21, 37], [22, 36], [23, 35], [24, 34], [25, 33], [26, 32], [27, 31], [28, 30], [29, 29], [30, 28], [31, 27], [32, 26], [33, 25], [34, 24], [35, 23], [36, 22], [37, 21], [38, 20], [39, 19], [20, 39], [21, 38], [22, 37], [23, 36], [24, 35], [25, 34], [26, 33], [27, 32], [28, 31], [29, 30], [30, 29], [31, 28], [32, 27], [33, 26], [34, 25], [35, 24], [36, 23], [37, 22], [38, 21], [39, 20], [21, 39], [22, 38], [23, 37], [24, 36], [25, 35], [26, 34], [27, 33], [28, 32], [29, 31], [30, 30], [31, 29], [32, 28], [33, 27], [34, 26], [35, 25], [36, 24], [37, 23], [38, 22], [39, 21], [22, 39], [23, 38], [24, 37], [25, 36], [26, 35], [27, 34], [28, 33], [29, 32], [30, 31], [31, 30], [32, 29], [33, 28], [34, 27], [35, 26], [36, 25], [37, 24], [38, 23], [39, 22], [23, 39], [24, 38], [25, 37], [26, 36], [27, 35], [28, 34], [29, 33], [30, 32], [31, 31], [32, 30], [33, 29], [34, 28], [35, 27], [36, 26], [37, 25], [38, 24], [39, 23], [24, 39], [25, 38], [26, 37], [27, 36], [28, 35], [29, 34], [30, 33], [31, 32], [32, 31], [33, 30], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [39, 24], [25, 39], [26, 38], [27, 37], [28, 36], [29, 35], [30, 34], [31, 33], [32, 32], [33, 31], [34, 30], [35, 29], [36, 28], [37, 27], [38, 26], [39, 25], [26, 39], [27, 38], [28, 37], [29, 36], [30, 35], [31, 34], [32, 33], [33, 32], [34, 31], [35, 30], [36, 29], [37, 28], [38, 27], [39, 26], [27, 39], [28, 38], [29, 37], [30, 36], [31, 35], [32, 34], [33, 33], [34, 32], [35, 31], [36, 30], [37, 29], [38, 28], [39, 27], [28, 39], [29, 38], [30, 37], [31, 36], [32, 35], [33, 34], [34, 33], [35, 32], [36, 31], [37, 30], [38, 29], [39, 28], [29, 39], [30, 38], [31, 37], [32, 36], [33, 35], [34, 34], [35, 33], [36, 32], [37, 31], [38, 30], [39, 29], [30, 39], [31, 38], [32, 37], [33, 36], [34, 35], [35, 34], [36, 33], [37, 32], [38, 31], [39, 30], [31, 39], [32, 38], [33, 37], [34, 36], [35, 35], [36, 34], [37, 33], [38, 32], [39, 31], [32, 39], [33, 38], [34, 37], [35, 36], [36, 35], [37, 34], [38, 33], [39, 32], [33, 39], [34, 38], [35, 37], [36, 36], [37, 35], [38, 34], [39, 33], [34, 39], [35, 38], [36, 37], [37, 36], [38, 35], [39, 34], [35, 39], [36, 38], [37, 37], [38, 36], [39, 35], [36, 39], [37, 38], [38, 37], [39, 36], [37, 39], [38, 38], [39, 37], [38, 39], [39, 38], [39, 39]]\n assert candidate(rows = 8,cols = 3,rCenter = 0,cCenter = 0) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [1, 2], [2, 1], [3, 0], [2, 2], [3, 1], [4, 0], [3, 2], [4, 1], [5, 0], [4, 2], [5, 1], [6, 0], [5, 2], [6, 1], [7, 0], [6, 2], [7, 1], [7, 2]]\n assert candidate(rows = 7,cols = 7,rCenter = 0,cCenter = 6) == [[0, 6], [1, 6], [0, 5], [2, 6], [1, 5], [0, 4], [3, 6], [2, 5], [1, 4], [0, 3], [4, 6], [3, 5], [2, 4], [1, 3], [0, 2], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2], [0, 1], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0], [6, 4], [5, 3], [4, 2], [3, 1], [2, 0], [6, 3], [5, 2], [4, 1], [3, 0], [6, 2], [5, 1], [4, 0], [6, 1], [5, 0], [6, 0]]\n assert candidate(rows = 1,cols = 100,rCenter = 0,cCenter = 50) == [[0, 50], [0, 51], [0, 49], [0, 52], [0, 48], [0, 53], [0, 47], [0, 54], [0, 46], [0, 55], [0, 45], [0, 56], [0, 44], [0, 57], [0, 43], [0, 58], [0, 42], [0, 59], [0, 41], [0, 60], [0, 40], [0, 61], [0, 39], [0, 62], [0, 38], [0, 63], [0, 37], [0, 64], [0, 36], [0, 65], [0, 35], [0, 66], [0, 34], [0, 67], [0, 33], [0, 68], [0, 32], [0, 69], [0, 31], [0, 70], [0, 30], [0, 71], [0, 29], [0, 72], [0, 28], [0, 73], [0, 27], [0, 74], [0, 26], [0, 75], [0, 25], [0, 76], [0, 24], [0, 77], [0, 23], [0, 78], [0, 22], [0, 79], [0, 21], [0, 80], [0, 20], [0, 81], [0, 19], [0, 82], [0, 18], [0, 83], [0, 17], [0, 84], [0, 16], [0, 85], [0, 15], [0, 86], [0, 14], [0, 87], [0, 13], [0, 88], [0, 12], [0, 89], [0, 11], [0, 90], [0, 10], [0, 91], [0, 9], [0, 92], [0, 8], [0, 93], [0, 7], [0, 94], [0, 6], [0, 95], [0, 5], [0, 96], [0, 4], [0, 97], [0, 3], [0, 98], [0, 2], [0, 99], [0, 1], [0, 0]]\n assert candidate(rows = 5,cols = 5,rCenter = 4,cCenter = 4) == [[4, 4], [3, 4], [4, 3], [2, 4], [3, 3], [4, 2], [1, 4], [2, 3], [3, 2], [4, 1], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 9,cols = 4,rCenter = 4,cCenter = 3) == [[4, 3], [3, 3], [5, 3], [4, 2], [2, 3], [3, 2], [6, 3], [5, 2], [4, 1], [1, 3], [2, 2], [3, 1], [7, 3], [6, 2], [5, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [8, 3], [7, 2], [6, 1], [5, 0], [0, 2], [1, 1], [2, 0], [8, 2], [7, 1], [6, 0], [0, 1], [1, 0], [8, 1], [7, 0], [0, 0], [8, 0]]\n assert candidate(rows = 50,cols = 50,rCenter = 25,cCenter = 25) == [[25, 25], [24, 25], [25, 26], [26, 25], [25, 24], [23, 25], [24, 26], [24, 24], [25, 27], [26, 26], [27, 25], [26, 24], [25, 23], [22, 25], [23, 26], [23, 24], [24, 27], [24, 23], [25, 28], [26, 27], [27, 26], [28, 25], [27, 24], [26, 23], [25, 22], [21, 25], [22, 26], [22, 24], [23, 27], [23, 23], [24, 28], [24, 22], [25, 29], [26, 28], [27, 27], [28, 26], [29, 25], [28, 24], [27, 23], [26, 22], [25, 21], [20, 25], [21, 26], [21, 24], [22, 27], [22, 23], [23, 28], [23, 22], [24, 29], [24, 21], [25, 30], [26, 29], [27, 28], [28, 27], [29, 26], [30, 25], [29, 24], [28, 23], [27, 22], [26, 21], [25, 20], [19, 25], [20, 26], [20, 24], [21, 27], [21, 23], [22, 28], [22, 22], [23, 29], [23, 21], [24, 30], [24, 20], [25, 31], [26, 30], [27, 29], [28, 28], [29, 27], [30, 26], [31, 25], [30, 24], [29, 23], [28, 22], [27, 21], [26, 20], [25, 19], [18, 25], [19, 26], [19, 24], [20, 27], [20, 23], [21, 28], [21, 22], [22, 29], [22, 21], [23, 30], [23, 20], [24, 31], [24, 19], [25, 32], [26, 31], [27, 30], [28, 29], [29, 28], [30, 27], [31, 26], [32, 25], [31, 24], [30, 23], [29, 22], [28, 21], [27, 20], [26, 19], [25, 18], [17, 25], [18, 26], [18, 24], [19, 27], [19, 23], [20, 28], [20, 22], [21, 29], [21, 21], [22, 30], [22, 20], [23, 31], [23, 19], [24, 32], [24, 18], [25, 33], [26, 32], [27, 31], [28, 30], [29, 29], [30, 28], [31, 27], [32, 26], [33, 25], [32, 24], [31, 23], [30, 22], [29, 21], [28, 20], [27, 19], [26, 18], [25, 17], [16, 25], [17, 26], [17, 24], [18, 27], [18, 23], [19, 28], [19, 22], [20, 29], [20, 21], [21, 30], [21, 20], [22, 31], [22, 19], [23, 32], [23, 18], [24, 33], [24, 17], [25, 34], [26, 33], [27, 32], [28, 31], [29, 30], [30, 29], [31, 28], [32, 27], [33, 26], [34, 25], [33, 24], [32, 23], [31, 22], [30, 21], [29, 20], [28, 19], [27, 18], [26, 17], [25, 16], [15, 25], [16, 26], [16, 24], [17, 27], [17, 23], [18, 28], [18, 22], [19, 29], [19, 21], [20, 30], [20, 20], [21, 31], [21, 19], [22, 32], [22, 18], [23, 33], [23, 17], [24, 34], [24, 16], [25, 35], [26, 34], [27, 33], [28, 32], [29, 31], [30, 30], [31, 29], [32, 28], [33, 27], [34, 26], [35, 25], [34, 24], [33, 23], [32, 22], [31, 21], [30, 20], [29, 19], [28, 18], [27, 17], [26, 16], [25, 15], [14, 25], [15, 26], [15, 24], [16, 27], [16, 23], [17, 28], [17, 22], [18, 29], [18, 21], [19, 30], [19, 20], [20, 31], [20, 19], [21, 32], [21, 18], [22, 33], [22, 17], [23, 34], [23, 16], [24, 35], [24, 15], [25, 36], [26, 35], [27, 34], [28, 33], [29, 32], [30, 31], [31, 30], [32, 29], [33, 28], [34, 27], [35, 26], [36, 25], [35, 24], [34, 23], [33, 22], [32, 21], [31, 20], [30, 19], [29, 18], [28, 17], [27, 16], [26, 15], [25, 14], [13, 25], [14, 26], [14, 24], [15, 27], [15, 23], [16, 28], [16, 22], [17, 29], [17, 21], [18, 30], [18, 20], [19, 31], [19, 19], [20, 32], [20, 18], [21, 33], [21, 17], [22, 34], [22, 16], [23, 35], [23, 15], [24, 36], [24, 14], [25, 37], [26, 36], [27, 35], [28, 34], [29, 33], [30, 32], [31, 31], [32, 30], [33, 29], [34, 28], [35, 27], [36, 26], [37, 25], [36, 24], [35, 23], [34, 22], [33, 21], [32, 20], [31, 19], [30, 18], [29, 17], [28, 16], [27, 15], [26, 14], [25, 13], [12, 25], [13, 26], [13, 24], [14, 27], [14, 23], [15, 28], [15, 22], [16, 29], [16, 21], [17, 30], [17, 20], [18, 31], [18, 19], [19, 32], [19, 18], [20, 33], [20, 17], [21, 34], [21, 16], [22, 35], [22, 15], [23, 36], [23, 14], [24, 37], [24, 13], [25, 38], [26, 37], [27, 36], [28, 35], [29, 34], [30, 33], [31, 32], [32, 31], [33, 30], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [37, 24], [36, 23], [35, 22], [34, 21], [33, 20], [32, 19], [31, 18], [30, 17], [29, 16], [28, 15], [27, 14], [26, 13], [25, 12], [11, 25], [12, 26], [12, 24], [13, 27], [13, 23], [14, 28], [14, 22], [15, 29], [15, 21], [16, 30], [16, 20], [17, 31], [17, 19], [18, 32], [18, 18], [19, 33], [19, 17], [20, 34], [20, 16], [21, 35], [21, 15], [22, 36], [22, 14], [23, 37], [23, 13], [24, 38], [24, 12], [25, 39], [26, 38], [27, 37], [28, 36], [29, 35], [30, 34], [31, 33], [32, 32], [33, 31], [34, 30], [35, 29], [36, 28], [37, 27], [38, 26], [39, 25], [38, 24], [37, 23], [36, 22], [35, 21], [34, 20], [33, 19], [32, 18], [31, 17], [30, 16], [29, 15], [28, 14], [27, 13], [26, 12], [25, 11], [10, 25], [11, 26], [11, 24], [12, 27], [12, 23], [13, 28], [13, 22], [14, 29], [14, 21], [15, 30], [15, 20], [16, 31], [16, 19], [17, 32], [17, 18], [18, 33], [18, 17], [19, 34], [19, 16], [20, 35], [20, 15], [21, 36], [21, 14], [22, 37], [22, 13], [23, 38], [23, 12], [24, 39], [24, 11], [25, 40], [26, 39], [27, 38], [28, 37], [29, 36], [30, 35], [31, 34], [32, 33], [33, 32], [34, 31], [35, 30], [36, 29], [37, 28], [38, 27], [39, 26], [40, 25], [39, 24], [38, 23], [37, 22], [36, 21], [35, 20], [34, 19], [33, 18], [32, 17], [31, 16], [30, 15], [29, 14], [28, 13], [27, 12], [26, 11], [25, 10], [9, 25], [10, 26], [10, 24], [11, 27], [11, 23], [12, 28], [12, 22], [13, 29], [13, 21], [14, 30], [14, 20], [15, 31], [15, 19], [16, 32], [16, 18], [17, 33], [17, 17], [18, 34], [18, 16], [19, 35], [19, 15], [20, 36], [20, 14], [21, 37], [21, 13], [22, 38], [22, 12], [23, 39], [23, 11], [24, 40], [24, 10], [25, 41], [26, 40], [27, 39], [28, 38], [29, 37], [30, 36], [31, 35], [32, 34], [33, 33], [34, 32], [35, 31], [36, 30], [37, 29], [38, 28], [39, 27], [40, 26], [41, 25], [40, 24], [39, 23], [38, 22], [37, 21], [36, 20], [35, 19], [34, 18], [33, 17], [32, 16], [31, 15], [30, 14], [29, 13], [28, 12], [27, 11], [26, 10], [25, 9], [8, 25], [9, 26], [9, 24], [10, 27], [10, 23], [11, 28], [11, 22], [12, 29], [12, 21], [13, 30], [13, 20], [14, 31], [14, 19], [15, 32], [15, 18], [16, 33], [16, 17], [17, 34], [17, 16], [18, 35], [18, 15], [19, 36], [19, 14], [20, 37], [20, 13], [21, 38], [21, 12], [22, 39], [22, 11], [23, 40], [23, 10], [24, 41], [24, 9], [25, 42], [26, 41], [27, 40], [28, 39], [29, 38], [30, 37], [31, 36], [32, 35], [33, 34], [34, 33], [35, 32], [36, 31], [37, 30], [38, 29], [39, 28], [40, 27], [41, 26], [42, 25], [41, 24], [40, 23], [39, 22], [38, 21], [37, 20], [36, 19], [35, 18], [34, 17], [33, 16], [32, 15], [31, 14], [30, 13], [29, 12], [28, 11], [27, 10], [26, 9], [25, 8], [7, 25], [8, 26], [8, 24], [9, 27], [9, 23], [10, 28], [10, 22], [11, 29], [11, 21], [12, 30], [12, 20], [13, 31], [13, 19], [14, 32], [14, 18], [15, 33], [15, 17], [16, 34], [16, 16], [17, 35], [17, 15], [18, 36], [18, 14], [19, 37], [19, 13], [20, 38], [20, 12], [21, 39], [21, 11], [22, 40], [22, 10], [23, 41], [23, 9], [24, 42], [24, 8], [25, 43], [26, 42], [27, 41], [28, 40], [29, 39], [30, 38], [31, 37], [32, 36], [33, 35], [34, 34], [35, 33], [36, 32], [37, 31], [38, 30], [39, 29], [40, 28], [41, 27], [42, 26], [43, 25], [42, 24], [41, 23], [40, 22], [39, 21], [38, 20], [37, 19], [36, 18], [35, 17], [34, 16], [33, 15], [32, 14], [31, 13], [30, 12], [29, 11], [28, 10], [27, 9], [26, 8], [25, 7], [6, 25], [7, 26], [7, 24], [8, 27], [8, 23], [9, 28], [9, 22], [10, 29], [10, 21], [11, 30], [11, 20], [12, 31], [12, 19], [13, 32], [13, 18], [14, 33], [14, 17], [15, 34], [15, 16], [16, 35], [16, 15], [17, 36], [17, 14], [18, 37], [18, 13], [19, 38], [19, 12], [20, 39], [20, 11], [21, 40], [21, 10], [22, 41], [22, 9], [23, 42], [23, 8], [24, 43], [24, 7], [25, 44], [26, 43], [27, 42], [28, 41], [29, 40], [30, 39], [31, 38], [32, 37], [33, 36], [34, 35], [35, 34], [36, 33], [37, 32], [38, 31], [39, 30], [40, 29], [41, 28], [42, 27], [43, 26], [44, 25], [43, 24], [42, 23], [41, 22], [40, 21], [39, 20], [38, 19], [37, 18], [36, 17], [35, 16], [34, 15], [33, 14], [32, 13], [31, 12], [30, 11], [29, 10], [28, 9], [27, 8], [26, 7], [25, 6], [5, 25], [6, 26], [6, 24], [7, 27], [7, 23], [8, 28], [8, 22], [9, 29], [9, 21], [10, 30], [10, 20], [11, 31], [11, 19], [12, 32], [12, 18], [13, 33], [13, 17], [14, 34], [14, 16], [15, 35], [15, 15], [16, 36], [16, 14], [17, 37], [17, 13], [18, 38], [18, 12], [19, 39], [19, 11], [20, 40], [20, 10], [21, 41], [21, 9], [22, 42], [22, 8], [23, 43], [23, 7], [24, 44], [24, 6], [25, 45], [26, 44], [27, 43], [28, 42], [29, 41], [30, 40], [31, 39], [32, 38], [33, 37], [34, 36], [35, 35], [36, 34], [37, 33], [38, 32], [39, 31], [40, 30], [41, 29], [42, 28], [43, 27], [44, 26], [45, 25], [44, 24], [43, 23], [42, 22], [41, 21], [40, 20], [39, 19], [38, 18], [37, 17], [36, 16], [35, 15], [34, 14], [33, 13], [32, 12], [31, 11], [30, 10], [29, 9], [28, 8], [27, 7], [26, 6], [25, 5], [4, 25], [5, 26], [5, 24], [6, 27], [6, 23], [7, 28], [7, 22], [8, 29], [8, 21], [9, 30], [9, 20], [10, 31], [10, 19], [11, 32], [11, 18], [12, 33], [12, 17], [13, 34], [13, 16], [14, 35], [14, 15], [15, 36], [15, 14], [16, 37], [16, 13], [17, 38], [17, 12], [18, 39], [18, 11], [19, 40], [19, 10], [20, 41], [20, 9], [21, 42], [21, 8], [22, 43], [22, 7], [23, 44], [23, 6], [24, 45], [24, 5], [25, 46], [26, 45], [27, 44], [28, 43], [29, 42], [30, 41], [31, 40], [32, 39], [33, 38], [34, 37], [35, 36], [36, 35], [37, 34], [38, 33], [39, 32], [40, 31], [41, 30], [42, 29], [43, 28], [44, 27], [45, 26], [46, 25], [45, 24], [44, 23], [43, 22], [42, 21], [41, 20], [40, 19], [39, 18], [38, 17], [37, 16], [36, 15], [35, 14], [34, 13], [33, 12], [32, 11], [31, 10], [30, 9], [29, 8], [28, 7], [27, 6], [26, 5], [25, 4], [3, 25], [4, 26], [4, 24], [5, 27], [5, 23], [6, 28], [6, 22], [7, 29], [7, 21], [8, 30], [8, 20], [9, 31], [9, 19], [10, 32], [10, 18], [11, 33], [11, 17], [12, 34], [12, 16], [13, 35], [13, 15], [14, 36], [14, 14], [15, 37], [15, 13], [16, 38], [16, 12], [17, 39], [17, 11], [18, 40], [18, 10], [19, 41], [19, 9], [20, 42], [20, 8], [21, 43], [21, 7], [22, 44], [22, 6], [23, 45], [23, 5], [24, 46], [24, 4], [25, 47], [26, 46], [27, 45], [28, 44], [29, 43], [30, 42], [31, 41], [32, 40], [33, 39], [34, 38], [35, 37], [36, 36], [37, 35], [38, 34], [39, 33], [40, 32], [41, 31], [42, 30], [43, 29], [44, 28], [45, 27], [46, 26], [47, 25], [46, 24], [45, 23], [44, 22], [43, 21], [42, 20], [41, 19], [40, 18], [39, 17], [38, 16], [37, 15], [36, 14], [35, 13], [34, 12], [33, 11], [32, 10], [31, 9], [30, 8], [29, 7], [28, 6], [27, 5], [26, 4], [25, 3], [2, 25], [3, 26], [3, 24], [4, 27], [4, 23], [5, 28], [5, 22], [6, 29], [6, 21], [7, 30], [7, 20], [8, 31], [8, 19], [9, 32], [9, 18], [10, 33], [10, 17], [11, 34], [11, 16], [12, 35], [12, 15], [13, 36], [13, 14], [14, 37], [14, 13], [15, 38], [15, 12], [16, 39], [16, 11], [17, 40], [17, 10], [18, 41], [18, 9], [19, 42], [19, 8], [20, 43], [20, 7], [21, 44], [21, 6], [22, 45], [22, 5], [23, 46], [23, 4], [24, 47], [24, 3], [25, 48], [26, 47], [27, 46], [28, 45], [29, 44], [30, 43], [31, 42], [32, 41], [33, 40], [34, 39], [35, 38], [36, 37], [37, 36], [38, 35], [39, 34], [40, 33], [41, 32], [42, 31], [43, 30], [44, 29], [45, 28], [46, 27], [47, 26], [48, 25], [47, 24], [46, 23], [45, 22], [44, 21], [43, 20], [42, 19], [41, 18], [40, 17], [39, 16], [38, 15], [37, 14], [36, 13], [35, 12], [34, 11], [33, 10], [32, 9], [31, 8], [30, 7], [29, 6], [28, 5], [27, 4], [26, 3], [25, 2], [1, 25], [2, 26], [2, 24], [3, 27], [3, 23], [4, 28], [4, 22], [5, 29], [5, 21], [6, 30], [6, 20], [7, 31], [7, 19], [8, 32], [8, 18], [9, 33], [9, 17], [10, 34], [10, 16], [11, 35], [11, 15], [12, 36], [12, 14], [13, 37], [13, 13], [14, 38], [14, 12], [15, 39], [15, 11], [16, 40], [16, 10], [17, 41], [17, 9], [18, 42], [18, 8], [19, 43], [19, 7], [20, 44], [20, 6], [21, 45], [21, 5], [22, 46], [22, 4], [23, 47], [23, 3], [24, 48], [24, 2], [25, 49], [26, 48], [27, 47], [28, 46], [29, 45], [30, 44], [31, 43], [32, 42], [33, 41], [34, 40], [35, 39], [36, 38], [37, 37], [38, 36], [39, 35], [40, 34], [41, 33], [42, 32], [43, 31], [44, 30], [45, 29], [46, 28], [47, 27], [48, 26], [49, 25], [48, 24], [47, 23], [46, 22], [45, 21], [44, 20], [43, 19], [42, 18], [41, 17], [40, 16], [39, 15], [38, 14], [37, 13], [36, 12], [35, 11], [34, 10], [33, 9], [32, 8], [31, 7], [30, 6], [29, 5], [28, 4], [27, 3], [26, 2], [25, 1], [0, 25], [1, 26], [1, 24], [2, 27], [2, 23], [3, 28], [3, 22], [4, 29], [4, 21], [5, 30], [5, 20], [6, 31], [6, 19], [7, 32], [7, 18], [8, 33], [8, 17], [9, 34], [9, 16], [10, 35], [10, 15], [11, 36], [11, 14], [12, 37], [12, 13], [13, 38], [13, 12], [14, 39], [14, 11], [15, 40], [15, 10], [16, 41], [16, 9], [17, 42], [17, 8], [18, 43], [18, 7], [19, 44], [19, 6], [20, 45], [20, 5], [21, 46], [21, 4], [22, 47], [22, 3], [23, 48], [23, 2], [24, 49], [24, 1], [26, 49], [27, 48], [28, 47], [29, 46], [30, 45], [31, 44], [32, 43], [33, 42], [34, 41], [35, 40], [36, 39], [37, 38], [38, 37], [39, 36], [40, 35], [41, 34], [42, 33], [43, 32], [44, 31], [45, 30], [46, 29], [47, 28], [48, 27], [49, 26], [49, 24], [48, 23], [47, 22], [46, 21], [45, 20], [44, 19], [43, 18], [42, 17], [41, 16], [40, 15], [39, 14], [38, 13], [37, 12], [36, 11], [35, 10], [34, 9], [33, 8], [32, 7], [31, 6], [30, 5], [29, 4], [28, 3], [27, 2], [26, 1], [25, 0], [0, 26], [0, 24], [1, 27], [1, 23], [2, 28], [2, 22], [3, 29], [3, 21], [4, 30], [4, 20], [5, 31], [5, 19], [6, 32], [6, 18], [7, 33], [7, 17], [8, 34], [8, 16], [9, 35], [9, 15], [10, 36], [10, 14], [11, 37], [11, 13], [12, 38], [12, 12], [13, 39], [13, 11], [14, 40], [14, 10], [15, 41], [15, 9], [16, 42], [16, 8], [17, 43], [17, 7], [18, 44], [18, 6], [19, 45], [19, 5], [20, 46], [20, 4], [21, 47], [21, 3], [22, 48], [22, 2], [23, 49], [23, 1], [24, 0], [27, 49], [28, 48], [29, 47], [30, 46], [31, 45], [32, 44], [33, 43], [34, 42], [35, 41], [36, 40], [37, 39], [38, 38], [39, 37], [40, 36], [41, 35], [42, 34], [43, 33], [44, 32], [45, 31], [46, 30], [47, 29], [48, 28], [49, 27], [49, 23], [48, 22], [47, 21], [46, 20], [45, 19], [44, 18], [43, 17], [42, 16], [41, 15], [40, 14], [39, 13], [38, 12], [37, 11], [36, 10], [35, 9], [34, 8], [33, 7], [32, 6], [31, 5], [30, 4], [29, 3], [28, 2], [27, 1], [26, 0], [0, 27], [0, 23], [1, 28], [1, 22], [2, 29], [2, 21], [3, 30], [3, 20], [4, 31], [4, 19], [5, 32], [5, 18], [6, 33], [6, 17], [7, 34], [7, 16], [8, 35], [8, 15], [9, 36], [9, 14], [10, 37], [10, 13], [11, 38], [11, 12], [12, 39], [12, 11], [13, 40], [13, 10], [14, 41], [14, 9], [15, 42], [15, 8], [16, 43], [16, 7], [17, 44], [17, 6], [18, 45], [18, 5], [19, 46], [19, 4], [20, 47], [20, 3], [21, 48], [21, 2], [22, 49], [22, 1], [23, 0], [28, 49], [29, 48], [30, 47], [31, 46], [32, 45], [33, 44], [34, 43], [35, 42], [36, 41], [37, 40], [38, 39], [39, 38], [40, 37], [41, 36], [42, 35], [43, 34], [44, 33], [45, 32], [46, 31], [47, 30], [48, 29], [49, 28], [49, 22], [48, 21], [47, 20], [46, 19], [45, 18], [44, 17], [43, 16], [42, 15], [41, 14], [40, 13], [39, 12], [38, 11], [37, 10], [36, 9], [35, 8], [34, 7], [33, 6], [32, 5], [31, 4], [30, 3], [29, 2], [28, 1], [27, 0], [0, 28], [0, 22], [1, 29], [1, 21], [2, 30], [2, 20], [3, 31], [3, 19], [4, 32], [4, 18], [5, 33], [5, 17], [6, 34], [6, 16], [7, 35], [7, 15], [8, 36], [8, 14], [9, 37], [9, 13], [10, 38], [10, 12], [11, 39], [11, 11], [12, 40], [12, 10], [13, 41], [13, 9], [14, 42], [14, 8], [15, 43], [15, 7], [16, 44], [16, 6], [17, 45], [17, 5], [18, 46], [18, 4], [19, 47], [19, 3], [20, 48], [20, 2], [21, 49], [21, 1], [22, 0], [29, 49], [30, 48], [31, 47], [32, 46], [33, 45], [34, 44], [35, 43], [36, 42], [37, 41], [38, 40], [39, 39], [40, 38], [41, 37], [42, 36], [43, 35], [44, 34], [45, 33], [46, 32], [47, 31], [48, 30], [49, 29], [49, 21], [48, 20], [47, 19], [46, 18], [45, 17], [44, 16], [43, 15], [42, 14], [41, 13], [40, 12], [39, 11], [38, 10], [37, 9], [36, 8], [35, 7], [34, 6], [33, 5], [32, 4], [31, 3], [30, 2], [29, 1], [28, 0], [0, 29], [0, 21], [1, 30], [1, 20], [2, 31], [2, 19], [3, 32], [3, 18], [4, 33], [4, 17], [5, 34], [5, 16], [6, 35], [6, 15], [7, 36], [7, 14], [8, 37], [8, 13], [9, 38], [9, 12], [10, 39], [10, 11], [11, 40], [11, 10], [12, 41], [12, 9], [13, 42], [13, 8], [14, 43], [14, 7], [15, 44], [15, 6], [16, 45], [16, 5], [17, 46], [17, 4], [18, 47], [18, 3], [19, 48], [19, 2], [20, 49], [20, 1], [21, 0], [30, 49], [31, 48], [32, 47], [33, 46], [34, 45], [35, 44], [36, 43], [37, 42], [38, 41], [39, 40], [40, 39], [41, 38], [42, 37], [43, 36], [44, 35], [45, 34], [46, 33], [47, 32], [48, 31], [49, 30], [49, 20], [48, 19], [47, 18], [46, 17], [45, 16], [44, 15], [43, 14], [42, 13], [41, 12], [40, 11], [39, 10], [38, 9], [37, 8], [36, 7], [35, 6], [34, 5], [33, 4], [32, 3], [31, 2], [30, 1], [29, 0], [0, 30], [0, 20], [1, 31], [1, 19], [2, 32], [2, 18], [3, 33], [3, 17], [4, 34], [4, 16], [5, 35], [5, 15], [6, 36], [6, 14], [7, 37], [7, 13], [8, 38], [8, 12], [9, 39], [9, 11], [10, 40], [10, 10], [11, 41], [11, 9], [12, 42], [12, 8], [13, 43], [13, 7], [14, 44], [14, 6], [15, 45], [15, 5], [16, 46], [16, 4], [17, 47], [17, 3], [18, 48], [18, 2], [19, 49], [19, 1], [20, 0], [31, 49], [32, 48], [33, 47], [34, 46], [35, 45], [36, 44], [37, 43], [38, 42], [39, 41], [40, 40], [41, 39], [42, 38], [43, 37], [44, 36], [45, 35], [46, 34], [47, 33], [48, 32], [49, 31], [49, 19], [48, 18], [47, 17], [46, 16], [45, 15], [44, 14], [43, 13], [42, 12], [41, 11], [40, 10], [39, 9], [38, 8], [37, 7], [36, 6], [35, 5], [34, 4], [33, 3], [32, 2], [31, 1], [30, 0], [0, 31], [0, 19], [1, 32], [1, 18], [2, 33], [2, 17], [3, 34], [3, 16], [4, 35], [4, 15], [5, 36], [5, 14], [6, 37], [6, 13], [7, 38], [7, 12], [8, 39], [8, 11], [9, 40], [9, 10], [10, 41], [10, 9], [11, 42], [11, 8], [12, 43], [12, 7], [13, 44], [13, 6], [14, 45], [14, 5], [15, 46], [15, 4], [16, 47], [16, 3], [17, 48], [17, 2], [18, 49], [18, 1], [19, 0], [32, 49], [33, 48], [34, 47], [35, 46], [36, 45], [37, 44], [38, 43], [39, 42], [40, 41], [41, 40], [42, 39], [43, 38], [44, 37], [45, 36], [46, 35], [47, 34], [48, 33], [49, 32], [49, 18], [48, 17], [47, 16], [46, 15], [45, 14], [44, 13], [43, 12], [42, 11], [41, 10], [40, 9], [39, 8], [38, 7], [37, 6], [36, 5], [35, 4], [34, 3], [33, 2], [32, 1], [31, 0], [0, 32], [0, 18], [1, 33], [1, 17], [2, 34], [2, 16], [3, 35], [3, 15], [4, 36], [4, 14], [5, 37], [5, 13], [6, 38], [6, 12], [7, 39], [7, 11], [8, 40], [8, 10], [9, 41], [9, 9], [10, 42], [10, 8], [11, 43], [11, 7], [12, 44], [12, 6], [13, 45], [13, 5], [14, 46], [14, 4], [15, 47], [15, 3], [16, 48], [16, 2], [17, 49], [17, 1], [18, 0], [33, 49], [34, 48], [35, 47], [36, 46], [37, 45], [38, 44], [39, 43], [40, 42], [41, 41], [42, 40], [43, 39], [44, 38], [45, 37], [46, 36], [47, 35], [48, 34], [49, 33], [49, 17], [48, 16], [47, 15], [46, 14], [45, 13], [44, 12], [43, 11], [42, 10], [41, 9], [40, 8], [39, 7], [38, 6], [37, 5], [36, 4], [35, 3], [34, 2], [33, 1], [32, 0], [0, 33], [0, 17], [1, 34], [1, 16], [2, 35], [2, 15], [3, 36], [3, 14], [4, 37], [4, 13], [5, 38], [5, 12], [6, 39], [6, 11], [7, 40], [7, 10], [8, 41], [8, 9], [9, 42], [9, 8], [10, 43], [10, 7], [11, 44], [11, 6], [12, 45], [12, 5], [13, 46], [13, 4], [14, 47], [14, 3], [15, 48], [15, 2], [16, 49], [16, 1], [17, 0], [34, 49], [35, 48], [36, 47], [37, 46], [38, 45], [39, 44], [40, 43], [41, 42], [42, 41], [43, 40], [44, 39], [45, 38], [46, 37], [47, 36], [48, 35], [49, 34], [49, 16], [48, 15], [47, 14], [46, 13], [45, 12], [44, 11], [43, 10], [42, 9], [41, 8], [40, 7], [39, 6], [38, 5], [37, 4], [36, 3], [35, 2], [34, 1], [33, 0], [0, 34], [0, 16], [1, 35], [1, 15], [2, 36], [2, 14], [3, 37], [3, 13], [4, 38], [4, 12], [5, 39], [5, 11], [6, 40], [6, 10], [7, 41], [7, 9], [8, 42], [8, 8], [9, 43], [9, 7], [10, 44], [10, 6], [11, 45], [11, 5], [12, 46], [12, 4], [13, 47], [13, 3], [14, 48], [14, 2], [15, 49], [15, 1], [16, 0], [35, 49], [36, 48], [37, 47], [38, 46], [39, 45], [40, 44], [41, 43], [42, 42], [43, 41], [44, 40], [45, 39], [46, 38], [47, 37], [48, 36], [49, 35], [49, 15], [48, 14], [47, 13], [46, 12], [45, 11], [44, 10], [43, 9], [42, 8], [41, 7], [40, 6], [39, 5], [38, 4], [37, 3], [36, 2], [35, 1], [34, 0], [0, 35], [0, 15], [1, 36], [1, 14], [2, 37], [2, 13], [3, 38], [3, 12], [4, 39], [4, 11], [5, 40], [5, 10], [6, 41], [6, 9], [7, 42], [7, 8], [8, 43], [8, 7], [9, 44], [9, 6], [10, 45], [10, 5], [11, 46], [11, 4], [12, 47], [12, 3], [13, 48], [13, 2], [14, 49], [14, 1], [15, 0], [36, 49], [37, 48], [38, 47], [39, 46], [40, 45], [41, 44], [42, 43], [43, 42], [44, 41], [45, 40], [46, 39], [47, 38], [48, 37], [49, 36], [49, 14], [48, 13], [47, 12], [46, 11], [45, 10], [44, 9], [43, 8], [42, 7], [41, 6], [40, 5], [39, 4], [38, 3], [37, 2], [36, 1], [35, 0], [0, 36], [0, 14], [1, 37], [1, 13], [2, 38], [2, 12], [3, 39], [3, 11], [4, 40], [4, 10], [5, 41], [5, 9], [6, 42], [6, 8], [7, 43], [7, 7], [8, 44], [8, 6], [9, 45], [9, 5], [10, 46], [10, 4], [11, 47], [11, 3], [12, 48], [12, 2], [13, 49], [13, 1], [14, 0], [37, 49], [38, 48], [39, 47], [40, 46], [41, 45], [42, 44], [43, 43], [44, 42], [45, 41], [46, 40], [47, 39], [48, 38], [49, 37], [49, 13], [48, 12], [47, 11], [46, 10], [45, 9], [44, 8], [43, 7], [42, 6], [41, 5], [40, 4], [39, 3], [38, 2], [37, 1], [36, 0], [0, 37], [0, 13], [1, 38], [1, 12], [2, 39], [2, 11], [3, 40], [3, 10], [4, 41], [4, 9], [5, 42], [5, 8], [6, 43], [6, 7], [7, 44], [7, 6], [8, 45], [8, 5], [9, 46], [9, 4], [10, 47], [10, 3], [11, 48], [11, 2], [12, 49], [12, 1], [13, 0], [38, 49], [39, 48], [40, 47], [41, 46], [42, 45], [43, 44], [44, 43], [45, 42], [46, 41], [47, 40], [48, 39], [49, 38], [49, 12], [48, 11], [47, 10], [46, 9], [45, 8], [44, 7], [43, 6], [42, 5], [41, 4], [40, 3], [39, 2], [38, 1], [37, 0], [0, 38], [0, 12], [1, 39], [1, 11], [2, 40], [2, 10], [3, 41], [3, 9], [4, 42], [4, 8], [5, 43], [5, 7], [6, 44], [6, 6], [7, 45], [7, 5], [8, 46], [8, 4], [9, 47], [9, 3], [10, 48], [10, 2], [11, 49], [11, 1], [12, 0], [39, 49], [40, 48], [41, 47], [42, 46], [43, 45], [44, 44], [45, 43], [46, 42], [47, 41], [48, 40], [49, 39], [49, 11], [48, 10], [47, 9], [46, 8], [45, 7], [44, 6], [43, 5], [42, 4], [41, 3], [40, 2], [39, 1], [38, 0], [0, 39], [0, 11], [1, 40], [1, 10], [2, 41], [2, 9], [3, 42], [3, 8], [4, 43], [4, 7], [5, 44], [5, 6], [6, 45], [6, 5], [7, 46], [7, 4], [8, 47], [8, 3], [9, 48], [9, 2], [10, 49], [10, 1], [11, 0], [40, 49], [41, 48], [42, 47], [43, 46], [44, 45], [45, 44], [46, 43], [47, 42], [48, 41], [49, 40], [49, 10], [48, 9], [47, 8], [46, 7], [45, 6], [44, 5], [43, 4], [42, 3], [41, 2], [40, 1], [39, 0], [0, 40], [0, 10], [1, 41], [1, 9], [2, 42], [2, 8], [3, 43], [3, 7], [4, 44], [4, 6], [5, 45], [5, 5], [6, 46], [6, 4], [7, 47], [7, 3], [8, 48], [8, 2], [9, 49], [9, 1], [10, 0], [41, 49], [42, 48], [43, 47], [44, 46], [45, 45], [46, 44], [47, 43], [48, 42], [49, 41], [49, 9], [48, 8], [47, 7], [46, 6], [45, 5], [44, 4], [43, 3], [42, 2], [41, 1], [40, 0], [0, 41], [0, 9], [1, 42], [1, 8], [2, 43], [2, 7], [3, 44], [3, 6], [4, 45], [4, 5], [5, 46], [5, 4], [6, 47], [6, 3], [7, 48], [7, 2], [8, 49], [8, 1], [9, 0], [42, 49], [43, 48], [44, 47], [45, 46], [46, 45], [47, 44], [48, 43], [49, 42], [49, 8], [48, 7], [47, 6], [46, 5], [45, 4], [44, 3], [43, 2], [42, 1], [41, 0], [0, 42], [0, 8], [1, 43], [1, 7], [2, 44], [2, 6], [3, 45], [3, 5], [4, 46], [4, 4], [5, 47], [5, 3], [6, 48], [6, 2], [7, 49], [7, 1], [8, 0], [43, 49], [44, 48], [45, 47], [46, 46], [47, 45], [48, 44], [49, 43], [49, 7], [48, 6], [47, 5], [46, 4], [45, 3], [44, 2], [43, 1], [42, 0], [0, 43], [0, 7], [1, 44], [1, 6], [2, 45], [2, 5], [3, 46], [3, 4], [4, 47], [4, 3], [5, 48], [5, 2], [6, 49], [6, 1], [7, 0], [44, 49], [45, 48], [46, 47], [47, 46], [48, 45], [49, 44], [49, 6], [48, 5], [47, 4], [46, 3], [45, 2], [44, 1], [43, 0], [0, 44], [0, 6], [1, 45], [1, 5], [2, 46], [2, 4], [3, 47], [3, 3], [4, 48], [4, 2], [5, 49], [5, 1], [6, 0], [45, 49], [46, 48], [47, 47], [48, 46], [49, 45], [49, 5], [48, 4], [47, 3], [46, 2], [45, 1], [44, 0], [0, 45], [0, 5], [1, 46], [1, 4], [2, 47], [2, 3], [3, 48], [3, 2], [4, 49], [4, 1], [5, 0], [46, 49], [47, 48], [48, 47], [49, 46], [49, 4], [48, 3], [47, 2], [46, 1], [45, 0], [0, 46], [0, 4], [1, 47], [1, 3], [2, 48], [2, 2], [3, 49], [3, 1], [4, 0], [47, 49], [48, 48], [49, 47], [49, 3], [48, 2], [47, 1], [46, 0], [0, 47], [0, 3], [1, 48], [1, 2], [2, 49], [2, 1], [3, 0], [48, 49], [49, 48], [49, 2], [48, 1], [47, 0], [0, 48], [0, 2], [1, 49], [1, 1], [2, 0], [49, 49], [49, 1], [48, 0], [0, 49], [0, 1], [1, 0], [49, 0], [0, 0]]\n assert candidate(rows = 4,cols = 6,rCenter = 3,cCenter = 0) == [[3, 0], [2, 0], [3, 1], [1, 0], [2, 1], [3, 2], [0, 0], [1, 1], [2, 2], [3, 3], [0, 1], [1, 2], [2, 3], [3, 4], [0, 2], [1, 3], [2, 4], [3, 5], [0, 3], [1, 4], [2, 5], [0, 4], [1, 5], [0, 5]]\n assert candidate(rows = 10,cols = 10,rCenter = 0,cCenter = 9) == [[0, 9], [1, 9], [0, 8], [2, 9], [1, 8], [0, 7], [3, 9], [2, 8], [1, 7], [0, 6], [4, 9], [3, 8], [2, 7], [1, 6], [0, 5], [5, 9], [4, 8], [3, 7], [2, 6], [1, 5], [0, 4], [6, 9], [5, 8], [4, 7], [3, 6], [2, 5], [1, 4], [0, 3], [7, 9], [6, 8], [5, 7], [4, 6], [3, 5], [2, 4], [1, 3], [0, 2], [8, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2], [0, 1], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0], [9, 7], [8, 6], [7, 5], [6, 4], [5, 3], [4, 2], [3, 1], [2, 0], [9, 6], [8, 5], [7, 4], [6, 3], [5, 2], [4, 1], [3, 0], [9, 5], [8, 4], [7, 3], [6, 2], [5, 1], [4, 0], [9, 4], [8, 3], [7, 2], [6, 1], [5, 0], [9, 3], [8, 2], [7, 1], [6, 0], [9, 2], [8, 1], [7, 0], [9, 1], [8, 0], [9, 0]]\n assert candidate(rows = 7,cols = 12,rCenter = 6,cCenter = 11) == [[6, 11], [5, 11], [6, 10], [4, 11], [5, 10], [6, 9], [3, 11], [4, 10], [5, 9], [6, 8], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [1, 11], [2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 7,cols = 2,rCenter = 3,cCenter = 1) == [[3, 1], [2, 1], [4, 1], [3, 0], [1, 1], [2, 0], [5, 1], [4, 0], [0, 1], [1, 0], [6, 1], [5, 0], [0, 0], [6, 0]]\n assert candidate(rows = 5,cols = 5,rCenter = 3,cCenter = 3) == [[3, 3], [2, 3], [3, 4], [4, 3], [3, 2], [1, 3], [2, 4], [2, 2], [4, 4], [4, 2], [3, 1], [0, 3], [1, 4], [1, 2], [2, 1], [4, 1], [3, 0], [0, 4], [0, 2], [1, 1], [2, 0], [4, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 5,cols = 10,rCenter = 3,cCenter = 0) == [[3, 0], [2, 0], [3, 1], [4, 0], [1, 0], [2, 1], [3, 2], [4, 1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 2], [0, 1], [1, 2], [2, 3], [3, 4], [4, 3], [0, 2], [1, 3], [2, 4], [3, 5], [4, 4], [0, 3], [1, 4], [2, 5], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7], [4, 6], [0, 5], [1, 6], [2, 7], [3, 8], [4, 7], [0, 6], [1, 7], [2, 8], [3, 9], [4, 8], [0, 7], [1, 8], [2, 9], [4, 9], [0, 8], [1, 9], [0, 9]]\n assert candidate(rows = 100,cols = 1,rCenter = 50,cCenter = 0) == [[50, 0], [49, 0], [51, 0], [48, 0], [52, 0], [47, 0], [53, 0], [46, 0], [54, 0], [45, 0], [55, 0], [44, 0], [56, 0], [43, 0], [57, 0], [42, 0], [58, 0], [41, 0], [59, 0], [40, 0], [60, 0], [39, 0], [61, 0], [38, 0], [62, 0], [37, 0], [63, 0], [36, 0], [64, 0], [35, 0], [65, 0], [34, 0], [66, 0], [33, 0], [67, 0], [32, 0], [68, 0], [31, 0], [69, 0], [30, 0], [70, 0], [29, 0], [71, 0], [28, 0], [72, 0], [27, 0], [73, 0], [26, 0], [74, 0], [25, 0], [75, 0], [24, 0], [76, 0], [23, 0], [77, 0], [22, 0], [78, 0], [21, 0], [79, 0], [20, 0], [80, 0], [19, 0], [81, 0], [18, 0], [82, 0], [17, 0], [83, 0], [16, 0], [84, 0], [15, 0], [85, 0], [14, 0], [86, 0], [13, 0], [87, 0], [12, 0], [88, 0], [11, 0], [89, 0], [10, 0], [90, 0], [9, 0], [91, 0], [8, 0], [92, 0], [7, 0], [93, 0], [6, 0], [94, 0], [5, 0], [95, 0], [4, 0], [96, 0], [3, 0], [97, 0], [2, 0], [98, 0], [1, 0], [99, 0], [0, 0]]\n assert candidate(rows = 12,cols = 12,rCenter = 3,cCenter = 3) == [[3, 3], [2, 3], [3, 4], [4, 3], [3, 2], [1, 3], [2, 4], [2, 2], [3, 5], [4, 4], [5, 3], [4, 2], [3, 1], [0, 3], [1, 4], [1, 2], [2, 5], [2, 1], [3, 6], [4, 5], [5, 4], [6, 3], [5, 2], [4, 1], [3, 0], [0, 4], [0, 2], [1, 5], [1, 1], [2, 6], [2, 0], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [6, 2], [5, 1], [4, 0], [0, 5], [0, 1], [1, 6], [1, 0], [2, 7], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [7, 2], [6, 1], [5, 0], [0, 6], [0, 0], [1, 7], [2, 8], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [8, 2], [7, 1], [6, 0], [0, 7], [1, 8], [2, 9], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [9, 2], [8, 1], [7, 0], [0, 8], [1, 9], [2, 10], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 6], [9, 5], [10, 4], [11, 3], [10, 2], [9, 1], [8, 0], [0, 9], [1, 10], [2, 11], [4, 11], [5, 10], [6, 9], [7, 8], [8, 7], [9, 6], [10, 5], [11, 4], [11, 2], [10, 1], [9, 0], [0, 10], [1, 11], [5, 11], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [11, 5], [11, 1], [10, 0], [0, 11], [6, 11], [7, 10], [8, 9], [9, 8], [10, 7], [11, 6], [11, 0], [7, 11], [8, 10], [9, 9], [10, 8], [11, 7], [8, 11], [9, 10], [10, 9], [11, 8], [9, 11], [10, 10], [11, 9], [10, 11], [11, 10], [11, 11]]\n assert candidate(rows = 20,cols = 5,rCenter = 19,cCenter = 0) == [[19, 0], [18, 0], [19, 1], [17, 0], [18, 1], [19, 2], [16, 0], [17, 1], [18, 2], [19, 3], [15, 0], [16, 1], [17, 2], [18, 3], [19, 4], [14, 0], [15, 1], [16, 2], [17, 3], [18, 4], [13, 0], [14, 1], [15, 2], [16, 3], [17, 4], [12, 0], [13, 1], [14, 2], [15, 3], [16, 4], [11, 0], [12, 1], [13, 2], [14, 3], [15, 4], [10, 0], [11, 1], [12, 2], [13, 3], [14, 4], [9, 0], [10, 1], [11, 2], [12, 3], [13, 4], [8, 0], [9, 1], [10, 2], [11, 3], [12, 4], [7, 0], [8, 1], [9, 2], [10, 3], [11, 4], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [5, 0], [6, 1], [7, 2], [8, 3], [9, 4], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4], [3, 0], [4, 1], [5, 2], [6, 3], [7, 4], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 1], [1, 2], [2, 3], [3, 4], [0, 2], [1, 3], [2, 4], [0, 3], [1, 4], [0, 4]]\n assert candidate(rows = 6,cols = 8,rCenter = 4,cCenter = 7) == [[4, 7], [3, 7], [5, 7], [4, 6], [2, 7], [3, 6], [5, 6], [4, 5], [1, 7], [2, 6], [3, 5], [5, 5], [4, 4], [0, 7], [1, 6], [2, 5], [3, 4], [5, 4], [4, 3], [0, 6], [1, 5], [2, 4], [3, 3], [5, 3], [4, 2], [0, 5], [1, 4], [2, 3], [3, 2], [5, 2], [4, 1], [0, 4], [1, 3], [2, 2], [3, 1], [5, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [5, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 4,cols = 5,rCenter = 2,cCenter = 3) == [[2, 3], [1, 3], [2, 4], [3, 3], [2, 2], [0, 3], [1, 4], [1, 2], [3, 4], [3, 2], [2, 1], [0, 4], [0, 2], [1, 1], [3, 1], [2, 0], [0, 1], [1, 0], [3, 0], [0, 0]]\n assert candidate(rows = 8,cols = 8,rCenter = 1,cCenter = 1) == [[1, 1], [0, 1], [1, 2], [2, 1], [1, 0], [0, 2], [0, 0], [1, 3], [2, 2], [3, 1], [2, 0], [0, 3], [1, 4], [2, 3], [3, 2], [4, 1], [3, 0], [0, 4], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [4, 0], [0, 5], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [5, 0], [0, 6], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [6, 0], [0, 7], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [7, 0], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [4, 7], [5, 6], [6, 5], [7, 4], [5, 7], [6, 6], [7, 5], [6, 7], [7, 6], [7, 7]]\n assert candidate(rows = 6,cols = 4,rCenter = 0,cCenter = 0) == [[0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], [0, 3], [1, 2], [2, 1], [3, 0], [1, 3], [2, 2], [3, 1], [4, 0], [2, 3], [3, 2], [4, 1], [5, 0], [3, 3], [4, 2], [5, 1], [4, 3], [5, 2], [5, 3]]\n assert candidate(rows = 8,cols = 4,rCenter = 0,cCenter = 3) == [[0, 3], [1, 3], [0, 2], [2, 3], [1, 2], [0, 1], [3, 3], [2, 2], [1, 1], [0, 0], [4, 3], [3, 2], [2, 1], [1, 0], [5, 3], [4, 2], [3, 1], [2, 0], [6, 3], [5, 2], [4, 1], [3, 0], [7, 3], [6, 2], [5, 1], [4, 0], [7, 2], [6, 1], [5, 0], [7, 1], [6, 0], [7, 0]]\n assert candidate(rows = 7,cols = 7,rCenter = 3,cCenter = 3) == [[3, 3], [2, 3], [3, 4], [4, 3], [3, 2], [1, 3], [2, 4], [2, 2], [3, 5], [4, 4], [5, 3], [4, 2], [3, 1], [0, 3], [1, 4], [1, 2], [2, 5], [2, 1], [3, 6], [4, 5], [5, 4], [6, 3], [5, 2], [4, 1], [3, 0], [0, 4], [0, 2], [1, 5], [1, 1], [2, 6], [2, 0], [4, 6], [5, 5], [6, 4], [6, 2], [5, 1], [4, 0], [0, 5], [0, 1], [1, 6], [1, 0], [5, 6], [6, 5], [6, 1], [5, 0], [0, 6], [0, 0], [6, 6], [6, 0]]\n assert candidate(rows = 10,cols = 10,rCenter = 9,cCenter = 0) == [[9, 0], [8, 0], [9, 1], [7, 0], [8, 1], [9, 2], [6, 0], [7, 1], [8, 2], [9, 3], [5, 0], [6, 1], [7, 2], [8, 3], [9, 4], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4], [9, 5], [3, 0], [4, 1], [5, 2], [6, 3], [7, 4], [8, 5], [9, 6], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [7, 5], [8, 6], [9, 7], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [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], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [0, 6], [1, 7], [2, 8], [3, 9], [0, 7], [1, 8], [2, 9], [0, 8], [1, 9], [0, 9]]\n assert candidate(rows = 15,cols = 5,rCenter = 14,cCenter = 2) == [[14, 2], [13, 2], [14, 3], [14, 1], [12, 2], [13, 3], [13, 1], [14, 4], [14, 0], [11, 2], [12, 3], [12, 1], [13, 4], [13, 0], [10, 2], [11, 3], [11, 1], [12, 4], [12, 0], [9, 2], [10, 3], [10, 1], [11, 4], [11, 0], [8, 2], [9, 3], [9, 1], [10, 4], [10, 0], [7, 2], [8, 3], [8, 1], [9, 4], [9, 0], [6, 2], [7, 3], [7, 1], [8, 4], [8, 0], [5, 2], [6, 3], [6, 1], [7, 4], [7, 0], [4, 2], [5, 3], [5, 1], [6, 4], [6, 0], [3, 2], [4, 3], [4, 1], [5, 4], [5, 0], [2, 2], [3, 3], [3, 1], [4, 4], [4, 0], [1, 2], [2, 3], [2, 1], [3, 4], [3, 0], [0, 2], [1, 3], [1, 1], [2, 4], [2, 0], [0, 3], [0, 1], [1, 4], [1, 0], [0, 4], [0, 0]]\n assert candidate(rows = 7,cols = 7,rCenter = 3,cCenter = 4) == [[3, 4], [2, 4], [3, 5], [4, 4], [3, 3], [1, 4], [2, 5], [2, 3], [3, 6], [4, 5], [5, 4], [4, 3], [3, 2], [0, 4], [1, 5], [1, 3], [2, 6], [2, 2], [4, 6], [5, 5], [6, 4], [5, 3], [4, 2], [3, 1], [0, 5], [0, 3], [1, 6], [1, 2], [2, 1], [5, 6], [6, 5], [6, 3], [5, 2], [4, 1], [3, 0], [0, 6], [0, 2], [1, 1], [2, 0], [6, 6], [6, 2], [5, 1], [4, 0], [0, 1], [1, 0], [6, 1], [5, 0], [0, 0], [6, 0]]\n assert candidate(rows = 10,cols = 1,rCenter = 5,cCenter = 0) == [[5, 0], [4, 0], [6, 0], [3, 0], [7, 0], [2, 0], [8, 0], [1, 0], [9, 0], [0, 0]]\n assert candidate(rows = 6,cols = 6,rCenter = 3,cCenter = 3) == [[3, 3], [2, 3], [3, 4], [4, 3], [3, 2], [1, 3], [2, 4], [2, 2], [3, 5], [4, 4], [5, 3], [4, 2], [3, 1], [0, 3], [1, 4], [1, 2], [2, 5], [2, 1], [4, 5], [5, 4], [5, 2], [4, 1], [3, 0], [0, 4], [0, 2], [1, 5], [1, 1], [2, 0], [5, 5], [5, 1], [4, 0], [0, 5], [0, 1], [1, 0], [5, 0], [0, 0]]\n assert candidate(rows = 6,cols = 4,rCenter = 3,cCenter = 0) == [[3, 0], [2, 0], [3, 1], [4, 0], [1, 0], [2, 1], [3, 2], [4, 1], [5, 0], [0, 0], [1, 1], [2, 2], [3, 3], [4, 2], [5, 1], [0, 1], [1, 2], [2, 3], [4, 3], [5, 2], [0, 2], [1, 3], [5, 3], [0, 3]]\n assert candidate(rows = 7,cols = 7,rCenter = 0,cCenter = 0) == [[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], [5, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [3, 6], [4, 5], [5, 4], [6, 3], [4, 6], [5, 5], [6, 4], [5, 6], [6, 5], [6, 6]]\n assert candidate(rows = 4,cols = 5,rCenter = 0,cCenter = 0) == [[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], [1, 4], [2, 3], [3, 2], [2, 4], [3, 3], [3, 4]]\n assert candidate(rows = 6,cols = 3,rCenter = 3,cCenter = 1) == [[3, 1], [2, 1], [3, 2], [4, 1], [3, 0], [1, 1], [2, 2], [2, 0], [4, 2], [5, 1], [4, 0], [0, 1], [1, 2], [1, 0], [5, 2], [5, 0], [0, 2], [0, 0]]\n assert candidate(rows = 15,cols = 5,rCenter = 0,cCenter = 0) == [[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], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0], [8, 4], [9, 3], [10, 2], [11, 1], [12, 0], [9, 4], [10, 3], [11, 2], [12, 1], [13, 0], [10, 4], [11, 3], [12, 2], [13, 1], [14, 0], [11, 4], [12, 3], [13, 2], [14, 1], [12, 4], [13, 3], [14, 2], [13, 4], [14, 3], [14, 4]]\n assert candidate(rows = 12,cols = 12,rCenter = 6,cCenter = 6) == [[6, 6], [5, 6], [6, 7], [7, 6], [6, 5], [4, 6], [5, 7], [5, 5], [6, 8], [7, 7], [8, 6], [7, 5], [6, 4], [3, 6], [4, 7], [4, 5], [5, 8], [5, 4], [6, 9], [7, 8], [8, 7], [9, 6], [8, 5], [7, 4], [6, 3], [2, 6], [3, 7], [3, 5], [4, 8], [4, 4], [5, 9], [5, 3], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [9, 5], [8, 4], [7, 3], [6, 2], [1, 6], [2, 7], [2, 5], [3, 8], [3, 4], [4, 9], [4, 3], [5, 10], [5, 2], [6, 11], [7, 10], [8, 9], [9, 8], [10, 7], [11, 6], [10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [0, 6], [1, 7], [1, 5], [2, 8], [2, 4], [3, 9], [3, 3], [4, 10], [4, 2], [5, 11], [5, 1], [7, 11], [8, 10], [9, 9], [10, 8], [11, 7], [11, 5], [10, 4], [9, 3], [8, 2], [7, 1], [6, 0], [0, 7], [0, 5], [1, 8], [1, 4], [2, 9], [2, 3], [3, 10], [3, 2], [4, 11], [4, 1], [5, 0], [8, 11], [9, 10], [10, 9], [11, 8], [11, 4], [10, 3], [9, 2], [8, 1], [7, 0], [0, 8], [0, 4], [1, 9], [1, 3], [2, 10], [2, 2], [3, 11], [3, 1], [4, 0], [9, 11], [10, 10], [11, 9], [11, 3], [10, 2], [9, 1], [8, 0], [0, 9], [0, 3], [1, 10], [1, 2], [2, 11], [2, 1], [3, 0], [10, 11], [11, 10], [11, 2], [10, 1], [9, 0], [0, 10], [0, 2], [1, 11], [1, 1], [2, 0], [11, 11], [11, 1], [10, 0], [0, 11], [0, 1], [1, 0], [11, 0], [0, 0]]\n assert candidate(rows = 20,cols = 20,rCenter = 19,cCenter = 19) == [[19, 19], [18, 19], [19, 18], [17, 19], [18, 18], [19, 17], [16, 19], [17, 18], [18, 17], [19, 16], [15, 19], [16, 18], [17, 17], [18, 16], [19, 15], [14, 19], [15, 18], [16, 17], [17, 16], [18, 15], [19, 14], [13, 19], [14, 18], [15, 17], [16, 16], [17, 15], [18, 14], [19, 13], [12, 19], [13, 18], [14, 17], [15, 16], [16, 15], [17, 14], [18, 13], [19, 12], [11, 19], [12, 18], [13, 17], [14, 16], [15, 15], [16, 14], [17, 13], [18, 12], [19, 11], [10, 19], [11, 18], [12, 17], [13, 16], [14, 15], [15, 14], [16, 13], [17, 12], [18, 11], [19, 10], [9, 19], [10, 18], [11, 17], [12, 16], [13, 15], [14, 14], [15, 13], [16, 12], [17, 11], [18, 10], [19, 9], [8, 19], [9, 18], [10, 17], [11, 16], [12, 15], [13, 14], [14, 13], [15, 12], [16, 11], [17, 10], [18, 9], [19, 8], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [13, 13], [14, 12], [15, 11], [16, 10], [17, 9], [18, 8], [19, 7], [6, 19], [7, 18], [8, 17], [9, 16], [10, 15], [11, 14], [12, 13], [13, 12], [14, 11], [15, 10], [16, 9], [17, 8], [18, 7], [19, 6], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15], [10, 14], [11, 13], [12, 12], [13, 11], [14, 10], [15, 9], [16, 8], [17, 7], [18, 6], [19, 5], [4, 19], [5, 18], [6, 17], [7, 16], [8, 15], [9, 14], [10, 13], [11, 12], [12, 11], [13, 10], [14, 9], [15, 8], [16, 7], [17, 6], [18, 5], [19, 4], [3, 19], [4, 18], [5, 17], [6, 16], [7, 15], [8, 14], [9, 13], [10, 12], [11, 11], [12, 10], [13, 9], [14, 8], [15, 7], [16, 6], [17, 5], [18, 4], [19, 3], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [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], [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], [0, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [9, 9], [10, 8], [11, 7], [12, 6], [13, 5], [14, 4], [15, 3], [16, 2], [17, 1], [18, 0], [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], [0, 16], [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, 0], [0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [8, 7], [9, 6], [10, 5], [11, 4], [12, 3], [13, 2], [14, 1], [15, 0], [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, 0], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [11, 2], [12, 1], [13, 0], [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], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 8,cols = 8,rCenter = 7,cCenter = 7) == [[7, 7], [6, 7], [7, 6], [5, 7], [6, 6], [7, 5], [4, 7], [5, 6], [6, 5], [7, 4], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 8,cols = 8,rCenter = 4,cCenter = 4) == [[4, 4], [3, 4], [4, 5], [5, 4], [4, 3], [2, 4], [3, 5], [3, 3], [4, 6], [5, 5], [6, 4], [5, 3], [4, 2], [1, 4], [2, 5], [2, 3], [3, 6], [3, 2], [4, 7], [5, 6], [6, 5], [7, 4], [6, 3], [5, 2], [4, 1], [0, 4], [1, 5], [1, 3], [2, 6], [2, 2], [3, 7], [3, 1], [5, 7], [6, 6], [7, 5], [7, 3], [6, 2], [5, 1], [4, 0], [0, 5], [0, 3], [1, 6], [1, 2], [2, 7], [2, 1], [3, 0], [6, 7], [7, 6], [7, 2], [6, 1], [5, 0], [0, 6], [0, 2], [1, 7], [1, 1], [2, 0], [7, 7], [7, 1], [6, 0], [0, 7], [0, 1], [1, 0], [7, 0], [0, 0]]\n assert candidate(rows = 15,cols = 5,rCenter = 7,cCenter = 2) == [[7, 2], [6, 2], [7, 3], [8, 2], [7, 1], [5, 2], [6, 3], [6, 1], [7, 4], [8, 3], [9, 2], [8, 1], [7, 0], [4, 2], [5, 3], [5, 1], [6, 4], [6, 0], [8, 4], [9, 3], [10, 2], [9, 1], [8, 0], [3, 2], [4, 3], [4, 1], [5, 4], [5, 0], [9, 4], [10, 3], [11, 2], [10, 1], [9, 0], [2, 2], [3, 3], [3, 1], [4, 4], [4, 0], [10, 4], [11, 3], [12, 2], [11, 1], [10, 0], [1, 2], [2, 3], [2, 1], [3, 4], [3, 0], [11, 4], [12, 3], [13, 2], [12, 1], [11, 0], [0, 2], [1, 3], [1, 1], [2, 4], [2, 0], [12, 4], [13, 3], [14, 2], [13, 1], [12, 0], [0, 3], [0, 1], [1, 4], [1, 0], [13, 4], [14, 3], [14, 1], [13, 0], [0, 4], [0, 0], [14, 4], [14, 0]]\n assert candidate(rows = 6,cols = 4,rCenter = 0,cCenter = 3) == [[0, 3], [1, 3], [0, 2], [2, 3], [1, 2], [0, 1], [3, 3], [2, 2], [1, 1], [0, 0], [4, 3], [3, 2], [2, 1], [1, 0], [5, 3], [4, 2], [3, 1], [2, 0], [5, 2], [4, 1], [3, 0], [5, 1], [4, 0], [5, 0]]\n assert candidate(rows = 9,cols = 9,rCenter = 4,cCenter = 8) == [[4, 8], [3, 8], [5, 8], [4, 7], [2, 8], [3, 7], [6, 8], [5, 7], [4, 6], [1, 8], [2, 7], [3, 6], [7, 8], [6, 7], [5, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [0, 7], [1, 6], [2, 5], [3, 4], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [0, 6], [1, 5], [2, 4], [3, 3], [8, 6], [7, 5], [6, 4], [5, 3], [4, 2], [0, 5], [1, 4], [2, 3], [3, 2], [8, 5], [7, 4], [6, 3], [5, 2], [4, 1], [0, 4], [1, 3], [2, 2], [3, 1], [8, 4], [7, 3], [6, 2], [5, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [8, 3], [7, 2], [6, 1], [5, 0], [0, 2], [1, 1], [2, 0], [8, 2], [7, 1], [6, 0], [0, 1], [1, 0], [8, 1], [7, 0], [0, 0], [8, 0]]\n assert candidate(rows = 5,cols = 5,rCenter = 0,cCenter = 0) == [[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], [1, 4], [2, 3], [3, 2], [4, 1], [2, 4], [3, 3], [4, 2], [3, 4], [4, 3], [4, 4]]\n assert candidate(rows = 7,cols = 5,rCenter = 3,cCenter = 2) == [[3, 2], [2, 2], [3, 3], [4, 2], [3, 1], [1, 2], [2, 3], [2, 1], [3, 4], [4, 3], [5, 2], [4, 1], [3, 0], [0, 2], [1, 3], [1, 1], [2, 4], [2, 0], [4, 4], [5, 3], [6, 2], [5, 1], [4, 0], [0, 3], [0, 1], [1, 4], [1, 0], [5, 4], [6, 3], [6, 1], [5, 0], [0, 4], [0, 0], [6, 4], [6, 0]]\n assert candidate(rows = 8,cols = 3,rCenter = 1,cCenter = 2) == [[1, 2], [0, 2], [2, 2], [1, 1], [0, 1], [3, 2], [2, 1], [1, 0], [0, 0], [4, 2], [3, 1], [2, 0], [5, 2], [4, 1], [3, 0], [6, 2], [5, 1], [4, 0], [7, 2], [6, 1], [5, 0], [7, 1], [6, 0], [7, 0]]\n assert candidate(rows = 7,cols = 2,rCenter = 6,cCenter = 0) == [[6, 0], [5, 0], [6, 1], [4, 0], [5, 1], [3, 0], [4, 1], [2, 0], [3, 1], [1, 0], [2, 1], [0, 0], [1, 1], [0, 1]]\n assert candidate(rows = 8,cols = 8,rCenter = 7,cCenter = 0) == [[7, 0], [6, 0], [7, 1], [5, 0], [6, 1], [7, 2], [4, 0], [5, 1], [6, 2], [7, 3], [3, 0], [4, 1], [5, 2], [6, 3], [7, 4], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [7, 5], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 4], [1, 5], [2, 6], [3, 7], [0, 5], [1, 6], [2, 7], [0, 6], [1, 7], [0, 7]]\n assert candidate(rows = 5,cols = 9,rCenter = 2,cCenter = 8) == [[2, 8], [1, 8], [3, 8], [2, 7], [0, 8], [1, 7], [4, 8], [3, 7], [2, 6], [0, 7], [1, 6], [4, 7], [3, 6], [2, 5], [0, 6], [1, 5], [4, 6], [3, 5], [2, 4], [0, 5], [1, 4], [4, 5], [3, 4], [2, 3], [0, 4], [1, 3], [4, 4], [3, 3], [2, 2], [0, 3], [1, 2], [4, 3], [3, 2], [2, 1], [0, 2], [1, 1], [4, 2], [3, 1], [2, 0], [0, 1], [1, 0], [4, 1], [3, 0], [0, 0], [4, 0]]\n assert candidate(rows = 60,cols = 25,rCenter = 30,cCenter = 10) == [[30, 10], [29, 10], [30, 11], [31, 10], [30, 9], [28, 10], [29, 11], [29, 9], [30, 12], [31, 11], [32, 10], [31, 9], [30, 8], [27, 10], [28, 11], [28, 9], [29, 12], [29, 8], [30, 13], [31, 12], [32, 11], [33, 10], [32, 9], [31, 8], [30, 7], [26, 10], [27, 11], [27, 9], [28, 12], [28, 8], [29, 13], [29, 7], [30, 14], [31, 13], [32, 12], [33, 11], [34, 10], [33, 9], [32, 8], [31, 7], [30, 6], [25, 10], [26, 11], [26, 9], [27, 12], [27, 8], [28, 13], [28, 7], [29, 14], [29, 6], [30, 15], [31, 14], [32, 13], [33, 12], [34, 11], [35, 10], [34, 9], [33, 8], [32, 7], [31, 6], [30, 5], [24, 10], [25, 11], [25, 9], [26, 12], [26, 8], [27, 13], [27, 7], [28, 14], [28, 6], [29, 15], [29, 5], [30, 16], [31, 15], [32, 14], [33, 13], [34, 12], [35, 11], [36, 10], [35, 9], [34, 8], [33, 7], [32, 6], [31, 5], [30, 4], [23, 10], [24, 11], [24, 9], [25, 12], [25, 8], [26, 13], [26, 7], [27, 14], [27, 6], [28, 15], [28, 5], [29, 16], [29, 4], [30, 17], [31, 16], [32, 15], [33, 14], [34, 13], [35, 12], [36, 11], [37, 10], [36, 9], [35, 8], [34, 7], [33, 6], [32, 5], [31, 4], [30, 3], [22, 10], [23, 11], [23, 9], [24, 12], [24, 8], [25, 13], [25, 7], [26, 14], [26, 6], [27, 15], [27, 5], [28, 16], [28, 4], [29, 17], [29, 3], [30, 18], [31, 17], [32, 16], [33, 15], [34, 14], [35, 13], [36, 12], [37, 11], [38, 10], [37, 9], [36, 8], [35, 7], [34, 6], [33, 5], [32, 4], [31, 3], [30, 2], [21, 10], [22, 11], [22, 9], [23, 12], [23, 8], [24, 13], [24, 7], [25, 14], [25, 6], [26, 15], [26, 5], [27, 16], [27, 4], [28, 17], [28, 3], [29, 18], [29, 2], [30, 19], [31, 18], [32, 17], [33, 16], [34, 15], [35, 14], [36, 13], [37, 12], [38, 11], [39, 10], [38, 9], [37, 8], [36, 7], [35, 6], [34, 5], [33, 4], [32, 3], [31, 2], [30, 1], [20, 10], [21, 11], [21, 9], [22, 12], [22, 8], [23, 13], [23, 7], [24, 14], [24, 6], [25, 15], [25, 5], [26, 16], [26, 4], [27, 17], [27, 3], [28, 18], [28, 2], [29, 19], [29, 1], [30, 20], [31, 19], [32, 18], [33, 17], [34, 16], [35, 15], [36, 14], [37, 13], [38, 12], [39, 11], [40, 10], [39, 9], [38, 8], [37, 7], [36, 6], [35, 5], [34, 4], [33, 3], [32, 2], [31, 1], [30, 0], [19, 10], [20, 11], [20, 9], [21, 12], [21, 8], [22, 13], [22, 7], [23, 14], [23, 6], [24, 15], [24, 5], [25, 16], [25, 4], [26, 17], [26, 3], [27, 18], [27, 2], [28, 19], [28, 1], [29, 20], [29, 0], [30, 21], [31, 20], [32, 19], [33, 18], [34, 17], [35, 16], [36, 15], [37, 14], [38, 13], [39, 12], [40, 11], [41, 10], [40, 9], [39, 8], [38, 7], [37, 6], [36, 5], [35, 4], [34, 3], [33, 2], [32, 1], [31, 0], [18, 10], [19, 11], [19, 9], [20, 12], [20, 8], [21, 13], [21, 7], [22, 14], [22, 6], [23, 15], [23, 5], [24, 16], [24, 4], [25, 17], [25, 3], [26, 18], [26, 2], [27, 19], [27, 1], [28, 20], [28, 0], [29, 21], [30, 22], [31, 21], [32, 20], [33, 19], [34, 18], [35, 17], [36, 16], [37, 15], [38, 14], [39, 13], [40, 12], [41, 11], [42, 10], [41, 9], [40, 8], [39, 7], [38, 6], [37, 5], [36, 4], [35, 3], [34, 2], [33, 1], [32, 0], [17, 10], [18, 11], [18, 9], [19, 12], [19, 8], [20, 13], [20, 7], [21, 14], [21, 6], [22, 15], [22, 5], [23, 16], [23, 4], [24, 17], [24, 3], [25, 18], [25, 2], [26, 19], [26, 1], [27, 20], [27, 0], [28, 21], [29, 22], [30, 23], [31, 22], [32, 21], [33, 20], [34, 19], [35, 18], [36, 17], [37, 16], [38, 15], [39, 14], [40, 13], [41, 12], [42, 11], [43, 10], [42, 9], [41, 8], [40, 7], [39, 6], [38, 5], [37, 4], [36, 3], [35, 2], [34, 1], [33, 0], [16, 10], [17, 11], [17, 9], [18, 12], [18, 8], [19, 13], [19, 7], [20, 14], [20, 6], [21, 15], [21, 5], [22, 16], [22, 4], [23, 17], [23, 3], [24, 18], [24, 2], [25, 19], [25, 1], [26, 20], [26, 0], [27, 21], [28, 22], [29, 23], [30, 24], [31, 23], [32, 22], [33, 21], [34, 20], [35, 19], [36, 18], [37, 17], [38, 16], [39, 15], [40, 14], [41, 13], [42, 12], [43, 11], [44, 10], [43, 9], [42, 8], [41, 7], [40, 6], [39, 5], [38, 4], [37, 3], [36, 2], [35, 1], [34, 0], [15, 10], [16, 11], [16, 9], [17, 12], [17, 8], [18, 13], [18, 7], [19, 14], [19, 6], [20, 15], [20, 5], [21, 16], [21, 4], [22, 17], [22, 3], [23, 18], [23, 2], [24, 19], [24, 1], [25, 20], [25, 0], [26, 21], [27, 22], [28, 23], [29, 24], [31, 24], [32, 23], [33, 22], [34, 21], [35, 20], [36, 19], [37, 18], [38, 17], [39, 16], [40, 15], [41, 14], [42, 13], [43, 12], [44, 11], [45, 10], [44, 9], [43, 8], [42, 7], [41, 6], [40, 5], [39, 4], [38, 3], [37, 2], [36, 1], [35, 0], [14, 10], [15, 11], [15, 9], [16, 12], [16, 8], [17, 13], [17, 7], [18, 14], [18, 6], [19, 15], [19, 5], [20, 16], [20, 4], [21, 17], [21, 3], [22, 18], [22, 2], [23, 19], [23, 1], [24, 20], [24, 0], [25, 21], [26, 22], [27, 23], [28, 24], [32, 24], [33, 23], [34, 22], [35, 21], [36, 20], [37, 19], [38, 18], [39, 17], [40, 16], [41, 15], [42, 14], [43, 13], [44, 12], [45, 11], [46, 10], [45, 9], [44, 8], [43, 7], [42, 6], [41, 5], [40, 4], [39, 3], [38, 2], [37, 1], [36, 0], [13, 10], [14, 11], [14, 9], [15, 12], [15, 8], [16, 13], [16, 7], [17, 14], [17, 6], [18, 15], [18, 5], [19, 16], [19, 4], [20, 17], [20, 3], [21, 18], [21, 2], [22, 19], [22, 1], [23, 20], [23, 0], [24, 21], [25, 22], [26, 23], [27, 24], [33, 24], [34, 23], [35, 22], [36, 21], [37, 20], [38, 19], [39, 18], [40, 17], [41, 16], [42, 15], [43, 14], [44, 13], [45, 12], [46, 11], [47, 10], [46, 9], [45, 8], [44, 7], [43, 6], [42, 5], [41, 4], [40, 3], [39, 2], [38, 1], [37, 0], [12, 10], [13, 11], [13, 9], [14, 12], [14, 8], [15, 13], [15, 7], [16, 14], [16, 6], [17, 15], [17, 5], [18, 16], [18, 4], [19, 17], [19, 3], [20, 18], [20, 2], [21, 19], [21, 1], [22, 20], [22, 0], [23, 21], [24, 22], [25, 23], [26, 24], [34, 24], [35, 23], [36, 22], [37, 21], [38, 20], [39, 19], [40, 18], [41, 17], [42, 16], [43, 15], [44, 14], [45, 13], [46, 12], [47, 11], [48, 10], [47, 9], [46, 8], [45, 7], [44, 6], [43, 5], [42, 4], [41, 3], [40, 2], [39, 1], [38, 0], [11, 10], [12, 11], [12, 9], [13, 12], [13, 8], [14, 13], [14, 7], [15, 14], [15, 6], [16, 15], [16, 5], [17, 16], [17, 4], [18, 17], [18, 3], [19, 18], [19, 2], [20, 19], [20, 1], [21, 20], [21, 0], [22, 21], [23, 22], [24, 23], [25, 24], [35, 24], [36, 23], [37, 22], [38, 21], [39, 20], [40, 19], [41, 18], [42, 17], [43, 16], [44, 15], [45, 14], [46, 13], [47, 12], [48, 11], [49, 10], [48, 9], [47, 8], [46, 7], [45, 6], [44, 5], [43, 4], [42, 3], [41, 2], [40, 1], [39, 0], [10, 10], [11, 11], [11, 9], [12, 12], [12, 8], [13, 13], [13, 7], [14, 14], [14, 6], [15, 15], [15, 5], [16, 16], [16, 4], [17, 17], [17, 3], [18, 18], [18, 2], [19, 19], [19, 1], [20, 20], [20, 0], [21, 21], [22, 22], [23, 23], [24, 24], [36, 24], [37, 23], [38, 22], [39, 21], [40, 20], [41, 19], [42, 18], [43, 17], [44, 16], [45, 15], [46, 14], [47, 13], [48, 12], [49, 11], [50, 10], [49, 9], [48, 8], [47, 7], [46, 6], [45, 5], [44, 4], [43, 3], [42, 2], [41, 1], [40, 0], [9, 10], [10, 11], [10, 9], [11, 12], [11, 8], [12, 13], [12, 7], [13, 14], [13, 6], [14, 15], [14, 5], [15, 16], [15, 4], [16, 17], [16, 3], [17, 18], [17, 2], [18, 19], [18, 1], [19, 20], [19, 0], [20, 21], [21, 22], [22, 23], [23, 24], [37, 24], [38, 23], [39, 22], [40, 21], [41, 20], [42, 19], [43, 18], [44, 17], [45, 16], [46, 15], [47, 14], [48, 13], [49, 12], [50, 11], [51, 10], [50, 9], [49, 8], [48, 7], [47, 6], [46, 5], [45, 4], [44, 3], [43, 2], [42, 1], [41, 0], [8, 10], [9, 11], [9, 9], [10, 12], [10, 8], [11, 13], [11, 7], [12, 14], [12, 6], [13, 15], [13, 5], [14, 16], [14, 4], [15, 17], [15, 3], [16, 18], [16, 2], [17, 19], [17, 1], [18, 20], [18, 0], [19, 21], [20, 22], [21, 23], [22, 24], [38, 24], [39, 23], [40, 22], [41, 21], [42, 20], [43, 19], [44, 18], [45, 17], [46, 16], [47, 15], [48, 14], [49, 13], [50, 12], [51, 11], [52, 10], [51, 9], [50, 8], [49, 7], [48, 6], [47, 5], [46, 4], [45, 3], [44, 2], [43, 1], [42, 0], [7, 10], [8, 11], [8, 9], [9, 12], [9, 8], [10, 13], [10, 7], [11, 14], [11, 6], [12, 15], [12, 5], [13, 16], [13, 4], [14, 17], [14, 3], [15, 18], [15, 2], [16, 19], [16, 1], [17, 20], [17, 0], [18, 21], [19, 22], [20, 23], [21, 24], [39, 24], [40, 23], [41, 22], [42, 21], [43, 20], [44, 19], [45, 18], [46, 17], [47, 16], [48, 15], [49, 14], [50, 13], [51, 12], [52, 11], [53, 10], [52, 9], [51, 8], [50, 7], [49, 6], [48, 5], [47, 4], [46, 3], [45, 2], [44, 1], [43, 0], [6, 10], [7, 11], [7, 9], [8, 12], [8, 8], [9, 13], [9, 7], [10, 14], [10, 6], [11, 15], [11, 5], [12, 16], [12, 4], [13, 17], [13, 3], [14, 18], [14, 2], [15, 19], [15, 1], [16, 20], [16, 0], [17, 21], [18, 22], [19, 23], [20, 24], [40, 24], [41, 23], [42, 22], [43, 21], [44, 20], [45, 19], [46, 18], [47, 17], [48, 16], [49, 15], [50, 14], [51, 13], [52, 12], [53, 11], [54, 10], [53, 9], [52, 8], [51, 7], [50, 6], [49, 5], [48, 4], [47, 3], [46, 2], [45, 1], [44, 0], [5, 10], [6, 11], [6, 9], [7, 12], [7, 8], [8, 13], [8, 7], [9, 14], [9, 6], [10, 15], [10, 5], [11, 16], [11, 4], [12, 17], [12, 3], [13, 18], [13, 2], [14, 19], [14, 1], [15, 20], [15, 0], [16, 21], [17, 22], [18, 23], [19, 24], [41, 24], [42, 23], [43, 22], [44, 21], [45, 20], [46, 19], [47, 18], [48, 17], [49, 16], [50, 15], [51, 14], [52, 13], [53, 12], [54, 11], [55, 10], [54, 9], [53, 8], [52, 7], [51, 6], [50, 5], [49, 4], [48, 3], [47, 2], [46, 1], [45, 0], [4, 10], [5, 11], [5, 9], [6, 12], [6, 8], [7, 13], [7, 7], [8, 14], [8, 6], [9, 15], [9, 5], [10, 16], [10, 4], [11, 17], [11, 3], [12, 18], [12, 2], [13, 19], [13, 1], [14, 20], [14, 0], [15, 21], [16, 22], [17, 23], [18, 24], [42, 24], [43, 23], [44, 22], [45, 21], [46, 20], [47, 19], [48, 18], [49, 17], [50, 16], [51, 15], [52, 14], [53, 13], [54, 12], [55, 11], [56, 10], [55, 9], [54, 8], [53, 7], [52, 6], [51, 5], [50, 4], [49, 3], [48, 2], [47, 1], [46, 0], [3, 10], [4, 11], [4, 9], [5, 12], [5, 8], [6, 13], [6, 7], [7, 14], [7, 6], [8, 15], [8, 5], [9, 16], [9, 4], [10, 17], [10, 3], [11, 18], [11, 2], [12, 19], [12, 1], [13, 20], [13, 0], [14, 21], [15, 22], [16, 23], [17, 24], [43, 24], [44, 23], [45, 22], [46, 21], [47, 20], [48, 19], [49, 18], [50, 17], [51, 16], [52, 15], [53, 14], [54, 13], [55, 12], [56, 11], [57, 10], [56, 9], [55, 8], [54, 7], [53, 6], [52, 5], [51, 4], [50, 3], [49, 2], [48, 1], [47, 0], [2, 10], [3, 11], [3, 9], [4, 12], [4, 8], [5, 13], [5, 7], [6, 14], [6, 6], [7, 15], [7, 5], [8, 16], [8, 4], [9, 17], [9, 3], [10, 18], [10, 2], [11, 19], [11, 1], [12, 20], [12, 0], [13, 21], [14, 22], [15, 23], [16, 24], [44, 24], [45, 23], [46, 22], [47, 21], [48, 20], [49, 19], [50, 18], [51, 17], [52, 16], [53, 15], [54, 14], [55, 13], [56, 12], [57, 11], [58, 10], [57, 9], [56, 8], [55, 7], [54, 6], [53, 5], [52, 4], [51, 3], [50, 2], [49, 1], [48, 0], [1, 10], [2, 11], [2, 9], [3, 12], [3, 8], [4, 13], [4, 7], [5, 14], [5, 6], [6, 15], [6, 5], [7, 16], [7, 4], [8, 17], [8, 3], [9, 18], [9, 2], [10, 19], [10, 1], [11, 20], [11, 0], [12, 21], [13, 22], [14, 23], [15, 24], [45, 24], [46, 23], [47, 22], [48, 21], [49, 20], [50, 19], [51, 18], [52, 17], [53, 16], [54, 15], [55, 14], [56, 13], [57, 12], [58, 11], [59, 10], [58, 9], [57, 8], [56, 7], [55, 6], [54, 5], [53, 4], [52, 3], [51, 2], [50, 1], [49, 0], [0, 10], [1, 11], [1, 9], [2, 12], [2, 8], [3, 13], [3, 7], [4, 14], [4, 6], [5, 15], [5, 5], [6, 16], [6, 4], [7, 17], [7, 3], [8, 18], [8, 2], [9, 19], [9, 1], [10, 20], [10, 0], [11, 21], [12, 22], [13, 23], [14, 24], [46, 24], [47, 23], [48, 22], [49, 21], [50, 20], [51, 19], [52, 18], [53, 17], [54, 16], [55, 15], [56, 14], [57, 13], [58, 12], [59, 11], [59, 9], [58, 8], [57, 7], [56, 6], [55, 5], [54, 4], [53, 3], [52, 2], [51, 1], [50, 0], [0, 11], [0, 9], [1, 12], [1, 8], [2, 13], [2, 7], [3, 14], [3, 6], [4, 15], [4, 5], [5, 16], [5, 4], [6, 17], [6, 3], [7, 18], [7, 2], [8, 19], [8, 1], [9, 20], [9, 0], [10, 21], [11, 22], [12, 23], [13, 24], [47, 24], [48, 23], [49, 22], [50, 21], [51, 20], [52, 19], [53, 18], [54, 17], [55, 16], [56, 15], [57, 14], [58, 13], [59, 12], [59, 8], [58, 7], [57, 6], [56, 5], [55, 4], [54, 3], [53, 2], [52, 1], [51, 0], [0, 12], [0, 8], [1, 13], [1, 7], [2, 14], [2, 6], [3, 15], [3, 5], [4, 16], [4, 4], [5, 17], [5, 3], [6, 18], [6, 2], [7, 19], [7, 1], [8, 20], [8, 0], [9, 21], [10, 22], [11, 23], [12, 24], [48, 24], [49, 23], [50, 22], [51, 21], [52, 20], [53, 19], [54, 18], [55, 17], [56, 16], [57, 15], [58, 14], [59, 13], [59, 7], [58, 6], [57, 5], [56, 4], [55, 3], [54, 2], [53, 1], [52, 0], [0, 13], [0, 7], [1, 14], [1, 6], [2, 15], [2, 5], [3, 16], [3, 4], [4, 17], [4, 3], [5, 18], [5, 2], [6, 19], [6, 1], [7, 20], [7, 0], [8, 21], [9, 22], [10, 23], [11, 24], [49, 24], [50, 23], [51, 22], [52, 21], [53, 20], [54, 19], [55, 18], [56, 17], [57, 16], [58, 15], [59, 14], [59, 6], [58, 5], [57, 4], [56, 3], [55, 2], [54, 1], [53, 0], [0, 14], [0, 6], [1, 15], [1, 5], [2, 16], [2, 4], [3, 17], [3, 3], [4, 18], [4, 2], [5, 19], [5, 1], [6, 20], [6, 0], [7, 21], [8, 22], [9, 23], [10, 24], [50, 24], [51, 23], [52, 22], [53, 21], [54, 20], [55, 19], [56, 18], [57, 17], [58, 16], [59, 15], [59, 5], [58, 4], [57, 3], [56, 2], [55, 1], [54, 0], [0, 15], [0, 5], [1, 16], [1, 4], [2, 17], [2, 3], [3, 18], [3, 2], [4, 19], [4, 1], [5, 20], [5, 0], [6, 21], [7, 22], [8, 23], [9, 24], [51, 24], [52, 23], [53, 22], [54, 21], [55, 20], [56, 19], [57, 18], [58, 17], [59, 16], [59, 4], [58, 3], [57, 2], [56, 1], [55, 0], [0, 16], [0, 4], [1, 17], [1, 3], [2, 18], [2, 2], [3, 19], [3, 1], [4, 20], [4, 0], [5, 21], [6, 22], [7, 23], [8, 24], [52, 24], [53, 23], [54, 22], [55, 21], [56, 20], [57, 19], [58, 18], [59, 17], [59, 3], [58, 2], [57, 1], [56, 0], [0, 17], [0, 3], [1, 18], [1, 2], [2, 19], [2, 1], [3, 20], [3, 0], [4, 21], [5, 22], [6, 23], [7, 24], [53, 24], [54, 23], [55, 22], [56, 21], [57, 20], [58, 19], [59, 18], [59, 2], [58, 1], [57, 0], [0, 18], [0, 2], [1, 19], [1, 1], [2, 20], [2, 0], [3, 21], [4, 22], [5, 23], [6, 24], [54, 24], [55, 23], [56, 22], [57, 21], [58, 20], [59, 19], [59, 1], [58, 0], [0, 19], [0, 1], [1, 20], [1, 0], [2, 21], [3, 22], [4, 23], [5, 24], [55, 24], [56, 23], [57, 22], [58, 21], [59, 20], [59, 0], [0, 20], [0, 0], [1, 21], [2, 22], [3, 23], [4, 24], [56, 24], [57, 23], [58, 22], [59, 21], [0, 21], [1, 22], [2, 23], [3, 24], [57, 24], [58, 23], [59, 22], [0, 22], [1, 23], [2, 24], [58, 24], [59, 23], [0, 23], [1, 24], [59, 24], [0, 24]]\n assert candidate(rows = 15,cols = 10,rCenter = 2,cCenter = 8) == [[2, 8], [1, 8], [2, 9], [3, 8], [2, 7], [0, 8], [1, 9], [1, 7], [3, 9], [4, 8], [3, 7], [2, 6], [0, 9], [0, 7], [1, 6], [4, 9], [5, 8], [4, 7], [3, 6], [2, 5], [0, 6], [1, 5], [5, 9], [6, 8], [5, 7], [4, 6], [3, 5], [2, 4], [0, 5], [1, 4], [6, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [0, 4], [1, 3], [7, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [0, 3], [1, 2], [8, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [0, 2], [1, 1], [9, 9], [10, 8], [9, 7], [8, 6], [7, 5], [6, 4], [5, 3], [4, 2], [3, 1], [2, 0], [0, 1], [1, 0], [10, 9], [11, 8], [10, 7], [9, 6], [8, 5], [7, 4], [6, 3], [5, 2], [4, 1], [3, 0], [0, 0], [11, 9], [12, 8], [11, 7], [10, 6], [9, 5], [8, 4], [7, 3], [6, 2], [5, 1], [4, 0], [12, 9], [13, 8], [12, 7], [11, 6], [10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [5, 0], [13, 9], [14, 8], [13, 7], [12, 6], [11, 5], [10, 4], [9, 3], [8, 2], [7, 1], [6, 0], [14, 9], [14, 7], [13, 6], [12, 5], [11, 4], [10, 3], [9, 2], [8, 1], [7, 0], [14, 6], [13, 5], [12, 4], [11, 3], [10, 2], [9, 1], [8, 0], [14, 5], [13, 4], [12, 3], [11, 2], [10, 1], [9, 0], [14, 4], [13, 3], [12, 2], [11, 1], [10, 0], [14, 3], [13, 2], [12, 1], [11, 0], [14, 2], [13, 1], [12, 0], [14, 1], [13, 0], [14, 0]]\n assert candidate(rows = 5,cols = 8,rCenter = 0,cCenter = 7) == [[0, 7], [1, 7], [0, 6], [2, 7], [1, 6], [0, 5], [3, 7], [2, 6], [1, 5], [0, 4], [4, 7], [3, 6], [2, 5], [1, 4], [0, 3], [4, 6], [3, 5], [2, 4], [1, 3], [0, 2], [4, 5], [3, 4], [2, 3], [1, 2], [0, 1], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [4, 3], [3, 2], [2, 1], [1, 0], [4, 2], [3, 1], [2, 0], [4, 1], [3, 0], [4, 0]]\n assert candidate(rows = 1,cols = 10,rCenter = 0,cCenter = 5) == [[0, 5], [0, 6], [0, 4], [0, 7], [0, 3], [0, 8], [0, 2], [0, 9], [0, 1], [0, 0]]\n assert candidate(rows = 9,cols = 9,rCenter = 8,cCenter = 8) == [[8, 8], [7, 8], [8, 7], [6, 8], [7, 7], [8, 6], [5, 8], [6, 7], [7, 6], [8, 5], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 6,cols = 4,rCenter = 3,cCenter = 3) == [[3, 3], [2, 3], [4, 3], [3, 2], [1, 3], [2, 2], [5, 3], [4, 2], [3, 1], [0, 3], [1, 2], [2, 1], [5, 2], [4, 1], [3, 0], [0, 2], [1, 1], [2, 0], [5, 1], [4, 0], [0, 1], [1, 0], [5, 0], [0, 0]]\n assert candidate(rows = 50,cols = 50,rCenter = 0,cCenter = 0) == [[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], [5, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 0], [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], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [11, 2], [12, 1], [13, 0], [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, 0], [0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [8, 7], [9, 6], [10, 5], [11, 4], [12, 3], [13, 2], [14, 1], [15, 0], [0, 16], [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, 0], [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], [0, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [9, 9], [10, 8], [11, 7], [12, 6], [13, 5], [14, 4], [15, 3], [16, 2], [17, 1], [18, 0], [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], [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], [20, 0], [0, 21], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1], [21, 0], [0, 22], [1, 21], [2, 20], [3, 19], [4, 18], [5, 17], [6, 16], [7, 15], [8, 14], [9, 13], [10, 12], [11, 11], [12, 10], [13, 9], [14, 8], [15, 7], [16, 6], [17, 5], [18, 4], [19, 3], [20, 2], [21, 1], [22, 0], [0, 23], [1, 22], [2, 21], [3, 20], [4, 19], [5, 18], [6, 17], [7, 16], [8, 15], [9, 14], [10, 13], [11, 12], [12, 11], [13, 10], [14, 9], [15, 8], [16, 7], [17, 6], [18, 5], [19, 4], [20, 3], [21, 2], [22, 1], [23, 0], [0, 24], [1, 23], [2, 22], [3, 21], [4, 20], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15], [10, 14], [11, 13], [12, 12], [13, 11], [14, 10], [15, 9], [16, 8], [17, 7], [18, 6], [19, 5], [20, 4], [21, 3], [22, 2], [23, 1], [24, 0], [0, 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], [13, 12], [14, 11], [15, 10], [16, 9], [17, 8], [18, 7], [19, 6], [20, 5], [21, 4], [22, 3], [23, 2], [24, 1], [25, 0], [0, 26], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [13, 13], [14, 12], [15, 11], [16, 10], [17, 9], [18, 8], [19, 7], [20, 6], [21, 5], [22, 4], [23, 3], [24, 2], [25, 1], [26, 0], [0, 27], [1, 26], [2, 25], [3, 24], [4, 23], [5, 22], [6, 21], [7, 20], [8, 19], [9, 18], [10, 17], [11, 16], [12, 15], [13, 14], [14, 13], [15, 12], [16, 11], [17, 10], [18, 9], [19, 8], [20, 7], [21, 6], [22, 5], [23, 4], [24, 3], [25, 2], [26, 1], [27, 0], [0, 28], [1, 27], [2, 26], [3, 25], [4, 24], [5, 23], [6, 22], [7, 21], [8, 20], [9, 19], [10, 18], [11, 17], [12, 16], [13, 15], [14, 14], [15, 13], [16, 12], [17, 11], [18, 10], [19, 9], [20, 8], [21, 7], [22, 6], [23, 5], [24, 4], [25, 3], [26, 2], [27, 1], [28, 0], [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], [15, 14], [16, 13], [17, 12], [18, 11], [19, 10], [20, 9], [21, 8], [22, 7], [23, 6], [24, 5], [25, 4], [26, 3], [27, 2], [28, 1], [29, 0], [0, 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, 15], [16, 14], [17, 13], [18, 12], [19, 11], [20, 10], [21, 9], [22, 8], [23, 7], [24, 6], [25, 5], [26, 4], [27, 3], [28, 2], [29, 1], [30, 0], [0, 31], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16], [16, 15], [17, 14], [18, 13], [19, 12], [20, 11], [21, 10], [22, 9], [23, 8], [24, 7], [25, 6], [26, 5], [27, 4], [28, 3], [29, 2], [30, 1], [31, 0], [0, 32], [1, 31], [2, 30], [3, 29], [4, 28], [5, 27], [6, 26], [7, 25], [8, 24], [9, 23], [10, 22], [11, 21], [12, 20], [13, 19], [14, 18], [15, 17], [16, 16], [17, 15], [18, 14], [19, 13], [20, 12], [21, 11], [22, 10], [23, 9], [24, 8], [25, 7], [26, 6], [27, 5], [28, 4], [29, 3], [30, 2], [31, 1], [32, 0], [0, 33], [1, 32], [2, 31], [3, 30], [4, 29], [5, 28], [6, 27], [7, 26], [8, 25], [9, 24], [10, 23], [11, 22], [12, 21], [13, 20], [14, 19], [15, 18], [16, 17], [17, 16], [18, 15], [19, 14], [20, 13], [21, 12], [22, 11], [23, 10], [24, 9], [25, 8], [26, 7], [27, 6], [28, 5], [29, 4], [30, 3], [31, 2], [32, 1], [33, 0], [0, 34], [1, 33], [2, 32], [3, 31], [4, 30], [5, 29], [6, 28], [7, 27], [8, 26], [9, 25], [10, 24], [11, 23], [12, 22], [13, 21], [14, 20], [15, 19], [16, 18], [17, 17], [18, 16], [19, 15], [20, 14], [21, 13], [22, 12], [23, 11], [24, 10], [25, 9], [26, 8], [27, 7], [28, 6], [29, 5], [30, 4], [31, 3], [32, 2], [33, 1], [34, 0], [0, 35], [1, 34], [2, 33], [3, 32], [4, 31], [5, 30], [6, 29], [7, 28], [8, 27], [9, 26], [10, 25], [11, 24], [12, 23], [13, 22], [14, 21], [15, 20], [16, 19], [17, 18], [18, 17], [19, 16], [20, 15], [21, 14], [22, 13], [23, 12], [24, 11], [25, 10], [26, 9], [27, 8], [28, 7], [29, 6], [30, 5], [31, 4], [32, 3], [33, 2], [34, 1], [35, 0], [0, 36], [1, 35], [2, 34], [3, 33], [4, 32], [5, 31], [6, 30], [7, 29], [8, 28], [9, 27], [10, 26], [11, 25], [12, 24], [13, 23], [14, 22], [15, 21], [16, 20], [17, 19], [18, 18], [19, 17], [20, 16], [21, 15], [22, 14], [23, 13], [24, 12], [25, 11], [26, 10], [27, 9], [28, 8], [29, 7], [30, 6], [31, 5], [32, 4], [33, 3], [34, 2], [35, 1], [36, 0], [0, 37], [1, 36], [2, 35], [3, 34], [4, 33], [5, 32], [6, 31], [7, 30], [8, 29], [9, 28], [10, 27], [11, 26], [12, 25], [13, 24], [14, 23], [15, 22], [16, 21], [17, 20], [18, 19], [19, 18], [20, 17], [21, 16], [22, 15], [23, 14], [24, 13], [25, 12], [26, 11], [27, 10], [28, 9], [29, 8], [30, 7], [31, 6], [32, 5], [33, 4], [34, 3], [35, 2], [36, 1], [37, 0], [0, 38], [1, 37], [2, 36], [3, 35], [4, 34], [5, 33], [6, 32], [7, 31], [8, 30], [9, 29], [10, 28], [11, 27], [12, 26], [13, 25], [14, 24], [15, 23], [16, 22], [17, 21], [18, 20], [19, 19], [20, 18], [21, 17], [22, 16], [23, 15], [24, 14], [25, 13], [26, 12], [27, 11], [28, 10], [29, 9], [30, 8], [31, 7], [32, 6], [33, 5], [34, 4], [35, 3], [36, 2], [37, 1], [38, 0], [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], [20, 19], [21, 18], [22, 17], [23, 16], [24, 15], [25, 14], [26, 13], [27, 12], [28, 11], [29, 10], [30, 9], [31, 8], [32, 7], [33, 6], [34, 5], [35, 4], [36, 3], [37, 2], [38, 1], [39, 0], [0, 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, 20], [21, 19], [22, 18], [23, 17], [24, 16], [25, 15], [26, 14], [27, 13], [28, 12], [29, 11], [30, 10], [31, 9], [32, 8], [33, 7], [34, 6], [35, 5], [36, 4], [37, 3], [38, 2], [39, 1], [40, 0], [0, 41], [1, 40], [2, 39], [3, 38], [4, 37], [5, 36], [6, 35], [7, 34], [8, 33], [9, 32], [10, 31], [11, 30], [12, 29], [13, 28], [14, 27], [15, 26], [16, 25], [17, 24], [18, 23], [19, 22], [20, 21], [21, 20], [22, 19], [23, 18], [24, 17], [25, 16], [26, 15], [27, 14], [28, 13], [29, 12], [30, 11], [31, 10], [32, 9], [33, 8], [34, 7], [35, 6], [36, 5], [37, 4], [38, 3], [39, 2], [40, 1], [41, 0], [0, 42], [1, 41], [2, 40], [3, 39], [4, 38], [5, 37], [6, 36], [7, 35], [8, 34], [9, 33], [10, 32], [11, 31], [12, 30], [13, 29], [14, 28], [15, 27], [16, 26], [17, 25], [18, 24], [19, 23], [20, 22], [21, 21], [22, 20], [23, 19], [24, 18], [25, 17], [26, 16], [27, 15], [28, 14], [29, 13], [30, 12], [31, 11], [32, 10], [33, 9], [34, 8], [35, 7], [36, 6], [37, 5], [38, 4], [39, 3], [40, 2], [41, 1], [42, 0], [0, 43], [1, 42], [2, 41], [3, 40], [4, 39], [5, 38], [6, 37], [7, 36], [8, 35], [9, 34], [10, 33], [11, 32], [12, 31], [13, 30], [14, 29], [15, 28], [16, 27], [17, 26], [18, 25], [19, 24], [20, 23], [21, 22], [22, 21], [23, 20], [24, 19], [25, 18], [26, 17], [27, 16], [28, 15], [29, 14], [30, 13], [31, 12], [32, 11], [33, 10], [34, 9], [35, 8], [36, 7], [37, 6], [38, 5], [39, 4], [40, 3], [41, 2], [42, 1], [43, 0], [0, 44], [1, 43], [2, 42], [3, 41], [4, 40], [5, 39], [6, 38], [7, 37], [8, 36], [9, 35], [10, 34], [11, 33], [12, 32], [13, 31], [14, 30], [15, 29], [16, 28], [17, 27], [18, 26], [19, 25], [20, 24], [21, 23], [22, 22], [23, 21], [24, 20], [25, 19], [26, 18], [27, 17], [28, 16], [29, 15], [30, 14], [31, 13], [32, 12], [33, 11], [34, 10], [35, 9], [36, 8], [37, 7], [38, 6], [39, 5], [40, 4], [41, 3], [42, 2], [43, 1], [44, 0], [0, 45], [1, 44], [2, 43], [3, 42], [4, 41], [5, 40], [6, 39], [7, 38], [8, 37], [9, 36], [10, 35], [11, 34], [12, 33], [13, 32], [14, 31], [15, 30], [16, 29], [17, 28], [18, 27], [19, 26], [20, 25], [21, 24], [22, 23], [23, 22], [24, 21], [25, 20], [26, 19], [27, 18], [28, 17], [29, 16], [30, 15], [31, 14], [32, 13], [33, 12], [34, 11], [35, 10], [36, 9], [37, 8], [38, 7], [39, 6], [40, 5], [41, 4], [42, 3], [43, 2], [44, 1], [45, 0], [0, 46], [1, 45], [2, 44], [3, 43], [4, 42], [5, 41], [6, 40], [7, 39], [8, 38], [9, 37], [10, 36], [11, 35], [12, 34], [13, 33], [14, 32], [15, 31], [16, 30], [17, 29], [18, 28], [19, 27], [20, 26], [21, 25], [22, 24], [23, 23], [24, 22], [25, 21], [26, 20], [27, 19], [28, 18], [29, 17], [30, 16], [31, 15], [32, 14], [33, 13], [34, 12], [35, 11], [36, 10], [37, 9], [38, 8], [39, 7], [40, 6], [41, 5], [42, 4], [43, 3], [44, 2], [45, 1], [46, 0], [0, 47], [1, 46], [2, 45], [3, 44], [4, 43], [5, 42], [6, 41], [7, 40], [8, 39], [9, 38], [10, 37], [11, 36], [12, 35], [13, 34], [14, 33], [15, 32], [16, 31], [17, 30], [18, 29], [19, 28], [20, 27], [21, 26], [22, 25], [23, 24], [24, 23], [25, 22], [26, 21], [27, 20], [28, 19], [29, 18], [30, 17], [31, 16], [32, 15], [33, 14], [34, 13], [35, 12], [36, 11], [37, 10], [38, 9], [39, 8], [40, 7], [41, 6], [42, 5], [43, 4], [44, 3], [45, 2], [46, 1], [47, 0], [0, 48], [1, 47], [2, 46], [3, 45], [4, 44], [5, 43], [6, 42], [7, 41], [8, 40], [9, 39], [10, 38], [11, 37], [12, 36], [13, 35], [14, 34], [15, 33], [16, 32], [17, 31], [18, 30], [19, 29], [20, 28], [21, 27], [22, 26], [23, 25], [24, 24], [25, 23], [26, 22], [27, 21], [28, 20], [29, 19], [30, 18], [31, 17], [32, 16], [33, 15], [34, 14], [35, 13], [36, 12], [37, 11], [38, 10], [39, 9], [40, 8], [41, 7], [42, 6], [43, 5], [44, 4], [45, 3], [46, 2], [47, 1], [48, 0], [0, 49], [1, 48], [2, 47], [3, 46], [4, 45], [5, 44], [6, 43], [7, 42], [8, 41], [9, 40], [10, 39], [11, 38], [12, 37], [13, 36], [14, 35], [15, 34], [16, 33], [17, 32], [18, 31], [19, 30], [20, 29], [21, 28], [22, 27], [23, 26], [24, 25], [25, 24], [26, 23], [27, 22], [28, 21], [29, 20], [30, 19], [31, 18], [32, 17], [33, 16], [34, 15], [35, 14], [36, 13], [37, 12], [38, 11], [39, 10], [40, 9], [41, 8], [42, 7], [43, 6], [44, 5], [45, 4], [46, 3], [47, 2], [48, 1], [49, 0], [1, 49], [2, 48], [3, 47], [4, 46], [5, 45], [6, 44], [7, 43], [8, 42], [9, 41], [10, 40], [11, 39], [12, 38], [13, 37], [14, 36], [15, 35], [16, 34], [17, 33], [18, 32], [19, 31], [20, 30], [21, 29], [22, 28], [23, 27], [24, 26], [25, 25], [26, 24], [27, 23], [28, 22], [29, 21], [30, 20], [31, 19], [32, 18], [33, 17], [34, 16], [35, 15], [36, 14], [37, 13], [38, 12], [39, 11], [40, 10], [41, 9], [42, 8], [43, 7], [44, 6], [45, 5], [46, 4], [47, 3], [48, 2], [49, 1], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41], [11, 40], [12, 39], [13, 38], [14, 37], [15, 36], [16, 35], [17, 34], [18, 33], [19, 32], [20, 31], [21, 30], [22, 29], [23, 28], [24, 27], [25, 26], [26, 25], [27, 24], [28, 23], [29, 22], [30, 21], [31, 20], [32, 19], [33, 18], [34, 17], [35, 16], [36, 15], [37, 14], [38, 13], [39, 12], [40, 11], [41, 10], [42, 9], [43, 8], [44, 7], [45, 6], [46, 5], [47, 4], [48, 3], [49, 2], [3, 49], [4, 48], [5, 47], [6, 46], [7, 45], [8, 44], [9, 43], [10, 42], [11, 41], [12, 40], [13, 39], [14, 38], [15, 37], [16, 36], [17, 35], [18, 34], [19, 33], [20, 32], [21, 31], [22, 30], [23, 29], [24, 28], [25, 27], [26, 26], [27, 25], [28, 24], [29, 23], [30, 22], [31, 21], [32, 20], [33, 19], [34, 18], [35, 17], [36, 16], [37, 15], [38, 14], [39, 13], [40, 12], [41, 11], [42, 10], [43, 9], [44, 8], [45, 7], [46, 6], [47, 5], [48, 4], [49, 3], [4, 49], [5, 48], [6, 47], [7, 46], [8, 45], [9, 44], [10, 43], [11, 42], [12, 41], [13, 40], [14, 39], [15, 38], [16, 37], [17, 36], [18, 35], [19, 34], [20, 33], [21, 32], [22, 31], [23, 30], [24, 29], [25, 28], [26, 27], [27, 26], [28, 25], [29, 24], [30, 23], [31, 22], [32, 21], [33, 20], [34, 19], [35, 18], [36, 17], [37, 16], [38, 15], [39, 14], [40, 13], [41, 12], [42, 11], [43, 10], [44, 9], [45, 8], [46, 7], [47, 6], [48, 5], [49, 4], [5, 49], [6, 48], [7, 47], [8, 46], [9, 45], [10, 44], [11, 43], [12, 42], [13, 41], [14, 40], [15, 39], [16, 38], [17, 37], [18, 36], [19, 35], [20, 34], [21, 33], [22, 32], [23, 31], [24, 30], [25, 29], [26, 28], [27, 27], [28, 26], [29, 25], [30, 24], [31, 23], [32, 22], [33, 21], [34, 20], [35, 19], [36, 18], [37, 17], [38, 16], [39, 15], [40, 14], [41, 13], [42, 12], [43, 11], [44, 10], [45, 9], [46, 8], [47, 7], [48, 6], [49, 5], [6, 49], [7, 48], [8, 47], [9, 46], [10, 45], [11, 44], [12, 43], [13, 42], [14, 41], [15, 40], [16, 39], [17, 38], [18, 37], [19, 36], [20, 35], [21, 34], [22, 33], [23, 32], [24, 31], [25, 30], [26, 29], [27, 28], [28, 27], [29, 26], [30, 25], [31, 24], [32, 23], [33, 22], [34, 21], [35, 20], [36, 19], [37, 18], [38, 17], [39, 16], [40, 15], [41, 14], [42, 13], [43, 12], [44, 11], [45, 10], [46, 9], [47, 8], [48, 7], [49, 6], [7, 49], [8, 48], [9, 47], [10, 46], [11, 45], [12, 44], [13, 43], [14, 42], [15, 41], [16, 40], [17, 39], [18, 38], [19, 37], [20, 36], [21, 35], [22, 34], [23, 33], [24, 32], [25, 31], [26, 30], [27, 29], [28, 28], [29, 27], [30, 26], [31, 25], [32, 24], [33, 23], [34, 22], [35, 21], [36, 20], [37, 19], [38, 18], [39, 17], [40, 16], [41, 15], [42, 14], [43, 13], [44, 12], [45, 11], [46, 10], [47, 9], [48, 8], [49, 7], [8, 49], [9, 48], [10, 47], [11, 46], [12, 45], [13, 44], [14, 43], [15, 42], [16, 41], [17, 40], [18, 39], [19, 38], [20, 37], [21, 36], [22, 35], [23, 34], [24, 33], [25, 32], [26, 31], [27, 30], [28, 29], [29, 28], [30, 27], [31, 26], [32, 25], [33, 24], [34, 23], [35, 22], [36, 21], [37, 20], [38, 19], [39, 18], [40, 17], [41, 16], [42, 15], [43, 14], [44, 13], [45, 12], [46, 11], [47, 10], [48, 9], [49, 8], [9, 49], [10, 48], [11, 47], [12, 46], [13, 45], [14, 44], [15, 43], [16, 42], [17, 41], [18, 40], [19, 39], [20, 38], [21, 37], [22, 36], [23, 35], [24, 34], [25, 33], [26, 32], [27, 31], [28, 30], [29, 29], [30, 28], [31, 27], [32, 26], [33, 25], [34, 24], [35, 23], [36, 22], [37, 21], [38, 20], [39, 19], [40, 18], [41, 17], [42, 16], [43, 15], [44, 14], [45, 13], [46, 12], [47, 11], [48, 10], [49, 9], [10, 49], [11, 48], [12, 47], [13, 46], [14, 45], [15, 44], [16, 43], [17, 42], [18, 41], [19, 40], [20, 39], [21, 38], [22, 37], [23, 36], [24, 35], [25, 34], [26, 33], [27, 32], [28, 31], [29, 30], [30, 29], [31, 28], [32, 27], [33, 26], [34, 25], [35, 24], [36, 23], [37, 22], [38, 21], [39, 20], [40, 19], [41, 18], [42, 17], [43, 16], [44, 15], [45, 14], [46, 13], [47, 12], [48, 11], [49, 10], [11, 49], [12, 48], [13, 47], [14, 46], [15, 45], [16, 44], [17, 43], [18, 42], [19, 41], [20, 40], [21, 39], [22, 38], [23, 37], [24, 36], [25, 35], [26, 34], [27, 33], [28, 32], [29, 31], [30, 30], [31, 29], [32, 28], [33, 27], [34, 26], [35, 25], [36, 24], [37, 23], [38, 22], [39, 21], [40, 20], [41, 19], [42, 18], [43, 17], [44, 16], [45, 15], [46, 14], [47, 13], [48, 12], [49, 11], [12, 49], [13, 48], [14, 47], [15, 46], [16, 45], [17, 44], [18, 43], [19, 42], [20, 41], [21, 40], [22, 39], [23, 38], [24, 37], [25, 36], [26, 35], [27, 34], [28, 33], [29, 32], [30, 31], [31, 30], [32, 29], [33, 28], [34, 27], [35, 26], [36, 25], [37, 24], [38, 23], [39, 22], [40, 21], [41, 20], [42, 19], [43, 18], [44, 17], [45, 16], [46, 15], [47, 14], [48, 13], [49, 12], [13, 49], [14, 48], [15, 47], [16, 46], [17, 45], [18, 44], [19, 43], [20, 42], [21, 41], [22, 40], [23, 39], [24, 38], [25, 37], [26, 36], [27, 35], [28, 34], [29, 33], [30, 32], [31, 31], [32, 30], [33, 29], [34, 28], [35, 27], [36, 26], [37, 25], [38, 24], [39, 23], [40, 22], [41, 21], [42, 20], [43, 19], [44, 18], [45, 17], [46, 16], [47, 15], [48, 14], [49, 13], [14, 49], [15, 48], [16, 47], [17, 46], [18, 45], [19, 44], [20, 43], [21, 42], [22, 41], [23, 40], [24, 39], [25, 38], [26, 37], [27, 36], [28, 35], [29, 34], [30, 33], [31, 32], [32, 31], [33, 30], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [39, 24], [40, 23], [41, 22], [42, 21], [43, 20], [44, 19], [45, 18], [46, 17], [47, 16], [48, 15], [49, 14], [15, 49], [16, 48], [17, 47], [18, 46], [19, 45], [20, 44], [21, 43], [22, 42], [23, 41], [24, 40], [25, 39], [26, 38], [27, 37], [28, 36], [29, 35], [30, 34], [31, 33], [32, 32], [33, 31], [34, 30], [35, 29], [36, 28], [37, 27], [38, 26], [39, 25], [40, 24], [41, 23], [42, 22], [43, 21], [44, 20], [45, 19], [46, 18], [47, 17], [48, 16], [49, 15], [16, 49], [17, 48], [18, 47], [19, 46], [20, 45], [21, 44], [22, 43], [23, 42], [24, 41], [25, 40], [26, 39], [27, 38], [28, 37], [29, 36], [30, 35], [31, 34], [32, 33], [33, 32], [34, 31], [35, 30], [36, 29], [37, 28], [38, 27], [39, 26], [40, 25], [41, 24], [42, 23], [43, 22], [44, 21], [45, 20], [46, 19], [47, 18], [48, 17], [49, 16], [17, 49], [18, 48], [19, 47], [20, 46], [21, 45], [22, 44], [23, 43], [24, 42], [25, 41], [26, 40], [27, 39], [28, 38], [29, 37], [30, 36], [31, 35], [32, 34], [33, 33], [34, 32], [35, 31], [36, 30], [37, 29], [38, 28], [39, 27], [40, 26], [41, 25], [42, 24], [43, 23], [44, 22], [45, 21], [46, 20], [47, 19], [48, 18], [49, 17], [18, 49], [19, 48], [20, 47], [21, 46], [22, 45], [23, 44], [24, 43], [25, 42], [26, 41], [27, 40], [28, 39], [29, 38], [30, 37], [31, 36], [32, 35], [33, 34], [34, 33], [35, 32], [36, 31], [37, 30], [38, 29], [39, 28], [40, 27], [41, 26], [42, 25], [43, 24], [44, 23], [45, 22], [46, 21], [47, 20], [48, 19], [49, 18], [19, 49], [20, 48], [21, 47], [22, 46], [23, 45], [24, 44], [25, 43], [26, 42], [27, 41], [28, 40], [29, 39], [30, 38], [31, 37], [32, 36], [33, 35], [34, 34], [35, 33], [36, 32], [37, 31], [38, 30], [39, 29], [40, 28], [41, 27], [42, 26], [43, 25], [44, 24], [45, 23], [46, 22], [47, 21], [48, 20], [49, 19], [20, 49], [21, 48], [22, 47], [23, 46], [24, 45], [25, 44], [26, 43], [27, 42], [28, 41], [29, 40], [30, 39], [31, 38], [32, 37], [33, 36], [34, 35], [35, 34], [36, 33], [37, 32], [38, 31], [39, 30], [40, 29], [41, 28], [42, 27], [43, 26], [44, 25], [45, 24], [46, 23], [47, 22], [48, 21], [49, 20], [21, 49], [22, 48], [23, 47], [24, 46], [25, 45], [26, 44], [27, 43], [28, 42], [29, 41], [30, 40], [31, 39], [32, 38], [33, 37], [34, 36], [35, 35], [36, 34], [37, 33], [38, 32], [39, 31], [40, 30], [41, 29], [42, 28], [43, 27], [44, 26], [45, 25], [46, 24], [47, 23], [48, 22], [49, 21], [22, 49], [23, 48], [24, 47], [25, 46], [26, 45], [27, 44], [28, 43], [29, 42], [30, 41], [31, 40], [32, 39], [33, 38], [34, 37], [35, 36], [36, 35], [37, 34], [38, 33], [39, 32], [40, 31], [41, 30], [42, 29], [43, 28], [44, 27], [45, 26], [46, 25], [47, 24], [48, 23], [49, 22], [23, 49], [24, 48], [25, 47], [26, 46], [27, 45], [28, 44], [29, 43], [30, 42], [31, 41], [32, 40], [33, 39], [34, 38], [35, 37], [36, 36], [37, 35], [38, 34], [39, 33], [40, 32], [41, 31], [42, 30], [43, 29], [44, 28], [45, 27], [46, 26], [47, 25], [48, 24], [49, 23], [24, 49], [25, 48], [26, 47], [27, 46], [28, 45], [29, 44], [30, 43], [31, 42], [32, 41], [33, 40], [34, 39], [35, 38], [36, 37], [37, 36], [38, 35], [39, 34], [40, 33], [41, 32], [42, 31], [43, 30], [44, 29], [45, 28], [46, 27], [47, 26], [48, 25], [49, 24], [25, 49], [26, 48], [27, 47], [28, 46], [29, 45], [30, 44], [31, 43], [32, 42], [33, 41], [34, 40], [35, 39], [36, 38], [37, 37], [38, 36], [39, 35], [40, 34], [41, 33], [42, 32], [43, 31], [44, 30], [45, 29], [46, 28], [47, 27], [48, 26], [49, 25], [26, 49], [27, 48], [28, 47], [29, 46], [30, 45], [31, 44], [32, 43], [33, 42], [34, 41], [35, 40], [36, 39], [37, 38], [38, 37], [39, 36], [40, 35], [41, 34], [42, 33], [43, 32], [44, 31], [45, 30], [46, 29], [47, 28], [48, 27], [49, 26], [27, 49], [28, 48], [29, 47], [30, 46], [31, 45], [32, 44], [33, 43], [34, 42], [35, 41], [36, 40], [37, 39], [38, 38], [39, 37], [40, 36], [41, 35], [42, 34], [43, 33], [44, 32], [45, 31], [46, 30], [47, 29], [48, 28], [49, 27], [28, 49], [29, 48], [30, 47], [31, 46], [32, 45], [33, 44], [34, 43], [35, 42], [36, 41], [37, 40], [38, 39], [39, 38], [40, 37], [41, 36], [42, 35], [43, 34], [44, 33], [45, 32], [46, 31], [47, 30], [48, 29], [49, 28], [29, 49], [30, 48], [31, 47], [32, 46], [33, 45], [34, 44], [35, 43], [36, 42], [37, 41], [38, 40], [39, 39], [40, 38], [41, 37], [42, 36], [43, 35], [44, 34], [45, 33], [46, 32], [47, 31], [48, 30], [49, 29], [30, 49], [31, 48], [32, 47], [33, 46], [34, 45], [35, 44], [36, 43], [37, 42], [38, 41], [39, 40], [40, 39], [41, 38], [42, 37], [43, 36], [44, 35], [45, 34], [46, 33], [47, 32], [48, 31], [49, 30], [31, 49], [32, 48], [33, 47], [34, 46], [35, 45], [36, 44], [37, 43], [38, 42], [39, 41], [40, 40], [41, 39], [42, 38], [43, 37], [44, 36], [45, 35], [46, 34], [47, 33], [48, 32], [49, 31], [32, 49], [33, 48], [34, 47], [35, 46], [36, 45], [37, 44], [38, 43], [39, 42], [40, 41], [41, 40], [42, 39], [43, 38], [44, 37], [45, 36], [46, 35], [47, 34], [48, 33], [49, 32], [33, 49], [34, 48], [35, 47], [36, 46], [37, 45], [38, 44], [39, 43], [40, 42], [41, 41], [42, 40], [43, 39], [44, 38], [45, 37], [46, 36], [47, 35], [48, 34], [49, 33], [34, 49], [35, 48], [36, 47], [37, 46], [38, 45], [39, 44], [40, 43], [41, 42], [42, 41], [43, 40], [44, 39], [45, 38], [46, 37], [47, 36], [48, 35], [49, 34], [35, 49], [36, 48], [37, 47], [38, 46], [39, 45], [40, 44], [41, 43], [42, 42], [43, 41], [44, 40], [45, 39], [46, 38], [47, 37], [48, 36], [49, 35], [36, 49], [37, 48], [38, 47], [39, 46], [40, 45], [41, 44], [42, 43], [43, 42], [44, 41], [45, 40], [46, 39], [47, 38], [48, 37], [49, 36], [37, 49], [38, 48], [39, 47], [40, 46], [41, 45], [42, 44], [43, 43], [44, 42], [45, 41], [46, 40], [47, 39], [48, 38], [49, 37], [38, 49], [39, 48], [40, 47], [41, 46], [42, 45], [43, 44], [44, 43], [45, 42], [46, 41], [47, 40], [48, 39], [49, 38], [39, 49], [40, 48], [41, 47], [42, 46], [43, 45], [44, 44], [45, 43], [46, 42], [47, 41], [48, 40], [49, 39], [40, 49], [41, 48], [42, 47], [43, 46], [44, 45], [45, 44], [46, 43], [47, 42], [48, 41], [49, 40], [41, 49], [42, 48], [43, 47], [44, 46], [45, 45], [46, 44], [47, 43], [48, 42], [49, 41], [42, 49], [43, 48], [44, 47], [45, 46], [46, 45], [47, 44], [48, 43], [49, 42], [43, 49], [44, 48], [45, 47], [46, 46], [47, 45], [48, 44], [49, 43], [44, 49], [45, 48], [46, 47], [47, 46], [48, 45], [49, 44], [45, 49], [46, 48], [47, 47], [48, 46], [49, 45], [46, 49], [47, 48], [48, 47], [49, 46], [47, 49], [48, 48], [49, 47], [48, 49], [49, 48], [49, 49]]\n assert candidate(rows = 4,cols = 6,rCenter = 0,cCenter = 5) == [[0, 5], [1, 5], [0, 4], [2, 5], [1, 4], [0, 3], [3, 5], [2, 4], [1, 3], [0, 2], [3, 4], [2, 3], [1, 2], [0, 1], [3, 3], [2, 2], [1, 1], [0, 0], [3, 2], [2, 1], [1, 0], [3, 1], [2, 0], [3, 0]]\n assert candidate(rows = 8,cols = 5,rCenter = 5,cCenter = 0) == [[5, 0], [4, 0], [5, 1], [6, 0], [3, 0], [4, 1], [5, 2], [6, 1], [7, 0], [2, 0], [3, 1], [4, 2], [5, 3], [6, 2], [7, 1], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 3], [7, 2], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [6, 4], [7, 3], [0, 1], [1, 2], [2, 3], [3, 4], [7, 4], [0, 2], [1, 3], [2, 4], [0, 3], [1, 4], [0, 4]]\n assert candidate(rows = 4,cols = 6,rCenter = 3,cCenter = 5) == [[3, 5], [2, 5], [3, 4], [1, 5], [2, 4], [3, 3], [0, 5], [1, 4], [2, 3], [3, 2], [0, 4], [1, 3], [2, 2], [3, 1], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]]\n assert candidate(rows = 7,cols = 3,rCenter = 3,cCenter = 1) == [[3, 1], [2, 1], [3, 2], [4, 1], [3, 0], [1, 1], [2, 2], [2, 0], [4, 2], [5, 1], [4, 0], [0, 1], [1, 2], [1, 0], [5, 2], [6, 1], [5, 0], [0, 2], [0, 0], [6, 2], [6, 0]]\n assert candidate(rows = 10,cols = 5,rCenter = 2,cCenter = 4) == [[2, 4], [1, 4], [3, 4], [2, 3], [0, 4], [1, 3], [4, 4], [3, 3], [2, 2], [0, 3], [1, 2], [5, 4], [4, 3], [3, 2], [2, 1], [0, 2], [1, 1], [6, 4], [5, 3], [4, 2], [3, 1], [2, 0], [0, 1], [1, 0], [7, 4], [6, 3], [5, 2], [4, 1], [3, 0], [0, 0], [8, 4], [7, 3], [6, 2], [5, 1], [4, 0], [9, 4], [8, 3], [7, 2], [6, 1], [5, 0], [9, 3], [8, 2], [7, 1], [6, 0], [9, 2], [8, 1], [7, 0], [9, 1], [8, 0], [9, 0]]\n assert candidate(rows = 9,cols = 6,rCenter = 3,cCenter = 2) == [[3, 2], [2, 2], [3, 3], [4, 2], [3, 1], [1, 2], [2, 3], [2, 1], [3, 4], [4, 3], [5, 2], [4, 1], [3, 0], [0, 2], [1, 3], [1, 1], [2, 4], [2, 0], [3, 5], [4, 4], [5, 3], [6, 2], [5, 1], [4, 0], [0, 3], [0, 1], [1, 4], [1, 0], [2, 5], [4, 5], [5, 4], [6, 3], [7, 2], [6, 1], [5, 0], [0, 4], [0, 0], [1, 5], [5, 5], [6, 4], [7, 3], [8, 2], [7, 1], [6, 0], [0, 5], [6, 5], [7, 4], [8, 3], [8, 1], [7, 0], [7, 5], [8, 4], [8, 0], [8, 5]]\n", "comparison": "exact"}, "public_tests": ["1\n2\n0\n0", "2\n2\n0\n1", "2\n3\n1\n2"], "hints": [], "metadata": {"canonical_parameter_names": ["rows", "cols", "rCenter", "cCenter"], "leetcode_dataset_entry_point": "Solution().allCellsDistOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:24+00:00", "tests_total": 73, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math", "geometry", "sorting", "matrix"]}, "language": "python", "interface": {"raw_signature": "def allCellsDistOrder(self, rows: int, cols: int, rCenter: int, cCenter: int) -> list[list[int]]:", "container": "Solution", "callable": "allCellsDistOrder", "parameters": [{"name": "rows", "type": "int"}, {"name": "cols", "type": "int"}, {"name": "rCenter", "type": "int"}, {"name": "cCenter", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1031, "task_id": "maximum-sum-of-two-non-overlapping-subarrays", "difficulty": "Medium", "problem_description": "Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and secondLen.\n\nThe array with length firstLen could occur before or after the array with length secondLen, but they have to be non-overlapping.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\n\nInput: nums = [0,6,5,2,2,5,1,9,4], firstLen = 1, secondLen = 2\nOutput: 20\nExplanation: One choice of subarrays is [9] with length 1, and [6,5] with length 2.\n\nExample 2:\n\nInput: nums = [3,8,1,3,2,1,8,9,0], firstLen = 3, secondLen = 2\nOutput: 29\nExplanation: One choice of subarrays is [3,8,1] with length 3, and [8,9] with length 2.\n\nExample 3:\n\nInput: nums = [2,1,5,6,0,9,5,0,3,8], firstLen = 4, secondLen = 3\nOutput: 31\nExplanation: One choice of subarrays is [5,6,0,9] with length 4, and [0,3,8] with length 3.\n\nConstraints:\n\n- 1 <= firstLen, secondLen <= 1000\n- 2 <= firstLen + secondLen <= 1000\n- firstLen + secondLen <= nums.length <= 1000\n- 0 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 3,secondLen = 3) == 6\n assert candidate(nums = [0, 6, 5, 2, 2, 5, 1, 9, 4],firstLen = 1,secondLen = 2) == 20\n assert candidate(nums = [2, 1, 5, 6, 0, 9, 5, 0, 3, 8],firstLen = 4,secondLen = 3) == 31\n assert candidate(nums = [4, 5, 14, 16, 16, 20, 7, 13, 8, 15],firstLen = 3,secondLen = 5) == 109\n assert candidate(nums = [1, 4, 1, 1, 3, 3, 1, 2, 2, 2],firstLen = 3,secondLen = 5) == 18\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],firstLen = 3,secondLen = 2) == 35\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0],firstLen = 4,secondLen = 2) == 33\n assert candidate(nums = [1, 4, 1, 4, 1, 4, 1, 4, 1],firstLen = 1,secondLen = 1) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],firstLen = 2,secondLen = 3) == 35\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],firstLen = 2,secondLen = 2) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],firstLen = 2,secondLen = 4) == 390\n assert candidate(nums = [3, 8, 1, 3, 2, 1, 8, 9, 0],firstLen = 3,secondLen = 2) == 29\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],firstLen = 2,secondLen = 3) == 4990\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],firstLen = 4,secondLen = 5) == 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],firstLen = 5,secondLen = 7) == 234\n assert candidate(nums = [5, 8, 6, 7, 2, 0, 9, 4, 5, 1, 6, 8, 3, 4, 5, 2],firstLen = 4,secondLen = 5) == 52\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],firstLen = 5,secondLen = 5) == 105\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],firstLen = 3,secondLen = 4) == 840\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],firstLen = 3,secondLen = 5) == 80\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],firstLen = 15,secondLen = 10) == 3500\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],firstLen = 7,secondLen = 6) == 442\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],firstLen = 5,secondLen = 6) == 110\n assert candidate(nums = [1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 10,secondLen = 15) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 10,secondLen = 15) == 25\n assert candidate(nums = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0],firstLen = 2,secondLen = 3) == 300\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],firstLen = 2,secondLen = 5) == 11\n assert candidate(nums = [5, 3, 2, 5, 1, 6, 4, 9, 3, 2, 8, 7, 4, 5, 6, 1, 3, 4, 5, 6],firstLen = 5,secondLen = 5) == 55\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 5,secondLen = 10) == 15\n assert candidate(nums = [5, 1, 4, 7, 3, 1, 9, 8, 2, 0, 6],firstLen = 4,secondLen = 3) == 36\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],firstLen = 5,secondLen = 10) == 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],firstLen = 3,secondLen = 4) == 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, 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],firstLen = 20,secondLen = 30) == 3775\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],firstLen = 4,secondLen = 6) == 155\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],firstLen = 2,secondLen = 8) == 5500\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],firstLen = 25,secondLen = 25) == 48775\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],firstLen = 8,secondLen = 9) == 374\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],firstLen = 1,secondLen = 1) == 2\n assert candidate(nums = [5, 1, 2, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],firstLen = 10,secondLen = 8) == 567\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],firstLen = 7,secondLen = 6) == 1820\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],firstLen = 25,secondLen = 15) == 40\n assert candidate(nums = [5, 1, 3, 2, 4, 1, 3, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7],firstLen = 5,secondLen = 4) == 62\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],firstLen = 7,secondLen = 6) == 182\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],firstLen = 6,secondLen = 7) == 351\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],firstLen = 1,secondLen = 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],firstLen = 7,secondLen = 8) == 75\n assert candidate(nums = [1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0, 1000, 0],firstLen = 5,secondLen = 6) == 6000\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],firstLen = 10,secondLen = 10) == 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],firstLen = 4,secondLen = 7) == 1650\n assert candidate(nums = [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],firstLen = 10,secondLen = 10) == 210\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],firstLen = 4,secondLen = 3) == 4900\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],firstLen = 5,secondLen = 5) == 75\n assert candidate(nums = [9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9],firstLen = 1,secondLen = 19) == 36\n assert candidate(nums = [2, 3, 5, 1, 4, 7, 3, 1, 9, 8, 2, 0, 6],firstLen = 5,secondLen = 4) == 42\n assert candidate(nums = [5, 1, 6, 3, 7, 4, 8, 2, 9, 10],firstLen = 4,secondLen = 4) == 49\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],firstLen = 5,secondLen = 6) == 275\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],firstLen = 10,secondLen = 10) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],firstLen = 8,secondLen = 4) == 228\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],firstLen = 10,secondLen = 15) == 25\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],firstLen = 2,secondLen = 7) == 51\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],firstLen = 4,secondLen = 3) == 490\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],firstLen = 5,secondLen = 10) == 195\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],firstLen = 6,secondLen = 8) == 177\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],firstLen = 6,secondLen = 4) == 155\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],firstLen = 5,secondLen = 4) == 900\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],firstLen = 4,secondLen = 4) == 520\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],firstLen = 2,secondLen = 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, 21, 22, 23, 24, 25, 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, 1000],firstLen = 30,secondLen = 25) == 4915\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],firstLen = 5,secondLen = 5) == 1000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],firstLen = 5,secondLen = 5) == 70\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],firstLen = 8,secondLen = 9) == 153\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 5,secondLen = 10) == 15\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],firstLen = 40,secondLen = 35) == 4725\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],firstLen = 15,secondLen = 15) == 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],firstLen = 10,secondLen = 5) == 195\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],firstLen = 10,secondLen = 10) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],firstLen = 5,secondLen = 3) == 920\n assert candidate(nums = [200, 100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],firstLen = 3,secondLen = 4) == 396\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],firstLen = 4,secondLen = 4) == 40\n assert candidate(nums = [3, 5, 2, 1, 7, 9, 3, 5, 1, 9, 2, 6, 5, 8, 7, 4, 1, 5, 3, 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9],firstLen = 4,secondLen = 5) == 61\n assert candidate(nums = [2, 1, 3, 4, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 15,secondLen = 20) == 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],firstLen = 9,secondLen = 10) == 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],firstLen = 5,secondLen = 5) == 155\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],firstLen = 7,secondLen = 4) == 68\n assert candidate(nums = [8, 3, 5, 4, 7, 9, 2, 3, 5, 6, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7],firstLen = 9,secondLen = 5) == 78\n assert candidate(nums = [8, 3, 9, 1, 8, 7, 1, 9, 5, 1, 8],firstLen = 4,secondLen = 3) == 45\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],firstLen = 15,secondLen = 10) == 149\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 2,secondLen = 2) == 4\n assert candidate(nums = [9, 3, 8, 5, 6, 1, 2, 7, 8, 9, 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],firstLen = 7,secondLen = 8) == 88\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],firstLen = 5,secondLen = 2) == 490\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],firstLen = 4,secondLen = 5) == 144\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],firstLen = 5,secondLen = 4) == 144\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],firstLen = 5,secondLen = 5) == 30\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],firstLen = 5,secondLen = 4) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 5,secondLen = 5) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],firstLen = 5,secondLen = 5) == 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],firstLen = 7,secondLen = 8) == 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],firstLen = 5,secondLen = 6) == 55\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],firstLen = 6,secondLen = 4) == 79\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],firstLen = 6,secondLen = 10) == 2000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],firstLen = 5,secondLen = 6) == 110\n assert candidate(nums = [5, 3, 1, 5, 2, 1, 3, 2, 1, 2, 5, 2, 5, 1, 3, 2, 5, 1, 3, 2, 5],firstLen = 5,secondLen = 7) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],firstLen = 3,secondLen = 3) == 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],firstLen = 5,secondLen = 10) == 195\n assert candidate(nums = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],firstLen = 6,secondLen = 5) == 1650\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28],firstLen = 8,secondLen = 6) == 301\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],firstLen = 6,secondLen = 5) == 275\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],firstLen = 2,secondLen = 3) == 400\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],firstLen = 15,secondLen = 10) == 25\n", "comparison": "exact"}, "public_tests": ["[0,6,5,2,2,5,1,9,4]\n1\n2", "[3,8,1,3,2,1,8,9,0]\n3\n2", "[2,1,5,6,0,9,5,0,3,8]\n4\n3"], "hints": ["We can use prefix sums to calculate any subarray sum quickly. For each L length subarray, find the best possible M length subarray that occurs before and after it."], "metadata": {"canonical_parameter_names": ["nums", "firstLen", "secondLen"], "leetcode_dataset_entry_point": "Solution().maxSumTwoNoOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:26+00:00", "tests_total": 110, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maxSumTwoNoOverlap(self, nums: list[int], firstLen: int, secondLen: int) -> int:", "container": "Solution", "callable": "maxSumTwoNoOverlap", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "firstLen", "type": "int"}, {"name": "secondLen", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1033, "task_id": "moving-stones-until-consecutive", "difficulty": "Medium", "problem_description": "There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones.\n\nIn one move, you pick up a stone at an endpoint (i.e., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y, and z with x < y < z. You pick up the stone at either position x or position z, and move that stone to an integer position k, with x < k < z and k != y.\n\nThe game ends when you cannot make any more moves (i.e., the stones are in three consecutive positions).\n\nReturn an integer array answer of length 2 where:\n\n- answer[0] is the minimum number of moves you can play, and\n- answer[1] is the maximum number of moves you can play.\n\nExample 1:\n\nInput: a = 1, b = 2, c = 5\nOutput: [1,2]\nExplanation: Move the stone from 5 to 3, or move the stone from 5 to 4 to 3.\n\nExample 2:\n\nInput: a = 4, b = 3, c = 2\nOutput: [0,0]\nExplanation: We cannot make any moves.\n\nExample 3:\n\nInput: a = 3, b = 5, c = 1\nOutput: [1,2]\nExplanation: Move the stone from 1 to 4; or move the stone from 1 to 2 to 4.\n\nConstraints:\n\n- 1 <= a, b, c <= 100\n- a, b, and c have different values.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 7,b = 8,c = 10) == [1, 1]\n assert candidate(a = 1,b = 100,c = 50) == [2, 97]\n assert candidate(a = 1,b = 3,c = 100) == [1, 97]\n assert candidate(a = 10,b = 12,c = 14) == [1, 2]\n assert candidate(a = 50,b = 51,c = 53) == [1, 1]\n assert candidate(a = 25,b = 27,c = 30) == [1, 3]\n assert candidate(a = 5,b = 6,c = 8) == [1, 1]\n assert candidate(a = 10,b = 9,c = 8) == [0, 0]\n assert candidate(a = 2,b = 5,c = 7) == [1, 3]\n assert candidate(a = 7,b = 1,c = 3) == [1, 4]\n assert candidate(a = 2,b = 8,c = 15) == [2, 11]\n assert candidate(a = 1,b = 2,c = 5) == [1, 2]\n assert candidate(a = 20,b = 25,c = 30) == [2, 8]\n assert candidate(a = 15,b = 17,c = 20) == [1, 3]\n assert candidate(a = 3,b = 5,c = 1) == [1, 2]\n assert candidate(a = 2,b = 7,c = 10) == [2, 6]\n assert candidate(a = 2,b = 6,c = 5) == [1, 2]\n assert candidate(a = 15,b = 13,c = 11) == [1, 2]\n assert candidate(a = 5,b = 10,c = 15) == [2, 8]\n assert candidate(a = 10,b = 20,c = 30) == [2, 18]\n assert candidate(a = 100,b = 1,c = 50) == [2, 97]\n assert candidate(a = 3,b = 6,c = 9) == [2, 4]\n assert candidate(a = 25,b = 28,c = 30) == [1, 3]\n assert candidate(a = 2,b = 3,c = 4) == [0, 0]\n assert candidate(a = 1,b = 3,c = 6) == [1, 3]\n assert candidate(a = 3,b = 4,c = 5) == [0, 0]\n assert candidate(a = 8,b = 13,c = 17) == [2, 7]\n assert candidate(a = 4,b = 3,c = 2) == [0, 0]\n assert candidate(a = 2,b = 18,c = 20) == [1, 16]\n assert candidate(a = 1,b = 10,c = 20) == [2, 17]\n assert candidate(a = 30,b = 35,c = 40) == [2, 8]\n assert candidate(a = 1,b = 5,c = 9) == [2, 6]\n assert candidate(a = 1,b = 50,c = 100) == [2, 97]\n assert candidate(a = 10,b = 12,c = 25) == [1, 13]\n assert candidate(a = 5,b = 8,c = 12) == [2, 5]\n assert candidate(a = 8,b = 11,c = 20) == [2, 10]\n assert candidate(a = 23,b = 24,c = 26) == [1, 1]\n assert candidate(a = 1,b = 3,c = 7) == [1, 4]\n assert candidate(a = 7,b = 10,c = 13) == [2, 4]\n assert candidate(a = 3,b = 11,c = 20) == [2, 15]\n assert candidate(a = 8,b = 12,c = 17) == [2, 7]\n assert candidate(a = 13,b = 16,c = 20) == [2, 5]\n assert candidate(a = 20,b = 22,c = 26) == [1, 4]\n assert candidate(a = 1,b = 3,c = 8) == [1, 5]\n assert candidate(a = 7,b = 10,c = 14) == [2, 5]\n assert candidate(a = 98,b = 99,c = 100) == [0, 0]\n assert candidate(a = 5,b = 15,c = 25) == [2, 18]\n assert candidate(a = 35,b = 40,c = 45) == [2, 8]\n assert candidate(a = 2,b = 5,c = 8) == [2, 4]\n assert candidate(a = 2,b = 6,c = 9) == [2, 5]\n assert candidate(a = 5,b = 9,c = 14) == [2, 7]\n assert candidate(a = 6,b = 10,c = 12) == [1, 4]\n assert candidate(a = 8,b = 10,c = 15) == [1, 5]\n assert candidate(a = 6,b = 10,c = 15) == [2, 7]\n assert candidate(a = 30,b = 32,c = 34) == [1, 2]\n assert candidate(a = 3,b = 6,c = 10) == [2, 5]\n assert candidate(a = 1,b = 4,c = 7) == [2, 4]\n assert candidate(a = 2,b = 9,c = 12) == [2, 8]\n assert candidate(a = 15,b = 20,c = 25) == [2, 8]\n assert candidate(a = 8,b = 13,c = 18) == [2, 8]\n assert candidate(a = 23,b = 26,c = 29) == [2, 4]\n assert candidate(a = 40,b = 41,c = 43) == [1, 1]\n assert candidate(a = 6,b = 9,c = 12) == [2, 4]\n assert candidate(a = 2,b = 3,c = 6) == [1, 2]\n assert candidate(a = 1,b = 4,c = 100) == [2, 97]\n assert candidate(a = 6,b = 7,c = 12) == [1, 4]\n assert candidate(a = 5,b = 10,c = 14) == [2, 7]\n assert candidate(a = 5,b = 11,c = 14) == [2, 7]\n assert candidate(a = 2,b = 5,c = 10) == [2, 6]\n assert candidate(a = 15,b = 25,c = 35) == [2, 18]\n assert candidate(a = 10,b = 15,c = 25) == [2, 13]\n assert candidate(a = 20,b = 21,c = 26) == [1, 4]\n assert candidate(a = 5,b = 8,c = 11) == [2, 4]\n assert candidate(a = 2,b = 8,c = 14) == [2, 10]\n assert candidate(a = 5,b = 7,c = 14) == [1, 7]\n assert candidate(a = 25,b = 30,c = 40) == [2, 13]\n assert candidate(a = 1,b = 6,c = 11) == [2, 8]\n assert candidate(a = 33,b = 35,c = 40) == [1, 5]\n assert candidate(a = 1,b = 3,c = 10) == [1, 7]\n assert candidate(a = 2,b = 4,c = 8) == [1, 4]\n assert candidate(a = 2,b = 7,c = 11) == [2, 7]\n assert candidate(a = 10,b = 13,c = 16) == [2, 4]\n assert candidate(a = 15,b = 20,c = 40) == [2, 23]\n assert candidate(a = 5,b = 6,c = 9) == [1, 2]\n assert candidate(a = 21,b = 24,c = 28) == [2, 5]\n assert candidate(a = 90,b = 95,c = 100) == [2, 8]\n assert candidate(a = 10,b = 20,c = 25) == [2, 13]\n assert candidate(a = 3,b = 7,c = 11) == [2, 6]\n assert candidate(a = 3,b = 8,c = 10) == [1, 5]\n assert candidate(a = 10,b = 11,c = 14) == [1, 2]\n assert candidate(a = 12,b = 14,c = 20) == [1, 6]\n assert candidate(a = 30,b = 31,c = 34) == [1, 2]\n assert candidate(a = 5,b = 11,c = 17) == [2, 10]\n assert candidate(a = 100,b = 99,c = 97) == [1, 1]\n assert candidate(a = 3,b = 5,c = 10) == [1, 5]\n assert candidate(a = 4,b = 7,c = 11) == [2, 5]\n assert candidate(a = 1,b = 2,c = 4) == [1, 1]\n assert candidate(a = 2,b = 5,c = 9) == [2, 5]\n assert candidate(a = 5,b = 7,c = 10) == [1, 3]\n assert candidate(a = 3,b = 8,c = 13) == [2, 8]\n assert candidate(a = 15,b = 17,c = 25) == [1, 8]\n assert candidate(a = 6,b = 9,c = 18) == [2, 10]\n assert candidate(a = 7,b = 8,c = 14) == [1, 5]\n assert candidate(a = 2,b = 6,c = 8) == [1, 4]\n assert candidate(a = 17,b = 20,c = 23) == [2, 4]\n assert candidate(a = 30,b = 32,c = 40) == [1, 8]\n assert candidate(a = 8,b = 10,c = 13) == [1, 3]\n assert candidate(a = 1,b = 4,c = 10) == [2, 7]\n assert candidate(a = 7,b = 8,c = 15) == [1, 6]\n assert candidate(a = 7,b = 14,c = 21) == [2, 12]\n assert candidate(a = 10,b = 15,c = 20) == [2, 8]\n assert candidate(a = 4,b = 6,c = 9) == [1, 3]\n assert candidate(a = 20,b = 22,c = 30) == [1, 8]\n assert candidate(a = 10,b = 14,c = 17) == [2, 5]\n assert candidate(a = 8,b = 12,c = 22) == [2, 12]\n assert candidate(a = 7,b = 11,c = 15) == [2, 6]\n assert candidate(a = 8,b = 15,c = 3) == [2, 10]\n assert candidate(a = 2,b = 8,c = 9) == [1, 5]\n assert candidate(a = 45,b = 50,c = 55) == [2, 8]\n assert candidate(a = 3,b = 6,c = 8) == [1, 3]\n assert candidate(a = 6,b = 9,c = 15) == [2, 7]\n assert candidate(a = 1,b = 5,c = 7) == [1, 4]\n assert candidate(a = 1,b = 2,c = 3) == [0, 0]\n assert candidate(a = 50,b = 52,c = 55) == [1, 3]\n assert candidate(a = 7,b = 11,c = 25) == [2, 16]\n assert candidate(a = 9,b = 11,c = 13) == [1, 2]\n assert candidate(a = 25,b = 30,c = 50) == [2, 23]\n assert candidate(a = 10,b = 14,c = 18) == [2, 6]\n assert candidate(a = 2,b = 99,c = 100) == [1, 96]\n assert candidate(a = 23,b = 27,c = 31) == [2, 6]\n", "comparison": "exact"}, "public_tests": ["1\n2\n5", "4\n3\n2", "3\n5\n1"], "hints": ["For the minimum: We can always do it in at most 2 moves, by moving one stone next to another, then the third stone next to the other two. When can we do it in 1 move? 0 moves? For the maximum: Every move, the maximum position minus the minimum position must decrease by at least 1."], "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().numMovesStones", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:28+00:00", "tests_total": 130, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "brainteaser"]}, "language": "python", "interface": {"raw_signature": "def numMovesStones(self, a: int, b: int, c: int) -> list[int]:", "container": "Solution", "callable": "numMovesStones", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1034, "task_id": "coloring-a-border", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid, and three integers row, col, and color. Each value in the grid represents the color of the grid square at that location.\n\nTwo squares are called adjacent if they are next to each other in any of the 4 directions.\n\nTwo squares belong to the same connected component if they have the same color and they are adjacent.\n\nThe border of a connected component is all the squares in the connected component that are either adjacent to (at least) a square not in the component, or on the boundary of the grid (the first or last row or column).\n\nYou should color the border of the connected component that contains the square grid[row][col] with color.\n\nReturn the final grid.\n\nExample 1:\n\nInput: grid = [[1,1],[1,2]], row = 0, col = 0, color = 3\nOutput: [[3,3],[3,2]]\n\nExample 2:\n\nInput: grid = [[1,2,2],[2,3,2]], row = 0, col = 1, color = 3\nOutput: [[1,3,3],[2,3,3]]\n\nExample 3:\n\nInput: grid = [[1,1,1],[1,1,1],[1,1,1]], row = 1, col = 1, color = 2\nOutput: [[2,2,2],[2,1,2],[2,2,2]]\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 50\n- 1 <= grid[i][j], color <= 1000\n- 0 <= row < m\n- 0 <= col < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1000, 1000, 1000], [1000, 1, 1000], [1000, 1000, 1000]],row = 1,col = 1,color = 2) == [[1000, 1000, 1000], [1000, 2, 1000], [1000, 1000, 1000]]\n assert candidate(grid = [[1, 1], [1, 2]],row = 0,col = 0,color = 3) == [[3, 3], [3, 2]]\n assert candidate(grid = [[1000, 1000], [1000, 1000]],row = 1,col = 1,color = 999) == [[999, 999], [999, 999]]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],row = 1,col = 1,color = 2) == [[2, 2, 2], [2, 1, 2], [2, 2, 2]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]],row = 1,col = 1,color = 3) == [[1, 1, 1, 1], [1, 3, 3, 1], [1, 3, 3, 1], [1, 1, 1, 1]]\n assert candidate(grid = [[2, 3, 4], [3, 1, 3], [4, 3, 2]],row = 1,col = 1,color = 5) == [[2, 3, 4], [3, 5, 3], [4, 3, 2]]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]],row = 1,col = 1,color = 10) == [[10, 10, 10], [10, 10, 10], [10, 10, 10]]\n assert candidate(grid = [[1, 2, 2], [2, 3, 2]],row = 0,col = 1,color = 3) == [[1, 3, 3], [2, 3, 3]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]],row = 1,col = 1,color = 4) == [[1, 1, 1, 1], [1, 4, 4, 1], [1, 4, 4, 1], [1, 1, 1, 1]]\n assert candidate(grid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]],row = 1,col = 1,color = 3) == [[1, 2, 1], [2, 3, 2], [1, 2, 1]]\n assert candidate(grid = [[2, 2, 2, 2], [2, 1, 1, 2], [2, 1, 1, 2], [2, 2, 2, 2]],row = 1,col = 1,color = 3) == [[2, 2, 2, 2], [2, 3, 3, 2], [2, 3, 3, 2], [2, 2, 2, 2]]\n assert candidate(grid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]],row = 1,col = 1,color = 4) == [[1, 2, 1], [2, 4, 2], [1, 2, 1]]\n assert candidate(grid = [[1, 2, 3, 4], [2, 1, 2, 3], [3, 2, 3, 2], [4, 3, 2, 1]],row = 0,col = 0,color = 5) == [[5, 2, 3, 4], [2, 1, 2, 3], [3, 2, 3, 2], [4, 3, 2, 1]]\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, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]],row = 4,col = 4,color = 12) == [[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, 12, 12, 3, 2, 1], [1, 2, 3, 12, 12, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 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, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 3, 5, 7, 9, 7, 5, 3, 1]],row = 2,col = 4,color = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 10, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [1, 3, 5, 7, 9, 7, 5, 3, 1]]\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]],row = 3,col = 3,color = 8) == [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 8, 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(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]],row = 2,col = 2,color = 26) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 26, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4]],row = 0,col = 0,color = 8) == [[8, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 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]],row = 3,col = 3,color = 5) == [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 5, 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(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]],row = 1,col = 1,color = 6) == [[1, 2, 3, 4, 5], [2, 6, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]\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]],row = 2,col = 2,color = 7) == [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 7, 7, 2, 1], [1, 2, 7, 7, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[3, 3, 3, 3, 3, 3], [3, 1, 1, 1, 1, 3], [3, 1, 2, 2, 1, 3], [3, 1, 2, 2, 1, 3], [3, 1, 1, 1, 1, 3], [3, 3, 3, 3, 3, 3]],row = 1,col = 1,color = 6) == [[3, 3, 3, 3, 3, 3], [3, 6, 6, 6, 6, 3], [3, 6, 2, 2, 6, 3], [3, 6, 2, 2, 6, 3], [3, 6, 6, 6, 6, 3], [3, 3, 3, 3, 3, 3]]\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6], [4, 4, 5, 5, 6, 6]],row = 1,col = 2,color = 7) == [[1, 1, 7, 7, 3, 3], [1, 1, 7, 7, 3, 3], [4, 4, 5, 5, 6, 6], [4, 4, 5, 5, 6, 6]]\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]],row = 2,col = 2,color = 4) == [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 4, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 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]],row = 2,col = 2,color = 10) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 10, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 1, 2, 2, 1], [1, 2, 2, 2, 2, 1], [1, 2, 1, 2, 2, 1], [1, 1, 1, 1, 1, 1]],row = 1,col = 1,color = 3) == [[1, 1, 1, 1, 1, 1], [1, 3, 3, 3, 3, 1], [1, 3, 1, 3, 3, 1], [1, 3, 3, 2, 3, 1], [1, 3, 1, 3, 3, 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]],row = 2,col = 2,color = 2) == [[2, 2, 2, 2, 2], [2, 1, 1, 1, 2], [2, 1, 1, 1, 2], [2, 1, 1, 1, 2], [2, 2, 2, 2, 2]]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 3, 4, 1], [1, 3, 1, 3, 1], [1, 4, 3, 4, 1], [1, 1, 1, 1, 1]],row = 1,col = 2,color = 5) == [[1, 1, 1, 1, 1], [1, 2, 5, 4, 1], [1, 3, 1, 3, 1], [1, 4, 3, 4, 1], [1, 1, 1, 1, 1]]\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]],row = 2,col = 2,color = 3) == [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 3, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 1, 2, 2, 2, 2, 2, 1], [1, 2, 2, 3, 3, 3, 2, 2, 1], [1, 2, 1, 3, 1, 3, 2, 2, 1], [1, 2, 2, 3, 3, 3, 2, 2, 1], [1, 2, 1, 2, 2, 2, 2, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],row = 4,col = 4,color = 4) == [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 1, 2, 2, 2, 2, 2, 1], [1, 2, 2, 3, 3, 3, 2, 2, 1], [1, 2, 1, 3, 4, 3, 2, 2, 1], [1, 2, 2, 3, 3, 3, 2, 2, 1], [1, 2, 1, 2, 2, 2, 2, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]\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]],row = 3,col = 3,color = 10) == [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 10, 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(grid = [[5, 5, 5], [5, 1, 5], [5, 5, 5], [1, 1, 1], [5, 5, 5]],row = 1,col = 1,color = 7) == [[5, 5, 5], [5, 7, 5], [5, 5, 5], [1, 1, 1], [5, 5, 5]]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 3, 2, 1], [1, 3, 1, 3, 1], [1, 2, 3, 2, 1], [1, 1, 1, 1, 1]],row = 2,col = 2,color = 9) == [[1, 1, 1, 1, 1], [1, 2, 3, 2, 1], [1, 3, 9, 3, 1], [1, 2, 3, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(grid = [[5, 3, 3, 3, 3, 5], [3, 1, 1, 1, 1, 3], [3, 1, 2, 2, 1, 3], [3, 1, 2, 2, 1, 3], [3, 1, 1, 1, 1, 3], [5, 3, 3, 3, 3, 5]],row = 2,col = 2,color = 4) == [[5, 3, 3, 3, 3, 5], [3, 1, 1, 1, 1, 3], [3, 1, 4, 4, 1, 3], [3, 1, 4, 4, 1, 3], [3, 1, 1, 1, 1, 3], [5, 3, 3, 3, 3, 5]]\n assert candidate(grid = [[1, 1, 1, 2, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 2, 1]],row = 2,col = 2,color = 4) == [[1, 1, 1, 2, 1], [1, 2, 2, 2, 1], [1, 2, 4, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 2, 1]]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 1, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]],row = 2,col = 2,color = 3) == [[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(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6]],row = 2,col = 1,color = 10) == [[1, 2, 3], [4, 5, 6], [7, 10, 9], [1, 2, 3], [4, 5, 6]]\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]],row = 2,col = 2,color = 7) == [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 7, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 2, 1], [1, 3, 4, 5, 3, 1], [1, 4, 5, 6, 4, 1], [1, 5, 6, 7, 5, 1], [1, 1, 1, 1, 1, 1]],row = 2,col = 2,color = 8) == [[1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 2, 1], [1, 3, 8, 5, 3, 1], [1, 4, 5, 6, 4, 1], [1, 5, 6, 7, 5, 1], [1, 1, 1, 1, 1, 1]]\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]],row = 2,col = 2,color = 4) == [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 4, 4, 2, 1], [1, 2, 4, 4, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 5], [5, 4, 3, 3, 4, 5], [5, 4, 3, 3, 4, 5], [5, 4, 4, 4, 4, 5], [5, 5, 5, 5, 5, 5]],row = 2,col = 2,color = 1) == [[5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 5], [5, 4, 1, 1, 4, 5], [5, 4, 1, 1, 4, 5], [5, 4, 4, 4, 4, 5], [5, 5, 5, 5, 5, 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]],row = 0,col = 0,color = 2) == [[2, 2, 2, 2], [2, 1, 1, 2], [2, 1, 1, 2], [2, 1, 1, 2], [2, 2, 2, 2]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],row = 1,col = 1,color = 13) == [[1, 2, 3], [4, 13, 6], [7, 8, 9], [10, 11, 12]]\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]],row = 2,col = 2,color = 6) == [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 6, 2, 1], [1, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1]],row = 2,col = 2,color = 2) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1]],row = 2,col = 2,color = 3) == [[1, 2, 1, 2, 1, 2, 1], [2, 1, 2, 1, 2, 1, 2], [1, 2, 3, 2, 1, 2, 1], [2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],row = 0,col = 0,color = 5) == [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]]\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]],row = 2,col = 2,color = 9) == [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 9, 9, 2, 1], [1, 2, 9, 9, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],row = 4,col = 4,color = 15) == [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 15, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]\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]],row = 2,col = 2,color = 3) == [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 3, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1]]\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, 1, 1, 3, 2, 1], [1, 2, 3, 1, 1, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]],row = 3,col = 3,color = 4) == [[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, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[1, 1, 1, 2, 2], [1, 2, 2, 2, 1], [1, 2, 1, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 2, 2]],row = 2,col = 2,color = 3) == [[1, 1, 1, 2, 2], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 2, 2]]\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]],row = 3,col = 3,color = 11) == [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 11, 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(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]],row = 2,col = 2,color = 5) == [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 5, 2, 1], [1, 2, 2, 2, 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]],row = 2,col = 2,color = 6) == [[1, 2, 6, 4, 5], [5, 4, 6, 2, 1], [1, 2, 6, 4, 5], [5, 4, 6, 2, 1], [1, 2, 6, 4, 5]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 2, 2, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 2, 2, 1, 1], [1, 1, 1, 1, 1, 1]],row = 2,col = 2,color = 8) == [[1, 1, 1, 1, 1, 1], [1, 1, 8, 8, 1, 1], [1, 8, 2, 2, 8, 1], [1, 8, 2, 2, 8, 1], [1, 1, 8, 8, 1, 1], [1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 6, 7, 6, 5], [5, 7, 5, 7, 5], [5, 6, 7, 6, 5], [5, 5, 5, 5, 5]],row = 1,col = 2,color = 8) == [[5, 5, 5, 5, 5], [5, 6, 8, 6, 5], [5, 7, 5, 7, 5], [5, 6, 7, 6, 5], [5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 2, 2, 2, 1, 1], [1, 1, 1, 2, 1, 2, 1, 1], [1, 1, 1, 2, 2, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]],row = 3,col = 3,color = 3) == [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 3, 3, 3, 1, 1], [1, 1, 1, 3, 1, 3, 1, 1], [1, 1, 1, 3, 3, 3, 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], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]],row = 3,col = 3,color = 9) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 9, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 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]],row = 3,col = 3,color = 10) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 10, 8], [5, 6, 7, 8, 9]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 1, 2, 1, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 1, 2, 1, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]],row = 3,col = 3,color = 3) == [[1, 1, 1, 1, 1, 1, 1], [1, 3, 3, 3, 3, 3, 1], [1, 3, 1, 3, 1, 3, 1], [1, 3, 3, 2, 3, 3, 1], [1, 3, 1, 3, 1, 3, 1], [1, 3, 3, 3, 3, 3, 1], [1, 1, 1, 1, 1, 1, 1]]\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]],row = 0,col = 0,color = 6) == [[6, 6, 6, 6, 6], [6, 2, 2, 2, 6], [6, 2, 3, 2, 6], [6, 2, 2, 2, 6], [6, 6, 6, 6, 6]]\n assert candidate(grid = [[1, 1, 2, 2, 3], [1, 1, 2, 3, 3], [2, 2, 3, 3, 3], [2, 3, 3, 3, 3], [3, 3, 3, 3, 3]],row = 0,col = 0,color = 5) == [[5, 5, 2, 2, 3], [5, 5, 2, 3, 3], [2, 2, 3, 3, 3], [2, 3, 3, 3, 3], [3, 3, 3, 3, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 1, 2, 3, 4], [3, 2, 3, 2, 3], [4, 3, 2, 3, 2], [5, 4, 3, 2, 1]],row = 2,col = 2,color = 14) == [[1, 2, 3, 4, 5], [2, 1, 2, 3, 4], [3, 2, 14, 2, 3], [4, 3, 2, 3, 2], [5, 4, 3, 2, 1]]\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]],row = 3,col = 3,color = 13) == [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 13, 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(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [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]],row = 4,col = 4,color = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [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, 10, 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]]\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, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]],row = 4,col = 4,color = 11) == [[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, 11, 11, 3, 2, 1], [1, 2, 3, 11, 11, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]\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]],row = 2,col = 2,color = 6) == [[1, 1, 2, 2, 6], [1, 2, 2, 6, 6], [2, 2, 6, 6, 4], [2, 6, 6, 4, 4], [6, 6, 4, 4, 5]]\n assert candidate(grid = [[10, 10, 10], [10, 20, 10], [10, 10, 10], [10, 10, 10]],row = 1,col = 1,color = 15) == [[10, 10, 10], [10, 15, 10], [10, 10, 10], [10, 10, 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]],row = 3,col = 3,color = 7) == [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 7, 7, 2, 1], [1, 2, 7, 7, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 1, 4, 5, 1], [3, 4, 1, 2, 3], [4, 5, 2, 3, 4], [5, 1, 3, 4, 1]],row = 2,col = 2,color = 10) == [[1, 2, 3, 4, 5], [2, 1, 4, 5, 1], [3, 4, 10, 2, 3], [4, 5, 2, 3, 4], [5, 1, 3, 4, 1]]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],row = 1,col = 1,color = 5) == [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],row = 4,col = 4,color = 13) == [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 13, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(grid = [[10, 11, 10, 11], [11, 10, 11, 10], [10, 11, 10, 11], [11, 10, 11, 10]],row = 1,col = 1,color = 12) == [[10, 11, 10, 11], [11, 12, 11, 10], [10, 11, 10, 11], [11, 10, 11, 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], [2, 1, 2, 1, 2, 1]],row = 3,col = 3,color = 3) == [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 3, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 3, 2, 1], [1, 3, 5, 3, 1], [1, 2, 3, 2, 1], [1, 1, 1, 1, 1]],row = 1,col = 2,color = 6) == [[1, 1, 1, 1, 1], [1, 2, 6, 2, 1], [1, 3, 5, 3, 1], [1, 2, 3, 2, 1], [1, 1, 1, 1, 1]]\n", "comparison": "exact"}, "public_tests": ["[[1,1],[1,2]]\n0\n0\n3", "[[1,2,2],[2,3,2]]\n0\n1\n3", "[[1,1,1],[1,1,1],[1,1,1]]\n1\n1\n2"], "hints": ["Use a DFS to find every square in the component. Then for each square, color it if it has a neighbor that is outside the grid or a different color."], "metadata": {"canonical_parameter_names": ["grid", "row", "col", "color"], "leetcode_dataset_entry_point": "Solution().colorBorder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:31+00:00", "tests_total": 79, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def colorBorder(self, grid: list[list[int]], row: int, col: int, color: int) -> list[list[int]]:", "container": "Solution", "callable": "colorBorder", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "row", "type": "int"}, {"name": "col", "type": "int"}, {"name": "color", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1035, "task_id": "uncrossed-lines", "difficulty": "Medium", "problem_description": "You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.\n\nWe may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that:\n\n- nums1[i] == nums2[j], and\n- the line we draw does not intersect any other connecting (non-horizontal) line.\n\nNote that a connecting line cannot intersect even at the endpoints (i.e., each number can only belong to one connecting line).\n\nReturn the maximum number of connecting lines we can draw in this way.\n\nExample 1:\n\nInput: nums1 = [1,4,2], nums2 = [1,2,4]\nOutput: 2\nExplanation: We can draw 2 uncrossed lines as in the diagram.\nWe cannot draw 3 uncrossed lines, because the line from nums1[1] = 4 to nums2[2] = 4 will intersect the line from nums1[2]=2 to nums2[1]=2.\n\nExample 2:\n\nInput: nums1 = [2,5,1,2,5], nums2 = [10,5,2,1,5,2]\nOutput: 3\n\nExample 3:\n\nInput: nums1 = [1,3,7,1,7,5], nums2 = [1,9,2,5,1]\nOutput: 2\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 500\n- 1 <= nums1[i], nums2[j] <= 2000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [2, 5, 1, 2, 5],nums2 = [10, 5, 2, 1, 5, 2]) == 3\n assert candidate(nums1 = [1, 4, 2],nums2 = [1, 2, 4]) == 2\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(nums1 = [1, 2, 2, 1],nums2 = [2, 1, 1, 2]) == 2\n assert candidate(nums1 = [5],nums2 = [5]) == 1\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 4\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 = [1, 2, 3, 3, 4, 5],nums2 = [3, 3, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 3, 2, 1],nums2 = [1, 2, 3, 4, 3, 2, 1]) == 6\n assert candidate(nums1 = [5, 1, 4, 2],nums2 = [5, 2, 1, 4]) == 3\n assert candidate(nums1 = [1, 3, 7, 1, 7, 5],nums2 = [1, 9, 2, 5, 1]) == 2\n assert candidate(nums1 = [3],nums2 = [3]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums1 = [1000, 2000],nums2 = [2000, 1000]) == 1\n assert candidate(nums1 = [5, 1, 4, 2],nums2 = [5, 1, 2]) == 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]) == 1\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 0\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [5, 1, 4, 5, 1, 3],nums2 = [5, 2, 1, 4, 1, 3]) == 5\n assert candidate(nums1 = [3],nums2 = [3, 3, 3]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums1 = [1, 4, 2, 6, 7, 8, 9],nums2 = [2, 3, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums1 = [1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 2\n assert candidate(nums1 = [1000, 2000, 1000, 2000],nums2 = [2000, 1000, 2000, 1000]) == 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, 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, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 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 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 11\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 = [1, 3, 7, 1, 7, 5, 9, 2, 4, 8],nums2 = [1, 9, 2, 5, 1, 3, 4, 8, 7]) == 5\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 1, 4, 9, 3, 7, 2, 8, 10, 6]) == 5\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, 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]) == 1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums1 = [10, 5, 2, 1, 5, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 2, 1]) == 9\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 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, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums1 = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],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]) == 15\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums1 = [1, 3, 7, 1, 7, 5, 9, 1, 3, 7, 1, 7, 5],nums2 = [1, 9, 2, 5, 1, 3, 7, 1, 7, 5, 9, 1, 3]) == 9\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, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10],nums2 = [3, 3, 3, 5, 5, 5, 7, 7, 7]) == 6\n assert candidate(nums1 = [8, 5, 1, 2, 6, 8, 3, 6],nums2 = [8, 3, 2, 1, 6, 8, 8, 5]) == 4\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, 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, 6, 7, 8, 9, 10]) == 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, 1, 1, 1, 1, 1, 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 60\n assert candidate(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 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 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(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums1 = [1, 3, 7, 1, 7, 5, 9, 2, 5],nums2 = [1, 9, 2, 5, 1, 5, 9, 7, 3]) == 4\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, 3],nums2 = [3, 3, 3, 3, 3, 3]) == 6\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 = [5, 10, 15, 20, 25, 30],nums2 = [5, 10, 15, 20, 25, 30, 5, 10, 15, 20, 25, 30]) == 6\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 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 1],nums2 = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 1]) == 22\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]) == 5\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8]) == 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, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [20, 10, 40, 30, 50]) == 3\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]) == 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]) == 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]) == 10\n assert candidate(nums1 = [1, 2, 2, 1, 3, 3, 1, 2],nums2 = [2, 1, 3, 3, 1, 2, 2, 1]) == 6\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]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums1 = [2, 3, 1, 3, 4, 5, 6],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums1 = [1, 3, 7, 1, 7, 5],nums2 = [1, 9, 2, 5, 1, 7, 5]) == 4\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]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45]) == 3\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]) == 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]) == 10\n assert candidate(nums1 = [5, 1, 4, 3, 6, 2, 7, 8, 9],nums2 = [10, 5, 2, 3, 8, 1, 6, 4, 7]) == 4\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]) == 5\n assert candidate(nums1 = [5, 3, 8, 7, 9, 2, 4, 1],nums2 = [7, 2, 3, 8, 9, 4, 5, 1]) == 5\n assert candidate(nums1 = [1, 3, 7, 1, 7, 5],nums2 = [1, 9, 2, 5, 1, 7, 5, 1, 9, 2, 5, 1, 7, 5]) == 5\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2],nums2 = [1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1]) == 28\n assert candidate(nums1 = [1, 2, 1, 4, 1, 5, 1],nums2 = [1, 5, 1, 4, 1, 2, 1]) == 5\n assert candidate(nums1 = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 5\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, 2, 3, 4, 5]) == 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, 21, 22, 23, 24, 25, 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],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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums1 = [1, 2, 1, 3, 1, 4, 1, 5],nums2 = [5, 1, 4, 1, 3, 1, 2, 1]) == 5\n assert candidate(nums1 = [1, 4, 2, 3, 5, 7],nums2 = [1, 3, 5, 4, 2, 7]) == 4\n assert candidate(nums1 = [2, 1, 3, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 8\n assert candidate(nums1 = [5, 14, 23, 42, 55, 67, 78],nums2 = [5, 14, 23, 42, 55, 67, 78]) == 7\n assert candidate(nums1 = [4, 1, 3, 3, 5, 2, 1, 4, 3, 3],nums2 = [3, 5, 1, 3, 2, 1, 4, 3, 4]) == 6\n assert candidate(nums1 = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],nums2 = [110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100]) == 1\n assert candidate(nums1 = [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]) == 16\n assert candidate(nums1 = [1, 2, 1, 3, 1, 4, 1, 5, 1],nums2 = [1, 5, 1, 4, 1, 3, 1, 2, 1]) == 5\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 = [10, 5, 2, 1, 5, 2, 8, 7, 10, 9],nums2 = [10, 2, 5, 1, 5, 2, 9, 10, 7, 8]) == 6\n assert candidate(nums1 = [5, 1, 4, 5, 5, 3],nums2 = [5, 5, 3, 1, 4, 5]) == 4\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, 11, 12, 13, 14, 15],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 13, 14, 15]) == 13\n assert candidate(nums1 = [1, 2, 2, 1, 5],nums2 = [3, 2, 2, 1, 5, 3, 2, 2, 1]) == 4\n assert candidate(nums1 = [1, 4, 2, 3, 5, 6],nums2 = [6, 2, 4, 5, 1]) == 2\n assert candidate(nums1 = [5, 14, 10, 3, 2, 1, 5, 18, 9, 10, 13, 11, 10, 13, 13, 20, 7, 7, 13, 4, 12, 18, 10, 3, 1, 10, 19, 14, 18, 2, 17, 20, 2, 19, 2, 11, 2, 13, 12, 20, 1, 10, 19, 14, 18, 2, 17, 20],nums2 = [5, 5, 5, 14, 10, 3, 2, 1, 5, 18, 9, 10, 13, 11, 10, 13, 13, 20, 7, 7, 13, 4, 12, 18, 10, 3, 1, 10, 19, 14, 18, 2, 17, 20, 2, 19, 2, 11, 2, 13, 12, 20, 1, 10, 19, 14, 18, 2, 17, 20]) == 48\n", "comparison": "exact"}, "public_tests": ["[1,4,2]\n[1,2,4]", "[2,5,1,2,5]\n[10,5,2,1,5,2]", "[1,3,7,1,7,5]\n[1,9,2,5,1]"], "hints": ["Think dynamic programming. Given an oracle dp(i,j) that tells us how many lines A[i:], B[j:] [the sequence A[i], A[i+1], ... and B[j], B[j+1], ...] are uncrossed, can we write this as a recursion?"], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxUncrossedLines", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:33+00:00", "tests_total": 106, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "longest-common-subsequence"]}, "language": "python", "interface": {"raw_signature": "def maxUncrossedLines(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxUncrossedLines", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1036, "task_id": "escape-a-large-maze", "difficulty": "Hard", "problem_description": "There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y).\n\nWe start at the source = [s_x, s_y] square and want to reach the target = [t_x, t_y] square. There is also an array of blocked squares, where each blocked[i] = [x_i, y_i] represents a blocked square with coordinates (x_i, y_i).\n\nEach move, we can walk one square north, east, south, or west if the square is not in the array of blocked squares. We are also not allowed to walk outside of the grid.\n\nReturn true if and only if it is possible to reach the target square from the source square through a sequence of valid moves.\n\nExample 1:\n\nInput: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]\nOutput: false\nExplanation: The target square is inaccessible starting from the source square because we cannot move.\nWe cannot move north or east because those squares are blocked.\nWe cannot move south or west because we cannot go outside of the grid.\n\nExample 2:\n\nInput: blocked = [], source = [0,0], target = [999999,999999]\nOutput: true\nExplanation: Because there are no blocked cells, it is possible to reach the target square.\n\nConstraints:\n\n- 0 <= blocked.length <= 200\n- blocked[i].length == 2\n- 0 <= x_i, y_i < 10^6\n- source.length == target.length == 2\n- 0 <= s_x, s_y, t_x, t_y < 10^6\n- source != target\n- It is guaranteed that source and target are not blocked.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],source = [0, 0],target = [6, 6]) == True\n assert candidate(blocked = [[5, 5]],source = [4, 4],target = [6, 6]) == True\n assert candidate(blocked = [],source = [0, 0],target = [999999, 999999]) == True\n assert candidate(blocked = [[1, 2], [2, 1], [2, 3], [3, 2]],source = [0, 0],target = [4, 4]) == True\n assert candidate(blocked = [[10, 10], [11, 10], [12, 10], [13, 10]],source = [9, 9],target = [14, 14]) == True\n assert candidate(blocked = [[500000, 500000]],source = [499999, 499999],target = [500001, 500001]) == True\n assert candidate(blocked = [[10, 10], [10, 11], [10, 12], [11, 10], [11, 11], [11, 12], [12, 10], [12, 11], [12, 12]],source = [9, 9],target = [13, 13]) == True\n assert candidate(blocked = [[0, 1], [1, 0], [2, 0], [0, 2]],source = [0, 0],target = [3, 3]) == False\n assert candidate(blocked = [[5, 5], [5, 6], [5, 7], [6, 5], [6, 7], [7, 5], [7, 6], [7, 7]],source = [4, 4],target = [8, 8]) == True\n assert candidate(blocked = [[1, 1], [2, 2], [3, 3]],source = [0, 0],target = [3, 4]) == True\n assert candidate(blocked = [[10, 10], [11, 10], [10, 11], [11, 11]],source = [0, 0],target = [20, 20]) == True\n assert candidate(blocked = [[0, 3], [1, 3], [2, 3], [3, 3]],source = [0, 0],target = [0, 4]) == True\n assert candidate(blocked = [[0, 1], [1, 0]],source = [0, 0],target = [0, 2]) == False\n assert candidate(blocked = [[0, 1], [1, 1], [2, 1], [3, 1]],source = [0, 0],target = [0, 4]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [2, 1]],source = [0, 0],target = [3, 3]) == True\n assert candidate(blocked = [[100, 100], [100, 101], [101, 100], [101, 101], [200, 200], [200, 201], [201, 200], [201, 201]],source = [0, 0],target = [300, 300]) == True\n assert candidate(blocked = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],source = [0, 0],target = [11, 11]) == True\n assert candidate(blocked = [[999997, 999998], [999998, 999998], [999999, 999998], [999997, 999999], [999998, 999999], [999999, 999999]],source = [999995, 999995],target = [999999, 999999]) == False\n assert candidate(blocked = [[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]],source = [0, 0],target = [100, 100]) == True\n assert candidate(blocked = [[500, 500], [501, 500], [502, 500], [500, 501], [501, 501], [502, 501], [500, 502], [501, 502], [502, 502]],source = [500, 499],target = [502, 503]) == True\n assert candidate(blocked = [[1000, 1000], [1001, 1000], [1000, 1001], [1001, 1001], [1002, 1000], [1000, 1002], [1002, 1002], [1001, 1002], [1003, 1001], [1001, 1003]],source = [500, 500],target = [1500, 1500]) == True\n assert candidate(blocked = [[999998, 999998], [999998, 999999], [999999, 999998], [999999, 999999]],source = [999997, 999997],target = [999998, 999997]) == True\n assert candidate(blocked = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],source = [0, 0],target = [9, 9]) == True\n assert candidate(blocked = [[5, 4], [4, 5], [6, 5], [5, 6]],source = [5, 5],target = [6, 6]) == False\n assert candidate(blocked = [[500000, 500000], [500001, 500001], [500002, 500002], [500003, 500003]],source = [499999, 499999],target = [500004, 500004]) == True\n assert candidate(blocked = [[1, 2], [2, 1], [2, 3], [3, 2], [4, 3], [5, 4]],source = [0, 0],target = [6, 6]) == True\n assert candidate(blocked = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3]],source = [10, 10],target = [0, 2]) == True\n assert candidate(blocked = [[999998, 999998], [999997, 999998], [999996, 999998], [999998, 999997], [999997, 999997], [999996, 999997], [999998, 999996], [999997, 999996], [999996, 999996]],source = [999995, 999995],target = [999999, 999999]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500002, 500000], [500000, 500001], [500001, 500001], [500002, 500001]],source = [499999, 499999],target = [500001, 500001]) == True\n assert candidate(blocked = [[10, 10], [11, 10], [12, 10], [10, 11], [10, 12], [11, 11], [11, 12], [12, 11], [12, 12], [13, 13], [14, 14], [13, 14], [14, 13]],source = [0, 0],target = [20, 20]) == True\n assert candidate(blocked = [[999999, 999998], [999998, 999999]],source = [0, 0],target = [999998, 999997]) == True\n assert candidate(blocked = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4]],source = [0, 0],target = [0, 5]) == True\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5]],source = [0, 0],target = [3, 5]) == True\n assert candidate(blocked = [[999999, 999999]],source = [0, 0],target = [999998, 999998]) == True\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 2], [2, 3], [2, 4], [2, 5]],source = [0, 0],target = [6, 0]) == True\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],source = [0, 0],target = [10, 1]) == True\n assert candidate(blocked = [[100000, 100000], [100001, 100000], [100002, 100000], [100003, 100000], [100004, 100000], [100005, 100000], [100006, 100000], [100007, 100000]],source = [99999, 99999],target = [100008, 100008]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [2, 1], [2, 2]],source = [0, 0],target = [3, 3]) == True\n assert candidate(blocked = [[0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]],source = [0, 0],target = [5, 5]) == False\n assert candidate(blocked = [[500000, 0], [500001, 0], [500002, 0], [500003, 0], [500004, 0], [500005, 0], [500006, 0], [500007, 0], [500008, 0], [500009, 0]],source = [499990, 0],target = [500010, 0]) == True\n assert candidate(blocked = [[0, 0], [1, 0], [2, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3]],source = [0, 3],target = [3, 0]) == True\n assert candidate(blocked = [[0, 1], [1, 0], [1, 1]],source = [2, 2],target = [3, 3]) == True\n assert candidate(blocked = [[10, 10], [11, 10], [12, 10], [10, 11], [11, 11], [10, 12]],source = [9, 9],target = [13, 13]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3]],source = [0, 0],target = [5, 5]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500001], [500002, 500002]],source = [500000, 500001],target = [500002, 500000]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500002, 500000], [500003, 500000], [500004, 500000], [500005, 500000], [500000, 500001], [500000, 500002], [500000, 500003], [500000, 500004], [500000, 500005]],source = [499999, 500000],target = [500006, 500006]) == True\n assert candidate(blocked = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]],source = [0, 0],target = [5, 9]) == True\n assert candidate(blocked = [[100, 100], [101, 100], [102, 100], [100, 101], [101, 101], [102, 101], [100, 102], [101, 102], [102, 102]],source = [99, 99],target = [103, 103]) == True\n assert candidate(blocked = [[0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]],source = [0, 0],target = [3, 3]) == False\n assert candidate(blocked = [[0, 1], [1, 0], [1, 1], [2, 1], [1, 2], [2, 2], [3, 2], [2, 3], [3, 3], [4, 3], [3, 4], [4, 4], [5, 4], [4, 5], [5, 5], [6, 5], [5, 6], [6, 6], [7, 6], [6, 7], [7, 7]],source = [0, 0],target = [10, 10]) == False\n assert candidate(blocked = [[1, 1], [2, 1], [1, 2], [2, 2]],source = [0, 0],target = [3, 3]) == True\n assert candidate(blocked = [[100, 100], [101, 100], [102, 100], [100, 101], [101, 101], [102, 101], [100, 102], [101, 102], [102, 102]],source = [50, 50],target = [150, 150]) == True\n assert candidate(blocked = [[100, 100], [101, 100], [102, 100], [103, 100], [104, 100], [100, 101], [100, 102], [100, 103], [100, 104], [101, 101], [101, 102], [101, 103], [102, 101], [102, 102], [103, 101]],source = [100, 100],target = [104, 104]) == True\n assert candidate(blocked = [[999999, 999998], [999998, 999999], [999998, 999998]],source = [999997, 999997],target = [999999, 999999]) == False\n assert candidate(blocked = [[999999, 999999], [999998, 999998], [999997, 999997]],source = [999996, 999996],target = [0, 0]) == True\n assert candidate(blocked = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4]],source = [0, 5],target = [5, 0]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500000, 500001], [500001, 500001]],source = [499999, 499999],target = [500002, 500002]) == True\n assert candidate(blocked = [[10, 10], [11, 10], [10, 11], [11, 11], [12, 10], [10, 12], [12, 12], [11, 12], [13, 11], [11, 13]],source = [0, 0],target = [14, 14]) == True\n assert candidate(blocked = [[999999, 999999], [999998, 999998], [999997, 999997], [999996, 999996], [999995, 999995]],source = [0, 0],target = [999999, 999999]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],source = [0, 0],target = [0, 11]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],source = [0, 0],target = [999999, 999999]) == True\n assert candidate(blocked = [[0, 500000], [0, 500001], [0, 500002], [0, 500003], [0, 500004], [0, 500005], [0, 500006], [0, 500007], [0, 500008], [0, 500009]],source = [0, 499990],target = [0, 500010]) == True\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]],source = [0, 0],target = [3, 0]) == True\n assert candidate(blocked = [[100, 100], [101, 100], [100, 101], [101, 101], [102, 100], [100, 102], [102, 102], [101, 102], [103, 101], [101, 103], [104, 101], [101, 104], [105, 101], [101, 105]],source = [50, 50],target = [150, 150]) == True\n assert candidate(blocked = [[50, 50], [51, 51], [52, 52], [53, 53], [54, 54], [55, 55], [56, 56], [57, 57], [58, 58]],source = [49, 49],target = [59, 59]) == True\n assert candidate(blocked = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],source = [0, 0],target = [9, 10]) == True\n assert candidate(blocked = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],source = [0, 0],target = [2, 0]) == True\n assert candidate(blocked = [[200, 200], [201, 200], [202, 200], [203, 200], [204, 200], [205, 200], [206, 200], [207, 200], [208, 200], [209, 200]],source = [100, 100],target = [300, 300]) == True\n assert candidate(blocked = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],source = [0, 0],target = [0, 10]) == True\n assert candidate(blocked = [[500, 500], [501, 500], [502, 500], [503, 500], [504, 500], [500, 501], [501, 501], [502, 501], [503, 501], [504, 501]],source = [499, 499],target = [505, 505]) == True\n assert candidate(blocked = [[999998, 999999], [999999, 999998]],source = [0, 0],target = [999997, 999998]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500001], [500002, 500002], [500003, 500003], [500004, 500004]],source = [499999, 499999],target = [500005, 500005]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500000, 500001], [500001, 500001], [500002, 500000], [500000, 500002], [500002, 500002]],source = [500000, 499999],target = [500002, 500003]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4]],source = [0, 0],target = [5, 5]) == True\n assert candidate(blocked = [[500, 500], [501, 500], [500, 501], [501, 501]],source = [400, 400],target = [600, 600]) == True\n assert candidate(blocked = [[100000, 100000], [100001, 100000], [100002, 100000], [100000, 100001], [100000, 100002]],source = [99999, 99999],target = [100003, 100003]) == True\n assert candidate(blocked = [[500, 500], [500, 501], [500, 502], [500, 503], [500, 504], [501, 500], [501, 501], [501, 502], [501, 503], [501, 504], [502, 500], [502, 501], [502, 502], [502, 503], [502, 504], [503, 500], [503, 501], [503, 502], [503, 503], [503, 504]],source = [500, 499],target = [504, 504]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [2, 1], [2, 2], [2, 3], [3, 2], [3, 3], [3, 4], [4, 3], [4, 4]],source = [0, 0],target = [5, 5]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500002, 500000], [500000, 500001], [500000, 500002]],source = [499999, 499999],target = [500003, 500003]) == True\n assert candidate(blocked = [[100, 100], [101, 100], [102, 100], [103, 100], [104, 100], [100, 101], [100, 102], [100, 103], [100, 104]],source = [99, 99],target = [105, 105]) == True\n assert candidate(blocked = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9]],source = [0, 0],target = [3, 0]) == True\n assert candidate(blocked = [[999998, 999998], [999998, 999999], [999999, 999998], [999997, 999999], [999999, 999997]],source = [999997, 999997],target = [999998, 999999]) == False\n assert candidate(blocked = [[0, 1], [1, 0], [2, 0], [3, 0], [0, 2], [1, 2], [2, 2], [3, 2]],source = [0, 0],target = [3, 3]) == False\n assert candidate(blocked = [[1, 0], [0, 1], [2, 0], [0, 2], [3, 0], [0, 3], [4, 0], [0, 4]],source = [0, 0],target = [4, 4]) == False\n assert candidate(blocked = [[50000, 50000], [50000, 50001], [50000, 50002], [50001, 50000], [50001, 50001], [50001, 50002], [50002, 50000], [50002, 50001], [50002, 50002]],source = [0, 0],target = [99999, 99999]) == True\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]],source = [0, 0],target = [5, 5]) == True\n assert candidate(blocked = [[2, 1], [2, 2], [3, 2], [4, 2], [5, 2]],source = [1, 1],target = [6, 1]) == True\n assert candidate(blocked = [[100000, 100000], [100001, 100000], [100002, 100000], [100000, 100001], [100001, 100001], [100002, 100001], [100000, 100002], [100001, 100002], [100002, 100002]],source = [99999, 99999],target = [100003, 100003]) == True\n assert candidate(blocked = [[50, 50], [50, 51], [50, 52], [51, 50], [52, 50], [51, 52], [52, 51]],source = [49, 49],target = [53, 53]) == True\n assert candidate(blocked = [[200, 200], [201, 200], [202, 200], [200, 201], [200, 202], [201, 202], [202, 202]],source = [100, 100],target = [250, 250]) == True\n assert candidate(blocked = [[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]],source = [0, 0],target = [11, 11]) == True\n assert candidate(blocked = [[500, 500], [501, 500], [502, 500], [503, 500], [504, 500], [505, 500], [506, 500], [500, 501], [500, 502], [500, 503], [500, 504], [500, 505], [500, 506]],source = [500, 499],target = [506, 506]) == True\n assert candidate(blocked = [[1, 0], [0, 1], [2, 0], [0, 2], [3, 0], [0, 3]],source = [0, 0],target = [3, 3]) == False\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500002, 500000], [500000, 500001], [500001, 500001], [500002, 500001]],source = [499999, 499999],target = [500003, 500003]) == True\n assert candidate(blocked = [[999999, 0], [999998, 0], [999997, 0], [999998, 1], [999999, 1]],source = [999995, 0],target = [999999, 999999]) == True\n assert candidate(blocked = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],source = [0, 1],target = [11, 1]) == True\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]],source = [0, 0],target = [6, 6]) == True\n assert candidate(blocked = [[1, 0], [1, 1], [2, 0], [2, 1]],source = [0, 0],target = [2, 2]) == True\n assert candidate(blocked = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]],source = [0, 3],target = [3, 3]) == True\n assert candidate(blocked = [[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]],source = [0, 0],target = [3, 3]) == True\n assert candidate(blocked = [[1000, 1000], [1001, 1001], [1002, 1002], [1000, 1001], [1001, 1000], [1002, 1001], [1001, 1002], [1000, 1002], [1002, 1000]],source = [999, 999],target = [1003, 1003]) == True\n assert candidate(blocked = [[5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7], [7, 5], [7, 6], [7, 7], [8, 8], [8, 9], [8, 10], [9, 8], [9, 9], [9, 10], [10, 8], [10, 9], [10, 10]],source = [4, 4],target = [11, 11]) == True\n assert candidate(blocked = [[100, 100], [101, 100], [102, 100], [103, 100], [104, 100], [105, 100], [106, 100], [107, 100], [108, 100], [109, 100], [100, 101], [100, 102], [100, 103], [100, 104], [100, 105], [100, 106], [100, 107], [100, 108], [100, 109]],source = [99, 99],target = [109, 109]) == True\n assert candidate(blocked = [[100000, 100000], [100001, 100001], [100002, 100002], [100003, 100003], [100004, 100004]],source = [0, 0],target = [200000, 200000]) == True\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],source = [0, 0],target = [4, 4]) == True\n assert candidate(blocked = [[100000, 100000], [100000, 100001], [100000, 100002], [100000, 100003], [100000, 100004], [100001, 100000], [100001, 100001], [100001, 100002], [100001, 100003], [100001, 100004]],source = [0, 0],target = [200000, 200000]) == True\n assert candidate(blocked = [[500000, 500000], [500001, 500000], [500002, 500000], [500000, 500001], [500001, 500001], [500002, 500001], [500000, 500002], [500001, 500002], [500002, 500002]],source = [499990, 499990],target = [500010, 500010]) == True\n assert candidate(blocked = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],source = [0, 0],target = [5, 5]) == False\n assert candidate(blocked = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [1, 3]],source = [0, 0],target = [5, 5]) == True\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,0]]\n[0,0]\n[0,2]", "[]\n[0,0]\n[999999,999999]"], "hints": ["If we become stuck, there's either a loop around the source or around the target.", "If there is a loop around say, the source, what is the maximum number of squares it can have?"], "metadata": {"canonical_parameter_names": ["blocked", "source", "target"], "leetcode_dataset_entry_point": "Solution().isEscapePossible", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:35+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "depth-first-search", "breadth-first-search", "bidirectional-search"]}, "language": "python", "interface": {"raw_signature": "def isEscapePossible(self, blocked: list[list[int]], source: list[int], target: list[int]) -> bool:", "container": "Solution", "callable": "isEscapePossible", "parameters": [{"name": "blocked", "type": "list[list[int]]"}, {"name": "source", "type": "list[int]"}, {"name": "target", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1037, "task_id": "valid-boomerang", "difficulty": "Easy", "problem_description": "Given an array points where points[i] = [x_i, y_i] represents a point on the X-Y plane, return true if these points are a boomerang.\n\nA boomerang is a set of three points that are all distinct and not in a straight line.\n\nExample 1:\n\nInput: points = [[1,1],[2,3],[3,2]]\nOutput: true\n\nExample 2:\n\nInput: points = [[1,1],[2,2],[3,3]]\nOutput: false\n\nConstraints:\n\n- points.length == 3\n- points[i].length == 2\n- 0 <= x_i, y_i <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [1, 3]]) == True\n assert candidate(points = [[1, 1], [2, 5], [3, 9]]) == False\n assert candidate(points = [[1, 1], [2, 3], [3, 2]]) == True\n assert candidate(points = [[5, 5], [6, 6], [7, 7]]) == False\n assert candidate(points = [[1, 1], [2, 1], [3, 1]]) == False\n assert candidate(points = [[0, 0], [1, 1], [2, 2]]) == False\n assert candidate(points = [[0, 1], [1, 1], [2, 1]]) == False\n assert candidate(points = [[0, 0], [1, 1], [1, 0]]) == True\n assert candidate(points = [[0, 0], [1, 1], [1, 2]]) == True\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == False\n assert candidate(points = [[0, 0], [0, 1], [0, 2]]) == False\n assert candidate(points = [[5, 0], [0, 0], [0, 5]]) == True\n assert candidate(points = [[0, 0], [1, 2], [2, 1]]) == True\n assert candidate(points = [[1, 1], [2, 2], [2, 1]]) == True\n assert candidate(points = [[10, 10], [20, 20], [30, 30]]) == False\n assert candidate(points = [[1, 0], [0, 0], [0, 1]]) == True\n assert candidate(points = [[1, 1], [1, 2], [1, 3]]) == False\n assert candidate(points = [[1, 0], [2, 1], [1, 2]]) == True\n assert candidate(points = [[1, 2], [2, 3], [3, 4]]) == False\n assert candidate(points = [[0, 0], [0, 1], [1, 1]]) == True\n assert candidate(points = [[1, 0], [2, 0], [3, 0]]) == False\n assert candidate(points = [[1, 1], [2, 1], [2, 2]]) == True\n assert candidate(points = [[2, 1], [1, 2], [3, 4]]) == True\n assert candidate(points = [[100, 100], [50, 50], [0, 0]]) == False\n assert candidate(points = [[1, 1], [2, 2], [3, 4]]) == True\n assert candidate(points = [[1, 1], [3, 3], [2, 2]]) == False\n assert candidate(points = [[1, 1], [1, 2], [1, 3]]) == False\n assert candidate(points = [[1, 2], [2, 4], [3, 6]]) == False\n assert candidate(points = [[1, 2], [3, 4], [5, 6]]) == False\n assert candidate(points = [[1, 1], [2, 2], [2, 3]]) == True\n assert candidate(points = [[0, 1], [1, 0], [0, 0]]) == True\n assert candidate(points = [[100, 100], [99, 99], [98, 98]]) == False\n assert candidate(points = [[100, 0], [50, 50], [0, 100]]) == False\n assert candidate(points = [[50, 50], [50, 60], [60, 50]]) == True\n assert candidate(points = [[33, 33], [66, 66], [99, 99]]) == False\n assert candidate(points = [[10, 10], [15, 10], [10, 15]]) == True\n assert candidate(points = [[1, 2], [2, 1], [3, 4]]) == True\n assert candidate(points = [[1, 1], [2, 2], [4, 4]]) == False\n assert candidate(points = [[1, 1], [2, 3], [1, 5]]) == True\n assert candidate(points = [[50, 0], [0, 50], [25, 25]]) == False\n assert candidate(points = [[0, 0], [1, 2], [3, 6]]) == False\n assert candidate(points = [[1, 1], [1, 2], [2, 2]]) == True\n assert candidate(points = [[0, 100], [100, 0], [50, 50]]) == False\n assert candidate(points = [[1, 2], [4, 6], [5, 3]]) == True\n assert candidate(points = [[1, 1], [1, 2], [2, 1]]) == True\n assert candidate(points = [[1, 1], [2, 2], [1, 2]]) == True\n assert candidate(points = [[0, 0], [1, 0], [2, 1]]) == True\n assert candidate(points = [[0, 0], [100, 100], [50, 50]]) == False\n assert candidate(points = [[50, 50], [60, 60], [70, 70]]) == False\n assert candidate(points = [[10, 20], [20, 30], [30, 40]]) == False\n assert candidate(points = [[100, 100], [99, 98], [98, 97]]) == True\n assert candidate(points = [[50, 50], [50, 60], [50, 70]]) == False\n assert candidate(points = [[0, 100], [50, 50], [100, 0]]) == False\n assert candidate(points = [[2, 3], [5, 6], [8, 9]]) == False\n assert candidate(points = [[0, 0], [0, 1], [1, 0]]) == True\n assert candidate(points = [[10, 0], [20, 0], [30, 0]]) == False\n assert candidate(points = [[0, 1], [1, 2], [2, 3]]) == False\n assert candidate(points = [[1, 1], [2, 2], [0, 0]]) == False\n assert candidate(points = [[5, 5], [10, 5], [15, 5]]) == False\n assert candidate(points = [[1, 100], [100, 1], [50, 50]]) == True\n assert candidate(points = [[99, 99], [98, 98], [97, 97]]) == False\n assert candidate(points = [[1, 1], [3, 1], [2, 2]]) == True\n assert candidate(points = [[2, 4], [4, 6], [6, 8]]) == False\n assert candidate(points = [[99, 98], [98, 97], [97, 96]]) == False\n assert candidate(points = [[0, 100], [50, 50], [100, 0]]) == False\n assert candidate(points = [[10, 20], [20, 30], [30, 30]]) == True\n assert candidate(points = [[1, 2], [2, 3], [4, 5]]) == False\n assert candidate(points = [[0, 1], [1, 0], [2, 1]]) == True\n assert candidate(points = [[5, 0], [0, 5], [5, 5]]) == True\n assert candidate(points = [[10, 20], [30, 40], [50, 60]]) == False\n assert candidate(points = [[1, 1], [2, 3], [3, 1]]) == True\n assert candidate(points = [[0, 0], [1, 0], [2, 0]]) == False\n assert candidate(points = [[5, 5], [10, 10], [15, 15]]) == False\n assert candidate(points = [[5, 5], [10, 15], [20, 25]]) == True\n assert candidate(points = [[2, 3], [3, 6], [5, 10]]) == True\n assert candidate(points = [[3, 6], [6, 12], [9, 18]]) == False\n assert candidate(points = [[10, 20], [20, 10], [30, 0]]) == False\n assert candidate(points = [[1, 1], [2, 3], [3, 6]]) == True\n assert candidate(points = [[1, 1], [2, 2], [3, 5]]) == True\n assert candidate(points = [[33, 55], [66, 77], [99, 88]]) == True\n assert candidate(points = [[1, 0], [0, 1], [0, 2]]) == True\n assert candidate(points = [[50, 50], [51, 51], [52, 52]]) == False\n assert candidate(points = [[2, 2], [1, 1], [3, 3]]) == False\n assert candidate(points = [[5, 5], [5, 6], [6, 5]]) == True\n assert candidate(points = [[5, 5], [15, 10], [25, 15]]) == False\n assert candidate(points = [[1, 1], [2, 3], [4, 6]]) == True\n assert candidate(points = [[0, 50], [50, 0], [25, 25]]) == False\n assert candidate(points = [[0, 0], [1, 2], [2, 4]]) == False\n assert candidate(points = [[0, 0], [1, 2], [3, 4]]) == True\n assert candidate(points = [[1, 2], [4, 5], [7, 8]]) == False\n assert candidate(points = [[10, 20], [30, 40], [50, 60]]) == False\n assert candidate(points = [[10, 10], [20, 30], [30, 50]]) == False\n assert candidate(points = [[1, 5], [3, 4], [4, 5]]) == True\n assert candidate(points = [[50, 50], [50, 51], [51, 50]]) == True\n assert candidate(points = [[1, 100], [100, 1], [50, 50]]) == True\n assert candidate(points = [[10, 20], [20, 10], [30, 20]]) == True\n assert candidate(points = [[1, 5], [2, 3], [3, 1]]) == False\n assert candidate(points = [[99, 99], [50, 50], [1, 1]]) == False\n assert candidate(points = [[5, 3], [6, 4], [7, 5]]) == False\n assert candidate(points = [[5, 5], [5, 6], [6, 6]]) == True\n assert candidate(points = [[1, 1], [2, 3], [4, 5]]) == True\n assert candidate(points = [[2, 4], [4, 2], [0, 0]]) == True\n assert candidate(points = [[1, 2], [2, 3], [3, 5]]) == True\n assert candidate(points = [[1, 1], [1, 100], [100, 1]]) == True\n assert candidate(points = [[0, 1], [1, 0], [1, 1]]) == True\n assert candidate(points = [[99, 1], [100, 1], [99, 2]]) == True\n assert candidate(points = [[3, 6], [6, 12], [9, 17]]) == True\n assert candidate(points = [[100, 100], [0, 0], [50, 50]]) == False\n assert candidate(points = [[0, 0], [50, 50], [100, 100]]) == False\n assert candidate(points = [[0, 0], [2, 0], [1, 1]]) == True\n assert candidate(points = [[7, 7], [8, 9], [9, 7]]) == True\n", "comparison": "exact"}, "public_tests": ["[[1,1],[2,3],[3,2]]", "[[1,1],[2,2],[3,3]]"], "hints": ["3 points form a boomerang if and only if the triangle formed from them has non-zero area."], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().isBoomerang", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:37+00:00", "tests_total": 116, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def isBoomerang(self, points: list[list[int]]) -> bool:", "container": "Solution", "callable": "isBoomerang", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1039, "task_id": "minimum-score-triangulation-of-polygon", "difficulty": "Medium", "problem_description": "You have a convex n-sided polygon where each vertex has an integer value. You are given an integer array values where values[i] is the value of the i^th vertex in clockwise order.\n\nPolygon triangulation is a process where you divide a polygon into a set of triangles and the vertices of each triangle must also be vertices of the original polygon. Note that no other shapes other than triangles are allowed in the division. This process will result in n - 2 triangles.\n\nYou will triangulate the polygon. For each triangle, the weight of that triangle is the product of the values at its vertices. The total score of the triangulation is the sum of these weights over all n - 2 triangles.\n\nReturn the minimum possible score that you can achieve with some triangulation of the polygon.\n\nExample 1:\n\nInput: values = [1,2,3]\nOutput: 6\nExplanation: The polygon is already triangulated, and the score of the only triangle is 6.\n\nExample 2:\n\nInput: values = [3,7,4,5]\nOutput: 144\nExplanation: There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144.\nThe minimum score is 144.\n\nExample 3:\n\nInput: values = [1,3,1,4,1,5]\nOutput: 13\nExplanation: The minimum score triangulation is 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13.\n\nConstraints:\n\n- n == values.length\n- 3 <= n <= 50\n- 1 <= values[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [10, 1, 1, 10]) == 110\n assert candidate(values = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 328\n assert candidate(values = [3, 1, 2, 4, 5, 6]) == 76\n assert candidate(values = [10, 1, 20, 2, 30, 3, 40, 4]) == 510\n assert candidate(values = [1, 5, 11, 7, 10, 2, 12, 8]) == 342\n assert candidate(values = [1, 3, 1, 4, 1, 5]) == 13\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 328000\n assert candidate(values = [3, 5, 10, 7, 2]) == 270\n assert candidate(values = [6, 6, 6, 6, 6, 6]) == 864\n assert candidate(values = [5, 2, 1, 4, 3]) == 37\n assert candidate(values = [10, 20, 30, 40, 50]) == 38000\n assert candidate(values = [1, 1, 1, 1, 1, 1]) == 4\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 875\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]) == 44\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5]) == 625\n assert candidate(values = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 864\n assert candidate(values = [5, 5, 5, 5]) == 250\n assert candidate(values = [3, 3, 3, 3, 3, 3]) == 108\n assert candidate(values = [8, 3, 5, 1]) == 39\n assert candidate(values = [3, 7, 4, 5]) == 144\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 328\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(values = [1, 2, 3]) == 6\n assert candidate(values = [10, 5, 2, 1, 4, 3]) == 102\n assert candidate(values = [5, 50, 24, 30]) == 9600\n assert candidate(values = [6, 10, 5, 2, 1, 4, 3]) == 150\n assert candidate(values = [1, 2, 3, 4, 5]) == 38\n assert candidate(values = [5, 8, 7, 3, 2, 9, 4]) == 346\n assert candidate(values = [5, 3, 2, 6, 1, 4, 7]) == 96\n assert candidate(values = [2, 1, 3, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 77\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2658\n assert candidate(values = [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]) == 41736\n assert candidate(values = [10, 5, 1, 9, 3, 7, 2, 6]) == 184\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 328000\n assert candidate(values = [15, 25, 35, 45, 55, 65, 75]) == 200625\n assert candidate(values = [2, 10, 3, 8, 4, 1, 9, 7]) == 183\n assert candidate(values = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 70000\n assert candidate(values = [2, 3, 4, 5, 6, 7, 8, 9]) == 464\n assert candidate(values = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 486\n assert candidate(values = [30, 20, 10, 5, 15, 25, 40, 35]) == 23125\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 328\n assert candidate(values = [30, 20, 10, 40, 50, 60, 70]) == 119000\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]) == 48\n assert candidate(values = [50, 40, 30, 20, 10, 90, 80, 70, 60, 50, 40, 30, 20, 10, 90, 80, 70, 60, 50, 40, 30]) == 527000\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1000\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70]) == 110000\n assert candidate(values = [8, 3, 7, 1, 2, 9, 4]) == 131\n assert candidate(values = [100, 1, 100, 1, 100, 1, 100]) == 10301\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 570\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 29750\n assert candidate(values = [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]) == 14469840\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 238\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 328000\n assert candidate(values = [5, 6, 7, 8, 9, 10, 11]) == 1850\n assert candidate(values = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 11702400\n assert candidate(values = [8, 2, 3, 4, 1, 5, 7]) == 125\n assert candidate(values = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 328\n assert candidate(values = [1, 100, 2, 99, 3, 98, 4, 97, 5]) == 2254\n assert candidate(values = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == 7158270\n assert candidate(values = [3, 2, 1, 4, 6, 5, 9, 7, 8]) == 248\n assert candidate(values = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 5634\n assert candidate(values = [7, 6, 8, 5, 3, 4, 9, 2]) == 386\n assert candidate(values = [7, 3, 8, 6, 2, 9, 1, 4, 10, 5]) == 248\n assert candidate(values = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10, 11, 12, 13, 14, 15]) == 1088\n assert candidate(values = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1128\n assert candidate(values = [40, 10, 30, 20, 50, 60, 70, 80, 90]) == 252000\n assert candidate(values = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 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]) == 66691\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]) == 47\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 238\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1118\n assert candidate(values = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 864\n assert candidate(values = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 291840\n assert candidate(values = [7, 8, 9, 10, 11, 12, 13, 14]) == 5194\n assert candidate(values = [12, 8, 6, 3, 7, 11, 9, 5, 4]) == 1299\n assert candidate(values = [10, 1, 100, 10, 1, 100, 10, 1, 100]) == 3031\n assert candidate(values = [9, 1, 8, 1, 7, 2, 6, 3, 5, 4]) == 125\n assert candidate(values = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6]) == 3836\n assert candidate(values = [5, 6, 3, 2, 7, 8, 4, 1, 9]) == 201\n assert candidate(values = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 32000000\n assert candidate(values = [3, 7, 4, 5, 6, 8, 2, 9, 1]) == 181\n assert candidate(values = [10, 5, 1, 100, 10, 5, 1]) == 1110\n assert candidate(values = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 41788\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80]) == 166000\n assert candidate(values = [5, 25, 15, 10, 40, 50]) == 14625\n assert candidate(values = [10, 20, 30, 40, 50]) == 38000\n assert candidate(values = [2, 5, 8, 13, 21, 34, 55, 89]) == 15792\n assert candidate(values = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 10503\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1625\n assert candidate(values = [12, 34, 56, 78, 90, 11, 22, 33, 44, 55]) == 208538\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 238000\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[3,7,4,5]", "[1,3,1,4,1,5]"], "hints": ["Without loss of generality, there is a triangle that uses adjacent vertices A[0] and A[N-1] (where N = A.length). Depending on your choice K of it, this breaks down the triangulation into two subproblems A[1:K] and A[K+1:N-1]."], "metadata": {"canonical_parameter_names": ["values"], "leetcode_dataset_entry_point": "Solution().minScoreTriangulation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:42+00:00", "tests_total": 111, "tests_dropped": 20, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "triangulation", "polygons"]}, "language": "python", "interface": {"raw_signature": "def minScoreTriangulation(self, values: list[int]) -> int:", "container": "Solution", "callable": "minScoreTriangulation", "parameters": [{"name": "values", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1040, "task_id": "moving-stones-until-consecutive-ii", "difficulty": "Medium", "problem_description": "There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones.\n\nCall a stone an endpoint stone if it has the smallest or largest position. In one move, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint stone.\n\n- In particular, if the stones are at say, stones = [1,2,5], you cannot move the endpoint stone at position 5, since moving it to any position (such as 0, or 3) will still keep that stone as an endpoint stone.\n\nThe game ends when you cannot make any more moves (i.e., the stones are in three consecutive positions).\n\nReturn an integer array answer of length 2 where:\n\n- answer[0] is the minimum number of moves you can play, and\n- answer[1] is the maximum number of moves you can play.\n\nExample 1:\n\nInput: stones = [7,4,9]\nOutput: [1,2]\nExplanation: We can move 4 -> 8 for one move to finish the game.\nOr, we can move 9 -> 5, 4 -> 6 for two moves to finish the game.\n\nExample 2:\n\nInput: stones = [6,5,4,3,10]\nOutput: [2,3]\nExplanation: We can move 3 -> 8 then 10 -> 7 to finish the game.\nOr, we can move 3 -> 7, 4 -> 8, 5 -> 9 to finish the game.\nNotice we cannot move 10 -> 2 to finish the game, because that would be an illegal move.\n\nConstraints:\n\n- 3 <= stones.length <= 10^4\n- 1 <= stones[i] <= 10^9\n- All the values of stones are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [4, 5, 6, 7, 100]) == [2, 92]\n assert candidate(stones = [10, 11, 12, 14, 15, 16]) == [1, 1]\n assert candidate(stones = [3, 6, 9, 12, 15]) == [3, 6]\n assert candidate(stones = [6, 5, 4, 3, 10]) == [2, 3]\n assert candidate(stones = [1, 3, 5, 7, 9]) == [2, 3]\n assert candidate(stones = [7, 4, 9]) == [1, 2]\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 0]\n assert candidate(stones = [100, 101, 102, 103]) == [0, 0]\n assert candidate(stones = [1, 2, 100, 101, 102]) == [2, 97]\n assert candidate(stones = [1, 5, 9, 14, 15]) == [3, 10]\n assert candidate(stones = [1, 5, 100]) == [2, 94]\n assert candidate(stones = [1, 2, 5, 7, 9]) == [2, 4]\n assert candidate(stones = [10, 11, 12, 13, 14, 15]) == [0, 0]\n assert candidate(stones = [2, 3, 6, 8, 9]) == [2, 3]\n assert candidate(stones = [1, 2, 5]) == [2, 2]\n assert candidate(stones = [1, 2, 3, 4, 5]) == [0, 0]\n assert candidate(stones = [1, 2, 3, 4, 10, 11, 12, 13]) == [4, 5]\n assert candidate(stones = [1, 100, 101, 102]) == [2, 98]\n assert candidate(stones = [1, 2, 3, 8, 10]) == [2, 5]\n assert candidate(stones = [1, 2, 1000, 1001, 1002, 1003]) == [2, 997]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0]\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == [10, 26]\n assert candidate(stones = [1, 10, 11, 12, 13, 14, 15, 20]) == [2, 8]\n assert candidate(stones = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101]) == [9, 81]\n assert candidate(stones = [5, 6, 10, 11, 15, 16, 20, 21, 25, 26, 30, 31, 35, 36, 40]) == [9, 21]\n assert candidate(stones = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 101]) == [2, 79]\n assert candidate(stones = [1, 2, 10, 20, 30, 40, 50, 60, 70, 80]) == [7, 70]\n assert candidate(stones = [1, 2, 1000, 2000, 3000, 4000, 5000]) == [5, 4993]\n assert candidate(stones = [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 8]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [0, 0]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100]) == [2, 79]\n assert candidate(stones = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == [7, 88]\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]) == [8, 20]\n assert candidate(stones = [1, 3, 10, 15, 18, 25]) == [4, 18]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [14, 126]\n assert candidate(stones = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30]) == [8, 14]\n assert candidate(stones = [10, 11, 12, 20, 21, 22, 23, 24]) == [3, 7]\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 15]) == [3, 7]\n assert candidate(stones = [1, 3, 6, 8, 12, 15, 18, 22, 25]) == [5, 15]\n assert candidate(stones = [2, 5, 7, 12, 15, 18, 22, 25, 28, 32, 35, 38]) == [8, 23]\n assert candidate(stones = [100, 101, 102, 200, 201, 202, 300, 301, 302]) == [6, 194]\n assert candidate(stones = [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, 100]) == [19, 72]\n assert candidate(stones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950]) == [86, 4850]\n assert candidate(stones = [1, 3, 6, 8, 10, 13, 16, 18, 21]) == [5, 11]\n assert candidate(stones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081]) == [37, 1034]\n assert candidate(stones = [1, 2, 3, 6, 10]) == [2, 5]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35]) == [5, 20]\n assert candidate(stones = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 30, 31, 32, 33, 34, 40, 41, 42, 43, 44, 50, 51, 52, 53, 54]) == [14, 24]\n assert candidate(stones = [1, 2, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == [2, 97]\n assert candidate(stones = [1, 2, 3, 10, 11, 12, 20, 21, 22, 30]) == [6, 20]\n assert candidate(stones = [1, 2, 3, 4, 100, 101, 102]) == [3, 95]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [18, 171]\n assert candidate(stones = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [10, 891]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == [17, 162]\n assert candidate(stones = [1, 2, 3, 4, 100, 101, 102, 103]) == [4, 95]\n assert candidate(stones = [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]) == [21, 81]\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [9, 81]\n assert candidate(stones = [1, 2, 1000000000]) == [2, 999999997]\n assert candidate(stones = [1, 2, 3, 100, 101, 102, 200, 201, 202, 300]) == [7, 290]\n assert candidate(stones = [1, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 7]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == [2, 90]\n assert candidate(stones = [2, 5, 7, 10, 15, 20, 30]) == [4, 20]\n assert candidate(stones = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == [15, 72]\n assert candidate(stones = [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]) == [27, 261]\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) == [6, 11]\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [11, 99]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40]) == [3, 27]\n assert candidate(stones = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == [7, 13]\n assert candidate(stones = [1, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [8, 36]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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]\n assert candidate(stones = [1, 2, 3, 7, 8, 9, 13, 14, 15, 19, 20, 21]) == [6, 9]\n assert candidate(stones = [2, 5, 7, 8, 11, 13, 15, 17, 19, 22, 25, 27, 29]) == [6, 14]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1000]) == [2, 980]\n assert candidate(stones = [1, 2, 3, 6, 7, 8, 10, 11, 12, 15, 16, 17]) == [3, 5]\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [6, 11]\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [9, 72]\n assert candidate(stones = [1, 2, 3, 8, 9, 10, 11]) == [3, 4]\n assert candidate(stones = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [8, 36]\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30]) == [7, 14]\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [6, 502]\n assert candidate(stones = [1, 2, 3, 5, 6, 7, 10, 11, 12, 15, 16, 17, 20, 21, 22, 25, 26, 27]) == [6, 9]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106]) == [7, 92]\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35]) == [9, 16]\n assert candidate(stones = [1, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == [20, 18981]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 21, 22, 23, 24, 25]) == [6, 9]\n assert candidate(stones = [2, 4, 5, 6, 8, 10, 11, 13, 15, 16]) == [3, 5]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == [17, 162]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == [13, 477]\n assert candidate(stones = [1, 2, 3, 4, 9, 10, 11, 12, 17, 18, 19, 20]) == [4, 8]\n assert candidate(stones = [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, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250]) == [40, 196]\n assert candidate(stones = [1, 2, 3, 5, 6, 8, 10, 11]) == [2, 3]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [9, 81]\n assert candidate(stones = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57]) == [11, 39]\n assert candidate(stones = [1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27]) == [7, 12]\n assert candidate(stones = [2, 5, 7, 11, 14, 17, 20]) == [4, 10]\n assert candidate(stones = [1, 4, 8, 10, 13, 17, 20]) == [4, 11]\n assert candidate(stones = [1, 2, 3, 4, 5, 100, 101, 102, 103, 104]) == [5, 94]\n assert candidate(stones = [1, 2, 5, 7, 11, 13, 17, 19]) == [4, 11]\n assert candidate(stones = [3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105]) == [9, 88]\n assert candidate(stones = [1, 2, 3, 8, 9, 10]) == [3, 4]\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40]) == [6, 24]\n assert candidate(stones = [1, 3, 6, 10, 14, 15]) == [3, 9]\n assert candidate(stones = [1, 3, 5, 7, 9, 100]) == [3, 93]\n assert candidate(stones = [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]) == [21, 100]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 0]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26, 27, 28, 29, 30]) == [4, 4]\n assert candidate(stones = [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]) == [45, 441]\n assert candidate(stones = [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 40]) == [2, 9]\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [7, 13]\n assert candidate(stones = [1, 2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [16, 78]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0]\n assert candidate(stones = [2, 5, 7, 8, 11, 13, 16, 20]) == [4, 9]\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [8, 32]\n assert candidate(stones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [6, 44]\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == [12, 52]\n assert candidate(stones = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == [8, 72]\n assert candidate(stones = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [8, 999999982]\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [9, 792]\n assert candidate(stones = [1, 2, 3, 4, 100, 101, 102, 150]) == [4, 142]\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [8, 32]\n assert candidate(stones = [1, 2, 3, 4, 5, 100, 101, 102, 103, 104]) == [5, 94]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 102, 103, 104, 105]) == [6, 84]\n assert candidate(stones = [100, 101, 102, 103, 104, 200, 201, 202, 203, 204]) == [5, 95]\n assert candidate(stones = [1, 3, 10, 20, 30, 40, 50]) == [5, 42]\n assert candidate(stones = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [16, 76]\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [13, 117]\n assert candidate(stones = [2, 5, 10, 15, 20, 25, 30, 35, 40]) == [6, 28]\n assert candidate(stones = [1, 3, 5, 10, 20, 30]) == [3, 23]\n assert candidate(stones = [1, 2, 5, 6, 10, 11, 13, 14, 17, 18]) == [4, 8]\n assert candidate(stones = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14]) == [4, 4]\n assert candidate(stones = [1, 2, 3, 10, 11, 12]) == [3, 6]\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100]) == [2, 89]\n assert candidate(stones = [2, 3, 4, 5, 6, 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]\n assert candidate(stones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105]) == [10, 90]\n assert candidate(stones = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == [6, 10]\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [16, 72]\n", "comparison": "exact"}, "public_tests": ["[7,4,9]", "[6,5,4,3,10]"], "hints": ["For the minimum, how many stones are already in place? For the maximum, we have to lose either the gap A[1] - A[0] or A[N-1] - A[N-2] (where N = A.length), but every other space can be occupied."], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().numMovesStonesII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:44+00:00", "tests_total": 140, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "math", "sliding-window", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numMovesStonesII(self, stones: list[int]) -> list[int]:", "container": "Solution", "callable": "numMovesStonesII", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1041, "task_id": "robot-bounded-in-circle", "difficulty": "Medium", "problem_description": "On an infinite plane, a robot initially stands at (0, 0) and faces north. Note that:\n\n- The north direction is the positive direction of the y-axis.\n- The south direction is the negative direction of the y-axis.\n- The east direction is the positive direction of the x-axis.\n- The west direction is the negative direction of the x-axis.\n\nThe robot can receive one of three instructions:\n\n- \"G\": go straight 1 unit.\n- \"L\": turn 90 degrees to the left (i.e., anti-clockwise direction).\n- \"R\": turn 90 degrees to the right (i.e., clockwise direction).\n\nThe robot performs the instructions given in order, and repeats them forever.\n\nReturn true if and only if there exists a circle in the plane such that the robot never leaves the circle.\n\nExample 1:\n\nInput: instructions = \"GGLLGG\"\nOutput: true\nExplanation: The robot is initially at (0, 0) facing the north direction.\n\"G\": move one step. Position: (0, 1). Direction: North.\n\"G\": move one step. Position: (0, 2). Direction: North.\n\"L\": turn 90 degrees anti-clockwise. Position: (0, 2). Direction: West.\n\"L\": turn 90 degrees anti-clockwise. Position: (0, 2). Direction: South.\n\"G\": move one step. Position: (0, 1). Direction: South.\n\"G\": move one step. Position: (0, 0). Direction: South.\nRepeating the instructions, the robot goes into the cycle: (0, 0) --> (0, 1) --> (0, 2) --> (0, 1) --> (0, 0).\nBased on that, we return true.\n\nExample 2:\n\nInput: instructions = \"GG\"\nOutput: false\nExplanation: The robot is initially at (0, 0) facing the north direction.\n\"G\": move one step. Position: (0, 1). Direction: North.\n\"G\": move one step. Position: (0, 2). Direction: North.\nRepeating the instructions, keeps advancing in the north direction and does not go into cycles.\nBased on that, we return false.\n\nExample 3:\n\nInput: instructions = \"GL\"\nOutput: true\nExplanation: The robot is initially at (0, 0) facing the north direction.\n\"G\": move one step. Position: (0, 1). Direction: North.\n\"L\": turn 90 degrees anti-clockwise. Position: (0, 1). Direction: West.\n\"G\": move one step. Position: (-1, 1). Direction: West.\n\"L\": turn 90 degrees anti-clockwise. Position: (-1, 1). Direction: South.\n\"G\": move one step. Position: (-1, 0). Direction: South.\n\"L\": turn 90 degrees anti-clockwise. Position: (-1, 0). Direction: East.\n\"G\": move one step. Position: (0, 0). Direction: East.\n\"L\": turn 90 degrees anti-clockwise. Position: (0, 0). Direction: North.\nRepeating the instructions, the robot goes into the cycle: (0, 0) --> (0, 1) --> (-1, 1) --> (-1, 0) --> (0, 0).\nBased on that, we return true.\n\nConstraints:\n\n- 1 <= instructions.length <= 100\n- instructions[i] is 'G', 'L' or, 'R'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(instructions = \"GGLGRGLL\") == True\n assert candidate(instructions = \"LLLL\") == True\n assert candidate(instructions = \"GLLRLLRL\") == True\n assert candidate(instructions = \"GRGL\") == False\n assert candidate(instructions = \"LLGRL\") == True\n assert candidate(instructions = \"LRRL\") == True\n assert candidate(instructions = \"LLGRR\") == False\n assert candidate(instructions = \"LRRRRLL\") == True\n assert candidate(instructions = \"LL\") == True\n assert candidate(instructions = \"RRGRRG\") == True\n assert candidate(instructions = \"GGGG\") == False\n assert candidate(instructions = \"GGRRGG\") == True\n assert candidate(instructions = \"GLGLG\") == True\n assert candidate(instructions = \"GGLLGG\") == True\n assert candidate(instructions = \"L\") == True\n assert candidate(instructions = \"GL\") == True\n assert candidate(instructions = \"R\") == True\n assert candidate(instructions = \"GG\") == False\n assert candidate(instructions = \"GLGLGLGL\") == True\n assert candidate(instructions = \"RRRR\") == True\n assert candidate(instructions = \"G\") == False\n assert candidate(instructions = \"GLGLGRRG\") == False\n assert candidate(instructions = \"GLLRLLRR\") == True\n assert candidate(instructions = \"RR\") == True\n assert candidate(instructions = \"LGLLGLLGRRRRGG\") == True\n assert candidate(instructions = \"LGR\") == False\n assert candidate(instructions = \"GLGLGRRR\") == True\n assert candidate(instructions = \"GRRG\") == True\n assert candidate(instructions = \"GRRGRRGRRGRRGRRGLG\") == True\n assert candidate(instructions = \"GLRGLRGLRGLRGLRGLR\") == False\n assert candidate(instructions = \"GGGGGRRRRRLLLLL\") == False\n assert candidate(instructions = \"GGRRLLGGRRLLGGRRLL\") == False\n assert candidate(instructions = \"LGGRRGGRRGGRRG\") == True\n assert candidate(instructions = \"RRRLLLLGGGGRRRLLL\") == True\n assert candidate(instructions = \"RRLLRRLLRRLLRR\") == True\n assert candidate(instructions = \"GLRGLRGLRGLRGLR\") == False\n assert candidate(instructions = \"RRRRGGGGLLGGGG\") == True\n assert candidate(instructions = \"GLGLGLGLGLGLGLGLGL\") == True\n assert candidate(instructions = \"RRRRRRRRRRRRRR\") == True\n assert candidate(instructions = \"RRLLGGGLLLRRRR\") == True\n assert candidate(instructions = \"LGLLGLGLLGLGRR\") == True\n assert candidate(instructions = \"GGRRLLGGLLRR\") == False\n assert candidate(instructions = \"GGGGGLLLRRRGGGGGLLLRRR\") == False\n assert candidate(instructions = \"LRRLRLRLRLRLRLRL\") == True\n assert candidate(instructions = \"LLLLRRRRLLLLRRRR\") == True\n assert candidate(instructions = \"GLGRGLGRGLGRGL\") == True\n assert candidate(instructions = \"GLRRLGLRRL\") == False\n assert candidate(instructions = \"GRRGRRGRRGRRGRRGRR\") == True\n assert candidate(instructions = \"LLLLRRRRLLLLRRRRGG\") == False\n assert candidate(instructions = \"GGGGRRRLLLLGGGRR\") == True\n assert candidate(instructions = \"GRRGRLGLGG\") == True\n assert candidate(instructions = \"RRLLGGGGLLRRLG\") == True\n assert candidate(instructions = \"GGLLGGRRLLRRGG\") == False\n assert candidate(instructions = \"GLGRRGLLGLLRRGGG\") == True\n assert candidate(instructions = \"LRRLGRLGRLGRLRLR\") == True\n assert candidate(instructions = \"GLLRRGGLLRRGGLLRR\") == False\n assert candidate(instructions = \"GGGRRRGRRRRGGGRRR\") == True\n assert candidate(instructions = \"RRLLGGGGLLRRG\") == False\n assert candidate(instructions = \"LRRRRLLRRRRLLRRR\") == True\n assert candidate(instructions = \"GRRGRRGRRGRRGG\") == False\n assert candidate(instructions = \"GGGLGGGLGGGLGGGL\") == True\n assert candidate(instructions = \"GGRRGGRRGGRRGGRR\") == True\n assert candidate(instructions = \"LLRRGGGGLLRRGG\") == False\n assert candidate(instructions = \"GGLRLRGGRRLL\") == False\n assert candidate(instructions = \"LRRGGLLLGGRRGG\") == False\n assert candidate(instructions = \"GLRRGLRRGLRR\") == True\n assert candidate(instructions = \"LLLLGRRGGGLLRLLRRR\") == True\n assert candidate(instructions = \"GLRLRLRLRLRRGGGG\") == True\n assert candidate(instructions = \"RRGLLRRGLLRRGLLRRG\") == True\n assert candidate(instructions = \"GLLGRRGRRGLLGRR\") == True\n assert candidate(instructions = \"LGGGGRLRRRRGLLGG\") == True\n assert candidate(instructions = \"GRRGGLLLGGRRGG\") == True\n assert candidate(instructions = \"LLLLRRRLLLLRRR\") == True\n assert candidate(instructions = \"LRLLRRLLRRLLRRLL\") == True\n assert candidate(instructions = \"RRLLGGGLLLRRGG\") == True\n assert candidate(instructions = \"RRGRLGGRLGRLG\") == True\n assert candidate(instructions = \"GGGLLLGGRRRRGGGL\") == False\n assert candidate(instructions = \"GLGGRLGRLGLGRLGLGG\") == True\n assert candidate(instructions = \"GGLGGLGGRRRR\") == True\n assert candidate(instructions = \"LGLRLGLRLGLRLGLRL\") == True\n assert candidate(instructions = \"GLGLGLGLGRRGRRGL\") == True\n assert candidate(instructions = \"LGGRLGRRGLLGRRGLGRR\") == True\n assert candidate(instructions = \"RRRLLLLRRRLLLL\") == True\n assert candidate(instructions = \"GLRGLRLRLGRRGGGG\") == True\n assert candidate(instructions = \"LGGRRGLGGLLRRGL\") == True\n assert candidate(instructions = \"GGGGLLLRRRGGRRRL\") == True\n assert candidate(instructions = \"GLRLRLRLRLRLRLRL\") == True\n assert candidate(instructions = \"GLGRRGGLLRRGGLLRR\") == True\n assert candidate(instructions = \"GGGGRRRLLLLLGGGG\") == True\n assert candidate(instructions = \"RRRGLLGGLLLGGG\") == True\n assert candidate(instructions = \"GGRRLLGGRRLL\") == False\n assert candidate(instructions = \"LGRGLRLRLGRR\") == True\n assert candidate(instructions = \"LGGRRGRRLLGGRL\") == True\n assert candidate(instructions = \"GLLLRRRRGLLLRRRR\") == True\n assert candidate(instructions = \"GGGLLLGGGLLLGGGL\") == True\n assert candidate(instructions = \"GLRLGLRLGLRLGLRL\") == True\n assert candidate(instructions = \"LGLLGLGLLGLGRRGLGRR\") == False\n assert candidate(instructions = \"GLGRLLRLRRRL\") == False\n assert candidate(instructions = \"LGLGLLRLRLRLRL\") == False\n assert candidate(instructions = \"GLGLGLGLGLGL\") == True\n assert candidate(instructions = \"LLGGRRLLGGRRLLGG\") == True\n assert candidate(instructions = \"GLGGRLGRLGLGRL\") == True\n assert candidate(instructions = \"LGLLGLGLGLGLLGLL\") == True\n assert candidate(instructions = \"LRLRLRLRLRLRLRLRLR\") == True\n assert candidate(instructions = \"GGLRLRRLLGLGGGG\") == True\n assert candidate(instructions = \"GGGGGGGGGGGGGG\") == False\n assert candidate(instructions = \"GRRRLRLLGLGLGRLR\") == False\n assert candidate(instructions = \"GGGLGGGLGGGLGGGLGG\") == False\n assert candidate(instructions = \"LGLRLGLRLGLRLGLRLR\") == True\n assert candidate(instructions = \"GLGLGLGLGLGLGLGL\") == True\n assert candidate(instructions = \"LGLGLGLGLGLGLGLG\") == True\n assert candidate(instructions = \"LLLLLLLLLLLLLL\") == True\n assert candidate(instructions = \"LGLGLGLGLGLGLG\") == True\n assert candidate(instructions = \"GGRRGLGRRGRRGRR\") == True\n assert candidate(instructions = \"LRLRLRLRLRLRLRLR\") == True\n assert candidate(instructions = \"GLGLGLGLGL\") == True\n assert candidate(instructions = \"GRRGRRGRRGRRGRRG\") == True\n assert candidate(instructions = \"GRRGLLRLLGRGLL\") == True\n assert candidate(instructions = \"LGLRLGLRLG\") == True\n assert candidate(instructions = \"GGLRLGLLGGRR\") == True\n assert candidate(instructions = \"GLRRLLRRLLRRLLRR\") == True\n assert candidate(instructions = \"RRLLRRLLRRLLRRLLRR\") == True\n assert candidate(instructions = \"GLRLRLRLRLRLRLRLGG\") == True\n assert candidate(instructions = \"RRGGLLRGGLLRRGLL\") == True\n assert candidate(instructions = \"GGGGGGGGGGGGGGGG\") == False\n assert candidate(instructions = \"GRRGLRGGGLLRLLGRR\") == True\n assert candidate(instructions = \"GLRRGLLLGGGGRRRR\") == True\n assert candidate(instructions = \"RRRRLLLLGGGG\") == False\n assert candidate(instructions = \"GLRRGLGLRLRR\") == True\n assert candidate(instructions = \"LGGRLGRRGLG\") == False\n assert candidate(instructions = \"GGGGRRRRLLLL\") == False\n assert candidate(instructions = \"RGLLRLGLGRRG\") == True\n assert candidate(instructions = \"RRLLRRLLRRLLRRLL\") == True\n assert candidate(instructions = \"GLRLGLRLGLRL\") == True\n assert candidate(instructions = \"GLGRRRRRGGGLLGLGRR\") == True\n assert candidate(instructions = \"GGGLRRLLGLRRLL\") == True\n assert candidate(instructions = \"GGLLGGGGLLGGGG\") == False\n assert candidate(instructions = \"LRRLRLRLRL\") == True\n assert candidate(instructions = \"GRRGGGGLLLRRGGLG\") == False\n assert candidate(instructions = \"LRRGLLRRGLLRRGLLRR\") == True\n", "comparison": "exact"}, "public_tests": ["\"GGLLGG\"", "\"GG\"", "\"GL\""], "hints": ["Calculate the final vector of how the robot travels after executing all instructions once - it consists of a change in position plus a change in direction.", "The robot stays in the circle if and only if (looking at the final vector) it changes direction (ie. doesn't stay pointing north), or it moves 0."], "metadata": {"canonical_parameter_names": ["instructions"], "leetcode_dataset_entry_point": "Solution().isRobotBounded", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:46+00:00", "tests_total": 140, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def isRobotBounded(self, instructions: str) -> bool:", "container": "Solution", "callable": "isRobotBounded", "parameters": [{"name": "instructions", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1042, "task_id": "flower-planting-with-no-adjacent", "difficulty": "Medium", "problem_description": "You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [x_i, y_i] describes a bidirectional path between garden x_i to garden y_i. In each garden, you want to plant one of 4 types of flowers.\n\nAll gardens have at most 3 paths coming into or leaving it.\n\nYour task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.\n\nReturn any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)^th garden. The flower types are denoted 1, 2, 3, or 4. It is guaranteed an answer exists.\n\nExample 1:\n\nInput: n = 3, paths = [[1,2],[2,3],[3,1]]\nOutput: [1,2,3]\nExplanation:\nGardens 1 and 2 have different types.\nGardens 2 and 3 have different types.\nGardens 3 and 1 have different types.\nHence, [1,2,3] is a valid answer. Other valid answers include [1,2,4], [1,4,2], and [3,2,1].\n\nExample 2:\n\nInput: n = 4, paths = [[1,2],[3,4]]\nOutput: [1,2,1,2]\n\nExample 3:\n\nInput: n = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]\nOutput: [1,2,3,4]\n\nConstraints:\n\n- 1 <= n <= 10^4\n- 0 <= paths.length <= 2 * 10^4\n- paths[i].length == 2\n- 1 <= x_i, y_i <= n\n- x_i != y_i\n- Every garden has at most 3 paths coming into or leaving it.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,paths = [[1, 2], [2, 3], [3, 1]]) == [1, 2, 3]\n assert candidate(n = 6,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6]]) == [1, 2, 2, 2, 1, 1]\n assert candidate(n = 6,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == [1, 2, 1, 2, 1, 2]\n assert candidate(n = 5,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [1, 2, 1, 2, 3]\n assert candidate(n = 7,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == [1, 2, 1, 2, 1, 2, 3]\n assert candidate(n = 4,paths = [[1, 2], [3, 4]]) == [1, 2, 1, 2]\n assert candidate(n = 8,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]]) == [1, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(n = 7,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 7], [1, 3], [4, 6]]) == [1, 2, 3, 1, 2, 3, 2]\n assert candidate(n = 5,paths = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [1, 2, 1, 2, 1]\n assert candidate(n = 7,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [5, 7]]) == [1, 2, 3, 1, 2, 1, 3]\n assert candidate(n = 4,paths = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4]]) == [1, 2, 3, 4]\n assert candidate(n = 6,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [4, 6]]) == [1, 2, 3, 1, 2, 3]\n assert candidate(n = 6,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [4, 6]]) == [1, 2, 3, 1, 2, 3]\n assert candidate(n = 5,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == [1, 2, 1, 2, 3]\n assert candidate(n = 10,paths = [[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]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 2]\n assert candidate(n = 12,paths = [[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, 3], [4, 6], [7, 9], [2, 4], [5, 7], [8, 10], [11, 12]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(n = 10,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 4], [3, 5], [6, 8], [7, 9]]) == [1, 2, 1, 3, 2, 1, 2, 3, 1, 2]\n assert candidate(n = 12,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 11], [6, 12]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3]\n assert candidate(n = 12,paths = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 12], [8, 10], [9, 11]]) == [1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 3, 2]\n assert candidate(n = 18,paths = [[1, 2], [2, 3], [3, 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, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 3, 2, 1, 3, 2, 1, 3, 2]\n assert candidate(n = 20,paths = [[1, 2], [2, 3], [3, 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], [10, 11]]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(n = 9,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 8], [5, 9], [6, 9], [7, 8], [8, 9]]) == [1, 2, 2, 2, 1, 1, 1, 3, 2]\n assert candidate(n = 15,paths = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [3, 6], [4, 7], [4, 8], [5, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 15]]) == [1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2]\n assert candidate(n = 15,paths = [[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, 9], [10, 11], [12, 13], [14, 15]]) == [1, 2, 2, 1, 1, 1, 1, 2, 3, 2, 3, 2, 3, 2, 3]\n assert candidate(n = 25,paths = [[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, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 13]]) == [1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 3, 1, 3, 1, 3, 1, 3, 1]\n assert candidate(n = 15,paths = [[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], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(n = 25,paths = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [6, 21], [7, 22], [8, 23], [9, 24], [10, 25], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25], [21, 22], [22, 23], [23, 24], [24, 25]]) == [1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 0, 4, 0, 4]\n assert candidate(n = 20,paths = [[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], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [9, 20], [10, 20], [11, 20], [12, 20], [13, 20], [14, 20], [15, 20], [16, 20], [17, 20], [18, 20], [19, 20]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3]\n assert candidate(n = 15,paths = [[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], [6, 14], [7, 15], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 14], [1, 5], [2, 6], [3, 7], [4, 8]]) == [1, 2, 2, 2, 3, 1, 1, 1, 1, 1, 3, 3, 3, 2, 2]\n assert candidate(n = 25,paths = [[1, 2], [2, 3], [3, 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, 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], [24, 1], [25, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 1], [24, 2], [25, 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, 0]\n assert candidate(n = 20,paths = [[1, 2], [2, 3], [3, 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, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [2, 4], [5, 7], [8, 10], [11, 13], [14, 16], [17, 19]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]\n assert candidate(n = 15,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 6], [7, 8], [9, 10], [5, 7], [6, 9], [11, 12], [11, 13], [11, 14], [12, 15], [13, 14]]) == [1, 2, 2, 2, 1, 3, 3, 1, 1, 3, 1, 2, 2, 3, 1]\n assert candidate(n = 12,paths = [[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, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(n = 10,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 6], [7, 8], [9, 10], [5, 7], [6, 9]]) == [1, 2, 2, 2, 1, 3, 3, 1, 1, 3]\n assert candidate(n = 20,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [6, 15], [7, 15], [8, 15], [9, 16], [10, 16], [11, 16], [12, 17], [13, 17], [14, 17], [15, 18], [16, 18], [17, 19], [18, 20], [19, 20]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2]\n assert candidate(n = 10,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [2, 8], [3, 9], [4, 6], [5, 7]]) == [1, 2, 1, 2, 1, 3, 2, 1, 2, 3]\n assert candidate(n = 12,paths = [[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, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 1], [12, 2]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(n = 20,paths = [[1, 2], [1, 10], [2, 3], [2, 9], [3, 4], [3, 8], [4, 5], [4, 7], [5, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 12], [11, 20], [12, 13], [12, 19], [13, 14], [13, 18], [14, 15], [14, 17], [15, 16], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 11]]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(n = 12,paths = [[1, 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, 11], [7, 12], [8, 11], [8, 12], [9, 11], [9, 12]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(n = 10,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 4]\n assert candidate(n = 20,paths = [[1, 2], [2, 3], [3, 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, 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, 1], [20, 2]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 0]\n assert candidate(n = 10,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 6], [5, 7], [5, 8], [6, 9], [7, 10], [8, 9], [9, 10]]) == [1, 2, 2, 2, 1, 3, 3, 3, 1, 4]\n assert candidate(n = 9,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6], [5, 7], [6, 8], [7, 9], [8, 9]]) == [1, 2, 2, 2, 1, 3, 3, 1, 4]\n assert candidate(n = 12,paths = [[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, 11], [10, 12]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(n = 15,paths = [[1, 2], [2, 3], [3, 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], [15, 2]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(n = 10,paths = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 9], [5, 10], [6, 10]]) == [1, 2, 2, 1, 1, 1, 1, 2, 2, 2]\n assert candidate(n = 20,paths = [[1, 2], [2, 3], [3, 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, 3], [4, 6], [7, 9], [10, 12], [13, 15], [16, 18], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15], [6, 14], [7, 13], [8, 12], [9, 11]]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 3]\n assert candidate(n = 15,paths = [[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], [6, 14], [7, 15], [8, 14], [9, 15], [10, 14], [11, 15], [12, 15], [13, 15]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(n = 20,paths = [[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], [8, 14], [8, 15], [8, 16], [9, 17], [9, 18], [9, 19], [10, 20], [11, 14], [11, 15], [11, 16], [12, 17], [12, 18], [12, 19], [13, 20]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 10,paths = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [1, 5], [3, 8]]) == [1, 2, 1, 2, 3, 1, 2, 3, 1, 2]\n assert candidate(n = 15,paths = [[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, 9], [10, 11], [12, 13], [14, 15], [1, 15], [3, 5], [8, 12]]) == [1, 2, 2, 1, 1, 1, 1, 2, 3, 2, 3, 3, 2, 2, 3]\n assert candidate(n = 10,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 10]]) == [1, 2, 2, 2, 1, 3, 3, 1, 1, 3]\n assert candidate(n = 12,paths = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 12], [8, 12], [9, 12], [10, 11], [10, 12], [11, 12]]) == [1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 3, 4]\n assert candidate(n = 18,paths = [[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], [10, 18], [11, 18], [12, 18], [13, 18], [14, 18], [15, 18], [16, 18], [17, 18]]) == [1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 3]\n assert candidate(n = 25,paths = [[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, 23], [9, 24], [9, 25], [10, 23], [10, 24], [10, 25], [11, 20], [11, 21], [11, 22], [12, 20], [12, 21], [12, 22], [13, 20], [13, 21], [13, 22], [14, 23], [14, 24], [14, 25], [15, 23], [15, 24], [15, 25], [16, 23], [16, 24], [16, 25], [17, 23], [17, 24], [17, 25], [18, 23], [18, 24], [18, 25], [19, 23], [19, 24], [19, 25]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3]\n assert candidate(n = 12,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 7], [6, 8], [7, 9], [7, 10], [8, 11], [8, 12], [9, 10], [11, 12]]) == [1, 2, 2, 2, 1, 1, 3, 3, 1, 4, 2, 4]\n assert candidate(n = 10,paths = [[1, 2], [1, 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]]) == [1, 2, 2, 2, 2, 1, 1, 1, 1, 3]\n assert candidate(n = 15,paths = [[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], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15]]) == [1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(n = 12,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [9, 10], [11, 12]]) == [1, 2, 2, 2, 1, 3, 4, 1, 3, 4, 1, 3]\n", "comparison": "exact"}, "public_tests": ["3\n[[1,2],[2,3],[3,1]]", "4\n[[1,2],[3,4]]", "4\n[[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]"], "hints": ["Since each garden is connected to at most 3 gardens, there's always an available color for each garden. For example, if one garden is next to gardens with colors 1, 3, 4, then color #2 is available."], "metadata": {"canonical_parameter_names": ["n", "paths"], "leetcode_dataset_entry_point": "Solution().gardenNoAdj", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:48+00:00", "tests_total": 59, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph", "graph-coloring"]}, "language": "python", "interface": {"raw_signature": "def gardenNoAdj(self, n: int, paths: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "gardenNoAdj", "parameters": [{"name": "n", "type": "int"}, {"name": "paths", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1043, "task_id": "partition-array-for-maximum-sum", "difficulty": "Medium", "problem_description": "Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray.\n\nReturn the largest sum of the given array after partitioning. Test cases are generated so that the answer fits in a 32-bit integer.\n\nExample 1:\n\nInput: arr = [1,15,7,9,2,5,10], k = 3\nOutput: 84\nExplanation: arr becomes [15,15,15,9,10,10,10]\n\nExample 2:\n\nInput: arr = [1,4,1,5,7,3,6,1,9,9,3], k = 4\nOutput: 83\n\nExample 3:\n\nInput: arr = [1], k = 1\nOutput: 1\n\nConstraints:\n\n- 1 <= arr.length <= 500\n- 0 <= arr[i] <= 10^9\n- 1 <= k <= arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1],k = 1) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 45\n assert candidate(arr = [1, 15, 7, 9, 2, 5, 10],k = 3) == 84\n assert candidate(arr = [10, 20, 30, 40, 50],k = 3) == 190\n assert candidate(arr = [9, 1, 2, 3, 9],k = 3) == 45\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 55\n assert candidate(arr = [2, 3, 5, 10, 15, 20],k = 2) == 66\n assert candidate(arr = [3, 2, 1, 4, 7, 8, 5, 6, 9],k = 3) == 62\n assert candidate(arr = [5, 4, 3, 2, 1],k = 1) == 15\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 58\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 50\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 54\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5) == 25\n assert candidate(arr = [5, 4, 3, 2, 1],k = 5) == 25\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 60\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 75\n assert candidate(arr = [1, 2, 3, 4, 5],k = 3) == 19\n assert candidate(arr = [1, 4, 1, 5, 7, 3, 6, 1, 9, 9, 3],k = 4) == 83\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 100\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10],k = 9) == 90\n assert candidate(arr = [2, 3, 1, 2, 4, 3],k = 2) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 75\n assert candidate(arr = [4, 3, 2, 5, 6],k = 2) == 24\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 6) == 143\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 75\n assert candidate(arr = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 8) == 180\n assert candidate(arr = [8, 5, 4, 2, 1, 9, 3, 7, 6, 10, 11, 13, 12, 14, 15, 17, 16, 18, 19, 20, 22, 21, 23, 24, 26, 25, 27, 28, 30, 29, 31, 32, 33, 35, 34, 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],k = 6) == 2007\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 = 7) == 1422\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) == 229\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 7500\n assert candidate(arr = [9, 1, 5, 7, 3, 6, 4, 8, 2, 10],k = 2) == 80\n assert candidate(arr = [7, 1, 5, 3, 6, 4, 2, 9, 8, 11, 10, 12],k = 6) == 118\n assert candidate(arr = [8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 49\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) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(arr = [9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3, 9],k = 4) == 117\n assert candidate(arr = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 2) == 58\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) == 20\n assert candidate(arr = [7, 3, 6, 1, 4, 9, 2, 8, 5, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 7) == 835\n assert candidate(arr = [5, 1, 1, 5, 2, 2, 2, 2, 2, 5],k = 4) == 50\n assert candidate(arr = [9, 1, 2, 3, 9, 3, 2, 4, 5, 6],k = 3) == 75\n assert candidate(arr = [5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1],k = 3) == 334\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 7) == 6700\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 139\n assert candidate(arr = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 3) == 458\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 1) == 2000\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) == 240\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 423\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, 10],k = 25) == 300\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) == 150\n assert candidate(arr = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 2) == 1050\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 = 10) == 160\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) == 1375\n assert candidate(arr = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6],k = 3) == 4800\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 2) == 1270\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 15\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, 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 = 15) == 900\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) == 20\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 150\n assert candidate(arr = [5, 3, 7, 9, 2, 6, 1, 8, 4, 10, 11, 12, 13, 14, 15],k = 5) == 170\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 = 2) == 480\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 120\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) == 300\n assert candidate(arr = [9, 1, 2, 3, 9, 1, 4, 5, 1, 6, 7, 8, 1, 9],k = 4) == 122\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 = 5) == 130\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, 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 = 7) == 881\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == 50\n assert candidate(arr = [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 = 4) == 192\n assert candidate(arr = [5, 1, 100, 1, 1, 100, 1, 1, 100, 1, 1],k = 3) == 910\n assert candidate(arr = [5, 4, 3, 2, 1],k = 4) == 21\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 68\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 3) == 54\n assert candidate(arr = [5, 2, 7, 1, 8, 3, 6, 4, 9, 10, 11, 12, 13, 14, 15],k = 8) == 176\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 = 10) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 49\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 2) == 200\n assert candidate(arr = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 300\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 = 15) == 675\n assert candidate(arr = [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, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 502\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 162\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == 10000\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, 59],k = 15) == 1320\n assert candidate(arr = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 10) == 150\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 750\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 150],k = 6) == 1590\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 4) == 480\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 2) == 90\n assert candidate(arr = [5, 1, 3, 4, 6, 2, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29],k = 6) == 563\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 = 5) == 250\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, 10],k = 25) == 300\n assert candidate(arr = [5, 6, 1, 2, 8, 7, 3, 4, 5, 6, 7, 8, 9],k = 5) == 106\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 200\n assert candidate(arr = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 2) == 180\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) == 420\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 175\n assert candidate(arr = [5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == 147\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) == 250\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 111\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 135\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) == 229\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5],k = 3) == 89\n", "comparison": "exact"}, "public_tests": ["[1,15,7,9,2,5,10]\n3", "[1,4,1,5,7,3,6,1,9,9,3]\n4", "[1]\n1"], "hints": ["Think dynamic programming: dp[i] will be the answer for array A[0], ..., A[i-1].", "For j = 1 .. k that keeps everything in bounds, dp[i] is the maximum of dp[i-j] + max(A[i-1], ..., A[i-j]) * j ."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().maxSumAfterPartitioning", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:50+00:00", "tests_total": 104, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maxSumAfterPartitioning(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "maxSumAfterPartitioning", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1044, "task_id": "longest-duplicate-substring", "difficulty": "Hard", "problem_description": "Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap.\n\nReturn any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is \"\".\n\nExample 1:\n\nInput: s = \"banana\"\nOutput: \"ana\"\n\nExample 2:\n\nInput: s = \"abcd\"\nOutput: \"\"\n\nConstraints:\n\n- 2 <= s.length <= 3 * 10^4\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcabcabc\") == \"abcabc\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"mississippi\") == \"issi\"\n assert candidate(s = \"banana\") == \"ana\"\n assert candidate(s = \"bananaaa\") == \"ana\"\n assert candidate(s = \"abcdefgh\") == \"\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"aaaaa\") == \"aaaa\"\n assert candidate(s = \"aabb\") == \"a\"\n assert candidate(s = \"aaaa\") == \"aaa\"\n assert candidate(s = \"abab\") == \"ab\"\n assert candidate(s = \"longestrepeatingsubstringlongestrepeatingsubstring\") == \"longestrepeatingsubstring\"\n assert candidate(s = \"abcdefghijkabcdefgh\") == \"abcdefgh\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijkabcdefghijk\") == \"abcdefghijkabcdefghijkabcdefghijk\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"norepeats\") == \"e\"\n assert candidate(s = \"abcdeabcdeabcdeabcdeabcde\") == \"abcdeabcdeabcdeabcde\"\n assert candidate(s = \"abcabcabcabcabcabcabcd\") == \"abcabcabcabcabcabc\"\n assert candidate(s = \"abracadabra\") == \"abra\"\n assert candidate(s = \"abcdefabcdefabcdef\") == \"abcdefabcdef\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabc\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccc\") == \"aaaaaaaaa\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefgh\"\n assert candidate(s = \"aaaaaabbccccaaa\") == \"aaaaa\"\n assert candidate(s = \"abcdefghigklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"klmnopqrstuvwxyz\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedsubstringsubstring\") == \"substring\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == \"abcdefghijabcdefghij\"\n assert candidate(s = \"hellohellohello\") == \"hellohello\"\n assert candidate(s = \"abababababababababababababababab\") == \"ababababababababababababababab\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\") == \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"anvnvnvnvnvnvnvnvvnvnvnvnvnvnvnvnvnvn\") == \"vnvnvnvnvnvnvnvnvn\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaananabanana\") == \"banana\"\n assert candidate(s = \"abcabcabcabcabcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(s = \"bananaapplebananabananaapplebananabananaapple\") == \"bananaapplebananabananaapple\"\n assert candidate(s = \"abcabcabcabcd\") == \"abcabcabc\"\n assert candidate(s = \"mississippimississippimississippi\") == \"mississippimississippi\"\n assert candidate(s = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\") == \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\"\n assert candidate(s = \"qwertyuiopqwertyuiop\") == \"qwertyuiop\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdeabcdfabcde\") == \"abcde\"\n assert candidate(s = \"abracadabraabracadabraabracadabraabracadabraabracadabra\") == \"abracadabraabracadabraabracadabraabracadabra\"\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == \"abracadabraabracadabra\"\n assert candidate(s = \"zabacabadabacaba\") == \"abacaba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"z\"\n assert candidate(s = \"aaaaaa\") == \"aaaaa\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"abcabcabcabcabcabc\") == \"abcabcabcabcabc\"\n assert candidate(s = \"abcdefghijkabcdefghijk\") == \"abcdefghijk\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"bananaananabananana\") == \"banana\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicroscopicsilicovolcanoconiosis\") == \"pneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(s = \"thisisaverylongstringwithsomerepeatedsubstringsubstring\") == \"substring\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\") == \"abcdefghijkabcdefghijk\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicroscopicsilicovolcanoconiosis\") == \"pneumonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(s = \"abcdabcdabcdabcd\") == \"abcdabcdabcd\"\n assert candidate(s = \"bananaaaanaaanana\") == \"anaaa\"\n assert candidate(s = \"aaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abababababababababababababab\") == \"ababababababababababababab\"\n assert candidate(s = \"asdfghjklasdfghjklasdfghjkl\") == \"asdfghjklasdfghjkl\"\n assert candidate(s = \"racecaracecaracecar\") == \"racecaracecar\"\n assert candidate(s = \"abcdefghijk\") == \"\"\n assert candidate(s = \"ababababababababababab\") == \"abababababababababab\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"abababababababababab\") == \"ababababababababab\"\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == \"qwertyuiopqwertyuiopqwertyuiop\"\n assert candidate(s = \"bananaananabanananabanana\") == \"ananabanana\"\n assert candidate(s = \"abacabadabacaba\") == \"abacaba\"\n assert candidate(s = \"zxyzyxyzxyzyxyzxyzyxzyzy\") == \"zxyzyxyzxyzyx\"\n assert candidate(s = \"bananaananab\") == \"anana\"\n assert candidate(s = \"ananananananananan\") == \"anananananananan\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyz\"\n assert candidate(s = \"abcdefghijkabcdefghijabcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"zzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzz\"\n assert candidate(s = \"thisisaverylongstringwithsomerepeatingpatterns\") == \"ing\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxy\") == \"xyxyxyxyxyxyxyxyxyxyxy\"\n assert candidate(s = \"xyzabcxyzabcxyzabcxyzabcxyz\") == \"xyzabcxyzabcxyzabcxyz\"\n assert candidate(s = \"supercalifragilisticexpialidocioussupercalifragilisticexpialidocious\") == \"supercalifragilisticexpialidocious\"\n assert candidate(s = \"aaaaabbbbbaaaaabbbb\") == \"aaaaabbbb\"\n assert candidate(s = \"bananaapplebananabananaapple\") == \"bananaapple\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"longestsubstringissubstring\") == \"substring\"\n assert candidate(s = \"abcdefgabcdefg\") == \"abcdefg\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == \"abcdeabcdeabcde\"\n assert candidate(s = \"thisisaverylongstringwitharepeatedsubstringthisisaverylongstringwitharepeatedsubstring\") == \"thisisaverylongstringwitharepeatedsubstring\"\n assert candidate(s = \"abracadabraabracadabra\") == \"abracadabra\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcd\"\n assert candidate(s = \"xyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyz\"\n assert candidate(s = \"bananaanananab\") == \"anana\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"a\"\n assert candidate(s = \"longestsubstrlongestsubstrlongestsubstr\") == \"longestsubstrlongestsubstr\"\n assert candidate(s = \"anananananananananananananananananan\") == \"ananananananananananananananananan\"\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == \"aabbccddeeff\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"noonnoonnoon\") == \"noonnoon\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"anananananananananananananananananananananananananananananananananananananananananananan\") == \"ananananananananananananananananananananananananananananananananananananananananananan\"\n assert candidate(s = \"abcdeabcdeabcde\") == \"abcdeabcde\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrs\") == \"mnopqrsmnopqrsmnopqrs\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == \"abcdefgabcdefg\"\n assert candidate(s = \"racecar\") == \"c\"\n assert candidate(s = \"abcdefghijabcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"ababababababababababababababababababababababab\") == \"abababababababababababababababababababababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghabcdefgh\") == \"abcdefgh\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == \"ic\"\n assert candidate(s = \"xylophonepianoguitarxylophonepianoguitarxylophonepianoguitar\") == \"xylophonepianoguitarxylophonepianoguitar\"\n assert candidate(s = \"aaaaabaaaaabaaaaab\") == \"aaaaabaaaaab\"\n assert candidate(s = \"mississippimississippimississippimississippimississippimississippi\") == \"mississippimississippimississippimississippimississippi\"\n assert candidate(s = \"hellohellohellohello\") == \"hellohellohello\"\n assert candidate(s = \"zxcvbnmzxcvbnmzxcvbnm\") == \"zxcvbnmzxcvbnm\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaa\"\n", "comparison": "exact"}, "public_tests": ["\"banana\"", "\"abcd\""], "hints": ["Binary search for the length of the answer. (If there's an answer of length 10, then there are answers of length 9, 8, 7, ...)", "To check whether an answer of length K exists, we can use Rabin-Karp 's algorithm."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestDupSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:53+00:00", "tests_total": 117, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "binary-search", "sliding-window", "rolling-hash", "suffix-array", "hash-function", "suffix-automaton", "suffix-tree", "z-algorithm", "boyer-moore-string-search-algorithm"]}, "language": "python", "interface": {"raw_signature": "def longestDupSubstring(self, s: str) -> str:", "container": "Solution", "callable": "longestDupSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1046, "task_id": "last-stone-weight", "difficulty": "Easy", "problem_description": "You are given an array of integers stones where stones[i] is the weight of the i^th stone.\n\nWe are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x <= y. The result of this smash is:\n\n- If x == y, both stones are destroyed, and\n- If x != y, the stone of weight x is destroyed, and the stone of weight y has new weight y - x.\n\nAt the end of the game, there is at most one stone left.\n\nReturn the weight of the last remaining stone. If there are no stones left, return 0.\n\nExample 1:\n\nInput: stones = [2,7,4,1,8,1]\nOutput: 1\nExplanation:\nWe combine 7 and 8 to get 1 so the array converts to [2,4,1,1,1] then,\nwe combine 2 and 4 to get 2 so the array converts to [2,1,1,1] then,\nwe combine 2 and 1 to get 1 so the array converts to [1,1,1] then,\nwe combine 1 and 1 to get 0 so the array converts to [1] then that's the value of the last stone.\n\nExample 2:\n\nInput: stones = [1]\nOutput: 1\n\nConstraints:\n\n- 1 <= stones.length <= 30\n- 1 <= stones[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [9, 3, 2, 10, 8]) == 2\n assert candidate(stones = [5, 5, 5, 5, 5]) == 5\n assert candidate(stones = [5, 5, 5, 5, 5]) == 5\n assert candidate(stones = [3, 3, 3, 3, 3]) == 3\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(stones = [10, 4, 2, 10]) == 2\n assert candidate(stones = [3, 7, 8, 9]) == 3\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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(stones = [3, 3, 3, 3]) == 0\n assert candidate(stones = [10, 4, 3, 100]) == 83\n assert candidate(stones = [5, 8, 1, 2, 7]) == 1\n assert candidate(stones = [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(stones = [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]) == 971\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(stones = [10, 4, 3, 100, 56, 89]) == 28\n assert candidate(stones = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(stones = [2, 2, 2, 2, 2, 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\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(stones = [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(stones = [10, 4, 3, 100, 5]) == 78\n assert candidate(stones = [1]) == 1\n assert candidate(stones = [2, 2, 2, 2, 2, 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\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [10, 4, 3, 100, 2]) == 81\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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(stones = [6, 6, 6, 6, 6]) == 6\n assert candidate(stones = [5, 8, 12, 9, 11, 10]) == 1\n assert candidate(stones = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 995\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 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(stones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(stones = [2, 7, 4, 1, 8, 1]) == 1\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 1]) == 1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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(stones = [1, 1, 1, 1, 1, 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]) == 971\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [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]) == 0\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [5, 8, 12, 19, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == 0\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 999, 899, 799, 699, 599, 499, 399, 299, 199, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 76\n assert candidate(stones = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(stones = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(stones = [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, 1]) == 499\n assert candidate(stones = [500, 400, 300, 200, 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]) == 0\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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\n assert candidate(stones = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1, 1, 1, 1, 1]) == 1\n assert candidate(stones = [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(stones = [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]) == 10\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 25, 10, 5, 1]) == 9\n assert candidate(stones = [800, 700, 600, 500, 400, 300, 200, 100, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100, 50, 49, 48, 47, 46]) == 44\n assert candidate(stones = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == 0\n assert candidate(stones = [250, 500, 750, 1000, 250, 500, 750, 1000, 250, 500, 750, 1000, 250, 500, 750, 1000, 250, 500, 750, 1000, 250, 500, 750, 1000, 250, 500, 750, 1000, 250, 500]) == 250\n assert candidate(stones = [300, 200, 100, 50, 25, 12, 6, 3, 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(stones = [800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 45\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]) == 1\n assert candidate(stones = [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, 1]) == 7\n assert candidate(stones = [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]) == 10\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 1]) == 1\n assert candidate(stones = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(stones = [20, 10, 5, 25, 15, 30, 35, 50, 40, 60]) == 0\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [500, 300, 200, 400, 100, 150, 250, 600, 700, 800, 900]) == 0\n assert candidate(stones = [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]) == 3\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [5, 8, 2, 9, 7, 3, 6, 10, 1, 4]) == 1\n assert candidate(stones = [1, 10, 100, 1000, 10, 100, 1000, 1, 10, 100, 1000, 1, 10, 100, 1000, 1, 10, 100, 1000, 1, 10, 100, 1000, 1, 10, 100, 1000, 1, 10]) == 213\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 6\n assert candidate(stones = [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]) == 5\n assert candidate(stones = [500, 500, 500, 500, 499, 499, 499, 499, 498, 498, 498, 498, 497, 497, 497, 497, 496, 496, 496, 496, 495, 495, 495, 495, 494, 494, 494, 494, 493, 493]) == 0\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(stones = [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, 499]) == 1\n assert candidate(stones = [2, 2, 3, 3, 5, 5, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28]) == 0\n assert candidate(stones = [100, 100, 100, 100, 99, 99, 99, 99, 98, 98, 98, 98]) == 0\n assert candidate(stones = [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\n assert candidate(stones = [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]) == 0\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(stones = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 565\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 0\n assert candidate(stones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 9\n assert candidate(stones = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 5\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 6\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987]) == 0\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [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, 1000]) == 565\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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\n assert candidate(stones = [300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200]) == 0\n assert candidate(stones = [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(stones = [300, 200, 100, 50, 25, 12, 6, 3, 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(stones = [10, 4, 6, 9, 2, 11, 3, 7, 5, 8]) == 1\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10, 989, 11, 988, 12, 987, 13, 986, 14, 985, 15]) == 858\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n", "comparison": "exact"}, "public_tests": ["[2,7,4,1,8,1]", "[1]"], "hints": ["Simulate the process. We can do it with a heap, or by sorting some list of stones every time we take a turn."], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().lastStoneWeight", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:55+00:00", "tests_total": 124, "tests_dropped": 19, "flags": [], "topic_tags": ["array", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def lastStoneWeight(self, stones: list[int]) -> int:", "container": "Solution", "callable": "lastStoneWeight", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1047, "task_id": "remove-all-adjacent-duplicates-in-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.\n\nWe repeatedly make duplicate removals on s until we no longer can.\n\nReturn the final string after all such duplicate removals have been made. It can be proven that the answer is unique.\n\nExample 1:\n\nInput: s = \"abbaca\"\nOutput: \"ca\"\nExplanation:\nFor example, in \"abbaca\" we could remove \"bb\" since the letters are adjacent and equal, and this is the only possible move. The result of this move is that the string is \"aaca\", of which only \"aa\" is possible, so the final string is \"ca\".\n\nExample 2:\n\nInput: s = \"azxxzy\"\nOutput: \"ay\"\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"acbbcaa\") == \"a\"\n assert candidate(s = \"aabbaa\") == \"\"\n assert candidate(s = \"abcdef\") == \"abcdef\"\n assert candidate(s = \"abbacdcd\") == \"cdcd\"\n assert candidate(s = \"aaaaa\") == \"a\"\n assert candidate(s = \"abbaca\") == \"ca\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"aabbccddccbaaabbccdd\") == \"ba\"\n assert candidate(s = \"abcddcba\") == \"\"\n assert candidate(s = \"abba\") == \"\"\n assert candidate(s = \"zyz\") == \"zyz\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"abbacca\") == \"a\"\n assert candidate(s = \"abcd\") == \"abcd\"\n assert candidate(s = \"abbazzyy\") == \"\"\n assert candidate(s = \"aabbccddeeff\") == \"\"\n assert candidate(s = \"aabbcc\") == \"\"\n assert candidate(s = \"mississippi\") == \"m\"\n assert candidate(s = \"aaaaaaaaa\") == \"a\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"aaaaaaaa\") == \"\"\n assert candidate(s = \"zzzyyxxwwvvuuttrrqqqllopssmmnnllkkjjiihhggffeeddccbbaa\") == \"zqop\"\n assert candidate(s = \"aabbccdd\") == \"\"\n assert candidate(s = \"azxxzy\") == \"ay\"\n assert candidate(s = \"aabbbccddeeeffggghhhiiiijjjjkkkkllllmmmmnnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzz\") == \"beghopwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"\"\n assert candidate(s = \"abcdeedcba\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdabcdbcaabbccdd\") == \"abcdabcdbc\"\n assert candidate(s = \"xyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyx\") == \"xyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyx\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbaaabbbaaaabbbaaaaabbbbbbaaaaaaaaa\") == \"a\"\n assert candidate(s = \"mississiissippi\") == \"m\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == \"\"\n assert candidate(s = \"aaabbbcccdddcccbbbaaa\") == \"abcdcba\"\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == \"\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"\"\n", "comparison": "exact"}, "public_tests": ["\"abbaca\"", "\"azxxzy\""], "hints": ["Use a stack to process everything greedily."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removeDuplicates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:08:57+00:00", "tests_total": 42, "tests_dropped": 2, "flags": [], "topic_tags": ["string", "stack"]}, "language": "python", "interface": {"raw_signature": "def removeDuplicates(self, s: str) -> str:", "container": "Solution", "callable": "removeDuplicates", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1048, "task_id": "longest-string-chain", "difficulty": "Medium", "problem_description": "You are given an array of words where each word consists of lowercase English letters.\n\nword_A is a predecessor of word_B if and only if we can insert exactly one letter anywhere in word_A without changing the order of the other characters to make it equal to word_B.\n\n- For example, \"abc\" is a predecessor of \"abac\", while \"cba\" is not a predecessor of \"bcad\".\n\nA word chain is a sequence of words [word_1, word_2, ..., word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on. A single word is trivially a word chain with k == 1.\n\nReturn the length of the longest possible word chain with words chosen from the given list of words.\n\nExample 1:\n\nInput: words = [\"a\",\"b\",\"ba\",\"bca\",\"bda\",\"bdca\"]\nOutput: 4\nExplanation: One of the longest word chains is [\"a\",\"ba\",\"bda\",\"bdca\"].\n\nExample 2:\n\nInput: words = [\"xbc\",\"pcxbcf\",\"xb\",\"cxbc\",\"pcxbc\"]\nOutput: 5\nExplanation: All the words can be put in a word chain [\"xb\", \"xbc\", \"cxbc\", \"pcxbc\", \"pcxbcf\"].\n\nExample 3:\n\nInput: words = [\"abcd\",\"dbqca\"]\nOutput: 1\nExplanation: The trivial word chain [\"abcd\"] is one of the longest word chains.\n[\"abcd\",\"dbqca\"] is not a valid word chain because the ordering of the letters is changed.\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length <= 16\n- words[i] only consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['xbc', 'pcxbcf', 'xb', 'cxbc', 'pcxbc']) == 5\n assert candidate(words = ['a', 'b', 'ba', 'bca', 'bda', 'bdca']) == 4\n assert candidate(words = ['abcd', 'abde', 'acde', 'bcde', 'abcde']) == 2\n assert candidate(words = ['a', 'abc', 'bde', 'abdce']) == 1\n assert candidate(words = ['m', 'mo', 'moc', 'moch', 'mocha', 'lca', 'lcoa', 'lcoc', 'lococ', 'loccoc']) == 5\n assert candidate(words = ['ksqvsyqpcq', 'ksqvsyqcpcq', 'vqsqpcq', 'ksqvsyqckpcq', 'kpcq', 'cqcq', 'qpcq', 'pcqcq']) == 3\n assert candidate(words = ['ksq', 'ksqa', 'k', 'q', 'kq', 'pql', 'kqs', 'ks', 'ar', 'n', 'qn', 'kaq', 'pxq']) == 4\n assert candidate(words = ['a', 'abc', 'bcd', 'abcd', 'abcde']) == 3\n assert candidate(words = ['a', 'abc', 'bdc', 'bcd', 'abcd', 'bdca', 'edcba']) == 2\n assert candidate(words = ['abcd', 'dbqca']) == 1\n assert candidate(words = ['a', 'abc', 'bdc', 'abcde']) == 1\n assert candidate(words = ['xyz', 'xyaz', 'xyazt', 'xyaztr', 'xyaztrd', 'xyaztrdf', 'xyaztrdfg', 'xyaztrdfgh', 'xyaztrdfghj', 'xyaztrdfghjk', 'xyaztrdfghjkl', 'xyaztrdfghjklm']) == 12\n assert candidate(words = ['abcdef', 'abcde', 'abce', 'abceg', 'abeg', 'ae', 'ag', 'aeg', 'abc', 'ab', 'a', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop']) == 14\n assert candidate(words = ['xyz', 'xy', 'xz', 'yz', 'x', 'y', 'z', 'xyza', 'xyzab', 'xyzabc', 'xyzabcd', 'xyzabcde']) == 8\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij']) == 10\n assert candidate(words = ['abcd', 'abdc', 'acbd', 'bacd', 'cabd', 'dabc', 'abcdx', 'abcdxy', 'abcdxyz', 'abcdxyza']) == 5\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop']) == 16\n assert candidate(words = ['abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop']) == 14\n assert candidate(words = ['abc', 'def', 'ab', 'bc', 'de', 'ef', 'abcd', 'defg', 'abef', 'abcd', 'bcde', 'cdef', 'abcd', 'bcde', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn', 'klmno', 'lmnop', 'mnopq', 'nopqr', 'opqrs', 'pqrs', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz']) == 4\n assert candidate(words = ['abcd', 'abcde', 'abfde', 'abfce', 'abcfg', 'abcgd', 'abcdefgh', 'abcdfeh', 'abcdfehi', 'abcdfehij']) == 3\n assert candidate(words = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']) == 1\n assert candidate(words = ['ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno', 'abcdefghijklmnop']) == 15\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == 8\n assert candidate(words = ['k', 'ko', 'kom', 'komo', 'komol', 'komole', 'komolen', 'komolex', 'komolexy', 'komolexyu', 'komolexyuc', 'komolexyucn', 'komolexyucne', 'komolexyucnew', 'komolexyucnewd', 'komolexyucnewdy', 'komolexyucnewdyt']) == 16\n assert candidate(words = ['xyz', 'xyzu', 'xyzuv', 'xyzuvw', 'xyzuvwx', 'xyzuvwxy', 'xyzuvwxz', 'xyzuvwxyz', 'xyzuvwxyza', 'xyzuvwxyzab', 'xyzuvwxyzabc', 'xyzuvwxyzabcd', 'xyzuvwxyzabce', 'xyzuvwxyzabcde', 'xyzuvwxyzabcdef', 'xyzuvwxyzabcdefg']) == 14\n assert candidate(words = ['abcd', 'abdc', 'acbd', 'bacd', 'bcad', 'cabd', 'cbad', 'dabc', 'dbac', 'dcab', 'dcba', 'bdac', 'bcad', 'acdb', 'cdba', 'adbc', 'bdca', 'cadb', 'cdab', 'cbda', 'abcd', 'abdc', 'acbd', 'bacd', 'bcad', 'cabd', 'cbad', 'dabc', 'dbac', 'dcab', 'dcba', 'bdac', 'bcad', 'acdb', 'cdba', 'adbc', 'bdca', 'cadb', 'cdab', 'cbda']) == 1\n assert candidate(words = ['xyz', 'xz', 'xy', 'yz', 'x', 'y', 'z', 'xyza', 'xyzab', 'xyzabc', 'xyzabcd', 'xyzabcde']) == 8\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaaa', 'aaaaaaaaaaaa']) == 12\n assert candidate(words = ['mn', 'mno', 'mnoa', 'mnob', 'mnoab', 'mnop', 'mnopq', 'mnopqr', 'mnopqrs', 'mnopqrst']) == 7\n assert candidate(words = ['abcd', 'acbd', 'adcb', 'bacd', 'bcad', 'bdac', 'cabd', 'cbad', 'cdab', 'dabc', 'dbac', 'dcab']) == 1\n assert candidate(words = ['a', 'b', 'c', 'ab', 'bc', 'abc', 'abcd', 'abdc', 'acbd', 'bacd', 'bdac', 'cabd', 'cbad', 'dabc', 'dbac']) == 4\n assert candidate(words = ['apple', 'ape', 'aple', 'appel', 'apples', 'appl', 'applle', 'appllees']) == 4\n assert candidate(words = ['xyz', 'xyzz', 'xyyzz', 'xyyyzz', 'xyyyyzz', 'xyyyyyzz', 'xyyyyyyzz', 'xyyyyyzzz', 'xyyyyyyzzzz']) == 7\n assert candidate(words = ['abcd', 'abdc', 'acbd', 'bacd', 'badc', 'cabd', 'cbad', 'cdab', 'cdba', 'dcba', 'dcab', 'dbac', 'dbca']) == 1\n assert candidate(words = ['apple', 'app', 'aple', 'appl', 'applu', 'apples', 'applks', 'applksa', 'applksag', 'applksage', 'applksager', 'applksagerm']) == 6\n assert candidate(words = ['m', 'mo', 'moc', 'moch', 'mocha', 'mochas', 'mochaste', 'mochaster', 'mochastera', 'mochasteras']) == 6\n assert candidate(words = ['p', 'pq', 'pqr', 'pqrs', 'pqrst', 'pqrstu', 'pqrstuv', 'pqrstuvw', 'pqrstuvwx', 'pqrstuvwxy', 'pqrstuvwxyz', 'pqrstuvwxyza', 'pqrstuvwxyzab', 'pqrstuvwxyzabc', 'pqrstuvwxyzabcd', 'pqrstuvwxyzabcde']) == 16\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 10\n assert candidate(words = ['m', 'mo', 'mop', 'mopt', 'mopti', 'moptio', 'moptiop', 'moptiopi', 'moptiopim', 'moptiopimu', 'moptiopimuv', 'moptiopimuvi', 'moptiopimuvis', 'moptiopimuvisd']) == 14\n assert candidate(words = ['abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop']) == 8\n assert candidate(words = ['xyz', 'xy', 'x', 'xyzpq', 'yzpq', 'ypq', 'pq', 'zpq', 'p', 'q', 'qp']) == 5\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', 'az', 'bz', 'cz', 'dz', 'ez', 'fz', 'gz', 'hz', 'iz', 'jz', 'kz', 'lz', 'mz', 'nz', 'oz', 'pz', 'qz', 'rz', 'sz', 'tz', 'uz', 'vz', 'wz', 'xz', 'yz', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 3\n assert candidate(words = ['xyz', 'xz', 'xy', 'x', 'yz', 'y', 'xzpq', 'zpq', 'zq', 'pq', 'q']) == 4\n assert candidate(words = ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'aghij', 'aghi', 'agh', 'ag', 'a', 'agghij', 'agghijr', 'agghijrk', 'agghijrkm', 'agghijrkmp', 'agghijrkmpa', 'agghijrkmpab', 'agghijrkmpabc', 'agghijrkmpabcd']) == 14\n assert candidate(words = ['q', 'qz', 'qzh', 'qzhd', 'qzhdr', 'qzhdre', 'qzhdrec', 'qzhdrecu', 'qzhdrecuj', 'qzhdrecuju', 'qzhdrecujuu', 'qzhdrecujuus']) == 12\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 2\n assert candidate(words = ['a', 'b', 'ab', 'bc', 'abc', 'abcd', 'bcde', 'cde', 'efg', 'fgh', 'efgh', 'efghi', 'efghij']) == 4\n assert candidate(words = ['mnop', 'mno', 'mo', 'mn', 'm', 'on', 'om', 'op', 'pn', 'po', 'np', 'no', 'p', 'o', 'n']) == 4\n assert candidate(words = ['abcd', 'abcde', 'abcdef', 'abcdf', 'abcdg', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk']) == 4\n assert candidate(words = ['abcd', 'abdc', 'abacd', 'abcd', 'abac', 'abcde', 'abcfde', 'abcdefg', 'abcdegh']) == 3\n assert candidate(words = ['abc', 'ab', 'bc', 'abcde', 'abde', 'acde', 'cde', 'a', 'b', 'c', 'd', 'e']) == 3\n assert candidate(words = ['z', 'yz', 'xyz', 'wxyz', 'vwxyz', 'uvwxy', 'uvwx', 'uvx', 'ux', 'x', 'pq', 'pqr', 'pqrs', 'pqrsu', 'pqrstuv', 'pqrstuvw', 'pqrstuvwx', 'pqrstuvwxy', 'pqrstuvwxyz', 'abcdefghijkl', 'abcdefghij', 'abcdefghijk', 'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmnop']) == 5\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\n assert candidate(words = ['k', 'a', 'b', 'ka', 'kb', 'abc', 'bcd', 'abcd', 'bcde', 'abcde', 'fgh', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz']) == 3\n assert candidate(words = ['aaaaab', 'aaab', 'aab', 'ab', 'b', 'ba', 'aba', 'abab', 'ababa', 'ababab', 'abababa', 'abababab', 'ababababa', 'ababababab']) == 10\n assert candidate(words = ['mnop', 'mno', 'mn', 'mnoq', 'mnopqr', 'mnopqrs', 'mnopqrst', 'mnopqrstu', 'mnopqrstuv', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxz']) == 8\n assert candidate(words = ['abcdef', 'abef', 'abcf', 'acdf', 'adef', 'abdf', 'abefg', 'abecf', 'abedf', 'abcef', 'abcdf', 'abdef', 'abcdefg']) == 4\n assert candidate(words = ['zyx', 'zyxa', 'zyxb', 'zyxc', 'zyxd', 'zyxe', 'zyxf', 'zyxg', 'zyxh', 'zyxi', 'zyxj', 'zyxk', 'zyxl', 'zyxm', 'zyxn', 'zyxo', 'zyxp', 'zyxq', 'zyxr', 'zyxs', 'zyxt', 'zyxu', 'zyxv', 'zyxw', 'zyxx', 'zyxy', 'zyxz']) == 2\n assert candidate(words = ['xyz', 'xz', 'xy', 'x', 'wxyz', 'wxz', 'wxy', 'wx', 'w', 'vxyz', 'vxz', 'vxy', 'vx', 'v', 'uvxyz', 'uvxz', 'uvxy', 'uvx', 'uv', 'tuvsxyz', 'tuvsxz', 'tuvsxy', 'tuvsx', 'tuvs', 'tuvxyz', 'tuvxz', 'tuvxy', 'tuvx', 'tuv', 'stuvxyz', 'stuvxz', 'stuvxy', 'stuvx', 'stuv', 'stuvxyz', 'stuvxz', 'stuvxy', 'stuvx', 'stuv']) == 7\n assert candidate(words = ['abcd', 'acbd', 'adcb', 'bacd', 'bcad', 'cabd', 'cbad', 'cdab', 'cdba', 'dcba', 'dcab', 'dbac', 'dbca', 'abcdxyz', 'abcdeyz', 'abcdefz', 'abcdefw']) == 1\n", "comparison": "exact"}, "public_tests": ["[\"a\",\"b\",\"ba\",\"bca\",\"bda\",\"bdca\"]", "[\"xbc\",\"pcxbcf\",\"xb\",\"cxbc\",\"pcxbc\"]", "[\"abcd\",\"dbqca\"]"], "hints": ["Instead of adding a character, try deleting a character to form a chain in reverse.", "For each word in order of length, for each word2 which is word with one character removed, length[word2] = max(length[word2], length[word] + 1)."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().longestStrChain", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:00+00:00", "tests_total": 84, "tests_dropped": 24, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "string", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def longestStrChain(self, words: list[str]) -> int:", "container": "Solution", "callable": "longestStrChain", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1049, "task_id": "last-stone-weight-ii", "difficulty": "Medium", "problem_description": "You are given an array of integers stones where stones[i] is the weight of the i^th stone.\n\nWe are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is:\n\n- If x == y, both stones are destroyed, and\n- If x != y, the stone of weight x is destroyed, and the stone of weight y has new weight y - x.\n\nAt the end of the game, there is at most one stone left.\n\nReturn the smallest possible weight of the left stone. If there are no stones left, return 0.\n\nExample 1:\n\nInput: stones = [2,7,4,1,8,1]\nOutput: 1\nExplanation:\nWe can combine 2 and 4 to get 2, so the array converts to [2,7,1,8,1] then,\nwe can combine 7 and 8 to get 1, so the array converts to [2,1,1,1] then,\nwe can combine 2 and 1 to get 1, so the array converts to [1,1,1] then,\nwe can combine 1 and 1 to get 0, so the array converts to [1], then that's the optimal value.\n\nExample 2:\n\nInput: stones = [31,26,33,21,40]\nOutput: 5\n\nConstraints:\n\n- 1 <= stones.length <= 30\n- 1 <= stones[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [10, 10, 10, 10, 10]) == 10\n assert candidate(stones = [3, 9, 7, 3]) == 2\n assert candidate(stones = [1, 2, 3, 4, 5]) == 1\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 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(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(stones = [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(stones = [100, 1]) == 99\n assert candidate(stones = [31, 26, 33, 21, 40]) == 5\n assert candidate(stones = [15, 10, 5, 10, 10]) == 0\n assert candidate(stones = [1, 100, 100, 1]) == 0\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(stones = [10, 10, 10, 10]) == 0\n assert candidate(stones = [1]) == 1\n assert candidate(stones = [2, 7, 4, 1, 8, 1]) == 1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(stones = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 65\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(stones = [9, 3, 9, 8, 7, 8, 5, 4]) == 1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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(stones = [9, 9, 9, 9, 9, 9, 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(stones = [50, 25, 25, 75, 100, 50]) == 25\n assert candidate(stones = [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]) == 0\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 1\n assert candidate(stones = [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(stones = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == 15\n assert candidate(stones = [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]) == 0\n assert candidate(stones = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n assert candidate(stones = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 0\n assert candidate(stones = [8, 14, 22, 26, 28, 30, 35, 40, 43, 45, 47, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1\n assert candidate(stones = [45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(stones = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 5\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(stones = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 0\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 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(stones = [91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(stones = [8, 3, 5, 7, 11, 9, 14, 16, 2, 6]) == 1\n assert candidate(stones = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 95\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(stones = [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(stones = [8, 8, 8, 8, 8, 8, 8, 8]) == 0\n assert candidate(stones = [50, 50, 50, 50, 50, 50, 50]) == 50\n assert candidate(stones = [12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(stones = [99, 1, 100, 1, 100, 1, 100, 1, 100]) == 95\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 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(stones = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(stones = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(stones = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 0\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(stones = [29, 10, 15, 30, 25, 5]) == 4\n assert candidate(stones = [10, 14, 10, 4, 7, 12]) == 1\n assert candidate(stones = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 1\n assert candidate(stones = [5, 8, 12, 9, 15, 20, 18]) == 1\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 0\n assert candidate(stones = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 0\n assert candidate(stones = [100, 1, 2, 3, 99]) == 1\n assert candidate(stones = [20, 30, 40, 50, 60, 70]) == 10\n assert candidate(stones = [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]) == 72\n assert candidate(stones = [30, 20, 10, 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\n assert candidate(stones = [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\n assert candidate(stones = [100, 1, 99, 2, 98, 3, 97, 4]) == 0\n assert candidate(stones = [29, 22, 24, 27, 30, 31, 28, 25, 21, 20]) == 1\n assert candidate(stones = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 1\n assert candidate(stones = [50, 50, 50, 50, 50, 50, 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(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(stones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 0\n assert candidate(stones = [20, 15, 10, 5, 30, 25, 40, 50]) == 5\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 5\n assert candidate(stones = [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]) == 0\n assert candidate(stones = [100, 50, 25, 12, 6, 3, 1]) == 3\n assert candidate(stones = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(stones = [25, 25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(stones = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == 0\n assert candidate(stones = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 55\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 0\n assert candidate(stones = [50, 49, 51, 48, 52]) == 44\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 100]) == 13\n assert candidate(stones = [8, 14, 17, 31, 56, 13, 29]) == 2\n assert candidate(stones = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 50\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1\n assert candidate(stones = [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]) == 1\n assert candidate(stones = [2, 3, 7, 8, 10, 12, 15, 18, 20, 25]) == 0\n assert candidate(stones = [50, 50, 50, 50, 50, 50, 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(stones = [100, 99, 98, 97, 96, 95]) == 1\n", "comparison": "exact"}, "public_tests": ["[2,7,4,1,8,1]", "[31,26,33,21,40]"], "hints": ["Think of the final answer as a sum of weights with + or - sign symbols infront of each weight. Actually, all sums with 1 of each sign symbol are possible.", "Use dynamic programming: for every possible sum with N stones, those sums +x or -x is possible with N+1 stones, where x is the value of the newest stone. (This overcounts sums that are all positive or all negative, but those don't matter.)"], "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().lastStoneWeightII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:02+00:00", "tests_total": 99, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "dynamic-programming", "knapsack-problem", "0-1-knapsack"]}, "language": "python", "interface": {"raw_signature": "def lastStoneWeightII(self, stones: list[int]) -> int:", "container": "Solution", "callable": "lastStoneWeightII", "parameters": [{"name": "stones", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1051, "task_id": "height-checker", "difficulty": "Easy", "problem_description": "A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is the expected height of the i^th student in line.\n\nYou are given an integer array heights representing the current order that the students are standing in. Each heights[i] is the height of the i^th student in line (0-indexed).\n\nReturn the number of indices where heights[i] != expected[i].\n\nExample 1:\n\nInput: heights = [1,1,4,2,1,3]\nOutput: 3\nExplanation:\nheights: [1,1,4,2,1,3]\nexpected: [1,1,1,2,3,4]\nIndices 2, 4, and 5 do not match.\n\nExample 2:\n\nInput: heights = [5,1,2,3,4]\nOutput: 5\nExplanation:\nheights: [5,1,2,3,4]\nexpected: [1,2,3,4,5]\nAll indices do not match.\n\nExample 3:\n\nInput: heights = [1,2,3,4,5]\nOutput: 0\nExplanation:\nheights: [1,2,3,4,5]\nexpected: [1,2,3,4,5]\nAll indices match.\n\nConstraints:\n\n- 1 <= heights.length <= 100\n- 1 <= heights[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [1]) == 0\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(heights = [1, 2, 1, 2]) == 2\n assert candidate(heights = [3, 3, 3, 3, 3]) == 0\n assert candidate(heights = [1, 2, 3, 4, 5]) == 0\n assert candidate(heights = [1, 100, 1, 100, 1]) == 2\n assert candidate(heights = [3, 2, 1]) == 2\n assert candidate(heights = [1, 2, 3, 5, 4]) == 2\n assert candidate(heights = [5, 1, 2, 3, 4]) == 5\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(heights = [1, 1, 4, 2, 1, 3]) == 3\n assert candidate(heights = [1, 2, 2, 3, 3, 4]) == 0\n assert candidate(heights = [100, 99, 98, 97, 96]) == 4\n assert candidate(heights = [3, 1, 2]) == 3\n assert candidate(heights = [1, 1, 1, 1, 1]) == 0\n assert candidate(heights = [1, 3, 2]) == 2\n assert candidate(heights = [3, 3, 3, 3, 3, 3]) == 0\n assert candidate(heights = [10, 20, 30, 40, 50]) == 0\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(heights = [10, 1, 20, 2, 30, 3]) == 6\n assert candidate(heights = [5, 2, 3, 1, 4]) == 3\n assert candidate(heights = [1, 3, 2, 4, 5]) == 2\n assert candidate(heights = [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]) == 24\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 20\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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 35\n assert candidate(heights = [1, 3, 2, 2, 5, 3, 4]) == 5\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(heights = [30, 20, 10, 50, 40, 15, 5, 25, 35, 45]) == 10\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 0\n assert candidate(heights = [1, 3, 2, 4, 5, 3, 2, 1, 5, 4, 3, 2, 1, 4, 3, 2, 1, 3, 2, 1]) == 16\n assert candidate(heights = [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]) == 0\n assert candidate(heights = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 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(heights = [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, 5, 4, 3, 2, 1, 5, 4]) == 49\n assert candidate(heights = [2, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 6\n assert candidate(heights = [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]) == 0\n assert candidate(heights = [50, 50, 50, 50, 50, 50, 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(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(heights = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == 20\n assert candidate(heights = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 20\n assert candidate(heights = [34, 23, 12, 45, 67, 89, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 13\n assert candidate(heights = [3, 1, 2, 4, 6, 5, 8, 7, 10, 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, 21, 22, 23, 24, 25, 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(heights = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(heights = [3, 2, 1, 4, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 18\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2]) == 16\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 18\n assert candidate(heights = [10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(heights = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5, 100, 6, 100, 7, 100, 8, 100, 9, 100, 10]) == 15\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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(heights = [50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53]) == 0\n assert candidate(heights = [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\n assert candidate(heights = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 18\n assert candidate(heights = [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(heights = [3, 3, 2, 1, 3, 2, 3, 1, 3]) == 5\n assert candidate(heights = [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, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 62\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 1, 9, 10]) == 8\n assert candidate(heights = [2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(heights = [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]) == 30\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == 10\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(heights = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(heights = [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]) == 16\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 18\n assert candidate(heights = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(heights = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 20\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(heights = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 18\n assert candidate(heights = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 0\n assert candidate(heights = [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]) == 0\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 18\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n assert candidate(heights = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 17\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(heights = [30, 10, 20, 40, 60, 50, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 17\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 18\n assert candidate(heights = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == 0\n assert candidate(heights = [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]) == 40\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(heights = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 16\n assert candidate(heights = [5, 3, 4, 1, 2, 3, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 17\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]) == 0\n assert candidate(heights = [34, 56, 23, 89, 12, 33, 21, 67, 45, 90]) == 7\n assert candidate(heights = [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]) == 24\n assert candidate(heights = [1, 3, 2, 2, 5, 4, 7, 6, 8, 9]) == 6\n assert candidate(heights = [3, 3, 2, 1, 1, 1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4]) == 16\n assert candidate(heights = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 12\n assert candidate(heights = [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]) == 0\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]) == 0\n assert candidate(heights = [7, 8, 9, 10, 11, 5, 6, 4, 3, 2, 1]) == 11\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 20\n assert candidate(heights = [2, 1, 2, 1, 1, 2, 2, 1]) == 4\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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(heights = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2]) == 15\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 26\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(heights = [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, 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]) == 38\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(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]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,1,4,2,1,3]", "[5,1,2,3,4]", "[1,2,3,4,5]"], "hints": ["Build the correct order of heights by sorting another array, then compare the two arrays."], "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().heightChecker", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:04+00:00", "tests_total": 115, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "sorting", "counting-sort", "bubble-sort"]}, "language": "python", "interface": {"raw_signature": "def heightChecker(self, heights: list[int]) -> int:", "container": "Solution", "callable": "heightChecker", "parameters": [{"name": "heights", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1052, "task_id": "grumpy-bookstore-owner", "difficulty": "Medium", "problem_description": "There is a bookstore owner that has a store open for n minutes. You are given an integer array customers of length n where customers[i] is the number of the customers that enter the store at the start of the i^th minute and all those customers leave after the end of that minute.\n\nDuring certain minutes, the bookstore owner is grumpy. You are given a binary array grumpy where grumpy[i] is 1 if the bookstore owner is grumpy during the i^th minute, and is 0 otherwise.\n\nWhen the bookstore owner is grumpy, the customers entering during that minute are not satisfied. Otherwise, they are satisfied.\n\nThe bookstore owner knows a secret technique to remain not grumpy for minutes consecutive minutes, but this technique can only be used once.\n\nReturn the maximum number of customers that can be satisfied throughout the day.\n\nExample 1:\n\nInput: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3\nOutput: 16\nExplanation:\nThe bookstore owner keeps themselves not grumpy for the last 3 minutes.\nThe maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.\n\nExample 2:\n\nInput: customers = [1], grumpy = [0], minutes = 1\nOutput: 1\n\nConstraints:\n\n- n == customers.length == grumpy.length\n- 1 <= minutes <= n <= 2 * 10^4\n- 0 <= customers[i] <= 1000\n- grumpy[i] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = [3, 1, 4, 2, 2],grumpy = [0, 0, 1, 1, 1],minutes = 1) == 8\n assert candidate(customers = [5, 5, 5, 5, 5],grumpy = [0, 0, 0, 0, 0],minutes = 1) == 25\n assert candidate(customers = [2, 3, 4, 5],grumpy = [1, 0, 1, 1],minutes = 2) == 12\n assert candidate(customers = [2, 3, 4, 5, 6],grumpy = [1, 0, 1, 0, 1],minutes = 2) == 14\n assert candidate(customers = [2, 3, 4, 5],grumpy = [1, 0, 1, 0],minutes = 2) == 12\n assert candidate(customers = [10, 20, 30, 40, 50],grumpy = [0, 1, 0, 1, 0],minutes = 1) == 130\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 5) == 25\n assert candidate(customers = [2, 4, 2, 5, 0],grumpy = [0, 1, 0, 1, 1],minutes = 2) == 9\n assert candidate(customers = [1, 2, 3, 4, 5],grumpy = [1, 0, 1, 0, 1],minutes = 4) == 14\n assert candidate(customers = [5, 5, 5, 5, 5, 5],grumpy = [1, 1, 1, 1, 1, 1],minutes = 2) == 10\n assert candidate(customers = [10, 1, 2, 3, 4, 5],grumpy = [1, 0, 1, 0, 1, 0],minutes = 2) == 19\n assert candidate(customers = [1, 0, 1, 2, 1, 1, 7, 5],grumpy = [0, 1, 0, 1, 0, 1, 0, 1],minutes = 3) == 16\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 5) == 50\n assert candidate(customers = [1],grumpy = [0],minutes = 1) == 1\n assert candidate(customers = [2, 3, 4, 5],grumpy = [1, 1, 1, 1],minutes = 2) == 9\n assert candidate(customers = [10, 20, 30, 40, 50],grumpy = [0, 1, 0, 1, 0],minutes = 4) == 150\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],grumpy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],minutes = 5) == 55\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 1) == 10\n assert candidate(customers = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],grumpy = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],minutes = 4) == 8\n assert candidate(customers = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 7) == 1140\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],grumpy = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],minutes = 3) == 60\n assert candidate(customers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 5) == 35\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 10) == 550\n assert candidate(customers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],grumpy = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],minutes = 5) == 45\n assert candidate(customers = [90, 0, 40, 0, 20, 0, 70, 0, 50, 0, 10, 0, 30, 0, 60, 0, 80, 0, 100, 0],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 5) == 240\n assert candidate(customers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],grumpy = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1],minutes = 5) == 4500\n assert candidate(customers = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0, 111, 222, 333, 444, 555],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],minutes = 7) == 6438\n assert candidate(customers = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 4) == 500\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 10) == 100\n assert candidate(customers = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],minutes = 7) == 828\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],grumpy = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],minutes = 6) == 770\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],grumpy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],minutes = 10) == 20\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 7) == 110\n assert candidate(customers = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 3) == 4300\n assert candidate(customers = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1],grumpy = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],minutes = 5) == 25\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 7) == 108\n assert candidate(customers = [30, 20, 10, 0, 5, 15, 25, 35, 45, 55],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 200\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],grumpy = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],minutes = 5) == 105\n assert candidate(customers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],grumpy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],minutes = 10) == 45\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 2) == 19\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 5) == 490\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 9) == 1850\n assert candidate(customers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],grumpy = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],minutes = 8) == 354\n assert candidate(customers = [50, 25, 75, 100, 50, 25, 75, 100, 50, 25, 75, 100],grumpy = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],minutes = 4) == 600\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],grumpy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 7) == 174\n assert candidate(customers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 6) == 189\n assert candidate(customers = [5, 3, 8, 2, 10, 15, 7, 1, 4, 6],grumpy = [0, 1, 1, 0, 1, 0, 1, 1, 0, 1],minutes = 4) == 47\n assert candidate(customers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],grumpy = [0, 0, 0, 1, 1, 1, 1, 1, 1, 0],minutes = 3) == 4000\n assert candidate(customers = [3, 5, 0, 4, 7, 9, 6, 2, 5, 8],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 4) == 34\n assert candidate(customers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],grumpy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],minutes = 3) == 45\n assert candidate(customers = [200, 150, 100, 50, 0, 50, 100, 150, 200],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 3) == 700\n assert candidate(customers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 5) == 10\n assert candidate(customers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 3) == 79\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 3) == 60\n assert candidate(customers = [5, 1, 3, 4, 6, 2, 7, 8, 9, 10, 11, 12, 13, 14, 15],grumpy = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1],minutes = 6) == 99\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],grumpy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],minutes = 5) == 20\n assert candidate(customers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 5100\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 10) == 75\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 2) == 390\n assert candidate(customers = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100, 110, 120],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 4) == 610\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 10) == 75\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 130\n assert candidate(customers = [10, 0, 5, 2, 3, 8, 6, 4, 7, 9],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 5) == 52\n assert candidate(customers = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 6) == 197\n assert candidate(customers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 6) == 90\n assert candidate(customers = [100, 200, 0, 300, 400, 0, 500, 0, 600, 700],grumpy = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0],minutes = 5) == 2400\n assert candidate(customers = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 3) == 15\n assert candidate(customers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 9) == 925\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 2) == 0\n assert candidate(customers = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 3) == 11\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 3) == 90\n assert candidate(customers = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 10) == 1\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 2) == 19\n assert candidate(customers = [200, 300, 400, 500, 600, 700, 800, 900, 1000],grumpy = [1, 1, 0, 0, 1, 1, 0, 0, 1],minutes = 4) == 4300\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 4) == 90\n assert candidate(customers = [9, 8, 7, 6, 5, 4, 3, 2, 1],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 3) == 36\n assert candidate(customers = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 4) == 140\n assert candidate(customers = [23, 15, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 7) == 264\n assert candidate(customers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 5100\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],grumpy = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],minutes = 6) == 154\n assert candidate(customers = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],minutes = 10) == 197\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],grumpy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],minutes = 10) == 1000\n assert candidate(customers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 5100\n assert candidate(customers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 255\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],grumpy = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],minutes = 5) == 510\n assert candidate(customers = [5, 1, 3, 0, 2, 7, 8, 9, 10, 1],grumpy = [1, 1, 0, 0, 1, 1, 1, 0, 1, 0],minutes = 4) == 38\n", "comparison": "exact"}, "public_tests": ["[1,0,1,2,1,1,7,5]\n[0,1,0,1,0,1,0,1]\n3", "[1]\n[0]\n1"], "hints": ["Say the store owner uses their power in minute 1 to X and we have some answer A. If they instead use their power from minute 2 to X+1, we only have to use data from minutes 1, 2, X and X+1 to update our answer A."], "metadata": {"canonical_parameter_names": ["customers", "grumpy", "minutes"], "leetcode_dataset_entry_point": "Solution().maxSatisfied", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:06+00:00", "tests_total": 89, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maxSatisfied(self, customers: list[int], grumpy: list[int], minutes: int) -> int:", "container": "Solution", "callable": "maxSatisfied", "parameters": [{"name": "customers", "type": "list[int]"}, {"name": "grumpy", "type": "list[int]"}, {"name": "minutes", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1053, "task_id": "previous-permutation-with-one-swap", "difficulty": "Medium", "problem_description": "Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one swap. If it cannot be done, then return the same array.\n\nNote that a swap exchanges the positions of two numbers arr[i] and arr[j]\n\nExample 1:\n\nInput: arr = [3,2,1]\nOutput: [3,1,2]\nExplanation: Swapping 2 and 1.\n\nExample 2:\n\nInput: arr = [1,1,5]\nOutput: [1,1,5]\nExplanation: This is already the smallest permutation.\n\nExample 3:\n\nInput: arr = [1,9,4,6,7]\nOutput: [1,7,4,6,9]\nExplanation: Swapping 9 and 7.\n\nConstraints:\n\n- 1 <= arr.length <= 10^4\n- 1 <= arr[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5]) == [10, 9, 8, 7, 5, 6]\n assert candidate(arr = [3, 2, 1]) == [3, 1, 2]\n assert candidate(arr = [5, 1, 1, 2, 3]) == [3, 1, 1, 2, 5]\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5, 4, 3, 1, 2]\n assert candidate(arr = [4, 5, 1, 2, 3]) == [4, 3, 1, 2, 5]\n assert candidate(arr = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n assert candidate(arr = [10, 9, 8, 7, 6]) == [10, 9, 8, 6, 7]\n assert candidate(arr = [5, 1, 1]) == [1, 5, 1]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [1, 9, 4, 6, 7]) == [1, 7, 4, 6, 9]\n assert candidate(arr = [2, 1, 3, 1, 3]) == [2, 1, 1, 3, 3]\n assert candidate(arr = [1, 1, 5]) == [1, 1, 5]\n assert candidate(arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == [1, 10, 9, 8, 7, 6, 5, 4, 2, 3]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(arr = [1, 2, 1]) == [1, 1, 2]\n assert candidate(arr = [1, 3, 2]) == [1, 2, 3]\n assert candidate(arr = [3, 1, 1, 3]) == [1, 3, 1, 3]\n assert candidate(arr = [5, 3, 4, 2, 1]) == [5, 3, 4, 1, 2]\n assert candidate(arr = [10, 5, 9, 2, 6]) == [10, 5, 6, 2, 9]\n assert candidate(arr = [2, 3, 1]) == [2, 1, 3]\n assert candidate(arr = [5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == [5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 1, 2]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 1, 2, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [3, 1, 4, 1, 5, 9, 2, 6, 3, 5, 5]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1]) == [9, 8, 7, 6, 5, 4, 3, 1, 2, 1, 1]\n assert candidate(arr = [1, 2, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [1, 9, 9, 9, 9, 9, 9, 8, 7, 6, 5]) == [1, 9, 9, 9, 9, 9, 9, 8, 7, 5, 6]\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 6, 4, 2]) == [1, 3, 2, 4, 3, 5, 6, 2, 4]\n assert candidate(arr = [5, 3, 4, 4, 5, 4, 3]) == [5, 3, 4, 4, 5, 3, 4]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [9, 8, 7, 6, 5, 4, 3, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(arr = [5, 4, 4, 3, 2, 1, 1, 1, 1]) == [5, 4, 4, 3, 1, 2, 1, 1, 1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1]) == [10000, 1, 10000, 1, 10000, 1, 10000, 1, 1, 10000]\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 4, 3, 1, 2]\n assert candidate(arr = [1, 2, 3, 3, 2, 1]) == [1, 2, 3, 3, 1, 2]\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]\n assert candidate(arr = [1, 2, 3, 5, 4]) == [1, 2, 3, 4, 5]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [1, 3, 5, 7, 9, 8, 6, 4, 2]) == [1, 3, 5, 7, 9, 8, 6, 2, 4]\n assert candidate(arr = [2, 3, 5, 4, 6, 1, 8, 7, 9]) == [2, 3, 5, 4, 6, 1, 7, 8, 9]\n assert candidate(arr = [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, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 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, 1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2, 1]\n assert candidate(arr = [9, 9, 8, 8, 7, 7, 6, 6]) == [9, 9, 8, 8, 7, 6, 7, 6]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 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, 1, 2]\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 90, 91]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == [1, 2, 3, 4, 5, 10, 9, 8, 6, 7]\n assert candidate(arr = [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, 1, 2]\n assert candidate(arr = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == [5, 6, 7, 8, 4, 1, 2, 3, 9]\n assert candidate(arr = [1, 3, 2, 4, 5, 3, 2, 1, 4, 5, 6, 7]) == [1, 3, 2, 4, 5, 3, 1, 2, 4, 5, 6, 7]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10]\n assert candidate(arr = [9, 7, 7, 7, 8, 7, 7, 7, 9]) == [9, 7, 7, 7, 7, 8, 7, 7, 9]\n assert candidate(arr = [3, 5, 4, 5, 3, 2, 4, 3, 2, 1]) == [3, 5, 4, 5, 3, 2, 4, 3, 1, 2]\n assert candidate(arr = [8, 9, 7, 9, 7, 8, 9, 7, 9, 7]) == [8, 9, 7, 9, 7, 8, 9, 7, 7, 9]\n assert candidate(arr = [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]\n assert candidate(arr = [100, 200, 300, 400, 500, 450]) == [100, 200, 300, 400, 450, 500]\n assert candidate(arr = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == [1, 10000, 2, 9999, 3, 9998, 4, 9996, 5, 9997]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5]\n assert candidate(arr = [5, 3, 6, 7, 4, 8, 9, 1, 2]) == [5, 3, 6, 7, 4, 8, 2, 1, 9]\n assert candidate(arr = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3]\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == [1, 2, 3, 4, 3, 1, 2]\n assert candidate(arr = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == [3, 3, 3, 3, 2, 2, 2, 1, 2, 1, 1, 1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9]\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3]) == [3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1]) == [5, 4, 3, 1, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9]) == [9, 8, 7, 6, 7, 8, 9, 8, 6, 7, 7, 8, 9]\n assert candidate(arr = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 20]\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == [1000, 999, 998, 997, 996, 995, 994, 993, 991, 992]\n assert candidate(arr = [5, 4, 3, 2, 1, 1]) == [5, 4, 3, 1, 2, 1]\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1]) == [5, 6, 7, 8, 9, 1, 10]\n assert candidate(arr = [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, 1, 10]\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [5, 6, 7, 8, 9, 9, 1, 2, 3, 4, 5, 6, 7, 8, 10]\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]\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12]) == [2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 11, 12]\n assert candidate(arr = [1, 2, 2, 3, 3, 2, 2, 1]) == [1, 2, 2, 3, 3, 2, 1, 2]\n assert candidate(arr = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == [3, 3, 3, 3, 3, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [100, 90, 80, 70, 60, 50, 40, 30, 10, 20]\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6]\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 1, 2, 3, 4, 10]\n assert candidate(arr = [1, 9, 4, 6, 7, 8, 5, 4, 3, 2, 1]) == [1, 9, 4, 6, 7, 8, 5, 4, 3, 1, 2]\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]\n assert candidate(arr = [8, 8, 8, 8, 7, 8, 8, 8, 8]) == [8, 8, 8, 7, 8, 8, 8, 8, 8]\n assert candidate(arr = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == [10, 9, 10, 9, 10, 9, 10, 9, 9, 10]\n assert candidate(arr = [1, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == [1, 3, 3, 3, 3, 3, 3, 3, 2, 3]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [9, 8, 7, 6, 5, 4, 3, 1, 2, 10]\n assert candidate(arr = [10, 20, 30, 25, 15, 5]) == [10, 20, 30, 25, 5, 15]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == [9, 8, 7, 6, 5, 4, 3, 1, 2, 10, 11, 12]\n assert candidate(arr = [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, 1, 2]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 1, 2, 1]\n assert candidate(arr = [1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 5]\n assert candidate(arr = [2, 1, 3, 4, 3, 2, 1]) == [2, 1, 3, 4, 3, 1, 2]\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, 6, 7, 8, 9, 9, 1, 2, 3, 4, 5, 6, 7, 8, 10, 10]\n assert candidate(arr = [3, 3, 3, 3, 2, 2, 2, 1, 1]) == [3, 3, 3, 3, 2, 2, 1, 2, 1]\n assert candidate(arr = [1, 3, 5, 4, 3, 2, 1]) == [1, 3, 5, 4, 3, 1, 2]\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9]\n assert candidate(arr = [1000, 999, 998, 997, 996, 995]) == [1000, 999, 998, 997, 995, 996]\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [1, 2, 2, 3, 4, 5, 5, 4, 3, 1, 2]\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 10]\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1]) == [5, 4, 3, 1, 2, 1, 1, 1]\n assert candidate(arr = [10, 9, 8, 7, 6, 7, 8, 9, 10]) == [10, 9, 8, 6, 7, 7, 8, 9, 10]\n assert candidate(arr = [1, 3, 2, 4, 3, 2, 1]) == [1, 3, 2, 4, 3, 1, 2]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\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, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\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]\n assert candidate(arr = [10, 9, 8, 7, 8, 9, 10]) == [10, 9, 7, 8, 8, 9, 10]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1, 3, 5, 4, 2]) == [1, 3, 5, 2, 4]\n assert candidate(arr = [10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5]) == [10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 5, 6, 5, 5]\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 2]) == [3, 3, 3, 3, 3, 2, 3]\n assert candidate(arr = [1, 1, 2, 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]\n assert candidate(arr = [10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2]\n assert candidate(arr = [3, 3, 2, 1, 3, 3]) == [3, 3, 1, 2, 3, 3]\n assert candidate(arr = [5, 1, 1, 1, 1, 1]) == [1, 5, 1, 1, 1, 1]\n assert candidate(arr = [5, 4, 5, 4, 5, 4, 5, 4]) == [5, 4, 5, 4, 5, 4, 4, 5]\n assert candidate(arr = [4, 5, 3, 4, 5, 6, 7]) == [4, 4, 3, 5, 5, 6, 7]\n assert candidate(arr = [1, 3, 2, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(arr = [3, 3, 2, 1, 4, 4, 5]) == [3, 3, 1, 2, 4, 4, 5]\n assert candidate(arr = [1, 2, 3, 3, 3, 2, 1, 1, 1]) == [1, 2, 3, 3, 3, 1, 2, 1, 1]\n", "comparison": "exact"}, "public_tests": ["[3,2,1]", "[1,1,5]", "[1,9,4,6,7]"], "hints": ["You need to swap two values, one larger than the other. Where is the larger one located?"], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().prevPermOpt1", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:08+00:00", "tests_total": 140, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def prevPermOpt1(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "prevPermOpt1", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1054, "task_id": "distant-barcodes", "difficulty": "Medium", "problem_description": "In a warehouse, there is a row of barcodes, where the i^th barcode is barcodes[i].\n\nRearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.\n\nExample 1:\n\nInput: barcodes = [1,1,1,2,2,2]\nOutput: [2,1,2,1,2,1]\n\nExample 2:\n\nInput: barcodes = [1,1,1,1,2,2,3,3]\nOutput: [1,3,1,3,1,2,1,2]\n\nConstraints:\n\n- 1 <= barcodes.length <= 10000\n- 1 <= barcodes[i] <= 10000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(barcodes = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5]) == [1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 2, 5, 2]\n assert candidate(barcodes = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 3, 1, 4, 2, 4, 2, 5, 3, 5]\n assert candidate(barcodes = [2, 2, 1, 1, 3, 3, 4, 4]) == [1, 3, 1, 3, 2, 4, 2, 4]\n assert candidate(barcodes = [1, 2, 2, 1, 2, 1]) == [1, 2, 1, 2, 1, 2]\n assert candidate(barcodes = [4, 1, 2, 2, 2, 3, 3, 3, 3]) == [3, 2, 3, 2, 3, 1, 3, 4, 2]\n assert candidate(barcodes = [5, 6, 7, 8, 8, 8, 8]) == [8, 5, 8, 6, 8, 7, 8]\n assert candidate(barcodes = [5, 5, 5, 6, 6, 7, 7, 7, 7]) == [7, 5, 7, 5, 7, 6, 7, 6, 5]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [1, 5, 1, 5, 1, 5, 1, 5, 1, 5]\n assert candidate(barcodes = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3]) == [1, 2, 1, 2, 1, 2, 1, 3, 1, 3]\n assert candidate(barcodes = [1, 1, 1, 1, 2, 2, 3, 3]) == [1, 2, 1, 2, 1, 3, 1, 3]\n assert candidate(barcodes = [2, 2, 3, 3, 3, 3, 4, 4, 4]) == [3, 4, 3, 4, 3, 2, 3, 2, 4]\n assert candidate(barcodes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(barcodes = [1, 2, 3, 4]) == [1, 3, 2, 4]\n assert candidate(barcodes = [1, 1, 1, 2, 2, 2]) == [1, 2, 1, 2, 1, 2]\n assert candidate(barcodes = [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, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 43, 43, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == [32, 37, 32, 37, 32, 37, 32, 38, 32, 38, 32, 38, 32, 39, 33, 39, 33, 39, 33, 40, 33, 40, 33, 40, 33, 42, 34, 42, 34, 42, 34, 44, 34, 44, 41, 44, 41, 46, 41, 46, 41, 46, 45, 43, 45, 43, 45, 47, 45, 47, 35, 48, 35, 48, 35, 49, 36, 49, 36, 50, 36, 50]\n assert candidate(barcodes = [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]) == [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 4, 8, 4, 8, 4, 8, 4, 8, 4, 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 5, 9, 5, 9, 5, 9, 5, 9, 5, 9]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [5, 7, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 7, 6, 7, 6, 7, 6, 7, 6]\n assert candidate(barcodes = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 8888, 8888, 8888, 8888, 8888, 8888, 8888, 8888, 8888, 8888, 7777, 7777, 7777, 7777, 7777, 7777, 7777, 7777, 7777, 7777]) == [7777, 8888, 7777, 8888, 7777, 8888, 7777, 8888, 7777, 8888, 7777, 9999, 7777, 9999, 7777, 9999, 7777, 9999, 7777, 9999, 8888, 9999, 8888, 9999, 8888, 9999, 8888, 9999, 8888, 9999]\n assert candidate(barcodes = [100, 100, 100, 200, 200, 200, 300, 300, 300, 400, 400, 400, 500, 500, 500, 600, 600, 600, 700, 700, 700, 800, 800, 800, 900, 900, 900, 1000, 1000, 1000]) == [100, 600, 100, 600, 100, 600, 200, 700, 200, 700, 200, 700, 300, 800, 300, 800, 300, 800, 400, 900, 400, 900, 400, 900, 500, 1000, 500, 1000, 500, 1000]\n assert candidate(barcodes = [1, 1, 1, 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]) == [3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 2, 3, 2, 3, 2, 3, 2, 4, 1, 4, 1, 4, 1, 4]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 6, 7, 6, 7, 6]\n assert candidate(barcodes = [1, 1, 1, 1, 1, 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, 4, 5, 5, 5, 5]) == [4, 3, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 5, 3, 5, 3, 5]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [5, 8, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9]) == [5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 5, 8, 6, 8, 6, 9]\n assert candidate(barcodes = [10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 50, 50]) == [10, 20, 10, 20, 10, 30, 10, 30, 10, 30, 10, 30, 10, 40, 20, 40, 20, 40, 20, 50, 20, 50]\n assert candidate(barcodes = [10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 13, 13]) == [10, 11, 10, 11, 10, 11, 10, 11, 10, 12, 10, 12, 10, 12, 11, 13, 11, 13]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [5, 6, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 6, 8, 6, 8, 6, 8, 6, 8, 6, 8]\n assert candidate(barcodes = [1, 1, 2, 2, 3, 3, 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, 13, 1, 14, 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, 12, 24, 12, 25, 13, 25]\n assert candidate(barcodes = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 6, 7, 6, 7, 6, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 4, 7, 4, 7, 4, 7, 4, 7, 3, 6, 3, 6, 3, 6, 2, 6, 2, 6, 1, 6]\n assert candidate(barcodes = [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, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4]\n assert candidate(barcodes = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == [9980, 9990, 9981, 9991, 9982, 9992, 9983, 9993, 9984, 9994, 9985, 9995, 9986, 9996, 9987, 9997, 9988, 9998, 9989, 9999]\n assert candidate(barcodes = [9999, 9999, 9999, 9999, 9999, 9998, 9998, 9998, 9998, 9998, 9997, 9997, 9997, 9997, 9997, 9996, 9996, 9996, 9996, 9996]) == [9996, 9998, 9996, 9998, 9996, 9998, 9996, 9998, 9996, 9998, 9997, 9999, 9997, 9999, 9997, 9999, 9997, 9999, 9997, 9999]\n assert candidate(barcodes = [71, 71, 71, 71, 71, 71, 71, 71, 71, 72, 72, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73, 73, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76, 77, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 79, 79, 79, 79, 80, 80, 80, 80, 81, 81, 81, 82, 82, 82, 82, 83, 83, 83, 83, 84, 84, 85, 85, 86, 86, 86, 87, 87, 87, 87, 88, 88, 89, 89, 90, 90, 90, 91, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 94, 95, 95, 95, 96, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 100, 100, 100, 100]) == [71, 80, 71, 80, 71, 82, 71, 82, 71, 82, 71, 82, 71, 83, 71, 83, 71, 83, 72, 83, 72, 87, 72, 87, 72, 87, 72, 87, 72, 91, 72, 91, 72, 91, 72, 91, 73, 94, 73, 94, 73, 94, 73, 94, 73, 97, 73, 97, 73, 97, 74, 97, 74, 98, 74, 98, 74, 98, 74, 98, 74, 99, 75, 99, 75, 99, 75, 99, 75, 100, 75, 100, 75, 100, 78, 100, 78, 81, 78, 81, 78, 81, 78, 86, 78, 86, 76, 86, 76, 90, 76, 90, 76, 90, 76, 92, 77, 92, 77, 92, 77, 93, 77, 93, 77, 93, 96, 95, 96, 95, 96, 95, 96, 84, 96, 84, 79, 85, 79, 85, 79, 88, 79, 88, 80, 89, 80, 89]\n assert candidate(barcodes = [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]) == [1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 6, 2, 6, 2, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 4, 7, 4, 7, 4]\n assert candidate(barcodes = [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, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 5, 2, 5, 2, 5, 2, 5, 3, 5, 3, 5, 3, 5, 3]\n assert candidate(barcodes = [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, 6, 1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [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, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13]) == [10, 11, 10, 12, 10, 12, 10, 12, 10, 12, 10, 12, 10, 12, 11, 12, 11, 13, 11, 13, 11, 13, 11, 13, 11, 13]\n assert candidate(barcodes = [11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13]) == [12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 13, 12, 13, 12, 13, 12, 13, 12]\n assert candidate(barcodes = [10, 20, 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, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 10]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [5, 6, 5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 8, 6, 8, 6, 8, 6, 8, 6, 8, 6]\n assert candidate(barcodes = [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]) == [5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 4, 5, 4, 2, 4, 2, 4, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(barcodes = [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, 5, 1, 5, 1, 6, 1, 6, 2, 6, 2, 6, 2, 7, 2, 7, 3, 7, 3, 7, 3, 8, 3, 8, 4, 8, 4, 8, 4, 9, 4, 9, 5, 9, 5, 9]\n assert candidate(barcodes = [9999, 9999, 9999, 9999, 9999, 9998, 9998, 9998, 9998, 9998, 9997, 9997, 9997, 9997, 9997]) == [9997, 9998, 9997, 9998, 9997, 9999, 9997, 9999, 9997, 9999, 9998, 9999, 9998, 9999, 9998]\n assert candidate(barcodes = [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]) == [7, 5, 7, 5, 7, 5, 7, 5, 7, 4, 7, 4, 7, 4, 6, 4, 6, 3, 6, 3, 6, 3, 6, 2, 6, 2, 5, 1]\n assert candidate(barcodes = [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]) == [23, 22, 23, 22, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 1]\n assert candidate(barcodes = [1, 1, 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, 6, 6, 6, 6, 6, 6, 6, 6]) == [4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 2, 5, 2, 5, 2, 5, 2, 6, 1, 6, 1, 6]\n assert candidate(barcodes = [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, 10, 10, 10, 10, 10, 10]) == [1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 1, 6, 1, 6, 1, 7, 3, 7, 3, 7, 3, 7, 4, 7, 4, 7, 4, 7, 5, 7, 5, 7, 5]\n assert candidate(barcodes = [17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19]) == [18, 17, 18, 17, 18, 17, 18, 17, 18, 17, 18, 17, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 17, 19, 17, 19, 17, 19]\n assert candidate(barcodes = [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, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 6, 7, 6, 7, 4, 7, 4, 7, 4, 7, 4, 7, 4, 7, 4, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 2, 5, 2, 6, 2, 6, 2, 6, 1, 6, 1, 6, 1]\n assert candidate(barcodes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 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]) == [10, 30, 10, 30, 10, 30, 10, 30, 10, 30, 10, 30, 10, 30, 10, 30, 10, 30, 10, 30, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40]\n assert candidate(barcodes = [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]) == [1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6]\n assert candidate(barcodes = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == [1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 2, 4, 2, 4, 2, 4]\n assert candidate(barcodes = [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, 10, 10, 10]) == [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 9, 8, 9, 8, 9, 8]\n assert candidate(barcodes = [100, 200, 100, 300, 100, 400, 100, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == [100, 300, 100, 300, 100, 300, 100, 400, 100, 400, 100, 400, 100, 400, 200, 500, 200, 500, 200, 500, 200, 500, 300]\n assert candidate(barcodes = [9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 14, 14]) == [9, 10, 9, 11, 9, 11, 9, 11, 9, 11, 9, 12, 9, 12, 10, 12, 10, 13, 10, 13, 10, 14, 10, 14]\n assert candidate(barcodes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6]) == [7, 8, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 8, 9, 8, 6, 8, 6, 8, 6, 8, 6, 8, 6, 8, 6, 8]\n assert candidate(barcodes = [13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16]) == [16, 14, 16, 14, 16, 13, 16, 13, 16, 13, 16, 13, 16, 13, 16, 13, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15]\n assert candidate(barcodes = [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]) == [7, 6, 7, 6, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 8, 4, 8, 4, 8, 4, 8, 4, 8, 3, 8, 3, 8, 3, 6, 2, 6, 2, 6, 1, 6]\n assert candidate(barcodes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12]) == [9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 11, 9, 11, 9, 11, 9, 11, 10, 12, 10, 12, 10, 12, 10]\n assert candidate(barcodes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == [10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11]\n assert candidate(barcodes = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 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(barcodes = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4]\n assert candidate(barcodes = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000]) == [2000, 2000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000]\n assert candidate(barcodes = [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, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]\n assert candidate(barcodes = [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, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 19, 19, 20, 20, 20]) == [16, 15, 16, 15, 16, 15, 16, 15, 16, 17, 16, 17, 16, 17, 16, 17, 16, 20, 16, 20, 15, 20, 15, 18, 15, 18, 15, 19, 15, 19]\n assert candidate(barcodes = [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]) == [7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10]\n assert candidate(barcodes = [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]) == [1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(barcodes = [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]) == [1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 5, 2, 5, 2, 5, 2, 5, 3, 5, 3, 5, 3, 5, 3]\n assert candidate(barcodes = [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]) == [2, 6, 2, 7, 2, 7, 2, 7, 3, 7, 3, 8, 3, 8, 3, 8, 4, 8, 4, 9, 4, 9, 4, 9, 5, 9, 5, 10, 5, 10, 5, 10, 6, 10, 6, 1, 6, 1]\n assert candidate(barcodes = [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, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 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(barcodes = [9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12]) == [10, 12, 10, 12, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11]\n assert candidate(barcodes = [10000, 10000, 9999, 9999, 9998, 9998, 9997, 9997, 9996, 9996, 9995, 9995, 9994, 9994, 9993, 9993, 9992, 9992, 9991, 9991, 9990, 9990, 9989, 9989, 9988, 9988, 9987, 9987, 9986, 9986]) == [9986, 9993, 9986, 9994, 9987, 9994, 9987, 9995, 9988, 9995, 9988, 9996, 9989, 9996, 9989, 9997, 9990, 9997, 9990, 9998, 9991, 9998, 9991, 9999, 9992, 9999, 9992, 10000, 9993, 10000]\n assert candidate(barcodes = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 1, 5, 1, 3, 1, 3, 1, 3, 1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 4]\n assert candidate(barcodes = [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]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5]\n assert candidate(barcodes = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 102, 102]) == [100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 101, 100, 102, 100, 102, 100, 102, 100, 102, 101, 102, 101, 102, 101, 102]\n assert candidate(barcodes = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000]) == [3000, 1000, 3000, 1000, 3000, 1000, 3000, 1000, 3000, 1000, 3000, 1000, 3000, 1000, 3000, 1000, 3000, 2000, 3000, 2000, 3000, 2000, 3000, 2000, 3000, 2000, 3000, 2000, 3000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000]\n assert candidate(barcodes = [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]) == [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7]\n assert candidate(barcodes = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300]) == [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 300, 100, 300, 100, 300, 100, 300, 100, 300, 200, 300, 200, 300, 200, 300, 200]\n assert candidate(barcodes = [21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31, 31]) == [21, 30, 21, 30, 21, 30, 21, 30, 21, 24, 21, 24, 22, 24, 22, 25, 22, 25, 22, 25, 22, 29, 22, 29, 23, 29, 23, 27, 23, 27, 23, 28, 26, 28, 26, 31, 26, 31, 26]\n assert candidate(barcodes = [20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22]) == [20, 21, 20, 21, 20, 21, 20, 21, 20, 21, 20, 21, 20, 22, 20, 22, 20, 22, 21, 22, 21, 22]\n assert candidate(barcodes = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 1, 2]\n assert candidate(barcodes = [51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 60, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 65, 66, 66, 66, 66, 67, 67, 67, 68, 68, 68, 69, 69, 70, 70]) == [51, 56, 51, 56, 51, 56, 51, 56, 51, 58, 51, 58, 51, 58, 51, 58, 52, 66, 52, 66, 52, 66, 52, 66, 52, 59, 52, 59, 52, 59, 52, 60, 54, 60, 54, 60, 54, 65, 54, 65, 54, 65, 54, 67, 55, 67, 55, 67, 55, 68, 55, 68, 55, 68, 55, 61, 57, 61, 57, 62, 57, 62, 57, 63, 57, 63, 57, 64, 53, 64, 53, 69, 53, 69, 53, 70, 53, 70, 56]\n assert candidate(barcodes = [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]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5]\n assert candidate(barcodes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [5, 6, 5, 6, 5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6]\n assert candidate(barcodes = [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, 6, 1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10, 5, 10]\n assert candidate(barcodes = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16]) == [14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 16, 14, 16, 15, 16, 15]\n assert candidate(barcodes = [10, 10, 10, 20, 20, 20, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50]) == [50, 40, 50, 30, 50, 30, 50, 30, 50, 30, 50, 30, 50, 10, 40, 10, 40, 10, 40, 20, 40, 20, 40, 20]\n assert candidate(barcodes = [17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20]) == [17, 18, 17, 18, 17, 18, 17, 19, 17, 19, 17, 19, 17, 19, 17, 19, 17, 19, 18, 20, 18, 20, 18, 20, 18, 20]\n assert candidate(barcodes = [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, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3]\n assert candidate(barcodes = [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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6]\n", "comparison": "exact"}, "public_tests": ["[1,1,1,2,2,2]", "[1,1,1,1,2,2,3,3]"], "hints": ["We want to always choose the most common or second most common element to write next. What data structure allows us to query this effectively?"], "metadata": {"canonical_parameter_names": ["barcodes"], "leetcode_dataset_entry_point": "Solution().rearrangeBarcodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:11+00:00", "tests_total": 96, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "heap-priority-queue", "counting"]}, "language": "python", "interface": {"raw_signature": "def rearrangeBarcodes(self, barcodes: list[int]) -> list[int]:", "container": "Solution", "callable": "rearrangeBarcodes", "parameters": [{"name": "barcodes", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1061, "task_id": "lexicographically-smallest-equivalent-string", "difficulty": "Medium", "problem_description": "You are given two strings of the same length s1 and s2 and a string baseStr.\n\nWe say s1[i] and s2[i] are equivalent characters.\n\n- For example, if s1 = \"abc\" and s2 = \"cde\", then we have 'a' == 'c', 'b' == 'd', and 'c' == 'e'.\n\nEquivalent characters follow the usual rules of any equivalence relation:\n\n- Reflexivity: 'a' == 'a'.\n- Symmetry: 'a' == 'b' implies 'b' == 'a'.\n- Transitivity: 'a' == 'b' and 'b' == 'c' implies 'a' == 'c'.\n\nFor example, given the equivalency information from s1 = \"abc\" and s2 = \"cde\", \"acd\" and \"aab\" are equivalent strings of baseStr = \"eed\", and \"aab\" is the lexicographically smallest equivalent string of baseStr.\n\nReturn the lexicographically smallest equivalent string of baseStr by using the equivalency information from s1 and s2.\n\nExample 1:\n\nInput: s1 = \"parker\", s2 = \"morris\", baseStr = \"parser\"\nOutput: \"makkek\"\nExplanation: Based on the equivalency information in s1 and s2, we can group their characters as [m,p], [a,o], [k,r,s], [e,i].\nThe characters in each group are equivalent and sorted in lexicographical order.\nSo the answer is \"makkek\".\n\nExample 2:\n\nInput: s1 = \"hello\", s2 = \"world\", baseStr = \"hold\"\nOutput: \"hdld\"\nExplanation: Based on the equivalency information in s1 and s2, we can group their characters as [h,w], [d,e,o], [l,r].\nSo only the second letter 'o' in baseStr is changed to 'd', the answer is \"hdld\".\n\nExample 3:\n\nInput: s1 = \"leetcode\", s2 = \"programs\", baseStr = \"sourcecode\"\nOutput: \"aauaaaaada\"\nExplanation: We group the equivalent characters in s1 and s2 as [a,o,e,r,s,c], [l,p], [g,t] and [d,m], thus all letters in baseStr except 'u' and 'd' are transformed to 'a', the answer is \"aauaaaaada\".\n\nConstraints:\n\n- 1 <= s1.length, s2.length, baseStr <= 1000\n- s1.length == s2.length\n- s1, s2, and baseStr consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"abc\",s2 = \"bcd\",baseStr = \"xyz\") == \"xyz\"\n assert candidate(s1 = \"leetcode\",s2 = \"programs\",baseStr = \"sourcecode\") == \"aauaaaaada\"\n assert candidate(s1 = \"parker\",s2 = \"morris\",baseStr = \"parser\") == \"makkek\"\n assert candidate(s1 = \"abc\",s2 = \"bcd\",baseStr = \"zab\") == \"zaa\"\n assert candidate(s1 = \"abc\",s2 = \"bcd\",baseStr = \"ace\") == \"aae\"\n assert candidate(s1 = \"a\",s2 = \"b\",baseStr = \"z\") == \"z\"\n assert candidate(s1 = \"aaa\",s2 = \"bbb\",baseStr = \"ccc\") == \"ccc\"\n assert candidate(s1 = \"a\",s2 = \"z\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxya\"\n assert candidate(s1 = \"hello\",s2 = \"world\",baseStr = \"hold\") == \"hdld\"\n assert candidate(s1 = \"abc\",s2 = \"cde\",baseStr = \"eed\") == \"aab\"\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\",baseStr = \"abcdefghij\") == \"abcdefghij\"\n assert candidate(s1 = \"aabbaabbccdd\",s2 = \"bbaaddeeccff\",baseStr = \"aabbaabbccdd\") == \"aaaaaaaaccaa\"\n assert candidate(s1 = \"mnopqrstuvwxyzabcdefghijkl\",s2 = \"pqrstuvwxyzabcdefghijklmno\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abacaba\",s2 = \"zbzbzbz\",baseStr = \"zzzabzz\") == \"aaaabaa\"\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\",baseStr = \"abcdef\") == \"abccba\"\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zzzzzzzzzzzzzzz\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aaaaefghijklmnopqrstuvwxya\"\n assert candidate(s1 = \"qqqqqqqqqq\",s2 = \"wwwwwwwwww\",baseStr = \"quicksort\") == \"quicksort\"\n assert candidate(s1 = \"qwertyuiop\",s2 = \"asdfghjklz\",baseStr = \"qwertyuiopasdfghjklz\") == \"asdfghjilpasdfghjilp\"\n assert candidate(s1 = \"mnopqr\",s2 = \"nopqrs\",baseStr = \"mnopqrstuvwxyz\") == \"mmmmmmmtuvwxyz\"\n assert candidate(s1 = \"zzzzzz\",s2 = \"zzzzzz\",baseStr = \"zzzzzz\") == \"zzzzzz\"\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\",baseStr = \"abcdefgh\") == \"abcddcba\"\n assert candidate(s1 = \"abacabadaba\",s2 = \"xyzxyzxyzxy\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aaaaefghijklmnopqrstuvwaaa\"\n assert candidate(s1 = \"zyxwvutsrqponmlkjihgfedcba\",s2 = \"abcdefghijklmnopqrstuvwxyz\",baseStr = \"basestring\") == \"bahehgiimg\"\n assert candidate(s1 = \"ab\",s2 = \"ba\",baseStr = \"abcd\") == \"aacd\"\n assert candidate(s1 = \"abacabad\",s2 = \"pqprpqps\",baseStr = \"zabcde\") == \"zabcde\"\n assert candidate(s1 = \"abcdefg\",s2 = \"gfedcba\",baseStr = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihabcdcba\"\n assert candidate(s1 = \"abcabcabc\",s2 = \"defdefdef\",baseStr = \"abcdefg\") == \"abcabcg\"\n assert candidate(s1 = \"mnopqr\",s2 = \"nopqrm\",baseStr = \"mnopqrstuvwxyz\") == \"mmmmmmstuvwxyz\"\n assert candidate(s1 = \"xyzzxyzz\",s2 = \"zzxxyyzz\",baseStr = \"zzzzyyyyxxxxyyyy\") == \"xxxxxxxxxxxxxxxx\"\n assert candidate(s1 = \"aaaaabbbbbccccc\",s2 = \"bbbbbcccccddddd\",baseStr = \"fedcba\") == \"feaaaa\"\n assert candidate(s1 = \"abcabcabc\",s2 = \"cbacbacba\",baseStr = \"abcdefghi\") == \"abadefghi\"\n assert candidate(s1 = \"zzzzzzzzzz\",s2 = \"aaaaaaaaaa\",baseStr = \"zzzzzzzzzz\") == \"aaaaaaaaaa\"\n assert candidate(s1 = \"aabbcc\",s2 = \"bbccdd\",baseStr = \"abcabc\") == \"aaaaaa\"\n assert candidate(s1 = \"abacabad\",s2 = \"bcbcbcbc\",baseStr = \"zzzzzzzz\") == \"zzzzzzzz\"\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyza\",baseStr = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"aacdefghijklmnopqrstuvwxyaaacdefghijklmnopqrstuvwxya\"\n assert candidate(s1 = \"aaaaabbbbbccccc\",s2 = \"zzzzzyyyyyxxxxx\",baseStr = \"azbycxdwevfugthsiqjronmpkl\") == \"aabbccdwevfugthsiqjronmpkl\"\n assert candidate(s1 = \"abababababababab\",s2 = \"babababababababa\",baseStr = \"abababababababab\") == \"aaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abcde\",s2 = \"vwxyz\",baseStr = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"\n assert candidate(s1 = \"acaeac\",s2 = \"cdcdcd\",baseStr = \"acaeacdcd\") == \"aaaaaaaaa\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"qponmlkjihgfedcba\") == \"jklmmlkjihgfedcba\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmmlkjihgfedcba\"\n assert candidate(s1 = \"mnopqr\",s2 = \"qrstuv\",baseStr = \"mnopqrqqqqqq\") == \"mnopmnmmmmmm\"\n assert candidate(s1 = \"abcdeabcde\",s2 = \"fghijfghij\",baseStr = \"abcdefghij\") == \"abcdeabcde\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"abcdefghijklmnopqrstuvwxyz\",baseStr = \"thequickbrownfoxjumpsoverthelazydog\") == \"thequickbrownfoxjumpsoverthelazydog\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"smallestequivalentstring\") == \"hmallehgejfiealemghgiimg\"\n assert candidate(s1 = \"abcdef\",s2 = \"ghijkl\",baseStr = \"fedcba\") == \"fedcba\"\n assert candidate(s1 = \"qwertyuiop\",s2 = \"asdfghjklz\",baseStr = \"qazwsxedcrfvtgbyhnumpoi\") == \"aapssxddcffvggbhhnjmpli\"\n assert candidate(s1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",s2 = \"ddddccccbbbbaaaahhhhggggffffeeeeiiii\",baseStr = \"abcdefghi\") == \"abbaeffei\"\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"xyzxyzxyzxyzxyz\",baseStr = \"zzzzzzzzzzzzzzz\") == \"aaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"hello\") == \"helll\"\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"dcbaabdcbaab\",baseStr = \"abcdefg\") == \"aaaaefg\"\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\",baseStr = \"transform\") == \"transaorm\"\n assert candidate(s1 = \"abcabcabcabc\",s2 = \"defdefdefdef\",baseStr = \"abcdefabcdef\") == \"abcabcabcabc\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"bcdefghijklmnopqrstuvwxyza\",baseStr = \"zyxwvutsrqponmlkjihgfedcba\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",baseStr = \"zzzyyxxwwvvuuttoossrrqqppoonnmmllkkjjiihhggffeeddccbaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abcabcabc\",s2 = \"bcdcbdbcd\",baseStr = \"abcbcadcb\") == \"aaaaaaaaa\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmmlkjihgfedcba\"\n assert candidate(s1 = \"aaaaaaabbbbbbb\",s2 = \"bbbbbbbaaaaaaa\",baseStr = \"algorithm\") == \"algorithm\"\n assert candidate(s1 = \"aabbcc\",s2 = \"bbccdd\",baseStr = \"abcd\") == \"aaaa\"\n assert candidate(s1 = \"mammal\",s2 = \"walrus\",baseStr = \"evolve\") == \"evolve\"\n assert candidate(s1 = \"aaaaa\",s2 = \"bbbbb\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aacdefghijklmnopqrstuvwxyz\"\n assert candidate(s1 = \"pqrstu\",s2 = \"vwxyzq\",baseStr = \"python\") == \"psthon\"\n assert candidate(s1 = \"pqrs\",s2 = \"qrst\",baseStr = \"pqrstuvxyzpqrs\") == \"pppppuvxyzpppp\"\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\",baseStr = \"abcdefghihgfedcba\") == \"abcddcbaiabcddcba\"\n assert candidate(s1 = \"pqrstu\",s2 = \"stuvwp\",baseStr = \"ppqrstuvwp\") == \"ppqppqppqp\"\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abcdef\",s2 = \"fghijk\",baseStr = \"jklmnopqrstuvwxzyz\") == \"ealmnopqrstuvwxzyz\"\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\",baseStr = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgabccba\"\n assert candidate(s1 = \"aaaaaaa\",s2 = \"bbbbbbb\",baseStr = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aaaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"language\") == \"lamgfage\"\n assert candidate(s1 = \"eqdf\",s2 = \"wtqu\",baseStr = \"eqdf\") == \"eddf\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"bcdefghijklmnopqrstuvwxyza\",baseStr = \"thequickbrownfoxjumpsoverthelazydog\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"xyxzyz\",s2 = \"zyzxzy\",baseStr = \"xyzzyx\") == \"xxxxxx\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\",baseStr = \"thequickbrownfoxjumpsoverthelazydog\") == \"ghejfickbildmflcjfmkhleeighelaabdlg\"\n assert candidate(s1 = \"ababababab\",s2 = \"bababababa\",baseStr = \"ababababab\") == \"aaaaaaaaaa\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"bcadefghijklmnopqrstuvwxzy\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aaadefghijklmnopqrstuvwxyy\"\n assert candidate(s1 = \"equivalent\",s2 = \"characters\",baseStr = \"example\") == \"axampla\"\n assert candidate(s1 = \"ababababab\",s2 = \"bcbcbcbcbc\",baseStr = \"abacabadab\") == \"aaaaaaadaa\"\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zxyzxyzxyzxyzxy\",baseStr = \"abacabadabacaba\") == \"aaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abcdabcdabcdabcd\",s2 = \"dcbaecbaecbaecba\",baseStr = \"abcdefghijk\") == \"abbaafghijk\"\n assert candidate(s1 = \"leet\",s2 = \"code\",baseStr = \"leetcode\") == \"cdddcddd\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"bcdefghijklmnopqrstuvwxyza\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"abcdefg\",s2 = \"ghijklm\",baseStr = \"abcdefg\") == \"abcdefa\"\n assert candidate(s1 = \"qwertyuiopasdfghjklzxcvbnm\",s2 = \"mlkjihgfedcbazyxwvutsrqpon\",baseStr = \"zyxwvutsrqponmlkjihgfedcba\") == \"faaaeafaaeaeeeaeafaafeaaaa\"\n assert candidate(s1 = \"abcabcabcabc\",s2 = \"defdefdefdef\",baseStr = \"complexity\") == \"complbxity\"\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"bcdefghijklmnopqrstuvwxyza\",baseStr = \"thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s1 = \"acbacbacbacb\",s2 = \"zyxzyxzyxzyx\",baseStr = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwbca\"\n assert candidate(s1 = \"aaaaaa\",s2 = \"bbbbbb\",baseStr = \"ababab\") == \"aaaaaa\"\n assert candidate(s1 = \"xyzzzz\",s2 = \"zzzzzz\",baseStr = \"xyzzyx\") == \"xxxxxx\"\n", "comparison": "exact"}, "public_tests": ["\"parker\"\n\"morris\"\n\"parser\"", "\"hello\"\n\"world\"\n\"hold\"", "\"leetcode\"\n\"programs\"\n\"sourcecode\""], "hints": ["Model these equalities as edges of a graph.", "Group each connected component of the graph and assign each node of this component to the node with the lowest lexicographically character.", "Finally convert the string with the precalculated information."], "metadata": {"canonical_parameter_names": ["s1", "s2", "baseStr"], "leetcode_dataset_entry_point": "Solution().smallestEquivalentString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:27+00:00", "tests_total": 98, "tests_dropped": 9, "flags": [], "topic_tags": ["string", "union-find"]}, "language": "python", "interface": {"raw_signature": "def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:", "container": "Solution", "callable": "smallestEquivalentString", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}, {"name": "baseStr", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1071, "task_id": "greatest-common-divisor-of-strings", "difficulty": "Easy", "problem_description": "For two strings s and t, we say \"t divides s\" if and only if s = t + t + t + ... + t + t (i.e., t is concatenated with itself one or more times).\n\nGiven two strings str1 and str2, return the largest string x such that x divides both str1 and str2.\n\nExample 1:\n\nInput: str1 = \"ABCABC\", str2 = \"ABC\"\nOutput: \"ABC\"\n\nExample 2:\n\nInput: str1 = \"ABABAB\", str2 = \"ABAB\"\nOutput: \"AB\"\n\nExample 3:\n\nInput: str1 = \"LEET\", str2 = \"CODE\"\nOutput: \"\"\n\nExample 4:\n\nInput: str1 = \"AAAAAB\", str2 = \"AAA\"\nOutput: \"\"\n\nConstraints:\n\n- 1 <= str1.length, str2.length <= 1000\n- str1 and str2 consist of English uppercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(str1 = \"ABAB\",str2 = \"ABA\") == \"\"\n assert candidate(str1 = \"ABCDEFGH\",str2 = \"XYZ\") == \"\"\n assert candidate(str1 = \"ABCABC\",str2 = \"ABC\") == \"ABC\"\n assert candidate(str1 = \"ABABAB\",str2 = \"ABA\") == \"\"\n assert candidate(str1 = \"ABABAB\",str2 = \"ABAB\") == \"AB\"\n assert candidate(str1 = \"ABCABCABC\",str2 = \"ABCABC\") == \"ABC\"\n assert candidate(str1 = \"ABCD\",str2 = \"EFGH\") == \"\"\n assert candidate(str1 = \"XYZXYZXYZ\",str2 = \"XYZXYZ\") == \"XYZ\"\n assert candidate(str1 = \"AAAAAAAAAA\",str2 = \"AAAAAAAAAA\") == \"AAAAAAAAAA\"\n assert candidate(str1 = \"GCDGCDGCD\",str2 = \"GCD\") == \"GCD\"\n assert candidate(str1 = \"ABCD\",str2 = \"ABCD\") == \"ABCD\"\n assert candidate(str1 = \"HELLOHELLO\",str2 = \"HELLO\") == \"HELLO\"\n assert candidate(str1 = \"A\",str2 = \"A\") == \"A\"\n assert candidate(str1 = \"PQRS\",str2 = \"PQRS\") == \"PQRS\"\n assert candidate(str1 = \"AAAA\",str2 = \"AA\") == \"AA\"\n assert candidate(str1 = \"ABCDEFG\",str2 = \"BCD\") == \"\"\n assert candidate(str1 = \"LEET\",str2 = \"CODE\") == \"\"\n assert candidate(str1 = \"HELLOHELLOHELLO\",str2 = \"HELLO\") == \"HELLO\"\n assert candidate(str1 = \"ABCDEF\",str2 = \"ABC\") == \"\"\n assert candidate(str1 = \"ABABABAB\",str2 = \"BABA\") == \"\"\n assert candidate(str1 = \"AAAAAAAAA\",str2 = \"AAAAA\") == \"A\"\n assert candidate(str1 = \"TATATATA\",str2 = \"TAT\") == \"\"\n assert candidate(str1 = \"ABCABCABC\",str2 = \"ABC\") == \"ABC\"\n assert candidate(str1 = \"ABABABAB\",str2 = \"ABAB\") == \"ABAB\"\n assert candidate(str1 = \"BANANABANANABANANABANANA\",str2 = \"BANANABANANA\") == \"BANANABANANA\"\n assert candidate(str1 = \"XYXYXYXY\",str2 = \"XYXY\") == \"XYXY\"\n assert candidate(str1 = \"DOUBLEDOUBLEDOUBLE\",str2 = \"DOUBLEDOUBLE\") == \"DOUBLE\"\n assert candidate(str1 = \"SIMILARITYSIMILARITY\",str2 = \"SIMILARITY\") == \"SIMILARITY\"\n assert candidate(str1 = \"REPREPREP\",str2 = \"REPRE\") == \"\"\n assert candidate(str1 = \"ABACABACABAC\",str2 = \"ABAC\") == \"ABAC\"\n assert candidate(str1 = \"DOGDOGDOGDOGDOGDOG\",str2 = \"DOGDOGDOG\") == \"DOGDOGDOG\"\n assert candidate(str1 = \"XYZXYZXYZXYZXYZXYZ\",str2 = \"XYZXYZXYZXYZ\") == \"XYZXYZ\"\n assert candidate(str1 = \"PPPPPPPPPPPPPPPP\",str2 = \"PPPPPP\") == \"PP\"\n assert candidate(str1 = \"MULTIPLEMULTIPLEMULTIPLE\",str2 = \"MULTIPLEMULTIPLE\") == \"MULTIPLE\"\n assert candidate(str1 = \"MIXEDCASEMIXEDCASE\",str2 = \"MIXEDCASE\") == \"MIXEDCASE\"\n assert candidate(str1 = \"XYXYXYXYXYXYXYXY\",str2 = \"XYXYXY\") == \"XY\"\n assert candidate(str1 = \"ANTEANTEANTEANTEANTEANTEANTEANTEANTE\",str2 = \"ANTEANTEANTEANTE\") == \"ANTE\"\n assert candidate(str1 = \"QWQWQWQWQWQW\",str2 = \"QWQW\") == \"QWQW\"\n assert candidate(str1 = \"PINEAPPLEPINEAPPLEPINEAPPLEPINEAPPLE\",str2 = \"PINEAPPLEPINEAPPLE\") == \"PINEAPPLEPINEAPPLE\"\n assert candidate(str1 = \"MNMNMNMN\",str2 = \"MNMN\") == \"MNMN\"\n assert candidate(str1 = \"XYZXYZXYZXYZXYZ\",str2 = \"XYZXYZXYZ\") == \"XYZ\"\n assert candidate(str1 = \"REPORTEPORTEPORTE\",str2 = \"REPORTEPORTE\") == \"\"\n assert candidate(str1 = \"RRRRRRRRRRRR\",str2 = \"RRRRRR\") == \"RRRRRR\"\n assert candidate(str1 = \"DIFFERENTLENGTHDIFFERENTLENGTH\",str2 = \"DIFFERENTLENGTH\") == \"DIFFERENTLENGTH\"\n assert candidate(str1 = \"SMALLSAME\",str2 = \"SAME\") == \"\"\n assert candidate(str1 = \"MIXEDUPMIXEDUP\",str2 = \"MIXEDUP\") == \"MIXEDUP\"\n assert candidate(str1 = \"UPPERCASEUPPERCASEUPPERCASE\",str2 = \"UPPERCASEUPPERCASE\") == \"UPPERCASE\"\n assert candidate(str1 = \"LONGSTRINGLONGSTRINGLONGSTRINGLONGSTRING\",str2 = \"LONGSTRINGLONGSTRING\") == \"LONGSTRINGLONGSTRING\"\n assert candidate(str1 = \"LONGSTRINGLONGSTRINGLONGSTRING\",str2 = \"LONGSTRINGLONG\") == \"\"\n assert candidate(str1 = \"SIMPLESIMPLESIMPLE\",str2 = \"SIMPLESIMPLE\") == \"SIMPLE\"\n assert candidate(str1 = \"AAAAABBBB\",str2 = \"AAAAA\") == \"\"\n assert candidate(str1 = \"SHORT\",str2 = \"VERYLONGSTRINGTHATISNOTAREPEAT\") == \"\"\n assert candidate(str1 = \"AB\",str2 = \"BA\") == \"\"\n assert candidate(str1 = \"PRIMEPRIMEPRIME\",str2 = \"PRIMEPRIME\") == \"PRIME\"\n assert candidate(str1 = \"MNMNMNMNMNMN\",str2 = \"MNMN\") == \"MNMN\"\n assert candidate(str1 = \"BEEBEEBEEBEEBEEBEEBEEBEE\",str2 = \"BEEBEEBEEBEE\") == \"BEEBEEBEEBEE\"\n assert candidate(str1 = \"GRAPEGRAPEGRAPEGRAPEGRAPEGRAPE\",str2 = \"GRAPEGRAPEGRAPE\") == \"GRAPEGRAPEGRAPE\"\n assert candidate(str1 = \"TIGERTIGERTIGERTIGERTIGERTIGER\",str2 = \"TIGERTIGERTIGER\") == \"TIGERTIGERTIGER\"\n assert candidate(str1 = \"SCIENCE\",str2 = \"SCIENCE\") == \"SCIENCE\"\n assert candidate(str1 = \"ABCDEFGABCDEFG\",str2 = \"ABCDEFG\") == \"ABCDEFG\"\n assert candidate(str1 = \"XYZXYZXYZXYZXYZXYZXYZXYZ\",str2 = \"XYZXYZXYZ\") == \"XYZ\"\n assert candidate(str1 = \"MIXEDMIXEDMIXEDMIXED\",str2 = \"MIXEDMIXED\") == \"MIXEDMIXED\"\n assert candidate(str1 = \"ALMOSTSAMEALMOSTSAME\",str2 = \"ALMOSTSAME\") == \"ALMOSTSAME\"\n assert candidate(str1 = \"APPLEAPPLEAPPLEAPPLEAPPLE\",str2 = \"APPLEAPPLEAPPLE\") == \"APPLE\"\n assert candidate(str1 = \"MIXMIXMIXMIX\",str2 = \"MIXMIX\") == \"MIXMIX\"\n assert candidate(str1 = \"MATHMATHMATHMATH\",str2 = \"MATH\") == \"MATH\"\n assert candidate(str1 = \"SIMPLESIMPLESIMPLESIMPLE\",str2 = \"SIMPLE\") == \"SIMPLE\"\n assert candidate(str1 = \"DUCKDUCKDUCKDUCKDUCKDUCKDUCKDUCK\",str2 = \"DUCKDUCKDUCKDUCK\") == \"DUCKDUCKDUCKDUCK\"\n assert candidate(str1 = \"LONGLONGLONGLONGLONGLONG\",str2 = \"LONGLONGLONG\") == \"LONGLONGLONG\"\n assert candidate(str1 = \"ZAZAZAZAZA\",str2 = \"ZAZA\") == \"ZA\"\n assert candidate(str1 = \"AABAAABAAB\",str2 = \"AAB\") == \"\"\n assert candidate(str1 = \"ABCDEFABCDEF\",str2 = \"ABCDEF\") == \"ABCDEF\"\n assert candidate(str1 = \"PATTERNPATTERNPATTERN\",str2 = \"PATTERNPATTERN\") == \"PATTERN\"\n assert candidate(str1 = \"UNIQUEUNIQUEUNIQUEUNIQUEUNIQUE\",str2 = \"UNIQUEUNIQUE\") == \"UNIQUE\"\n assert candidate(str1 = \"WOWOWOWOWOWO\",str2 = \"WOWOWO\") == \"WOWOWO\"\n assert candidate(str1 = \"HELLOHELLOHELLOHELLO\",str2 = \"HELLOHELLOHELLO\") == \"HELLO\"\n assert candidate(str1 = \"REPEATREPEATREPEATREPEATREPEAT\",str2 = \"REPEATREPEAT\") == \"REPEAT\"\n assert candidate(str1 = \"IDENTICALIDENTICALIDENTICAL\",str2 = \"IDENTICALIDENTICAL\") == \"IDENTICAL\"\n assert candidate(str1 = \"ABCDEFGABCDEFG\",str2 = \"DEFGABCD\") == \"\"\n assert candidate(str1 = \"SAMESTRINGSAME\",str2 = \"SAME\") == \"\"\n assert candidate(str1 = \"REPEATREPEATREPEAT\",str2 = \"REPEATREPEAT\") == \"REPEAT\"\n assert candidate(str1 = \"QQQQQQQQQQ\",str2 = \"QQQQ\") == \"QQ\"\n assert candidate(str1 = \"FAMILYFAMILYFAMILY\",str2 = \"FAMILYFAMILY\") == \"FAMILY\"\n assert candidate(str1 = \"ABCABCABCABCABCABC\",str2 = \"ABCABCABC\") == \"ABCABCABC\"\n assert candidate(str1 = \"UNIQUEUNIQUEUNIQUEUNIQUE\",str2 = \"UNIQUEUNIQUE\") == \"UNIQUEUNIQUE\"\n assert candidate(str1 = \"LONGSTRINGLONGSTRING\",str2 = \"LONGSTRING\") == \"LONGSTRING\"\n assert candidate(str1 = \"UNIQUEUNIQUE\",str2 = \"UNIQUEUNIQUEUNIQUE\") == \"UNIQUE\"\n assert candidate(str1 = \"MOUSEMOUSEMOUSEMOUSEMOUSEMOUSE\",str2 = \"MOUSEMOUSE\") == \"MOUSEMOUSE\"\n assert candidate(str1 = \"ABABABABABAB\",str2 = \"ABAB\") == \"ABAB\"\n assert candidate(str1 = \"HELLOWORLDHELLOWORLD\",str2 = \"HELLOWORLD\") == \"HELLOWORLD\"\n assert candidate(str1 = \"ABCDABCD\",str2 = \"ABCDABCDABCD\") == \"ABCD\"\n assert candidate(str1 = \"SAMESAMESAME\",str2 = \"SAME\") == \"SAME\"\n assert candidate(str1 = \"QRSTQRSTQRST\",str2 = \"QRSTQRST\") == \"QRST\"\n assert candidate(str1 = \"KARMAKARMAKARMAKARMA\",str2 = \"KARMAKARMA\") == \"KARMAKARMA\"\n assert candidate(str1 = \"AAAAABAAAAAB\",str2 = \"AAAAAB\") == \"AAAAAB\"\n assert candidate(str1 = \"TTT\",str2 = \"TTTTTTT\") == \"T\"\n assert candidate(str1 = \"QQQQQQQQQQQQQQQQ\",str2 = \"QQQQ\") == \"QQQQ\"\n assert candidate(str1 = \"AAAABBBBAAAABBBB\",str2 = \"AAAABBBB\") == \"AAAABBBB\"\n assert candidate(str1 = \"QWQWQWQWQWQW\",str2 = \"QWQWQW\") == \"QWQWQW\"\n assert candidate(str1 = \"PPPPPPPP\",str2 = \"PPPP\") == \"PPPP\"\n assert candidate(str1 = \"SPAMSPAMSPAMSPAM\",str2 = \"SPAMSPAM\") == \"SPAMSPAM\"\n assert candidate(str1 = \"PATTERNPATTERN\",str2 = \"PATTERN\") == \"PATTERN\"\n assert candidate(str1 = \"XYZXYZXYZXYZXYZXYZ\",str2 = \"XYZXYZ\") == \"XYZXYZ\"\n assert candidate(str1 = \"SCREENSCREENSCREENSCREEN\",str2 = \"SCREEN\") == \"SCREEN\"\n assert candidate(str1 = \"PIZZAPIZZAPIZZAPIZZA\",str2 = \"PIZZAPIZZA\") == \"PIZZAPIZZA\"\n assert candidate(str1 = \"ORANGEORANGEORANGEORANGEORANGEORANGEORANGEORANGE\",str2 = \"ORANGEORANGEORANGE\") == \"ORANGE\"\n assert candidate(str1 = \"PRIMEPRIMEPRIMEPRIME\",str2 = \"PRIMEPRIME\") == \"PRIMEPRIME\"\n assert candidate(str1 = \"REPEATREPEATREPEAT\",str2 = \"REPEAT\") == \"REPEAT\"\n assert candidate(str1 = \"CODECODECODECODECODECODE\",str2 = \"CODECODECODE\") == \"CODECODECODE\"\n assert candidate(str1 = \"PROJECTORPROJECTORPROJECTORPROJECTOR\",str2 = \"PROJECTORPROJECTOR\") == \"PROJECTORPROJECTOR\"\n assert candidate(str1 = \"PYTHONPYTHONPYTHON\",str2 = \"PYTHONPYTHON\") == \"PYTHON\"\n assert candidate(str1 = \"CCCCCCCCCCCCCC\",str2 = \"CCCCCCCCC\") == \"C\"\n assert candidate(str1 = \"PQPQPQ\",str2 = \"PQPQPQPQPQ\") == \"PQ\"\n assert candidate(str1 = \"DESKDESKDESKDESK\",str2 = \"DESK\") == \"DESK\"\n assert candidate(str1 = \"GUITARGUITARGUITAR\",str2 = \"GUITAR\") == \"GUITAR\"\n assert candidate(str1 = \"QWQWQWQWQW\",str2 = \"QWQWQW\") == \"QW\"\n assert candidate(str1 = \"LONGLONGLONGLONGLONG\",str2 = \"LONGLONGLONG\") == \"LONG\"\n assert candidate(str1 = \"DEVDEVDEVDEVDEV\",str2 = \"DEVDEV\") == \"DEV\"\n assert candidate(str1 = \"UNIQUEUNIQUEUNIQUEUNIQUEUNIQUE\",str2 = \"UNIQUEUNIQUEUNIQUE\") == \"UNIQUE\"\n assert candidate(str1 = \"TREETREETREETREE\",str2 = \"TREETREE\") == \"TREETREE\"\n assert candidate(str1 = \"XYZXYZXYZXYZXYZXYZ\",str2 = \"XYZXYZXYZ\") == \"XYZXYZXYZ\"\n assert candidate(str1 = \"HELLOHELLOHELLOHELLOHELLO\",str2 = \"HELLOHELLOHELLO\") == \"HELLO\"\n assert candidate(str1 = \"SMALL\",str2 = \"SMALLSMALLSMALL\") == \"SMALL\"\n assert candidate(str1 = \"MNMNMNMNMN\",str2 = \"MNMN\") == \"MN\"\n assert candidate(str1 = \"ABCABCABCABC\",str2 = \"ABCABC\") == \"ABCABC\"\n assert candidate(str1 = \"LONGERSTRINGLONGERSTRINGLONGERSTRING\",str2 = \"LONGERSTRINGLONGERSTRING\") == \"LONGERSTRING\"\n assert candidate(str1 = \"PATTERNPATTERNPATTERNPATTERN\",str2 = \"PATTERNPATTERN\") == \"PATTERNPATTERN\"\n assert candidate(str1 = \"HELLOHELLOHELLOHELLOHELLOHELLO\",str2 = \"HELLOHELLOHELLOHELLOHELLO\") == \"HELLO\"\n assert candidate(str1 = \"DIFFERENTLENGTHS\",str2 = \"SOMEOTHERSTRING\") == \"\"\n assert candidate(str1 = \"MIXEDUP\",str2 = \"MIXEDUPMIXEDUP\") == \"MIXEDUP\"\n assert candidate(str1 = \"KEYBOARDKEYBOARDKEYBOARDKEYBOARD\",str2 = \"KEYBOARDKEYBOARD\") == \"KEYBOARDKEYBOARD\"\n assert candidate(str1 = \"FLOWERFLOWERFLOWERFLOWER\",str2 = \"FLOWERFLOWER\") == \"FLOWERFLOWER\"\n assert candidate(str1 = \"LONGSTRING\",str2 = \"LONGSTRINGLONGSTRING\") == \"LONGSTRING\"\n assert candidate(str1 = \"SAMESTRINGSAMESTRINGSAMESTRING\",str2 = \"SAMESTRINGSAMESTRING\") == \"SAMESTRING\"\n assert candidate(str1 = \"NONONONONONO\",str2 = \"NONO\") == \"NONO\"\n assert candidate(str1 = \"ABCDABCDABCDABCD\",str2 = \"ABCDABCD\") == \"ABCDABCD\"\n assert candidate(str1 = \"TESTTESTTESTTEST\",str2 = \"TESTTEST\") == \"TESTTEST\"\n assert candidate(str1 = \"SAMELENGTH\",str2 = \"DIFFERENT\") == \"\"\n assert candidate(str1 = \"HELLOHELLOHELLO\",str2 = \"HELLOHELLO\") == \"HELLO\"\n assert candidate(str1 = \"DOGDOGDOGDOGDOG\",str2 = \"DOGDOG\") == \"DOG\"\n assert candidate(str1 = \"CATCATCATCATCAT\",str2 = \"CATCAT\") == \"CAT\"\n assert candidate(str1 = \"ABABABABAB\",str2 = \"ABAB\") == \"AB\"\n assert candidate(str1 = \"LONGLONGLONGLONG\",str2 = \"LONG\") == \"LONG\"\n assert candidate(str1 = \"COMPUTERCOMPUTERCOMPUTER\",str2 = \"COMPUTER\") == \"COMPUTER\"\n assert candidate(str1 = \"RUBYRUBYRUBYRUBY\",str2 = \"RUBYRUBY\") == \"RUBYRUBY\"\n assert candidate(str1 = \"BEEBEEBEEBEEBEE\",str2 = \"BEEBEE\") == \"BEE\"\n assert candidate(str1 = \"ABABABABABAB\",str2 = \"ABABAB\") == \"ABABAB\"\n assert candidate(str1 = \"BIGBIGBIGBIG\",str2 = \"BIG\") == \"BIG\"\n assert candidate(str1 = \"APPLEAPPLEAPPLEAPPLEAPPLEAPPLE\",str2 = \"APPLEAPPLEAPPLE\") == \"APPLEAPPLEAPPLE\"\n assert candidate(str1 = \"AABBCCDDEEFF\",str2 = \"AABBCCDD\") == \"\"\n assert candidate(str1 = \"UVUVUVUVUVUV\",str2 = \"UVUVUV\") == \"UVUVUV\"\n assert candidate(str1 = \"PPPPPPPPPP\",str2 = \"PPPP\") == \"PP\"\n assert candidate(str1 = \"TESTTESTTESTTEST\",str2 = \"TESTTESTTEST\") == \"TEST\"\n assert candidate(str1 = \"AABBCCDDEE\",str2 = \"AABBCC\") == \"\"\n assert candidate(str1 = \"MIXMIXMIXMIXMIX\",str2 = \"MIXMIX\") == \"MIX\"\n assert candidate(str1 = \"PYTHONPYTHONPYTHONPYTHON\",str2 = \"PYTHONPYTHON\") == \"PYTHONPYTHON\"\n assert candidate(str1 = \"PYTHONPYTHONPYTHONPYTHONPYTHON\",str2 = \"PYTHONPYTHON\") == \"PYTHON\"\n assert candidate(str1 = \"AABBCCAABBCC\",str2 = \"AABBCC\") == \"AABBCC\"\n assert candidate(str1 = \"LIONLIONLIONLIONLIONLION\",str2 = \"LIONLIONLION\") == \"LIONLIONLION\"\n assert candidate(str1 = \"ABCDEFGABCDEFGABCDEFG\",str2 = \"ABCDEFGABCDEFG\") == \"ABCDEFG\"\n assert candidate(str1 = \"MICROPHONEMICROPHONEMICROPHONE\",str2 = \"MICROPHONE\") == \"MICROPHONE\"\n assert candidate(str1 = \"ABABABABABABABAB\",str2 = \"ABABAB\") == \"AB\"\n assert candidate(str1 = \"XYZXYZXYZXYZ\",str2 = \"XYZXYZ\") == \"XYZXYZ\"\n assert candidate(str1 = \"HEADPHONESHEADPHONES\",str2 = \"HEADPHONESHEADPHONES\") == \"HEADPHONESHEADPHONES\"\n assert candidate(str1 = \"ABCDEFGHABCDEFGHABCDEFGH\",str2 = \"ABCDEFGHABCDEFGH\") == \"ABCDEFGH\"\n assert candidate(str1 = \"SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER\",str2 = \"SPEAKERSPEAKER\") == \"SPEAKER\"\n assert candidate(str1 = \"DIVIDEDIVIDE\",str2 = \"DIVIDE\") == \"DIVIDE\"\n assert candidate(str1 = \"JSJSJSJSJSJSJS\",str2 = \"JSJSJSJS\") == \"JS\"\n assert candidate(str1 = \"CATCATCATCATCATCAT\",str2 = \"CATCATCAT\") == \"CATCATCAT\"\n assert candidate(str1 = \"NOTCOMMONNOTCOMMONNOTCOMMON\",str2 = \"NOTCOMMONNOT\") == \"\"\n assert candidate(str1 = \"XZXZXZXZXZ\",str2 = \"XZXZ\") == \"XZ\"\n assert candidate(str1 = \"DOGDOGDOGDOGDOGDOGDOGDOGDOGDOG\",str2 = \"DOGDOGDOGDOG\") == \"DOGDOG\"\n", "comparison": "exact"}, "public_tests": ["\"ABCABC\"\n\"ABC\"", "\"ABABAB\"\n\"ABAB\"", "\"LEET\"\n\"CODE\"", "\"AAAAAB\"\n\"AAA\""], "hints": ["The greatest common divisor must be a prefix of each string, so we can try all prefixes."], "metadata": {"canonical_parameter_names": ["str1", "str2"], "leetcode_dataset_entry_point": "Solution().gcdOfStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:42+00:00", "tests_total": 175, "tests_dropped": 3, "flags": [], "topic_tags": ["math", "string", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def gcdOfStrings(self, str1: str, str2: str) -> str:", "container": "Solution", "callable": "gcdOfStrings", "parameters": [{"name": "str1", "type": "str"}, {"name": "str2", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1072, "task_id": "flip-columns-for-maximum-number-of-equal-rows", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix matrix.\n\nYou can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa).\n\nReturn the maximum number of rows that have all values equal after some number of flips.\n\nExample 1:\n\nInput: matrix = [[0,1],[1,1]]\nOutput: 1\nExplanation: After flipping no values, 1 row has all values equal.\n\nExample 2:\n\nInput: matrix = [[0,1],[1,0]]\nOutput: 2\nExplanation: After flipping values in the first column, both rows have equal values.\n\nExample 3:\n\nInput: matrix = [[0,0,0],[0,0,1],[1,1,0]]\nOutput: 2\nExplanation: After flipping values in the first two columns, the last two rows have equal values.\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 300\n- matrix[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[0, 1], [1, 0]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == 3\n assert candidate(matrix = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1], [1, 1, 1, 1], [0, 1, 0, 0]]) == 1\n assert candidate(matrix = [[1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]]) == 3\n assert candidate(matrix = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 1]]) == 2\n assert candidate(matrix = [[1, 1, 1], [0, 0, 0], [1, 0, 1]]) == 2\n assert candidate(matrix = [[0, 1], [1, 1]]) == 1\n assert candidate(matrix = [[0, 0, 0], [0, 0, 1], [1, 1, 0]]) == 2\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == 3\n assert candidate(matrix = [[1, 0, 0, 1], [1, 0, 1, 0], [0, 1, 0, 0]]) == 1\n assert candidate(matrix = [[0, 0], [0, 0], [1, 1], [1, 1]]) == 4\n assert candidate(matrix = [[0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 1, 1]]) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 1]]) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0]]) == 4\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]]) == 2\n assert candidate(matrix = [[0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 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, 1]]) == 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]]) == 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]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 1], [0, 1, 1, 0, 0, 1, 1, 0, 0, 0]]) == 2\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 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]]) == 2\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 0]]) == 2\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]]) == 4\n assert candidate(matrix = [[0, 0, 1, 0, 1], [1, 1, 0, 1, 0], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0]]) == 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], [0, 1, 0, 1, 0, 1]]) == 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]]) == 4\n assert candidate(matrix = [[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], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 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, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 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]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 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]]) == 2\n assert candidate(matrix = [[1, 0, 0, 0, 0, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0, 0]]) == 1\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 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]]) == 2\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 1], [1, 0, 1, 0, 0]]) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0]]) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == 2\n assert candidate(matrix = [[0, 0, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 1], [1, 1, 0, 0, 0]]) == 2\n assert candidate(matrix = [[1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1]]) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 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]]) == 4\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 0, 1]]) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 2\n assert candidate(matrix = [[0, 1, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 1], [0, 1, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 1]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 1\n assert candidate(matrix = [[0, 1, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 1, 0, 1, 0, 1]]) == 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, 0], [0, 1, 0, 1, 0, 1, 1]]) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1]]) == 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], [1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0]]) == 2\n assert candidate(matrix = [[0, 0, 1, 1, 0], [0, 0, 1, 1, 1], [1, 1, 0, 0, 1], [1, 1, 0, 0, 0]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(matrix = [[1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 1]]) == 4\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, 0, 1, 1, 0]]) == 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]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0]]) == 4\n assert candidate(matrix = [[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, 1, 0, 1, 0, 1, 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\n assert candidate(matrix = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0]]) == 2\n assert candidate(matrix = [[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, 0, 1, 1, 1, 1]]) == 4\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], [1, 0, 1, 0, 1, 0, 1]]) == 4\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, 0]]) == 3\n assert candidate(matrix = [[1, 0, 0, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0]]) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 2\n assert candidate(matrix = [[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\n assert candidate(matrix = [[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]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 2\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]]) == 2\n assert candidate(matrix = [[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]]) == 2\n assert candidate(matrix = [[0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]]) == 4\n assert candidate(matrix = [[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], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(matrix = [[0, 0, 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, 0]]) == 1\n assert candidate(matrix = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1, 0]]) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]]) == 2\n assert candidate(matrix = [[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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[0, 1, 1, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [1, 0, 0, 0, 1]]) == 2\n assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 1]]) == 3\n assert candidate(matrix = [[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, 1]]) == 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\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 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], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == 2\n assert candidate(matrix = [[0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,1]]", "[[0,1],[1,0]]", "[[0,0,0],[0,0,1],[1,1,0]]"], "hints": ["Flipping a subset of columns is like doing a bitwise XOR of some number K onto each row. We want rows X with X ^ K = all 0s or all 1s. This is the same as X = X^K ^K = (all 0s or all 1s) ^ K, so we want to count rows that have opposite bits set. For example, if K = 1, then we count rows X = (00000...001, or 1111....110)."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().maxEqualRowsAfterFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:45+00:00", "tests_total": 88, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxEqualRowsAfterFlips(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "maxEqualRowsAfterFlips", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1073, "task_id": "adding-two-negabinary-numbers", "difficulty": "Medium", "problem_description": "Given two numbers arr1 and arr2 in base -2, return the result of adding them together.\n\nEach number is given in array format: as an array of 0s and 1s, from most significant bit to least significant bit. For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3. A number arr in array, format is also guaranteed to have no leading zeros: either arr == [0] or arr[0] == 1.\n\nReturn the result of adding arr1 and arr2 in the same format: as an array of 0s and 1s with no leading zeros.\n\nExample 1:\n\nInput: arr1 = [1,1,1,1,1], arr2 = [1,0,1]\nOutput: [1,0,0,0,0]\nExplanation: arr1 represents 11, arr2 represents 5, the output represents 16.\n\nExample 2:\n\nInput: arr1 = [0], arr2 = [0]\nOutput: [0]\n\nExample 3:\n\nInput: arr1 = [0], arr2 = [1]\nOutput: [1]\n\nConstraints:\n\n- 1 <= arr1.length, arr2.length <= 1000\n- arr1[i] and arr2[i] are 0 or 1\n- arr1 and arr2 have no leading zeros\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [0],arr2 = [0]) == [0]\n assert candidate(arr1 = [1, 0, 1, 0, 1],arr2 = [1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 0],arr2 = [1, 1, 0]) == [1, 0, 0]\n assert candidate(arr1 = [1, 0, 1],arr2 = [1, 1, 1, 1, 1]) == [1, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 0, 1],arr2 = [1, 0, 1, 0]) == [1, 1, 0, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 0, 1],arr2 = [1, 1, 0, 1]) == [1, 0, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 1],arr2 = [1, 1, 0]) == [1, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 0, 0, 0],arr2 = [1, 0, 0, 0, 0]) == [1, 1, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 1],arr2 = [1, 1, 0, 0]) == [1, 1, 0, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 0, 1],arr2 = [1, 0, 1, 1]) == [1, 1, 0, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 1],arr2 = [1, 1, 1]) == [1, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0],arr2 = [1, 1, 1, 1]) == [1, 0, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 0, 1]) == [1, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1],arr2 = [1, 1, 0, 0, 0]) == [1, 0, 1, 0, 1]\n assert candidate(arr1 = [0],arr2 = [1]) == [1]\n assert candidate(arr1 = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],arr2 = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 0, 1, 0],arr2 = [0, 1, 1, 0, 1, 1, 0]) == [1, 0, 0, 0, 0]\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0]\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 1, 1, 1, 1],arr2 = [1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 0, 0, 0, 1, 0, 0, 0, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 0, 1],arr2 = [1, 0, 1, 1, 1]) == [1, 0, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 1, 0, 1],arr2 = [1, 1, 0, 0, 1, 1]) == [1, 1, 0, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],arr2 = [1, 1, 0, 0, 0, 0, 0, 0, 0, 1]) == [1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],arr2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],arr2 = [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, 0, 0]\n assert candidate(arr1 = [0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0],arr2 = [1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1]) == [1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1]\n assert candidate(arr1 = [1, 1, 0, 1, 1, 0, 1, 1, 0],arr2 = [0, 1, 1, 0, 0, 1, 0, 1, 1]) == [1, 1, 1, 1, 0, 0, 1]\n assert candidate(arr1 = [1, 1, 0, 1, 1, 1, 0, 1],arr2 = [1, 1, 1, 0, 1, 0, 1, 1]) == [1, 0, 1, 0, 0, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 0, 1, 0],arr2 = [1, 0, 1, 1, 1]) == [1, 1, 0, 1, 0, 0, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],arr2 = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0],arr2 = [1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == [1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1]) == [1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 1, 1, 1, 0, 1, 0],arr2 = [1, 1, 1, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 0, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],arr2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [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(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],arr2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0],arr2 = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1],arr2 = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1],arr2 = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 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]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0],arr2 = [1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1]\n assert candidate(arr1 = [0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],arr2 = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 0, 1],arr2 = [1, 0, 1, 0, 1, 1]) == [1, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1],arr2 = [1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1]) == [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0]\n assert candidate(arr1 = [0, 1, 1, 1, 0, 1, 1, 0],arr2 = [1, 0, 1, 0, 1, 0, 1, 0]) == [1, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 0, 0, 1, 0, 0, 1],arr2 = [0, 1, 1, 1, 0, 0, 1]) == [1, 1, 0, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1],arr2 = [1, 0, 1, 1, 1]) == [1, 1, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0],arr2 = [1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 1, 0, 1]) == [1, 1, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],arr2 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],arr2 = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1]) == [1, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],arr2 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == [1, 0, 0, 0, 1, 0, 0, 0, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],arr2 = [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, 0, 0]\n assert candidate(arr1 = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1],arr2 = [1, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1, 1],arr2 = [1, 0, 0, 1, 0, 1]) == [1, 1, 0, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1],arr2 = [1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1]) == [1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1]) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(arr1 = [1, 1, 0, 0, 1, 1, 0, 1],arr2 = [1, 1, 1, 1, 0, 0, 1, 1]) == [1, 0, 1, 1, 1, 1, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [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(arr1 = [1, 1, 1, 0, 1, 1, 0, 1, 1, 0],arr2 = [1, 1, 0, 0, 0, 1, 0, 1, 0, 1]) == [1, 0, 1, 0, 0, 1, 1, 0, 1, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 0, 0, 1, 1, 0, 0, 1, 1]) == [1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 0, 1, 0]) == [1, 1, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1],arr2 = [1, 0, 1, 0, 1, 0, 1]) == [1, 1, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [0, 0, 1, 1, 1, 0, 1, 1, 0],arr2 = [0, 1, 0, 0, 1, 1, 1, 0, 1]) == [1, 1, 0, 0, 0, 0, 1, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],arr2 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 0, 0, 0, 1, 1],arr2 = [1, 1, 1, 1, 0, 0, 1]) == [1, 0, 1, 1, 0, 0, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],arr2 = [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, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 1, 0, 0, 1, 1]) == [1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 0, 1, 1, 0, 1, 1],arr2 = [1, 0, 1, 1, 1, 0, 0, 1, 1, 1]) == [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 0, 1, 0, 1, 1, 1, 0, 1],arr2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 1]) == [1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1, 0],arr2 = [1, 0, 1, 1, 0]) == [1, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 1, 0, 0, 0, 1],arr2 = [1, 0, 0, 0, 1, 0, 0, 0, 1]) == [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1],arr2 = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1]) == [1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0],arr2 = [0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 0, 0, 0, 1, 1],arr2 = [1, 0, 1, 1, 1, 0, 0, 0]) == [1, 1, 0, 0, 0, 1, 1, 0, 1, 1]\n assert candidate(arr1 = [1, 1, 0, 1, 0, 1],arr2 = [1, 0, 0, 0, 1, 0]) == [1, 1, 0, 1, 0, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1],arr2 = [1, 1, 0, 1, 0, 1]) == [1, 0, 1, 1, 1, 1, 0]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],arr2 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0, 1, 0],arr2 = [0, 1, 0, 1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 0, 1, 0, 1]) == [1, 1, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 0, 1, 1],arr2 = [1, 1, 1, 0, 0]) == [1, 0, 1, 1, 1]\n assert candidate(arr1 = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0],arr2 = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == [1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(arr1 = [1, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 0, 1],arr2 = [1, 0, 1, 0, 1]) == [1, 0]\n assert candidate(arr1 = [1, 1, 1, 0, 0, 1, 1, 0, 1],arr2 = [1, 0, 1, 1, 1, 0, 0, 0, 0]) == [1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1]\n assert candidate(arr1 = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],arr2 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == [1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1]\n", "comparison": "exact"}, "public_tests": ["[1,1,1,1,1]\n[1,0,1]", "[0]\n[0]", "[0]\n[1]"], "hints": ["We can try to determine the last digit of the answer, then divide everything by 2 and repeat."], "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().addNegabinary", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:47+00:00", "tests_total": 104, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def addNegabinary(self, arr1: list[int], arr2: list[int]) -> list[int]:", "container": "Solution", "callable": "addNegabinary", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1074, "task_id": "number-of-submatrices-that-sum-to-target", "difficulty": "Hard", "problem_description": "Given a matrix and a target, return the number of non-empty submatrices that sum to target.\n\nA submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2.\n\nTwo submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are different if they have some coordinate that is different: for example, if x1 != x1'.\n\nExample 1:\n\nInput: matrix = [[0,1,0],[1,1,1],[0,1,0]], target = 0\nOutput: 4\nExplanation: The four 1x1 submatrices that only contain 0.\n\nExample 2:\n\nInput: matrix = [[1,-1],[-1,1]], target = 0\nOutput: 5\nExplanation: The two 1x2 submatrices, plus the two 2x1 submatrices, plus the 2x2 submatrix.\n\nExample 3:\n\nInput: matrix = [[904]], target = 0\nOutput: 0\n\nConstraints:\n\n- 1 <= matrix.length <= 100\n- 1 <= matrix[0].length <= 100\n- -1000 <= matrix[i][j] <= 1000\n- -10^8 <= target <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1]],target = 1) == 1\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6]],target = 12) == 1\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]],target = -9) == 1\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],target = 0) == 36\n assert candidate(matrix = [[1, 2], [3, 4]],target = 3) == 2\n assert candidate(matrix = [[904]],target = 0) == 0\n assert candidate(matrix = [[1, -1, 0], [0, 0, 0], [0, 0, 0]],target = -1) == 6\n assert candidate(matrix = [[0, 1, 0], [1, 1, 1], [0, 1, 0]],target = 0) == 4\n assert candidate(matrix = [[1, -1], [-1, 1]],target = 0) == 5\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 15) == 4\n assert candidate(matrix = [[1, -1, 1, -1], [-1, 1, -1, 1], [1, -1, 1, -1], [-1, 1, -1, 1]],target = 0) == 64\n assert candidate(matrix = [[-1, 0, 1, -1, 1], [0, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]],target = 0) == 128\n assert candidate(matrix = [[5, 1, 2, 3], [1, 6, 4, 5], [2, 4, 7, 8], [3, 5, 8, 9]],target = 18) == 0\n assert candidate(matrix = [[1, -1, 1, -1], [1, -1, 1, -1], [-1, 1, -1, 1], [-1, 1, -1, 1]],target = 0) == 52\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8]],target = 10) == 2\n assert candidate(matrix = [[-1, 2, -3, 4], [-2, 3, -4, 5], [-3, 4, -5, 6], [-4, 5, -6, 7]],target = 10) == 0\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 45) == 2\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]],target = -3) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],target = 0) == 100\n assert candidate(matrix = [[-1, 1, -1], [1, -1, 1], [-1, 1, -1]],target = 0) == 20\n assert candidate(matrix = [[10, 20, 10], [20, 30, 20], [10, 20, 10]],target = 60) == 0\n assert candidate(matrix = [[1, 2], [2, 1], [1, 2], [2, 1]],target = 3) == 10\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6], [7, 8]],target = 10) == 2\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],target = 10) == 2\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 15) == 4\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = 21) == 4\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],target = 15) == 6\n assert candidate(matrix = [[5, 1, -2, 4], [2, 1, 0, 3], [-1, 3, -1, 2], [0, 2, 1, -1]],target = 3) == 10\n assert candidate(matrix = [[-1, 1, 2, -1], [1, 1, -1, 1], [-2, -2, 1, 2]],target = 0) == 8\n assert candidate(matrix = [[1000, -1000, 1000], [-1000, 1000, -1000], [1000, -1000, 1000]],target = 0) == 20\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],target = 4) == 17\n assert candidate(matrix = [[1, -2, 3], [-4, 5, -6], [7, -8, 9]],target = -5) == 2\n assert candidate(matrix = [[1, -1, 0], [0, 1, -1], [-1, 0, 1]],target = 0) == 19\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],target = 0) == 60\n assert candidate(matrix = [[-1, 2, -3, 4, 5], [2, -1, 3, -4, 6], [-3, 2, -1, 4, -5], [4, -3, 2, -1, 5]],target = 3) == 19\n assert candidate(matrix = [[1, 0, 1], [0, -1, 0], [1, 0, 1]],target = 2) == 4\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],target = 20) == 1\n assert candidate(matrix = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],target = 6) == 8\n assert candidate(matrix = [[5, -1, 3], [-3, 0, 5], [3, -2, -1]],target = 4) == 3\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],target = 0) == 100\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],target = -15) == 4\n assert candidate(matrix = [[5, -4, -3, 4], [-3, -4, 4, 5], [5, 1, 5, -4]],target = 5) == 6\n assert candidate(matrix = [[-10, 20, -30], [40, -50, 60], [-70, 80, -90]],target = -50) == 2\n assert candidate(matrix = [[-1, 0, 1], [2, 3, 4], [5, 6, 7]],target = 10) == 0\n assert candidate(matrix = [[1, -2, 3, -4], [-4, 3, -2, 1], [2, -3, 4, -5], [-5, 4, -3, 2]],target = -6) == 4\n assert candidate(matrix = [[0, 1, 2], [3, 4, 5], [6, 7, 8]],target = 12) == 3\n assert candidate(matrix = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]],target = 1) == 40\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],target = 25) == 0\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 30) == 0\n assert candidate(matrix = [[10, -10, 20, -20], [-10, 10, -20, 20], [20, -20, 30, -30], [-20, 20, -30, 30]],target = 0) == 52\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],target = 150) == 4\n assert candidate(matrix = [[1, -2, 3, -4, 5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20]],target = 5) == 10\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],target = 60) == 3\n assert candidate(matrix = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = 15) == 6\n assert candidate(matrix = [[0, 1, 0], [1, 1, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]],target = 1) == 33\n assert candidate(matrix = [[1, 0, -1, 1], [2, 3, 2, -1], [-1, -1, -1, -1], [1, 1, 1, 1]],target = 1) == 18\n assert candidate(matrix = [[-10, -20, -30], [-20, -30, -40], [-30, -40, -50]],target = -70) == 4\n assert candidate(matrix = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],target = 2) == 8\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],target = 30) == 4\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],target = 1500) == 4\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [-13, 14, -15, 16]],target = 0) == 9\n assert candidate(matrix = [[1, 0, 1], [0, -2, 3]],target = 2) == 2\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],target = 150) == 4\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = 3) == 6\n assert candidate(matrix = [[1, 2, -3, 4], [-1, 0, 2, 1], [3, -2, 1, 4], [0, 1, -1, 2]],target = 5) == 4\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [4, 5, 6], [6, 5, 4]],target = 9) == 3\n assert candidate(matrix = [[-1, 2, 3], [-4, 5, -6], [7, -8, 9]],target = 5) == 3\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [5, -6, 7, -8, 9], [-9, 10, -11, 12, -13], [14, -15, 16, -17, 18], [-19, 20, -21, 22, -23]],target = 0) == 36\n assert candidate(matrix = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],target = 9) == 4\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],target = -15) == 4\n assert candidate(matrix = [[0, 1, 0], [1, 1, 1], [0, 1, 0], [1, 1, 1], [0, 1, 0]],target = 1) == 30\n assert candidate(matrix = [[1, 2, -1, -4, -20], [2, 3, -2, -3, -15], [3, 4, -3, -2, -10], [4, 5, -4, -1, -5]],target = -5) == 9\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 30) == 2\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],target = 24) == 3\n assert candidate(matrix = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],target = 70) == 4\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],target = 0) == 36\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],target = 10) == 2\n assert candidate(matrix = [[-1, 2, -3, 4], [2, -2, 1, 1], [-1, 3, -2, 2], [1, -1, 2, -2]],target = 0) == 16\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]],target = 2) == 56\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]],target = 1) == 16\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],target = 10) == 3\n assert candidate(matrix = [[1, -1, 1], [-1, 1, -1], [1, -1, 1]],target = 0) == 20\n", "comparison": "exact"}, "public_tests": ["[[0,1,0],[1,1,1],[0,1,0]]\n0", "[[1,-1],[-1,1]]\n0", "[[904]]\n0"], "hints": ["Using a 2D prefix sum, we can query the sum of any submatrix in O(1) time. Now for each (r1, r2), we can find the largest sum of a submatrix that uses every row in [r1, r2] in linear time using a sliding window."], "metadata": {"canonical_parameter_names": ["matrix", "target"], "leetcode_dataset_entry_point": "Solution().numSubmatrixSumTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:49+00:00", "tests_total": 82, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numSubmatrixSumTarget(self, matrix: list[list[int]], target: int) -> int:", "container": "Solution", "callable": "numSubmatrixSumTarget", "parameters": [{"name": "matrix", "type": "list[list[int]]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1078, "task_id": "occurrences-after-bigram", "difficulty": "Easy", "problem_description": "Given two strings first and second, consider occurrences in some text of the form \"first second third\", where second comes immediately after first, and third comes immediately after second.\n\nReturn an array of all the words third for each occurrence of \"first second third\".\n\nExample 1:\n\nInput: text = \"alice is a good girl she is a good student\", first = \"a\", second = \"good\"\nOutput: [\"girl\",\"student\"]\n\nExample 2:\n\nInput: text = \"we will we will rock you\", first = \"we\", second = \"will\"\nOutput: [\"we\",\"rock\"]\n\nConstraints:\n\n- 1 <= text.length <= 1000\n- text consists of lowercase English letters and spaces.\n- All the words in text are separated by a single space.\n- 1 <= first.length, second.length <= 10\n- first and second consist of lowercase English letters.\n- text will not have any leading or trailing spaces.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"hello world hello hello world\",first = \"hello\",second = \"world\") == ['hello']\n assert candidate(text = \"repeat repeat repeat repeat\",first = \"repeat\",second = \"repeat\") == ['repeat', 'repeat']\n assert candidate(text = \"look at the stars look at the moon\",first = \"look\",second = \"at\") == ['the', 'the']\n assert candidate(text = \"in the beginning there was the word\",first = \"the\",second = \"beginning\") == ['there']\n assert candidate(text = \"this is a test this is only a test\",first = \"this\",second = \"is\") == ['a', 'only']\n assert candidate(text = \"one two three two three four three five\",first = \"two\",second = \"three\") == ['two', 'four']\n assert candidate(text = \"every good boy does fine every good boy does fine\",first = \"good\",second = \"boy\") == ['does', 'does']\n assert candidate(text = \"alice is a good girl she is a good student\",first = \"a\",second = \"good\") == ['girl', 'student']\n assert candidate(text = \"we will we will rock you\",first = \"we\",second = \"will\") == ['we', 'rock']\n assert candidate(text = \"foo bar foo bar foo\",first = \"foo\",second = \"bar\") == ['foo', 'foo']\n assert candidate(text = \"in a village of la mancha the name of which i have no desire to call to mind\",first = \"village\",second = \"of\") == ['la']\n assert candidate(text = \"this is a test this is only a test\",first = \"is\",second = \"a\") == ['test']\n assert candidate(text = \"foo bar foo foo bar bar foo\",first = \"foo\",second = \"bar\") == ['foo', 'bar']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",first = \"the\",second = \"lazy\") == ['dog']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the quick brown fox jumps over the lazy dog\",first = \"quick\",second = \"brown\") == ['fox', 'fox']\n assert candidate(text = \"a b c a b c a b c a b c a b c a b c\",first = \"a\",second = \"b\") == ['c', 'c', 'c', 'c', 'c', 'c']\n assert candidate(text = \"repeat repeat repeat repeat repeat repeat repeat repeat repeat\",first = \"repeat\",second = \"repeat\") == ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat']\n assert candidate(text = \"one two three four five six seven eight nine ten eleven twelve\",first = \"five\",second = \"six\") == ['seven']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the quick brown fox\",first = \"quick\",second = \"brown\") == ['fox', 'fox']\n assert candidate(text = \"a tale of two cities a tale of two brothers a tale of two sisters\",first = \"tale\",second = \"of\") == ['two', 'two', 'two']\n assert candidate(text = \"once upon a time in a land far far away once upon a time in a magical land\",first = \"once\",second = \"upon\") == ['a', 'a']\n assert candidate(text = \"this is a simple test this is a more complex test this is a simple test\",first = \"is\",second = \"a\") == ['simple', 'more', 'simple']\n assert candidate(text = \"the rain in spain stays mainly in the plain the rain in spain\",first = \"rain\",second = \"in\") == ['spain', 'spain']\n assert candidate(text = \"one fish two fish red fish blue fish one fish two fish red fish blue fish\",first = \"fish\",second = \"red\") == ['fish', 'fish']\n assert candidate(text = \"one two three four five six seven eight nine ten one two three four five six\",first = \"three\",second = \"four\") == ['five', 'five']\n assert candidate(text = \"x y z x y z x y z x y z x y z x y z x y z x y z\",first = \"x\",second = \"y\") == ['z', 'z', 'z', 'z', 'z', 'z', 'z', 'z']\n assert candidate(text = \"this is a simple sentence to test the function this is a simple test\",first = \"simple\",second = \"sentence\") == ['to']\n assert candidate(text = \"a a a a a a a a a a a a a a a a a a a a a\",first = \"a\",second = \"a\") == ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']\n assert candidate(text = \"once upon a time in a land far far away once upon a time\",first = \"once\",second = \"upon\") == ['a', 'a']\n assert candidate(text = \"repeated repeated repeated repeated repeated repeated\",first = \"repeated\",second = \"repeated\") == ['repeated', 'repeated', 'repeated', 'repeated']\n assert candidate(text = \"abc def ghi jkl mno pqr stu vwx yz abc def ghi jkl mno\",first = \"def\",second = \"ghi\") == ['jkl', 'jkl']\n assert candidate(text = \"a b c a b c a b c a b c a b c a b c a b c a b c a b c a b c\",first = \"a\",second = \"b\") == ['c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c']\n assert candidate(text = \"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\",first = \"a\",second = \"b\") == ['c', 'c']\n assert candidate(text = \"this is a simple test case this is a very simple test case\",first = \"is\",second = \"a\") == ['simple', 'very']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the quick brown fox jumps\",first = \"quick\",second = \"brown\") == ['fox', 'fox']\n assert candidate(text = \"once upon a time in a land far far away once upon a time in a land\",first = \"once\",second = \"upon\") == ['a', 'a']\n assert candidate(text = \"find these occurrences carefully find these occurrences again find these occurrences one more time\",first = \"find\",second = \"these\") == ['occurrences', 'occurrences', 'occurrences']\n assert candidate(text = \"a quick movement of the enemy will jeopardize six gunboats a quick and silent movement of the enemy will jeopardize five gunboats\",first = \"quick\",second = \"and\") == ['silent']\n assert candidate(text = \"complex example with multiple matches and no matches complex example with multiple matches and no matches\",first = \"with\",second = \"multiple\") == ['matches', 'matches']\n assert candidate(text = \"she sells sea shells by the sea shore she sells sea shells by the sea shore\",first = \"sea\",second = \"shells\") == ['by', 'by']\n assert candidate(text = \"complex scenario with different words complex scenario with different words complex\",first = \"with\",second = \"different\") == ['words', 'words']\n assert candidate(text = \"repeated repeated repeated words words words in a sentence\",first = \"words\",second = \"in\") == ['a']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the quick brown fox jumps over the quick brown fox\",first = \"quick\",second = \"brown\") == ['fox', 'fox', 'fox']\n assert candidate(text = \"x y z a b c x y z a b c x y z a b c x y z a b c\",first = \"x\",second = \"y\") == ['z', 'z', 'z', 'z']\n assert candidate(text = \"word word word word word word word word word word word word word word word word word word word word\",first = \"word\",second = \"word\") == ['word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word', 'word']\n assert candidate(text = \"edge case where the last word is the second\",first = \"second\",second = \"word\") == []\n assert candidate(text = \"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\",first = \"f\",second = \"g\") == ['h', 'h']\n assert candidate(text = \"the cat sat on the mat the dog sat on the log the cat sat on the mat the dog sat on the log\",first = \"sat\",second = \"on\") == ['the', 'the', 'the', 'the']\n assert candidate(text = \"hello there hello there hello there hello there hello there\",first = \"hello\",second = \"there\") == ['hello', 'hello', 'hello', 'hello']\n assert candidate(text = \"one fish two fish red fish blue fish one fish two fish red fish blue fish\",first = \"two\",second = \"fish\") == ['red', 'red']\n assert candidate(text = \"repeat after me repeat after me repeat after me repeat after me\",first = \"repeat\",second = \"after\") == ['me', 'me', 'me', 'me']\n assert candidate(text = \"one two three four five six seven eight nine ten eleven twelve\",first = \"three\",second = \"four\") == ['five']\n assert candidate(text = \"in the heart of the night the old owl hooted and the stars twinkled in the dark\",first = \"the\",second = \"old\") == ['owl']\n assert candidate(text = \"finding the third word after first second finding the third word after first\",first = \"finding\",second = \"the\") == ['third', 'third']\n assert candidate(text = \"find the pattern in this text pattern in this text pattern in this text pattern\",first = \"pattern\",second = \"in\") == ['this', 'this', 'this']\n assert candidate(text = \"a longer sentence with a variety of words and phrases to test the function properly\",first = \"variety\",second = \"of\") == ['words']\n assert candidate(text = \"she sells sea shells by the sea shore and the shells she sells are sea shells\",first = \"sea\",second = \"shells\") == ['by']\n assert candidate(text = \"example of a longer sentence where the pattern can be found multiple times example of a longer\",first = \"example\",second = \"of\") == ['a', 'a']\n assert candidate(text = \"multiple words in sequence are repeated multiple times multiple words in sequence\",first = \"multiple\",second = \"words\") == ['in', 'in']\n assert candidate(text = \"abc def ghi jkl mno pqr stu vwx yza abc def ghi jkl mno pqr stu vwx yza\",first = \"ghi\",second = \"jkl\") == ['mno', 'mno']\n assert candidate(text = \"abc abc abc abc abc abc abc abc abc abc\",first = \"abc\",second = \"abc\") == ['abc', 'abc', 'abc', 'abc', 'abc', 'abc', 'abc', 'abc']\n assert candidate(text = \"a quick movement of the enemy will jeopardize five gunboats a quick movement of the army will jeopardize five gunboats\",first = \"quick\",second = \"movement\") == ['of', 'of']\n assert candidate(text = \"a quick movement of the enemy will jeopardize six gunboats a quick movement of the enemy will jeopardize five gunboats\",first = \"quick\",second = \"movement\") == ['of', 'of']\n assert candidate(text = \"complex pattern with complex pattern and another complex pattern\",first = \"complex\",second = \"pattern\") == ['with', 'and']\n assert candidate(text = \"a b c a b c a b c a b c a b c\",first = \"a\",second = \"b\") == ['c', 'c', 'c', 'c', 'c']\n assert candidate(text = \"this is a simple test to see if the function works correctly with multiple occurrences of first second third\",first = \"first\",second = \"second\") == ['third']\n assert candidate(text = \"once upon a time in a galaxy far far away once upon a time in a galaxy\",first = \"once\",second = \"upon\") == ['a', 'a']\n assert candidate(text = \"cycling in the mountains mountains are beautiful cycling in the mountains\",first = \"cycling\",second = \"in\") == ['the', 'the']\n assert candidate(text = \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\",first = \"one\",second = \"two\") == ['three']\n assert candidate(text = \"this is a simple sentence with multiple occurrences of the same word word\",first = \"the\",second = \"same\") == ['word']\n assert candidate(text = \"if you are reading this text then you are doing a great job reading\",first = \"reading\",second = \"this\") == ['text']\n assert candidate(text = \"this is a simple test case with multiple matches this is a simple test\",first = \"this\",second = \"is\") == ['a', 'a']\n assert candidate(text = \"to be or not to be that is the question to be or not to be that is the question\",first = \"be\",second = \"or\") == ['not', 'not']\n assert candidate(text = \"in the heart of the city in the heart of the heart in the heart of the city\",first = \"heart\",second = \"of\") == ['the', 'the', 'the']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the lazy dog jumps over the quick brown fox\",first = \"the\",second = \"lazy\") == ['dog', 'dog']\n assert candidate(text = \"this is a simple test this is a simple test this is a simple test\",first = \"is\",second = \"a\") == ['simple', 'simple', 'simple']\n assert candidate(text = \"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\",first = \"a\",second = \"b\") == ['c', 'c']\n assert candidate(text = \"last two words do not match first second\",first = \"first\",second = \"second\") == []\n assert candidate(text = \"every good boy does fine every good boy does fine every good boy does fine\",first = \"good\",second = \"boy\") == ['does', 'does', 'does']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the quick brown fox jumps over the lazy dog again\",first = \"quick\",second = \"brown\") == ['fox', 'fox']\n assert candidate(text = \"repeat repeat repeat repeat repeat repeat repeat\",first = \"repeat\",second = \"repeat\") == ['repeat', 'repeat', 'repeat', 'repeat', 'repeat']\n assert candidate(text = \"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\",first = \"x\",second = \"y\") == ['z']\n assert candidate(text = \"the quick brown fox jumps over the lazy dog the quick brown fox is quick\",first = \"quick\",second = \"brown\") == ['fox', 'fox']\n assert candidate(text = \"cycling through the words cycling through the words cycling\",first = \"through\",second = \"the\") == ['words', 'words']\n assert candidate(text = \"a b c a b c 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\",first = \"b\",second = \"c\") == ['a', 'a', 'd']\n assert candidate(text = \"she sells sea shells by the sea shore she sells sea shells\",first = \"sea\",second = \"shells\") == ['by']\n assert candidate(text = \"hello world hello world hello world hello world hello world hello world\",first = \"hello\",second = \"world\") == ['hello', 'hello', 'hello', 'hello', 'hello']\n assert candidate(text = \"consecutive consecutive words words words words in this sequence sequence\",first = \"words\",second = \"words\") == ['words', 'words', 'in']\n assert candidate(text = \"complex sentence with multiple occurrences of first second third first second third\",first = \"first\",second = \"second\") == ['third', 'third']\n assert candidate(text = \"every good boy does fine every good boy does fine every good boy does fine\",first = \"every\",second = \"good\") == ['boy', 'boy', 'boy']\n assert candidate(text = \"this is a test this is only a test this is a test this is a test\",first = \"this\",second = \"is\") == ['a', 'only', 'a', 'a']\n assert candidate(text = \"repeat repeat repeat repeat repeat repeat\",first = \"repeat\",second = \"repeat\") == ['repeat', 'repeat', 'repeat', 'repeat']\n assert candidate(text = \"repeated repeated repeated repeated repeated repeated repeated repeated\",first = \"repeated\",second = \"repeated\") == ['repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated']\n assert candidate(text = \"aa bb aa bb aa bb aa bb aa bb aa bb\",first = \"aa\",second = \"bb\") == ['aa', 'aa', 'aa', 'aa', 'aa']\n assert candidate(text = \"a quick movement of the enemy will jeopardize six gunboats a quick movement of the enemy will jeopardize six gunboats\",first = \"movement\",second = \"of\") == ['the', 'the']\n assert candidate(text = \"x y z x y z x y z x y z x y z x y z x y z x y z x y z x y z x y z\",first = \"y\",second = \"z\") == ['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']\n assert candidate(text = \"this is a test this is only a test in case of an actual emergency this is a test\",first = \"this\",second = \"is\") == ['a', 'only', 'a']\n assert candidate(text = \"to be or not to be that is the question to be or not to be\",first = \"to\",second = \"be\") == ['or', 'that', 'or']\n", "comparison": "exact"}, "public_tests": ["\"alice is a good girl she is a good student\"\n\"a\"\n\"good\"", "\"we will we will rock you\"\n\"we\"\n\"will\""], "hints": ["Split the string into words, then look at adjacent triples of words."], "metadata": {"canonical_parameter_names": ["text", "first", "second"], "leetcode_dataset_entry_point": "Solution().findOcurrences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:51+00:00", "tests_total": 101, "tests_dropped": 3, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def findOcurrences(self, text: str, first: str, second: str) -> list[str]:", "container": "Solution", "callable": "findOcurrences", "parameters": [{"name": "text", "type": "str"}, {"name": "first", "type": "str"}, {"name": "second", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1079, "task_id": "letter-tile-possibilities", "difficulty": "Medium", "problem_description": "You have n tiles, where each tile has one letter tiles[i] printed on it.\n\nReturn the number of possible non-empty sequences of letters you can make using the letters printed on those tiles.\n\nExample 1:\n\nInput: tiles = \"AAB\"\nOutput: 8\nExplanation: The possible sequences are \"A\", \"B\", \"AA\", \"AB\", \"BA\", \"AAB\", \"ABA\", \"BAA\".\n\nExample 2:\n\nInput: tiles = \"AAABBC\"\nOutput: 188\n\nExample 3:\n\nInput: tiles = \"V\"\nOutput: 1\n\nConstraints:\n\n- 1 <= tiles.length <= 7\n- tiles consists of uppercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tiles = \"AAAAAAA\") == 7\n assert candidate(tiles = \"QQQ\") == 3\n assert candidate(tiles = \"ABCDEFG\") == 13699\n assert candidate(tiles = \"ABC\") == 15\n assert candidate(tiles = \"AAB\") == 8\n assert candidate(tiles = \"AABBCC\") == 270\n assert candidate(tiles = \"XYZ\") == 15\n assert candidate(tiles = \"AAABBC\") == 188\n assert candidate(tiles = \"AB\") == 4\n assert candidate(tiles = \"AAAAAA\") == 6\n assert candidate(tiles = \"ABCD\") == 64\n assert candidate(tiles = \"V\") == 1\n assert candidate(tiles = \"ABBB\") == 13\n assert candidate(tiles = \"AAA\") == 3\n assert candidate(tiles = \"AABC\") == 34\n assert candidate(tiles = \"UVWXYZ\") == 1956\n assert candidate(tiles = \"ZZZZZZZ\") == 7\n assert candidate(tiles = \"XYZXYZ\") == 270\n assert candidate(tiles = \"AABBCD\") == 522\n assert candidate(tiles = \"HELLO\") == 170\n assert candidate(tiles = \"ABCDABC\") == 1840\n assert candidate(tiles = \"AABBCCD\") == 1840\n assert candidate(tiles = \"ABCDEFF\") == 7012\n assert candidate(tiles = \"REPEAT\") == 1010\n assert candidate(tiles = \"WWWWW\") == 5\n assert candidate(tiles = \"AABBBCC\") == 649\n assert candidate(tiles = \"QQQQQQQ\") == 7\n assert candidate(tiles = \"ABCXYZ\") == 1956\n assert candidate(tiles = \"PYTHON\") == 1956\n assert candidate(tiles = \"AABCCD\") == 522\n assert candidate(tiles = \"ABCDEF\") == 1956\n assert candidate(tiles = \"XYZABC\") == 1956\n assert candidate(tiles = \"ABCDE\") == 325\n assert candidate(tiles = \"AABCDD\") == 522\n assert candidate(tiles = \"UNIQUE\") == 1010\n assert candidate(tiles = \"TILES\") == 325\n", "comparison": "exact"}, "public_tests": ["\"AAB\"", "\"AAABBC\"", "\"V\""], "hints": ["Try to build the string with a backtracking DFS by considering what you can put in every position."], "metadata": {"canonical_parameter_names": ["tiles"], "leetcode_dataset_entry_point": "Solution().numTilePossibilities", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:53+00:00", "tests_total": 74, "tests_dropped": 38, "flags": [], "topic_tags": ["hash-table", "string", "backtracking", "counting"]}, "language": "python", "interface": {"raw_signature": "def numTilePossibilities(self, tiles: str) -> int:", "container": "Solution", "callable": "numTilePossibilities", "parameters": [{"name": "tiles", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1081, "task_id": "smallest-subsequence-of-distinct-characters", "difficulty": "Medium", "problem_description": "Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.\n\nExample 1:\n\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\n\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s consists of lowercase English letters.\n\nNote: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"rakuqjeiaxeidqqeaeiaxqeaeiaxjeidqq\") == \"rakudeiqxj\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"cccaae\") == \"cae\"\n assert candidate(s = \"cbacdcbc\") == \"acdb\"\n assert candidate(s = \"abacabadabc\") == \"abcd\"\n assert candidate(s = \"thesqskillqy\") == \"theqskily\"\n assert candidate(s = \"leetcode\") == \"letcod\"\n assert candidate(s = \"thesqpie\") == \"thesqpi\"\n assert candidate(s = \"example\") == \"exampl\"\n assert candidate(s = \"sequence\") == \"sequnc\"\n assert candidate(s = \"npxldumzcd\") == \"npxldumzc\"\n assert candidate(s = \"rakwsmggxvbrmgypwk\") == \"aksgxvbrmypw\"\n assert candidate(s = \"zyxzyxzyx\") == \"xyz\"\n assert candidate(s = \"distinct\") == \"disnct\"\n assert candidate(s = \"abcd\") == \"abcd\"\n assert candidate(s = \"bcabc\") == \"abc\"\n assert candidate(s = \"ecbacba\") == \"eacb\"\n assert candidate(s = \"aabbcc\") == \"abc\"\n assert candidate(s = \"abcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"thesqtkwzyetipaswz\") == \"heqkwytipasz\"\n assert candidate(s = \"thesqtax\") == \"hesqtax\"\n assert candidate(s = \"crad\") == \"crad\"\n assert candidate(s = \"character\") == \"charte\"\n assert candidate(s = \"srzgp\") == \"srzgp\"\n assert candidate(s = \"nnnn\") == \"n\"\n assert candidate(s = \"subsequence\") == \"bsequnc\"\n assert candidate(s = \"indegree\") == \"indegr\"\n assert candidate(s = \"theskyisblue\") == \"thekyisblu\"\n assert candidate(s = \"thisisaverylongstringwithmanycharactersrepeatedmultipletimes\") == \"aveloginwhmycrdupts\"\n assert candidate(s = \"abracadabra\") == \"abcdr\"\n assert candidate(s = \"uniquecharacters\") == \"niquchartes\"\n assert candidate(s = \"swiss\") == \"swi\"\n assert candidate(s = \"iwanttofly\") == \"iwantofly\"\n assert candidate(s = \"repetition\") == \"repiton\"\n assert candidate(s = \"cbacdcbcacdcbcacdcbc\") == \"abcd\"\n assert candidate(s = \"abcdabcdabcd\") == \"abcd\"\n assert candidate(s = \"elephantzoo\") == \"elphantzo\"\n assert candidate(s = \"algorithm\") == \"algorithm\"\n assert candidate(s = \"hello\") == \"helo\"\n assert candidate(s = \"aaaaabbbbbccccdddd\") == \"abcd\"\n assert candidate(s = \"substring\") == \"subtring\"\n assert candidate(s = \"sphinxofblackquartzjumpsverilyzippyfidgetsbymywyrm\") == \"hinxoackqjumpsvelyzfdgtbwr\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog\") == \"adeqickbownfxjumpsvrthlzyg\"\n assert candidate(s = \"alphabet\") == \"alphbet\"\n assert candidate(s = \"abcdabcdeabcde\") == \"abcde\"\n assert candidate(s = \"zxyxzyzyxyzzyxzy\") == \"xyz\"\n assert candidate(s = \"abcdcba\") == \"abcd\"\n assert candidate(s = \"abcdeedcbaedcba\") == \"abcde\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"abcdabcde\") == \"abcde\"\n assert candidate(s = \"allcharactersareunique\") == \"alchrtesniqu\"\n assert candidate(s = \"aebabdce\") == \"abdce\"\n assert candidate(s = \"abcdabcdbdabcdabcd\") == \"abcd\"\n assert candidate(s = \"nmlkjihgfedcba\") == \"nmlkjihgfedcba\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == \"qwertyuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"xyzxyzxyz\") == \"xyz\"\n assert candidate(s = \"leetcodeleet\") == \"codelt\"\n assert candidate(s = \"theswiftbrownfoxjumpsoverthelazydog\") == \"eibownfxjumpsvrthlazydg\"\n assert candidate(s = \"ababababababababab\") == \"ab\"\n assert candidate(s = \"nctzggabcddcba\") == \"nctzgabd\"\n assert candidate(s = \"ananananananananananananananananananananananananananan\") == \"an\"\n assert candidate(s = \"programmingisfun\") == \"pograminsfu\"\n assert candidate(s = \"sivisoitnsidvsnoovsinovsdinovnsidvsindvsiodinvsiodinvson\") == \"iotdnsv\"\n assert candidate(s = \"paper\") == \"aper\"\n assert candidate(s = \"characters\") == \"chartes\"\n assert candidate(s = \"ecbacbacba\") == \"eabc\"\n assert candidate(s = \"abcdabcdabcdabcd\") == \"abcd\"\n assert candidate(s = \"programming\") == \"pogramin\"\n assert candidate(s = \"repeatedcharactersaaaabbccddeeff\") == \"epachrtsbdf\"\n assert candidate(s = \"abababababababababab\") == \"ab\"\n assert candidate(s = \"cbacdcbcde\") == \"abcde\"\n assert candidate(s = \"leetcodelite\") == \"codelit\"\n assert candidate(s = \"rwrwrwxyz\") == \"rwxyz\"\n assert candidate(s = \"abacabadabcabcabcabcdabcdabcde\") == \"abcde\"\n assert candidate(s = \"backtracking\") == \"backtring\"\n assert candidate(s = \"evolving\") == \"eolving\"\n assert candidate(s = \"thesamecharacterrepeats\") == \"amcherpts\"\n assert candidate(s = \"abcdabdcab\") == \"abcd\"\n assert candidate(s = \"abacabadabcdeabcdeabacabad\") == \"abcde\"\n assert candidate(s = \"abcdabcdeabcd\") == \"abcde\"\n assert candidate(s = \"xxyyzzxxzzyyxzyxzyzzyyzzyzyz\") == \"xyz\"\n assert candidate(s = \"banana\") == \"ban\"\n assert candidate(s = \"combinatorial\") == \"cmbinatorl\"\n assert candidate(s = \"zzzzyyyyxxxwvvvutttssrrqqppoonnmmllkkjjiihhhggffeeddccbbaa\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"eleetcode\") == \"eltcod\"\n assert candidate(s = \"elephanttree\") == \"elphantr\"\n assert candidate(s = \"elephant\") == \"elphant\"\n assert candidate(s = \"aabbccddeeffgg\") == \"abcdefg\"\n assert candidate(s = \"abcdabcdeabcdefabcdefgabcdefghabcdefghijkabcdefghijk\") == \"abcdefghijk\"\n assert candidate(s = \"aabbcceedd\") == \"abced\"\n assert candidate(s = \"rhythm\") == \"rhytm\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcd\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"bcbcbcbcbc\") == \"bc\"\n assert candidate(s = \"characterswithunequalfrequency\") == \"acerswithlfquny\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\") == \"eqickbownfxjumpsvrthlazydg\"\n assert candidate(s = \"aaaabbbbccccdddd\") == \"abcd\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbbcccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdedcba\") == \"abcde\"\n assert candidate(s = \"complexproblem\") == \"cexproblm\"\n assert candidate(s = \"zyxzyzyxzyx\") == \"xyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"lexicographical\") == \"excographil\"\n assert candidate(s = \"abcdefghihgfedcba\") == \"abcdefghi\"\n assert candidate(s = \"racecar\") == \"acer\"\n assert candidate(s = \"qpwoeirutyalskdfjhgfcxzvbnm\") == \"qpwoeirutyalskdfjhgcxzvbnm\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"rithmschool\") == \"rithmscol\"\n assert candidate(s = \"dynamicprogramming\") == \"dyacpogrmin\"\n assert candidate(s = \"interviewquestion\") == \"erviwquston\"\n assert candidate(s = \"abcdabcdeabcdeabcde\") == \"abcde\"\n assert candidate(s = \"thisisaverylongstringwithmanycharactersandmanyrepeatedcharacters\") == \"aveloginwcdmyphrts\"\n assert candidate(s = \"thisisatest\") == \"hiaest\"\n assert candidate(s = \"mississippi\") == \"misp\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"azyxwvutsrqponmlkjihgfedcb\"\n assert candidate(s = \"permutation\") == \"permuation\"\n assert candidate(s = \"xyzzzyxyzzzyxyzzzyxyzzzy\") == \"xyz\"\n assert candidate(s = \"aabbbcccddd\") == \"abcd\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n", "comparison": "exact"}, "public_tests": ["\"bcabc\"", "\"cbacdcbc\""], "hints": ["Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().smallestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:09:58+00:00", "tests_total": 124, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "stack", "greedy", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def smallestSubsequence(self, s: str) -> str:", "container": "Solution", "callable": "smallestSubsequence", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1090, "task_id": "largest-values-from-labels", "difficulty": "Medium", "problem_description": "You are given n item's value and label as two integer arrays values and labels. You are also given two integers numWanted and useLimit.\n\nYour task is to find a subset of items with the maximum sum of their values such that:\n\n- The number of items is at most numWanted.\n- The number of items with the same label is at most useLimit.\n\nReturn the maximum sum.\n\nExample 1:\n\nInput: values = [5,4,3,2,1], labels = [1,1,2,2,3], numWanted = 3, useLimit = 1\nOutput: 9\nExplanation:\nThe subset chosen is the first, third, and fifth items with the sum of values 5 + 3 + 1.\n\nExample 2:\n\nInput: values = [5,4,3,2,1], labels = [1,3,3,3,2], numWanted = 3, useLimit = 2\nOutput: 12\nExplanation:\nThe subset chosen is the first, second, and third items with the sum of values 5 + 4 + 3.\n\nExample 3:\n\nInput: values = [9,8,8,7,6], labels = [0,0,0,1,1], numWanted = 3, useLimit = 1\nOutput: 16\nExplanation:\nThe subset chosen is the first and fourth items with the sum of values 9 + 7.\n\nConstraints:\n\n- n == values.length == labels.length\n- 1 <= n <= 2 * 10^4\n- 0 <= values[i], labels[i] <= 2 * 10^4\n- 1 <= numWanted, useLimit <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [10, 10, 10, 10],labels = [1, 1, 1, 1],numWanted = 3,useLimit = 2) == 20\n assert candidate(values = [10, 10, 10, 10],labels = [1, 2, 3, 4],numWanted = 4,useLimit = 1) == 40\n assert candidate(values = [9, 8, 8, 7, 6],labels = [0, 0, 0, 1, 1],numWanted = 3,useLimit = 1) == 16\n assert candidate(values = [10, 20, 30, 40, 50],labels = [1, 2, 3, 4, 5],numWanted = 5,useLimit = 1) == 150\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 40\n assert candidate(values = [10, 20, 30, 40, 50],labels = [1, 1, 1, 1, 1],numWanted = 3,useLimit = 2) == 90\n assert candidate(values = [1, 2, 3, 4, 5],labels = [1, 1, 1, 1, 1],numWanted = 3,useLimit = 1) == 5\n assert candidate(values = [1, 2, 3, 4, 5],labels = [1, 2, 3, 4, 5],numWanted = 5,useLimit = 1) == 15\n assert candidate(values = [5, 4, 3, 2, 1],labels = [1, 3, 3, 3, 2],numWanted = 3,useLimit = 2) == 12\n assert candidate(values = [5, 4, 3, 2, 1],labels = [1, 1, 2, 2, 3],numWanted = 3,useLimit = 1) == 9\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 2) == 19\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 400\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 5,useLimit = 2) == 2800\n assert candidate(values = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],labels = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],numWanted = 5,useLimit = 2) == 80\n assert candidate(values = [5, 10, 15, 20, 25, 30],labels = [1, 2, 1, 3, 2, 3],numWanted = 4,useLimit = 2) == 90\n assert candidate(values = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 1937\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],labels = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3],numWanted = 6,useLimit = 3) == 220\n assert candidate(values = [25, 25, 25, 25, 25, 25],labels = [1, 1, 1, 1, 1, 1],numWanted = 4,useLimit = 1) == 25\n assert candidate(values = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 8,useLimit = 2) == 120\n assert candidate(values = [30, 20, 10, 30, 20, 10, 30, 20, 10],labels = [1, 2, 3, 1, 2, 3, 1, 2, 3],numWanted = 5,useLimit = 2) == 110\n assert candidate(values = [3, 5, 1, 3, 5, 3, 5, 3, 5, 3],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],numWanted = 6,useLimit = 2) == 18\n assert candidate(values = [10, 20, 30, 40, 50],labels = [1, 1, 1, 1, 2],numWanted = 3,useLimit = 2) == 120\n assert candidate(values = [50, 40, 30, 20, 10],labels = [1, 2, 2, 3, 3],numWanted = 4,useLimit = 1) == 110\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 10,useLimit = 2) == 39\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],numWanted = 5,useLimit = 2) == 40\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],numWanted = 8,useLimit = 2) == 57\n assert candidate(values = [20, 18, 17, 16, 15, 14, 13, 12, 11, 10],labels = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],numWanted = 4,useLimit = 1) == 71\n assert candidate(values = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],numWanted = 10,useLimit = 3) == 105\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 1) == 100\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],numWanted = 5,useLimit = 1) == 19\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2],numWanted = 8,useLimit = 2) == 680\n assert candidate(values = [10000, 10000, 9999, 9999, 9998, 9998, 9997, 9997, 9996, 9996],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],numWanted = 8,useLimit = 2) == 79988\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 15,useLimit = 3) == 195\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1],numWanted = 3,useLimit = 1) == 17\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5],numWanted = 5,useLimit = 2) == 35\n assert candidate(values = [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],labels = [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],numWanted = 15,useLimit = 2) == 270\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 10,useLimit = 1) == 55\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 3,useLimit = 1) == 100\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 6,useLimit = 3) == 390\n assert candidate(values = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 15,useLimit = 2) == 195\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 7,useLimit = 1) == 49\n assert candidate(values = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 2) == 38\n assert candidate(values = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],numWanted = 15,useLimit = 3) == 138\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 1) == 1\n assert candidate(values = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],numWanted = 6,useLimit = 3) == 90\n assert candidate(values = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 8,useLimit = 1) == 80\n assert candidate(values = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 8,useLimit = 3) == 60\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 10) == 400\n assert candidate(values = [100, 50, 200, 150, 100],labels = [1, 2, 1, 2, 1],numWanted = 2,useLimit = 1) == 350\n assert candidate(values = [10, 20, 30, 40, 50],labels = [1, 1, 2, 2, 3],numWanted = 2,useLimit = 1) == 90\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],labels = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3],numWanted = 6,useLimit = 2) == 30\n assert candidate(values = [25, 20, 15, 10, 5],labels = [1, 2, 3, 4, 5],numWanted = 3,useLimit = 1) == 60\n assert candidate(values = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 75\n assert candidate(values = [20, 15, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19],labels = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],numWanted = 10,useLimit = 3) == 147\n assert candidate(values = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],numWanted = 8,useLimit = 3) == 84\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],numWanted = 5,useLimit = 2) == 34\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9],numWanted = 3,useLimit = 1) == 24\n assert candidate(values = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10],labels = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],numWanted = 5,useLimit = 2) == 210\n assert candidate(values = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],numWanted = 10,useLimit = 2) == 105\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 25\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 3) == 35\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 1) == 100\n assert candidate(values = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 8,useLimit = 1) == 16\n assert candidate(values = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4],numWanted = 7,useLimit = 2) == 40\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5],labels = [1, 2, 3, 4, 5, 6, 7, 8],numWanted = 6,useLimit = 1) == 30\n assert candidate(values = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 2) == 38\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 5,useLimit = 3) == 360\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 10,useLimit = 1) == 550\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [0, 1, 0, 1, 0, 1, 0, 1, 0],numWanted = 4,useLimit = 1) == 17\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],numWanted = 8,useLimit = 3) == 75\n assert candidate(values = [15, 10, 10, 5, 5, 5, 5],labels = [1, 1, 2, 2, 2, 3, 3],numWanted = 5,useLimit = 2) == 45\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 7,useLimit = 1) == 35\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],numWanted = 10,useLimit = 3) == 131\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [0, 1, 0, 1, 0, 1, 0, 1, 0],numWanted = 5,useLimit = 2) == 30\n assert candidate(values = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 50\n assert candidate(values = [15, 12, 11, 10, 9, 8],labels = [1, 1, 2, 2, 3, 3],numWanted = 4,useLimit = 2) == 48\n assert candidate(values = [500, 400, 300, 200, 100],labels = [1, 2, 3, 4, 5],numWanted = 3,useLimit = 1) == 1200\n assert candidate(values = [100, 80, 60, 40, 20],labels = [1, 1, 1, 1, 1],numWanted = 5,useLimit = 3) == 240\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],numWanted = 6,useLimit = 2) == 450\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 7,useLimit = 3) == 490\n assert candidate(values = [5, 9, 1, 9, 8, 5, 7, 8, 2, 1],labels = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3],numWanted = 6,useLimit = 2) == 46\n assert candidate(values = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],numWanted = 5,useLimit = 1) == 60\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 4,useLimit = 3) == 20\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],numWanted = 5,useLimit = 2) == 40\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 5,useLimit = 3) == 5\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2],numWanted = 10,useLimit = 2) == 46\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 2) == 1900\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],numWanted = 10,useLimit = 1) == 50\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40],labels = [1, 1, 2, 2, 3, 3, 4, 4],numWanted = 4,useLimit = 2) == 130\n assert candidate(values = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],numWanted = 5,useLimit = 1) == 100\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],labels = [0, 0, 0, 1, 1, 1, 2, 2, 2],numWanted = 5,useLimit = 2) == 31\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],numWanted = 5,useLimit = 1) == 10\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],labels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],numWanted = 10,useLimit = 2) == 155\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],numWanted = 5,useLimit = 2) == 340\n assert candidate(values = [30, 25, 20, 15, 10, 5],labels = [1, 2, 3, 4, 5, 6],numWanted = 4,useLimit = 1) == 90\n assert candidate(values = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],labels = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],numWanted = 5,useLimit = 3) == 360\n assert candidate(values = [20, 18, 15, 12, 10, 8, 6, 4, 2],labels = [1, 1, 2, 2, 3, 3, 4, 4, 5],numWanted = 5,useLimit = 2) == 75\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],labels = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],numWanted = 5,useLimit = 1) == 40\n assert candidate(values = [30, 20, 10, 10, 20, 30],labels = [1, 1, 2, 2, 3, 3],numWanted = 5,useLimit = 1) == 70\n", "comparison": "exact"}, "public_tests": ["[5,4,3,2,1]\n[1,1,2,2,3]\n3\n1", "[5,4,3,2,1]\n[1,3,3,3,2]\n3\n2", "[9,8,8,7,6]\n[0,0,0,1,1]\n3\n1"], "hints": ["Consider the items in order from largest to smallest value, and greedily take the items if they fall under the use_limit. We can keep track of how many items of each label are used by using a hash table."], "metadata": {"canonical_parameter_names": ["values", "labels", "numWanted", "useLimit"], "leetcode_dataset_entry_point": "Solution().largestValsFromLabels", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:11+00:00", "tests_total": 99, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def largestValsFromLabels(self, values: list[int], labels: list[int], numWanted: int, useLimit: int) -> int:", "container": "Solution", "callable": "largestValsFromLabels", "parameters": [{"name": "values", "type": "list[int]"}, {"name": "labels", "type": "list[int]"}, {"name": "numWanted", "type": "int"}, {"name": "useLimit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1091, "task_id": "shortest-path-in-binary-matrix", "difficulty": "Medium", "problem_description": "Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1.\n\nA clear path in a binary matrix is a path from the top-left cell (i.e., (0, 0)) to the bottom-right cell (i.e., (n - 1, n - 1)) such that:\n\n- All the visited cells of the path are 0.\n- All the adjacent cells of the path are 8-directionally connected (i.e., they are different and they share an edge or a corner).\n\nThe length of a clear path is the number of visited cells of this path.\n\nExample 1:\n\nInput: grid = [[0,1],[1,0]]\nOutput: 2\n\nExample 2:\n\nInput: grid = [[0,0,0],[1,1,0],[1,1,0]]\nOutput: 4\n\nExample 3:\n\nInput: grid = [[1,0,0],[1,1,0],[1,1,0]]\nOutput: -1\n\nConstraints:\n\n- n == grid.length\n- n == grid[i].length\n- 1 <= n <= 100\n- grid[i][j] is 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1], [1, 0]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0], [1, 1, 0], [1, 1, 0]]) == 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\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 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == -1\n assert candidate(grid = [[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]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 0, 0], [1, 1, 0], [1, 1, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 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\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 13\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]]) == 7\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 0, 0], [1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == -1\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, 1, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 10\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, 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, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1], [1, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 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, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(grid = [[0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 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, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0, 0, 1, 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, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 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, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0]]) == 11\n assert candidate(grid = [[0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0]]) == 7\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, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 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, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 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, 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, 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], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\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, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 17\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]]) == 10\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [1, 1, 0, 1, 0, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 13\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 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, 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, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 1, 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, 1], [0, 0, 0, 1, 0, 0, 0, 1, 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, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 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, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 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]]) == 9\n assert candidate(grid = [[0, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0]]) == 7\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, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[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, 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, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 15\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 1, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 0, 0], [1, 1, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0]]) == 13\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, 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, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1, 0], [0, 1, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 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]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [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, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 1, 1, 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, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0, 0]]) == 13\n", "comparison": "exact"}, "public_tests": ["[[0,1],[1,0]]", "[[0,0,0],[1,1,0],[1,1,0]]", "[[1,0,0],[1,1,0],[1,1,0]]"], "hints": ["Do a breadth first search to find the shortest path."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().shortestPathBinaryMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:13+00:00", "tests_total": 67, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def shortestPathBinaryMatrix(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "shortestPathBinaryMatrix", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1092, "task_id": "shortest-common-supersequence", "difficulty": "Hard", "problem_description": "Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return any of them.\n\nA string s is a subsequence of string t if deleting some number of characters from t (possibly 0) results in the string s.\n\nExample 1:\n\nInput: str1 = \"abac\", str2 = \"cab\"\nOutput: \"cabac\"\nExplanation:\nstr1 = \"abac\" is a subsequence of \"cabac\" because we can delete the first \"c\".\nstr2 = \"cab\" is a subsequence of \"cabac\" because we can delete the last \"ac\".\nThe answer provided is the shortest such string that satisfies these properties.\n\nExample 2:\n\nInput: str1 = \"aaaaaaaa\", str2 = \"aaaaaaaa\"\nOutput: \"aaaaaaaa\"\n\nConstraints:\n\n- 1 <= str1.length, str2.length <= 1000\n- str1 and str2 consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(str1 = \"xyz\",str2 = \"xyx\") == \"xyxz\"\n assert candidate(str1 = \"short\",str2 = \"sorts\") == \"shorts\"\n assert candidate(str1 = \"algorithm\",str2 = \"altruistic\") == \"altgoruistichm\"\n assert candidate(str1 = \"ab\",str2 = \"ba\") == \"bab\"\n assert candidate(str1 = \"abc\",str2 = \"def\") == \"defabc\"\n assert candidate(str1 = \"aaaaaaaa\",str2 = \"aaaaaaaa\") == \"aaaaaaaa\"\n assert candidate(str1 = \"abc\",str2 = \"cba\") == \"cbabc\"\n assert candidate(str1 = \"abc\",str2 = \"abc\") == \"abc\"\n assert candidate(str1 = \"sequence\",str2 = \"subsequence\") == \"subsequence\"\n assert candidate(str1 = \"dynamic\",str2 = \"programming\") == \"progrdynammingc\"\n assert candidate(str1 = \"abac\",str2 = \"cab\") == \"cabac\"\n assert candidate(str1 = \"xyz\",str2 = \"zyx\") == \"zyxyz\"\n assert candidate(str1 = \"abcde\",str2 = \"ace\") == \"abcde\"\n assert candidate(str1 = \"a\",str2 = \"b\") == \"ba\"\n assert candidate(str1 = \"abcd\",str2 = \"aebd\") == \"aebcd\"\n assert candidate(str1 = \"datastructure\",str2 = \"algorithm\") == \"dalgotastriucthmure\"\n assert candidate(str1 = \"xyzuvw\",str2 = \"uvwzyx\") == \"xyzuvwzyx\"\n assert candidate(str1 = \"kitten\",str2 = \"sitting\") == \"skittieng\"\n assert candidate(str1 = \"intersection\",str2 = \"introduction\") == \"interodusection\"\n assert candidate(str1 = \"sequences\",str2 = \"supersequence\") == \"supersequences\"\n assert candidate(str1 = \"abracadabra\",str2 = \"cadabraabra\") == \"cadabracadabra\"\n assert candidate(str1 = \"mississippi\",str2 = \"missouri\") == \"missourissippi\"\n assert candidate(str1 = \"interview\",str2 = \"environment\") == \"eintervironmentw\"\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"cdabcdabcdab\") == \"cdabcdabcdabcd\"\n assert candidate(str1 = \"abcdefghij\",str2 = \"jihgfedcba\") == \"jihgfedcbabcdefghij\"\n assert candidate(str1 = \"ababab\",str2 = \"bababa\") == \"bababab\"\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"bcdabcda\") == \"abcdabcdabcd\"\n assert candidate(str1 = \"optimization\",str2 = \"generalization\") == \"generaloptimization\"\n assert candidate(str1 = \"interview\",str2 = \"intermission\") == \"intermvissionew\"\n assert candidate(str1 = \"partiallyoverlapping\",str2 = \"overlapping\") == \"partiallyoverlapping\"\n assert candidate(str1 = \"abcdabcd\",str2 = \"dcbaabcd\") == \"dcabcdaabcd\"\n assert candidate(str1 = \"uniquecharacters\",str2 = \"charactersunique\") == \"uniquecharactersunique\"\n assert candidate(str1 = \"abcxyz\",str2 = \"xyzabc\") == \"xyzabcxyz\"\n assert candidate(str1 = \"longest\",str2 = \"longestcommonsubsequence\") == \"longestcommonsubsequence\"\n assert candidate(str1 = \"abcdefgxyz\",str2 = \"zyxabcdefg\") == \"zyxabcdefgxyz\"\n assert candidate(str1 = \"longestcommonsubsequence\",str2 = \"shortestuncommonsupersequence\") == \"shlortngestuncommonsuperbsequence\"\n assert candidate(str1 = \"abracadabra\",str2 = \"bracadabrac\") == \"abracadabrac\"\n assert candidate(str1 = \"abcde\",str2 = \"fghij\") == \"fghijabcde\"\n assert candidate(str1 = \"mississippi\",str2 = \"pississippi\") == \"pmississippi\"\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"dcba\") == \"dabcdabcdabcd\"\n assert candidate(str1 = \"abcdefghiklmnopqrstuvwxyz\",str2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghiklmnopqrstuvwxyz\"\n assert candidate(str1 = \"complexity\",str2 = \"simplicity\") == \"sicomplexicity\"\n assert candidate(str1 = \"longest\",str2 = \"shortest\") == \"shlortngest\"\n assert candidate(str1 = \"programming\",str2 = \"grammingpro\") == \"programmingpro\"\n assert candidate(str1 = \"abcdefghijk\",str2 = \"mnopqrstuvwxyz\") == \"mnopqrstuvwxyzabcdefghijk\"\n assert candidate(str1 = \"supercalifragilisticexpialidocious\",str2 = \"california\") == \"supercalifornagilisticexpialidocious\"\n assert candidate(str1 = \"aabbccddeeff\",str2 = \"ffeeddccbbaa\") == \"ffeeddccbbaabbccddeeff\"\n assert candidate(str1 = \"abcdefg\",str2 = \"xyzabc\") == \"xyzabcdefg\"\n assert candidate(str1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",str2 = \"congratulations\") == \"cpneumongratoulatramicroscopicsilicovolcanoconiosis\"\n assert candidate(str1 = \"supersequence\",str2 = \"subsequence\") == \"subpersequence\"\n assert candidate(str1 = \"abababab\",str2 = \"babababa\") == \"babababab\"\n assert candidate(str1 = \"abracadabra\",str2 = \"bracadabra\") == \"abracadabra\"\n assert candidate(str1 = \"abcdexyz\",str2 = \"xyzab\") == \"abcdexyzab\"\n assert candidate(str1 = \"abcdefgh\",str2 = \"efghijkl\") == \"abcdefghijkl\"\n assert candidate(str1 = \"shortest\",str2 = \"common\") == \"cshommonrtest\"\n assert candidate(str1 = \"abcdxyz\",str2 = \"xyzabcd\") == \"xyzabcdxyz\"\n assert candidate(str1 = \"abracadabra\",str2 = \"avadakedavra\") == \"avbradcakedavbra\"\n assert candidate(str1 = \"abcdefgh\",str2 = \"efghabcd\") == \"efghabcdefgh\"\n assert candidate(str1 = \"super\",str2 = \"supercalifragilisticexpialidocious\") == \"supercalifragilisticexpialidocious\"\n assert candidate(str1 = \"overlapping\",str2 = \"lappingover\") == \"overlappingover\"\n assert candidate(str1 = \"abracadabra\",str2 = \"cabracadabrac\") == \"cabracadabrac\"\n assert candidate(str1 = \"programming\",str2 = \"development\") == \"developrogramemintg\"\n assert candidate(str1 = \"abcd\",str2 = \"abcdeabcde\") == \"abcdeabcde\"\n assert candidate(str1 = \"abcdexyz\",str2 = \"yzabcdex\") == \"yzabcdexyz\"\n assert candidate(str1 = \"programming\",str2 = \"gramming\") == \"programming\"\n assert candidate(str1 = \"aabbccdd\",str2 = \"dddccccbbbaa\") == \"dddccccbbbaabbccdd\"\n assert candidate(str1 = \"longestcommonsubsequence\",str2 = \"shortestcommonsupersequence\") == \"shlortngestcommonsuperbsequence\"\n assert candidate(str1 = \"abcdefghijklmnopqrstuvwxyz\",str2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyz\"\n assert candidate(str1 = \"longest\",str2 = \"longer\") == \"longerst\"\n assert candidate(str1 = \"abcdefghijk\",str2 = \"abcdefghij\") == \"abcdefghijk\"\n assert candidate(str1 = \"abcd\",str2 = \"efgh\") == \"efghabcd\"\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"abcd\") == \"abcdabcdabcd\"\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"dcbaabcdabcd\") == \"dcabcdaabcdabcd\"\n assert candidate(str1 = \"abcdexyz\",str2 = \"yzabcd\") == \"yzabcdexyz\"\n assert candidate(str1 = \"repeatedcharactersin\",str2 = \"charactersinrepeated\") == \"repeatedcharactersinrepeated\"\n assert candidate(str1 = \"abcdefgh\",str2 = \"hgfedcba\") == \"hgfedcbabcdefgh\"\n assert candidate(str1 = \"repeatedcharacters\",str2 = \"charactersrepeated\") == \"repeatedcharactersrepeated\"\n assert candidate(str1 = \"thisisatest\",str2 = \"atestisthis\") == \"atehistisathiest\"\n assert candidate(str1 = \"shortest\",str2 = \"subsequence\") == \"subshortequencest\"\n assert candidate(str1 = \"aaaaabbbbb\",str2 = \"bbbbbbaaaa\") == \"aaaaabbbbbbaaaa\"\n assert candidate(str1 = \"abcabcabc\",str2 = \"cbacbacba\") == \"cbacbacabcabc\"\n assert candidate(str1 = \"interview\",str2 = \"interstellar\") == \"interstviellarw\"\n assert candidate(str1 = \"abcdexyz\",str2 = \"xyzabcd\") == \"xyzabcdexyz\"\n assert candidate(str1 = \"longest\",str2 = \"longshort\") == \"longeshort\"\n assert candidate(str1 = \"aaaaabbbb\",str2 = \"bbbaaaaa\") == \"bbbaaaaabbbb\"\n assert candidate(str1 = \"abcd\",str2 = \"dcba\") == \"dcbabcd\"\n assert candidate(str1 = \"abcdexyz\",str2 = \"xyzabcdexyz\") == \"xyzabcdexyz\"\n assert candidate(str1 = \"aaaaaaaaaa\",str2 = \"bbbbbbbbbb\") == \"bbbbbbbbbbaaaaaaaaaa\"\n assert candidate(str1 = \"abcd\",str2 = \"efghijklmnopqrstuvwxyz\") == \"efghijklmnopqrstuvwxyzabcd\"\n assert candidate(str1 = \"abcdefghijk\",str2 = \"jihgfedcba\") == \"jihgfedcbabcdefghijk\"\n assert candidate(str1 = \"aabbcc\",str2 = \"abcabc\") == \"abcabbcc\"\n assert candidate(str1 = \"abcabcabc\",str2 = \"bcabcabc\") == \"abcabcabc\"\n assert candidate(str1 = \"intersection\",str2 = \"interstellar\") == \"interstellarction\"\n assert candidate(str1 = \"abcdabcdabcd\",str2 = \"abcdabcdabcdabcd\") == \"abcdabcdabcdabcd\"\n assert candidate(str1 = \"abcdeffedcba\",str2 = \"defgfedcba\") == \"abcdefgfedcba\"\n assert candidate(str1 = \"supercalifragilisticexpialidocious\",str2 = \"supercalifragilisticexpialidocious\") == \"supercalifragilisticexpialidocious\"\n assert candidate(str1 = \"dynamic\",str2 = \"program\") == \"progrdynamic\"\n assert candidate(str1 = \"interview\",str2 = \"terviewin\") == \"interviewin\"\n assert candidate(str1 = \"longerstring\",str2 = \"short\") == \"shlongerstring\"\n", "comparison": "exact"}, "public_tests": ["\"abac\"\n\"cab\"", "\"aaaaaaaa\"\n\"aaaaaaaa\""], "hints": ["We can find the length of the longest common subsequence between str1[i:] and str2[j:] (for all (i, j)) by using dynamic programming.", "We can use this information to recover the shortest common supersequence."], "metadata": {"canonical_parameter_names": ["str1", "str2"], "leetcode_dataset_entry_point": "Solution().shortestCommonSupersequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:16+00:00", "tests_total": 99, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["string", "dynamic-programming", "longest-common-subsequence"]}, "language": "python", "interface": {"raw_signature": "def shortestCommonSupersequence(self, str1: str, str2: str) -> str:", "container": "Solution", "callable": "shortestCommonSupersequence", "parameters": [{"name": "str1", "type": "str"}, {"name": "str2", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1094, "task_id": "car-pooling", "difficulty": "Medium", "problem_description": "There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).\n\nYou are given the integer capacity and an array trips where trips[i] = [numPassengers_i, from_i, to_i] indicates that the i^th trip has numPassengers_i passengers and the locations to pick them up and drop them off are from_i and to_i respectively. The locations are given as the number of kilometers due east from the car's initial location.\n\nPassengers are dropped off before new passengers are picked up at the same location. At every point along the route, the total number of passengers in the car must not exceed capacity.\n\nReturn true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.\n\nExample 1:\n\nInput: trips = [[2,1,5],[3,3,7]], capacity = 4\nOutput: false\nExplanation:\nAt kilometer 1, 2 passengers are picked up, so the car holds 2.\nAt kilometer 3, 3 more are picked up, so the car holds 5.\nSince 5 > capacity = 4, the trips cannot all be completed.\n\nExample 2:\n\nInput: trips = [[2,1,5],[3,3,7]], capacity = 5\nOutput: true\nExplanation:\nAt kilometer 1, the car holds 2 passengers.\nAt kilometer 3, the car holds 5 passengers.\nAt kilometer 5, the first 2 are dropped off, so the car holds 3.\nAt kilometer 7, the last 3 are dropped off, so the car holds 0.\nThe maximum occupancy is 5, which never exceeds capacity = 5.\n\nConstraints:\n\n- 1 <= trips.length <= 1000\n- trips[i].length == 3\n- 1 <= numPassengers_i <= 100\n- 0 <= from_i < to_i <= 1000\n- 1 <= capacity <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(trips = [[3, 2, 8], [4, 4, 6], [10, 8, 10]],capacity = 12) == True\n assert candidate(trips = [[3, 2, 7], [2, 7, 9], [4, 1, 3]],capacity = 6) == False\n assert candidate(trips = [[2, 1, 5], [3, 5, 7]],capacity = 5) == True\n assert candidate(trips = [[2, 1, 6], [1, 3, 5], [4, 4, 8]],capacity = 9) == True\n assert candidate(trips = [[3, 2, 7], [3, 7, 9], [8, 3, 9]],capacity = 11) == True\n assert candidate(trips = [[2, 4, 5], [3, 1, 3], [3, 3, 7]],capacity = 5) == True\n assert candidate(trips = [[2, 1, 5], [3, 3, 7]],capacity = 5) == True\n assert candidate(trips = [[1, 3, 6], [2, 3, 7], [1, 8, 9]],capacity = 11) == True\n assert candidate(trips = [[2, 1, 5], [3, 5, 7], [2, 5, 8]],capacity = 6) == True\n assert candidate(trips = [[2, 1, 5], [3, 3, 7]],capacity = 4) == False\n assert candidate(trips = [[5, 2, 4], [3, 1, 3], [8, 6, 9], [2, 4, 8]],capacity = 15) == True\n assert candidate(trips = [[100, 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]],capacity = 105) == True\n assert candidate(trips = [[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]],capacity = 8) == False\n assert candidate(trips = [[1, 1, 3], [1, 1, 4], [1, 1, 5], [1, 1, 6], [1, 1, 7], [1, 1, 8], [1, 1, 9], [1, 1, 10]],capacity = 7) == False\n assert candidate(trips = [[100, 0, 100], [50, 50, 150], [25, 75, 200]],capacity = 150) == False\n assert candidate(trips = [[5, 0, 100], [3, 10, 50], [4, 50, 90], [2, 60, 80]],capacity = 20) == True\n assert candidate(trips = [[10, 0, 20], [5, 5, 15], [3, 10, 20], [2, 15, 20]],capacity = 20) == True\n assert candidate(trips = [[5, 1, 3], [10, 2, 6], [1, 2, 10], [2, 5, 7]],capacity = 17) == True\n assert candidate(trips = [[1, 0, 1], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6]],capacity = 2) == True\n assert candidate(trips = [[1, 0, 20], [2, 0, 15], [3, 0, 10], [4, 0, 5]],capacity = 20) == True\n assert candidate(trips = [[1, 1, 10], [1, 10, 20], [1, 20, 30], [1, 30, 40], [1, 40, 50]],capacity = 10) == True\n assert candidate(trips = [[3, 1, 10], [2, 2, 8], [1, 5, 7], [4, 6, 9]],capacity = 10) == True\n assert candidate(trips = [[30, 0, 2], [50, 1, 3], [40, 2, 4], [20, 3, 5], [10, 4, 6]],capacity = 80) == False\n assert candidate(trips = [[10, 0, 5], [10, 5, 10], [10, 10, 15]],capacity = 25) == True\n assert candidate(trips = [[5, 1, 6], [5, 3, 8], [5, 5, 10], [5, 7, 12]],capacity = 15) == True\n assert candidate(trips = [[1, 0, 500], [2, 100, 400], [3, 200, 300], [4, 300, 400], [5, 400, 500]],capacity = 15) == True\n assert candidate(trips = [[2, 1, 4], [3, 2, 5], [4, 3, 6], [1, 4, 7], [1, 5, 8], [1, 6, 9]],capacity = 10) == True\n assert candidate(trips = [[1, 1, 5], [2, 1, 6], [1, 2, 7], [1, 3, 8], [1, 4, 9], [1, 5, 10]],capacity = 5) == False\n assert candidate(trips = [[2, 2, 3], [2, 3, 5], [2, 5, 7], [2, 7, 9]],capacity = 3) == True\n assert candidate(trips = [[10, 0, 10], [10, 10, 20], [10, 20, 30], [10, 30, 40], [10, 40, 50]],capacity = 40) == True\n assert candidate(trips = [[3, 1, 2], [4, 2, 3], [5, 3, 4], [4, 4, 5], [3, 5, 6], [2, 6, 7]],capacity = 15) == True\n assert candidate(trips = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6], [6, 6, 7], [7, 7, 8], [8, 8, 9]],capacity = 7) == False\n assert candidate(trips = [[10, 0, 1], [10, 1, 2], [10, 2, 3], [10, 3, 4], [10, 4, 5], [10, 5, 6]],capacity = 10) == True\n assert candidate(trips = [[1, 1, 3], [2, 2, 5], [3, 3, 7], [4, 4, 8], [5, 5, 9]],capacity = 10) == False\n assert candidate(trips = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6], [6, 6, 7], [7, 7, 8], [8, 8, 9]],capacity = 28) == True\n assert candidate(trips = [[100, 0, 1000], [100, 100, 900], [100, 200, 800], [100, 300, 700], [100, 400, 600]],capacity = 300) == False\n assert candidate(trips = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6], [6, 6, 7]],capacity = 6) == True\n assert candidate(trips = [[5, 1, 3], [5, 3, 5], [5, 5, 7], [5, 7, 9], [5, 9, 11]],capacity = 20) == True\n assert candidate(trips = [[10, 1, 2], [10, 2, 3], [10, 3, 4], [10, 4, 5], [10, 5, 6], [10, 6, 7]],capacity = 25) == True\n assert candidate(trips = [[10, 0, 10], [5, 0, 5], [1, 6, 10], [2, 5, 8], [3, 7, 12]],capacity = 20) == True\n assert candidate(trips = [[20, 0, 30], [10, 10, 20], [5, 20, 30]],capacity = 25) == False\n assert candidate(trips = [[30, 0, 10], [20, 10, 20], [10, 20, 30], [5, 30, 40], [5, 40, 50]],capacity = 55) == True\n assert candidate(trips = [[1, 1, 3], [2, 3, 6], [3, 6, 9], [4, 9, 12], [5, 12, 15], [6, 15, 18], [7, 18, 21], [8, 21, 24]],capacity = 20) == True\n assert candidate(trips = [[5, 1, 3], [2, 2, 5], [4, 4, 8], [3, 5, 9]],capacity = 12) == True\n assert candidate(trips = [[1, 0, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7]],capacity = 3) == True\n assert candidate(trips = [[1, 0, 100], [2, 50, 100], [3, 75, 100]],capacity = 6) == True\n assert candidate(trips = [[10, 0, 3], [5, 3, 6], [10, 6, 9], [5, 9, 12]],capacity = 20) == True\n assert candidate(trips = [[3, 0, 1], [3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9]],capacity = 9) == True\n assert candidate(trips = [[5, 0, 3], [2, 3, 5], [7, 5, 10], [1, 10, 15]],capacity = 12) == True\n assert candidate(trips = [[3, 1, 4], [5, 1, 5], [2, 3, 7], [2, 4, 8]],capacity = 14) == True\n assert candidate(trips = [[10, 0, 1], [10, 0, 2], [10, 0, 3], [10, 0, 4], [10, 0, 5]],capacity = 50) == True\n assert candidate(trips = [[3, 1, 3], [2, 2, 4], [1, 3, 5], [4, 4, 6], [2, 5, 7], [1, 6, 8]],capacity = 10) == True\n assert candidate(trips = [[4, 1, 10], [2, 2, 5], [3, 3, 6], [1, 5, 12]],capacity = 15) == True\n assert candidate(trips = [[5, 0, 5], [4, 5, 10], [3, 10, 15], [2, 15, 20], [1, 20, 25]],capacity = 15) == True\n assert candidate(trips = [[10, 0, 10], [10, 10, 20], [10, 20, 30], [10, 30, 40], [10, 40, 50]],capacity = 20) == True\n assert candidate(trips = [[2, 1, 4], [3, 2, 5], [2, 3, 6], [1, 4, 7], [4, 5, 8], [3, 6, 9]],capacity = 8) == True\n assert candidate(trips = [[3, 0, 1], [3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6]],capacity = 10) == True\n assert candidate(trips = [[10, 0, 10], [20, 5, 15], [30, 10, 20], [40, 15, 25], [50, 20, 30]],capacity = 100) == True\n assert candidate(trips = [[10, 1, 10], [5, 2, 5], [3, 5, 7], [2, 7, 8]],capacity = 20) == True\n assert candidate(trips = [[3, 0, 1], [3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5]],capacity = 12) == True\n assert candidate(trips = [[2, 1, 5], [3, 3, 7], [1, 1, 3], [4, 5, 9]],capacity = 7) == True\n assert candidate(trips = [[1, 1, 1000], [2, 2, 999], [3, 3, 998], [4, 4, 997], [5, 5, 996]],capacity = 15) == True\n assert candidate(trips = [[5, 1, 5], [3, 5, 9], [2, 9, 12], [1, 12, 15]],capacity = 15) == True\n assert candidate(trips = [[10, 0, 10], [20, 10, 20], [10, 15, 25], [20, 20, 30], [30, 25, 35]],capacity = 40) == False\n assert candidate(trips = [[2, 1, 3], [3, 2, 4], [4, 3, 5], [5, 4, 6], [6, 5, 7]],capacity = 15) == True\n assert candidate(trips = [[2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6]],capacity = 4) == True\n assert candidate(trips = [[3, 2, 7], [3, 2, 7], [3, 2, 7]],capacity = 9) == True\n assert candidate(trips = [[50, 0, 500], [50, 100, 600], [50, 200, 700], [50, 300, 800], [50, 400, 900]],capacity = 150) == False\n assert candidate(trips = [[100, 0, 1], [100, 1, 2], [100, 2, 3], [100, 3, 4], [100, 4, 5]],capacity = 100) == True\n assert candidate(trips = [[50, 10, 20], [30, 20, 30], [20, 30, 40], [10, 40, 50], [5, 50, 60]],capacity = 100) == True\n assert candidate(trips = [[50, 0, 500], [50, 500, 1000]],capacity = 100) == True\n assert candidate(trips = [[3, 2, 5], [3, 2, 7], [3, 3, 6], [3, 4, 8]],capacity = 9) == False\n assert candidate(trips = [[5, 1, 3], [2, 3, 8], [3, 5, 9], [1, 6, 10]],capacity = 15) == True\n assert candidate(trips = [[5, 0, 3], [4, 2, 5], [3, 4, 8], [2, 6, 10]],capacity = 14) == True\n assert candidate(trips = [[2, 0, 2], [2, 2, 4], [2, 4, 6], [2, 6, 8], [2, 8, 10], [2, 10, 12]],capacity = 12) == True\n assert candidate(trips = [[1, 1, 2], [1, 1, 2], [1, 1, 2], [1, 1, 2], [1, 1, 2]],capacity = 4) == False\n assert candidate(trips = [[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]],capacity = 10) == True\n assert candidate(trips = [[1, 0, 3], [2, 1, 5], [3, 2, 7], [4, 3, 9], [5, 4, 10]],capacity = 15) == True\n assert candidate(trips = [[10, 0, 100], [10, 20, 120], [10, 40, 140], [10, 60, 160], [10, 80, 180]],capacity = 30) == False\n assert candidate(trips = [[10, 0, 5], [3, 5, 10], [4, 10, 15], [2, 15, 20]],capacity = 12) == True\n assert candidate(trips = [[20, 0, 1000], [10, 100, 900], [5, 200, 800], [1, 300, 700]],capacity = 50) == True\n assert candidate(trips = [[5, 1, 3], [2, 2, 5], [4, 3, 8], [3, 5, 7]],capacity = 10) == True\n assert candidate(trips = [[1, 0, 2], [1, 2, 4], [1, 4, 6], [1, 6, 8], [1, 8, 10], [1, 10, 12]],capacity = 5) == True\n assert candidate(trips = [[5, 1, 5], [3, 1, 4], [2, 3, 6], [1, 4, 7]],capacity = 10) == True\n assert candidate(trips = [[10, 0, 5], [2, 5, 10], [1, 10, 15], [10, 15, 20]],capacity = 12) == True\n assert candidate(trips = [[3, 1, 5], [2, 2, 6], [4, 3, 8], [1, 4, 9], [5, 5, 10]],capacity = 10) == False\n assert candidate(trips = [[6, 0, 20], [2, 10, 30], [4, 20, 40], [1, 30, 50], [3, 40, 60]],capacity = 15) == True\n assert candidate(trips = [[10, 0, 1], [9, 1, 2], [8, 2, 3], [7, 3, 4], [6, 4, 5], [5, 5, 6]],capacity = 10) == True\n assert candidate(trips = [[10, 0, 1], [10, 1, 2], [10, 2, 3], [10, 3, 4], [10, 4, 5]],capacity = 10) == True\n assert candidate(trips = [[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]],capacity = 45) == True\n assert candidate(trips = [[3, 0, 1], [3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7]],capacity = 9) == True\n assert candidate(trips = [[1, 1, 100], [2, 2, 99], [3, 3, 98], [4, 4, 97]],capacity = 10) == True\n assert candidate(trips = [[1, 0, 1], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7]],capacity = 1) == True\n assert candidate(trips = [[3, 1, 3], [3, 2, 5], [3, 3, 7], [3, 4, 8], [3, 5, 9], [3, 6, 10]],capacity = 9) == False\n assert candidate(trips = [[5, 1, 3], [5, 3, 5], [5, 5, 7], [5, 7, 9]],capacity = 10) == True\n assert candidate(trips = [[5, 1, 5], [2, 3, 8], [4, 5, 9], [3, 6, 10]],capacity = 12) == True\n assert candidate(trips = [[10, 0, 2], [5, 2, 5], [3, 5, 10], [7, 7, 12]],capacity = 15) == True\n assert candidate(trips = [[3, 0, 5], [2, 0, 10], [1, 5, 7], [4, 8, 10]],capacity = 10) == True\n assert candidate(trips = [[50, 0, 100], [20, 100, 200], [30, 200, 300], [40, 300, 400]],capacity = 150) == True\n assert candidate(trips = [[1, 1, 3], [2, 2, 4], [3, 3, 5], [4, 4, 6], [5, 5, 7], [6, 6, 8], [7, 7, 9]],capacity = 15) == True\n assert candidate(trips = [[50, 0, 10], [30, 5, 15], [20, 10, 20], [10, 15, 25]],capacity = 110) == True\n assert candidate(trips = [[2, 1, 5], [3, 5, 8], [1, 8, 12], [4, 10, 15]],capacity = 10) == True\n assert candidate(trips = [[1, 0, 10], [2, 1, 9], [3, 2, 8], [4, 3, 7], [5, 4, 6]],capacity = 15) == True\n assert candidate(trips = [[10, 1, 4], [5, 5, 7], [2, 2, 6], [4, 6, 8]],capacity = 15) == True\n assert candidate(trips = [[2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8]],capacity = 3) == True\n assert candidate(trips = [[3, 1, 4], [5, 2, 5], [1, 2, 6], [2, 3, 7], [3, 4, 8]],capacity = 14) == True\n assert candidate(trips = [[2, 1, 5], [3, 3, 7], [5, 5, 10], [1, 7, 12], [4, 8, 13]],capacity = 15) == True\n assert candidate(trips = [[5, 1, 5], [6, 4, 9], [4, 9, 14], [3, 14, 19]],capacity = 15) == True\n assert candidate(trips = [[5, 1, 5], [2, 2, 8], [3, 4, 6], [1, 3, 10]],capacity = 12) == True\n assert candidate(trips = [[3, 1, 3], [2, 1, 4], [1, 2, 5], [4, 3, 6], [2, 4, 7]],capacity = 10) == True\n", "comparison": "exact"}, "public_tests": ["[[2,1,5],[3,3,7]]\n4", "[[2,1,5],[3,3,7]]\n5"], "hints": ["Sort the pickup and dropoff events by location, then process them in order."], "metadata": {"canonical_parameter_names": ["trips", "capacity"], "leetcode_dataset_entry_point": "Solution().carPooling", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:20+00:00", "tests_total": 112, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "sorting", "heap-priority-queue", "simulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def carPooling(self, trips: list[list[int]], capacity: int) -> bool:", "container": "Solution", "callable": "carPooling", "parameters": [{"name": "trips", "type": "list[list[int]]"}, {"name": "capacity", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1096, "task_id": "brace-expansion-ii", "difficulty": "Hard", "problem_description": "Under the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents.\n\nThe grammar can best be understood through simple examples:\n\n- Single letters represent a singleton set containing that word.\n - R(\"a\") = {\"a\"}\n - R(\"w\") = {\"w\"}\n- When we take a comma-delimited list of two or more expressions, we take the union of possibilities.\n - R(\"{a,b,c}\") = {\"a\",\"b\",\"c\"}\n - R(\"{{a,b},{b,c}}\") = {\"a\",\"b\",\"c\"} (notice the final set only contains each word at most once)\n- When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression.\n - R(\"{a,b}{c,d}\") = {\"ac\",\"ad\",\"bc\",\"bd\"}\n - R(\"a{b,c}{d,e}f{g,h}\") = {\"abdfg\", \"abdfh\", \"abefg\", \"abefh\", \"acdfg\", \"acdfh\", \"acefg\", \"acefh\"}\n\nFormally, the three rules for our grammar:\n\n- For every lowercase letter x, we have R(x) = {x}.\n- For expressions e_1, e_2, ... , e_k with k >= 2, we have R({e_1, e_2, ...}) = R(e_1) ∪ R(e_2) ∪ ...\n- For expressions e_1 and e_2, we have R(e_1 + e_2) = {a + b for (a, b) in R(e_1) × R(e_2)}, where + denotes concatenation, and × denotes the cartesian product.\n\nGiven an expression representing a set of words under the given grammar, return the sorted list of words that the expression represents.\n\nExample 1:\n\nInput: expression = \"{a,b}{c,{d,e}}\"\nOutput: [\"ac\",\"ad\",\"ae\",\"bc\",\"bd\",\"be\"]\n\nExample 2:\n\nInput: expression = \"{{a,z},a{b,c},{ab,z}}\"\nOutput: [\"a\",\"ab\",\"ac\",\"z\"]\nExplanation: Each distinct word is written only once in the final answer.\n\nConstraints:\n\n- 1 <= expression.length <= 60\n- expression[i] consists of '{', '}', ','or lowercase English letters.\n- The given expression represents a set of words based on the grammar given in the description.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(expression = \"a\") == ['a']\n assert candidate(expression = \"{a,bc,def}\") == ['a', 'bc', 'def']\n assert candidate(expression = \"a{b{c,d},e{f,g}}\") == ['abc', 'abd', 'aef', 'aeg']\n assert candidate(expression = \"{a,b,c}\") == ['a', 'b', 'c']\n assert candidate(expression = \"{a,b}c\") == ['ac', 'bc']\n assert candidate(expression = \"{abc}\") == ['abc']\n assert candidate(expression = \"a{b,c,d}e\") == ['abe', 'ace', 'ade']\n assert candidate(expression = \"{a,b}{c,{d,{e,f}}}\") == ['ac', 'ad', 'ae', 'af', 'bc', 'bd', 'be', 'bf']\n assert candidate(expression = \"a{b,c}\") == ['ab', 'ac']\n assert candidate(expression = \"{a,b}{c,d}\") == ['ac', 'ad', 'bc', 'bd']\n assert candidate(expression = \"a{b,c}d\") == ['abd', 'acd']\n assert candidate(expression = \"{a,b}{c,{d,e}}\") == ['ac', 'ad', 'ae', 'bc', 'bd', 'be']\n assert candidate(expression = \"a{b,c}d{e,f}\") == ['abde', 'abdf', 'acde', 'acdf']\n assert candidate(expression = \"{a,b}{c,{d{e,f},g}}\") == ['ac', 'ade', 'adf', 'ag', 'bc', 'bde', 'bdf', 'bg']\n assert candidate(expression = \"{a{b,c},d{e,f}}\") == ['ab', 'ac', 'de', 'df']\n assert candidate(expression = \"{a,b}{c,d,e}\") == ['ac', 'ad', 'ae', 'bc', 'bd', 'be']\n assert candidate(expression = \"{a,b,c}{d,e,f}\") == ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf']\n assert candidate(expression = \"{{a,z},a{b,c},{ab,z}}\") == ['a', 'ab', 'ac', 'z']\n assert candidate(expression = \"{a{b{c,d},e{f,g}},{h{i,j},k{l,m,n}}}\") == ['abc', 'abd', 'aef', 'aeg', 'hi', 'hj', 'kl', 'km', 'kn']\n assert candidate(expression = \"{a,b}{c{d{e{f,g},h},i},j{k{l,m{no,pq{r,s}},t{u,v}}}}\") == ['acdef', 'acdeg', 'acdh', 'aci', 'ajkl', 'ajkmno', 'ajkmpqr', 'ajkmpqs', 'ajktu', 'ajktv', 'bcdef', 'bcdeg', 'bcdh', 'bci', 'bjkl', 'bjkmno', 'bjkmpqr', 'bjkmpqs', 'bjktu', 'bjktv']\n assert candidate(expression = \"{a,b{c,d{e,f}},g{h,i}}{j,k}\") == ['aj', 'ak', 'bcj', 'bck', 'bdej', 'bdek', 'bdfj', 'bdfk', 'ghj', 'ghk', 'gij', 'gik']\n assert candidate(expression = \"{a{b{c,d},e},f{g{h,i},j}}\") == ['abc', 'abd', 'ae', 'fgh', 'fgi', 'fj']\n assert candidate(expression = \"{a,b,c}{d,{e,f},{g,h}}{i,j}\") == ['adi', 'adj', 'aei', 'aej', 'afi', 'afj', 'agi', 'agj', 'ahi', 'ahj', 'bdi', 'bdj', 'bei', 'bej', 'bfi', 'bfj', 'bgi', 'bgj', 'bhi', 'bhj', 'cdi', 'cdj', 'cei', 'cej', 'cfi', 'cfj', 'cgi', 'cgj', 'chi', 'chj']\n assert candidate(expression = \"{a{b{c{d,e},f},g},h{i,j}}\") == ['abcd', 'abce', 'abf', 'ag', 'hi', 'hj']\n assert candidate(expression = \"{a,b}{c{d,e,f},g{h,i}}{j,k}\") == ['acdj', 'acdk', 'acej', 'acek', 'acfj', 'acfk', 'aghj', 'aghk', 'agij', 'agik', 'bcdj', 'bcdk', 'bcej', 'bcek', 'bcfj', 'bcfk', 'bghj', 'bghk', 'bgij', 'bgik']\n assert candidate(expression = \"{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}\") == ['acgjo', 'acgjp', 'acgjq', 'acgjr', 'acgjs', 'acgjt', 'acgju', 'acgjv', 'acgjw', 'acgjx', 'acgjy', 'acgjz', 'acgko', 'acgkp', 'acgkq', 'acgkr', 'acgks', 'acgkt', 'acgku', 'acgkv', 'acgkw', 'acgkx', 'acgky', 'acgkz', 'acglo', 'acglp', 'acglq', 'acglr', 'acgls', 'acglt', 'acglu', 'acglv', 'acglw', 'acglx', 'acgly', 'acglz', 'acgmo', 'acgmp', 'acgmq', 'acgmr', 'acgms', 'acgmt', 'acgmu', 'acgmv', 'acgmw', 'acgmx', 'acgmy', 'acgmz', 'acgno', 'acgnp', 'acgnq', 'acgnr', 'acgns', 'acgnt', 'acgnu', 'acgnv', 'acgnw', 'acgnx', 'acgny', 'acgnz', 'achjo', 'achjp', 'achjq', 'achjr', 'achjs', 'achjt', 'achju', 'achjv', 'achjw', 'achjx', 'achjy', 'achjz', 'achko', 'achkp', 'achkq', 'achkr', 'achks', 'achkt', 'achku', 'achkv', 'achkw', 'achkx', 'achky', 'achkz', 'achlo', 'achlp', 'achlq', 'achlr', 'achls', 'achlt', 'achlu', 'achlv', 'achlw', 'achlx', 'achly', 'achlz', 'achmo', 'achmp', 'achmq', 'achmr', 'achms', 'achmt', 'achmu', 'achmv', 'achmw', 'achmx', 'achmy', 'achmz', 'achno', 'achnp', 'achnq', 'achnr', 'achns', 'achnt', 'achnu', 'achnv', 'achnw', 'achnx', 'achny', 'achnz', 'acijo', 'acijp', 'acijq', 'acijr', 'acijs', 'acijt', 'aciju', 'acijv', 'acijw', 'acijx', 'acijy', 'acijz', 'aciko', 'acikp', 'acikq', 'acikr', 'aciks', 'acikt', 'aciku', 'acikv', 'acikw', 'acikx', 'aciky', 'acikz', 'acilo', 'acilp', 'acilq', 'acilr', 'acils', 'acilt', 'acilu', 'acilv', 'acilw', 'acilx', 'acily', 'acilz', 'acimo', 'acimp', 'acimq', 'acimr', 'acims', 'acimt', 'acimu', 'acimv', 'acimw', 'acimx', 'acimy', 'acimz', 'acino', 'acinp', 'acinq', 'acinr', 'acins', 'acint', 'acinu', 'acinv', 'acinw', 'acinx', 'aciny', 'acinz', 'adgjo', 'adgjp', 'adgjq', 'adgjr', 'adgjs', 'adgjt', 'adgju', 'adgjv', 'adgjw', 'adgjx', 'adgjy', 'adgjz', 'adgko', 'adgkp', 'adgkq', 'adgkr', 'adgks', 'adgkt', 'adgku', 'adgkv', 'adgkw', 'adgkx', 'adgky', 'adgkz', 'adglo', 'adglp', 'adglq', 'adglr', 'adgls', 'adglt', 'adglu', 'adglv', 'adglw', 'adglx', 'adgly', 'adglz', 'adgmo', 'adgmp', 'adgmq', 'adgmr', 'adgms', 'adgmt', 'adgmu', 'adgmv', 'adgmw', 'adgmx', 'adgmy', 'adgmz', 'adgno', 'adgnp', 'adgnq', 'adgnr', 'adgns', 'adgnt', 'adgnu', 'adgnv', 'adgnw', 'adgnx', 'adgny', 'adgnz', 'adhjo', 'adhjp', 'adhjq', 'adhjr', 'adhjs', 'adhjt', 'adhju', 'adhjv', 'adhjw', 'adhjx', 'adhjy', 'adhjz', 'adhko', 'adhkp', 'adhkq', 'adhkr', 'adhks', 'adhkt', 'adhku', 'adhkv', 'adhkw', 'adhkx', 'adhky', 'adhkz', 'adhlo', 'adhlp', 'adhlq', 'adhlr', 'adhls', 'adhlt', 'adhlu', 'adhlv', 'adhlw', 'adhlx', 'adhly', 'adhlz', 'adhmo', 'adhmp', 'adhmq', 'adhmr', 'adhms', 'adhmt', 'adhmu', 'adhmv', 'adhmw', 'adhmx', 'adhmy', 'adhmz', 'adhno', 'adhnp', 'adhnq', 'adhnr', 'adhns', 'adhnt', 'adhnu', 'adhnv', 'adhnw', 'adhnx', 'adhny', 'adhnz', 'adijo', 'adijp', 'adijq', 'adijr', 'adijs', 'adijt', 'adiju', 'adijv', 'adijw', 'adijx', 'adijy', 'adijz', 'adiko', 'adikp', 'adikq', 'adikr', 'adiks', 'adikt', 'adiku', 'adikv', 'adikw', 'adikx', 'adiky', 'adikz', 'adilo', 'adilp', 'adilq', 'adilr', 'adils', 'adilt', 'adilu', 'adilv', 'adilw', 'adilx', 'adily', 'adilz', 'adimo', 'adimp', 'adimq', 'adimr', 'adims', 'adimt', 'adimu', 'adimv', 'adimw', 'adimx', 'adimy', 'adimz', 'adino', 'adinp', 'adinq', 'adinr', 'adins', 'adint', 'adinu', 'adinv', 'adinw', 'adinx', 'adiny', 'adinz', 'aegjo', 'aegjp', 'aegjq', 'aegjr', 'aegjs', 'aegjt', 'aegju', 'aegjv', 'aegjw', 'aegjx', 'aegjy', 'aegjz', 'aegko', 'aegkp', 'aegkq', 'aegkr', 'aegks', 'aegkt', 'aegku', 'aegkv', 'aegkw', 'aegkx', 'aegky', 'aegkz', 'aeglo', 'aeglp', 'aeglq', 'aeglr', 'aegls', 'aeglt', 'aeglu', 'aeglv', 'aeglw', 'aeglx', 'aegly', 'aeglz', 'aegmo', 'aegmp', 'aegmq', 'aegmr', 'aegms', 'aegmt', 'aegmu', 'aegmv', 'aegmw', 'aegmx', 'aegmy', 'aegmz', 'aegno', 'aegnp', 'aegnq', 'aegnr', 'aegns', 'aegnt', 'aegnu', 'aegnv', 'aegnw', 'aegnx', 'aegny', 'aegnz', 'aehjo', 'aehjp', 'aehjq', 'aehjr', 'aehjs', 'aehjt', 'aehju', 'aehjv', 'aehjw', 'aehjx', 'aehjy', 'aehjz', 'aehko', 'aehkp', 'aehkq', 'aehkr', 'aehks', 'aehkt', 'aehku', 'aehkv', 'aehkw', 'aehkx', 'aehky', 'aehkz', 'aehlo', 'aehlp', 'aehlq', 'aehlr', 'aehls', 'aehlt', 'aehlu', 'aehlv', 'aehlw', 'aehlx', 'aehly', 'aehlz', 'aehmo', 'aehmp', 'aehmq', 'aehmr', 'aehms', 'aehmt', 'aehmu', 'aehmv', 'aehmw', 'aehmx', 'aehmy', 'aehmz', 'aehno', 'aehnp', 'aehnq', 'aehnr', 'aehns', 'aehnt', 'aehnu', 'aehnv', 'aehnw', 'aehnx', 'aehny', 'aehnz', 'aeijo', 'aeijp', 'aeijq', 'aeijr', 'aeijs', 'aeijt', 'aeiju', 'aeijv', 'aeijw', 'aeijx', 'aeijy', 'aeijz', 'aeiko', 'aeikp', 'aeikq', 'aeikr', 'aeiks', 'aeikt', 'aeiku', 'aeikv', 'aeikw', 'aeikx', 'aeiky', 'aeikz', 'aeilo', 'aeilp', 'aeilq', 'aeilr', 'aeils', 'aeilt', 'aeilu', 'aeilv', 'aeilw', 'aeilx', 'aeily', 'aeilz', 'aeimo', 'aeimp', 'aeimq', 'aeimr', 'aeims', 'aeimt', 'aeimu', 'aeimv', 'aeimw', 'aeimx', 'aeimy', 'aeimz', 'aeino', 'aeinp', 'aeinq', 'aeinr', 'aeins', 'aeint', 'aeinu', 'aeinv', 'aeinw', 'aeinx', 'aeiny', 'aeinz', 'afgjo', 'afgjp', 'afgjq', 'afgjr', 'afgjs', 'afgjt', 'afgju', 'afgjv', 'afgjw', 'afgjx', 'afgjy', 'afgjz', 'afgko', 'afgkp', 'afgkq', 'afgkr', 'afgks', 'afgkt', 'afgku', 'afgkv', 'afgkw', 'afgkx', 'afgky', 'afgkz', 'afglo', 'afglp', 'afglq', 'afglr', 'afgls', 'afglt', 'afglu', 'afglv', 'afglw', 'afglx', 'afgly', 'afglz', 'afgmo', 'afgmp', 'afgmq', 'afgmr', 'afgms', 'afgmt', 'afgmu', 'afgmv', 'afgmw', 'afgmx', 'afgmy', 'afgmz', 'afgno', 'afgnp', 'afgnq', 'afgnr', 'afgns', 'afgnt', 'afgnu', 'afgnv', 'afgnw', 'afgnx', 'afgny', 'afgnz', 'afhjo', 'afhjp', 'afhjq', 'afhjr', 'afhjs', 'afhjt', 'afhju', 'afhjv', 'afhjw', 'afhjx', 'afhjy', 'afhjz', 'afhko', 'afhkp', 'afhkq', 'afhkr', 'afhks', 'afhkt', 'afhku', 'afhkv', 'afhkw', 'afhkx', 'afhky', 'afhkz', 'afhlo', 'afhlp', 'afhlq', 'afhlr', 'afhls', 'afhlt', 'afhlu', 'afhlv', 'afhlw', 'afhlx', 'afhly', 'afhlz', 'afhmo', 'afhmp', 'afhmq', 'afhmr', 'afhms', 'afhmt', 'afhmu', 'afhmv', 'afhmw', 'afhmx', 'afhmy', 'afhmz', 'afhno', 'afhnp', 'afhnq', 'afhnr', 'afhns', 'afhnt', 'afhnu', 'afhnv', 'afhnw', 'afhnx', 'afhny', 'afhnz', 'afijo', 'afijp', 'afijq', 'afijr', 'afijs', 'afijt', 'afiju', 'afijv', 'afijw', 'afijx', 'afijy', 'afijz', 'afiko', 'afikp', 'afikq', 'afikr', 'afiks', 'afikt', 'afiku', 'afikv', 'afikw', 'afikx', 'afiky', 'afikz', 'afilo', 'afilp', 'afilq', 'afilr', 'afils', 'afilt', 'afilu', 'afilv', 'afilw', 'afilx', 'afily', 'afilz', 'afimo', 'afimp', 'afimq', 'afimr', 'afims', 'afimt', 'afimu', 'afimv', 'afimw', 'afimx', 'afimy', 'afimz', 'afino', 'afinp', 'afinq', 'afinr', 'afins', 'afint', 'afinu', 'afinv', 'afinw', 'afinx', 'afiny', 'afinz', 'bcgjo', 'bcgjp', 'bcgjq', 'bcgjr', 'bcgjs', 'bcgjt', 'bcgju', 'bcgjv', 'bcgjw', 'bcgjx', 'bcgjy', 'bcgjz', 'bcgko', 'bcgkp', 'bcgkq', 'bcgkr', 'bcgks', 'bcgkt', 'bcgku', 'bcgkv', 'bcgkw', 'bcgkx', 'bcgky', 'bcgkz', 'bcglo', 'bcglp', 'bcglq', 'bcglr', 'bcgls', 'bcglt', 'bcglu', 'bcglv', 'bcglw', 'bcglx', 'bcgly', 'bcglz', 'bcgmo', 'bcgmp', 'bcgmq', 'bcgmr', 'bcgms', 'bcgmt', 'bcgmu', 'bcgmv', 'bcgmw', 'bcgmx', 'bcgmy', 'bcgmz', 'bcgno', 'bcgnp', 'bcgnq', 'bcgnr', 'bcgns', 'bcgnt', 'bcgnu', 'bcgnv', 'bcgnw', 'bcgnx', 'bcgny', 'bcgnz', 'bchjo', 'bchjp', 'bchjq', 'bchjr', 'bchjs', 'bchjt', 'bchju', 'bchjv', 'bchjw', 'bchjx', 'bchjy', 'bchjz', 'bchko', 'bchkp', 'bchkq', 'bchkr', 'bchks', 'bchkt', 'bchku', 'bchkv', 'bchkw', 'bchkx', 'bchky', 'bchkz', 'bchlo', 'bchlp', 'bchlq', 'bchlr', 'bchls', 'bchlt', 'bchlu', 'bchlv', 'bchlw', 'bchlx', 'bchly', 'bchlz', 'bchmo', 'bchmp', 'bchmq', 'bchmr', 'bchms', 'bchmt', 'bchmu', 'bchmv', 'bchmw', 'bchmx', 'bchmy', 'bchmz', 'bchno', 'bchnp', 'bchnq', 'bchnr', 'bchns', 'bchnt', 'bchnu', 'bchnv', 'bchnw', 'bchnx', 'bchny', 'bchnz', 'bcijo', 'bcijp', 'bcijq', 'bcijr', 'bcijs', 'bcijt', 'bciju', 'bcijv', 'bcijw', 'bcijx', 'bcijy', 'bcijz', 'bciko', 'bcikp', 'bcikq', 'bcikr', 'bciks', 'bcikt', 'bciku', 'bcikv', 'bcikw', 'bcikx', 'bciky', 'bcikz', 'bcilo', 'bcilp', 'bcilq', 'bcilr', 'bcils', 'bcilt', 'bcilu', 'bcilv', 'bcilw', 'bcilx', 'bcily', 'bcilz', 'bcimo', 'bcimp', 'bcimq', 'bcimr', 'bcims', 'bcimt', 'bcimu', 'bcimv', 'bcimw', 'bcimx', 'bcimy', 'bcimz', 'bcino', 'bcinp', 'bcinq', 'bcinr', 'bcins', 'bcint', 'bcinu', 'bcinv', 'bcinw', 'bcinx', 'bciny', 'bcinz', 'bdgjo', 'bdgjp', 'bdgjq', 'bdgjr', 'bdgjs', 'bdgjt', 'bdgju', 'bdgjv', 'bdgjw', 'bdgjx', 'bdgjy', 'bdgjz', 'bdgko', 'bdgkp', 'bdgkq', 'bdgkr', 'bdgks', 'bdgkt', 'bdgku', 'bdgkv', 'bdgkw', 'bdgkx', 'bdgky', 'bdgkz', 'bdglo', 'bdglp', 'bdglq', 'bdglr', 'bdgls', 'bdglt', 'bdglu', 'bdglv', 'bdglw', 'bdglx', 'bdgly', 'bdglz', 'bdgmo', 'bdgmp', 'bdgmq', 'bdgmr', 'bdgms', 'bdgmt', 'bdgmu', 'bdgmv', 'bdgmw', 'bdgmx', 'bdgmy', 'bdgmz', 'bdgno', 'bdgnp', 'bdgnq', 'bdgnr', 'bdgns', 'bdgnt', 'bdgnu', 'bdgnv', 'bdgnw', 'bdgnx', 'bdgny', 'bdgnz', 'bdhjo', 'bdhjp', 'bdhjq', 'bdhjr', 'bdhjs', 'bdhjt', 'bdhju', 'bdhjv', 'bdhjw', 'bdhjx', 'bdhjy', 'bdhjz', 'bdhko', 'bdhkp', 'bdhkq', 'bdhkr', 'bdhks', 'bdhkt', 'bdhku', 'bdhkv', 'bdhkw', 'bdhkx', 'bdhky', 'bdhkz', 'bdhlo', 'bdhlp', 'bdhlq', 'bdhlr', 'bdhls', 'bdhlt', 'bdhlu', 'bdhlv', 'bdhlw', 'bdhlx', 'bdhly', 'bdhlz', 'bdhmo', 'bdhmp', 'bdhmq', 'bdhmr', 'bdhms', 'bdhmt', 'bdhmu', 'bdhmv', 'bdhmw', 'bdhmx', 'bdhmy', 'bdhmz', 'bdhno', 'bdhnp', 'bdhnq', 'bdhnr', 'bdhns', 'bdhnt', 'bdhnu', 'bdhnv', 'bdhnw', 'bdhnx', 'bdhny', 'bdhnz', 'bdijo', 'bdijp', 'bdijq', 'bdijr', 'bdijs', 'bdijt', 'bdiju', 'bdijv', 'bdijw', 'bdijx', 'bdijy', 'bdijz', 'bdiko', 'bdikp', 'bdikq', 'bdikr', 'bdiks', 'bdikt', 'bdiku', 'bdikv', 'bdikw', 'bdikx', 'bdiky', 'bdikz', 'bdilo', 'bdilp', 'bdilq', 'bdilr', 'bdils', 'bdilt', 'bdilu', 'bdilv', 'bdilw', 'bdilx', 'bdily', 'bdilz', 'bdimo', 'bdimp', 'bdimq', 'bdimr', 'bdims', 'bdimt', 'bdimu', 'bdimv', 'bdimw', 'bdimx', 'bdimy', 'bdimz', 'bdino', 'bdinp', 'bdinq', 'bdinr', 'bdins', 'bdint', 'bdinu', 'bdinv', 'bdinw', 'bdinx', 'bdiny', 'bdinz', 'begjo', 'begjp', 'begjq', 'begjr', 'begjs', 'begjt', 'begju', 'begjv', 'begjw', 'begjx', 'begjy', 'begjz', 'begko', 'begkp', 'begkq', 'begkr', 'begks', 'begkt', 'begku', 'begkv', 'begkw', 'begkx', 'begky', 'begkz', 'beglo', 'beglp', 'beglq', 'beglr', 'begls', 'beglt', 'beglu', 'beglv', 'beglw', 'beglx', 'begly', 'beglz', 'begmo', 'begmp', 'begmq', 'begmr', 'begms', 'begmt', 'begmu', 'begmv', 'begmw', 'begmx', 'begmy', 'begmz', 'begno', 'begnp', 'begnq', 'begnr', 'begns', 'begnt', 'begnu', 'begnv', 'begnw', 'begnx', 'begny', 'begnz', 'behjo', 'behjp', 'behjq', 'behjr', 'behjs', 'behjt', 'behju', 'behjv', 'behjw', 'behjx', 'behjy', 'behjz', 'behko', 'behkp', 'behkq', 'behkr', 'behks', 'behkt', 'behku', 'behkv', 'behkw', 'behkx', 'behky', 'behkz', 'behlo', 'behlp', 'behlq', 'behlr', 'behls', 'behlt', 'behlu', 'behlv', 'behlw', 'behlx', 'behly', 'behlz', 'behmo', 'behmp', 'behmq', 'behmr', 'behms', 'behmt', 'behmu', 'behmv', 'behmw', 'behmx', 'behmy', 'behmz', 'behno', 'behnp', 'behnq', 'behnr', 'behns', 'behnt', 'behnu', 'behnv', 'behnw', 'behnx', 'behny', 'behnz', 'beijo', 'beijp', 'beijq', 'beijr', 'beijs', 'beijt', 'beiju', 'beijv', 'beijw', 'beijx', 'beijy', 'beijz', 'beiko', 'beikp', 'beikq', 'beikr', 'beiks', 'beikt', 'beiku', 'beikv', 'beikw', 'beikx', 'beiky', 'beikz', 'beilo', 'beilp', 'beilq', 'beilr', 'beils', 'beilt', 'beilu', 'beilv', 'beilw', 'beilx', 'beily', 'beilz', 'beimo', 'beimp', 'beimq', 'beimr', 'beims', 'beimt', 'beimu', 'beimv', 'beimw', 'beimx', 'beimy', 'beimz', 'beino', 'beinp', 'beinq', 'beinr', 'beins', 'beint', 'beinu', 'beinv', 'beinw', 'beinx', 'beiny', 'beinz', 'bfgjo', 'bfgjp', 'bfgjq', 'bfgjr', 'bfgjs', 'bfgjt', 'bfgju', 'bfgjv', 'bfgjw', 'bfgjx', 'bfgjy', 'bfgjz', 'bfgko', 'bfgkp', 'bfgkq', 'bfgkr', 'bfgks', 'bfgkt', 'bfgku', 'bfgkv', 'bfgkw', 'bfgkx', 'bfgky', 'bfgkz', 'bfglo', 'bfglp', 'bfglq', 'bfglr', 'bfgls', 'bfglt', 'bfglu', 'bfglv', 'bfglw', 'bfglx', 'bfgly', 'bfglz', 'bfgmo', 'bfgmp', 'bfgmq', 'bfgmr', 'bfgms', 'bfgmt', 'bfgmu', 'bfgmv', 'bfgmw', 'bfgmx', 'bfgmy', 'bfgmz', 'bfgno', 'bfgnp', 'bfgnq', 'bfgnr', 'bfgns', 'bfgnt', 'bfgnu', 'bfgnv', 'bfgnw', 'bfgnx', 'bfgny', 'bfgnz', 'bfhjo', 'bfhjp', 'bfhjq', 'bfhjr', 'bfhjs', 'bfhjt', 'bfhju', 'bfhjv', 'bfhjw', 'bfhjx', 'bfhjy', 'bfhjz', 'bfhko', 'bfhkp', 'bfhkq', 'bfhkr', 'bfhks', 'bfhkt', 'bfhku', 'bfhkv', 'bfhkw', 'bfhkx', 'bfhky', 'bfhkz', 'bfhlo', 'bfhlp', 'bfhlq', 'bfhlr', 'bfhls', 'bfhlt', 'bfhlu', 'bfhlv', 'bfhlw', 'bfhlx', 'bfhly', 'bfhlz', 'bfhmo', 'bfhmp', 'bfhmq', 'bfhmr', 'bfhms', 'bfhmt', 'bfhmu', 'bfhmv', 'bfhmw', 'bfhmx', 'bfhmy', 'bfhmz', 'bfhno', 'bfhnp', 'bfhnq', 'bfhnr', 'bfhns', 'bfhnt', 'bfhnu', 'bfhnv', 'bfhnw', 'bfhnx', 'bfhny', 'bfhnz', 'bfijo', 'bfijp', 'bfijq', 'bfijr', 'bfijs', 'bfijt', 'bfiju', 'bfijv', 'bfijw', 'bfijx', 'bfijy', 'bfijz', 'bfiko', 'bfikp', 'bfikq', 'bfikr', 'bfiks', 'bfikt', 'bfiku', 'bfikv', 'bfikw', 'bfikx', 'bfiky', 'bfikz', 'bfilo', 'bfilp', 'bfilq', 'bfilr', 'bfils', 'bfilt', 'bfilu', 'bfilv', 'bfilw', 'bfilx', 'bfily', 'bfilz', 'bfimo', 'bfimp', 'bfimq', 'bfimr', 'bfims', 'bfimt', 'bfimu', 'bfimv', 'bfimw', 'bfimx', 'bfimy', 'bfimz', 'bfino', 'bfinp', 'bfinq', 'bfinr', 'bfins', 'bfint', 'bfinu', 'bfinv', 'bfinw', 'bfinx', 'bfiny', 'bfinz']\n assert candidate(expression = \"a{b{c,d},e{f,g}}h\") == ['abch', 'abdh', 'aefh', 'aegh']\n assert candidate(expression = \"{a,{b,{c,{d,e}}}}{f,g}\") == ['af', 'ag', 'bf', 'bg', 'cf', 'cg', 'df', 'dg', 'ef', 'eg']\n assert candidate(expression = \"{a,b,c}{d{e,f},g{h,i}}{j,k}\") == ['adej', 'adek', 'adfj', 'adfk', 'aghj', 'aghk', 'agij', 'agik', 'bdej', 'bdek', 'bdfj', 'bdfk', 'bghj', 'bghk', 'bgij', 'bgik', 'cdej', 'cdek', 'cdfj', 'cdfk', 'cghj', 'cghk', 'cgij', 'cgik']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,h}\") == ['adg', 'adh', 'aeg', 'aeh', 'afg', 'afh', 'bdg', 'bdh', 'beg', 'beh', 'bfg', 'bfh', 'cdg', 'cdh', 'ceg', 'ceh', 'cfg', 'cfh']\n assert candidate(expression = \"{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}\") == ['aab', 'aac', 'bab', 'bac', 'cab', 'cac', 'dab', 'dac', 'eab', 'eac', 'fab', 'fac', 'gab', 'gac', 'hab', 'hac', 'iab', 'iac', 'jab', 'jac', 'kab', 'kac', 'lab', 'lac', 'mab', 'mac', 'nab', 'nac', 'oab', 'oac', 'pab', 'pac', 'qab', 'qac', 'rab', 'rac', 'sab', 'sac', 'tab', 'tac', 'uab', 'uac', 'vab', 'vac', 'wab', 'wac', 'xab', 'xac', 'yab', 'yac', 'zab', 'zac']\n assert candidate(expression = \"{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,y,z}\") == ['ax', 'ay', 'az', 'bx', 'by', 'bz', 'cx', 'cy', 'cz', 'dx', 'dy', 'dz', 'ex', 'ey', 'ez', 'fx', 'fy', 'fz', 'gx', 'gy', 'gz', 'hx', 'hy', 'hz', 'ix', 'iy', 'iz', 'jx', 'jy', 'jz', 'kx', 'ky', 'kz', 'lx', 'ly', 'lz', 'mx', 'my', 'mz', 'nx', 'ny', 'nz', 'ox', 'oy', 'oz', 'px', 'py', 'pz', 'qx', 'qy', 'qz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'tx', 'ty', 'tz', 'ux', 'uy', 'uz', 'vx', 'vy', 'vz', 'wx', 'wy', 'wz', 'xx', 'xy', 'xz', 'yx', 'yy', 'yz', 'zx', 'zy', 'zz']\n assert candidate(expression = \"{a,b{c,d},e{f,g}}{h,i}\") == ['ah', 'ai', 'bch', 'bci', 'bdh', 'bdi', 'efh', 'efi', 'egh', 'egi']\n assert candidate(expression = \"{a,b{c,d{e,f}}}{g,h}\") == ['ag', 'ah', 'bcg', 'bch', 'bdeg', 'bdeh', 'bdfg', 'bdfh']\n assert candidate(expression = \"{a,b}{c{d,e}}{f,g{h,i}}{j,k{m,n}}\") == ['acdfj', 'acdfkm', 'acdfkn', 'acdghj', 'acdghkm', 'acdghkn', 'acdgij', 'acdgikm', 'acdgikn', 'acefj', 'acefkm', 'acefkn', 'aceghj', 'aceghkm', 'aceghkn', 'acegij', 'acegikm', 'acegikn', 'bcdfj', 'bcdfkm', 'bcdfkn', 'bcdghj', 'bcdghkm', 'bcdghkn', 'bcdgij', 'bcdgikm', 'bcdgikn', 'bcefj', 'bcefkm', 'bcefkn', 'bceghj', 'bceghkm', 'bceghkn', 'bcegij', 'bcegikm', 'bcegikn']\n assert candidate(expression = \"{a,{b,{c,d}}}{e,{f,{g,h}}}\") == ['ae', 'af', 'ag', 'ah', 'be', 'bf', 'bg', 'bh', 'ce', 'cf', 'cg', 'ch', 'de', 'df', 'dg', 'dh']\n assert candidate(expression = \"{a,b}{c,d,e}{f,g,h}{i,j,k}\") == ['acfi', 'acfj', 'acfk', 'acgi', 'acgj', 'acgk', 'achi', 'achj', 'achk', 'adfi', 'adfj', 'adfk', 'adgi', 'adgj', 'adgk', 'adhi', 'adhj', 'adhk', 'aefi', 'aefj', 'aefk', 'aegi', 'aegj', 'aegk', 'aehi', 'aehj', 'aehk', 'bcfi', 'bcfj', 'bcfk', 'bcgi', 'bcgj', 'bcgk', 'bchi', 'bchj', 'bchk', 'bdfi', 'bdfj', 'bdfk', 'bdgi', 'bdgj', 'bdgk', 'bdhi', 'bdhj', 'bdhk', 'befi', 'befj', 'befk', 'begi', 'begj', 'begk', 'behi', 'behj', 'behk']\n assert candidate(expression = \"{a,b,c}{d,e,f,g}\") == ['ad', 'ae', 'af', 'ag', 'bd', 'be', 'bf', 'bg', 'cd', 'ce', 'cf', 'cg']\n assert candidate(expression = \"{a,{b,{c,{d,e}}}}f\") == ['af', 'bf', 'cf', 'df', 'ef']\n assert candidate(expression = \"{a,b}{c{d,e},f{g,h}}{i,j}{k,l}\") == ['acdik', 'acdil', 'acdjk', 'acdjl', 'aceik', 'aceil', 'acejk', 'acejl', 'afgik', 'afgil', 'afgjk', 'afgjl', 'afhik', 'afhil', 'afhjk', 'afhjl', 'bcdik', 'bcdil', 'bcdjk', 'bcdjl', 'bceik', 'bceil', 'bcejk', 'bcejl', 'bfgik', 'bfgil', 'bfgjk', 'bfgjl', 'bfhik', 'bfhil', 'bfhjk', 'bfhjl']\n assert candidate(expression = \"{a,b}{c,d{e,f}}\") == ['ac', 'ade', 'adf', 'bc', 'bde', 'bdf']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,h,{i,j},{k,l}}\") == ['adg', 'adh', 'adi', 'adj', 'adk', 'adl', 'aeg', 'aeh', 'aei', 'aej', 'aek', 'ael', 'afg', 'afh', 'afi', 'afj', 'afk', 'afl', 'bdg', 'bdh', 'bdi', 'bdj', 'bdk', 'bdl', 'beg', 'beh', 'bei', 'bej', 'bek', 'bel', 'bfg', 'bfh', 'bfi', 'bfj', 'bfk', 'bfl', 'cdg', 'cdh', 'cdi', 'cdj', 'cdk', 'cdl', 'ceg', 'ceh', 'cei', 'cej', 'cek', 'cel', 'cfg', 'cfh', 'cfi', 'cfj', 'cfk', 'cfl']\n assert candidate(expression = \"{{a,b,c},{d,e,f},{g,h,i}}{j,k,l}\") == ['aj', 'ak', 'al', 'bj', 'bk', 'bl', 'cj', 'ck', 'cl', 'dj', 'dk', 'dl', 'ej', 'ek', 'el', 'fj', 'fk', 'fl', 'gj', 'gk', 'gl', 'hj', 'hk', 'hl', 'ij', 'ik', 'il']\n assert candidate(expression = \"{a,b}{c,{d,e}}{f,{g,h}}{i,j}\") == ['acfi', 'acfj', 'acgi', 'acgj', 'achi', 'achj', 'adfi', 'adfj', 'adgi', 'adgj', 'adhi', 'adhj', 'aefi', 'aefj', 'aegi', 'aegj', 'aehi', 'aehj', 'bcfi', 'bcfj', 'bcgi', 'bcgj', 'bchi', 'bchj', 'bdfi', 'bdfj', 'bdgi', 'bdgj', 'bdhi', 'bdhj', 'befi', 'befj', 'begi', 'begj', 'behi', 'behj']\n assert candidate(expression = \"{a,b}{c,{d,e,f}}{g,h}\") == ['acg', 'ach', 'adg', 'adh', 'aeg', 'aeh', 'afg', 'afh', 'bcg', 'bch', 'bdg', 'bdh', 'beg', 'beh', 'bfg', 'bfh']\n assert candidate(expression = \"{a,{b,{c,{d,{e,f}}}}}\") == ['a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(expression = \"{a,b}{c,d}{e,f}\") == ['ace', 'acf', 'ade', 'adf', 'bce', 'bcf', 'bde', 'bdf']\n assert candidate(expression = \"{a,b}{c,d,e}{f,g,h,i}\") == ['acf', 'acg', 'ach', 'aci', 'adf', 'adg', 'adh', 'adi', 'aef', 'aeg', 'aeh', 'aei', 'bcf', 'bcg', 'bch', 'bci', 'bdf', 'bdg', 'bdh', 'bdi', 'bef', 'beg', 'beh', 'bei']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,h,i}{j,k,l,m,n,o,p}\") == ['adgj', 'adgk', 'adgl', 'adgm', 'adgn', 'adgo', 'adgp', 'adhj', 'adhk', 'adhl', 'adhm', 'adhn', 'adho', 'adhp', 'adij', 'adik', 'adil', 'adim', 'adin', 'adio', 'adip', 'aegj', 'aegk', 'aegl', 'aegm', 'aegn', 'aego', 'aegp', 'aehj', 'aehk', 'aehl', 'aehm', 'aehn', 'aeho', 'aehp', 'aeij', 'aeik', 'aeil', 'aeim', 'aein', 'aeio', 'aeip', 'afgj', 'afgk', 'afgl', 'afgm', 'afgn', 'afgo', 'afgp', 'afhj', 'afhk', 'afhl', 'afhm', 'afhn', 'afho', 'afhp', 'afij', 'afik', 'afil', 'afim', 'afin', 'afio', 'afip', 'bdgj', 'bdgk', 'bdgl', 'bdgm', 'bdgn', 'bdgo', 'bdgp', 'bdhj', 'bdhk', 'bdhl', 'bdhm', 'bdhn', 'bdho', 'bdhp', 'bdij', 'bdik', 'bdil', 'bdim', 'bdin', 'bdio', 'bdip', 'begj', 'begk', 'begl', 'begm', 'begn', 'bego', 'begp', 'behj', 'behk', 'behl', 'behm', 'behn', 'beho', 'behp', 'beij', 'beik', 'beil', 'beim', 'bein', 'beio', 'beip', 'bfgj', 'bfgk', 'bfgl', 'bfgm', 'bfgn', 'bfgo', 'bfgp', 'bfhj', 'bfhk', 'bfhl', 'bfhm', 'bfhn', 'bfho', 'bfhp', 'bfij', 'bfik', 'bfil', 'bfim', 'bfin', 'bfio', 'bfip', 'cdgj', 'cdgk', 'cdgl', 'cdgm', 'cdgn', 'cdgo', 'cdgp', 'cdhj', 'cdhk', 'cdhl', 'cdhm', 'cdhn', 'cdho', 'cdhp', 'cdij', 'cdik', 'cdil', 'cdim', 'cdin', 'cdio', 'cdip', 'cegj', 'cegk', 'cegl', 'cegm', 'cegn', 'cego', 'cegp', 'cehj', 'cehk', 'cehl', 'cehm', 'cehn', 'ceho', 'cehp', 'ceij', 'ceik', 'ceil', 'ceim', 'cein', 'ceio', 'ceip', 'cfgj', 'cfgk', 'cfgl', 'cfgm', 'cfgn', 'cfgo', 'cfgp', 'cfhj', 'cfhk', 'cfhl', 'cfhm', 'cfhn', 'cfho', 'cfhp', 'cfij', 'cfik', 'cfil', 'cfim', 'cfin', 'cfio', 'cfip']\n assert candidate(expression = \"{a{b,c},d{e,f}}{g{h,i},j{k,l}}\") == ['abgh', 'abgi', 'abjk', 'abjl', 'acgh', 'acgi', 'acjk', 'acjl', 'degh', 'degi', 'dejk', 'dejl', 'dfgh', 'dfgi', 'dfjk', 'dfjl']\n assert candidate(expression = \"{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(expression = \"{x{y,z},a{b,c}{d,e},f{g{h,i},j{k,l}},m{n{o,p},q{r,s}}}\") == ['abd', 'abe', 'acd', 'ace', 'fgh', 'fgi', 'fjk', 'fjl', 'mno', 'mnp', 'mqr', 'mqs', 'xy', 'xz']\n assert candidate(expression = \"{a,b{c{d,e},f},g{h,i}}{j,k}\") == ['aj', 'ak', 'bcdj', 'bcdk', 'bcej', 'bcek', 'bfj', 'bfk', 'ghj', 'ghk', 'gij', 'gik']\n assert candidate(expression = \"{a,b}c{d,e}\") == ['acd', 'ace', 'bcd', 'bce']\n assert candidate(expression = \"a{b{c{d,e},f},g{h,i{,j}}{k,l}}m\") == ['abcdm', 'abcem', 'abfm', 'aghkm', 'aghlm', 'agijkm', 'agijlm', 'agikm', 'agilm']\n assert candidate(expression = \"{a,b,c,d}{e,f,g,h}\") == ['ae', 'af', 'ag', 'ah', 'be', 'bf', 'bg', 'bh', 'ce', 'cf', 'cg', 'ch', 'de', 'df', 'dg', 'dh']\n assert candidate(expression = \"{a,b}{{c,d},{e,f}}{g,h}\") == ['acg', 'ach', 'adg', 'adh', 'aeg', 'aeh', 'afg', 'afh', 'bcg', 'bch', 'bdg', 'bdh', 'beg', 'beh', 'bfg', 'bfh']\n assert candidate(expression = \"{a,{b,c{d,e}},f{g,h}}\") == ['a', 'b', 'cd', 'ce', 'fg', 'fh']\n assert candidate(expression = \"{a,b}{c{d,e},f{g,h}}\") == ['acd', 'ace', 'afg', 'afh', 'bcd', 'bce', 'bfg', 'bfh']\n assert candidate(expression = \"{a,b{c,d}}{e,f}\") == ['ae', 'af', 'bce', 'bcf', 'bde', 'bdf']\n assert candidate(expression = \"a{b,{c,{d,e}}}{f,g}\") == ['abf', 'abg', 'acf', 'acg', 'adf', 'adg', 'aef', 'aeg']\n assert candidate(expression = \"{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}\") == ['aeiq', 'aeir', 'aeis', 'aeit', 'aeiu', 'aeiv', 'aeiw', 'aeix', 'aeiy', 'aeiz', 'aejq', 'aejr', 'aejs', 'aejt', 'aeju', 'aejv', 'aejw', 'aejx', 'aejy', 'aejz', 'aekq', 'aekr', 'aeks', 'aekt', 'aeku', 'aekv', 'aekw', 'aekx', 'aeky', 'aekz', 'aelq', 'aelr', 'aels', 'aelt', 'aelu', 'aelv', 'aelw', 'aelx', 'aely', 'aelz', 'aemq', 'aemr', 'aems', 'aemt', 'aemu', 'aemv', 'aemw', 'aemx', 'aemy', 'aemz', 'aenq', 'aenr', 'aens', 'aent', 'aenu', 'aenv', 'aenw', 'aenx', 'aeny', 'aenz', 'aeoq', 'aeor', 'aeos', 'aeot', 'aeou', 'aeov', 'aeow', 'aeox', 'aeoy', 'aeoz', 'aepq', 'aepr', 'aeps', 'aept', 'aepu', 'aepv', 'aepw', 'aepx', 'aepy', 'aepz', 'afiq', 'afir', 'afis', 'afit', 'afiu', 'afiv', 'afiw', 'afix', 'afiy', 'afiz', 'afjq', 'afjr', 'afjs', 'afjt', 'afju', 'afjv', 'afjw', 'afjx', 'afjy', 'afjz', 'afkq', 'afkr', 'afks', 'afkt', 'afku', 'afkv', 'afkw', 'afkx', 'afky', 'afkz', 'aflq', 'aflr', 'afls', 'aflt', 'aflu', 'aflv', 'aflw', 'aflx', 'afly', 'aflz', 'afmq', 'afmr', 'afms', 'afmt', 'afmu', 'afmv', 'afmw', 'afmx', 'afmy', 'afmz', 'afnq', 'afnr', 'afns', 'afnt', 'afnu', 'afnv', 'afnw', 'afnx', 'afny', 'afnz', 'afoq', 'afor', 'afos', 'afot', 'afou', 'afov', 'afow', 'afox', 'afoy', 'afoz', 'afpq', 'afpr', 'afps', 'afpt', 'afpu', 'afpv', 'afpw', 'afpx', 'afpy', 'afpz', 'agiq', 'agir', 'agis', 'agit', 'agiu', 'agiv', 'agiw', 'agix', 'agiy', 'agiz', 'agjq', 'agjr', 'agjs', 'agjt', 'agju', 'agjv', 'agjw', 'agjx', 'agjy', 'agjz', 'agkq', 'agkr', 'agks', 'agkt', 'agku', 'agkv', 'agkw', 'agkx', 'agky', 'agkz', 'aglq', 'aglr', 'agls', 'aglt', 'aglu', 'aglv', 'aglw', 'aglx', 'agly', 'aglz', 'agmq', 'agmr', 'agms', 'agmt', 'agmu', 'agmv', 'agmw', 'agmx', 'agmy', 'agmz', 'agnq', 'agnr', 'agns', 'agnt', 'agnu', 'agnv', 'agnw', 'agnx', 'agny', 'agnz', 'agoq', 'agor', 'agos', 'agot', 'agou', 'agov', 'agow', 'agox', 'agoy', 'agoz', 'agpq', 'agpr', 'agps', 'agpt', 'agpu', 'agpv', 'agpw', 'agpx', 'agpy', 'agpz', 'ahiq', 'ahir', 'ahis', 'ahit', 'ahiu', 'ahiv', 'ahiw', 'ahix', 'ahiy', 'ahiz', 'ahjq', 'ahjr', 'ahjs', 'ahjt', 'ahju', 'ahjv', 'ahjw', 'ahjx', 'ahjy', 'ahjz', 'ahkq', 'ahkr', 'ahks', 'ahkt', 'ahku', 'ahkv', 'ahkw', 'ahkx', 'ahky', 'ahkz', 'ahlq', 'ahlr', 'ahls', 'ahlt', 'ahlu', 'ahlv', 'ahlw', 'ahlx', 'ahly', 'ahlz', 'ahmq', 'ahmr', 'ahms', 'ahmt', 'ahmu', 'ahmv', 'ahmw', 'ahmx', 'ahmy', 'ahmz', 'ahnq', 'ahnr', 'ahns', 'ahnt', 'ahnu', 'ahnv', 'ahnw', 'ahnx', 'ahny', 'ahnz', 'ahoq', 'ahor', 'ahos', 'ahot', 'ahou', 'ahov', 'ahow', 'ahox', 'ahoy', 'ahoz', 'ahpq', 'ahpr', 'ahps', 'ahpt', 'ahpu', 'ahpv', 'ahpw', 'ahpx', 'ahpy', 'ahpz', 'beiq', 'beir', 'beis', 'beit', 'beiu', 'beiv', 'beiw', 'beix', 'beiy', 'beiz', 'bejq', 'bejr', 'bejs', 'bejt', 'beju', 'bejv', 'bejw', 'bejx', 'bejy', 'bejz', 'bekq', 'bekr', 'beks', 'bekt', 'beku', 'bekv', 'bekw', 'bekx', 'beky', 'bekz', 'belq', 'belr', 'bels', 'belt', 'belu', 'belv', 'belw', 'belx', 'bely', 'belz', 'bemq', 'bemr', 'bems', 'bemt', 'bemu', 'bemv', 'bemw', 'bemx', 'bemy', 'bemz', 'benq', 'benr', 'bens', 'bent', 'benu', 'benv', 'benw', 'benx', 'beny', 'benz', 'beoq', 'beor', 'beos', 'beot', 'beou', 'beov', 'beow', 'beox', 'beoy', 'beoz', 'bepq', 'bepr', 'beps', 'bept', 'bepu', 'bepv', 'bepw', 'bepx', 'bepy', 'bepz', 'bfiq', 'bfir', 'bfis', 'bfit', 'bfiu', 'bfiv', 'bfiw', 'bfix', 'bfiy', 'bfiz', 'bfjq', 'bfjr', 'bfjs', 'bfjt', 'bfju', 'bfjv', 'bfjw', 'bfjx', 'bfjy', 'bfjz', 'bfkq', 'bfkr', 'bfks', 'bfkt', 'bfku', 'bfkv', 'bfkw', 'bfkx', 'bfky', 'bfkz', 'bflq', 'bflr', 'bfls', 'bflt', 'bflu', 'bflv', 'bflw', 'bflx', 'bfly', 'bflz', 'bfmq', 'bfmr', 'bfms', 'bfmt', 'bfmu', 'bfmv', 'bfmw', 'bfmx', 'bfmy', 'bfmz', 'bfnq', 'bfnr', 'bfns', 'bfnt', 'bfnu', 'bfnv', 'bfnw', 'bfnx', 'bfny', 'bfnz', 'bfoq', 'bfor', 'bfos', 'bfot', 'bfou', 'bfov', 'bfow', 'bfox', 'bfoy', 'bfoz', 'bfpq', 'bfpr', 'bfps', 'bfpt', 'bfpu', 'bfpv', 'bfpw', 'bfpx', 'bfpy', 'bfpz', 'bgiq', 'bgir', 'bgis', 'bgit', 'bgiu', 'bgiv', 'bgiw', 'bgix', 'bgiy', 'bgiz', 'bgjq', 'bgjr', 'bgjs', 'bgjt', 'bgju', 'bgjv', 'bgjw', 'bgjx', 'bgjy', 'bgjz', 'bgkq', 'bgkr', 'bgks', 'bgkt', 'bgku', 'bgkv', 'bgkw', 'bgkx', 'bgky', 'bgkz', 'bglq', 'bglr', 'bgls', 'bglt', 'bglu', 'bglv', 'bglw', 'bglx', 'bgly', 'bglz', 'bgmq', 'bgmr', 'bgms', 'bgmt', 'bgmu', 'bgmv', 'bgmw', 'bgmx', 'bgmy', 'bgmz', 'bgnq', 'bgnr', 'bgns', 'bgnt', 'bgnu', 'bgnv', 'bgnw', 'bgnx', 'bgny', 'bgnz', 'bgoq', 'bgor', 'bgos', 'bgot', 'bgou', 'bgov', 'bgow', 'bgox', 'bgoy', 'bgoz', 'bgpq', 'bgpr', 'bgps', 'bgpt', 'bgpu', 'bgpv', 'bgpw', 'bgpx', 'bgpy', 'bgpz', 'bhiq', 'bhir', 'bhis', 'bhit', 'bhiu', 'bhiv', 'bhiw', 'bhix', 'bhiy', 'bhiz', 'bhjq', 'bhjr', 'bhjs', 'bhjt', 'bhju', 'bhjv', 'bhjw', 'bhjx', 'bhjy', 'bhjz', 'bhkq', 'bhkr', 'bhks', 'bhkt', 'bhku', 'bhkv', 'bhkw', 'bhkx', 'bhky', 'bhkz', 'bhlq', 'bhlr', 'bhls', 'bhlt', 'bhlu', 'bhlv', 'bhlw', 'bhlx', 'bhly', 'bhlz', 'bhmq', 'bhmr', 'bhms', 'bhmt', 'bhmu', 'bhmv', 'bhmw', 'bhmx', 'bhmy', 'bhmz', 'bhnq', 'bhnr', 'bhns', 'bhnt', 'bhnu', 'bhnv', 'bhnw', 'bhnx', 'bhny', 'bhnz', 'bhoq', 'bhor', 'bhos', 'bhot', 'bhou', 'bhov', 'bhow', 'bhox', 'bhoy', 'bhoz', 'bhpq', 'bhpr', 'bhps', 'bhpt', 'bhpu', 'bhpv', 'bhpw', 'bhpx', 'bhpy', 'bhpz', 'ceiq', 'ceir', 'ceis', 'ceit', 'ceiu', 'ceiv', 'ceiw', 'ceix', 'ceiy', 'ceiz', 'cejq', 'cejr', 'cejs', 'cejt', 'ceju', 'cejv', 'cejw', 'cejx', 'cejy', 'cejz', 'cekq', 'cekr', 'ceks', 'cekt', 'ceku', 'cekv', 'cekw', 'cekx', 'ceky', 'cekz', 'celq', 'celr', 'cels', 'celt', 'celu', 'celv', 'celw', 'celx', 'cely', 'celz', 'cemq', 'cemr', 'cems', 'cemt', 'cemu', 'cemv', 'cemw', 'cemx', 'cemy', 'cemz', 'cenq', 'cenr', 'cens', 'cent', 'cenu', 'cenv', 'cenw', 'cenx', 'ceny', 'cenz', 'ceoq', 'ceor', 'ceos', 'ceot', 'ceou', 'ceov', 'ceow', 'ceox', 'ceoy', 'ceoz', 'cepq', 'cepr', 'ceps', 'cept', 'cepu', 'cepv', 'cepw', 'cepx', 'cepy', 'cepz', 'cfiq', 'cfir', 'cfis', 'cfit', 'cfiu', 'cfiv', 'cfiw', 'cfix', 'cfiy', 'cfiz', 'cfjq', 'cfjr', 'cfjs', 'cfjt', 'cfju', 'cfjv', 'cfjw', 'cfjx', 'cfjy', 'cfjz', 'cfkq', 'cfkr', 'cfks', 'cfkt', 'cfku', 'cfkv', 'cfkw', 'cfkx', 'cfky', 'cfkz', 'cflq', 'cflr', 'cfls', 'cflt', 'cflu', 'cflv', 'cflw', 'cflx', 'cfly', 'cflz', 'cfmq', 'cfmr', 'cfms', 'cfmt', 'cfmu', 'cfmv', 'cfmw', 'cfmx', 'cfmy', 'cfmz', 'cfnq', 'cfnr', 'cfns', 'cfnt', 'cfnu', 'cfnv', 'cfnw', 'cfnx', 'cfny', 'cfnz', 'cfoq', 'cfor', 'cfos', 'cfot', 'cfou', 'cfov', 'cfow', 'cfox', 'cfoy', 'cfoz', 'cfpq', 'cfpr', 'cfps', 'cfpt', 'cfpu', 'cfpv', 'cfpw', 'cfpx', 'cfpy', 'cfpz', 'cgiq', 'cgir', 'cgis', 'cgit', 'cgiu', 'cgiv', 'cgiw', 'cgix', 'cgiy', 'cgiz', 'cgjq', 'cgjr', 'cgjs', 'cgjt', 'cgju', 'cgjv', 'cgjw', 'cgjx', 'cgjy', 'cgjz', 'cgkq', 'cgkr', 'cgks', 'cgkt', 'cgku', 'cgkv', 'cgkw', 'cgkx', 'cgky', 'cgkz', 'cglq', 'cglr', 'cgls', 'cglt', 'cglu', 'cglv', 'cglw', 'cglx', 'cgly', 'cglz', 'cgmq', 'cgmr', 'cgms', 'cgmt', 'cgmu', 'cgmv', 'cgmw', 'cgmx', 'cgmy', 'cgmz', 'cgnq', 'cgnr', 'cgns', 'cgnt', 'cgnu', 'cgnv', 'cgnw', 'cgnx', 'cgny', 'cgnz', 'cgoq', 'cgor', 'cgos', 'cgot', 'cgou', 'cgov', 'cgow', 'cgox', 'cgoy', 'cgoz', 'cgpq', 'cgpr', 'cgps', 'cgpt', 'cgpu', 'cgpv', 'cgpw', 'cgpx', 'cgpy', 'cgpz', 'chiq', 'chir', 'chis', 'chit', 'chiu', 'chiv', 'chiw', 'chix', 'chiy', 'chiz', 'chjq', 'chjr', 'chjs', 'chjt', 'chju', 'chjv', 'chjw', 'chjx', 'chjy', 'chjz', 'chkq', 'chkr', 'chks', 'chkt', 'chku', 'chkv', 'chkw', 'chkx', 'chky', 'chkz', 'chlq', 'chlr', 'chls', 'chlt', 'chlu', 'chlv', 'chlw', 'chlx', 'chly', 'chlz', 'chmq', 'chmr', 'chms', 'chmt', 'chmu', 'chmv', 'chmw', 'chmx', 'chmy', 'chmz', 'chnq', 'chnr', 'chns', 'chnt', 'chnu', 'chnv', 'chnw', 'chnx', 'chny', 'chnz', 'choq', 'chor', 'chos', 'chot', 'chou', 'chov', 'chow', 'chox', 'choy', 'choz', 'chpq', 'chpr', 'chps', 'chpt', 'chpu', 'chpv', 'chpw', 'chpx', 'chpy', 'chpz', 'deiq', 'deir', 'deis', 'deit', 'deiu', 'deiv', 'deiw', 'deix', 'deiy', 'deiz', 'dejq', 'dejr', 'dejs', 'dejt', 'deju', 'dejv', 'dejw', 'dejx', 'dejy', 'dejz', 'dekq', 'dekr', 'deks', 'dekt', 'deku', 'dekv', 'dekw', 'dekx', 'deky', 'dekz', 'delq', 'delr', 'dels', 'delt', 'delu', 'delv', 'delw', 'delx', 'dely', 'delz', 'demq', 'demr', 'dems', 'demt', 'demu', 'demv', 'demw', 'demx', 'demy', 'demz', 'denq', 'denr', 'dens', 'dent', 'denu', 'denv', 'denw', 'denx', 'deny', 'denz', 'deoq', 'deor', 'deos', 'deot', 'deou', 'deov', 'deow', 'deox', 'deoy', 'deoz', 'depq', 'depr', 'deps', 'dept', 'depu', 'depv', 'depw', 'depx', 'depy', 'depz', 'dfiq', 'dfir', 'dfis', 'dfit', 'dfiu', 'dfiv', 'dfiw', 'dfix', 'dfiy', 'dfiz', 'dfjq', 'dfjr', 'dfjs', 'dfjt', 'dfju', 'dfjv', 'dfjw', 'dfjx', 'dfjy', 'dfjz', 'dfkq', 'dfkr', 'dfks', 'dfkt', 'dfku', 'dfkv', 'dfkw', 'dfkx', 'dfky', 'dfkz', 'dflq', 'dflr', 'dfls', 'dflt', 'dflu', 'dflv', 'dflw', 'dflx', 'dfly', 'dflz', 'dfmq', 'dfmr', 'dfms', 'dfmt', 'dfmu', 'dfmv', 'dfmw', 'dfmx', 'dfmy', 'dfmz', 'dfnq', 'dfnr', 'dfns', 'dfnt', 'dfnu', 'dfnv', 'dfnw', 'dfnx', 'dfny', 'dfnz', 'dfoq', 'dfor', 'dfos', 'dfot', 'dfou', 'dfov', 'dfow', 'dfox', 'dfoy', 'dfoz', 'dfpq', 'dfpr', 'dfps', 'dfpt', 'dfpu', 'dfpv', 'dfpw', 'dfpx', 'dfpy', 'dfpz', 'dgiq', 'dgir', 'dgis', 'dgit', 'dgiu', 'dgiv', 'dgiw', 'dgix', 'dgiy', 'dgiz', 'dgjq', 'dgjr', 'dgjs', 'dgjt', 'dgju', 'dgjv', 'dgjw', 'dgjx', 'dgjy', 'dgjz', 'dgkq', 'dgkr', 'dgks', 'dgkt', 'dgku', 'dgkv', 'dgkw', 'dgkx', 'dgky', 'dgkz', 'dglq', 'dglr', 'dgls', 'dglt', 'dglu', 'dglv', 'dglw', 'dglx', 'dgly', 'dglz', 'dgmq', 'dgmr', 'dgms', 'dgmt', 'dgmu', 'dgmv', 'dgmw', 'dgmx', 'dgmy', 'dgmz', 'dgnq', 'dgnr', 'dgns', 'dgnt', 'dgnu', 'dgnv', 'dgnw', 'dgnx', 'dgny', 'dgnz', 'dgoq', 'dgor', 'dgos', 'dgot', 'dgou', 'dgov', 'dgow', 'dgox', 'dgoy', 'dgoz', 'dgpq', 'dgpr', 'dgps', 'dgpt', 'dgpu', 'dgpv', 'dgpw', 'dgpx', 'dgpy', 'dgpz', 'dhiq', 'dhir', 'dhis', 'dhit', 'dhiu', 'dhiv', 'dhiw', 'dhix', 'dhiy', 'dhiz', 'dhjq', 'dhjr', 'dhjs', 'dhjt', 'dhju', 'dhjv', 'dhjw', 'dhjx', 'dhjy', 'dhjz', 'dhkq', 'dhkr', 'dhks', 'dhkt', 'dhku', 'dhkv', 'dhkw', 'dhkx', 'dhky', 'dhkz', 'dhlq', 'dhlr', 'dhls', 'dhlt', 'dhlu', 'dhlv', 'dhlw', 'dhlx', 'dhly', 'dhlz', 'dhmq', 'dhmr', 'dhms', 'dhmt', 'dhmu', 'dhmv', 'dhmw', 'dhmx', 'dhmy', 'dhmz', 'dhnq', 'dhnr', 'dhns', 'dhnt', 'dhnu', 'dhnv', 'dhnw', 'dhnx', 'dhny', 'dhnz', 'dhoq', 'dhor', 'dhos', 'dhot', 'dhou', 'dhov', 'dhow', 'dhox', 'dhoy', 'dhoz', 'dhpq', 'dhpr', 'dhps', 'dhpt', 'dhpu', 'dhpv', 'dhpw', 'dhpx', 'dhpy', 'dhpz']\n assert candidate(expression = \"{a,b,c}{d,e{f,g{h,i}}}{j,k}\") == ['adj', 'adk', 'aefj', 'aefk', 'aeghj', 'aeghk', 'aegij', 'aegik', 'bdj', 'bdk', 'befj', 'befk', 'beghj', 'beghk', 'begij', 'begik', 'cdj', 'cdk', 'cefj', 'cefk', 'ceghj', 'ceghk', 'cegij', 'cegik']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,h,i}\") == ['adg', 'adh', 'adi', 'aeg', 'aeh', 'aei', 'afg', 'afh', 'afi', 'bdg', 'bdh', 'bdi', 'beg', 'beh', 'bei', 'bfg', 'bfh', 'bfi', 'cdg', 'cdh', 'cdi', 'ceg', 'ceh', 'cei', 'cfg', 'cfh', 'cfi']\n assert candidate(expression = \"{x,y}{a,b,c}{m,n}\") == ['xam', 'xan', 'xbm', 'xbn', 'xcm', 'xcn', 'yam', 'yan', 'ybm', 'ybn', 'ycm', 'ycn']\n assert candidate(expression = \"{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}\") == ['ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bk', 'bl', 'bm', 'bn', 'bo', 'bp', 'bq', 'br', 'bs', 'bt', 'bu', 'bv', 'bw', 'bx', 'by', 'bz', 'cd', 'ce', 'cf', 'cg', 'ch', 'ci', 'cj', 'ck', 'cl', 'cm', 'cn', 'co', 'cp', 'cq', 'cr', 'cs', 'ct', 'cu', 'cv', 'cw', 'cx', 'cy', 'cz']\n assert candidate(expression = \"{a{b{c,d},e},f{g,h}}{i,j}\") == ['abci', 'abcj', 'abdi', 'abdj', 'aei', 'aej', 'fgi', 'fgj', 'fhi', 'fhj']\n assert candidate(expression = \"{a{b{c,d{e,f}},g{h,i{}}},j{k{l,m{n{o,p},q{r,s}}},x{y,z}}}\") == ['abc,jklabc', 'abc,jkljkl', 'abc,jkmnoabc', 'abc,jkmnojkmno', 'abc,jkmnpabc', 'abc,jkmnpjkmnp', 'abc,jkmqrabc', 'abc,jkmqrjkmqr', 'abc,jkmqsabc', 'abc,jkmqsjkmqs', 'abc,jxyabc', 'abc,jxyjxy', 'abc,jxzabc', 'abc,jxzjxz', 'abde,jklabde', 'abde,jkljkl', 'abde,jkmnoabde', 'abde,jkmnojkmno', 'abde,jkmnpabde', 'abde,jkmnpjkmnp', 'abde,jkmqrabde', 'abde,jkmqrjkmqr', 'abde,jkmqsabde', 'abde,jkmqsjkmqs', 'abde,jxyabde', 'abde,jxyjxy', 'abde,jxzabde', 'abde,jxzjxz', 'abdf,jklabdf', 'abdf,jkljkl', 'abdf,jkmnoabdf', 'abdf,jkmnojkmno', 'abdf,jkmnpabdf', 'abdf,jkmnpjkmnp', 'abdf,jkmqrabdf', 'abdf,jkmqrjkmqr', 'abdf,jkmqsabdf', 'abdf,jkmqsjkmqs', 'abdf,jxyabdf', 'abdf,jxyjxy', 'abdf,jxzabdf', 'abdf,jxzjxz', 'agh,jklagh', 'agh,jkljkl', 'agh,jkmnoagh', 'agh,jkmnojkmno', 'agh,jkmnpagh', 'agh,jkmnpjkmnp', 'agh,jkmqragh', 'agh,jkmqrjkmqr', 'agh,jkmqsagh', 'agh,jkmqsjkmqs', 'agh,jxyagh', 'agh,jxyjxy', 'agh,jxzagh', 'agh,jxzjxz', 'agi', 'agijkl', 'agijkmno', 'agijkmnp', 'agijkmqr', 'agijkmqs', 'agijxy', 'agijxz']\n assert candidate(expression = \"{a,b,c,d,e}{f,g,h,i,j,k}{l,m,n,o,p}\") == ['afl', 'afm', 'afn', 'afo', 'afp', 'agl', 'agm', 'agn', 'ago', 'agp', 'ahl', 'ahm', 'ahn', 'aho', 'ahp', 'ail', 'aim', 'ain', 'aio', 'aip', 'ajl', 'ajm', 'ajn', 'ajo', 'ajp', 'akl', 'akm', 'akn', 'ako', 'akp', 'bfl', 'bfm', 'bfn', 'bfo', 'bfp', 'bgl', 'bgm', 'bgn', 'bgo', 'bgp', 'bhl', 'bhm', 'bhn', 'bho', 'bhp', 'bil', 'bim', 'bin', 'bio', 'bip', 'bjl', 'bjm', 'bjn', 'bjo', 'bjp', 'bkl', 'bkm', 'bkn', 'bko', 'bkp', 'cfl', 'cfm', 'cfn', 'cfo', 'cfp', 'cgl', 'cgm', 'cgn', 'cgo', 'cgp', 'chl', 'chm', 'chn', 'cho', 'chp', 'cil', 'cim', 'cin', 'cio', 'cip', 'cjl', 'cjm', 'cjn', 'cjo', 'cjp', 'ckl', 'ckm', 'ckn', 'cko', 'ckp', 'dfl', 'dfm', 'dfn', 'dfo', 'dfp', 'dgl', 'dgm', 'dgn', 'dgo', 'dgp', 'dhl', 'dhm', 'dhn', 'dho', 'dhp', 'dil', 'dim', 'din', 'dio', 'dip', 'djl', 'djm', 'djn', 'djo', 'djp', 'dkl', 'dkm', 'dkn', 'dko', 'dkp', 'efl', 'efm', 'efn', 'efo', 'efp', 'egl', 'egm', 'egn', 'ego', 'egp', 'ehl', 'ehm', 'ehn', 'eho', 'ehp', 'eil', 'eim', 'ein', 'eio', 'eip', 'ejl', 'ejm', 'ejn', 'ejo', 'ejp', 'ekl', 'ekm', 'ekn', 'eko', 'ekp']\n assert candidate(expression = \"{a{b{c{d{e}}}}}{f{g{h{i}}}}\") == ['abcdefghi']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,h,i}{j,k,l}\") == ['adgj', 'adgk', 'adgl', 'adhj', 'adhk', 'adhl', 'adij', 'adik', 'adil', 'aegj', 'aegk', 'aegl', 'aehj', 'aehk', 'aehl', 'aeij', 'aeik', 'aeil', 'afgj', 'afgk', 'afgl', 'afhj', 'afhk', 'afhl', 'afij', 'afik', 'afil', 'bdgj', 'bdgk', 'bdgl', 'bdhj', 'bdhk', 'bdhl', 'bdij', 'bdik', 'bdil', 'begj', 'begk', 'begl', 'behj', 'behk', 'behl', 'beij', 'beik', 'beil', 'bfgj', 'bfgk', 'bfgl', 'bfhj', 'bfhk', 'bfhl', 'bfij', 'bfik', 'bfil', 'cdgj', 'cdgk', 'cdgl', 'cdhj', 'cdhk', 'cdhl', 'cdij', 'cdik', 'cdil', 'cegj', 'cegk', 'cegl', 'cehj', 'cehk', 'cehl', 'ceij', 'ceik', 'ceil', 'cfgj', 'cfgk', 'cfgl', 'cfhj', 'cfhk', 'cfhl', 'cfij', 'cfik', 'cfil']\n assert candidate(expression = \"{a,b}{c,d}{e,f}{g,h}\") == ['aceg', 'aceh', 'acfg', 'acfh', 'adeg', 'adeh', 'adfg', 'adfh', 'bceg', 'bceh', 'bcfg', 'bcfh', 'bdeg', 'bdeh', 'bdfg', 'bdfh']\n assert candidate(expression = \"{a,b}{c,d}{e,{f,g{h,i}}}\") == ['ace', 'acf', 'acgh', 'acgi', 'ade', 'adf', 'adgh', 'adgi', 'bce', 'bcf', 'bcgh', 'bcgi', 'bde', 'bdf', 'bdgh', 'bdgi']\n assert candidate(expression = \"{a{b{c,d},e},f{g,h}}\") == ['abc', 'abd', 'ae', 'fg', 'fh']\n assert candidate(expression = \"{a,b}{c,d,e}{f,g,h}\") == ['acf', 'acg', 'ach', 'adf', 'adg', 'adh', 'aef', 'aeg', 'aeh', 'bcf', 'bcg', 'bch', 'bdf', 'bdg', 'bdh', 'bef', 'beg', 'beh']\n assert candidate(expression = \"{a{b,c},{d,e}{f,g}}\") == ['ab', 'ac', 'df', 'dg', 'ef', 'eg']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,h,i,j}\") == ['adg', 'adh', 'adi', 'adj', 'aeg', 'aeh', 'aei', 'aej', 'afg', 'afh', 'afi', 'afj', 'bdg', 'bdh', 'bdi', 'bdj', 'beg', 'beh', 'bei', 'bej', 'bfg', 'bfh', 'bfi', 'bfj', 'cdg', 'cdh', 'cdi', 'cdj', 'ceg', 'ceh', 'cei', 'cej', 'cfg', 'cfh', 'cfi', 'cfj']\n assert candidate(expression = \"{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}\") == ['ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'bc', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bk', 'bl', 'bm', 'bn', 'bo', 'bp', 'bq', 'br', 'bs', 'bt', 'bu', 'bv', 'bw', 'bx', 'by', 'bz']\n assert candidate(expression = \"a{b,c}d{e,f}g{h,i}\") == ['abdegh', 'abdegi', 'abdfgh', 'abdfgi', 'acdegh', 'acdegi', 'acdfgh', 'acdfgi']\n assert candidate(expression = \"{a,b{c,d{e,f}},g{h,i{,j}}{k,l}}m{n,o{p,q}}\") == ['amn', 'amop', 'amoq', 'bcmn', 'bcmop', 'bcmoq', 'bdemn', 'bdemop', 'bdemoq', 'bdfmn', 'bdfmop', 'bdfmoq', 'ghkmn', 'ghkmop', 'ghkmoq', 'ghlmn', 'ghlmop', 'ghlmoq', 'gijkmn', 'gijkmop', 'gijkmoq', 'gijlmn', 'gijlmop', 'gijlmoq', 'gikmn', 'gikmop', 'gikmoq', 'gilmn', 'gilmop', 'gilmoq']\n assert candidate(expression = \"{a,b}{c{d,e{f,g}},h}\") == ['acd', 'acef', 'aceg', 'ah', 'bcd', 'bcef', 'bceg', 'bh']\n assert candidate(expression = \"{a,b}{c{d{e,f},g},h{ij,k}}\") == ['acde', 'acdf', 'acg', 'ahij', 'ahk', 'bcde', 'bcdf', 'bcg', 'bhij', 'bhk']\n assert candidate(expression = \"{a{b,c},d{e,f}}{g,h}\") == ['abg', 'abh', 'acg', 'ach', 'deg', 'deh', 'dfg', 'dfh']\n assert candidate(expression = \"{a,b{c,d{e,f}},g{h,i{,j}}}\") == ['a', 'bc', 'bde', 'bdf', 'gh', 'gi', 'gij']\n assert candidate(expression = \"{a,b{c,d}}{e,f{g,h}}{i,{j,k}}\") == ['aei', 'aej', 'aek', 'afgi', 'afgj', 'afgk', 'afhi', 'afhj', 'afhk', 'bcei', 'bcej', 'bcek', 'bcfgi', 'bcfgj', 'bcfgk', 'bcfhi', 'bcfhj', 'bcfhk', 'bdei', 'bdej', 'bdek', 'bdfgi', 'bdfgj', 'bdfgk', 'bdfhi', 'bdfhj', 'bdfhk']\n assert candidate(expression = \"{x{y,z},{a,b,c}{d,e},{f,g}{h,{i,j}}}\") == ['ad', 'ae', 'bd', 'be', 'cd', 'ce', 'fh', 'fi', 'fj', 'gh', 'gi', 'gj', 'xy', 'xz']\n assert candidate(expression = \"{a,b,c}{d,e,f}{g,{h,i}}\") == ['adg', 'adh', 'adi', 'aeg', 'aeh', 'aei', 'afg', 'afh', 'afi', 'bdg', 'bdh', 'bdi', 'beg', 'beh', 'bei', 'bfg', 'bfh', 'bfi', 'cdg', 'cdh', 'cdi', 'ceg', 'ceh', 'cei', 'cfg', 'cfh', 'cfi']\n assert candidate(expression = \"{x,y,z}{a,b,c}{m,n}\") == ['xam', 'xan', 'xbm', 'xbn', 'xcm', 'xcn', 'yam', 'yan', 'ybm', 'ybn', 'ycm', 'ycn', 'zam', 'zan', 'zbm', 'zbn', 'zcm', 'zcn']\n assert candidate(expression = \"{{a,b},{c,d}}{e,f}{g,h}\") == ['aeg', 'aeh', 'afg', 'afh', 'beg', 'beh', 'bfg', 'bfh', 'ceg', 'ceh', 'cfg', 'cfh', 'deg', 'deh', 'dfg', 'dfh']\n assert candidate(expression = \"{a,b}c{d,e}{f,g}\") == ['acdf', 'acdg', 'acef', 'aceg', 'bcdf', 'bcdg', 'bcef', 'bceg']\n assert candidate(expression = \"{a,b{c{d,e}}}{f,g{h,i}}{j,k{m,n}}\") == ['afj', 'afkm', 'afkn', 'aghj', 'aghkm', 'aghkn', 'agij', 'agikm', 'agikn', 'bcdfj', 'bcdfkm', 'bcdfkn', 'bcdghj', 'bcdghkm', 'bcdghkn', 'bcdgij', 'bcdgikm', 'bcdgikn', 'bcefj', 'bcefkm', 'bcefkn', 'bceghj', 'bceghkm', 'bceghkn', 'bcegij', 'bcegikm', 'bcegikn']\n assert candidate(expression = \"{a,{b,{c,{d,{e,{f,g}}}}}}\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(expression = \"{a{b,c},{d,e}f}\") == ['ab', 'ac', 'df', 'ef']\n", "comparison": "exact"}, "public_tests": ["\"{a,b}{c,{d,e}}\"", "\"{{a,z},a{b,c},{ab,z}}\""], "hints": ["You can write helper methods to parse the next \"chunk\" of the expression. If you see eg. \"a\", the answer is just the set {a}. If you see \"{\", you parse until you complete the \"}\" (the number of { and } seen are equal) and that becomes a chunk that you find where the appropriate commas are, and parse each individual expression between the commas."], "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().braceExpansionII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:22+00:00", "tests_total": 100, "tests_dropped": 7, "flags": [], "topic_tags": ["hash-table", "string", "backtracking", "stack", "breadth-first-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def braceExpansionII(self, expression: str) -> list[str]:", "container": "Solution", "callable": "braceExpansionII", "parameters": [{"name": "expression", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1103, "task_id": "distribute-candies-to-people", "difficulty": "Easy", "problem_description": "We distribute some number of candies, to a row of n = num_people people in the following way:\n\nWe then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last person.\n\nThen, we go back to the start of the row, giving n + 1 candies to the first person, n + 2 candies to the second person, and so on until we give 2 * n candies to the last person.\n\nThis process repeats (with us giving one more candy each time, and moving to the start of the row after we reach the end) until we run out of candies. The last person will receive all of our remaining candies (not necessarily one more than the previous gift).\n\nReturn an array (of length num_people and sum candies) that represents the final distribution of candies.\n\nExample 1:\n\nInput: candies = 7, num_people = 4\nOutput: [1,2,3,1]\nExplanation:\nOn the first turn, ans[0] += 1, and the array is [1,0,0,0].\nOn the second turn, ans[1] += 2, and the array is [1,2,0,0].\nOn the third turn, ans[2] += 3, and the array is [1,2,3,0].\nOn the fourth turn, ans[3] += 1 (because there is only one candy left), and the final array is [1,2,3,1].\n\nExample 2:\n\nInput: candies = 10, num_people = 3\nOutput: [5,2,3]\nExplanation:\nOn the first turn, ans[0] += 1, and the array is [1,0,0].\nOn the second turn, ans[1] += 2, and the array is [1,2,0].\nOn the third turn, ans[2] += 3, and the array is [1,2,3].\nOn the fourth turn, ans[0] += 4, and the final array is [5,2,3].\n\nConstraints:\n\n- 1 <= candies <= 10^9\n- 1 <= num_people <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candies = 500000000,num_people = 500) == [1008064, 1008128, 1008192, 1008256, 1008320, 1008384, 1008448, 1008512, 1008576, 1008640, 1008704, 1008768, 1008832, 1008896, 1008960, 1009024, 1009088, 1009152, 1009216, 1009280, 1009344, 1009408, 1009472, 1009536, 1009600, 1009664, 1009728, 1009792, 1009856, 1009920, 1009984, 1010048, 1010112, 1010176, 1010240, 1010304, 1010368, 1010432, 1010496, 1010560, 1010624, 1010688, 1010752, 1010816, 1010880, 1010944, 1011008, 1011072, 1011136, 1011200, 1011264, 1011328, 1011392, 1011456, 1011520, 1011584, 1011648, 1011712, 1011776, 1011840, 1011904, 1011968, 1012032, 1012096, 1012160, 1012224, 1012288, 1012352, 1012416, 1012480, 1012544, 1012608, 1012672, 1012736, 1012800, 1012864, 1012928, 1012992, 1013056, 1013120, 1013184, 1013248, 1013312, 1013376, 1013440, 1013504, 1013568, 1013632, 1013696, 1013760, 1013824, 1013888, 1013952, 1014016, 1014080, 1014144, 1014208, 1014272, 1014336, 1014400, 1014464, 1014528, 1014592, 1014656, 1014720, 1014784, 1014848, 1014912, 1014976, 1015040, 1015104, 1015168, 1015232, 1015296, 1015360, 1015424, 1015488, 1015552, 1015616, 1015680, 1015744, 1015808, 992996, 984312, 984375, 984438, 984501, 984564, 984627, 984690, 984753, 984816, 984879, 984942, 985005, 985068, 985131, 985194, 985257, 985320, 985383, 985446, 985509, 985572, 985635, 985698, 985761, 985824, 985887, 985950, 986013, 986076, 986139, 986202, 986265, 986328, 986391, 986454, 986517, 986580, 986643, 986706, 986769, 986832, 986895, 986958, 987021, 987084, 987147, 987210, 987273, 987336, 987399, 987462, 987525, 987588, 987651, 987714, 987777, 987840, 987903, 987966, 988029, 988092, 988155, 988218, 988281, 988344, 988407, 988470, 988533, 988596, 988659, 988722, 988785, 988848, 988911, 988974, 989037, 989100, 989163, 989226, 989289, 989352, 989415, 989478, 989541, 989604, 989667, 989730, 989793, 989856, 989919, 989982, 990045, 990108, 990171, 990234, 990297, 990360, 990423, 990486, 990549, 990612, 990675, 990738, 990801, 990864, 990927, 990990, 991053, 991116, 991179, 991242, 991305, 991368, 991431, 991494, 991557, 991620, 991683, 991746, 991809, 991872, 991935, 991998, 992061, 992124, 992187, 992250, 992313, 992376, 992439, 992502, 992565, 992628, 992691, 992754, 992817, 992880, 992943, 993006, 993069, 993132, 993195, 993258, 993321, 993384, 993447, 993510, 993573, 993636, 993699, 993762, 993825, 993888, 993951, 994014, 994077, 994140, 994203, 994266, 994329, 994392, 994455, 994518, 994581, 994644, 994707, 994770, 994833, 994896, 994959, 995022, 995085, 995148, 995211, 995274, 995337, 995400, 995463, 995526, 995589, 995652, 995715, 995778, 995841, 995904, 995967, 996030, 996093, 996156, 996219, 996282, 996345, 996408, 996471, 996534, 996597, 996660, 996723, 996786, 996849, 996912, 996975, 997038, 997101, 997164, 997227, 997290, 997353, 997416, 997479, 997542, 997605, 997668, 997731, 997794, 997857, 997920, 997983, 998046, 998109, 998172, 998235, 998298, 998361, 998424, 998487, 998550, 998613, 998676, 998739, 998802, 998865, 998928, 998991, 999054, 999117, 999180, 999243, 999306, 999369, 999432, 999495, 999558, 999621, 999684, 999747, 999810, 999873, 999936, 999999, 1000062, 1000125, 1000188, 1000251, 1000314, 1000377, 1000440, 1000503, 1000566, 1000629, 1000692, 1000755, 1000818, 1000881, 1000944, 1001007, 1001070, 1001133, 1001196, 1001259, 1001322, 1001385, 1001448, 1001511, 1001574, 1001637, 1001700, 1001763, 1001826, 1001889, 1001952, 1002015, 1002078, 1002141, 1002204, 1002267, 1002330, 1002393, 1002456, 1002519, 1002582, 1002645, 1002708, 1002771, 1002834, 1002897, 1002960, 1003023, 1003086, 1003149, 1003212, 1003275, 1003338, 1003401, 1003464, 1003527, 1003590, 1003653, 1003716, 1003779, 1003842, 1003905, 1003968, 1004031, 1004094, 1004157, 1004220, 1004283, 1004346, 1004409, 1004472, 1004535, 1004598, 1004661, 1004724, 1004787, 1004850, 1004913, 1004976, 1005039, 1005102, 1005165, 1005228, 1005291, 1005354, 1005417, 1005480, 1005543, 1005606, 1005669, 1005732, 1005795, 1005858, 1005921, 1005984, 1006047, 1006110, 1006173, 1006236, 1006299, 1006362, 1006425, 1006488, 1006551, 1006614, 1006677, 1006740, 1006803, 1006866, 1006929, 1006992, 1007055, 1007118, 1007181, 1007244, 1007307, 1007370, 1007433, 1007496, 1007559, 1007622, 1007685, 1007748, 1007811, 1007874, 1007937, 1008000]\n assert candidate(candies = 1,num_people = 1) == [1]\n assert candidate(candies = 50,num_people = 5) == [7, 9, 11, 13, 10]\n assert candidate(candies = 20,num_people = 5) == [6, 2, 3, 4, 5]\n assert candidate(candies = 1000,num_people = 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, 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, 0, 0, 0, 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(candies = 10,num_people = 5) == [1, 2, 3, 4, 0]\n assert candidate(candies = 7,num_people = 4) == [1, 2, 3, 1]\n assert candidate(candies = 1000000000,num_people = 1000) == [990045, 990090, 990135, 990180, 990225, 990270, 990315, 990360, 990405, 990450, 990495, 990540, 990585, 990630, 990675, 990720, 990765, 990810, 990855, 990900, 990945, 990990, 991035, 991080, 991125, 991170, 991215, 991260, 991305, 991350, 991395, 991440, 991485, 991530, 991575, 991620, 991665, 991710, 991755, 991800, 991845, 991890, 991935, 991980, 992025, 992070, 992115, 992160, 992205, 992250, 992295, 992340, 992385, 992430, 992475, 992520, 992565, 992610, 992655, 992700, 992745, 992790, 992835, 992880, 992925, 992970, 993015, 993060, 993105, 993150, 993195, 993240, 993285, 993330, 993375, 993420, 993465, 993510, 993555, 993600, 993645, 993690, 993735, 993780, 993825, 993870, 993915, 993960, 994005, 994050, 994095, 994140, 994185, 994230, 994275, 994320, 994365, 994410, 994455, 994500, 994545, 994590, 994635, 994680, 994725, 994770, 994815, 994860, 994905, 994950, 994995, 995040, 995085, 995130, 995175, 995220, 995265, 995310, 995355, 995400, 995445, 995490, 995535, 995580, 995625, 995670, 995715, 995760, 995805, 995850, 995895, 995940, 995985, 996030, 996075, 996120, 996165, 996210, 996255, 996300, 996345, 996390, 996435, 996480, 996525, 996570, 996615, 996660, 996705, 996750, 996795, 996840, 996885, 996930, 996975, 997020, 997065, 997110, 997155, 997200, 997245, 997290, 997335, 997380, 997425, 997470, 997515, 997560, 997605, 997650, 997695, 997740, 997785, 997830, 997875, 997920, 997965, 998010, 998055, 998100, 998145, 998190, 998235, 998280, 998325, 998370, 998415, 998460, 998505, 998550, 998595, 998640, 998685, 998730, 998775, 998820, 998865, 998910, 998955, 999000, 999045, 999090, 999135, 999180, 999225, 999270, 999315, 999360, 999405, 999450, 999495, 999540, 999585, 999630, 999675, 999720, 999765, 999810, 999855, 999900, 999945, 999990, 1000035, 1000080, 1000125, 1000170, 1000215, 1000260, 1000305, 1000350, 1000395, 1000440, 1000485, 1000530, 1000575, 1000620, 1000665, 1000710, 1000755, 1000800, 1000845, 1000890, 1000935, 1000980, 1001025, 1001070, 1001115, 1001160, 1001205, 1001250, 1001295, 1001340, 1001385, 1001430, 1001475, 1001520, 1001565, 1001610, 1001655, 1001700, 1001745, 1001790, 1001835, 1001880, 1001925, 1001970, 1002015, 1002060, 1002105, 1002150, 1002195, 1002240, 1002285, 1002330, 1002375, 1002420, 1002465, 1002510, 1002555, 1002600, 1002645, 1002690, 1002735, 1002780, 1002825, 1002870, 1002915, 1002960, 1003005, 1003050, 1003095, 1003140, 1003185, 1003230, 1003275, 1003320, 1003365, 1003410, 1003455, 1003500, 1003545, 1003590, 1003635, 1003680, 1003725, 1003770, 1003815, 1003860, 1003905, 1003950, 1003995, 1004040, 1004085, 1004130, 1004175, 1004220, 1004265, 1004310, 1004355, 1004400, 1004445, 1004490, 1004535, 1004580, 1004625, 1004670, 1004715, 1004760, 1004805, 1004850, 1004895, 1004940, 1004985, 1005030, 1005075, 1005120, 1005165, 1005210, 1005255, 1005300, 1005345, 1005390, 1005435, 1005480, 1005525, 1005570, 1005615, 1005660, 1005705, 1005750, 1005795, 1005840, 1005885, 1005930, 1005975, 1006020, 1006065, 1006110, 1006155, 1006200, 1006245, 1006290, 1006335, 1006380, 1006425, 1006470, 1006515, 1006560, 1006605, 1006650, 1006695, 1006740, 1006785, 1006830, 1006875, 1006920, 1006965, 1007010, 1007055, 1007100, 1007145, 1007190, 1007235, 1007280, 1007325, 1007370, 1007415, 1007460, 1007505, 1007550, 1007595, 1007640, 1007685, 1007730, 1007775, 1007820, 1007865, 1007910, 1007955, 1008000, 1008045, 1008090, 1008135, 1008180, 1008225, 1008270, 1008315, 1008360, 1008405, 1008450, 1008495, 1008540, 1008585, 1008630, 1008675, 1008720, 1008765, 1008810, 1008855, 1008900, 1008945, 1008990, 1009035, 1009080, 1009125, 1009170, 1009215, 1009260, 1009305, 1009350, 1009395, 1009440, 1009485, 1009530, 1009575, 1009620, 1009665, 1009710, 1009755, 1009800, 1009845, 1009890, 1009935, 1009980, 1010025, 1010070, 1010115, 1010160, 1010205, 1010250, 1010295, 1010340, 1010385, 1010430, 1010475, 1010520, 1010565, 1010610, 1010655, 1010700, 1010745, 1010790, 1010835, 1010880, 1010925, 1010970, 1011015, 1011060, 1011105, 1011150, 1011195, 1011240, 1011285, 1011330, 1011375, 1011420, 1011465, 1011510, 1011555, 1011600, 1011645, 1011690, 1011735, 1011780, 1011825, 1011870, 1011915, 1011960, 1012005, 1012050, 1012095, 1012140, 1012185, 1012230, 1012275, 1012320, 1012365, 1012410, 1012455, 1012500, 1012545, 1012590, 1012635, 1012680, 1012725, 1012770, 1012815, 1012860, 1012905, 1012950, 1012995, 1013040, 1013085, 1013130, 1013175, 1013220, 1013265, 1013310, 1013355, 1013400, 1013445, 1013490, 1013535, 1013580, 1013625, 1013670, 1013715, 1013760, 1013805, 1013850, 1013895, 1013940, 1013985, 1014030, 1014075, 1014120, 1014165, 1014210, 1014255, 1014300, 1014345, 1014390, 1014435, 1014480, 1014525, 1014570, 1014615, 1014660, 1014705, 1014750, 1014795, 1014840, 1014885, 1014930, 1014975, 1015020, 1015065, 1015110, 1015155, 1015200, 1015245, 1015290, 1015335, 1015380, 1015425, 1015470, 1015515, 1015560, 1015605, 1015650, 1015695, 1015740, 1015785, 1015830, 1015875, 1015920, 1015965, 1016010, 1016055, 1016100, 1016145, 1016190, 1016235, 1016280, 1016325, 1016370, 1016415, 1016460, 1016505, 1016550, 1016595, 1016640, 1016685, 1016730, 1016775, 1016820, 1016865, 1016910, 1016955, 1017000, 1017045, 1017090, 1017135, 1017180, 1017225, 1017270, 1017315, 1017360, 1017405, 1017450, 1017495, 1017540, 1017585, 1017630, 1017675, 1017720, 1017765, 1017810, 1017855, 1017900, 1017945, 1017990, 1018035, 1018080, 1018125, 1018170, 1018215, 1018260, 1018305, 1018350, 1018395, 1018440, 1018485, 1018530, 1018575, 1018620, 1018665, 1018710, 1018755, 1018800, 1018845, 1018890, 1018935, 1018980, 1019025, 1019070, 1019115, 1019160, 1019205, 1019250, 1019295, 1019340, 1019385, 1019430, 1019475, 1019520, 1019565, 1019610, 1019655, 1019700, 1019745, 1019790, 1019835, 1019880, 1019925, 1019970, 1020015, 1020060, 1020105, 1020150, 1020195, 1020240, 1020285, 1020330, 1020375, 1020420, 1020465, 1020510, 1020555, 1020600, 1020645, 1020690, 1020735, 1020780, 1020825, 1020870, 1020915, 1020960, 1021005, 1021050, 1021095, 1021140, 1021185, 1021230, 1021275, 1021320, 1021365, 1021410, 1021455, 1021500, 1021545, 1021590, 1021635, 1021680, 1021725, 1021770, 1021815, 1021860, 1021905, 1021950, 1021995, 1022040, 1022085, 1022130, 1022175, 1022220, 1022265, 1022310, 1022355, 1022400, 1016164, 977768, 977812, 977856, 977900, 977944, 977988, 978032, 978076, 978120, 978164, 978208, 978252, 978296, 978340, 978384, 978428, 978472, 978516, 978560, 978604, 978648, 978692, 978736, 978780, 978824, 978868, 978912, 978956, 979000, 979044, 979088, 979132, 979176, 979220, 979264, 979308, 979352, 979396, 979440, 979484, 979528, 979572, 979616, 979660, 979704, 979748, 979792, 979836, 979880, 979924, 979968, 980012, 980056, 980100, 980144, 980188, 980232, 980276, 980320, 980364, 980408, 980452, 980496, 980540, 980584, 980628, 980672, 980716, 980760, 980804, 980848, 980892, 980936, 980980, 981024, 981068, 981112, 981156, 981200, 981244, 981288, 981332, 981376, 981420, 981464, 981508, 981552, 981596, 981640, 981684, 981728, 981772, 981816, 981860, 981904, 981948, 981992, 982036, 982080, 982124, 982168, 982212, 982256, 982300, 982344, 982388, 982432, 982476, 982520, 982564, 982608, 982652, 982696, 982740, 982784, 982828, 982872, 982916, 982960, 983004, 983048, 983092, 983136, 983180, 983224, 983268, 983312, 983356, 983400, 983444, 983488, 983532, 983576, 983620, 983664, 983708, 983752, 983796, 983840, 983884, 983928, 983972, 984016, 984060, 984104, 984148, 984192, 984236, 984280, 984324, 984368, 984412, 984456, 984500, 984544, 984588, 984632, 984676, 984720, 984764, 984808, 984852, 984896, 984940, 984984, 985028, 985072, 985116, 985160, 985204, 985248, 985292, 985336, 985380, 985424, 985468, 985512, 985556, 985600, 985644, 985688, 985732, 985776, 985820, 985864, 985908, 985952, 985996, 986040, 986084, 986128, 986172, 986216, 986260, 986304, 986348, 986392, 986436, 986480, 986524, 986568, 986612, 986656, 986700, 986744, 986788, 986832, 986876, 986920, 986964, 987008, 987052, 987096, 987140, 987184, 987228, 987272, 987316, 987360, 987404, 987448, 987492, 987536, 987580, 987624, 987668, 987712, 987756, 987800, 987844, 987888, 987932, 987976, 988020, 988064, 988108, 988152, 988196, 988240, 988284, 988328, 988372, 988416, 988460, 988504, 988548, 988592, 988636, 988680, 988724, 988768, 988812, 988856, 988900, 988944, 988988, 989032, 989076, 989120, 989164, 989208, 989252, 989296, 989340, 989384, 989428, 989472, 989516, 989560, 989604, 989648, 989692, 989736, 989780, 989824, 989868, 989912, 989956, 990000]\n assert candidate(candies = 10,num_people = 3) == [5, 2, 3]\n assert candidate(candies = 100,num_people = 10) == [12, 14, 16, 13, 5, 6, 7, 8, 9, 10]\n assert candidate(candies = 20,num_people = 4) == [6, 7, 3, 4]\n assert candidate(candies = 500,num_people = 15) == [48, 23, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]\n assert candidate(candies = 150,num_people = 5) == [34, 35, 24, 27, 30]\n assert candidate(candies = 99,num_people = 5) == [18, 21, 24, 21, 15]\n assert candidate(candies = 1000,num_people = 1) == [1000]\n assert candidate(candies = 100,num_people = 1) == [100]\n assert candidate(candies = 890123456,num_people = 456) == [1950861, 1950954, 1951047, 1951140, 1951233, 1951326, 1951419, 1951512, 1951605, 1951698, 1951791, 1951884, 1951977, 1952070, 1952163, 1952256, 1952349, 1952442, 1952535, 1952628, 1952721, 1952814, 1952907, 1953000, 1953093, 1953186, 1953279, 1953372, 1953465, 1953558, 1953651, 1953744, 1953837, 1953930, 1954023, 1954116, 1954209, 1954302, 1954395, 1954488, 1954581, 1954674, 1954767, 1954860, 1954953, 1955046, 1955139, 1955232, 1955325, 1955418, 1955511, 1955604, 1955697, 1955790, 1955883, 1955976, 1956069, 1956162, 1956255, 1956348, 1956441, 1956534, 1956627, 1956720, 1956813, 1956906, 1956999, 1957092, 1957185, 1957278, 1957371, 1957464, 1957557, 1957650, 1957743, 1957836, 1957929, 1958022, 1958115, 1958208, 1958301, 1958394, 1958487, 1958580, 1958673, 1958766, 1958859, 1958952, 1959045, 1959138, 1959231, 1959324, 1959417, 1959510, 1959603, 1959696, 1959789, 1959882, 1959975, 1960068, 1960161, 1960254, 1960347, 1960440, 1960533, 1960626, 1960719, 1960812, 1960905, 1960998, 1961091, 1961184, 1961277, 1961370, 1961463, 1961556, 1961649, 1961742, 1961835, 1961928, 1962021, 1962114, 1962207, 1962300, 1962393, 1962486, 1962579, 1962672, 1962765, 1962858, 1962951, 1963044, 1963137, 1963230, 1963323, 1963416, 1963509, 1963602, 1963695, 1963788, 1963881, 1963974, 1964067, 1964160, 1964253, 1964346, 1964439, 1964532, 1964625, 1964718, 1964811, 1964904, 1964997, 1965090, 1965183, 1965276, 1965369, 1965462, 1965555, 1965648, 1965741, 1965834, 1965927, 1966020, 1966113, 1966206, 1966299, 1966392, 1966485, 1966578, 1966671, 1966764, 1966857, 1966950, 1967043, 1967136, 1967229, 1967322, 1967415, 1967508, 1967601, 1967694, 1967787, 1967880, 1967973, 1968066, 1968159, 1968252, 1968345, 1968438, 1968531, 1968624, 1968717, 1968810, 1968903, 1968996, 1969089, 1969182, 1969275, 1969368, 1969461, 1969554, 1969647, 1969740, 1969833, 1969926, 1970019, 1970112, 1970205, 1970298, 1970391, 1970484, 1970577, 1970670, 1970763, 1970856, 1970949, 1971042, 1971135, 1971228, 1971321, 1971414, 1971507, 1971600, 1971693, 1971786, 1971879, 1971972, 1972065, 1972158, 1972251, 1972344, 1972437, 1972530, 1972623, 1972716, 1972809, 1972902, 1972995, 1973088, 1950916, 1931080, 1931172, 1931264, 1931356, 1931448, 1931540, 1931632, 1931724, 1931816, 1931908, 1932000, 1932092, 1932184, 1932276, 1932368, 1932460, 1932552, 1932644, 1932736, 1932828, 1932920, 1933012, 1933104, 1933196, 1933288, 1933380, 1933472, 1933564, 1933656, 1933748, 1933840, 1933932, 1934024, 1934116, 1934208, 1934300, 1934392, 1934484, 1934576, 1934668, 1934760, 1934852, 1934944, 1935036, 1935128, 1935220, 1935312, 1935404, 1935496, 1935588, 1935680, 1935772, 1935864, 1935956, 1936048, 1936140, 1936232, 1936324, 1936416, 1936508, 1936600, 1936692, 1936784, 1936876, 1936968, 1937060, 1937152, 1937244, 1937336, 1937428, 1937520, 1937612, 1937704, 1937796, 1937888, 1937980, 1938072, 1938164, 1938256, 1938348, 1938440, 1938532, 1938624, 1938716, 1938808, 1938900, 1938992, 1939084, 1939176, 1939268, 1939360, 1939452, 1939544, 1939636, 1939728, 1939820, 1939912, 1940004, 1940096, 1940188, 1940280, 1940372, 1940464, 1940556, 1940648, 1940740, 1940832, 1940924, 1941016, 1941108, 1941200, 1941292, 1941384, 1941476, 1941568, 1941660, 1941752, 1941844, 1941936, 1942028, 1942120, 1942212, 1942304, 1942396, 1942488, 1942580, 1942672, 1942764, 1942856, 1942948, 1943040, 1943132, 1943224, 1943316, 1943408, 1943500, 1943592, 1943684, 1943776, 1943868, 1943960, 1944052, 1944144, 1944236, 1944328, 1944420, 1944512, 1944604, 1944696, 1944788, 1944880, 1944972, 1945064, 1945156, 1945248, 1945340, 1945432, 1945524, 1945616, 1945708, 1945800, 1945892, 1945984, 1946076, 1946168, 1946260, 1946352, 1946444, 1946536, 1946628, 1946720, 1946812, 1946904, 1946996, 1947088, 1947180, 1947272, 1947364, 1947456, 1947548, 1947640, 1947732, 1947824, 1947916, 1948008, 1948100, 1948192, 1948284, 1948376, 1948468, 1948560, 1948652, 1948744, 1948836, 1948928, 1949020, 1949112, 1949204, 1949296, 1949388, 1949480, 1949572, 1949664, 1949756, 1949848, 1949940, 1950032, 1950124, 1950216, 1950308, 1950400, 1950492, 1950584, 1950676, 1950768]\n assert candidate(candies = 888888888,num_people = 999) == [902140, 902183, 902226, 902269, 902312, 902355, 902398, 902441, 902484, 902527, 902570, 902613, 902656, 902699, 902742, 902785, 902828, 902871, 902914, 902957, 903000, 903043, 903086, 903129, 903172, 903215, 903258, 903301, 903344, 903387, 903430, 903473, 903516, 903559, 903602, 903645, 903688, 903731, 903774, 903817, 903860, 903903, 903946, 903989, 904032, 904075, 904118, 904161, 904204, 904247, 904290, 904333, 904376, 904419, 904462, 904505, 904548, 904591, 904634, 904677, 904720, 904763, 904806, 904849, 904892, 904935, 904978, 905021, 905064, 905107, 905150, 905193, 905236, 905279, 905322, 905365, 905408, 905451, 905494, 905537, 905580, 905623, 905666, 905709, 905752, 905795, 905838, 905881, 905924, 905967, 906010, 906053, 906096, 906139, 906182, 906225, 906268, 906311, 906354, 906397, 906440, 906483, 906526, 906569, 906612, 906655, 906698, 906741, 906784, 906827, 906870, 906913, 906956, 906999, 907042, 907085, 907128, 907171, 907214, 907257, 907300, 907343, 907386, 907429, 907472, 907515, 907558, 907601, 907644, 907687, 907730, 907773, 907816, 907859, 907902, 907945, 907988, 908031, 908074, 908117, 908160, 908203, 908246, 908289, 908332, 908375, 908418, 908461, 908504, 908547, 908590, 908633, 908676, 908719, 908762, 908805, 908848, 908891, 908934, 908977, 909020, 909063, 909106, 909149, 909192, 909235, 909278, 909321, 909364, 909407, 909450, 909493, 909536, 909579, 909622, 909665, 909708, 909751, 909794, 909837, 909880, 909923, 909966, 910009, 910052, 910095, 910138, 910181, 910224, 910267, 910310, 910353, 910396, 910439, 910482, 910525, 910568, 910611, 910654, 910697, 910740, 910783, 910826, 910869, 910912, 877313, 868833, 868875, 868917, 868959, 869001, 869043, 869085, 869127, 869169, 869211, 869253, 869295, 869337, 869379, 869421, 869463, 869505, 869547, 869589, 869631, 869673, 869715, 869757, 869799, 869841, 869883, 869925, 869967, 870009, 870051, 870093, 870135, 870177, 870219, 870261, 870303, 870345, 870387, 870429, 870471, 870513, 870555, 870597, 870639, 870681, 870723, 870765, 870807, 870849, 870891, 870933, 870975, 871017, 871059, 871101, 871143, 871185, 871227, 871269, 871311, 871353, 871395, 871437, 871479, 871521, 871563, 871605, 871647, 871689, 871731, 871773, 871815, 871857, 871899, 871941, 871983, 872025, 872067, 872109, 872151, 872193, 872235, 872277, 872319, 872361, 872403, 872445, 872487, 872529, 872571, 872613, 872655, 872697, 872739, 872781, 872823, 872865, 872907, 872949, 872991, 873033, 873075, 873117, 873159, 873201, 873243, 873285, 873327, 873369, 873411, 873453, 873495, 873537, 873579, 873621, 873663, 873705, 873747, 873789, 873831, 873873, 873915, 873957, 873999, 874041, 874083, 874125, 874167, 874209, 874251, 874293, 874335, 874377, 874419, 874461, 874503, 874545, 874587, 874629, 874671, 874713, 874755, 874797, 874839, 874881, 874923, 874965, 875007, 875049, 875091, 875133, 875175, 875217, 875259, 875301, 875343, 875385, 875427, 875469, 875511, 875553, 875595, 875637, 875679, 875721, 875763, 875805, 875847, 875889, 875931, 875973, 876015, 876057, 876099, 876141, 876183, 876225, 876267, 876309, 876351, 876393, 876435, 876477, 876519, 876561, 876603, 876645, 876687, 876729, 876771, 876813, 876855, 876897, 876939, 876981, 877023, 877065, 877107, 877149, 877191, 877233, 877275, 877317, 877359, 877401, 877443, 877485, 877527, 877569, 877611, 877653, 877695, 877737, 877779, 877821, 877863, 877905, 877947, 877989, 878031, 878073, 878115, 878157, 878199, 878241, 878283, 878325, 878367, 878409, 878451, 878493, 878535, 878577, 878619, 878661, 878703, 878745, 878787, 878829, 878871, 878913, 878955, 878997, 879039, 879081, 879123, 879165, 879207, 879249, 879291, 879333, 879375, 879417, 879459, 879501, 879543, 879585, 879627, 879669, 879711, 879753, 879795, 879837, 879879, 879921, 879963, 880005, 880047, 880089, 880131, 880173, 880215, 880257, 880299, 880341, 880383, 880425, 880467, 880509, 880551, 880593, 880635, 880677, 880719, 880761, 880803, 880845, 880887, 880929, 880971, 881013, 881055, 881097, 881139, 881181, 881223, 881265, 881307, 881349, 881391, 881433, 881475, 881517, 881559, 881601, 881643, 881685, 881727, 881769, 881811, 881853, 881895, 881937, 881979, 882021, 882063, 882105, 882147, 882189, 882231, 882273, 882315, 882357, 882399, 882441, 882483, 882525, 882567, 882609, 882651, 882693, 882735, 882777, 882819, 882861, 882903, 882945, 882987, 883029, 883071, 883113, 883155, 883197, 883239, 883281, 883323, 883365, 883407, 883449, 883491, 883533, 883575, 883617, 883659, 883701, 883743, 883785, 883827, 883869, 883911, 883953, 883995, 884037, 884079, 884121, 884163, 884205, 884247, 884289, 884331, 884373, 884415, 884457, 884499, 884541, 884583, 884625, 884667, 884709, 884751, 884793, 884835, 884877, 884919, 884961, 885003, 885045, 885087, 885129, 885171, 885213, 885255, 885297, 885339, 885381, 885423, 885465, 885507, 885549, 885591, 885633, 885675, 885717, 885759, 885801, 885843, 885885, 885927, 885969, 886011, 886053, 886095, 886137, 886179, 886221, 886263, 886305, 886347, 886389, 886431, 886473, 886515, 886557, 886599, 886641, 886683, 886725, 886767, 886809, 886851, 886893, 886935, 886977, 887019, 887061, 887103, 887145, 887187, 887229, 887271, 887313, 887355, 887397, 887439, 887481, 887523, 887565, 887607, 887649, 887691, 887733, 887775, 887817, 887859, 887901, 887943, 887985, 888027, 888069, 888111, 888153, 888195, 888237, 888279, 888321, 888363, 888405, 888447, 888489, 888531, 888573, 888615, 888657, 888699, 888741, 888783, 888825, 888867, 888909, 888951, 888993, 889035, 889077, 889119, 889161, 889203, 889245, 889287, 889329, 889371, 889413, 889455, 889497, 889539, 889581, 889623, 889665, 889707, 889749, 889791, 889833, 889875, 889917, 889959, 890001, 890043, 890085, 890127, 890169, 890211, 890253, 890295, 890337, 890379, 890421, 890463, 890505, 890547, 890589, 890631, 890673, 890715, 890757, 890799, 890841, 890883, 890925, 890967, 891009, 891051, 891093, 891135, 891177, 891219, 891261, 891303, 891345, 891387, 891429, 891471, 891513, 891555, 891597, 891639, 891681, 891723, 891765, 891807, 891849, 891891, 891933, 891975, 892017, 892059, 892101, 892143, 892185, 892227, 892269, 892311, 892353, 892395, 892437, 892479, 892521, 892563, 892605, 892647, 892689, 892731, 892773, 892815, 892857, 892899, 892941, 892983, 893025, 893067, 893109, 893151, 893193, 893235, 893277, 893319, 893361, 893403, 893445, 893487, 893529, 893571, 893613, 893655, 893697, 893739, 893781, 893823, 893865, 893907, 893949, 893991, 894033, 894075, 894117, 894159, 894201, 894243, 894285, 894327, 894369, 894411, 894453, 894495, 894537, 894579, 894621, 894663, 894705, 894747, 894789, 894831, 894873, 894915, 894957, 894999, 895041, 895083, 895125, 895167, 895209, 895251, 895293, 895335, 895377, 895419, 895461, 895503, 895545, 895587, 895629, 895671, 895713, 895755, 895797, 895839, 895881, 895923, 895965, 896007, 896049, 896091, 896133, 896175, 896217, 896259, 896301, 896343, 896385, 896427, 896469, 896511, 896553, 896595, 896637, 896679, 896721, 896763, 896805, 896847, 896889, 896931, 896973, 897015, 897057, 897099, 897141, 897183, 897225, 897267, 897309, 897351, 897393, 897435, 897477, 897519, 897561, 897603, 897645, 897687, 897729, 897771, 897813, 897855, 897897, 897939, 897981, 898023, 898065, 898107, 898149, 898191, 898233, 898275, 898317, 898359, 898401, 898443, 898485, 898527, 898569, 898611, 898653, 898695, 898737, 898779, 898821, 898863, 898905, 898947, 898989, 899031, 899073, 899115, 899157, 899199, 899241, 899283, 899325, 899367, 899409, 899451, 899493, 899535, 899577, 899619, 899661, 899703, 899745, 899787, 899829, 899871, 899913, 899955, 899997, 900039, 900081, 900123, 900165, 900207, 900249, 900291, 900333, 900375, 900417, 900459, 900501, 900543, 900585, 900627, 900669, 900711, 900753, 900795, 900837, 900879, 900921, 900963, 901005, 901047, 901089, 901131, 901173, 901215, 901257, 901299, 901341, 901383, 901425, 901467, 901509, 901551, 901593, 901635, 901677, 901719, 901761, 901803, 901845, 901887, 901929, 901971, 902013, 902055, 902097]\n assert candidate(candies = 1000000000,num_people = 2) == [500008040, 499991960]\n assert candidate(candies = 1,num_people = 10) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(candies = 50,num_people = 8) == [10, 7, 3, 4, 5, 6, 7, 8]\n assert candidate(candies = 999999999,num_people = 500) == [2002590, 2002680, 2002770, 2002860, 2002950, 2003040, 2003130, 2003220, 2003310, 2003400, 2003490, 2003580, 2003670, 2003760, 2003850, 2003940, 2004030, 2004120, 2004210, 2004300, 2004390, 2004480, 2004570, 2004660, 2004750, 2004840, 2004930, 2005020, 2005110, 2005200, 2005290, 2005380, 2005470, 2005560, 2005650, 2005740, 2005830, 2005920, 2006010, 2006100, 2006190, 2006280, 2006370, 2006460, 2006550, 2006640, 2006730, 2006820, 2006910, 2007000, 2007090, 2007180, 2007270, 2007360, 2007450, 2007540, 2007630, 2007720, 2007810, 2007900, 2007990, 2008080, 2008170, 2008260, 2008350, 2008440, 2008530, 2008620, 2008710, 2008800, 2008890, 2008980, 2009070, 2009160, 2009250, 2009340, 2009430, 2009520, 2009610, 2009700, 2009790, 2009880, 2009970, 2010060, 2010150, 2010240, 2010330, 2010420, 2010510, 2010600, 2010690, 2010780, 2010870, 2010960, 2011050, 2011140, 2011230, 2011320, 2011410, 2011500, 2011590, 2011680, 2011770, 2011860, 2011950, 2012040, 2012130, 2012220, 2012310, 2012400, 2012490, 2012580, 2012670, 2012760, 2012850, 2012940, 2013030, 2013120, 2013210, 2013300, 2013390, 2013480, 2013570, 2013660, 2013750, 2013840, 2013930, 2014020, 2014110, 2014200, 2014290, 2014380, 2014470, 2014560, 2014650, 2014740, 2014830, 2014920, 2015010, 2015100, 2015190, 2015280, 2015370, 2015460, 2015550, 2015640, 2015730, 2015820, 2015910, 2016000, 2016090, 2016180, 2016270, 2016360, 2016450, 2016540, 2016630, 2016720, 2016810, 2016900, 2016990, 2017080, 2017170, 2017260, 2017350, 2017440, 2017530, 2017620, 2017710, 2017800, 2017890, 2017980, 2018070, 2018160, 2018250, 2018340, 2018430, 2018520, 2018610, 2018700, 2018790, 2018880, 2018970, 2019060, 2019150, 2019240, 2019330, 2019420, 2019510, 2019600, 2019690, 2019780, 2019870, 2019960, 2020050, 2020140, 2020230, 2020320, 2020410, 2020500, 2020590, 2020680, 2020770, 2020860, 2020950, 2021040, 2021130, 2021220, 2021310, 2021400, 2021490, 2021580, 2021670, 2021760, 2021850, 2021940, 2022030, 2022120, 2022210, 2022300, 2016108, 1977758, 1977847, 1977936, 1978025, 1978114, 1978203, 1978292, 1978381, 1978470, 1978559, 1978648, 1978737, 1978826, 1978915, 1979004, 1979093, 1979182, 1979271, 1979360, 1979449, 1979538, 1979627, 1979716, 1979805, 1979894, 1979983, 1980072, 1980161, 1980250, 1980339, 1980428, 1980517, 1980606, 1980695, 1980784, 1980873, 1980962, 1981051, 1981140, 1981229, 1981318, 1981407, 1981496, 1981585, 1981674, 1981763, 1981852, 1981941, 1982030, 1982119, 1982208, 1982297, 1982386, 1982475, 1982564, 1982653, 1982742, 1982831, 1982920, 1983009, 1983098, 1983187, 1983276, 1983365, 1983454, 1983543, 1983632, 1983721, 1983810, 1983899, 1983988, 1984077, 1984166, 1984255, 1984344, 1984433, 1984522, 1984611, 1984700, 1984789, 1984878, 1984967, 1985056, 1985145, 1985234, 1985323, 1985412, 1985501, 1985590, 1985679, 1985768, 1985857, 1985946, 1986035, 1986124, 1986213, 1986302, 1986391, 1986480, 1986569, 1986658, 1986747, 1986836, 1986925, 1987014, 1987103, 1987192, 1987281, 1987370, 1987459, 1987548, 1987637, 1987726, 1987815, 1987904, 1987993, 1988082, 1988171, 1988260, 1988349, 1988438, 1988527, 1988616, 1988705, 1988794, 1988883, 1988972, 1989061, 1989150, 1989239, 1989328, 1989417, 1989506, 1989595, 1989684, 1989773, 1989862, 1989951, 1990040, 1990129, 1990218, 1990307, 1990396, 1990485, 1990574, 1990663, 1990752, 1990841, 1990930, 1991019, 1991108, 1991197, 1991286, 1991375, 1991464, 1991553, 1991642, 1991731, 1991820, 1991909, 1991998, 1992087, 1992176, 1992265, 1992354, 1992443, 1992532, 1992621, 1992710, 1992799, 1992888, 1992977, 1993066, 1993155, 1993244, 1993333, 1993422, 1993511, 1993600, 1993689, 1993778, 1993867, 1993956, 1994045, 1994134, 1994223, 1994312, 1994401, 1994490, 1994579, 1994668, 1994757, 1994846, 1994935, 1995024, 1995113, 1995202, 1995291, 1995380, 1995469, 1995558, 1995647, 1995736, 1995825, 1995914, 1996003, 1996092, 1996181, 1996270, 1996359, 1996448, 1996537, 1996626, 1996715, 1996804, 1996893, 1996982, 1997071, 1997160, 1997249, 1997338, 1997427, 1997516, 1997605, 1997694, 1997783, 1997872, 1997961, 1998050, 1998139, 1998228, 1998317, 1998406, 1998495, 1998584, 1998673, 1998762, 1998851, 1998940, 1999029, 1999118, 1999207, 1999296, 1999385, 1999474, 1999563, 1999652, 1999741, 1999830, 1999919, 2000008, 2000097, 2000186, 2000275, 2000364, 2000453, 2000542, 2000631, 2000720, 2000809, 2000898, 2000987, 2001076, 2001165, 2001254, 2001343, 2001432, 2001521, 2001610, 2001699, 2001788, 2001877, 2001966, 2002055, 2002144, 2002233, 2002322, 2002411, 2002500]\n assert candidate(candies = 987654321,num_people = 999) == [989055, 989100, 989145, 989190, 989235, 989280, 989325, 989370, 989415, 989460, 989505, 989550, 989595, 989640, 989685, 989730, 989775, 989820, 989865, 989910, 989955, 990000, 990045, 990090, 990135, 990180, 990225, 990270, 990315, 990360, 990405, 990450, 990495, 990540, 990585, 990630, 990675, 990720, 990765, 990810, 990855, 990900, 990945, 990990, 991035, 991080, 991125, 991170, 991215, 991260, 991305, 991350, 991395, 991440, 991485, 991530, 991575, 991620, 991665, 991710, 991755, 991800, 991845, 991890, 991935, 991980, 992025, 992070, 992115, 992160, 992205, 992250, 992295, 992340, 992385, 992430, 992475, 992520, 992565, 992610, 992655, 992700, 992745, 992790, 992835, 992880, 992925, 992970, 993015, 993060, 993105, 993150, 993195, 993240, 993285, 993330, 993375, 993420, 993465, 993510, 993555, 993600, 993645, 993690, 993735, 993780, 993825, 993870, 993915, 993960, 994005, 994050, 994095, 994140, 994185, 994230, 994275, 994320, 994365, 994410, 994455, 994500, 994545, 994590, 994635, 994680, 994725, 994770, 994815, 994860, 994905, 994950, 994995, 995040, 995085, 995130, 995175, 995220, 995265, 995310, 995355, 995400, 995445, 995490, 995535, 995580, 995625, 995670, 995715, 995760, 995805, 995850, 995895, 995940, 995985, 996030, 996075, 996120, 996165, 996210, 996255, 996300, 996345, 996390, 996435, 996480, 996525, 996570, 996615, 996660, 996705, 996750, 996795, 996840, 996885, 996930, 996975, 997020, 997065, 997110, 997155, 997200, 997245, 997290, 997335, 997380, 997425, 997470, 997515, 997560, 997605, 997650, 997695, 997740, 997785, 997830, 997875, 997920, 997965, 998010, 998055, 998100, 998145, 998190, 998235, 998280, 998325, 998370, 998415, 998460, 998505, 998550, 998595, 998640, 998685, 998730, 998775, 998820, 998865, 998910, 998955, 999000, 999045, 999090, 999135, 999180, 999225, 999270, 999315, 999360, 999405, 999450, 999495, 999540, 999585, 999630, 999675, 999720, 999765, 999810, 999855, 999900, 999945, 999990, 1000035, 1000080, 1000125, 1000170, 1000215, 1000260, 1000305, 1000350, 1000395, 1000440, 1000485, 1000530, 1000575, 1000620, 1000665, 1000710, 1000755, 1000800, 1000845, 1000890, 1000935, 1000980, 1001025, 1001070, 1001115, 1001160, 1001205, 1001250, 1001295, 1001340, 1001385, 1001430, 1001475, 1001520, 1001565, 1001610, 1001655, 1001700, 1001745, 1001790, 1001835, 1001880, 1001925, 1001970, 1002015, 1002060, 1002105, 1002150, 1002195, 1002240, 1002285, 1002330, 1002375, 1002420, 1002465, 1002510, 1002555, 1002600, 1002645, 1002690, 1002735, 1002780, 1002825, 1002870, 1002915, 1002960, 1003005, 1003050, 1003095, 1003140, 1003185, 1003230, 1003275, 1003320, 1003365, 1003410, 1003455, 1003500, 1003545, 1003590, 1003635, 1003680, 1003725, 1003770, 1003815, 1003860, 1003905, 1003950, 1003995, 1004040, 1004085, 1004130, 1004175, 1004220, 1004265, 1004310, 1004355, 1004400, 1004445, 1004490, 1004535, 1004580, 1004625, 1004670, 1004715, 1004760, 1004805, 1004850, 1004895, 1004940, 1004985, 1005030, 1005075, 1005120, 1005165, 1005210, 1005255, 1005300, 1005345, 1005390, 1005435, 1005480, 1005525, 1005570, 1005615, 1005660, 1005705, 1005750, 1005795, 1005840, 1005885, 1005930, 1005975, 1006020, 1006065, 1006110, 1006155, 1006200, 1006245, 1006290, 1006335, 1006380, 1006425, 1006470, 1006515, 1006560, 1006605, 1006650, 1006695, 1006740, 1006785, 1006830, 1006875, 1006920, 1006965, 1007010, 1007055, 1007100, 1007145, 1007190, 1007235, 1007280, 1007325, 1007370, 1007415, 1007460, 1007505, 1007550, 1007595, 1007640, 1007685, 1007730, 1007775, 1007820, 1007865, 1007910, 1007955, 1008000, 1008045, 1008090, 1008135, 1008180, 1008225, 1008270, 1008315, 1008360, 1008405, 1008450, 1008495, 1008540, 1008585, 1008630, 1008675, 1008720, 1008765, 1008810, 1008855, 1008900, 1008945, 1008990, 1009035, 1009080, 1009125, 1009170, 1009215, 1009260, 1009305, 1009350, 1009395, 1009440, 1009485, 1009530, 1009575, 1009620, 1009665, 1009710, 1009755, 1009800, 1009845, 1009890, 1009935, 1009980, 1010025, 1010070, 1010115, 1010160, 1010205, 1010250, 1010295, 1010340, 1010385, 1010430, 1010475, 1010520, 1010565, 1010610, 1010655, 1010700, 1010745, 1010790, 1010835, 1010880, 1010925, 1008501, 966570, 966614, 966658, 966702, 966746, 966790, 966834, 966878, 966922, 966966, 967010, 967054, 967098, 967142, 967186, 967230, 967274, 967318, 967362, 967406, 967450, 967494, 967538, 967582, 967626, 967670, 967714, 967758, 967802, 967846, 967890, 967934, 967978, 968022, 968066, 968110, 968154, 968198, 968242, 968286, 968330, 968374, 968418, 968462, 968506, 968550, 968594, 968638, 968682, 968726, 968770, 968814, 968858, 968902, 968946, 968990, 969034, 969078, 969122, 969166, 969210, 969254, 969298, 969342, 969386, 969430, 969474, 969518, 969562, 969606, 969650, 969694, 969738, 969782, 969826, 969870, 969914, 969958, 970002, 970046, 970090, 970134, 970178, 970222, 970266, 970310, 970354, 970398, 970442, 970486, 970530, 970574, 970618, 970662, 970706, 970750, 970794, 970838, 970882, 970926, 970970, 971014, 971058, 971102, 971146, 971190, 971234, 971278, 971322, 971366, 971410, 971454, 971498, 971542, 971586, 971630, 971674, 971718, 971762, 971806, 971850, 971894, 971938, 971982, 972026, 972070, 972114, 972158, 972202, 972246, 972290, 972334, 972378, 972422, 972466, 972510, 972554, 972598, 972642, 972686, 972730, 972774, 972818, 972862, 972906, 972950, 972994, 973038, 973082, 973126, 973170, 973214, 973258, 973302, 973346, 973390, 973434, 973478, 973522, 973566, 973610, 973654, 973698, 973742, 973786, 973830, 973874, 973918, 973962, 974006, 974050, 974094, 974138, 974182, 974226, 974270, 974314, 974358, 974402, 974446, 974490, 974534, 974578, 974622, 974666, 974710, 974754, 974798, 974842, 974886, 974930, 974974, 975018, 975062, 975106, 975150, 975194, 975238, 975282, 975326, 975370, 975414, 975458, 975502, 975546, 975590, 975634, 975678, 975722, 975766, 975810, 975854, 975898, 975942, 975986, 976030, 976074, 976118, 976162, 976206, 976250, 976294, 976338, 976382, 976426, 976470, 976514, 976558, 976602, 976646, 976690, 976734, 976778, 976822, 976866, 976910, 976954, 976998, 977042, 977086, 977130, 977174, 977218, 977262, 977306, 977350, 977394, 977438, 977482, 977526, 977570, 977614, 977658, 977702, 977746, 977790, 977834, 977878, 977922, 977966, 978010, 978054, 978098, 978142, 978186, 978230, 978274, 978318, 978362, 978406, 978450, 978494, 978538, 978582, 978626, 978670, 978714, 978758, 978802, 978846, 978890, 978934, 978978, 979022, 979066, 979110, 979154, 979198, 979242, 979286, 979330, 979374, 979418, 979462, 979506, 979550, 979594, 979638, 979682, 979726, 979770, 979814, 979858, 979902, 979946, 979990, 980034, 980078, 980122, 980166, 980210, 980254, 980298, 980342, 980386, 980430, 980474, 980518, 980562, 980606, 980650, 980694, 980738, 980782, 980826, 980870, 980914, 980958, 981002, 981046, 981090, 981134, 981178, 981222, 981266, 981310, 981354, 981398, 981442, 981486, 981530, 981574, 981618, 981662, 981706, 981750, 981794, 981838, 981882, 981926, 981970, 982014, 982058, 982102, 982146, 982190, 982234, 982278, 982322, 982366, 982410, 982454, 982498, 982542, 982586, 982630, 982674, 982718, 982762, 982806, 982850, 982894, 982938, 982982, 983026, 983070, 983114, 983158, 983202, 983246, 983290, 983334, 983378, 983422, 983466, 983510, 983554, 983598, 983642, 983686, 983730, 983774, 983818, 983862, 983906, 983950, 983994, 984038, 984082, 984126, 984170, 984214, 984258, 984302, 984346, 984390, 984434, 984478, 984522, 984566, 984610, 984654, 984698, 984742, 984786, 984830, 984874, 984918, 984962, 985006, 985050, 985094, 985138, 985182, 985226, 985270, 985314, 985358, 985402, 985446, 985490, 985534, 985578, 985622, 985666, 985710, 985754, 985798, 985842, 985886, 985930, 985974, 986018, 986062, 986106, 986150, 986194, 986238, 986282, 986326, 986370, 986414, 986458, 986502, 986546, 986590, 986634, 986678, 986722, 986766, 986810, 986854, 986898, 986942, 986986, 987030, 987074, 987118, 987162, 987206, 987250, 987294, 987338, 987382, 987426, 987470, 987514, 987558, 987602, 987646, 987690, 987734, 987778, 987822, 987866, 987910, 987954, 987998, 988042, 988086, 988130, 988174, 988218, 988262, 988306, 988350, 988394, 988438, 988482, 988526, 988570, 988614, 988658, 988702, 988746, 988790, 988834, 988878, 988922, 988966, 989010]\n assert candidate(candies = 500,num_people = 1000) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(candies = 999999999,num_people = 999) == [989055, 989100, 989145, 989190, 989235, 989280, 989325, 989370, 989415, 989460, 989505, 989550, 989595, 989640, 989685, 989730, 989775, 989820, 989865, 989910, 989955, 990000, 990045, 990090, 990135, 990180, 990225, 990270, 990315, 990360, 990405, 990450, 990495, 990540, 990585, 990630, 990675, 990720, 990765, 990810, 990855, 990900, 990945, 990990, 991035, 991080, 991125, 991170, 991215, 991260, 991305, 991350, 991395, 991440, 991485, 991530, 991575, 991620, 991665, 991710, 991755, 991800, 991845, 991890, 991935, 991980, 992025, 992070, 992115, 992160, 992205, 992250, 992295, 992340, 992385, 992430, 992475, 992520, 992565, 992610, 992655, 992700, 992745, 992790, 992835, 992880, 992925, 992970, 993015, 993060, 993105, 993150, 993195, 993240, 993285, 993330, 993375, 993420, 993465, 993510, 993555, 993600, 993645, 993690, 993735, 993780, 993825, 993870, 993915, 993960, 994005, 994050, 994095, 994140, 994185, 994230, 994275, 994320, 994365, 994410, 994455, 994500, 994545, 994590, 994635, 994680, 994725, 994770, 994815, 994860, 994905, 994950, 994995, 995040, 995085, 995130, 995175, 995220, 995265, 995310, 995355, 995400, 995445, 995490, 995535, 995580, 995625, 995670, 995715, 995760, 995805, 995850, 995895, 995940, 995985, 996030, 996075, 996120, 996165, 996210, 996255, 996300, 996345, 996390, 996435, 996480, 996525, 996570, 996615, 996660, 996705, 996750, 996795, 996840, 996885, 996930, 996975, 997020, 997065, 997110, 997155, 997200, 997245, 997290, 997335, 997380, 997425, 997470, 997515, 997560, 997605, 997650, 997695, 997740, 997785, 997830, 997875, 997920, 997965, 998010, 998055, 998100, 998145, 998190, 998235, 998280, 998325, 998370, 998415, 998460, 998505, 998550, 998595, 998640, 998685, 998730, 998775, 998820, 998865, 998910, 998955, 999000, 999045, 999090, 999135, 999180, 999225, 999270, 999315, 999360, 999405, 999450, 999495, 999540, 999585, 999630, 999675, 999720, 999765, 999810, 999855, 999900, 999945, 999990, 1000035, 1000080, 1000125, 1000170, 1000215, 1000260, 1000305, 1000350, 1000395, 1000440, 1000485, 1000530, 1000575, 1000620, 1000665, 1000710, 1000755, 1000800, 1000845, 1000890, 1000935, 1000980, 1001025, 1001070, 1001115, 1001160, 1001205, 1001250, 1001295, 1001340, 1001385, 1001430, 1001475, 1001520, 1001565, 1001610, 1001655, 1001700, 1001745, 1001790, 1001835, 1001880, 1001925, 1001970, 1002015, 1002060, 1002105, 1002150, 1002195, 1002240, 1002285, 1002330, 1002375, 1002420, 1002465, 1002510, 1002555, 1002600, 1002645, 1002690, 1002735, 1002780, 1002825, 1002870, 1002915, 1002960, 1003005, 1003050, 1003095, 1003140, 1003185, 1003230, 1003275, 1003320, 1003365, 1003410, 1003455, 1003500, 1003545, 1003590, 1003635, 1003680, 1003725, 1003770, 1003815, 1003860, 1003905, 1003950, 1003995, 1004040, 1004085, 1004130, 1004175, 1004220, 1004265, 1004310, 1004355, 1004400, 1004445, 1004490, 1004535, 1004580, 1004625, 1004670, 1004715, 1004760, 1004805, 1004850, 1004895, 1004940, 1004985, 1005030, 1005075, 1005120, 1005165, 1005210, 1005255, 1005300, 1005345, 1005390, 1005435, 1005480, 1005525, 1005570, 1005615, 1005660, 1005705, 1005750, 1005795, 1005840, 1005885, 1005930, 1005975, 1006020, 1006065, 1006110, 1006155, 1006200, 1006245, 1006290, 1006335, 1006380, 1006425, 1006470, 1006515, 1006560, 1006605, 1006650, 1006695, 1006740, 1006785, 1006830, 1006875, 1006920, 1006965, 1007010, 1007055, 1007100, 1007145, 1007190, 1007235, 1007280, 1007325, 1007370, 1007415, 1007460, 1007505, 1007550, 1007595, 1007640, 1007685, 1007730, 1007775, 1007820, 1007865, 1007910, 1007955, 1008000, 1008045, 1008090, 1008135, 1008180, 1008225, 1008270, 1008315, 1008360, 1008405, 1008450, 1008495, 1008540, 1008585, 1008630, 1008675, 1008720, 1008765, 1008810, 1008855, 1008900, 1008945, 1008990, 1009035, 1009080, 1009125, 1009170, 1009215, 1009260, 1009305, 1009350, 1009395, 1009440, 1009485, 1009530, 1009575, 1009620, 1009665, 1009710, 1009755, 1009800, 1009845, 1009890, 1009935, 1009980, 1010025, 1010070, 1010115, 1010160, 1010205, 1010250, 1010295, 1010340, 1010385, 1010430, 1010475, 1010520, 1010565, 1010610, 1010655, 1010700, 1010745, 1010790, 1010835, 1010880, 1010925, 1010970, 1011015, 1011060, 1011105, 1011150, 1011195, 1011240, 1011285, 1011330, 1011375, 1011420, 1011465, 1011510, 1011555, 1011600, 1011645, 1011690, 1011735, 1011780, 1011825, 1011870, 1011915, 1011960, 1012005, 1012050, 1012095, 1012140, 1012185, 1012230, 1012275, 1012320, 1012365, 1012410, 1012455, 1012500, 1012545, 1012590, 1012635, 1012680, 1012725, 1012770, 1012815, 1012860, 1012905, 1012950, 1012995, 1013040, 1013085, 1013130, 1013175, 1013220, 1013265, 1013310, 1013355, 1013400, 1013445, 1013490, 1013535, 1013580, 1013625, 1013670, 1013715, 1013760, 1013805, 1013850, 1013895, 1013940, 1013985, 1014030, 1014075, 1014120, 1014165, 1014210, 1014255, 1014300, 1014345, 1014390, 1014435, 1014480, 1014525, 1014570, 1014615, 1014660, 1014705, 1014750, 1014795, 1014840, 1014885, 1014930, 1014975, 1015020, 1015065, 1015110, 1015155, 1015200, 1015245, 1015290, 1015335, 1015380, 1015425, 1015470, 1015515, 1015560, 1015605, 1015650, 1015695, 1015740, 1015785, 1015830, 1015875, 1015920, 1015965, 1016010, 1016055, 1016100, 1016145, 1016190, 1016235, 1016280, 1016325, 1016370, 1016415, 1016460, 1016505, 1016550, 1016595, 1016640, 1016685, 1016730, 1016775, 1016820, 1016865, 1016910, 1016955, 1017000, 1017045, 1017090, 1017135, 1017180, 1017225, 1017270, 1017315, 1017360, 1017405, 1017450, 1017495, 1017540, 1017585, 1017630, 1017675, 1017720, 1017765, 1017810, 1017855, 1017900, 1017945, 1017990, 1018035, 1018080, 1018125, 1018170, 1018215, 1018260, 1018305, 1018350, 1018395, 1018440, 1018485, 1018530, 1018575, 1018620, 1018665, 1018710, 1018755, 1018800, 1018845, 1018890, 1018935, 1018980, 1019025, 1019070, 1019115, 1019160, 1019205, 1019250, 1019295, 1019340, 1019385, 1019430, 1019475, 1019520, 1019565, 1019610, 1019655, 1019700, 1019745, 1019790, 1019835, 1019880, 1019925, 1019970, 1020015, 1020060, 1020105, 1020150, 1020195, 1020240, 1020285, 1020330, 1020375, 1020420, 1020465, 1020510, 1020555, 1020600, 1020645, 1020690, 1020735, 1020780, 1020825, 1020870, 1020915, 1020960, 1021005, 1021050, 1021095, 1021140, 1021185, 1021230, 1021275, 1021320, 1021365, 1021410, 1021455, 1021500, 1021545, 1021590, 1021635, 1021680, 1021725, 1021770, 1021815, 1021860, 1021905, 1021950, 1021995, 1022040, 1022085, 1022130, 1022175, 1022220, 1022265, 1022310, 1022355, 1022400, 1022445, 1022490, 1022535, 1022580, 1022625, 1022670, 1022715, 1022760, 1022805, 1022850, 1022895, 1022940, 1022985, 1023030, 1023075, 1023120, 1023165, 1023210, 1023255, 1023300, 1023345, 1023390, 1017153, 978758, 978802, 978846, 978890, 978934, 978978, 979022, 979066, 979110, 979154, 979198, 979242, 979286, 979330, 979374, 979418, 979462, 979506, 979550, 979594, 979638, 979682, 979726, 979770, 979814, 979858, 979902, 979946, 979990, 980034, 980078, 980122, 980166, 980210, 980254, 980298, 980342, 980386, 980430, 980474, 980518, 980562, 980606, 980650, 980694, 980738, 980782, 980826, 980870, 980914, 980958, 981002, 981046, 981090, 981134, 981178, 981222, 981266, 981310, 981354, 981398, 981442, 981486, 981530, 981574, 981618, 981662, 981706, 981750, 981794, 981838, 981882, 981926, 981970, 982014, 982058, 982102, 982146, 982190, 982234, 982278, 982322, 982366, 982410, 982454, 982498, 982542, 982586, 982630, 982674, 982718, 982762, 982806, 982850, 982894, 982938, 982982, 983026, 983070, 983114, 983158, 983202, 983246, 983290, 983334, 983378, 983422, 983466, 983510, 983554, 983598, 983642, 983686, 983730, 983774, 983818, 983862, 983906, 983950, 983994, 984038, 984082, 984126, 984170, 984214, 984258, 984302, 984346, 984390, 984434, 984478, 984522, 984566, 984610, 984654, 984698, 984742, 984786, 984830, 984874, 984918, 984962, 985006, 985050, 985094, 985138, 985182, 985226, 985270, 985314, 985358, 985402, 985446, 985490, 985534, 985578, 985622, 985666, 985710, 985754, 985798, 985842, 985886, 985930, 985974, 986018, 986062, 986106, 986150, 986194, 986238, 986282, 986326, 986370, 986414, 986458, 986502, 986546, 986590, 986634, 986678, 986722, 986766, 986810, 986854, 986898, 986942, 986986, 987030, 987074, 987118, 987162, 987206, 987250, 987294, 987338, 987382, 987426, 987470, 987514, 987558, 987602, 987646, 987690, 987734, 987778, 987822, 987866, 987910, 987954, 987998, 988042, 988086, 988130, 988174, 988218, 988262, 988306, 988350, 988394, 988438, 988482, 988526, 988570, 988614, 988658, 988702, 988746, 988790, 988834, 988878, 988922, 988966, 989010]\n assert candidate(candies = 120,num_people = 6) == [21, 24, 27, 14, 16, 18]\n assert candidate(candies = 999999,num_people = 500) == [1503, 1506, 1509, 1512, 1515, 1518, 1521, 1524, 1527, 1530, 1533, 1536, 1539, 1542, 1545, 1548, 1551, 1554, 1557, 1560, 1563, 1566, 1569, 1572, 1575, 1578, 1581, 1584, 1587, 1590, 1593, 1596, 1599, 1602, 1605, 1608, 1611, 1614, 1617, 1620, 1623, 1626, 1629, 1632, 1635, 1638, 1641, 1644, 1647, 1650, 1653, 1656, 1659, 1662, 1665, 1668, 1671, 1674, 1677, 1680, 1683, 1686, 1689, 1692, 1695, 1698, 1701, 1704, 1707, 1710, 1713, 1716, 1719, 1722, 1725, 1728, 1731, 1734, 1737, 1740, 1743, 1746, 1749, 1752, 1755, 1758, 1761, 1764, 1767, 1770, 1773, 1776, 1779, 1782, 1785, 1788, 1791, 1794, 1797, 1800, 1803, 1806, 1809, 1812, 1815, 1818, 1821, 1824, 1827, 1830, 1833, 1836, 1839, 1842, 1845, 1848, 1851, 1854, 1857, 1860, 1863, 1866, 1869, 1872, 1875, 1878, 1881, 1884, 1887, 1890, 1893, 1896, 1899, 1902, 1905, 1908, 1911, 1914, 1917, 1920, 1923, 1926, 1929, 1932, 1935, 1938, 1941, 1944, 1947, 1950, 1953, 1956, 1959, 1962, 1965, 1968, 1971, 1974, 1977, 1980, 1983, 1986, 1989, 1992, 1995, 1998, 2001, 2004, 2007, 2010, 2013, 2016, 2019, 2022, 2025, 2028, 2031, 2034, 2037, 2040, 2043, 2046, 2049, 2052, 2055, 2058, 2061, 2064, 2067, 2070, 2073, 2076, 2079, 2082, 2085, 2088, 2091, 2094, 2097, 2100, 2103, 2106, 2109, 2112, 2115, 2118, 2121, 2124, 2127, 2130, 2133, 2136, 2139, 2142, 2145, 2148, 2151, 2154, 2157, 2160, 2163, 2166, 2169, 2172, 2175, 2178, 2181, 2184, 2187, 2190, 2193, 2196, 2199, 2202, 2205, 2208, 2211, 2214, 2217, 2220, 2223, 2226, 2229, 2232, 2235, 2238, 2241, 2244, 2247, 2250, 2253, 2256, 2259, 2262, 2265, 2268, 2271, 2274, 2277, 2280, 2283, 2286, 2289, 2292, 2295, 2298, 2301, 2304, 2307, 2310, 2313, 2316, 2319, 2322, 2325, 2328, 2331, 2334, 2337, 2340, 2343, 2346, 2349, 2352, 2355, 2358, 2361, 2364, 2367, 2370, 2373, 2376, 2379, 2382, 2385, 2388, 2391, 2394, 2397, 2400, 2403, 2406, 2409, 2412, 2415, 2418, 2421, 2424, 2427, 2430, 2433, 2436, 2439, 2442, 2445, 2448, 2451, 2454, 2457, 2460, 2463, 2466, 2469, 2472, 2475, 2478, 2481, 2484, 2487, 2490, 2493, 2496, 2499, 2502, 2505, 2508, 2511, 2514, 2517, 2520, 2523, 2526, 2529, 2532, 2535, 2538, 2541, 2544, 2547, 2550, 2553, 2556, 2559, 2562, 2565, 2568, 2571, 2574, 2577, 2580, 2583, 2586, 2589, 2592, 2595, 2598, 2601, 2604, 2607, 2610, 2613, 2616, 2619, 2622, 2625, 2628, 2631, 2634, 2637, 2640, 2643, 2646, 2649, 2652, 2655, 2658, 2661, 2664, 2667, 2670, 2673, 2676, 2679, 2682, 2685, 2688, 2691, 2694, 2697, 2700, 2703, 2706, 2709, 2712, 2715, 2718, 2721, 2724, 2727, 2730, 2733, 2736, 2739, 2336, 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]\n assert candidate(candies = 120,num_people = 15) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(candies = 123456,num_people = 789) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(candies = 81,num_people = 9) == [11, 13, 15, 7, 5, 6, 7, 8, 9]\n assert candidate(candies = 1000,num_people = 25) == [27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 30, 21, 22, 23, 24, 25]\n assert candidate(candies = 25,num_people = 3) == [9, 7, 9]\n assert candidate(candies = 200,num_people = 6) == [40, 34, 27, 30, 33, 36]\n assert candidate(candies = 1000,num_people = 2) == [494, 506]\n assert candidate(candies = 897654321,num_people = 500) == [1785085, 1785170, 1785255, 1785340, 1785425, 1785510, 1785595, 1785680, 1785765, 1785850, 1785935, 1786020, 1786105, 1786190, 1786275, 1786360, 1786445, 1786530, 1786615, 1786700, 1786785, 1786870, 1786955, 1787040, 1787125, 1787210, 1787295, 1787380, 1787465, 1787550, 1787635, 1787720, 1787805, 1787890, 1787975, 1788060, 1788145, 1788230, 1788315, 1788400, 1788485, 1788570, 1788655, 1788740, 1788825, 1788910, 1788995, 1789080, 1789165, 1789250, 1789335, 1789420, 1789505, 1789590, 1789675, 1789760, 1789845, 1789930, 1790015, 1790100, 1790185, 1790270, 1790355, 1790440, 1790525, 1790610, 1790695, 1790780, 1790865, 1790950, 1791035, 1791120, 1791205, 1791290, 1791375, 1791460, 1791545, 1791630, 1791715, 1791800, 1791885, 1791970, 1792055, 1792140, 1792225, 1792310, 1792395, 1792480, 1792565, 1792650, 1792735, 1792820, 1792905, 1792990, 1793075, 1793160, 1793245, 1793330, 1793415, 1793500, 1793585, 1793670, 1793755, 1793840, 1793925, 1794010, 1794095, 1794180, 1794265, 1794350, 1794435, 1794520, 1794605, 1794690, 1794775, 1794860, 1794945, 1795030, 1795115, 1795200, 1795285, 1795370, 1795455, 1795540, 1795625, 1795710, 1795795, 1795880, 1795965, 1796050, 1796135, 1796220, 1796305, 1796390, 1796475, 1796560, 1796645, 1796730, 1796815, 1796900, 1796985, 1797070, 1797155, 1797240, 1797325, 1797410, 1797495, 1797580, 1797665, 1797750, 1797835, 1797920, 1798005, 1798090, 1798175, 1798260, 1798345, 1798430, 1798515, 1798600, 1798685, 1798770, 1798855, 1798940, 1799025, 1799110, 1799195, 1799280, 1799365, 1799450, 1799535, 1799620, 1799705, 1799790, 1799875, 1799960, 1800045, 1800130, 1800215, 1800300, 1800385, 1800470, 1800555, 1800640, 1800725, 1800810, 1800895, 1800980, 1801065, 1801150, 1801235, 1801320, 1801405, 1801490, 1801575, 1801660, 1801745, 1801830, 1801915, 1802000, 1802085, 1802170, 1802255, 1802340, 1802425, 1802510, 1802595, 1802680, 1802765, 1802850, 1802935, 1803020, 1803105, 1803190, 1803275, 1803360, 1803445, 1803530, 1803615, 1803700, 1803785, 1803870, 1803955, 1804040, 1804125, 1804210, 1804295, 1804380, 1804465, 1804550, 1804635, 1804720, 1804805, 1804890, 1804975, 1805060, 1805145, 1805230, 1805315, 1805400, 1805485, 1805570, 1805655, 1805740, 1805825, 1805910, 1805995, 1806080, 1806165, 1806250, 1806335, 1806420, 1806505, 1806590, 1806675, 1806760, 1806845, 1806930, 1807015, 1807100, 1807185, 1807270, 1807355, 1807440, 1807525, 1807610, 1807695, 1807780, 1807865, 1807950, 1808035, 1808120, 1808205, 1808290, 1808375, 1808460, 1808545, 1808630, 1808715, 1808800, 1808885, 1808970, 1809055, 1809140, 1809225, 1809310, 1809395, 1809480, 1809565, 1809650, 1809735, 1809820, 1809905, 1809990, 1810075, 1810160, 1810245, 1810330, 1810415, 1810500, 1810585, 1810670, 1810755, 1810840, 1810925, 1811010, 1811095, 1811180, 1811265, 1811350, 1811435, 1811520, 1811605, 1811690, 1811775, 1811860, 1811945, 1812030, 1812115, 1812200, 1812285, 1812370, 1812455, 1812540, 1812625, 1812710, 1812795, 1812880, 1812965, 1813050, 1813135, 1813220, 1813305, 1813390, 1813475, 1813560, 1813645, 1813730, 1813815, 1813900, 1813985, 1814070, 1814155, 1814240, 1814325, 1814410, 1814495, 1814580, 1814665, 1814750, 1814835, 1814920, 1815005, 1815090, 1815175, 1815260, 1815345, 1815430, 1815515, 1815600, 1815685, 1815770, 1815855, 1815940, 1816025, 1816110, 1816195, 1816280, 1816365, 1816450, 1798850, 1774248, 1774332, 1774416, 1774500, 1774584, 1774668, 1774752, 1774836, 1774920, 1775004, 1775088, 1775172, 1775256, 1775340, 1775424, 1775508, 1775592, 1775676, 1775760, 1775844, 1775928, 1776012, 1776096, 1776180, 1776264, 1776348, 1776432, 1776516, 1776600, 1776684, 1776768, 1776852, 1776936, 1777020, 1777104, 1777188, 1777272, 1777356, 1777440, 1777524, 1777608, 1777692, 1777776, 1777860, 1777944, 1778028, 1778112, 1778196, 1778280, 1778364, 1778448, 1778532, 1778616, 1778700, 1778784, 1778868, 1778952, 1779036, 1779120, 1779204, 1779288, 1779372, 1779456, 1779540, 1779624, 1779708, 1779792, 1779876, 1779960, 1780044, 1780128, 1780212, 1780296, 1780380, 1780464, 1780548, 1780632, 1780716, 1780800, 1780884, 1780968, 1781052, 1781136, 1781220, 1781304, 1781388, 1781472, 1781556, 1781640, 1781724, 1781808, 1781892, 1781976, 1782060, 1782144, 1782228, 1782312, 1782396, 1782480, 1782564, 1782648, 1782732, 1782816, 1782900, 1782984, 1783068, 1783152, 1783236, 1783320, 1783404, 1783488, 1783572, 1783656, 1783740, 1783824, 1783908, 1783992, 1784076, 1784160, 1784244, 1784328, 1784412, 1784496, 1784580, 1784664, 1784748, 1784832, 1784916, 1785000]\n assert candidate(candies = 3456789,num_people = 12) == [288954, 286890, 287109, 287328, 287547, 287766, 287985, 288204, 288423, 288642, 288861, 289080]\n assert candidate(candies = 1000,num_people = 33) == [35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 22, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(candies = 2500,num_people = 7) == [340, 335, 345, 355, 365, 375, 385]\n assert candidate(candies = 1000,num_people = 10) == [105, 110, 115, 120, 90, 84, 88, 92, 96, 100]\n assert candidate(candies = 400,num_people = 15) == [17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 35, 14, 15]\n assert candidate(candies = 500,num_people = 1) == [500]\n assert candidate(candies = 25,num_people = 5) == [7, 6, 3, 4, 5]\n assert candidate(candies = 15,num_people = 2) == [9, 6]\n assert candidate(candies = 10000,num_people = 50) == [153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240, 243, 246, 249, 252, 255, 258, 261, 264, 267, 270, 262, 134, 136, 138, 140, 142, 144, 146, 148, 150]\n assert candidate(candies = 500000000,num_people = 250) == [2000377, 2000504, 2000631, 2000758, 2000885, 2001012, 2001139, 2001266, 2001393, 2001520, 2001647, 2001774, 2001901, 2002028, 2002155, 2002282, 2002409, 2002536, 2002663, 2002790, 2002917, 2003044, 2003171, 2003298, 2003425, 2003552, 2003679, 2003806, 2003933, 2004060, 2004187, 2004314, 2004441, 2004568, 2004695, 2004822, 2004949, 2005076, 2005203, 2005330, 2005457, 2005584, 2005711, 2005838, 2005965, 2006092, 2006219, 2006346, 2006473, 2006600, 2006727, 2006854, 2006981, 2007108, 2007235, 2007362, 2007489, 2007616, 2007743, 2007870, 2007997, 2008124, 2008251, 2008378, 2008505, 2008632, 2008759, 2008886, 2009013, 2009140, 2009267, 2009394, 2009521, 2009648, 2009775, 2009902, 2010029, 2010156, 2010283, 2010410, 2010537, 2010664, 2010791, 2010918, 2011045, 2011172, 2011299, 2011426, 2011553, 2011680, 2011807, 2011934, 2012061, 2012188, 2012315, 2012442, 2012569, 2012696, 2012823, 2012950, 2013077, 2013204, 2013331, 2013458, 2013585, 2013712, 2013839, 2013966, 2014093, 2014220, 2014347, 2014474, 2014601, 2014728, 2014855, 2014982, 2015109, 2015236, 2015363, 2015490, 2015617, 2015744, 1992995, 1984374, 1984500, 1984626, 1984752, 1984878, 1985004, 1985130, 1985256, 1985382, 1985508, 1985634, 1985760, 1985886, 1986012, 1986138, 1986264, 1986390, 1986516, 1986642, 1986768, 1986894, 1987020, 1987146, 1987272, 1987398, 1987524, 1987650, 1987776, 1987902, 1988028, 1988154, 1988280, 1988406, 1988532, 1988658, 1988784, 1988910, 1989036, 1989162, 1989288, 1989414, 1989540, 1989666, 1989792, 1989918, 1990044, 1990170, 1990296, 1990422, 1990548, 1990674, 1990800, 1990926, 1991052, 1991178, 1991304, 1991430, 1991556, 1991682, 1991808, 1991934, 1992060, 1992186, 1992312, 1992438, 1992564, 1992690, 1992816, 1992942, 1993068, 1993194, 1993320, 1993446, 1993572, 1993698, 1993824, 1993950, 1994076, 1994202, 1994328, 1994454, 1994580, 1994706, 1994832, 1994958, 1995084, 1995210, 1995336, 1995462, 1995588, 1995714, 1995840, 1995966, 1996092, 1996218, 1996344, 1996470, 1996596, 1996722, 1996848, 1996974, 1997100, 1997226, 1997352, 1997478, 1997604, 1997730, 1997856, 1997982, 1998108, 1998234, 1998360, 1998486, 1998612, 1998738, 1998864, 1998990, 1999116, 1999242, 1999368, 1999494, 1999620, 1999746, 1999872, 1999998, 2000124, 2000250]\n assert candidate(candies = 499999999,num_people = 500) == [1008064, 1008128, 1008192, 1008256, 1008320, 1008384, 1008448, 1008512, 1008576, 1008640, 1008704, 1008768, 1008832, 1008896, 1008960, 1009024, 1009088, 1009152, 1009216, 1009280, 1009344, 1009408, 1009472, 1009536, 1009600, 1009664, 1009728, 1009792, 1009856, 1009920, 1009984, 1010048, 1010112, 1010176, 1010240, 1010304, 1010368, 1010432, 1010496, 1010560, 1010624, 1010688, 1010752, 1010816, 1010880, 1010944, 1011008, 1011072, 1011136, 1011200, 1011264, 1011328, 1011392, 1011456, 1011520, 1011584, 1011648, 1011712, 1011776, 1011840, 1011904, 1011968, 1012032, 1012096, 1012160, 1012224, 1012288, 1012352, 1012416, 1012480, 1012544, 1012608, 1012672, 1012736, 1012800, 1012864, 1012928, 1012992, 1013056, 1013120, 1013184, 1013248, 1013312, 1013376, 1013440, 1013504, 1013568, 1013632, 1013696, 1013760, 1013824, 1013888, 1013952, 1014016, 1014080, 1014144, 1014208, 1014272, 1014336, 1014400, 1014464, 1014528, 1014592, 1014656, 1014720, 1014784, 1014848, 1014912, 1014976, 1015040, 1015104, 1015168, 1015232, 1015296, 1015360, 1015424, 1015488, 1015552, 1015616, 1015680, 1015744, 1015808, 992995, 984312, 984375, 984438, 984501, 984564, 984627, 984690, 984753, 984816, 984879, 984942, 985005, 985068, 985131, 985194, 985257, 985320, 985383, 985446, 985509, 985572, 985635, 985698, 985761, 985824, 985887, 985950, 986013, 986076, 986139, 986202, 986265, 986328, 986391, 986454, 986517, 986580, 986643, 986706, 986769, 986832, 986895, 986958, 987021, 987084, 987147, 987210, 987273, 987336, 987399, 987462, 987525, 987588, 987651, 987714, 987777, 987840, 987903, 987966, 988029, 988092, 988155, 988218, 988281, 988344, 988407, 988470, 988533, 988596, 988659, 988722, 988785, 988848, 988911, 988974, 989037, 989100, 989163, 989226, 989289, 989352, 989415, 989478, 989541, 989604, 989667, 989730, 989793, 989856, 989919, 989982, 990045, 990108, 990171, 990234, 990297, 990360, 990423, 990486, 990549, 990612, 990675, 990738, 990801, 990864, 990927, 990990, 991053, 991116, 991179, 991242, 991305, 991368, 991431, 991494, 991557, 991620, 991683, 991746, 991809, 991872, 991935, 991998, 992061, 992124, 992187, 992250, 992313, 992376, 992439, 992502, 992565, 992628, 992691, 992754, 992817, 992880, 992943, 993006, 993069, 993132, 993195, 993258, 993321, 993384, 993447, 993510, 993573, 993636, 993699, 993762, 993825, 993888, 993951, 994014, 994077, 994140, 994203, 994266, 994329, 994392, 994455, 994518, 994581, 994644, 994707, 994770, 994833, 994896, 994959, 995022, 995085, 995148, 995211, 995274, 995337, 995400, 995463, 995526, 995589, 995652, 995715, 995778, 995841, 995904, 995967, 996030, 996093, 996156, 996219, 996282, 996345, 996408, 996471, 996534, 996597, 996660, 996723, 996786, 996849, 996912, 996975, 997038, 997101, 997164, 997227, 997290, 997353, 997416, 997479, 997542, 997605, 997668, 997731, 997794, 997857, 997920, 997983, 998046, 998109, 998172, 998235, 998298, 998361, 998424, 998487, 998550, 998613, 998676, 998739, 998802, 998865, 998928, 998991, 999054, 999117, 999180, 999243, 999306, 999369, 999432, 999495, 999558, 999621, 999684, 999747, 999810, 999873, 999936, 999999, 1000062, 1000125, 1000188, 1000251, 1000314, 1000377, 1000440, 1000503, 1000566, 1000629, 1000692, 1000755, 1000818, 1000881, 1000944, 1001007, 1001070, 1001133, 1001196, 1001259, 1001322, 1001385, 1001448, 1001511, 1001574, 1001637, 1001700, 1001763, 1001826, 1001889, 1001952, 1002015, 1002078, 1002141, 1002204, 1002267, 1002330, 1002393, 1002456, 1002519, 1002582, 1002645, 1002708, 1002771, 1002834, 1002897, 1002960, 1003023, 1003086, 1003149, 1003212, 1003275, 1003338, 1003401, 1003464, 1003527, 1003590, 1003653, 1003716, 1003779, 1003842, 1003905, 1003968, 1004031, 1004094, 1004157, 1004220, 1004283, 1004346, 1004409, 1004472, 1004535, 1004598, 1004661, 1004724, 1004787, 1004850, 1004913, 1004976, 1005039, 1005102, 1005165, 1005228, 1005291, 1005354, 1005417, 1005480, 1005543, 1005606, 1005669, 1005732, 1005795, 1005858, 1005921, 1005984, 1006047, 1006110, 1006173, 1006236, 1006299, 1006362, 1006425, 1006488, 1006551, 1006614, 1006677, 1006740, 1006803, 1006866, 1006929, 1006992, 1007055, 1007118, 1007181, 1007244, 1007307, 1007370, 1007433, 1007496, 1007559, 1007622, 1007685, 1007748, 1007811, 1007874, 1007937, 1008000]\n assert candidate(candies = 200000000,num_people = 500) == [390040, 390080, 390120, 390160, 390200, 390240, 390280, 390320, 390360, 390400, 390440, 390480, 390520, 390560, 390600, 390640, 390680, 390720, 390760, 390800, 390840, 390880, 390920, 390960, 391000, 391040, 391080, 391120, 391160, 391200, 391240, 391280, 391320, 391360, 391400, 391440, 391480, 391520, 391560, 391600, 391640, 391680, 391720, 391760, 391800, 391840, 391880, 391920, 391960, 392000, 392040, 392080, 392120, 392160, 392200, 392240, 392280, 392320, 392360, 392400, 392440, 392480, 392520, 392560, 392600, 392640, 392680, 392720, 392760, 392800, 392840, 392880, 392920, 392960, 393000, 393040, 393080, 393120, 393160, 393200, 393240, 393280, 393320, 393360, 393400, 393440, 393480, 393520, 393560, 393600, 393640, 393680, 393720, 393760, 393800, 393840, 393880, 393920, 393960, 394000, 394040, 394080, 394120, 394160, 394200, 394240, 394280, 394320, 394360, 394400, 394440, 394480, 394520, 394560, 394600, 394640, 394680, 394720, 394760, 394800, 394840, 394880, 394920, 394960, 395000, 395040, 395080, 395120, 395160, 395200, 395240, 395280, 395320, 395360, 395400, 395440, 395480, 395520, 395560, 395600, 395640, 395680, 395720, 395760, 395800, 395840, 395880, 395920, 395960, 396000, 396040, 396080, 396120, 396160, 396200, 396240, 396280, 396320, 396360, 396400, 396440, 396480, 396520, 396560, 396600, 396640, 396680, 396720, 396760, 396800, 396840, 396880, 396920, 396960, 397000, 397040, 397080, 397120, 397160, 397200, 397240, 397280, 397320, 397360, 397400, 397440, 397480, 397520, 397560, 397600, 397640, 397680, 397720, 397760, 397800, 397840, 397880, 397920, 397960, 398000, 398040, 398080, 398120, 398160, 398200, 398240, 398280, 398320, 398360, 398400, 398440, 398480, 398520, 398560, 398600, 398640, 398680, 398720, 398760, 398800, 398840, 398880, 398920, 398960, 399000, 399040, 399080, 399120, 399160, 399200, 399240, 399280, 399320, 399360, 399400, 399440, 399480, 399520, 399560, 399600, 399640, 399680, 399720, 399760, 399800, 399840, 399880, 399920, 399960, 400000, 400040, 400080, 400120, 400160, 400200, 400240, 400280, 400320, 400360, 400400, 400440, 400480, 400520, 400560, 400600, 400640, 400680, 400720, 400760, 400800, 400840, 400880, 400920, 400960, 401000, 401040, 401080, 401120, 401160, 401200, 401240, 401280, 401320, 401360, 401400, 401440, 401480, 401520, 401560, 401600, 401640, 401680, 401720, 401760, 401800, 401840, 401880, 401920, 401960, 402000, 402040, 402080, 402120, 402160, 402200, 402240, 402280, 402320, 402360, 402400, 402440, 402480, 402520, 402560, 402600, 402640, 402680, 402720, 402760, 402800, 402840, 402880, 402920, 402960, 403000, 403040, 403080, 403120, 403160, 403200, 403240, 403280, 403320, 403360, 403400, 403440, 403480, 403520, 403560, 403600, 403640, 403680, 403720, 403760, 403800, 403840, 403880, 403920, 403960, 404000, 404040, 404080, 404120, 404160, 404200, 404240, 404280, 404320, 404360, 404400, 404440, 404480, 404520, 404560, 404600, 404640, 404680, 404720, 404760, 404800, 404840, 404880, 404920, 404960, 405000, 405040, 405080, 405120, 405160, 405200, 405240, 405280, 405320, 405360, 405400, 405440, 405480, 405520, 405560, 405600, 405640, 405680, 405720, 405760, 405800, 405840, 405880, 405920, 405960, 406000, 406040, 406080, 406120, 406160, 406200, 406240, 406280, 406320, 406360, 406400, 406440, 406480, 406520, 406560, 406600, 406640, 406680, 406720, 406760, 406800, 406840, 406880, 406920, 406960, 407000, 407040, 407080, 407120, 407160, 407200, 407240, 407280, 407320, 407360, 407400, 407440, 407480, 407520, 407560, 407600, 407640, 407680, 407720, 407760, 407800, 407840, 407880, 407920, 407960, 408000, 408040, 408080, 408120, 408160, 408200, 408240, 408280, 408320, 408360, 408400, 408440, 408480, 408520, 408560, 408600, 408640, 408680, 408720, 408760, 408800, 408840, 408880, 408920, 408960, 409000, 409040, 409080, 409120, 409160, 409200, 409240, 409280, 409320, 409360, 409400, 409440, 409480, 409520, 409560, 409600, 409640, 409680, 409720, 409760, 409800, 409840, 409880, 409920, 409960, 400000]\n assert candidate(candies = 999999999,num_people = 1000) == [990045, 990090, 990135, 990180, 990225, 990270, 990315, 990360, 990405, 990450, 990495, 990540, 990585, 990630, 990675, 990720, 990765, 990810, 990855, 990900, 990945, 990990, 991035, 991080, 991125, 991170, 991215, 991260, 991305, 991350, 991395, 991440, 991485, 991530, 991575, 991620, 991665, 991710, 991755, 991800, 991845, 991890, 991935, 991980, 992025, 992070, 992115, 992160, 992205, 992250, 992295, 992340, 992385, 992430, 992475, 992520, 992565, 992610, 992655, 992700, 992745, 992790, 992835, 992880, 992925, 992970, 993015, 993060, 993105, 993150, 993195, 993240, 993285, 993330, 993375, 993420, 993465, 993510, 993555, 993600, 993645, 993690, 993735, 993780, 993825, 993870, 993915, 993960, 994005, 994050, 994095, 994140, 994185, 994230, 994275, 994320, 994365, 994410, 994455, 994500, 994545, 994590, 994635, 994680, 994725, 994770, 994815, 994860, 994905, 994950, 994995, 995040, 995085, 995130, 995175, 995220, 995265, 995310, 995355, 995400, 995445, 995490, 995535, 995580, 995625, 995670, 995715, 995760, 995805, 995850, 995895, 995940, 995985, 996030, 996075, 996120, 996165, 996210, 996255, 996300, 996345, 996390, 996435, 996480, 996525, 996570, 996615, 996660, 996705, 996750, 996795, 996840, 996885, 996930, 996975, 997020, 997065, 997110, 997155, 997200, 997245, 997290, 997335, 997380, 997425, 997470, 997515, 997560, 997605, 997650, 997695, 997740, 997785, 997830, 997875, 997920, 997965, 998010, 998055, 998100, 998145, 998190, 998235, 998280, 998325, 998370, 998415, 998460, 998505, 998550, 998595, 998640, 998685, 998730, 998775, 998820, 998865, 998910, 998955, 999000, 999045, 999090, 999135, 999180, 999225, 999270, 999315, 999360, 999405, 999450, 999495, 999540, 999585, 999630, 999675, 999720, 999765, 999810, 999855, 999900, 999945, 999990, 1000035, 1000080, 1000125, 1000170, 1000215, 1000260, 1000305, 1000350, 1000395, 1000440, 1000485, 1000530, 1000575, 1000620, 1000665, 1000710, 1000755, 1000800, 1000845, 1000890, 1000935, 1000980, 1001025, 1001070, 1001115, 1001160, 1001205, 1001250, 1001295, 1001340, 1001385, 1001430, 1001475, 1001520, 1001565, 1001610, 1001655, 1001700, 1001745, 1001790, 1001835, 1001880, 1001925, 1001970, 1002015, 1002060, 1002105, 1002150, 1002195, 1002240, 1002285, 1002330, 1002375, 1002420, 1002465, 1002510, 1002555, 1002600, 1002645, 1002690, 1002735, 1002780, 1002825, 1002870, 1002915, 1002960, 1003005, 1003050, 1003095, 1003140, 1003185, 1003230, 1003275, 1003320, 1003365, 1003410, 1003455, 1003500, 1003545, 1003590, 1003635, 1003680, 1003725, 1003770, 1003815, 1003860, 1003905, 1003950, 1003995, 1004040, 1004085, 1004130, 1004175, 1004220, 1004265, 1004310, 1004355, 1004400, 1004445, 1004490, 1004535, 1004580, 1004625, 1004670, 1004715, 1004760, 1004805, 1004850, 1004895, 1004940, 1004985, 1005030, 1005075, 1005120, 1005165, 1005210, 1005255, 1005300, 1005345, 1005390, 1005435, 1005480, 1005525, 1005570, 1005615, 1005660, 1005705, 1005750, 1005795, 1005840, 1005885, 1005930, 1005975, 1006020, 1006065, 1006110, 1006155, 1006200, 1006245, 1006290, 1006335, 1006380, 1006425, 1006470, 1006515, 1006560, 1006605, 1006650, 1006695, 1006740, 1006785, 1006830, 1006875, 1006920, 1006965, 1007010, 1007055, 1007100, 1007145, 1007190, 1007235, 1007280, 1007325, 1007370, 1007415, 1007460, 1007505, 1007550, 1007595, 1007640, 1007685, 1007730, 1007775, 1007820, 1007865, 1007910, 1007955, 1008000, 1008045, 1008090, 1008135, 1008180, 1008225, 1008270, 1008315, 1008360, 1008405, 1008450, 1008495, 1008540, 1008585, 1008630, 1008675, 1008720, 1008765, 1008810, 1008855, 1008900, 1008945, 1008990, 1009035, 1009080, 1009125, 1009170, 1009215, 1009260, 1009305, 1009350, 1009395, 1009440, 1009485, 1009530, 1009575, 1009620, 1009665, 1009710, 1009755, 1009800, 1009845, 1009890, 1009935, 1009980, 1010025, 1010070, 1010115, 1010160, 1010205, 1010250, 1010295, 1010340, 1010385, 1010430, 1010475, 1010520, 1010565, 1010610, 1010655, 1010700, 1010745, 1010790, 1010835, 1010880, 1010925, 1010970, 1011015, 1011060, 1011105, 1011150, 1011195, 1011240, 1011285, 1011330, 1011375, 1011420, 1011465, 1011510, 1011555, 1011600, 1011645, 1011690, 1011735, 1011780, 1011825, 1011870, 1011915, 1011960, 1012005, 1012050, 1012095, 1012140, 1012185, 1012230, 1012275, 1012320, 1012365, 1012410, 1012455, 1012500, 1012545, 1012590, 1012635, 1012680, 1012725, 1012770, 1012815, 1012860, 1012905, 1012950, 1012995, 1013040, 1013085, 1013130, 1013175, 1013220, 1013265, 1013310, 1013355, 1013400, 1013445, 1013490, 1013535, 1013580, 1013625, 1013670, 1013715, 1013760, 1013805, 1013850, 1013895, 1013940, 1013985, 1014030, 1014075, 1014120, 1014165, 1014210, 1014255, 1014300, 1014345, 1014390, 1014435, 1014480, 1014525, 1014570, 1014615, 1014660, 1014705, 1014750, 1014795, 1014840, 1014885, 1014930, 1014975, 1015020, 1015065, 1015110, 1015155, 1015200, 1015245, 1015290, 1015335, 1015380, 1015425, 1015470, 1015515, 1015560, 1015605, 1015650, 1015695, 1015740, 1015785, 1015830, 1015875, 1015920, 1015965, 1016010, 1016055, 1016100, 1016145, 1016190, 1016235, 1016280, 1016325, 1016370, 1016415, 1016460, 1016505, 1016550, 1016595, 1016640, 1016685, 1016730, 1016775, 1016820, 1016865, 1016910, 1016955, 1017000, 1017045, 1017090, 1017135, 1017180, 1017225, 1017270, 1017315, 1017360, 1017405, 1017450, 1017495, 1017540, 1017585, 1017630, 1017675, 1017720, 1017765, 1017810, 1017855, 1017900, 1017945, 1017990, 1018035, 1018080, 1018125, 1018170, 1018215, 1018260, 1018305, 1018350, 1018395, 1018440, 1018485, 1018530, 1018575, 1018620, 1018665, 1018710, 1018755, 1018800, 1018845, 1018890, 1018935, 1018980, 1019025, 1019070, 1019115, 1019160, 1019205, 1019250, 1019295, 1019340, 1019385, 1019430, 1019475, 1019520, 1019565, 1019610, 1019655, 1019700, 1019745, 1019790, 1019835, 1019880, 1019925, 1019970, 1020015, 1020060, 1020105, 1020150, 1020195, 1020240, 1020285, 1020330, 1020375, 1020420, 1020465, 1020510, 1020555, 1020600, 1020645, 1020690, 1020735, 1020780, 1020825, 1020870, 1020915, 1020960, 1021005, 1021050, 1021095, 1021140, 1021185, 1021230, 1021275, 1021320, 1021365, 1021410, 1021455, 1021500, 1021545, 1021590, 1021635, 1021680, 1021725, 1021770, 1021815, 1021860, 1021905, 1021950, 1021995, 1022040, 1022085, 1022130, 1022175, 1022220, 1022265, 1022310, 1022355, 1022400, 1016163, 977768, 977812, 977856, 977900, 977944, 977988, 978032, 978076, 978120, 978164, 978208, 978252, 978296, 978340, 978384, 978428, 978472, 978516, 978560, 978604, 978648, 978692, 978736, 978780, 978824, 978868, 978912, 978956, 979000, 979044, 979088, 979132, 979176, 979220, 979264, 979308, 979352, 979396, 979440, 979484, 979528, 979572, 979616, 979660, 979704, 979748, 979792, 979836, 979880, 979924, 979968, 980012, 980056, 980100, 980144, 980188, 980232, 980276, 980320, 980364, 980408, 980452, 980496, 980540, 980584, 980628, 980672, 980716, 980760, 980804, 980848, 980892, 980936, 980980, 981024, 981068, 981112, 981156, 981200, 981244, 981288, 981332, 981376, 981420, 981464, 981508, 981552, 981596, 981640, 981684, 981728, 981772, 981816, 981860, 981904, 981948, 981992, 982036, 982080, 982124, 982168, 982212, 982256, 982300, 982344, 982388, 982432, 982476, 982520, 982564, 982608, 982652, 982696, 982740, 982784, 982828, 982872, 982916, 982960, 983004, 983048, 983092, 983136, 983180, 983224, 983268, 983312, 983356, 983400, 983444, 983488, 983532, 983576, 983620, 983664, 983708, 983752, 983796, 983840, 983884, 983928, 983972, 984016, 984060, 984104, 984148, 984192, 984236, 984280, 984324, 984368, 984412, 984456, 984500, 984544, 984588, 984632, 984676, 984720, 984764, 984808, 984852, 984896, 984940, 984984, 985028, 985072, 985116, 985160, 985204, 985248, 985292, 985336, 985380, 985424, 985468, 985512, 985556, 985600, 985644, 985688, 985732, 985776, 985820, 985864, 985908, 985952, 985996, 986040, 986084, 986128, 986172, 986216, 986260, 986304, 986348, 986392, 986436, 986480, 986524, 986568, 986612, 986656, 986700, 986744, 986788, 986832, 986876, 986920, 986964, 987008, 987052, 987096, 987140, 987184, 987228, 987272, 987316, 987360, 987404, 987448, 987492, 987536, 987580, 987624, 987668, 987712, 987756, 987800, 987844, 987888, 987932, 987976, 988020, 988064, 988108, 988152, 988196, 988240, 988284, 988328, 988372, 988416, 988460, 988504, 988548, 988592, 988636, 988680, 988724, 988768, 988812, 988856, 988900, 988944, 988988, 989032, 989076, 989120, 989164, 989208, 989252, 989296, 989340, 989384, 989428, 989472, 989516, 989560, 989604, 989648, 989692, 989736, 989780, 989824, 989868, 989912, 989956, 990000]\n assert candidate(candies = 15,num_people = 4) == [6, 2, 3, 4]\n assert candidate(candies = 50,num_people = 7) == [9, 11, 8, 4, 5, 6, 7]\n assert candidate(candies = 300000000,num_people = 200) == [1500723, 1500846, 1500969, 1501092, 1501215, 1501338, 1501461, 1501584, 1501707, 1501830, 1501953, 1502076, 1502199, 1502322, 1502445, 1502568, 1502691, 1502814, 1502937, 1503060, 1503183, 1503306, 1503429, 1503552, 1503675, 1503798, 1503921, 1504044, 1504167, 1504290, 1504413, 1504536, 1504659, 1504782, 1504905, 1505028, 1505151, 1505274, 1505397, 1505520, 1505643, 1505766, 1505889, 1506012, 1506135, 1506258, 1506381, 1506504, 1506627, 1506750, 1506873, 1506996, 1507119, 1507242, 1507365, 1507488, 1507611, 1507734, 1507857, 1507980, 1508103, 1508226, 1508349, 1508472, 1508595, 1508718, 1508841, 1508964, 1509087, 1509210, 1509333, 1509456, 1509579, 1509702, 1509825, 1509948, 1510071, 1510194, 1510317, 1510440, 1510563, 1510686, 1510809, 1510932, 1511055, 1511178, 1511301, 1511424, 1511547, 1511670, 1511793, 1511916, 1512039, 1512162, 1497525, 1487912, 1488034, 1488156, 1488278, 1488400, 1488522, 1488644, 1488766, 1488888, 1489010, 1489132, 1489254, 1489376, 1489498, 1489620, 1489742, 1489864, 1489986, 1490108, 1490230, 1490352, 1490474, 1490596, 1490718, 1490840, 1490962, 1491084, 1491206, 1491328, 1491450, 1491572, 1491694, 1491816, 1491938, 1492060, 1492182, 1492304, 1492426, 1492548, 1492670, 1492792, 1492914, 1493036, 1493158, 1493280, 1493402, 1493524, 1493646, 1493768, 1493890, 1494012, 1494134, 1494256, 1494378, 1494500, 1494622, 1494744, 1494866, 1494988, 1495110, 1495232, 1495354, 1495476, 1495598, 1495720, 1495842, 1495964, 1496086, 1496208, 1496330, 1496452, 1496574, 1496696, 1496818, 1496940, 1497062, 1497184, 1497306, 1497428, 1497550, 1497672, 1497794, 1497916, 1498038, 1498160, 1498282, 1498404, 1498526, 1498648, 1498770, 1498892, 1499014, 1499136, 1499258, 1499380, 1499502, 1499624, 1499746, 1499868, 1499990, 1500112, 1500234, 1500356, 1500478, 1500600]\n assert candidate(candies = 5000,num_people = 20) == [205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 250]\n assert candidate(candies = 15,num_people = 1) == [15]\n assert candidate(candies = 123456789,num_people = 987) == [118456, 118472, 118488, 118504, 118520, 118536, 118552, 118568, 118584, 118600, 118616, 118632, 118648, 118664, 118680, 118696, 118712, 118728, 118744, 118760, 118776, 118792, 118808, 118824, 118840, 118856, 118872, 118888, 118904, 118920, 118936, 118952, 118968, 118984, 119000, 119016, 119032, 119048, 119064, 119080, 119096, 119112, 119128, 119144, 119160, 119176, 119192, 119208, 119224, 119240, 119256, 119272, 119288, 119304, 119320, 119336, 119352, 119368, 119384, 119400, 119416, 119432, 119448, 119464, 119480, 119496, 119512, 119528, 119544, 119560, 119576, 119592, 119608, 119624, 119640, 119656, 119672, 119688, 119704, 119720, 119736, 119752, 119768, 119784, 119800, 119816, 119832, 119848, 119864, 119880, 119896, 119912, 119928, 119944, 119960, 119976, 119992, 120008, 120024, 120040, 120056, 120072, 120088, 120104, 120120, 120136, 120152, 120168, 120184, 120200, 120216, 120232, 120248, 120264, 120280, 120296, 120312, 120328, 120344, 120360, 120376, 120392, 120408, 120424, 120440, 120456, 120472, 120488, 120504, 120520, 120536, 120552, 120568, 120584, 120600, 120616, 120632, 120648, 120664, 120680, 120696, 120712, 120728, 120744, 120760, 120776, 120792, 120808, 120824, 120840, 120856, 120872, 120888, 120904, 120920, 120936, 120952, 120968, 120984, 121000, 121016, 121032, 121048, 121064, 121080, 121096, 121112, 121128, 121144, 121160, 121176, 121192, 121208, 121224, 121240, 121256, 121272, 121288, 121304, 121320, 121336, 121352, 121368, 121384, 121400, 121416, 121432, 121448, 121464, 121480, 121496, 121512, 121528, 121544, 121560, 121576, 121592, 121608, 121624, 121640, 121656, 121672, 121688, 121704, 121720, 121736, 121752, 121768, 121784, 121800, 121816, 121832, 121848, 121864, 121880, 121896, 121912, 121928, 121944, 121960, 121976, 121992, 122008, 122024, 122040, 122056, 122072, 122088, 122104, 122120, 122136, 122152, 122168, 122184, 122200, 122216, 122232, 122248, 122264, 122280, 122296, 122312, 122328, 122344, 122360, 122376, 122392, 122408, 122424, 122440, 122456, 122472, 122488, 122504, 122520, 122536, 122552, 122568, 122584, 122600, 122616, 122632, 122648, 122664, 122680, 122696, 122712, 122728, 122744, 122760, 122776, 122792, 122808, 122824, 122840, 122856, 122872, 122888, 122904, 122920, 122936, 122952, 122968, 122984, 123000, 123016, 123032, 123048, 123064, 123080, 123096, 123112, 123128, 123144, 123160, 123176, 123192, 123208, 123224, 123240, 123256, 123272, 123288, 123304, 123320, 123336, 123352, 123368, 123384, 123400, 123416, 123432, 123448, 123464, 123480, 123496, 123512, 123528, 123544, 123560, 123576, 123592, 123608, 123624, 123640, 123656, 123672, 123688, 123704, 123720, 123736, 123752, 123768, 123784, 123800, 123816, 123832, 123848, 123864, 123880, 123896, 123912, 123928, 123944, 123960, 123976, 123992, 124008, 124024, 124040, 124056, 124072, 124088, 124104, 124120, 124136, 124152, 124168, 124184, 124200, 124216, 124232, 124248, 124264, 124280, 124296, 124312, 124328, 124344, 124360, 124376, 124392, 124408, 124424, 124440, 124456, 124472, 124488, 124504, 124520, 124536, 124552, 124568, 124584, 124600, 124616, 124632, 124648, 124664, 124680, 124696, 124712, 124728, 124744, 124760, 124776, 124792, 124808, 124824, 124840, 124856, 124872, 124888, 124904, 124920, 124936, 124952, 124968, 124984, 125000, 125016, 125032, 125048, 125064, 125080, 125096, 125112, 125128, 125144, 125160, 125176, 125192, 125208, 125224, 125240, 125256, 125272, 125288, 125304, 125320, 125336, 125352, 125368, 125384, 125400, 125416, 125432, 125448, 125464, 125480, 125496, 125512, 125528, 125544, 125560, 125576, 125592, 125608, 125624, 125640, 125656, 125672, 125688, 125704, 125720, 125736, 125752, 125768, 125784, 125800, 125816, 125832, 125848, 125864, 125880, 125896, 125912, 125928, 125944, 125960, 125976, 125992, 126008, 126024, 126040, 126056, 126072, 126088, 126104, 126120, 126136, 126152, 126168, 126184, 126200, 126216, 126232, 126248, 126264, 126280, 126296, 126312, 126328, 126344, 126360, 126376, 126392, 126408, 126424, 126440, 126456, 126472, 126488, 126504, 126520, 126536, 126552, 126568, 126584, 126600, 126616, 126632, 126648, 126664, 126680, 126696, 126712, 126728, 126744, 126760, 126776, 126792, 126808, 126824, 126840, 126856, 126872, 126888, 126904, 126920, 126936, 126952, 126968, 126984, 127000, 127016, 127032, 127048, 127064, 127080, 127096, 127112, 127128, 127144, 127160, 127176, 127192, 127208, 127224, 127240, 127256, 127272, 127288, 127304, 127320, 127336, 127352, 127368, 127384, 127400, 127416, 127432, 127448, 127464, 127480, 127496, 127512, 127528, 127544, 127560, 127576, 127592, 127608, 127624, 127640, 127656, 127672, 127688, 127704, 127720, 127736, 127752, 127768, 127784, 127800, 127816, 127832, 127848, 127864, 127880, 127896, 127912, 127928, 127944, 127960, 127976, 127992, 128008, 128024, 128040, 128056, 128072, 128088, 128104, 128120, 128136, 128152, 128168, 128184, 128200, 128216, 128232, 128248, 128264, 128280, 128296, 128312, 128328, 128344, 128360, 128376, 128392, 128408, 128424, 128440, 128456, 128472, 128488, 128504, 128520, 128536, 128552, 128568, 128584, 128600, 128616, 128632, 128648, 128664, 128680, 128696, 128712, 128728, 128744, 128760, 128776, 128792, 128808, 128824, 128840, 128856, 128872, 128888, 128904, 128920, 128936, 128952, 128968, 128984, 129000, 129016, 129032, 129048, 129064, 129080, 129096, 129112, 129128, 129144, 129160, 129176, 129192, 129208, 129224, 129240, 129256, 129272, 129288, 129304, 129320, 129336, 129352, 129368, 129384, 129400, 129416, 129432, 129448, 129464, 129480, 129496, 129512, 129528, 129544, 129560, 129576, 129592, 129608, 129624, 129640, 129656, 129672, 129688, 129704, 129720, 129736, 129752, 129768, 129784, 129800, 129816, 129832, 129848, 129864, 129880, 129896, 129912, 129928, 129944, 129960, 129976, 129992, 130008, 130024, 130040, 130056, 130072, 130088, 130104, 130120, 130136, 130152, 130168, 130184, 130200, 130216, 130232, 130248, 130264, 130280, 130296, 130312, 130328, 130344, 130360, 130376, 130392, 130408, 130424, 130440, 130456, 130472, 130488, 130504, 130520, 130536, 130552, 130568, 130584, 130600, 130616, 130632, 130648, 130664, 130680, 130696, 130712, 130728, 130744, 130760, 130776, 130792, 130808, 130824, 130840, 130856, 130872, 130888, 130904, 130920, 130936, 130952, 130968, 130984, 131000, 131016, 131032, 131048, 131064, 131080, 131096, 131112, 131128, 131144, 131160, 131176, 131192, 131208, 131224, 131240, 131256, 131272, 131288, 131304, 131320, 131336, 131352, 131368, 131384, 131400, 131416, 131432, 131448, 131464, 131480, 131496, 131512, 131528, 131544, 131560, 131576, 131592, 131608, 131624, 131640, 131656, 131672, 131688, 131704, 131720, 131736, 131752, 131768, 131784, 131800, 131816, 131832, 131848, 131864, 131880, 131896, 131912, 131928, 131944, 131960, 131976, 131992, 132008, 132024, 132040, 132056, 132072, 132088, 132104, 132120, 132136, 132152, 132168, 132184, 132200, 132216, 132232, 132248, 132264, 132280, 132296, 132312, 132328, 132344, 132360, 132376, 132392, 132408, 132424, 132440, 132456, 132472, 132488, 132504, 132520, 132536, 132552, 132568, 132584, 132600, 132616, 132632, 132648, 132664, 132680, 132696, 132712, 132728, 132744, 132760, 132776, 132792, 132808, 132824, 132840, 132856, 132872, 132888, 132904, 132920, 132936, 132952, 132716, 117270, 117285, 117300, 117315, 117330, 117345, 117360, 117375, 117390, 117405, 117420, 117435, 117450, 117465, 117480, 117495, 117510, 117525, 117540, 117555, 117570, 117585, 117600, 117615, 117630, 117645, 117660, 117675, 117690, 117705, 117720, 117735, 117750, 117765, 117780, 117795, 117810, 117825, 117840, 117855, 117870, 117885, 117900, 117915, 117930, 117945, 117960, 117975, 117990, 118005, 118020, 118035, 118050, 118065, 118080, 118095, 118110, 118125, 118140, 118155, 118170, 118185, 118200, 118215, 118230, 118245, 118260, 118275, 118290, 118305, 118320, 118335, 118350, 118365, 118380, 118395, 118410, 118425, 118440]\n assert candidate(candies = 150,num_people = 4) == [42, 32, 36, 40]\n assert candidate(candies = 100,num_people = 2) == [49, 51]\n assert candidate(candies = 123456789,num_people = 123) == [999872, 1000000, 1000128, 1000256, 1000384, 1000512, 1000640, 1000768, 1000896, 1001024, 1001152, 1001280, 1001408, 1001536, 1001664, 1001792, 1001920, 1002048, 1002176, 1002304, 1002432, 1002560, 1002688, 1002816, 1002944, 1003072, 1003200, 1003328, 1003456, 1003584, 1003712, 1003840, 1003968, 1004096, 1004224, 1004352, 1004480, 1004608, 1004736, 1004864, 1004992, 1005120, 1005248, 1005376, 1005504, 1005632, 1005760, 1005888, 1006016, 1006144, 1006272, 1006400, 1006528, 1006656, 1006784, 1006912, 1007040, 1007168, 1007296, 1007424, 1007552, 1007680, 1007808, 1007936, 1008064, 1008192, 1008320, 1008448, 1008576, 1008704, 1008832, 1008960, 1009088, 1009216, 1009344, 1009472, 1009600, 1009728, 1009856, 1009984, 1010112, 1010240, 1010368, 1010496, 1010624, 1010752, 1010880, 1011008, 1011136, 1011264, 1011392, 1011268, 995934, 996061, 996188, 996315, 996442, 996569, 996696, 996823, 996950, 997077, 997204, 997331, 997458, 997585, 997712, 997839, 997966, 998093, 998220, 998347, 998474, 998601, 998728, 998855, 998982, 999109, 999236, 999363, 999490, 999617, 999744]\n assert candidate(candies = 3000,num_people = 20) == [124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 185, 114, 117, 120]\n assert candidate(candies = 200,num_people = 1) == [200]\n assert candidate(candies = 9,num_people = 3) == [4, 2, 3]\n assert candidate(candies = 120,num_people = 2) == [64, 56]\n assert candidate(candies = 1500,num_people = 50) == [52, 54, 56, 58, 20, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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(candies = 100000,num_people = 2) == [50048, 49952]\n assert candidate(candies = 200000000,num_people = 100) == [1990200, 1990400, 1990600, 1990800, 1991000, 1991200, 1991400, 1991600, 1991800, 1992000, 1992200, 1992400, 1992600, 1992800, 1993000, 1993200, 1993400, 1993600, 1993800, 1994000, 1994200, 1994400, 1994600, 1994800, 1995000, 1995200, 1995400, 1995600, 1995800, 1996000, 1996200, 1996400, 1996600, 1996800, 1997000, 1997200, 1997400, 1997600, 1997800, 1998000, 1998200, 1998400, 1998600, 1998800, 1999000, 1999200, 1999400, 1999600, 1999800, 2000000, 2000200, 2000400, 2000600, 2000800, 2001000, 2001200, 2001400, 2001600, 2001800, 2002000, 2002200, 2002400, 2002600, 2002800, 2003000, 2003200, 2003400, 2003600, 2003800, 2004000, 2004200, 2004400, 2004600, 2004800, 2005000, 2005200, 2005400, 2005600, 2005800, 2006000, 2006200, 2006400, 2006600, 2006800, 2007000, 2007200, 2007400, 2007600, 2007800, 2008000, 2008200, 2008400, 2008600, 2008800, 2009000, 2009200, 2009400, 2009600, 2009800, 2000000]\n assert candidate(candies = 20,num_people = 1) == [20]\n assert candidate(candies = 1000000,num_people = 100) == [10515, 10530, 10545, 10560, 10575, 10590, 10605, 10620, 10635, 10650, 10665, 10680, 10695, 10305, 9310, 9324, 9338, 9352, 9366, 9380, 9394, 9408, 9422, 9436, 9450, 9464, 9478, 9492, 9506, 9520, 9534, 9548, 9562, 9576, 9590, 9604, 9618, 9632, 9646, 9660, 9674, 9688, 9702, 9716, 9730, 9744, 9758, 9772, 9786, 9800, 9814, 9828, 9842, 9856, 9870, 9884, 9898, 9912, 9926, 9940, 9954, 9968, 9982, 9996, 10010, 10024, 10038, 10052, 10066, 10080, 10094, 10108, 10122, 10136, 10150, 10164, 10178, 10192, 10206, 10220, 10234, 10248, 10262, 10276, 10290, 10304, 10318, 10332, 10346, 10360, 10374, 10388, 10402, 10416, 10430, 10444, 10458, 10472, 10486, 10500]\n assert candidate(candies = 123456789,num_people = 300) == [413453, 413506, 413559, 413612, 413665, 413718, 413771, 413824, 413877, 413930, 413983, 414036, 414089, 414142, 414195, 414248, 414301, 414354, 414407, 414460, 414513, 414566, 414619, 414672, 414725, 414778, 414831, 414884, 414937, 414990, 415043, 415096, 415149, 415202, 415255, 415308, 415361, 415414, 415467, 415520, 415573, 415626, 415679, 415732, 415785, 415838, 415891, 415944, 415997, 416050, 416103, 416156, 416209, 416262, 416315, 416368, 416421, 416474, 416527, 416580, 416633, 416686, 416739, 416792, 416845, 416898, 416951, 417004, 417057, 417110, 417163, 417216, 417269, 417322, 417375, 417428, 417481, 417534, 417587, 417640, 417693, 417746, 417799, 417852, 417905, 417958, 418011, 418064, 418117, 418170, 418223, 418276, 418329, 418382, 418435, 418488, 418541, 418594, 418647, 418700, 418753, 418806, 418859, 418912, 418965, 419018, 419071, 419124, 419177, 419230, 419283, 419336, 419137, 403728, 403780, 403832, 403884, 403936, 403988, 404040, 404092, 404144, 404196, 404248, 404300, 404352, 404404, 404456, 404508, 404560, 404612, 404664, 404716, 404768, 404820, 404872, 404924, 404976, 405028, 405080, 405132, 405184, 405236, 405288, 405340, 405392, 405444, 405496, 405548, 405600, 405652, 405704, 405756, 405808, 405860, 405912, 405964, 406016, 406068, 406120, 406172, 406224, 406276, 406328, 406380, 406432, 406484, 406536, 406588, 406640, 406692, 406744, 406796, 406848, 406900, 406952, 407004, 407056, 407108, 407160, 407212, 407264, 407316, 407368, 407420, 407472, 407524, 407576, 407628, 407680, 407732, 407784, 407836, 407888, 407940, 407992, 408044, 408096, 408148, 408200, 408252, 408304, 408356, 408408, 408460, 408512, 408564, 408616, 408668, 408720, 408772, 408824, 408876, 408928, 408980, 409032, 409084, 409136, 409188, 409240, 409292, 409344, 409396, 409448, 409500, 409552, 409604, 409656, 409708, 409760, 409812, 409864, 409916, 409968, 410020, 410072, 410124, 410176, 410228, 410280, 410332, 410384, 410436, 410488, 410540, 410592, 410644, 410696, 410748, 410800, 410852, 410904, 410956, 411008, 411060, 411112, 411164, 411216, 411268, 411320, 411372, 411424, 411476, 411528, 411580, 411632, 411684, 411736, 411788, 411840, 411892, 411944, 411996, 412048, 412100, 412152, 412204, 412256, 412308, 412360, 412412, 412464, 412516, 412568, 412620, 412672, 412724, 412776, 412828, 412880, 412932, 412984, 413036, 413088, 413140, 413192, 413244, 413296, 413348, 413400]\n assert candidate(candies = 12345,num_people = 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, 133, 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]\n assert candidate(candies = 250,num_people = 25) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 19, 0, 0, 0]\n assert candidate(candies = 50,num_people = 3) == [17, 15, 18]\n assert candidate(candies = 25,num_people = 25) == [1, 2, 3, 4, 5, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(candies = 10000,num_people = 2) == [5030, 4970]\n assert candidate(candies = 123456789,num_people = 500) == [248032, 248064, 248096, 248128, 248160, 248192, 248224, 248256, 248288, 248320, 248352, 248384, 248416, 248448, 248480, 248512, 248544, 248576, 248608, 248640, 248672, 248704, 248736, 248768, 248800, 248832, 248864, 248896, 248928, 248960, 248992, 249024, 249056, 249088, 249120, 249152, 249184, 249216, 249248, 249280, 249312, 249344, 249376, 249408, 249440, 249472, 249504, 249536, 249568, 249600, 249632, 249664, 249696, 249728, 249760, 249792, 249824, 249856, 249888, 249920, 249952, 249984, 250016, 250048, 250080, 250112, 250144, 250176, 250208, 250240, 250272, 250304, 250336, 250368, 250400, 250432, 250464, 250496, 250528, 250560, 250592, 250624, 250656, 250688, 250720, 250752, 250784, 250816, 250848, 250880, 250912, 250944, 250976, 251008, 251040, 251072, 251104, 251136, 251168, 251200, 251232, 251264, 251296, 251328, 251360, 251392, 251424, 251456, 251488, 251520, 251552, 251584, 251616, 251648, 251680, 251712, 251744, 251776, 251808, 251840, 251872, 251904, 251936, 251968, 252000, 252032, 252064, 252096, 252128, 252160, 252192, 252224, 252256, 252288, 252320, 252352, 252384, 252416, 252448, 252480, 252512, 252544, 252576, 252608, 252640, 252672, 252704, 252736, 252768, 252800, 252832, 252864, 252896, 252928, 252960, 252992, 253024, 253056, 253088, 253120, 253152, 253184, 253216, 253248, 253280, 253312, 253344, 253376, 253408, 253440, 253472, 253504, 253536, 253568, 253600, 253632, 253664, 253696, 253728, 253760, 253792, 253824, 253856, 253888, 253920, 253952, 253984, 254016, 254048, 254080, 254112, 254144, 254176, 254208, 254240, 254272, 254304, 254336, 254368, 254400, 254432, 254464, 254496, 254528, 254560, 254592, 254624, 254656, 254688, 254720, 254752, 254784, 254564, 239134, 239165, 239196, 239227, 239258, 239289, 239320, 239351, 239382, 239413, 239444, 239475, 239506, 239537, 239568, 239599, 239630, 239661, 239692, 239723, 239754, 239785, 239816, 239847, 239878, 239909, 239940, 239971, 240002, 240033, 240064, 240095, 240126, 240157, 240188, 240219, 240250, 240281, 240312, 240343, 240374, 240405, 240436, 240467, 240498, 240529, 240560, 240591, 240622, 240653, 240684, 240715, 240746, 240777, 240808, 240839, 240870, 240901, 240932, 240963, 240994, 241025, 241056, 241087, 241118, 241149, 241180, 241211, 241242, 241273, 241304, 241335, 241366, 241397, 241428, 241459, 241490, 241521, 241552, 241583, 241614, 241645, 241676, 241707, 241738, 241769, 241800, 241831, 241862, 241893, 241924, 241955, 241986, 242017, 242048, 242079, 242110, 242141, 242172, 242203, 242234, 242265, 242296, 242327, 242358, 242389, 242420, 242451, 242482, 242513, 242544, 242575, 242606, 242637, 242668, 242699, 242730, 242761, 242792, 242823, 242854, 242885, 242916, 242947, 242978, 243009, 243040, 243071, 243102, 243133, 243164, 243195, 243226, 243257, 243288, 243319, 243350, 243381, 243412, 243443, 243474, 243505, 243536, 243567, 243598, 243629, 243660, 243691, 243722, 243753, 243784, 243815, 243846, 243877, 243908, 243939, 243970, 244001, 244032, 244063, 244094, 244125, 244156, 244187, 244218, 244249, 244280, 244311, 244342, 244373, 244404, 244435, 244466, 244497, 244528, 244559, 244590, 244621, 244652, 244683, 244714, 244745, 244776, 244807, 244838, 244869, 244900, 244931, 244962, 244993, 245024, 245055, 245086, 245117, 245148, 245179, 245210, 245241, 245272, 245303, 245334, 245365, 245396, 245427, 245458, 245489, 245520, 245551, 245582, 245613, 245644, 245675, 245706, 245737, 245768, 245799, 245830, 245861, 245892, 245923, 245954, 245985, 246016, 246047, 246078, 246109, 246140, 246171, 246202, 246233, 246264, 246295, 246326, 246357, 246388, 246419, 246450, 246481, 246512, 246543, 246574, 246605, 246636, 246667, 246698, 246729, 246760, 246791, 246822, 246853, 246884, 246915, 246946, 246977, 247008, 247039, 247070, 247101, 247132, 247163, 247194, 247225, 247256, 247287, 247318, 247349, 247380, 247411, 247442, 247473, 247504, 247535, 247566, 247597, 247628, 247659, 247690, 247721, 247752, 247783, 247814, 247845, 247876, 247907, 247938, 247969, 248000]\n assert candidate(candies = 123456789,num_people = 200) == [616279, 616358, 616437, 616516, 616595, 616674, 616753, 616832, 616911, 616990, 617069, 617148, 617227, 617306, 617385, 617464, 617543, 617622, 617701, 617780, 617859, 617938, 618017, 618096, 618175, 618254, 618333, 618412, 618491, 618570, 618649, 618728, 618807, 618886, 618965, 619044, 619123, 619202, 619281, 619360, 619439, 619518, 619597, 619676, 619755, 619834, 619913, 619992, 620071, 620150, 620229, 620308, 620387, 620466, 620545, 620624, 620703, 620782, 620861, 620940, 621019, 621098, 621177, 621256, 621335, 621414, 621493, 621572, 621651, 621730, 621809, 621888, 621967, 622046, 622125, 622204, 622283, 622362, 622441, 622520, 622599, 622678, 622757, 622836, 622915, 622994, 623073, 623152, 623231, 623310, 623389, 623468, 623547, 623626, 623705, 623784, 623863, 623942, 624021, 624100, 624179, 624258, 624337, 624416, 624495, 624574, 624653, 624732, 624811, 624890, 624969, 625048, 624875, 609492, 609570, 609648, 609726, 609804, 609882, 609960, 610038, 610116, 610194, 610272, 610350, 610428, 610506, 610584, 610662, 610740, 610818, 610896, 610974, 611052, 611130, 611208, 611286, 611364, 611442, 611520, 611598, 611676, 611754, 611832, 611910, 611988, 612066, 612144, 612222, 612300, 612378, 612456, 612534, 612612, 612690, 612768, 612846, 612924, 613002, 613080, 613158, 613236, 613314, 613392, 613470, 613548, 613626, 613704, 613782, 613860, 613938, 614016, 614094, 614172, 614250, 614328, 614406, 614484, 614562, 614640, 614718, 614796, 614874, 614952, 615030, 615108, 615186, 615264, 615342, 615420, 615498, 615576, 615654, 615732, 615810, 615888, 615966, 616044, 616122, 616200]\n assert candidate(candies = 1000000,num_people = 50) == [20329, 20358, 20387, 20416, 20445, 20474, 20503, 20532, 20561, 20590, 20619, 20648, 20677, 20301, 19320, 19348, 19376, 19404, 19432, 19460, 19488, 19516, 19544, 19572, 19600, 19628, 19656, 19684, 19712, 19740, 19768, 19796, 19824, 19852, 19880, 19908, 19936, 19964, 19992, 20020, 20048, 20076, 20104, 20132, 20160, 20188, 20216, 20244, 20272, 20300]\n assert candidate(candies = 8,num_people = 3) == [3, 2, 3]\n assert candidate(candies = 8,num_people = 2) == [4, 4]\n assert candidate(candies = 1,num_people = 100) == [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]\n assert candidate(candies = 1,num_people = 1000) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(candies = 88,num_people = 10) == [12, 14, 13, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(candies = 2,num_people = 1) == [2]\n assert candidate(candies = 25,num_people = 10) == [1, 2, 3, 4, 5, 6, 4, 0, 0, 0]\n assert candidate(candies = 150,num_people = 8) == [24, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(candies = 5000,num_people = 499) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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(candies = 200,num_people = 4) == [45, 50, 55, 50]\n assert candidate(candies = 1000000,num_people = 500) == [1503, 1506, 1509, 1512, 1515, 1518, 1521, 1524, 1527, 1530, 1533, 1536, 1539, 1542, 1545, 1548, 1551, 1554, 1557, 1560, 1563, 1566, 1569, 1572, 1575, 1578, 1581, 1584, 1587, 1590, 1593, 1596, 1599, 1602, 1605, 1608, 1611, 1614, 1617, 1620, 1623, 1626, 1629, 1632, 1635, 1638, 1641, 1644, 1647, 1650, 1653, 1656, 1659, 1662, 1665, 1668, 1671, 1674, 1677, 1680, 1683, 1686, 1689, 1692, 1695, 1698, 1701, 1704, 1707, 1710, 1713, 1716, 1719, 1722, 1725, 1728, 1731, 1734, 1737, 1740, 1743, 1746, 1749, 1752, 1755, 1758, 1761, 1764, 1767, 1770, 1773, 1776, 1779, 1782, 1785, 1788, 1791, 1794, 1797, 1800, 1803, 1806, 1809, 1812, 1815, 1818, 1821, 1824, 1827, 1830, 1833, 1836, 1839, 1842, 1845, 1848, 1851, 1854, 1857, 1860, 1863, 1866, 1869, 1872, 1875, 1878, 1881, 1884, 1887, 1890, 1893, 1896, 1899, 1902, 1905, 1908, 1911, 1914, 1917, 1920, 1923, 1926, 1929, 1932, 1935, 1938, 1941, 1944, 1947, 1950, 1953, 1956, 1959, 1962, 1965, 1968, 1971, 1974, 1977, 1980, 1983, 1986, 1989, 1992, 1995, 1998, 2001, 2004, 2007, 2010, 2013, 2016, 2019, 2022, 2025, 2028, 2031, 2034, 2037, 2040, 2043, 2046, 2049, 2052, 2055, 2058, 2061, 2064, 2067, 2070, 2073, 2076, 2079, 2082, 2085, 2088, 2091, 2094, 2097, 2100, 2103, 2106, 2109, 2112, 2115, 2118, 2121, 2124, 2127, 2130, 2133, 2136, 2139, 2142, 2145, 2148, 2151, 2154, 2157, 2160, 2163, 2166, 2169, 2172, 2175, 2178, 2181, 2184, 2187, 2190, 2193, 2196, 2199, 2202, 2205, 2208, 2211, 2214, 2217, 2220, 2223, 2226, 2229, 2232, 2235, 2238, 2241, 2244, 2247, 2250, 2253, 2256, 2259, 2262, 2265, 2268, 2271, 2274, 2277, 2280, 2283, 2286, 2289, 2292, 2295, 2298, 2301, 2304, 2307, 2310, 2313, 2316, 2319, 2322, 2325, 2328, 2331, 2334, 2337, 2340, 2343, 2346, 2349, 2352, 2355, 2358, 2361, 2364, 2367, 2370, 2373, 2376, 2379, 2382, 2385, 2388, 2391, 2394, 2397, 2400, 2403, 2406, 2409, 2412, 2415, 2418, 2421, 2424, 2427, 2430, 2433, 2436, 2439, 2442, 2445, 2448, 2451, 2454, 2457, 2460, 2463, 2466, 2469, 2472, 2475, 2478, 2481, 2484, 2487, 2490, 2493, 2496, 2499, 2502, 2505, 2508, 2511, 2514, 2517, 2520, 2523, 2526, 2529, 2532, 2535, 2538, 2541, 2544, 2547, 2550, 2553, 2556, 2559, 2562, 2565, 2568, 2571, 2574, 2577, 2580, 2583, 2586, 2589, 2592, 2595, 2598, 2601, 2604, 2607, 2610, 2613, 2616, 2619, 2622, 2625, 2628, 2631, 2634, 2637, 2640, 2643, 2646, 2649, 2652, 2655, 2658, 2661, 2664, 2667, 2670, 2673, 2676, 2679, 2682, 2685, 2688, 2691, 2694, 2697, 2700, 2703, 2706, 2709, 2712, 2715, 2718, 2721, 2724, 2727, 2730, 2733, 2736, 2739, 2337, 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]\n assert candidate(candies = 8,num_people = 4) == [1, 2, 3, 2]\n", "comparison": "exact"}, "public_tests": ["7\n4", "10\n3"], "hints": ["Give candy to everyone each \"turn\" first [until you can't], then give candy to one person per turn."], "metadata": {"canonical_parameter_names": ["candies", "num_people"], "leetcode_dataset_entry_point": "Solution().distributeCandies", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:33+00:00", "tests_total": 88, "tests_dropped": 1, "flags": [], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def distributeCandies(self, candies: int, num_people: int) -> list[int]:", "container": "Solution", "callable": "distributeCandies", "parameters": [{"name": "candies", "type": "int"}, {"name": "num_people", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1104, "task_id": "path-in-zigzag-labelled-binary-tree", "difficulty": "Medium", "problem_description": "In an infinite binary tree where every node has two children, the nodes are labelled in row order.\n\nIn the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left.\n\nGiven the label of a node in this tree, return the labels in the path from the root of the tree to the node with that label.\n\nExample 1:\n\nInput: label = 14\nOutput: [1,3,4,14]\n\nExample 2:\n\nInput: label = 26\nOutput: [1,2,6,10,26]\n\nConstraints:\n\n- 1 <= label <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(label = 14) == [1, 3, 4, 14]\n assert candidate(label = 1023) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023]\n assert candidate(label = 3) == [1, 3]\n assert candidate(label = 1000000) == [1, 3, 4, 15, 17, 61, 69, 244, 279, 976, 1118, 3906, 4475, 15625, 17901, 62500, 71607, 250000, 286431, 1000000]\n assert candidate(label = 255) == [1, 3, 4, 15, 16, 63, 64, 255]\n assert candidate(label = 4) == [1, 3, 4]\n assert candidate(label = 13) == [1, 3, 5, 13]\n assert candidate(label = 15) == [1, 3, 4, 15]\n assert candidate(label = 6) == [1, 2, 6]\n assert candidate(label = 11) == [1, 2, 6, 11]\n assert candidate(label = 2) == [1, 2]\n assert candidate(label = 64) == [1, 3, 4, 15, 16, 63, 64]\n assert candidate(label = 8) == [1, 2, 7, 8]\n assert candidate(label = 1) == [1]\n assert candidate(label = 9) == [1, 2, 7, 9]\n assert candidate(label = 26) == [1, 2, 6, 10, 26]\n assert candidate(label = 12) == [1, 3, 5, 12]\n assert candidate(label = 10) == [1, 2, 6, 10]\n assert candidate(label = 7) == [1, 2, 7]\n assert candidate(label = 5) == [1, 3, 5]\n assert candidate(label = 16) == [1, 3, 4, 15, 16]\n assert candidate(label = 5000) == [1, 3, 4, 14, 19, 56, 78, 227, 312, 910, 1250, 3643, 5000]\n assert candidate(label = 1024) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024]\n assert candidate(label = 31) == [1, 2, 7, 8, 31]\n assert candidate(label = 32768) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192, 32767, 32768]\n assert candidate(label = 524288) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192, 32767, 32768, 131071, 131072, 524287, 524288]\n assert candidate(label = 8192) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192]\n assert candidate(label = 768) == [1, 3, 5, 12, 23, 48, 95, 192, 383, 768]\n assert candidate(label = 786432) == [1, 3, 5, 12, 23, 48, 95, 192, 383, 768, 1535, 3072, 6143, 12288, 24575, 49152, 98303, 196608, 393215, 786432]\n assert candidate(label = 789012) == [1, 3, 5, 12, 23, 48, 95, 192, 382, 770, 1530, 3082, 6123, 12328, 24495, 49313, 97981, 197253, 391925, 789012]\n assert candidate(label = 65536) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096, 16383, 16384, 65535, 65536]\n assert candidate(label = 4095) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095]\n assert candidate(label = 511) == [1, 2, 7, 8, 31, 32, 127, 128, 511]\n assert candidate(label = 524287) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192, 32767, 32768, 131071, 131072, 524287]\n assert candidate(label = 98304) == [1, 2, 6, 11, 24, 47, 96, 191, 384, 767, 1536, 3071, 6144, 12287, 24576, 49151, 98304]\n assert candidate(label = 393216) == [1, 2, 6, 11, 24, 47, 96, 191, 384, 767, 1536, 3071, 6144, 12287, 24576, 49151, 98304, 196607, 393216]\n assert candidate(label = 18) == [1, 3, 4, 14, 18]\n assert candidate(label = 16383) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096, 16383]\n assert candidate(label = 512) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512]\n assert candidate(label = 16384) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096, 16383, 16384]\n assert candidate(label = 131072) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192, 32767, 32768, 131071, 131072]\n assert candidate(label = 262143) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096, 16383, 16384, 65535, 65536, 262143]\n assert candidate(label = 127) == [1, 2, 7, 8, 31, 32, 127]\n assert candidate(label = 4096) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096]\n assert candidate(label = 32) == [1, 2, 7, 8, 31, 32]\n assert candidate(label = 777777) == [1, 2, 6, 11, 24, 47, 97, 189, 388, 759, 1552, 3038, 6211, 12152, 24846, 48611, 99385, 194444, 397543, 777777]\n assert candidate(label = 262144) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096, 16383, 16384, 65535, 65536, 262143, 262144]\n assert candidate(label = 500000) == [1, 2, 7, 8, 30, 34, 122, 139, 488, 559, 1953, 2237, 7812, 8950, 31250, 35803, 125000, 143215, 500000]\n assert candidate(label = 2048) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048]\n assert candidate(label = 150) == [1, 2, 7, 9, 29, 37, 116, 150]\n assert candidate(label = 999999) == [1, 3, 4, 15, 17, 61, 69, 244, 279, 976, 1118, 3906, 4475, 15624, 17902, 62499, 71608, 249999, 286432, 999999]\n assert candidate(label = 888888) == [1, 3, 5, 13, 20, 54, 83, 217, 333, 868, 1335, 3472, 5343, 13888, 21374, 55555, 85496, 222222, 341987, 888888]\n assert candidate(label = 8191) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191]\n assert candidate(label = 196608) == [1, 3, 5, 12, 23, 48, 95, 192, 383, 768, 1535, 3072, 6143, 12288, 24575, 49152, 98303, 196608]\n assert candidate(label = 128) == [1, 2, 7, 8, 31, 32, 127, 128]\n assert candidate(label = 2047) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047]\n assert candidate(label = 65535) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023, 1024, 4095, 4096, 16383, 16384, 65535]\n assert candidate(label = 983041) == [1, 3, 4, 15, 17, 60, 71, 240, 287, 960, 1151, 3840, 4607, 15360, 18431, 61440, 73727, 245760, 294911, 983041]\n assert candidate(label = 393215) == [1, 3, 5, 12, 23, 48, 95, 192, 383, 768, 1535, 3072, 6143, 12288, 24575, 49152, 98303, 196608, 393215]\n assert candidate(label = 32767) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192, 32767]\n assert candidate(label = 200000) == [1, 3, 5, 12, 23, 48, 94, 195, 377, 781, 1509, 3125, 6037, 12500, 24151, 50000, 96607, 200000]\n assert candidate(label = 131071) == [1, 2, 7, 8, 31, 32, 127, 128, 511, 512, 2047, 2048, 8191, 8192, 32767, 32768, 131071]\n assert candidate(label = 100000) == [1, 2, 6, 11, 24, 47, 97, 188, 390, 754, 1562, 3018, 6250, 12075, 25000, 48303, 100000]\n assert candidate(label = 800000) == [1, 3, 5, 12, 23, 48, 94, 195, 377, 781, 1509, 3125, 6037, 12500, 24151, 50000, 96607, 200000, 386431, 800000]\n assert candidate(label = 123456) == [1, 2, 7, 8, 30, 35, 120, 142, 482, 571, 1929, 2285, 7716, 9143, 30864, 36575, 123456]\n assert candidate(label = 63) == [1, 3, 4, 15, 16, 63]\n assert candidate(label = 256) == [1, 3, 4, 15, 16, 63, 64, 255, 256]\n assert candidate(label = 17) == [1, 3, 4, 15, 17]\n", "comparison": "exact"}, "public_tests": ["14", "26"], "hints": ["Based on the label of the current node, find what the label must be for the parent of that node."], "metadata": {"canonical_parameter_names": ["label"], "leetcode_dataset_entry_point": "Solution().pathInZigZagTree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:36+00:00", "tests_total": 78, "tests_dropped": 10, "flags": ["has_images"], "topic_tags": ["math", "tree", "binary-tree"]}, "language": "python", "interface": {"raw_signature": "def pathInZigZagTree(self, label: int) -> list[int]:", "container": "Solution", "callable": "pathInZigZagTree", "parameters": [{"name": "label", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1105, "task_id": "filling-bookcase-shelves", "difficulty": "Medium", "problem_description": "You are given an array books where books[i] = [thickness_i, height_i] indicates the thickness and height of the i^th book. You are also given an integer shelfWidth.\n\nWe want to place these books in order onto bookcase shelves that have a total width shelfWidth.\n\nWe choose some of the books to place on this shelf such that the sum of their thickness is less than or equal to shelfWidth, then build another level of the shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down. We repeat this process until there are no more books to place.\n\nNote that at each step of the above process, the order of the books we place is the same order as the given sequence of books.\n\n- For example, if we have an ordered list of 5 books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf.\n\nReturn the minimum possible height that the total bookshelf can be after placing shelves in this manner.\n\nExample 1:\n\nInput: books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelfWidth = 4\nOutput: 6\nExplanation:\nThe sum of the heights of the 3 shelves is 1 + 3 + 2 = 6.\nNotice that book number 2 does not have to be on the first shelf.\n\nExample 2:\n\nInput: books = [[1,3],[2,4],[3,2]], shelfWidth = 6\nOutput: 4\n\nConstraints:\n\n- 1 <= books.length <= 1000\n- 1 <= thickness_i <= shelfWidth <= 1000\n- 1 <= height_i <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 1) == 10\n assert candidate(books = [[1, 1], [2, 2], [3, 3]],shelfWidth = 5) == 4\n assert candidate(books = [[10, 1], [2, 2], [3, 3], [4, 4]],shelfWidth = 10) == 5\n assert candidate(books = [[5, 5], [5, 5], [5, 5]],shelfWidth = 10) == 10\n assert candidate(books = [[3, 1], [2, 2], [4, 3], [1, 4], [2, 5]],shelfWidth = 6) == 9\n assert candidate(books = [[1, 1], [2, 3], [2, 3], [1, 1], [1, 1], [1, 1], [1, 2]],shelfWidth = 4) == 6\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 2) == 2\n assert candidate(books = [[1, 3], [2, 4], [3, 2]],shelfWidth = 6) == 4\n assert candidate(books = [[5, 5], [5, 5], [5, 5], [5, 5]],shelfWidth = 10) == 10\n assert candidate(books = [[1, 1000], [1, 1000], [1, 1000]],shelfWidth = 3) == 1000\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 1) == 5\n assert candidate(books = [[3, 1], [2, 2], [1, 3]],shelfWidth = 5) == 4\n assert candidate(books = [[1, 2], [2, 3], [3, 4], [4, 5]],shelfWidth = 10) == 5\n assert candidate(books = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1]],shelfWidth = 10) == 7\n assert candidate(books = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],shelfWidth = 15) == 10\n assert candidate(books = [[10, 100], [5, 200], [5, 300], [10, 400], [5, 500], [5, 600], [10, 700], [10, 800], [5, 900], [5, 1000]],shelfWidth = 20) == 2200\n assert candidate(books = [[3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]],shelfWidth = 10) == 21\n assert candidate(books = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],shelfWidth = 15) == 10\n assert candidate(books = [[500, 1], [500, 2], [500, 3], [500, 4], [500, 5], [500, 6], [500, 7], [500, 8], [500, 9], [500, 10], [500, 11], [500, 12], [500, 13], [500, 14], [500, 15]],shelfWidth = 1000) == 64\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 1) == 15\n assert candidate(books = [[300, 100], [300, 200], [300, 300], [100, 400], [100, 500], [100, 600], [100, 700]],shelfWidth = 600) == 1100\n assert candidate(books = [[3, 1], [2, 5], [4, 7], [1, 2], [5, 3], [3, 4]],shelfWidth = 10) == 11\n assert candidate(books = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],shelfWidth = 10) == 18\n assert candidate(books = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],shelfWidth = 10) == 31\n assert candidate(books = [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]],shelfWidth = 6) == 15\n assert candidate(books = [[1, 500], [2, 500], [3, 500], [4, 500], [5, 500]],shelfWidth = 5) == 2000\n assert candidate(books = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],shelfWidth = 10) == 48\n assert candidate(books = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],shelfWidth = 20) == 25\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 3) == 4\n assert candidate(books = [[100, 500], [99, 499], [98, 498], [97, 497], [96, 496], [95, 495]],shelfWidth = 300) == 997\n assert candidate(books = [[10, 100], [10, 100], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 20) == 101\n assert candidate(books = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],shelfWidth = 20) == 19\n assert candidate(books = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]],shelfWidth = 15) == 47\n assert candidate(books = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5]],shelfWidth = 12) == 8\n assert candidate(books = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],shelfWidth = 5) == 15\n assert candidate(books = [[1, 500], [2, 500], [3, 500], [4, 500], [5, 500]],shelfWidth = 10) == 1000\n assert candidate(books = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],shelfWidth = 15) == 21\n assert candidate(books = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],shelfWidth = 20) == 30\n assert candidate(books = [[100, 100], [100, 200], [100, 300], [100, 400], [100, 500], [100, 600], [100, 700], [100, 800], [100, 900], [100, 1000]],shelfWidth = 300) == 2200\n assert candidate(books = [[5, 10], [10, 5], [15, 10], [20, 5], [25, 10], [30, 5], [35, 10], [40, 5], [45, 10], [50, 5]],shelfWidth = 50) == 55\n assert candidate(books = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10]],shelfWidth = 100) == 480\n assert candidate(books = [[500, 500], [500, 400], [300, 300], [200, 200], [100, 100]],shelfWidth = 1000) == 800\n assert candidate(books = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],shelfWidth = 5) == 30\n assert candidate(books = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],shelfWidth = 15) == 41\n assert candidate(books = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],shelfWidth = 13) == 77\n assert candidate(books = [[5, 1], [1, 5], [3, 3], [2, 2], [4, 4], [6, 6], [7, 7]],shelfWidth = 12) == 18\n assert candidate(books = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],shelfWidth = 1000) == 48\n assert candidate(books = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 1]],shelfWidth = 15) == 30\n assert candidate(books = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],shelfWidth = 15) == 22\n assert candidate(books = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],shelfWidth = 15) == 4971\n assert candidate(books = [[7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1]],shelfWidth = 14) == 16\n assert candidate(books = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900]],shelfWidth = 150) == 2600\n assert candidate(books = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],shelfWidth = 15) == 21\n assert candidate(books = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],shelfWidth = 25) == 15\n assert candidate(books = [[2, 10], [1, 5], [3, 15], [4, 20], [2, 8]],shelfWidth = 10) == 28\n assert candidate(books = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],shelfWidth = 20) == 19\n assert candidate(books = [[7, 3], [8, 4], [6, 5], [5, 6], [9, 7], [10, 8], [8, 9]],shelfWidth = 20) == 20\n assert candidate(books = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],shelfWidth = 10) == 4800\n assert candidate(books = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],shelfWidth = 10) == 6961\n assert candidate(books = [[250, 500], [500, 250], [250, 750], [750, 250], [500, 500], [500, 500], [250, 250], [250, 250], [250, 250], [250, 250]],shelfWidth = 1000) == 1750\n assert candidate(books = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],shelfWidth = 15) == 36\n assert candidate(books = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],shelfWidth = 5) == 15\n assert candidate(books = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],shelfWidth = 60) == 120\n assert candidate(books = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],shelfWidth = 15) == 17\n assert candidate(books = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50], [5, 10], [4, 20], [3, 30], [2, 40], [1, 50]],shelfWidth = 15) == 100\n assert candidate(books = [[7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2]],shelfWidth = 10) == 25\n assert candidate(books = [[3, 10], [2, 5], [1, 20], [4, 1], [5, 30], [3, 20], [2, 10], [1, 5], [4, 25], [5, 15]],shelfWidth = 10) == 75\n assert candidate(books = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],shelfWidth = 1) == 55\n assert candidate(books = [[5, 10], [4, 8], [3, 6], [2, 4], [1, 2], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10]],shelfWidth = 10) == 32\n assert candidate(books = [[1000, 1], [1000, 2], [1000, 3], [1000, 4], [1000, 5], [1000, 6], [1000, 7], [1000, 8], [1000, 9], [1000, 10]],shelfWidth = 1000) == 55\n assert candidate(books = [[1, 500], [2, 400], [3, 300], [4, 200], [5, 100]],shelfWidth = 15) == 500\n assert candidate(books = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],shelfWidth = 15) == 10\n assert candidate(books = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],shelfWidth = 150) == 36\n assert candidate(books = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],shelfWidth = 15) == 20\n assert candidate(books = [[3, 1], [1, 2], [1, 3], [3, 4], [2, 5], [1, 1], [2, 2], [3, 3], [1, 1]],shelfWidth = 5) == 13\n assert candidate(books = [[2, 1], [1, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],shelfWidth = 15) == 36\n assert candidate(books = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]],shelfWidth = 10) == 22\n assert candidate(books = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],shelfWidth = 10) == 55\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 5) == 2\n assert candidate(books = [[100, 1], [90, 2], [80, 3], [70, 4], [60, 5], [50, 6], [40, 7], [30, 8], [20, 9], [10, 10]],shelfWidth = 150) == 21\n assert candidate(books = [[5, 2], [3, 5], [4, 1], [6, 3], [2, 8], [1, 4], [7, 6]],shelfWidth = 15) == 15\n assert candidate(books = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],shelfWidth = 15) == 2100\n assert candidate(books = [[1, 200], [1, 100], [1, 150], [1, 50], [1, 250], [1, 100]],shelfWidth = 2) == 600\n assert candidate(books = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],shelfWidth = 10) == 29\n assert candidate(books = [[5, 10], [10, 5], [5, 5], [5, 10], [10, 5], [5, 5], [5, 10], [10, 5], [5, 5]],shelfWidth = 15) == 40\n assert candidate(books = [[1, 3], [2, 4], [3, 2], [4, 1], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],shelfWidth = 12) == 44\n assert candidate(books = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],shelfWidth = 20) == 23\n assert candidate(books = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],shelfWidth = 10) == 25\n assert candidate(books = [[2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2]],shelfWidth = 15) == 25\n assert candidate(books = [[3, 5], [2, 8], [1, 7], [4, 4], [5, 6], [6, 3], [7, 2], [8, 9]],shelfWidth = 12) == 25\n assert candidate(books = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],shelfWidth = 20) == 30\n assert candidate(books = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],shelfWidth = 20) == 18\n assert candidate(books = [[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, 1000], [1, 1000], [1, 1000], [1, 1000], [1, 1000]],shelfWidth = 3) == 7000\n assert candidate(books = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],shelfWidth = 1000) == 1250\n assert candidate(books = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],shelfWidth = 10) == 10\n assert candidate(books = [[7, 8], [6, 9], [5, 10], [4, 11], [3, 12], [2, 13], [1, 14]],shelfWidth = 20) == 23\n", "comparison": "exact"}, "public_tests": ["[[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]]\n4", "[[1,3],[2,4],[3,2]]\n6"], "hints": ["Use dynamic programming: dp(i) will be the answer to the problem for books[i:]."], "metadata": {"canonical_parameter_names": ["books", "shelfWidth"], "leetcode_dataset_entry_point": "Solution().minHeightShelves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:38+00:00", "tests_total": 101, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minHeightShelves(self, books: list[list[int]], shelfWidth: int) -> int:", "container": "Solution", "callable": "minHeightShelves", "parameters": [{"name": "books", "type": "list[list[int]]"}, {"name": "shelfWidth", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1106, "task_id": "parsing-a-boolean-expression", "difficulty": "Hard", "problem_description": "A boolean expression is an expression that evaluates to either true or false. It can be in one of the following shapes:\n\n- 't' that evaluates to true.\n- 'f' that evaluates to false.\n- '!(subExpr)' that evaluates to the logical NOT of the inner expression subExpr.\n- '&(subExpr_1, subExpr_2, ..., subExpr_n)' that evaluates to the logical AND of the inner expressions subExpr_1, subExpr_2, ..., subExpr_n where n >= 1.\n- '|(subExpr_1, subExpr_2, ..., subExpr_n)' that evaluates to the logical OR of the inner expressions subExpr_1, subExpr_2, ..., subExpr_n where n >= 1.\n\nGiven a string expression that represents a boolean expression, return the evaluation of that expression.\n\nIt is guaranteed that the given expression is valid and follows the given rules.\n\nExample 1:\n\nInput: expression = \"&(|(f))\"\nOutput: false\nExplanation:\nFirst, evaluate |(f) --> f. The expression is now \"&(f)\".\nThen, evaluate &(f) --> f. The expression is now \"f\".\nFinally, return false.\n\nExample 2:\n\nInput: expression = \"|(f,f,f,t)\"\nOutput: true\nExplanation: The evaluation of (false OR false OR false OR true) is true.\n\nExample 3:\n\nInput: expression = \"!(&(f,t))\"\nOutput: true\nExplanation:\nFirst, evaluate &(f,t) --> (false AND true) --> false --> f. The expression is now \"!(f)\".\nThen, evaluate !(f) --> NOT false --> true. We return true.\n\nConstraints:\n\n- 1 <= expression.length <= 2 * 10^4\n- expression[i] is one following characters: '(', ')', '&', '|', '!', 't', 'f', and ','.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(expression = \"!(!(t))\") == True\n assert candidate(expression = \"|(t,t,t)\") == True\n assert candidate(expression = \"|(f,f,f,t)\") == True\n assert candidate(expression = \"&(t,t,t,t,t,t)\") == True\n assert candidate(expression = \"!(&(&(t,f),|(t,t)))\") == True\n assert candidate(expression = \"&(|(f,t),&(t,f))\") == False\n assert candidate(expression = \"!(|(t,t))\") == False\n assert candidate(expression = \"|(&(t,f),&(f,t))\") == False\n assert candidate(expression = \"!(&(f,t))\") == True\n assert candidate(expression = \"|(f,t,f,t)\") == True\n assert candidate(expression = \"!(f)\") == True\n assert candidate(expression = \"&(f,t)\") == False\n assert candidate(expression = \"&(!(t),f)\") == False\n assert candidate(expression = \"!(&(|(f),&(f,t)))\") == True\n assert candidate(expression = \"&(t,|(f,f,f,t),!(&(f,t)))\") == True\n assert candidate(expression = \"&(t,t,t,t)\") == True\n assert candidate(expression = \"&(|(f))\") == False\n assert candidate(expression = \"!(&(|(t),|(f)),&(t,f))\") == True\n assert candidate(expression = \"|(f,f,f,f,f,f)\") == False\n assert candidate(expression = \"t\") == True\n assert candidate(expression = \"|(t,f)\") == True\n assert candidate(expression = \"f\") == False\n assert candidate(expression = \"|(|(t,f),&(f,f))\") == True\n assert candidate(expression = \"!(t)\") == False\n assert candidate(expression = \"|(&(t,f),t)\") == True\n assert candidate(expression = \"!(!(!(t)))\") == False\n assert candidate(expression = \"|(&(f,t),|(t,f))\") == True\n assert candidate(expression = \"&(|(t,f),&(f,t),|(t,t),&(f,f))\") == False\n assert candidate(expression = \"|(t,f,t,f)\") == True\n assert candidate(expression = \"&(t,t,t)\") == True\n assert candidate(expression = \"&(|(t,f),|(f,t))\") == True\n assert candidate(expression = \"|(f,&(t,f),|(f,f))\") == False\n assert candidate(expression = \"&(|(t,f),&(f,t))\") == False\n assert candidate(expression = \"|(&(t,f),|(t,t))\") == True\n assert candidate(expression = \"|(f,!(t),&(|(f,f),|(t,t)))\") == False\n assert candidate(expression = \"&(|(|(|(t,f),f),t),!(f),&(t,!(f)))\") == True\n assert candidate(expression = \"|(&(t,|(f,f),t),&(f,!(t),t),|(t,f,f))\") == True\n assert candidate(expression = \"!(&(|(f,t,f),&(t,f)),|(t,t,f))\") == True\n assert candidate(expression = \"&(|(t,&(f,f),t),&(f,|(t,f),t),|(&(f,t),f))\") == False\n assert candidate(expression = \"|(&(t,|(f,f,f)),!(|(t,t,t)),&(f,f))\") == False\n assert candidate(expression = \"&(|(&(t,f),&(f,f)),&(t,!(t)),f)\") == False\n assert candidate(expression = \"&(|(f,t),&(t,f),|(f,t),&(t,f),|(f,t),&(t,f),|(f,t),&(t,f))\") == False\n assert candidate(expression = \"&(f,!(t),|(&(t,!(t)),|(t,f,f,t,f)),&(f,f,t,t,t,t,f,t))\") == False\n assert candidate(expression = \"&(t,|(f,!(t),&(t,f,t,t),|(f,f,f,f)),&(f,|(t,f,t,t,t)),!(f,|(t,f,f,f,f)),&(t,t,t),t)\") == False\n assert candidate(expression = \"|(&(t,f),&(f,t),|(t,t),|(f,f),!(t),!(f),&(t,|(t,t)),|(t,&(t,f)))\") == True\n assert candidate(expression = \"|(&(f,t),&(t,f),&(f,t),&(t,f),&(f,t),&(t,f),&(f,t),&(t,f))\") == False\n assert candidate(expression = \"|(|(|(|(|(|(|(|(t),f),t),f),f),f),&(t,t,t,t,t,t,t,t),|(t,f,f,t,f),&(f,f,t,t,t,t,f,t),f,t)\") == False\n assert candidate(expression = \"|(&(t,!(f)),&(f,!(t)),&(t,t),!(f))\") == True\n assert candidate(expression = \"|(f,!(t),&(t,f),!(f))\") == True\n assert candidate(expression = \"|(&(f,t),|(t,f),!(f))\") == True\n assert candidate(expression = \"!(&(|(f,t),&(f,f)),|(t,t,t))\") == True\n assert candidate(expression = \"&(|(f,f,t),!(t),|(f,f,f),&(|(t,f),f),|(t,t,t))\") == False\n assert candidate(expression = \"!(&(|(t,f,f),f),|(t,t,t))\") == True\n assert candidate(expression = \"&(f,!(t),&(t,!(f)),|(f,t))\") == False\n assert candidate(expression = \"&(|(t,f),|(f,t),&(t,t),|(t,t),&(t,f),|(f,t))\") == False\n assert candidate(expression = \"!(&(|(f,!(t),&(t,f)),!(|(f,f,t)),&(t,f),|(f,t,t,t),&(t,|(f,f,f),t),&(t,f,f,t),|(t,!(f),f),f,!(t),&(f,t,f),|(t,f,t),f,!(t),&(f,t,f),|(t,f,t),f))\") == True\n assert candidate(expression = \"!(&(|(&(f,t),f),f))\") == True\n assert candidate(expression = \"|(f,!(f),&(t,f),|(t,t,f,f),&(t,t,t,t))\") == True\n assert candidate(expression = \"&(|(f,f,t),!(t),|(f,t,f))\") == False\n assert candidate(expression = \"!(&(|(&(t,f),&(f,f)),&(t,t),f))\") == True\n assert candidate(expression = \"&(f,!(t),|(f,f,t),&(t,t,t))\") == False\n assert candidate(expression = \"&(t,|(f,!(t),&(t,f,t),|(f,f,f)),&(f,|(t,f,t,t)),!(f,|(t,f)))\") == False\n assert candidate(expression = \"!(&(|(t,f),f),&(t,t,t))\") == True\n assert candidate(expression = \"&(t,|(f,!(t),&(t,f)),&(f,|(t,f,t)),!(f))\") == False\n assert candidate(expression = \"&(&(t,t),&(t,|(t,t)),&(t,|(t,|(t,t))),&(t,|(t,|(t,|(t,t)))))\") == True\n assert candidate(expression = \"!(&(|(f,t),&(t,f)),|(f,f,f,f))\") == True\n assert candidate(expression = \"&(|(f,f,t),!(t),|(f,f,f))\") == False\n assert candidate(expression = \"&(f,|(&(f,t),f),|(t,t),!(&(f,t)))\") == False\n assert candidate(expression = \"!(&(|(|(f,t),f),&(f,t,f,t)),|(f,f,f,f,f,t,t),&(t,t,t,t,t,t,t,t))\") == True\n assert candidate(expression = \"&(f,!(t),|(&(t,!(t)),|(t,f,f,t,f)),&(f,f,t,t,t,t),&(t,t,t,t,t,t,t,t),f)\") == False\n assert candidate(expression = \"&(|(|(|(f),f),t),&(t,f,t),!(f))\") == False\n assert candidate(expression = \"!(&(|(t,f),&(f,t)),|(t,t))\") == True\n assert candidate(expression = \"&(|(t,t,t),&(t,t,t),&(f,f,f),|(t,t,t),|(f,f,f))\") == False\n assert candidate(expression = \"!(&(!(f),t),|(f,&(t,f),f),&(t,f))\") == True\n assert candidate(expression = \"&(|(t,!(f),&(t,f)),!(|(f,f,t)),&(t,f),|(f,t,t,t))\") == False\n assert candidate(expression = \"&(|(t,!(f),&(f,t)),|(t,!(t),&(f,f)),|(t,t))\") == True\n assert candidate(expression = \"|(&(t,!(t)),f,!(f),t)\") == True\n assert candidate(expression = \"!(&(&(t,t),&(f,f)),|(&(t,f),&(t,t)))\") == True\n assert candidate(expression = \"&(f,|(&(f,t),f),|(t,t))\") == False\n assert candidate(expression = \"|(&(t,!(t)),f,!(f),t,!(|(&(f,t),f)))\") == True\n assert candidate(expression = \"!(&(f,|(&(t,f),f),&(t,t,t)))\") == True\n assert candidate(expression = \"|(f,&(|(t,f),&(t,f)),|(t,f))\") == True\n assert candidate(expression = \"&(t,!(f),|(&(t,t),|(f,f)),&(|(t,f),f))\") == False\n assert candidate(expression = \"!(&(|(&(t,f),t),&(f,|(t,f,t))),|(f,!(t),&(t,f,t)),!(f))\") == True\n assert candidate(expression = \"&(|(t,f),&(t,f),|(t,t),|(f,f),&(t,!(f)))\") == False\n assert candidate(expression = \"|(|(|(f),f),f)\") == False\n assert candidate(expression = \"&(f,!(t),&(t,!(f)),|(f,t),!(&(t,!(t))))\") == False\n assert candidate(expression = \"|(|(|(|(|(t),f),t),f),&(t,!(f)))\") == True\n assert candidate(expression = \"|(|(|(|(|(|(|(|(f),f),f),f),f),f),f),f)\") == False\n assert candidate(expression = \"!(&(|(f,f,f,t),!(t),|(t,t,t)),|(f,&(t,|(f,t),&(f,f)),!(f)))\") == True\n assert candidate(expression = \"&(|(|(|(|(t),f),t),f),&(t,t,t,t,t,t,t,t),|(t,f,f,t,f),&(f,f,t,t,t,t,f,t),f)\") == False\n assert candidate(expression = \"|(f,&(|(f,f),t),&(f,|(t,f),f),!(f))\") == True\n assert candidate(expression = \"&(|(|(t,f),f),&(t,!(f)),!(|(t,f)))\") == False\n assert candidate(expression = \"&(|(f,f,f),|(t,f,t),&(t,t))\") == False\n assert candidate(expression = \"&(|(t,&(f,t)),|(t,|(f,f)),&(t,|(t,|(f,t))),|(t,&(f,|(f,t))))\") == True\n assert candidate(expression = \"!(|(f,&(t,|(t,f)),!(t)))\") == False\n assert candidate(expression = \"!(&(|(|(|(|(f),t),f),t),&(t,f,t),!(f),|(t,f)))\") == True\n assert candidate(expression = \"!(&(|(t,f),&(f,f)),!(|(t,t,t,t)))\") == True\n assert candidate(expression = \"&(|(f,f,t),&(f,f,f),!(t),|(t,f,f,f,t),&(f,t,t,f))\") == False\n assert candidate(expression = \"!(&(|(&(t,|(f,t)),t),&(f,!(t),t)),|(t,!(f),&(f,f)))\") == True\n assert candidate(expression = \"&(|(f,f,f,t),|(t,f,t,f),&(t,t,t,t))\") == True\n assert candidate(expression = \"|(f,&(t,|(f,t),&(f,f)),!(f))\") == True\n assert candidate(expression = \"|(|(|(|(|(|(|(t),f),t),f),f),f),&(t,t,t,t,t,t,t,t),&(t,t,t,t,t,t,t,t))\") == True\n assert candidate(expression = \"&(|(t,f),!(f),&(t,t,t))\") == True\n assert candidate(expression = \"|(t,&(|(f,f),&(t,f)),&(t,|(t,f),&(f,f)))\") == True\n assert candidate(expression = \"!(|(|(|(f,t),t),f),&(f,|(t,!(t),f),&(t,t,t,t,t,t)))\") == True\n assert candidate(expression = \"!(|(&(f,t),|(t,f),&(f,f),|(t,t),&(t,f),|(f,f)))\") == False\n assert candidate(expression = \"|(&(t,t,t,t),|(|(f,f),f),&(t,f,f,t,t),!(t))\") == True\n assert candidate(expression = \"|(&(f,t),&(t,f),|(t,t))\") == True\n assert candidate(expression = \"|(|(f,f,f),&(t,t,t),!(|(f,f)))\") == True\n assert candidate(expression = \"!(&(|(&(f,f),t),f),|(f,|(t,f),&(f,t)))\") == True\n assert candidate(expression = \"|(&(t,t,t,t),|(f,f,f,f),&(t,f,t,f))\") == True\n assert candidate(expression = \"|(&(t,f,!(t)),&(t,f,t),&(f,!(t)),!(f),t)\") == True\n assert candidate(expression = \"&(|(|(f,t),t),f),&(f,|(t,!(t),f),&(t,t,t,t,t,t)),!(|(t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t))\") == False\n assert candidate(expression = \"!(&(t,!(f),&(t,t),|(t,f),&(t,!(t),&(f,f))))\") == True\n assert candidate(expression = \"!(&(|(f,f),&(t,t),&(t,f)),|(t,!(t),&(t,f)),&(t,t))\") == True\n assert candidate(expression = \"!(&(|(|(|(|(|(f),t),f),t),&(t,f,t),!(f),|(t,f)),&(f,t,t,f),!(t))\") == False\n assert candidate(expression = \"|(&(t,f),&(t,t,t),!(f),&(f,!(t)))\") == True\n assert candidate(expression = \"!(!(!(!(!(t)))))\") == False\n assert candidate(expression = \"&(|(t,f),|(f,t),&(t,t),|(t,t),&(t,f),|(f,t),!(t),!(f),&(t,|(t,t)),|(t,&(t,f)),&(f,|(t,f)),|(f,|(t,f)))\") == False\n assert candidate(expression = \"&(f,|(t,|(f,!(t))))\") == False\n assert candidate(expression = \"|(|(|(|(|(f),f),t),&(t,f,t),!(f),|(t,f)),&(f,t,t,f))\") == True\n assert candidate(expression = \"!(&(&(t,t),|(f,f),&(f,t)))\") == True\n assert candidate(expression = \"!(&(|(&(t,f),f),&(t,|(t,f))),|(t,!(f),t))\") == True\n assert candidate(expression = \"!(&(|(&(t,f),t),&(f,|(t,f))),|(f,!(t)))\") == True\n assert candidate(expression = \"&(f,&(|(f,f,t),!(t),|(f,f,f)),|(f,&(t,|(f,t),&(f,f)),!(f)),!(&(|(f,f,f,t),!(t),|(t,t,t)),|(f,&(t,|(f,t),&(f,f)),!(f))))\") == False\n assert candidate(expression = \"|(&(f,t,f),|(t,f,t),&(t,t,t,t,t))\") == True\n assert candidate(expression = \"|(|(|(t,f),f),&(|(t,t),&(f,t))),!(t)\") == True\n assert candidate(expression = \"!(|(t,!(t),&(t,!(f))))\") == False\n assert candidate(expression = \"!(|(&(t,!(t)),&(f,!(f)),&(t,t),!(f)))\") == False\n", "comparison": "exact"}, "public_tests": ["\"&(|(f))\"", "\"|(f,f,f,t)\"", "\"!(&(f,t))\""], "hints": ["Write a function \"parse\" which calls helper functions \"parse_or\", \"parse_and\", \"parse_not\"."], "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().parseBoolExpr", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:40+00:00", "tests_total": 130, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "recursion"]}, "language": "python", "interface": {"raw_signature": "def parseBoolExpr(self, expression: str) -> bool:", "container": "Solution", "callable": "parseBoolExpr", "parameters": [{"name": "expression", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1108, "task_id": "defanging-an-ip-address", "difficulty": "Easy", "problem_description": "Given a valid (IPv4) IP address, return a defanged version of that IP address.\n\nA defanged IP address replaces every period \".\" with \"[.]\".\n\nExample 1:\n\nInput: address = \"1.1.1.1\"\nOutput: \"1[.]1[.]1[.]1\"\n\nExample 2:\n\nInput: address = \"255.100.50.0\"\nOutput: \"255[.]100[.]50[.]0\"\n\nConstraints:\n\n- The given address is a valid IPv4 address.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(address = \"255.100.50.0\") == \"255[.]100[.]50[.]0\"\n assert candidate(address = \"255.255.255.255\") == \"255[.]255[.]255[.]255\"\n assert candidate(address = \"192.168.1.1\") == \"192[.]168[.]1[.]1\"\n assert candidate(address = \"0.0.0.0\") == \"0[.]0[.]0[.]0\"\n assert candidate(address = \"1.1.1.1\") == \"1[.]1[.]1[.]1\"\n assert candidate(address = \"198.18.0.0\") == \"198[.]18[.]0[.]0\"\n assert candidate(address = \"010.020.030.040\") == \"010[.]020[.]030[.]040\"\n assert candidate(address = \"13.37.13.37\") == \"13[.]37[.]13[.]37\"\n assert candidate(address = \"198.18.0.1\") == \"198[.]18[.]0[.]1\"\n assert candidate(address = \"224.0.0.251\") == \"224[.]0[.]0[.]251\"\n assert candidate(address = \"10.0.0.255\") == \"10[.]0[.]0[.]255\"\n assert candidate(address = \"224.0.0.224\") == \"224[.]0[.]0[.]224\"\n assert candidate(address = \"198.51.100.0\") == \"198[.]51[.]100[.]0\"\n assert candidate(address = \"254.254.254.254\") == \"254[.]254[.]254[.]254\"\n assert candidate(address = \"0.255.0.255\") == \"0[.]255[.]0[.]255\"\n assert candidate(address = \"169.254.1.2\") == \"169[.]254[.]1[.]2\"\n assert candidate(address = \"192.168.100.100\") == \"192[.]168[.]100[.]100\"\n assert candidate(address = \"169.254.169.254\") == \"169[.]254[.]169[.]254\"\n assert candidate(address = \"127.0.0.1\") == \"127[.]0[.]0[.]1\"\n assert candidate(address = \"172.31.255.255\") == \"172[.]31[.]255[.]255\"\n assert candidate(address = \"198.51.100.200\") == \"198[.]51[.]100[.]200\"\n assert candidate(address = \"169.254.0.1\") == \"169[.]254[.]0[.]1\"\n assert candidate(address = \"203.0.113.0\") == \"203[.]0[.]113[.]0\"\n assert candidate(address = \"001.002.003.004\") == \"001[.]002[.]003[.]004\"\n assert candidate(address = \"172.16.0.1\") == \"172[.]16[.]0[.]1\"\n assert candidate(address = \"111.222.333.444\") == \"111[.]222[.]333[.]444\"\n assert candidate(address = \"169.254.0.0\") == \"169[.]254[.]0[.]0\"\n assert candidate(address = \"10.10.10.10\") == \"10[.]10[.]10[.]10\"\n assert candidate(address = \"10.0.0.1\") == \"10[.]0[.]0[.]1\"\n assert candidate(address = \"224.0.0.1\") == \"224[.]0[.]0[.]1\"\n assert candidate(address = \"128.101.101.101\") == \"128[.]101[.]101[.]101\"\n assert candidate(address = \"100.100.100.100\") == \"100[.]100[.]100[.]100\"\n assert candidate(address = \"123.45.67.89\") == \"123[.]45[.]67[.]89\"\n assert candidate(address = \"114.114.114.114\") == \"114[.]114[.]114[.]114\"\n assert candidate(address = \"203.0.113.255\") == \"203[.]0[.]113[.]255\"\n assert candidate(address = \"99.99.99.99\") == \"99[.]99[.]99[.]99\"\n assert candidate(address = \"123.456.789.012\") == \"123[.]456[.]789[.]012\"\n assert candidate(address = \"169.254.100.50\") == \"169[.]254[.]100[.]50\"\n assert candidate(address = \"9.9.9.9\") == \"9[.]9[.]9[.]9\"\n assert candidate(address = \"240.240.240.240\") == \"240[.]240[.]240[.]240\"\n assert candidate(address = \"8.8.8.8\") == \"8[.]8[.]8[.]8\"\n assert candidate(address = \"1.12.123.123\") == \"1[.]12[.]123[.]123\"\n assert candidate(address = \"255.255.255.0\") == \"255[.]255[.]255[.]0\"\n assert candidate(address = \"239.255.255.250\") == \"239[.]255[.]255[.]250\"\n assert candidate(address = \"198.19.255.255\") == \"198[.]19[.]255[.]255\"\n assert candidate(address = \"100.200.050.025\") == \"100[.]200[.]050[.]025\"\n assert candidate(address = \"139.130.4.5\") == \"139[.]130[.]4[.]5\"\n assert candidate(address = \"208.67.222.222\") == \"208[.]67[.]222[.]222\"\n", "comparison": "exact"}, "public_tests": ["\"1.1.1.1\"", "\"255.100.50.0\""], "hints": [], "metadata": {"canonical_parameter_names": ["address"], "leetcode_dataset_entry_point": "Solution().defangIPaddr", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:42+00:00", "tests_total": 48, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def defangIPaddr(self, address: str) -> str:", "container": "Solution", "callable": "defangIPaddr", "parameters": [{"name": "address", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1109, "task_id": "corporate-flight-bookings", "difficulty": "Medium", "problem_description": "There are n flights that are labeled from 1 to n.\n\nYou are given an array of flight bookings bookings, where bookings[i] = [first_i, last_i, seats_i] represents a booking for flights first_i through last_i (inclusive) with seats_i seats reserved for each flight in the range.\n\nReturn an array answer of length n, where answer[i] is the total number of seats reserved for flight i.\n\nExample 1:\n\nInput: bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5\nOutput: [10,55,45,25,25]\nExplanation:\nFlight labels: 1 2 3 4 5\nBooking 1 reserved: 10 10\nBooking 2 reserved: 20 20\nBooking 3 reserved: 25 25 25 25\nTotal seats: 10 55 45 25 25\nHence, answer = [10,55,45,25,25]\n\nExample 2:\n\nInput: bookings = [[1,2,10],[2,2,15]], n = 2\nOutput: [10,25]\nExplanation:\nFlight labels: 1 2\nBooking 1 reserved: 10 10\nBooking 2 reserved: 15\nTotal seats: 10 25\nHence, answer = [10,25]\n\nConstraints:\n\n- 1 <= n <= 2 * 10^4\n- 1 <= bookings.length <= 2 * 10^4\n- bookings[i].length == 3\n- 1 <= first_i <= last_i <= n\n- 1 <= seats_i <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bookings = [[1, 2, 100], [2, 5, 50], [3, 4, 20]],n = 5) == [100, 150, 70, 70, 50]\n assert candidate(bookings = [[1, 1, 5], [1, 2, 7], [1, 3, 9]],n = 3) == [21, 16, 9]\n assert candidate(bookings = [[1, 4, 5], [4, 5, 6], [2, 5, 3]],n = 5) == [5, 8, 8, 14, 9]\n assert candidate(bookings = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],n = 5) == [1, 2, 3, 4, 5]\n assert candidate(bookings = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50]],n = 5) == [10, 20, 30, 40, 50]\n assert candidate(bookings = [[1, 5, 1], [1, 5, 1], [1, 5, 1], [1, 5, 1], [1, 5, 1]],n = 5) == [5, 5, 5, 5, 5]\n assert candidate(bookings = [[1, 5, 3], [2, 4, 2], [3, 3, 1]],n = 5) == [3, 5, 6, 5, 3]\n assert candidate(bookings = [[1, 1, 5], [2, 2, 7], [3, 3, 9]],n = 3) == [5, 7, 9]\n assert candidate(bookings = [[1, 5, 5], [2, 4, 10], [3, 3, 15]],n = 5) == [5, 15, 30, 15, 5]\n assert candidate(bookings = [[1, 2, 10], [2, 2, 15]],n = 2) == [10, 25]\n assert candidate(bookings = [[1, 5, 1], [2, 4, 2], [3, 3, 3]],n = 5) == [1, 3, 6, 3, 1]\n assert candidate(bookings = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 5, 500]],n = 5) == [100, 300, 500, 700, 900]\n assert candidate(bookings = [[1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 5, 100]],n = 5) == [100, 200, 200, 200, 200]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [2, 5, 25]],n = 5) == [10, 55, 45, 25, 25]\n assert candidate(bookings = [[1, 5, 1], [2, 5, 2], [3, 5, 3], [4, 5, 4], [5, 5, 5]],n = 5) == [1, 3, 6, 10, 15]\n assert candidate(bookings = [[1, 2, 1], [1, 2, 1], [1, 2, 1]],n = 2) == [3, 3]\n assert candidate(bookings = [[1, 2, 10000], [2, 3, 9000], [3, 4, 8000], [4, 5, 7000], [5, 5, 6000], [1, 3, 5000], [2, 4, 4000], [3, 5, 3000], [4, 5, 2000], [5, 5, 1000]],n = 5) == [15000, 28000, 29000, 24000, 19000]\n assert candidate(bookings = [[1, 2, 10], [3, 4, 20], [1, 4, 5], [2, 5, 15], [1, 3, 25]],n = 5) == [40, 55, 65, 40, 15]\n assert candidate(bookings = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 5, 40], [1, 5, 50]],n = 5) == [60, 80, 110, 140, 120]\n assert candidate(bookings = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 10, 70], [8, 10, 80]],n = 10) == [10, 30, 60, 100, 150, 200, 250, 300, 260, 210]\n assert candidate(bookings = [[1, 5, 1], [2, 4, 2], [3, 3, 3], [4, 5, 4], [5, 5, 5]],n = 5) == [1, 3, 6, 7, 10]\n assert candidate(bookings = [[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [6, 6, 60]],n = 10) == [10, 30, 60, 100, 150, 210, 100, 60, 30, 10]\n assert candidate(bookings = [[1, 2, 5], [2, 3, 10], [3, 4, 15], [4, 5, 20], [5, 5, 25], [1, 5, 1]],n = 5) == [6, 16, 26, 36, 46]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [1, 5, 5], [3, 5, 15], [2, 4, 25]],n = 5) == [15, 60, 65, 45, 20]\n assert candidate(bookings = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 5, 1], [1, 5, 1], [2, 5, 1], [3, 5, 1], [4, 5, 1], [5, 5, 1]],n = 5) == [2, 4, 5, 6, 7]\n assert candidate(bookings = [[1, 2, 1000], [2, 5, 500], [3, 4, 300], [1, 4, 200], [2, 5, 100]],n = 5) == [1200, 1800, 1100, 1100, 600]\n assert candidate(bookings = [[1, 10, 100], [2, 9, 200], [3, 8, 300], [4, 7, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900]],n = 10) == [100, 300, 600, 1000, 1500, 2100, 2300, 2100, 2000, 1000]\n assert candidate(bookings = [[1, 3, 100], [1, 4, 200], [1, 5, 300], [1, 6, 400], [1, 7, 500], [1, 8, 600], [1, 9, 700], [1, 10, 800]],n = 10) == [3600, 3600, 3600, 3500, 3300, 3000, 2600, 2100, 1500, 800]\n assert candidate(bookings = [[1, 5, 10], [2, 4, 20], [3, 3, 30], [4, 5, 40], [5, 5, 50]],n = 5) == [10, 30, 60, 70, 100]\n assert candidate(bookings = [[1, 3, 10], [1, 4, 20], [1, 5, 30], [1, 6, 40], [1, 7, 50], [2, 3, 10], [2, 4, 20], [2, 5, 30], [2, 6, 40], [2, 7, 50]],n = 7) == [150, 300, 300, 280, 240, 180, 100]\n assert candidate(bookings = [[1, 5, 10], [1, 5, 20], [1, 5, 30], [1, 5, 40], [1, 5, 50]],n = 5) == [150, 150, 150, 150, 150]\n assert candidate(bookings = [[1, 5, 1000], [1, 2, 2000], [3, 5, 3000], [2, 3, 4000], [4, 5, 5000]],n = 5) == [3000, 7000, 8000, 9000, 9000]\n assert candidate(bookings = [[1, 2, 10], [1, 5, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50]],n = 5) == [30, 60, 90, 110, 70]\n assert candidate(bookings = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [1, 5, 1]],n = 5) == [2, 3, 4, 5, 6]\n assert candidate(bookings = [[1, 3, 1000], [2, 4, 2000], [3, 5, 3000], [1, 5, 100], [2, 5, 200]],n = 5) == [1100, 3300, 6300, 5300, 3300]\n assert candidate(bookings = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 5, 5000]],n = 5) == [1000, 3000, 5000, 7000, 9000]\n assert candidate(bookings = [[1, 2, 100], [2, 5, 50], [3, 4, 200], [1, 5, 10]],n = 5) == [110, 160, 260, 260, 60]\n assert candidate(bookings = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 5, 40]],n = 5) == [10, 30, 60, 90, 70]\n assert candidate(bookings = [[1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 5, 5]],n = 5) == [5, 10, 10, 10, 10]\n assert candidate(bookings = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]],n = 5) == [55, 55, 55, 55, 55]\n assert candidate(bookings = [[1, 2, 10], [1, 2, 20], [1, 2, 30], [1, 2, 40], [1, 2, 50]],n = 2) == [150, 150]\n assert candidate(bookings = [[1, 5, 100], [1, 5, 200], [1, 5, 300], [1, 5, 400], [1, 5, 500]],n = 5) == [1500, 1500, 1500, 1500, 1500]\n assert candidate(bookings = [[1, 10, 100], [10, 10, 100], [1, 9, 200], [2, 8, 200], [2, 9, 300], [3, 8, 300], [3, 7, 400], [4, 7, 400], [4, 6, 500], [5, 6, 500], [5, 5, 600]],n = 10) == [300, 800, 1500, 2400, 3500, 2900, 1900, 1100, 600, 200]\n assert candidate(bookings = [[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]],n = 10) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(bookings = [[1, 5, 1], [2, 5, 2], [3, 5, 3], [4, 5, 4], [5, 5, 5], [1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40]],n = 5) == [11, 33, 56, 80, 55]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [1, 5, 5]],n = 5) == [15, 35, 55, 75, 45]\n assert candidate(bookings = [[1, 5, 10], [2, 4, 20], [3, 3, 30], [4, 5, 40], [1, 2, 50], [2, 3, 60], [3, 4, 70], [4, 5, 80]],n = 5) == [60, 140, 190, 220, 130]\n assert candidate(bookings = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [1, 5, 1]],n = 5) == [2, 3, 3, 3, 2]\n assert candidate(bookings = [[1, 1, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [1, 5, 10]],n = 5) == [50, 40, 30, 20, 10]\n assert candidate(bookings = [[1, 2, 10], [2, 5, 20], [3, 3, 15], [4, 4, 25], [5, 5, 30], [1, 5, 5]],n = 5) == [15, 35, 40, 50, 55]\n assert candidate(bookings = [[1, 5, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50], [1, 5, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50]],n = 5) == [20, 60, 120, 200, 300]\n assert candidate(bookings = [[1, 2, 10], [2, 2, 20], [1, 5, 5], [3, 3, 30], [4, 5, 40], [1, 5, 50]],n = 5) == [65, 85, 85, 95, 95]\n assert candidate(bookings = [[1, 10, 5], [2, 9, 6], [3, 8, 7], [4, 7, 8], [5, 6, 9], [6, 6, 10], [1, 2, 1], [2, 3, 2], [3, 4, 3]],n = 10) == [6, 14, 23, 29, 35, 45, 26, 18, 11, 5]\n assert candidate(bookings = [[1, 2, 10], [2, 2, 20], [2, 3, 20], [3, 3, 30], [3, 4, 30], [4, 4, 40], [4, 5, 40], [5, 5, 50]],n = 5) == [10, 50, 80, 110, 90]\n assert candidate(bookings = [[1, 5, 10], [1, 5, 20], [1, 5, 30], [1, 5, 40], [1, 5, 50], [1, 5, 60], [1, 5, 70], [1, 5, 80], [1, 5, 90]],n = 5) == [450, 450, 450, 450, 450]\n assert candidate(bookings = [[1, 3, 5], [3, 5, 15], [5, 5, 25], [1, 4, 10]],n = 5) == [15, 15, 30, 25, 40]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [1, 5, 50]],n = 5) == [60, 80, 100, 120, 90]\n assert candidate(bookings = [[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5]],n = 100) == [1, 3, 6, 10, 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, 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, 10, 6, 3, 1]\n assert candidate(bookings = [[1, 3, 5000], [2, 4, 4000], [3, 5, 3000], [4, 5, 2000], [1, 5, 1000]],n = 5) == [6000, 10000, 13000, 10000, 6000]\n assert candidate(bookings = [[1, 2, 100], [1, 5, 20], [2, 3, 150], [3, 4, 250], [4, 5, 300], [5, 6, 350], [6, 7, 400]],n = 7) == [120, 270, 420, 570, 670, 750, 400]\n assert candidate(bookings = [[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 = 15) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(bookings = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5]],n = 5) == [15, 15, 15, 15, 15]\n assert candidate(bookings = [[1, 1, 1000], [1, 2, 2000], [1, 3, 3000], [1, 4, 4000], [1, 5, 5000]],n = 5) == [15000, 14000, 12000, 9000, 5000]\n assert candidate(bookings = [[1, 1, 1000], [1, 5, 1000], [2, 2, 2000], [2, 3, 2000], [3, 3, 3000], [3, 4, 3000], [4, 4, 4000], [4, 5, 4000], [5, 5, 5000]],n = 5) == [2000, 5000, 9000, 12000, 10000]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 5, 50], [1, 5, 100]],n = 5) == [110, 130, 150, 170, 190]\n assert candidate(bookings = [[1, 2, 10000], [2, 3, 10000], [3, 4, 10000], [4, 5, 10000], [5, 5, 10000]],n = 5) == [10000, 20000, 20000, 20000, 20000]\n assert candidate(bookings = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [1, 5, 500], [5, 5, 600]],n = 5) == [600, 800, 1000, 1200, 1500]\n assert candidate(bookings = [[1, 20, 5], [5, 15, 10], [10, 20, 15], [15, 20, 20], [20, 20, 25]],n = 20) == [5, 5, 5, 5, 15, 15, 15, 15, 15, 30, 30, 30, 30, 30, 50, 40, 40, 40, 40, 65]\n assert candidate(bookings = [[1, 5, 100], [2, 4, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [1, 5, 100], [2, 4, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500]],n = 5) == [200, 600, 1200, 1400, 1200]\n assert candidate(bookings = [[1, 2, 500], [2, 3, 1000], [3, 4, 1500], [4, 5, 2000], [5, 6, 2500], [6, 7, 3000], [7, 8, 3500]],n = 8) == [500, 1500, 2500, 3500, 4500, 5500, 6500, 3500]\n assert candidate(bookings = [[100, 2000, 100], [200, 1900, 200], [300, 1800, 300], [400, 1700, 400], [500, 1600, 500]],n = 2000) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 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(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 5, 50], [1, 5, 5]],n = 5) == [15, 35, 55, 75, 95]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40]],n = 8) == [10, 25, 35, 45, 55, 65, 75, 40]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40]],n = 5) == [20, 60, 100, 140, 80]\n assert candidate(bookings = [[1, 5, 1], [2, 5, 2], [3, 5, 3], [4, 5, 4], [5, 5, 5], [1, 5, 1], [2, 5, 2], [3, 5, 3], [4, 5, 4], [5, 5, 5]],n = 5) == [2, 6, 12, 20, 30]\n assert candidate(bookings = [[1, 2, 500], [2, 3, 1000], [3, 4, 1500], [4, 5, 2000], [5, 5, 2500]],n = 5) == [500, 1500, 2500, 3500, 4500]\n assert candidate(bookings = [[1, 3, 10], [2, 5, 20], [3, 4, 30], [4, 6, 40], [5, 7, 50]],n = 7) == [10, 30, 60, 90, 110, 90, 50]\n assert candidate(bookings = [[1, 5, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 5, 50]],n = 5) == [10, 30, 60, 80, 100]\n assert candidate(bookings = [[1, 2000, 1], [2, 1999, 2], [3, 1998, 3], [4, 1997, 4], [5, 1996, 5]],n = 2000) == [1, 3, 6, 10, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 10, 6, 3, 1]\n assert candidate(bookings = [[1, 3, 50], [2, 5, 60], [3, 4, 70], [4, 5, 80], [1, 4, 20]],n = 5) == [70, 130, 200, 230, 140]\n assert candidate(bookings = [[1, 5, 5], [1, 5, 10], [1, 5, 15], [1, 5, 20], [1, 5, 25]],n = 5) == [75, 75, 75, 75, 75]\n assert candidate(bookings = [[1, 5, 10], [2, 4, 20], [3, 3, 30]],n = 5) == [10, 30, 60, 30, 10]\n assert candidate(bookings = [[1, 2, 100], [2, 3, 200], [3, 5, 300], [4, 5, 400], [1, 3, 100], [2, 4, 200]],n = 5) == [200, 600, 800, 900, 700]\n assert candidate(bookings = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50]],n = 7) == [10, 30, 60, 90, 120, 90, 50]\n assert candidate(bookings = [[1, 2, 10], [3, 4, 20], [5, 6, 30], [7, 8, 40], [9, 10, 50]],n = 10) == [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]\n assert candidate(bookings = [[1, 5, 10], [2, 3, 20], [3, 4, 30], [1, 2, 10], [4, 5, 20]],n = 5) == [20, 40, 60, 60, 30]\n assert candidate(bookings = [[1, 5, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [1, 2, 50], [3, 5, 60]],n = 5) == [60, 80, 120, 140, 110]\n assert candidate(bookings = [[1, 1, 10000], [2, 2, 10000], [3, 3, 10000], [4, 4, 10000], [5, 5, 10000]],n = 5) == [10000, 10000, 10000, 10000, 10000]\n assert candidate(bookings = [[1, 2, 50], [2, 3, 50], [3, 4, 50], [4, 5, 50], [1, 5, 100]],n = 5) == [150, 200, 200, 200, 150]\n assert candidate(bookings = [[1, 5, 10], [2, 3, 20], [4, 5, 30], [1, 3, 40], [3, 4, 50]],n = 5) == [50, 70, 120, 90, 40]\n assert candidate(bookings = [[1, 1, 1000], [1, 1000, 1], [2, 2, 2000], [2, 999, 2], [3, 3, 3000], [3, 998, 3], [4, 4, 4000], [4, 997, 4], [5, 5, 5000], [5, 996, 5]],n = 1000) == [1001, 2003, 3006, 4010, 5015, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 10, 6, 3, 1]\n assert candidate(bookings = [[1, 1, 1000], [1, 2, 1000], [1, 3, 1000], [1, 4, 1000], [1, 5, 1000]],n = 5) == [5000, 4000, 3000, 2000, 1000]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [1, 5, 50], [2, 5, 10], [3, 4, 20]],n = 5) == [60, 90, 130, 150, 100]\n assert candidate(bookings = [[1, 3, 15], [2, 3, 20], [3, 3, 25], [1, 2, 30], [2, 5, 50]],n = 5) == [45, 115, 110, 50, 50]\n assert candidate(bookings = [[1, 5, 10], [2, 4, 20], [3, 3, 30], [4, 5, 40], [1, 2, 50]],n = 5) == [60, 80, 60, 70, 50]\n assert candidate(bookings = [[1, 2, 100], [2, 3, 150], [3, 4, 200], [4, 5, 250], [5, 5, 300], [1, 5, 50]],n = 5) == [150, 300, 400, 500, 600]\n assert candidate(bookings = [[1, 2, 100], [1, 3, 200], [1, 4, 300], [1, 5, 400], [2, 5, 500]],n = 5) == [1000, 1500, 1400, 1200, 900]\n assert candidate(bookings = [[1, 1000, 1], [1001, 2000, 2], [500, 1500, 3], [1501, 2000, 4]],n = 2000) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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]\n assert candidate(bookings = [[5, 5, 10], [4, 5, 20], [3, 5, 30], [2, 5, 40], [1, 5, 50]],n = 5) == [50, 90, 120, 140, 150]\n assert candidate(bookings = [[1, 1, 1000], [1, 2, 1000], [1, 3, 1000], [1, 4, 1000], [1, 5, 1000], [1, 6, 1000], [1, 7, 1000], [1, 8, 1000], [1, 9, 1000], [1, 10, 1000]],n = 10) == [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]\n assert candidate(bookings = [[1, 2, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50], [1, 2, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50]],n = 5) == [20, 60, 100, 180, 280]\n assert candidate(bookings = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 5, 50], [1, 3, 10], [2, 4, 20], [3, 5, 30]],n = 5) == [20, 60, 110, 120, 120]\n assert candidate(bookings = [[1, 5, 10], [1, 5, 20], [1, 5, 30], [1, 5, 40], [1, 5, 50], [1, 5, 60], [1, 5, 70], [1, 5, 80], [1, 5, 90], [1, 5, 100]],n = 5) == [550, 550, 550, 550, 550]\n assert candidate(bookings = [[1, 2, 10], [2, 5, 20], [5, 5, 30], [1, 4, 40], [3, 4, 50], [2, 3, 60]],n = 5) == [50, 130, 170, 110, 50]\n assert candidate(bookings = [[1, 2, 5], [1, 5, 15], [2, 3, 10], [3, 5, 20], [1, 4, 25]],n = 5) == [45, 55, 70, 60, 35]\n", "comparison": "exact"}, "public_tests": ["[[1,2,10],[2,3,20],[2,5,25]]\n5", "[[1,2,10],[2,2,15]]\n2"], "hints": [], "metadata": {"canonical_parameter_names": ["bookings", "n"], "leetcode_dataset_entry_point": "Solution().corpFlightBookings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:45+00:00", "tests_total": 109, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def corpFlightBookings(self, bookings: list[list[int]], n: int) -> list[int]:", "container": "Solution", "callable": "corpFlightBookings", "parameters": [{"name": "bookings", "type": "list[list[int]]"}, {"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1111, "task_id": "maximum-nesting-depth-of-two-valid-parentheses-strings", "difficulty": "Medium", "problem_description": "A string is a valid parentheses string (denoted VPS) if and only if it consists of \"(\" and \")\" characters only, and:\n\n- It is the empty string, or\n- It can be written as AB (A concatenated with B), where A and B are VPS's, or\n- It can be written as (A), where A is a VPS.\n\nWe can similarly define the nesting depth depth(S) of any VPS S as follows:\n\n- depth(\"\") = 0\n- depth(A + B) = max(depth(A), depth(B)), where A and B are VPS's\n- depth(\"(\" + A + \")\") = 1 + depth(A), where A is a VPS.\n\nFor example, \"\", \"()()\", and \"()(()())\" are VPS's (with nesting depths 0, 1, and 2), and \")(\" and \"(()\" are not VPS's.\n\nGiven a VPS seq, split it into two disjoint subsequences A and B, such that A and B are VPS's (and A.length + B.length = seq.length). The subsequences may not necessarily be contiguous.\n\nFor example, for the sequence 123456789, one possible split is:\n\n-\nA = {1, 3, 5, 7, 9},\n-\nB = {2, 4, 6, 8}.\n\nThis corresponds to the output [0, 1, 0, 1, 0, 1, 0, 1, 0] where 0 indicates membership in A and 1 indicates membership in B.\n\nNow choose any such A and B such that max(depth(A), depth(B)) is the minimum possible value.\n\nReturn an answer array (of length seq.length) that encodes such a choice of A and B: answer[i] = 0 if seq[i] is part of A, else answer[i] = 1. Note that even though multiple answers may exist, you may return any of them.\n\nExample 1:\n\nInput: seq = \"(()())\"\nOutput: [0,1,1,1,1,0]\n\nExample 2:\n\nInput: seq = \"()(())()\"\nOutput: [0,0,0,1,1,0,1,1]\n\nConstraints:\n\n- 1 <= seq.size <= 10000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seq = \"()\") == [0, 0]\n assert candidate(seq = \"(()())\") == [0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"(()(()(())))\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((())())()\") == [0, 1, 0, 0, 1, 1, 1, 0, 0, 0]\n assert candidate(seq = \"\") == []\n assert candidate(seq = \"((()))\") == [0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(())(())\") == [0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(()(()))\") == [0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()())(())\") == [0, 1, 1, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(())()()\") == [0, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(seq = \"(()(()(()())))\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"()(())()\") == [0, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(seq = \"((())())\") == [0, 1, 0, 0, 1, 1, 1, 0]\n assert candidate(seq = \"(((())))\") == [0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()()()\") == [0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"((((()))))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((()))((()))((()))\") == [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()))()((()))(())\") == [0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(())(())(())\") == [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(()(()())(()(()())))\") == [0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(()(()((()))()))\") == [0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()(()(()))))\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((()(())))\") == [0, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((()()(()())))\") == [0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((()()()())(()))\") == [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((((()())))((())))\") == [0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()(()(()(())))()\") == [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0]\n assert candidate(seq = \"(((()())(()())))((()))\") == [0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()()(()(())))\") == [0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(((()()())))\") == [0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()((()))(()())\") == [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"((()()()()()))\") == [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]\n assert candidate(seq = \"()((()))(())\") == [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(()(((()(())))))\") == [0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0]\n assert candidate(seq = \"(((()()())))((()))\") == [0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()())(()))\") == [0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(((())))()(()())\") == [0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"()(((())))(())()\") == [0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(seq = \"()((()(()(()))))()\") == [0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0]\n assert candidate(seq = \"()(())()(())()(())\") == [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(seq = \"((((()))))((((()))))((((()))))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"()()()(((())))()()()(((())))\") == [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((()()))((()()))\") == [0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0]\n assert candidate(seq = \"((((()))))(((())))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(()(()))()((()))()\") == [0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0]\n assert candidate(seq = \"(((())))(((())))\") == [0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(()(()(()))(()))\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()())(())(())(())\") == [0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"()(())()((()))()(())\") == [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(seq = \"()()()()()()()()()()()()()()()\") == [0, 0, 0, 0, 0, 0, 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(seq = \"((())(()(())))\") == [0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((((())))(()))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()()()))\") == [0, 1, 0, 0, 0, 0, 0, 0, 1, 0]\n assert candidate(seq = \"(((()(()))))\") == [0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"(()(())((())))\") == [0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(()(()(()())(())))()()\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0]\n assert candidate(seq = \"(((((())))))\") == [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((()))(())(()(()))\") == [0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()()())((()))\") == [0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()((()))(())((()))\") == [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()()(())(())()\") == [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0]\n assert candidate(seq = \"()((()())(()))\") == [0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()()()()))((()()()()))\") == [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()))((()))\") == [0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()()()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"()()()()()(())\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(())(())(())(())\") == [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(()(()())((())))\") == [0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()((()))()(())(((())))\") == [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((())(()))((()()))\") == [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()))(()(()))(()(()))\") == [0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((((((()))))))\") == [0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(seq = \"()()()()()()()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"()(((())))()\") == [0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0]\n assert candidate(seq = \"(()())(())((()))\") == [0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(((()))(()(())))\") == [0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((((()))))(())(()(()))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()(()))(()(())))\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(((()())(())))\") == [0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((()(())))((()(())))\") == [0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()(()(()))(()(()))\") == [0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()((((()))))()\") == [0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0]\n assert candidate(seq = \"((())())((()))\") == [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((((()(())))))\") == [0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((((())))())(()())\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"(()())(()())\") == [0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"(()(()))()()\") == [0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0]\n assert candidate(seq = \"((())(()(()(()))))\") == [0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"(((())))(()(()))\") == [0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()()()()()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"(()())()((()))\") == [0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(((())(())((()))))\") == [0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((((()))))(())((()))((()))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(((())))((()))\") == [0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()((()))()((()))()((()))\") == [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()())())\") == [0, 1, 0, 0, 0, 0, 1, 1, 1, 0]\n assert candidate(seq = \"(()((()))(())())\") == [0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0]\n assert candidate(seq = \"()()()()()()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"()()(())()()(())()()\") == [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(seq = \"((())())(())\") == [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"((()())(()()))(())\") == [0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"()(()(()))()(()(()))\") == [0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()(()(()(()(())))))())\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0]\n assert candidate(seq = \"()()(()())()()\") == [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(seq = \"(())((()))(())((()))\") == [0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()(()())(()())\") == [0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"((((()))((())))\") == [0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1]\n assert candidate(seq = \"(((())))()(())()(())\") == [0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(seq = \"()((()())())\") == [0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0]\n assert candidate(seq = \"((((()))))((()))\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()()()((()))()(())\") == [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(()())((()))(()(()))\") == [0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()(()(()))))\") == [0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"(()((()))())(())\") == [0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"()(((())))()(((())))\") == [0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"()()()()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"()()((()))\") == [0, 0, 0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((())())((())())\") == [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0]\n assert candidate(seq = \"((((()))))(())\") == [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"((((((((()))))))))))\") == [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((()))((()))((()))((()))\") == [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()(((()))))(()(((()))))\") == [0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"(((()(())))(()(())))\") == [0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((()(()(()))))((()(()(()))))\") == [0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"()()(())(())(())\") == [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"((()(()())))\") == [0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((()))(()(()))((()))\") == [0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()))(())()(()(()))\") == [0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()))((())())\") == [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0]\n assert candidate(seq = \"()(()(()(()(()))))()\") == [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0]\n assert candidate(seq = \"((((()()()))))((()))\") == [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()(()))(()(()))\") == [0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()((())))\") == [0, 1, 1, 1, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"(((()))())()((()))\") == [0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"((()))()(())\") == [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0]\n assert candidate(seq = \"(((())))((((()))))\") == [0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((())()(()))\") == [0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()())(()())(()())(()())\") == [0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"(((((())))))(((((())))))\") == [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0]\n assert candidate(seq = \"((()))((()))\") == [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"()()((()))()()((()))\") == [0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0]\n assert candidate(seq = \"(()())(()())(()())\") == [0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"()()()()()\") == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(seq = \"(())(())(())(())(())\") == [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(seq = \"()((()))()((()))\") == [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0]\n", "comparison": "exact"}, "public_tests": ["\"(()())\"", "\"()(())()\""], "hints": [], "metadata": {"canonical_parameter_names": ["seq"], "leetcode_dataset_entry_point": "Solution().maxDepthAfterSplit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:47+00:00", "tests_total": 146, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["string", "stack", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def maxDepthAfterSplit(self, seq: str) -> list[int]:", "container": "Solution", "callable": "maxDepthAfterSplit", "parameters": [{"name": "seq", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1122, "task_id": "relative-sort-array", "difficulty": "Easy", "problem_description": "Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.\n\nSort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that do not appear in arr2 should be placed at the end of arr1 in ascending order.\n\nExample 1:\n\nInput: arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6]\nOutput: [2,2,2,1,4,3,3,9,6,7,19]\n\nExample 2:\n\nInput: arr1 = [28,6,22,8,44,17], arr2 = [22,28,8,6]\nOutput: [22,28,8,6,17,44]\n\nConstraints:\n\n- 1 <= arr1.length, arr2.length <= 1000\n- 0 <= arr1[i], arr2[i] <= 1000\n- All the elements of arr2 are distinct.\n- Each arr2[i] is in arr1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [28, 6, 22, 8, 44, 17],arr2 = [22, 28, 8, 6]) == [22, 28, 8, 6, 17, 44]\n assert candidate(arr1 = [1, 2, 3],arr2 = [1, 2, 3, 4, 5]) == [1, 2, 3]\n assert candidate(arr1 = [10, 9, 8, 7, 6],arr2 = [10, 9, 8, 7, 6]) == [10, 9, 8, 7, 6]\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [0, 2, 4, 6, 8]) == [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(arr1 = [3, 1, 2],arr2 = [3, 1]) == [3, 1, 2]\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]\n assert candidate(arr1 = [2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19],arr2 = [2, 1, 4, 3, 9, 6]) == [2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19]\n assert candidate(arr1 = [10, 10, 20, 20, 30, 30],arr2 = [10, 20]) == [10, 10, 20, 20, 30, 30]\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [3, 4, 5]) == [3, 4, 5, 1, 2]\n assert candidate(arr1 = [5, 3, 1, 2, 4],arr2 = [1, 2, 3]) == [1, 2, 3, 4, 5]\n assert candidate(arr1 = [5, 5, 5, 5, 5],arr2 = [5]) == [5, 5, 5, 5, 5]\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [3, 2, 1]) == [3, 2, 1, 4, 5]\n assert candidate(arr1 = [9, 8, 7, 6, 5],arr2 = [5, 6, 7, 8, 9]) == [5, 6, 7, 8, 9]\n assert candidate(arr1 = [7, 8, 9],arr2 = [9, 8, 7]) == [9, 8, 7]\n assert candidate(arr1 = [1000, 1000, 1000],arr2 = [1000]) == [1000, 1000, 1000]\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [2, 4]) == [2, 4, 1, 3, 5]\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [1]) == [1, 1, 1, 1]\n assert candidate(arr1 = [5, 3, 1, 2, 4],arr2 = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [30, 10, 20]) == [30, 10, 20, 40, 50]\n assert candidate(arr1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0]) == [1000, 1000, 900, 900, 800, 800, 700, 700, 600, 600, 500, 500, 400, 400, 300, 300, 200, 200, 100, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [100, 300, 500, 700, 900]) == [100, 300, 500, 700, 900, 200, 400, 600, 800, 1000]\n assert candidate(arr1 = [5, 3, 1, 2, 4, 3, 2, 5, 1, 2, 4, 3, 5],arr2 = [3, 2, 5]) == [3, 3, 3, 2, 2, 2, 5, 5, 5, 1, 1, 4, 4]\n assert candidate(arr1 = [50, 40, 30, 20, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50],arr2 = [50, 40, 30, 20, 10]) == [50, 50, 40, 40, 30, 30, 20, 20, 10, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(arr1 = [123, 456, 789, 123, 456, 789, 123, 456, 789],arr2 = [123, 456]) == [123, 123, 123, 456, 456, 456, 789, 789, 789]\n assert candidate(arr1 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],arr2 = [1, 3, 5]) == [1, 1, 1, 3, 3, 3, 5, 5, 5, 2, 2, 2, 4, 4, 4]\n assert candidate(arr1 = [111, 222, 333, 444, 555, 666, 777, 888, 999, 111, 222, 333, 444],arr2 = [111, 333, 555, 777, 999]) == [111, 111, 333, 333, 555, 777, 999, 222, 222, 444, 444, 666, 888]\n assert candidate(arr1 = [42, 78, 10, 42, 78, 10, 10, 42, 10, 78, 42, 10, 42],arr2 = [42, 10, 78]) == [42, 42, 42, 42, 42, 10, 10, 10, 10, 10, 78, 78, 78]\n assert candidate(arr1 = [88, 77, 66, 55, 44, 33, 22, 11],arr2 = [22, 44, 66, 88]) == [22, 44, 66, 88, 11, 33, 55, 77]\n assert candidate(arr1 = [42, 31, 56, 23, 56, 78, 23, 42, 65, 12, 56, 31],arr2 = [31, 56, 42, 78]) == [31, 31, 56, 56, 56, 42, 42, 78, 12, 23, 23, 65]\n assert candidate(arr1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],arr2 = [1, 2, 3, 4, 5]) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]\n assert candidate(arr1 = [5, 3, 2, 5, 6, 1, 4, 2, 2],arr2 = [2, 5, 6]) == [2, 2, 2, 5, 5, 6, 1, 3, 4]\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [5, 10]) == [5, 10, 1, 2, 3, 4, 6, 7, 8, 9]\n assert candidate(arr1 = [5, 9, 3, 7, 5, 9, 2, 8, 4, 1],arr2 = [9, 3, 5]) == [9, 9, 3, 5, 5, 1, 2, 4, 7, 8]\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [100, 90, 80, 70, 60]) == [100, 90, 80, 70, 60, 10, 20, 30, 40, 50]\n assert candidate(arr1 = [15, 22, 13, 15, 28, 15, 22, 13, 30, 45, 50],arr2 = [22, 15, 13]) == [22, 22, 15, 15, 15, 13, 13, 28, 30, 45, 50]\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],arr2 = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(arr1 = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 0, 100, 200, 300],arr2 = [300, 200, 100]) == [300, 200, 100, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3]\n assert candidate(arr1 = [28, 6, 22, 8, 44, 17, 17, 28, 6, 22, 8, 44],arr2 = [22, 28, 8, 6, 44, 17]) == [22, 22, 28, 28, 8, 8, 6, 6, 44, 44, 17, 17]\n assert candidate(arr1 = [7, 13, 5, 8, 1, 3, 4, 5, 9, 6, 2, 7, 8, 9, 13],arr2 = [13, 7, 5, 9]) == [13, 13, 7, 7, 5, 5, 9, 9, 1, 2, 3, 4, 6, 8, 8]\n assert candidate(arr1 = [23, 11, 34, 54, 78, 90, 33, 45, 12, 67],arr2 = [12, 34, 45, 54, 78]) == [12, 34, 45, 54, 78, 11, 23, 33, 67, 90]\n assert candidate(arr1 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [2, 4, 6, 8, 10, 12, 14]) == [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(arr1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr2 = [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(arr1 = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],arr2 = [15, 14, 13, 12, 11]) == [15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(arr1 = [8, 6, 7, 5, 3, 0, 9],arr2 = [8, 6, 7, 5, 3]) == [8, 6, 7, 5, 3, 0, 9]\n assert candidate(arr1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],arr2 = [1, 3, 5]) == [1, 1, 1, 3, 3, 3, 5, 5, 5, 2, 2, 2, 4, 4, 4]\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200]) == [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]\n assert candidate(arr1 = [5, 3, 1, 2, 4, 6, 8, 7, 9],arr2 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9, 2, 4, 6, 8]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [9, 7, 5, 3, 1]) == [9, 9, 7, 7, 5, 5, 3, 3, 1, 1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(arr1 = [5, 3, 2, 6, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],arr2 = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [3, 3, 5, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 2, 4, 6, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(arr1 = [200, 100, 300, 500, 400, 200, 100],arr2 = [100, 200, 300]) == [100, 100, 200, 200, 300, 400, 500]\n assert candidate(arr1 = [200, 100, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]\n assert candidate(arr1 = [2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19],arr2 = [19, 2, 9, 4, 6, 3, 7]) == [19, 2, 2, 2, 9, 4, 6, 3, 3, 7, 1]\n assert candidate(arr1 = [5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1, 5, 3, 1],arr2 = [1, 3, 5]) == [1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(arr1 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],arr2 = [7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(arr1 = [8, 6, 7, 5, 3, 0, 9],arr2 = [6, 7, 8]) == [6, 7, 8, 0, 3, 5, 9]\n assert candidate(arr1 = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42],arr2 = [42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],arr2 = [1, 9, 17, 25, 31]) == [1, 9, 17, 25, 31, 3, 5, 7, 11, 13, 15, 19, 21, 23, 27, 29]\n assert candidate(arr1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],arr2 = [5, 4, 3, 2, 1]) == [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900],arr2 = [500, 700, 900]) == [500, 700, 900, 100, 200, 300, 400, 600, 800]\n assert candidate(arr1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],arr2 = [3, 1, 4]) == [3, 3, 3, 1, 4, 4, 4, 4, 2, 2]\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(arr1 = [42, 42, 42, 42, 42, 42],arr2 = [42]) == [42, 42, 42, 42, 42, 42]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [0, 2, 4, 6, 8]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [0, 9]) == [0, 9, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(arr1 = [3, 1, 2, 3, 4, 1, 2, 3, 5, 1, 2],arr2 = [1, 2, 3]) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 5]\n assert candidate(arr1 = [5, 3, 9, 1, 5, 3, 9, 2, 8, 1, 0, 4, 7],arr2 = [1, 3, 5, 7, 9]) == [1, 1, 3, 3, 5, 5, 7, 9, 9, 0, 2, 4, 8]\n assert candidate(arr1 = [99, 88, 77, 66, 55, 44, 33, 22, 11, 0],arr2 = [11, 22, 33, 44, 55]) == [11, 22, 33, 44, 55, 0, 66, 77, 88, 99]\n assert candidate(arr1 = [7, 5, 3, 9, 1, 2, 8, 6, 4],arr2 = [4, 5, 6, 7, 8]) == [4, 5, 6, 7, 8, 1, 2, 3, 9]\n assert candidate(arr1 = [88, 99, 77, 66, 55, 44, 33, 22, 11, 88, 99, 77, 66, 55, 44],arr2 = [99, 77, 55, 33, 11]) == [99, 99, 77, 77, 55, 55, 33, 11, 22, 44, 44, 66, 66, 88, 88]\n assert candidate(arr1 = [5, 3, 1, 2, 4, 3, 2, 1, 0],arr2 = [1, 2, 3, 4, 5]) == [1, 1, 2, 2, 3, 3, 4, 5, 0]\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr1 = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],arr2 = [1, 2]) == [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(arr1 = [5, 3, 1, 2, 4, 3, 2, 1, 5, 4, 3, 2, 1],arr2 = [1, 2, 3]) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5]\n assert candidate(arr1 = [50, 25, 75, 100, 0, 50, 25, 75, 100],arr2 = [25, 50, 75]) == [25, 25, 50, 50, 75, 75, 0, 100, 100]\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],arr2 = [2, 4]) == [2, 2, 4, 4, 4, 4, 1, 3, 3, 3, 5, 5, 5, 5, 5]\n assert candidate(arr1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],arr2 = [1, 2, 3, 4, 5]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(arr1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],arr2 = [1, 3, 5]) == [1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 5, 2, 2, 2, 2, 4, 4, 4, 4]\n assert candidate(arr1 = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],arr2 = [10, 8, 6, 4, 2]) == [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]\n assert candidate(arr1 = [500, 400, 300, 200, 100, 50, 20, 10, 5, 2, 1],arr2 = [500, 400, 300]) == [500, 400, 300, 1, 2, 5, 10, 20, 50, 100, 200]\n assert candidate(arr1 = [10, 5, 14, 10, 32, 10, 5, 15, 20, 32],arr2 = [10, 5, 32]) == [10, 10, 10, 5, 5, 32, 32, 14, 15, 20]\n assert candidate(arr1 = [200, 150, 100, 50, 0, 50, 100, 150, 200, 250, 300, 350],arr2 = [250, 300, 350]) == [250, 300, 350, 0, 50, 50, 100, 100, 150, 150, 200, 200]\n assert candidate(arr1 = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],arr2 = [990, 992, 994, 996]) == [990, 992, 994, 996, 991, 993, 995, 997, 998, 999]\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [1000, 900, 800, 700, 600]) == [1000, 900, 800, 700, 600, 100, 200, 300, 400, 500]\n assert candidate(arr1 = [25, 36, 45, 78, 25, 36, 45, 78, 25, 36, 45, 78],arr2 = [25, 36]) == [25, 25, 25, 36, 36, 36, 45, 45, 45, 78, 78, 78]\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],arr2 = [90, 92, 94, 96, 98]) == [90, 92, 94, 96, 98, 91, 93, 95, 97, 99]\n assert candidate(arr1 = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1],arr2 = [1, 2, 3]) == [1, 1, 1, 1, 2, 2, 2, 3, 3, 3]\n assert candidate(arr1 = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10],arr2 = [10, 30, 50]) == [10, 10, 10, 30, 30, 30, 50, 50, 50, 20, 20, 20, 40, 40, 40]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [9, 7, 5, 3, 1]) == [9, 7, 5, 3, 1, 0, 2, 4, 6, 8]\n assert candidate(arr1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],arr2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [3, 6, 9, 1]) == [3, 6, 9, 1, 0, 2, 4, 5, 7, 8]\n assert candidate(arr1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],arr2 = [1, 3, 5]) == [1, 1, 1, 3, 3, 3, 5, 5, 5, 2, 2, 2, 4, 4, 4]\n assert candidate(arr1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],arr2 = [4]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(arr1 = [12, 24, 36, 48, 60, 72, 84, 96, 108],arr2 = [108, 84, 60, 36, 12]) == [108, 84, 60, 36, 12, 24, 48, 72, 96]\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(arr1 = [89, 45, 67, 23, 89, 45, 67, 23, 89, 45, 67, 23],arr2 = [89, 67, 23]) == [89, 89, 89, 67, 67, 67, 23, 23, 23, 45, 45, 45]\n assert candidate(arr1 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],arr2 = [7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(arr1 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [3, 6, 9, 12, 15]) == [3, 6, 9, 12, 15, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14]\n assert candidate(arr1 = [5, 3, 1, 2, 4, 9, 7, 8, 6],arr2 = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(arr1 = [250, 150, 350, 450, 550, 650, 750, 850, 950, 100],arr2 = [100, 150, 250, 350, 450]) == [100, 150, 250, 350, 450, 550, 650, 750, 850, 950]\n assert candidate(arr1 = [200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],arr2 = [100, 200]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]\n assert candidate(arr1 = [45, 55, 55, 45, 45, 55, 55, 45, 45, 55],arr2 = [45, 55]) == [45, 45, 45, 45, 45, 55, 55, 55, 55, 55]\n assert candidate(arr1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],arr2 = [1, 4, 5]) == [1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 2, 2, 3, 3, 3]\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],arr2 = [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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900],arr2 = [900, 700, 500, 300, 100]) == [900, 700, 500, 300, 100, 200, 400, 600, 800]\n assert candidate(arr1 = [123, 456, 789, 123, 456, 789, 123, 456, 789, 123, 456, 789],arr2 = [789, 456]) == [789, 789, 789, 789, 456, 456, 456, 456, 123, 123, 123, 123]\n assert candidate(arr1 = [2, 3, 2, 1, 4, 3, 2, 4, 6, 7, 9, 2, 19, 10, 11],arr2 = [2, 1, 4, 3, 9, 6]) == [2, 2, 2, 2, 1, 4, 4, 3, 3, 9, 6, 7, 10, 11, 19]\n assert candidate(arr1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],arr2 = [2, 4, 6, 8]) == [2, 2, 4, 4, 6, 6, 8, 8, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9]\n assert candidate(arr1 = [15, 25, 35, 45, 55, 15, 25, 35, 45, 55],arr2 = [15, 25, 35]) == [15, 15, 25, 25, 35, 35, 45, 45, 55, 55]\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [10, 5, 2, 1]) == [10, 5, 2, 1, 3, 4, 6, 7, 8, 9]\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(arr1 = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 0, 100, 200, 300],arr2 = [1, 2, 3]) == [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 0, 100, 200, 300]\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [0, 2, 4, 6, 8]) == [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [1, 5, 10, 15]) == [1, 5, 10, 15, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14]\n assert candidate(arr1 = [42, 42, 42, 100, 100, 100, 21, 21, 21],arr2 = [100, 21, 42]) == [100, 100, 100, 21, 21, 21, 42, 42, 42]\n assert candidate(arr1 = [300, 200, 100, 400, 300, 200, 100, 500, 600, 700, 800, 900],arr2 = [100, 200, 300, 400]) == [100, 100, 200, 200, 300, 300, 400, 500, 600, 700, 800, 900]\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],arr2 = [1, 5, 9, 13, 17, 21]) == [1, 5, 9, 13, 17, 21, 3, 7, 11, 15, 19, 23]\n assert candidate(arr1 = [200, 100, 300, 400, 500],arr2 = [100, 300, 500]) == [100, 300, 500, 200, 400]\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [0, 1, 2, 3, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr1 = [45, 12, 67, 45, 23, 45, 89, 67, 12, 34, 56],arr2 = [45, 12, 67]) == [45, 45, 45, 12, 12, 67, 67, 23, 34, 56, 89]\n assert candidate(arr1 = [88, 77, 66, 55, 44, 33, 22, 11, 0, 99, 11, 22, 33, 44, 55, 66, 77, 88],arr2 = [22, 44, 66, 88]) == [22, 22, 44, 44, 66, 66, 88, 88, 0, 11, 11, 33, 33, 55, 55, 77, 77, 99]\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50],arr2 = [100, 90, 80, 70, 60]) == [100, 90, 80, 70, 60, 10, 10, 20, 20, 30, 30, 40, 40, 50, 50]\n assert candidate(arr1 = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],arr2 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]\n", "comparison": "exact"}, "public_tests": ["[2,3,1,3,2,4,6,7,9,2,19]\n[2,1,4,3,9,6]", "[28,6,22,8,44,17]\n[22,28,8,6]"], "hints": ["Using a hashmap, we can map the values of arr2 to their position in arr2.", "After, we can use a custom sorting function."], "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().relativeSortArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:10:58+00:00", "tests_total": 130, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "counting-sort", "quicksort", "bubble-sort"]}, "language": "python", "interface": {"raw_signature": "def relativeSortArray(self, arr1: list[int], arr2: list[int]) -> list[int]:", "container": "Solution", "callable": "relativeSortArray", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1124, "task_id": "longest-well-performing-interval", "difficulty": "Medium", "problem_description": "We are given hours, a list of the number of hours worked per day for a given employee.\n\nA day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8.\n\nA well-performing interval is an interval of days for which the number of tiring days is strictly larger than the number of non-tiring days.\n\nReturn the length of the longest well-performing interval.\n\nExample 1:\n\nInput: hours = [9,9,6,0,6,6,9]\nOutput: 3\nExplanation: The longest well-performing interval is [9,9,6].\n\nExample 2:\n\nInput: hours = [6,6,6]\nOutput: 0\n\nConstraints:\n\n- 1 <= hours.length <= 10^4\n- 0 <= hours[i] <= 16\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hours = [9, 7, 9, 7, 9, 7, 9, 7]) == 7\n assert candidate(hours = [8, 9, 9, 10]) == 4\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9]) == 7\n assert candidate(hours = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(hours = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 9\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\n assert candidate(hours = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(hours = [16, 16, 16, 16]) == 4\n assert candidate(hours = [12, 13, 14, 15, 16, 0, 0, 0, 0, 0]) == 9\n assert candidate(hours = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 9]) == 1\n assert candidate(hours = [5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(hours = [8, 9, 9, 2, 5]) == 3\n assert candidate(hours = [12, 8, 9, 9, 9, 10, 8, 8, 9, 10, 12]) == 11\n assert candidate(hours = [10, 10, 10, 10, 10, 10, 10, 10]) == 8\n assert candidate(hours = [9, 9, 6, 0, 6, 6, 9]) == 3\n assert candidate(hours = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 15\n assert candidate(hours = [10, 10, 10, 10]) == 4\n assert candidate(hours = [6, 6, 6]) == 0\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8]) == 0\n assert candidate(hours = [7, 7, 7, 9, 9, 9]) == 5\n assert candidate(hours = [8, 9, 9, 2, 1, 0, 7]) == 3\n assert candidate(hours = [10, 8, 10, 8, 10, 8, 10, 8, 10, 8]) == 9\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 10\n assert candidate(hours = [6, 9, 6, 9, 6, 9, 6, 9]) == 7\n assert candidate(hours = [8, 9, 7, 8, 6, 4, 9, 8, 9, 8]) == 3\n assert candidate(hours = [7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(hours = [16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, 0]) == 25\n assert candidate(hours = [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]) == 27\n assert candidate(hours = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == 19\n assert candidate(hours = [9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6]) == 31\n assert candidate(hours = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 15\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 32\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 17\n assert candidate(hours = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0, 1, 2, 3, 4, 5]) == 15\n assert candidate(hours = [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, 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, 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]) == 101\n assert candidate(hours = [10, 7, 9, 6, 11, 4, 5, 12, 3, 14, 1, 2, 8, 9, 15, 0, 1, 6, 7, 10]) == 5\n assert candidate(hours = [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]) == 27\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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 48\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 19\n assert candidate(hours = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 16, 15, 14, 13, 12]) == 9\n assert candidate(hours = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 21\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9]) == 1\n assert candidate(hours = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == 15\n assert candidate(hours = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 15\n assert candidate(hours = [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]) == 15\n assert candidate(hours = [16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3]) == 17\n assert candidate(hours = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9]) == 1\n assert candidate(hours = [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]) == 27\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12]) == 20\n assert candidate(hours = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == 15\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]) == 21\n assert candidate(hours = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 33\n assert candidate(hours = [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]) == 31\n assert candidate(hours = [9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 20\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10]) == 1\n assert candidate(hours = [9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6]) == 15\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9]) == 1\n assert candidate(hours = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 19\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 31\n assert candidate(hours = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 10]) == 1\n assert candidate(hours = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 11\n assert candidate(hours = [9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 65\n assert candidate(hours = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20\n assert candidate(hours = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8]) == 15\n assert candidate(hours = [10, 1, 8, 12, 8, 9, 5, 6, 7, 10, 3, 11, 4, 8, 10]) == 3\n assert candidate(hours = [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, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 51\n assert candidate(hours = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1]) == 25\n assert candidate(hours = [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]) == 32\n assert candidate(hours = [8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 19\n assert candidate(hours = [9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6]) == 19\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4]) == 15\n assert candidate(hours = [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]) == 31\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n assert candidate(hours = [10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8, 10, 8]) == 19\n assert candidate(hours = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 16, 15, 14, 13, 12, 11]) == 11\n assert candidate(hours = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(hours = [1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8]) == 0\n assert candidate(hours = [8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 19\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n assert candidate(hours = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 19\n assert candidate(hours = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5]) == 15\n assert candidate(hours = [9, 6, 7, 8, 5, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 0, 8, 8, 9]) == 15\n assert candidate(hours = [9, 10, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 20\n assert candidate(hours = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 9\n assert candidate(hours = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(hours = [9, 7, 8, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == 17\n assert candidate(hours = [10, 5, 8, 10, 4, 6, 9, 11, 7, 3, 12, 8, 10, 9, 11, 13, 14, 6, 7, 8]) == 19\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(hours = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == 11\n assert candidate(hours = [8, 9, 9, 10, 8, 8, 8, 8, 8, 9, 9, 10, 11, 12, 7, 6, 5, 4, 3, 2]) == 15\n assert candidate(hours = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 9, 9]) == 3\n assert candidate(hours = [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, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 51\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5]) == 15\n assert candidate(hours = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == 33\n assert candidate(hours = [6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9]) == 21\n assert candidate(hours = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n", "comparison": "exact"}, "public_tests": ["[9,9,6,0,6,6,9]", "[6,6,6]"], "hints": ["Make a new array A of +1/-1s corresponding to if hours[i] is > 8 or not. The goal is to find the longest subarray with positive sum.", "Using prefix sums (PrefixSum[i+1] = A[0] + A[1] + ... + A[i]), you need to find for each j, the smallest i < j with PrefixSum[i] + 1 == PrefixSum[j]."], "metadata": {"canonical_parameter_names": ["hours"], "leetcode_dataset_entry_point": "Solution().longestWPI", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:02+00:00", "tests_total": 99, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "stack", "monotonic-stack", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def longestWPI(self, hours: list[int]) -> int:", "container": "Solution", "callable": "longestWPI", "parameters": [{"name": "hours", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1125, "task_id": "smallest-sufficient-team", "difficulty": "Hard", "problem_description": "In a project, you have a list of required skills req_skills, and a list of people. The i^th person people[i] contains a list of skills that the person has.\n\nConsider a sufficient team: a set of people such that for every required skill in req_skills, there is at least one person in the team who has that skill. We can represent these teams by the index of each person.\n\n- For example, team = [0, 1, 3] represents the people with skills people[0], people[1], and people[3].\n\nReturn any sufficient team of the smallest possible size, represented by the index of each person. You may return the answer in any order.\n\nIt is guaranteed an answer exists.\n\nExample 1:\n\nInput: req_skills = [\"java\",\"nodejs\",\"reactjs\"], people = [[\"java\"],[\"nodejs\"],[\"nodejs\",\"reactjs\"]]\nOutput: [0,2]\n\nExample 2:\n\nInput: req_skills = [\"algorithms\",\"math\",\"java\",\"reactjs\",\"csharp\",\"aws\"], people = [[\"algorithms\",\"math\",\"java\"],[\"algorithms\",\"math\",\"reactjs\"],[\"java\",\"csharp\",\"aws\"],[\"reactjs\",\"csharp\"],[\"csharp\",\"math\"],[\"aws\",\"java\"]]\nOutput: [1,2]\n\nConstraints:\n\n- 1 <= req_skills.length <= 16\n- 1 <= req_skills[i].length <= 16\n- req_skills[i] consists of lowercase English letters.\n- All the strings of req_skills are unique.\n- 1 <= people.length <= 60\n- 0 <= people[i].length <= 16\n- 1 <= people[i][j].length <= 16\n- people[i][j] consists of lowercase English letters.\n- All the strings of people[i] are unique.\n- Every skill in people[i] is a skill in req_skills.\n- It is guaranteed a sufficient team exists.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(req_skills=['python', 'sql'], people=[['python'], ['sql'], ['python', 'sql']]), [2])\n assert answers_match(candidate(req_skills=['java', 'nodejs', 'reactjs'], people=[['java'], ['nodejs'], ['nodejs', 'reactjs']]), [2, 0])\n assert answers_match(candidate(req_skills=['programming', 'testing', 'design'], people=[['programming'], ['testing'], ['design'], ['programming', 'testing'], ['testing', 'design'], ['design', 'programming']]), [4, 0])\n assert answers_match(candidate(req_skills=['a', 'b', 'c'], people=[['a', 'b'], ['b', 'c'], ['c'], ['a']]), [1, 3])\n assert answers_match(candidate(req_skills=['network', 'database'], people=[['network'], ['database'], ['network', 'database']]), [2])\n assert answers_match(candidate(req_skills=['coding', 'design', 'writing'], people=[['coding'], ['design'], ['writing'], ['coding', 'design', 'writing']]), [3])\n assert answers_match(candidate(req_skills=['coding', 'design'], people=[['coding'], ['design'], ['coding', 'design']]), [2])\n assert answers_match(candidate(req_skills=['algorithms', 'math', 'java', 'reactjs', 'csharp', 'aws'], people=[['algorithms', 'math', 'java'], ['algorithms', 'math', 'reactjs'], ['java', 'csharp', 'aws'], ['reactjs', 'csharp'], ['csharp', 'math'], ['aws', 'java']]), [2, 1])\n assert answers_match(candidate(req_skills=['python', 'data', 'ai'], people=[['python'], ['data'], ['ai'], ['python', 'data'], ['data', 'ai'], ['python', 'ai']]), [4, 0])\n assert answers_match(candidate(req_skills=['a', 'b', 'c', 'd'], people=[['a', 'b'], ['b', 'c'], ['c', 'd'], ['d', 'a'], ['a', 'b', 'c', 'd']]), [4])\n assert answers_match(candidate(req_skills=['frontend', 'backend', 'fullstack', 'uiux', 'devops'], people=[['frontend'], ['backend'], ['fullstack'], ['uiux'], ['devops'], ['frontend', 'backend'], ['fullstack', 'uiux'], ['backend', 'devops'], ['fullstack', 'devops'], ['frontend', 'uiux'], ['frontend', 'backend', 'uiux']]), [8, 10])\n assert answers_match(candidate(req_skills=['ui', 'ux', 'backend', 'frontend'], people=[['ui'], ['ux'], ['backend'], ['frontend'], ['ui', 'ux'], ['backend', 'frontend'], ['ui', 'backend'], ['ux', 'frontend'], ['ui', 'ux', 'backend', 'frontend']]), [8])\n assert answers_match(candidate(req_skills=['frontend', 'backend', 'devops', 'qa'], people=[['frontend'], ['backend'], ['devops'], ['qa'], ['frontend', 'backend'], ['backend', 'devops'], ['devops', 'qa'], ['frontend', 'qa'], ['frontend', 'backend', 'devops'], ['backend', 'devops', 'qa'], ['frontend', 'devops', 'qa'], ['frontend', 'backend', 'qa'], ['frontend', 'backend', 'devops', 'qa']]), [12])\n assert answers_match(candidate(req_skills=['mobiledev', 'webdev', 'devops', 'design', 'testing'], people=[['mobiledev'], ['webdev'], ['devops'], ['design'], ['testing'], ['mobiledev', 'webdev'], ['devops', 'design'], ['webdev', 'testing'], ['mobiledev', 'devops'], ['design', 'testing'], ['mobiledev', 'webdev', 'devops'], ['devops', 'design', 'testing']]), [11, 5])\n assert answers_match(candidate(req_skills=['iot', 'ml', 'ai', 'automation', 'cloudcomputing'], people=[['iot'], ['ml'], ['ai'], ['automation'], ['cloudcomputing'], ['iot', 'ml'], ['ai', 'automation'], ['cloudcomputing', 'ml'], ['iot', 'automation'], ['ai', 'cloudcomputing'], ['iot', 'ml', 'ai'], ['automation', 'cloudcomputing', 'ml']]), [11, 10])\n assert answers_match(candidate(req_skills=['database', 'frontend', 'backend', 'devops', 'cloud', 'security'], people=[['database'], ['frontend'], ['backend'], ['devops'], ['cloud'], ['security'], ['database', 'frontend'], ['backend', 'devops'], ['cloud', 'security'], ['database', 'backend'], ['frontend', 'devops'], ['cloud', 'frontend'], ['database', 'cloud'], ['devops', 'security'], ['database', 'frontend', 'backend'], ['devops', 'cloud', 'security']]), [15, 14])\n assert answers_match(candidate(req_skills=['python', 'javascript', 'ruby', 'cpp'], people=[['python', 'cpp'], ['javascript'], ['ruby'], ['python', 'javascript'], ['cpp', 'ruby'], ['python', 'ruby']]), [4, 3])\n assert answers_match(candidate(req_skills=['sql', 'nosql', 'devops', 'cloud', 'agile'], people=[['sql'], ['nosql'], ['devops'], ['cloud'], ['agile'], ['sql', 'nosql'], ['devops', 'cloud'], ['cloud', 'agile'], ['sql', 'devops'], ['nosql', 'agile']]), [7, 8, 1])\n assert answers_match(candidate(req_skills=['javascript', 'typescript', 'angular', 'react'], people=[['javascript'], ['typescript'], ['angular'], ['react'], ['javascript', 'typescript'], ['angular', 'react'], ['javascript', 'angular'], ['typescript', 'react'], ['javascript', 'typescript', 'angular', 'react']]), [8])\n assert answers_match(candidate(req_skills=['linux', 'windows', 'macos', 'docker'], people=[['linux'], ['windows'], ['macos'], ['docker'], ['linux', 'windows'], ['macos', 'docker'], ['linux', 'macos'], ['windows', 'docker'], ['linux', 'macos', 'docker'], ['windows', 'macos', 'docker'], ['linux', 'windows', 'docker'], ['linux', 'windows', 'macos', 'docker']]), [11])\n assert answers_match(candidate(req_skills=['sql', 'nosql', 'bigdata', 'machinelearning', 'datascience'], people=[['sql', 'nosql'], ['bigdata', 'machinelearning'], ['datascience'], ['sql', 'bigdata'], ['nosql', 'machinelearning'], ['bigdata', 'datascience'], ['machinelearning', 'datascience'], ['sql', 'nosql', 'bigdata', 'machinelearning', 'datascience']]), [7])\n assert answers_match(candidate(req_skills=['git', 'docker', 'jenkins', 'travis', 'circleci', 'aws'], people=[['git', 'docker'], ['jenkins', 'travis'], ['circleci', 'aws'], ['git', 'travis'], ['docker', 'circleci'], ['jenkins', 'aws'], ['git', 'docker', 'jenkins', 'travis', 'circleci', 'aws']]), [6])\n assert answers_match(candidate(req_skills=['mongodb', 'postgresql', 'mysql', 'oracle'], people=[['mongodb'], ['postgresql'], ['mysql'], ['oracle'], ['mongodb', 'postgresql'], ['mysql', 'oracle'], ['mongodb', 'mysql'], ['postgresql', 'oracle'], ['mongodb', 'postgresql', 'mysql'], ['postgresql', 'mysql', 'oracle'], ['mongodb', 'mysql', 'oracle'], ['mongodb', 'postgresql', 'oracle'], ['mongodb', 'postgresql', 'mysql', 'oracle']]), [12])\n assert answers_match(candidate(req_skills=['java', 'spring', 'hibernate', 'react'], people=[['java'], ['spring'], ['hibernate'], ['react'], ['java', 'spring'], ['spring', 'hibernate'], ['hibernate', 'react'], ['java', 'react'], ['java', 'spring', 'hibernate'], ['java', 'spring', 'react'], ['spring', 'hibernate', 'react'], ['java', 'spring', 'hibernate', 'react']]), [11])\n assert answers_match(candidate(req_skills=['sql', 'python', 'frontend', 'backend'], people=[['sql'], ['python'], ['frontend'], ['backend'], ['sql', 'python'], ['frontend', 'backend']]), [5, 4])\n assert answers_match(candidate(req_skills=['aws', 'azure', 'gcp'], people=[['aws', 'azure'], ['gcp'], ['aws'], ['azure', 'gcp'], ['aws', 'gcp'], ['azure'], ['aws', 'azure', 'gcp']]), [6])\n assert answers_match(candidate(req_skills=['coding', 'debugging', 'testing', 'design'], people=[['coding', 'debugging'], ['testing'], ['design'], ['coding', 'testing'], ['debugging', 'design']]), [4, 3])\n assert answers_match(candidate(req_skills=['photoshop', 'illustrator', 'indesign', 'lightroom'], people=[['photoshop', 'illustrator'], ['indesign'], ['lightroom'], ['photoshop', 'indesign'], ['illustrator', 'lightroom'], ['photoshop', 'lightroom'], ['indesign', 'lightroom'], ['photoshop', 'illustrator', 'indesign'], ['illustrator', 'indesign', 'lightroom'], ['photoshop', 'indesign', 'lightroom'], ['photoshop', 'illustrator', 'lightroom'], ['photoshop', 'illustrator', 'indesign', 'lightroom']]), [11])\n assert answers_match(candidate(req_skills=['security', 'analytics', 'ml', 'devops'], people=[['security'], ['analytics'], ['ml'], ['devops'], ['security', 'analytics'], ['ml', 'devops'], ['security', 'ml'], ['analytics', 'devops'], ['security', 'analytics', 'ml'], ['security', 'analytics', 'devops'], ['security', 'ml', 'devops'], ['analytics', 'ml', 'devops'], ['security', 'analytics', 'ml', 'devops']]), [12])\n assert answers_match(candidate(req_skills=['coding', 'debugging', 'design', 'deployment'], people=[['coding', 'debugging'], ['design'], ['deployment'], ['coding', 'deployment'], ['design', 'debugging']]), [3, 4])\n assert answers_match(candidate(req_skills=['sql', 'nosql', 'bigdata', 'cloud', 'devops'], people=[['sql'], ['nosql'], ['bigdata'], ['cloud'], ['devops'], ['sql', 'nosql'], ['bigdata', 'cloud'], ['devops', 'sql'], ['nosql', 'cloud'], ['bigdata', 'devops'], ['sql', 'cloud'], ['nosql', 'devops'], ['bigdata', 'sql'], ['cloud', 'devops'], ['sql', 'nosql', 'cloud'], ['bigdata', 'sql', 'cloud'], ['nosql', 'cloud', 'devops']]), [16, 12])\n assert answers_match(candidate(req_skills=['python', 'cpp', 'java', 'javascript'], people=[['python', 'cpp'], ['java'], ['javascript', 'java'], ['cpp', 'python'], ['cpp', 'java'], ['javascript']]), [2, 0])\n assert answers_match(candidate(req_skills=['coding', 'debugging', 'testing', 'deployment'], people=[['coding'], ['debugging'], ['testing'], ['deployment'], ['coding', 'debugging'], ['testing', 'deployment'], ['coding', 'testing'], ['debugging', 'deployment'], ['coding', 'debugging', 'testing'], ['debugging', 'testing', 'deployment'], ['coding', 'debugging', 'deployment'], ['coding', 'testing', 'deployment'], ['coding', 'debugging', 'testing', 'deployment']]), [12])\n assert answers_match(candidate(req_skills=['aws', 'azure', 'gcp', 'docker', 'kubernetes'], people=[['aws', 'azure'], ['gcp', 'docker'], ['kubernetes'], ['aws', 'docker'], ['azure', 'gcp'], ['aws', 'gcp', 'kubernetes']]), [5, 3, 0])\n assert answers_match(candidate(req_skills=['coding', 'testing', 'documentation', 'deployment'], people=[['coding', 'testing'], ['documentation', 'deployment'], ['coding', 'documentation'], ['testing', 'deployment'], ['coding', 'testing', 'documentation'], ['testing', 'documentation', 'deployment'], ['coding', 'documentation', 'deployment'], ['coding', 'testing', 'deployment'], ['coding', 'testing', 'documentation', 'deployment']]), [8])\n assert answers_match(candidate(req_skills=['html', 'css', 'javascript', 'react', 'nodejs'], people=[['html', 'css'], ['javascript'], ['react', 'nodejs'], ['html', 'javascript'], ['css', 'nodejs'], ['react'], ['html', 'javascript', 'react']]), [4, 6])\n assert answers_match(candidate(req_skills=['product', 'design', 'backend', 'frontend', 'testing'], people=[['product'], ['design'], ['backend'], ['frontend'], ['testing'], ['product', 'design'], ['backend', 'frontend'], ['testing', 'product'], ['design', 'backend'], ['frontend', 'testing'], ['product', 'backend', 'frontend', 'testing'], ['design', 'backend', 'frontend', 'testing']]), [11, 0])\n assert answers_match(candidate(req_skills=['docker', 'kubernetes', 'aws', 'gcp'], people=[['docker'], ['kubernetes'], ['aws'], ['gcp'], ['docker', 'kubernetes'], ['aws', 'gcp'], ['docker', 'aws'], ['kubernetes', 'gcp']]), [5, 4])\n assert answers_match(candidate(req_skills=['linux', 'windows', 'macos', 'unix'], people=[['linux'], ['windows'], ['macos'], ['unix'], ['linux', 'windows'], ['macos', 'unix'], ['linux', 'macos'], ['windows', 'unix'], ['linux', 'unix'], ['windows', 'macos'], ['linux', 'macos', 'unix'], ['linux', 'windows', 'unix'], ['windows', 'macos', 'unix'], ['linux', 'windows', 'macos'], ['linux', 'windows', 'macos', 'unix']]), [14])\n assert answers_match(candidate(req_skills=['python', 'javascript', 'typescript', 'react', 'angular', 'vue'], people=[['python'], ['javascript'], ['typescript'], ['react'], ['angular'], ['vue'], ['python', 'javascript'], ['typescript', 'react'], ['angular', 'vue'], ['python', 'react'], ['javascript', 'vue']]), [8, 7, 6])\n assert answers_match(candidate(req_skills=['html', 'css', 'javascript', 'react'], people=[['html', 'css'], ['javascript'], ['react'], ['css', 'javascript'], ['html', 'react'], ['html', 'css', 'javascript', 'react']]), [5])\n assert answers_match(candidate(req_skills=['frontend', 'backend', 'devops', 'qa'], people=[['frontend'], ['backend'], ['devops'], ['qa'], ['frontend', 'backend'], ['devops', 'qa'], ['frontend', 'devops'], ['backend', 'qa'], ['frontend', 'devops', 'qa'], ['backend', 'devops', 'qa'], ['frontend', 'backend', 'devops'], ['frontend', 'backend', 'qa'], ['frontend', 'backend', 'devops', 'qa']]), [12])\n assert answers_match(candidate(req_skills=['python', 'javascript', 'html', 'css', 'react', 'nodejs'], people=[['python'], ['javascript'], ['html'], ['css'], ['react'], ['nodejs'], ['python', 'javascript'], ['html', 'css'], ['react', 'nodejs'], ['python', 'html', 'css'], ['javascript', 'react', 'nodejs']]), [10, 9])\n assert answers_match(candidate(req_skills=['ux', 'ui', 'product', 'design', 'marketing'], people=[['ux'], ['ui'], ['product'], ['design'], ['marketing'], ['ux', 'ui'], ['product', 'design'], ['marketing', 'ux'], ['ui', 'product'], ['design', 'marketing'], ['ux', 'product'], ['ui', 'marketing'], ['product', 'design', 'marketing'], ['ux', 'ui', 'design'], ['ui', 'product', 'design'], ['ux', 'product', 'marketing'], ['ux', 'ui', 'product', 'design', 'marketing']]), [16])\n assert answers_match(candidate(req_skills=['python', 'javascript', 'cpp', 'go'], people=[['python', 'cpp'], ['javascript'], ['go'], ['python', 'javascript', 'go'], ['cpp', 'javascript']]), [3, 0])\n", "comparison": "unordered"}, "public_tests": ["[\"java\",\"nodejs\",\"reactjs\"]\n[[\"java\"],[\"nodejs\"],[\"nodejs\",\"reactjs\"]]", "[\"algorithms\",\"math\",\"java\",\"reactjs\",\"csharp\",\"aws\"]\n[[\"algorithms\",\"math\",\"java\"],[\"algorithms\",\"math\",\"reactjs\"],[\"java\",\"csharp\",\"aws\"],[\"reactjs\",\"csharp\"],[\"csharp\",\"math\"],[\"aws\",\"java\"]]"], "hints": ["Do a bitmask DP.", "For each person, for each set of skills, we can update our understanding of a minimum set of people needed to perform this set of skills."], "metadata": {"canonical_parameter_names": ["req_skills", "people"], "leetcode_dataset_entry_point": "Solution().smallestSufficientTeam", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:05+00:00", "tests_total": 72, "tests_dropped": 27, "flags": ["any_order"], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def smallestSufficientTeam(self, req_skills: list[str], people: list[list[str]]) -> list[int]:", "container": "Solution", "callable": "smallestSufficientTeam", "parameters": [{"name": "req_skills", "type": "list[str]"}, {"name": "people", "type": "list[list[str]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1128, "task_id": "number-of-equivalent-domino-pairs", "difficulty": "Easy", "problem_description": "Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino.\n\nReturn the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equivalent to dominoes[j].\n\nExample 1:\n\nInput: dominoes = [[1,2],[2,1],[3,4],[5,6]]\nOutput: 1\n\nExample 2:\n\nInput: dominoes = [[1,2],[1,2],[1,1],[1,2],[2,2]]\nOutput: 3\n\nConstraints:\n\n- 1 <= dominoes.length <= 4 * 10^4\n- dominoes[i].length == 2\n- 1 <= dominoes[i][j] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dominoes = [[7, 8], [8, 7], [7, 8], [7, 8], [8, 7]]) == 10\n assert candidate(dominoes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 10\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [5, 6]]) == 1\n assert candidate(dominoes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 0\n assert candidate(dominoes = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(dominoes = [[1, 1], [2, 2], [1, 2], [2, 1]]) == 1\n assert candidate(dominoes = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 6\n assert candidate(dominoes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 0\n assert candidate(dominoes = [[1, 2], [1, 2], [1, 1], [1, 2], [2, 2]]) == 3\n assert candidate(dominoes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == 0\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5]]) == 4\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2]]) == 21\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2], [2, 1]]) == 10\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1]]) == 48\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 28\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 1], [1, 9], [2, 3], [3, 2]]) == 6\n assert candidate(dominoes = [[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, 1]]) == 120\n assert candidate(dominoes = [[3, 4], [4, 3], [3, 5], [5, 3], [3, 6], [6, 3], [3, 7], [7, 3], [3, 8], [8, 3], [3, 9], [9, 3]]) == 6\n assert candidate(dominoes = [[9, 1], [1, 9], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [1, 9], [9, 1]]) == 14\n assert candidate(dominoes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 153\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [1, 9], [9, 1]]) == 34\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [5, 6], [6, 5], [1, 2], [2, 1]]) == 87\n assert candidate(dominoes = [[1, 1], [2, 2], [3, 3], [1, 2], [2, 1], [2, 3], [3, 2], [1, 3], [3, 1]]) == 3\n assert candidate(dominoes = [[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, 1], [1, 2], [2, 1]]) == 153\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3]]) == 9\n assert candidate(dominoes = [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 120\n assert candidate(dominoes = [[1, 1], [1, 2], [2, 1], [1, 1], [2, 2], [1, 2], [2, 1], [1, 2], [2, 2], [2, 1], [1, 1]]) == 19\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 1], [1, 9], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6]]) == 8\n assert candidate(dominoes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 36\n assert candidate(dominoes = [[1, 9], [9, 1], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9]]) == 34\n assert candidate(dominoes = [[1, 2], [2, 1], [2, 1], [1, 2], [3, 4], [4, 3], [3, 4]]) == 9\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 9], [9, 2], [3, 9], [9, 3], [4, 9], [9, 4], [5, 9], [9, 5], [6, 9], [9, 6], [7, 9], [9, 7], [8, 9], [9, 8], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [9, 9]]) == 9\n assert candidate(dominoes = [[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]]) == 9\n assert candidate(dominoes = [[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, 1]]) == 9\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [5, 5], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == 8\n assert candidate(dominoes = [[1, 2], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [2, 1], [1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [1, 2], [2, 1], [2, 1], [1, 2], [1, 2], [2, 1], [2, 1], [1, 2], [2, 1], [2, 1], [1, 2], [1, 2]]) == 300\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 9]]) == 4\n assert candidate(dominoes = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 10\n assert candidate(dominoes = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [1, 9]]) == 6\n assert candidate(dominoes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 1], [4, 2], [4, 3], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9]]) == 6\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [3, 3], [3, 3], [3, 3]]) == 9\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1]]) == 60\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [5, 5]]) == 5\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [1, 1]]) == 4\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1]]) == 8\n assert candidate(dominoes = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 1], [2, 1], [4, 3], [6, 5], [8, 7], [1, 9], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8]]) == 13\n assert candidate(dominoes = [[1, 1], [2, 2], [1, 2], [2, 1], [3, 3], [2, 3], [3, 2], [4, 4], [3, 4], [4, 3], [5, 5], [4, 5], [5, 4], [6, 6], [5, 6], [6, 5], [7, 7], [6, 7], [7, 6], [8, 8], [7, 8], [8, 7], [9, 9], [8, 9], [9, 8], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1]]) == 15\n assert candidate(dominoes = [[9, 1], [1, 9], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 1], [2, 2], [3, 3]]) == 3\n assert candidate(dominoes = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 13\n assert candidate(dominoes = [[1, 1], [1, 2], [2, 1], [1, 3], [3, 1], [2, 2], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 6\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [1, 2], [2, 1], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == 27\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5], [5, 5], [6, 7], [7, 6], [8, 8], [8, 8]]) == 5\n assert candidate(dominoes = [[9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1]]) == 8\n assert candidate(dominoes = [[1, 3], [3, 1], [1, 3], [3, 1], [1, 3], [3, 1], [1, 3], [3, 1]]) == 28\n assert candidate(dominoes = [[4, 5], [5, 4], [4, 6], [6, 4], [4, 7], [7, 4], [4, 8], [8, 4], [4, 9], [9, 4], [4, 1], [1, 4], [4, 2], [2, 4], [4, 3], [3, 4]]) == 8\n assert candidate(dominoes = [[1, 9], [9, 1], [1, 8], [8, 1], [1, 7], [7, 1], [1, 6], [6, 1], [1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1], [1, 1], [1, 1]]) == 9\n assert candidate(dominoes = [[2, 3], [3, 2], [2, 4], [4, 2], [2, 5], [5, 2], [2, 6], [6, 2], [2, 7], [7, 2]]) == 5\n assert candidate(dominoes = [[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], [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], [9, 9], [9, 9], [9, 9], [9, 9]]) == 54\n assert candidate(dominoes = [[1, 2], [2, 1], [2, 1], [1, 2], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 16\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2]]) == 21\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 15\n assert candidate(dominoes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 45\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5]]) == 25\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5], [5, 5], [5, 5]]) == 7\n assert candidate(dominoes = [[7, 8], [8, 7], [5, 9], [9, 5], [7, 8], [8, 7], [5, 9], [9, 5], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7]]) == 24\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [3, 4], [4, 3]]) == 30\n assert candidate(dominoes = [[1, 1], [2, 2], [3, 3], [4, 4], [1, 1], [2, 2], [3, 3]]) == 3\n assert candidate(dominoes = [[1, 9], [9, 1], [1, 8], [8, 1], [1, 7], [7, 1], [1, 6], [6, 1], [1, 5], [5, 1]]) == 5\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 5\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 4], [4, 3]]) == 6\n assert candidate(dominoes = [[1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 7], [7, 6], [7, 8], [8, 7], [8, 9], [9, 8], [1, 9], [9, 1], [2, 9], [9, 2], [3, 9], [9, 3], [4, 9], [9, 4], [5, 9], [9, 5], [6, 9], [9, 6], [7, 9], [9, 7]]) == 15\n assert candidate(dominoes = [[9, 1], [1, 9], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8]]) == 5\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 1], [1, 1], [1, 2], [2, 1], [1, 1], [1, 2], [2, 1], [1, 1]]) == 21\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 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], [3, 4], [4, 3], [3, 5], [5, 3], [3, 6], [6, 3], [3, 7], [7, 3], [3, 8], [8, 3], [3, 9], [9, 3], [4, 5], [5, 4], [4, 6], [6, 4], [4, 7], [7, 4], [4, 8], [8, 4], [4, 9], [9, 4], [5, 6], [6, 5], [5, 7], [7, 5], [5, 8], [8, 5], [5, 9], [9, 5], [6, 7], [7, 6], [6, 8], [8, 6], [6, 9], [9, 6], [7, 8], [8, 7], [7, 9], [9, 7], [8, 9], [9, 8]]) == 36\n assert candidate(dominoes = [[1, 9], [9, 1], [2, 9], [9, 2], [3, 9], [9, 3], [4, 9], [9, 4], [5, 9], [9, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 5\n assert candidate(dominoes = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [9, 1], [8, 2], [7, 3]]) == 10\n assert candidate(dominoes = [[1, 1], [2, 2], [1, 2], [2, 1], [3, 3], [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]]) == 9\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 9], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 9]]) == 25\n assert candidate(dominoes = [[1, 1], [2, 2], [1, 2], [2, 1], [3, 3], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 8\n assert candidate(dominoes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 1]]) == 1\n assert candidate(dominoes = [[1, 2], [2, 1], [1, 2], [2, 1], [3, 4], [4, 3], [3, 4], [4, 3], [5, 6], [6, 5], [5, 6], [6, 5], [7, 8], [8, 7], [7, 8], [8, 7], [9, 9], [9, 9]]) == 25\n assert candidate(dominoes = [[1, 1], [2, 2], [1, 2], [2, 1], [3, 3], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 1], [2, 2]]) == 4\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 1], [1, 9], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 9\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [4, 3], [1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [5, 6], [6, 5]]) == 18\n assert candidate(dominoes = [[1, 1], [2, 2], [3, 3], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [4, 4], [5, 5]]) == 3\n assert candidate(dominoes = [[1, 2], [2, 1], [2, 1], [1, 2], [1, 3], [3, 1], [2, 3], [3, 2], [3, 3], [3, 3]]) == 9\n assert candidate(dominoes = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 1]]) == 45\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,1],[3,4],[5,6]]", "[[1,2],[1,2],[1,1],[1,2],[2,2]]"], "hints": ["For each domino j, find the number of dominoes you've already seen (dominoes i with i < j) that are equivalent.", "You can keep track of what you've seen using a hashmap."], "metadata": {"canonical_parameter_names": ["dominoes"], "leetcode_dataset_entry_point": "Solution().numEquivDominoPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:07+00:00", "tests_total": 89, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def numEquivDominoPairs(self, dominoes: list[list[int]]) -> int:", "container": "Solution", "callable": "numEquivDominoPairs", "parameters": [{"name": "dominoes", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1129, "task_id": "shortest-path-with-alternating-colors", "difficulty": "Medium", "problem_description": "You are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n - 1. Each edge is red or blue in this graph, and there could be self-edges and parallel edges.\n\nYou are given two arrays redEdges and blueEdges where:\n\n- redEdges[i] = [a_i, b_i] indicates that there is a directed red edge from node a_i to node b_i in the graph, and\n- blueEdges[j] = [u_j, v_j] indicates that there is a directed blue edge from node u_j to node v_j in the graph.\n\nReturn an array answer of length n, where each answer[x] is the length of the shortest path from node 0 to node x such that the edge colors alternate along the path, or -1 if such a path does not exist.\n\nExample 1:\n\nInput: n = 3, redEdges = [[0,1],[1,2]], blueEdges = []\nOutput: [0,1,-1]\n\nExample 2:\n\nInput: n = 3, redEdges = [[0,1]], blueEdges = [[2,1]]\nOutput: [0,1,-1]\n\nConstraints:\n\n- 1 <= n <= 100\n- 0 <= redEdges.length, blueEdges.length <= 400\n- redEdges[i].length == blueEdges[j].length == 2\n- 0 <= a_i, b_i, u_j, v_j < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,redEdges = [[0, 1], [1, 2]],blueEdges = [[1, 3]]) == [0, 1, -1, 2]\n assert candidate(n = 4,redEdges = [[0, 1], [0, 2], [0, 3]],blueEdges = [[1, 2], [1, 3], [2, 3]]) == [0, 1, 1, 1]\n assert candidate(n = 2,redEdges = [[0, 0], [0, 0]],blueEdges = [[0, 0], [0, 0]]) == [0, -1]\n assert candidate(n = 3,redEdges = [[0, 1]],blueEdges = [[2, 1]]) == [0, 1, -1]\n assert candidate(n = 4,redEdges = [[0, 1], [0, 2], [1, 3]],blueEdges = [[2, 3]]) == [0, 1, 1, 2]\n assert candidate(n = 2,redEdges = [[0, 1]],blueEdges = [[1, 0]]) == [0, 1]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = []) == [0, 1, -1, -1, -1]\n assert candidate(n = 3,redEdges = [],blueEdges = [[0, 1], [1, 2]]) == [0, 1, -1]\n assert candidate(n = 5,redEdges = [[0, 1], [0, 2], [1, 2], [1, 3], [3, 4], [2, 4]],blueEdges = [[1, 2], [2, 3]]) == [0, 1, 1, 2, 3]\n assert candidate(n = 3,redEdges = [[0, 1], [1, 0]],blueEdges = [[2, 1]]) == [0, 1, -1]\n assert candidate(n = 3,redEdges = [[0, 1], [1, 2]],blueEdges = [[1, 2]]) == [0, 1, 2]\n assert candidate(n = 4,redEdges = [[0, 1], [0, 2], [1, 2]],blueEdges = [[0, 3], [2, 3]]) == [0, 1, 1, 1]\n assert candidate(n = 4,redEdges = [[0, 1], [1, 2], [2, 3]],blueEdges = [[0, 2]]) == [0, 1, 1, 2]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = [[1, 2], [2, 3], [3, 4]]) == [0, 1, 2, 3, 4]\n assert candidate(n = 3,redEdges = [[0, 1], [1, 2], [2, 0]],blueEdges = [[0, 2]]) == [0, 1, 1]\n assert candidate(n = 2,redEdges = [[0, 0]],blueEdges = [[0, 0]]) == [0, -1]\n assert candidate(n = 2,redEdges = [[0, 0]],blueEdges = [[1, 1]]) == [0, -1]\n assert candidate(n = 5,redEdges = [],blueEdges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [0, 1, -1, -1, -1]\n assert candidate(n = 3,redEdges = [[0, 1], [1, 2]],blueEdges = []) == [0, 1, -1]\n assert candidate(n = 4,redEdges = [[0, 1], [2, 3]],blueEdges = [[1, 2], [3, 0]]) == [0, 1, 2, 3]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = [[0, 2], [1, 3], [2, 4]]) == [0, 1, 1, 2, 3]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5]]) == [0, 1, 1, 2, 3, 3]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],blueEdges = [[1, 3], [3, 1], [2, 4]]) == [0, 1, -1, 2, 3]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0]]) == [0, 1, 1, 2, 3, 3, 4, 5, 5, 6]\n assert candidate(n = 9,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == [0, 1, -1, 1, 2, 3, -1, 3, 4]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[0, 3], [1, 4], [2, 5]]) == [0, 1, -1, 1, 2, 3]\n assert candidate(n = 6,redEdges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5]],blueEdges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [0, 1, 1, 2, 3, 3]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[0, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == [0, 1, -1, -1, -1, 1]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[1, 3], [2, 4], [5, 7], [6, 8]]) == [0, 1, -1, 2, 3, -1, -1, -1, -1, -1]\n assert candidate(n = 8,redEdges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == [0, 1, 1, 1, 2, 2, 3, 3]\n assert candidate(n = 5,redEdges = [[0, 1], [0, 2], [1, 3], [2, 4]],blueEdges = [[0, 3], [1, 2], [1, 4], [2, 3]]) == [0, 1, 1, 1, 2]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 0]]) == [0, 1, 1, 2, 3]\n assert candidate(n = 10,redEdges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],blueEdges = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [0, 1, -1, -1, -1, -1, -1, -1, 2, 1]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[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]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 4], [2, 6]],blueEdges = [[0, 2], [1, 3], [3, 5], [5, 7], [7, 1], [4, 6]]) == [0, 1, 1, 2, 1, 3, 2, 3]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == [0, 1, -1, -1, -1, -1, -1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 0], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 1]]) == [0, 1, 1, 2, 3, 3]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == [0, 1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 0]],blueEdges = [[1, 3], [3, 5], [5, 7], [7, 1], [0, 2], [2, 4], [4, 6], [6, 0]]) == [0, 1, 1, 2, -1, 3, -1, -1]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[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 = 5,redEdges = [[0, 1], [0, 4], [1, 2], [2, 3], [3, 4]],blueEdges = [[0, 2], [1, 3], [2, 0], [3, 1], [4, 2]]) == [0, 1, 1, 2, 1]\n assert candidate(n = 15,redEdges = [[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]],blueEdges = [[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]]) == [0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[1, 3], [3, 5], [5, 1], [2, 4], [4, 6], [6, 2]]) == [0, 1, -1, 2, 3, -1, 4]\n assert candidate(n = 6,redEdges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5]],blueEdges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == [0, 1, 1, 2, 3, 3]\n assert candidate(n = 15,redEdges = [[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]],blueEdges = [[0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 0], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6]]) == [0, 1, 5, 9, 13, 17, 21, 1, 2, 3, 7, 11, 15, 19, 23]\n assert candidate(n = 5,redEdges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [3, 4]],blueEdges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [0, 1, 1, 2, 3]\n assert candidate(n = 12,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]],blueEdges = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [0, 1, 4, 5, 8, 9, 1, 2, 3, 6, 7, 10]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[5, 0], [0, 5], [1, 4], [4, 1], [2, 5], [5, 2]]) == [0, 1, 4, 5, 2, 1]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [0, 1, -1, -1, 1, 2, 3, -1, -1, 3]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [0, 1, 1, 2, 3, 3, 4, 5, 5, 6]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = [[4, 0], [3, 1], [2, 2], [1, 3], [0, 4]]) == [0, 1, -1, 2, 1]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 1], [5, 2], [6, 4]]) == [0, 1, 4, 1, 2, 3, 6]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6]]) == [0, 1, -1, 1, 2, 3, -1]\n assert candidate(n = 9,redEdges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 5], [4, 6]],blueEdges = [[5, 7], [5, 8], [6, 7], [6, 8], [7, 0], [7, 1], [8, 0], [8, 2], [0, 3], [0, 4]]) == [0, 1, 1, 1, 1, 2, 2, 2, 2]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[9, 0], [0, 9], [1, 8], [8, 1], [2, 7], [7, 2], [3, 6], [6, 3], [4, 5], [5, 4]]) == [0, 1, -1, -1, -1, -1, -1, -1, 2, 1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 0]],blueEdges = [[1, 3], [3, 4], [4, 5], [5, 1]]) == [0, 1, -1, 2, -1, -1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5]],blueEdges = [[0, 2], [2, 3], [3, 0], [4, 1], [5, 0]]) == [0, 1, 1, -1, -1, -1]\n assert candidate(n = 7,redEdges = [[0, 1], [2, 3], [4, 5], [5, 6]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == [0, 1, 1, 2, -1, 3, 4]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[0, 7], [1, 6], [2, 5], [3, 4], [5, 3], [6, 2], [7, 1]]) == [0, 1, 5, 9, 10, 6, 2, 1]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[7, 0], [0, 7], [1, 6], [6, 1], [2, 5], [5, 2], [3, 4], [4, 3]]) == [0, 1, -1, -1, -1, -1, 2, 1]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[0, 3], [2, 5]]) == [0, 1, -1, 1, 2, -1, -1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == [0, 1, -1, -1, -1, -1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3]],blueEdges = [[0, 2], [2, 4], [4, 1], [1, 5]]) == [0, 1, 1, 1, -1, 2]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = [[0, 2], [2, 4]]) == [0, 1, 1, 2, -1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[1, 3], [3, 5]]) == [0, 1, -1, 2, 3, -1]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5]]) == [0, 1, 1, 2, 3, 3]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],blueEdges = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == [0, 1, -1, -1, -1, 1, 2, 3, -1, -1]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[1, 3], [2, 4], [5, 7]]) == [0, 1, -1, 2, 3, -1, -1, -1]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 0]],blueEdges = [[1, 3], [3, 2], [2, 0], [0, 1]]) == [0, 1, 2, 2, -1]\n assert candidate(n = 7,redEdges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == [0, 1, 1, 1, 2, 2, 3]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4]],blueEdges = [[1, 3], [2, 4]]) == [0, 1, -1, 2, 3]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [2, 7], [3, 8], [4, 9]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 0], [8, 1], [9, 2]]) == [0, 1, 4, 1, 2, 1, 6, 3, 2, 3]\n assert candidate(n = 10,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],blueEdges = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == [0, 1, -1, -1, -1, 1, 2, 3, -1, -1]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],blueEdges = [[0, 2], [2, 4], [4, 1], [1, 3], [3, 0]]) == [0, 1, 1, 2, 3]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[6, 0], [0, 6], [1, 5], [5, 1], [2, 4], [4, 2], [3, 6], [6, 3]]) == [0, 1, 6, 4, 5, 2, 1]\n assert candidate(n = 8,redEdges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[1, 2], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1], [0, 3]]) == [0, 1, 1, 1, 2, 3, 3, 4]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 4]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 1], [4, 3]]) == [0, 1, 1, 2, 1]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 0], [3, 4]],blueEdges = [[0, 2], [2, 3], [3, 0], [4, 1]]) == [0, 1, 1, -1, -1]\n assert candidate(n = 9,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]]) == [0, 1, 1, 2, 3, 3, 4, 5, 5]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],blueEdges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 9,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 5], [2, 6], [3, 7]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 1], [7, 2], [8, 4]]) == [0, 1, 3, 1, 2, 3, 4, 2, 4]\n assert candidate(n = 9,redEdges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8]],blueEdges = [[8, 4], [4, 0], [0, 2], [2, 4], [5, 1], [1, 3], [3, 5], [7, 6]]) == [0, 1, 1, 2, -1, 3, 4, -1, -1]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],blueEdges = [[1, 3], [3, 1], [2, 4], [4, 2]]) == [0, 1, 4, 2, 3]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 0], [1, 2], [2, 3], [3, 4]],blueEdges = [[0, 2], [1, 3], [2, 0], [3, 1], [4, 0]]) == [0, 1, 1, 2, 3]\n assert candidate(n = 9,redEdges = [[0, 1], [0, 3], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],blueEdges = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8]]) == [0, 1, -1, 1, 1, 2, 3, 2, 3]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0]]) == [0, 1, 1, 2, 3, 3, 4, 5]\n assert candidate(n = 10,redEdges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],blueEdges = [[0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 9]]) == [0, 1, 1, 1, 2, 2, 2, 2, 2, 3]\n assert candidate(n = 7,redEdges = [[0, 1], [0, 3], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == [0, 1, 1, 1, 3, 2, 3]\n assert candidate(n = 10,redEdges = [[0, 2], [2, 4], [4, 6], [6, 8]],blueEdges = [[1, 3], [3, 5], [5, 7], [7, 9]]) == [0, -1, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4]],blueEdges = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == [0, 1, 5, 1, 2, 3, 7]\n assert candidate(n = 8,redEdges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7]],blueEdges = [[0, 3], [0, 4], [1, 5], [1, 6], [2, 7]]) == [0, 1, 1, 1, 1, 2, 2, 2]\n assert candidate(n = 6,redEdges = [[0, 1], [1, 2], [2, 0], [2, 3], [3, 4], [4, 5]],blueEdges = [[1, 3], [2, 4], [3, 5], [4, 0], [5, 1], [5, 2]]) == [0, 1, -1, 2, 3, -1]\n assert candidate(n = 8,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],blueEdges = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == [0, 1, 1, 2, 3, 3, 4, 5]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[0, 3], [1, 4], [2, 5]]) == [0, 1, -1, 1, 2, 3, -1]\n assert candidate(n = 7,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],blueEdges = [[1, 3], [2, 4], [3, 5], [4, 6]]) == [0, 1, -1, 2, 3, -1, 4]\n assert candidate(n = 5,redEdges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],blueEdges = [[1, 2], [2, 3], [3, 4], [4, 0], [0, 1]]) == [0, 1, 2, 3, 4]\n", "comparison": "exact"}, "public_tests": ["3\n[[0,1],[1,2]]\n[]", "3\n[[0,1]]\n[[2,1]]"], "hints": ["Do a breadth-first search, where the \"nodes\" are actually (Node, color of last edge taken)."], "metadata": {"canonical_parameter_names": ["n", "redEdges", "blueEdges"], "leetcode_dataset_entry_point": "Solution().shortestAlternatingPaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:09+00:00", "tests_total": 97, "tests_dropped": 0, "flags": [], "topic_tags": ["breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def shortestAlternatingPaths(self, n: int, redEdges: list[list[int]], blueEdges: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "shortestAlternatingPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "redEdges", "type": "list[list[int]]"}, {"name": "blueEdges", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1130, "task_id": "minimum-cost-tree-from-leaf-values", "difficulty": "Medium", "problem_description": "Given an array arr of positive integers, consider all binary trees such that:\n\n- Each node has either 0 or 2 children;\n- The values of arr correspond to the values of each leaf in an in-order traversal of the tree.\n- The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree, respectively.\n\nAmong all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node. It is guaranteed this sum fits into a 32-bit integer.\n\nA node is a leaf if and only if it has zero children.\n\nExample 1:\n\nInput: arr = [6,2,4]\nOutput: 32\nExplanation: There are two possible trees shown.\nThe first has a non-leaf node sum 36, and the second has non-leaf node sum 32.\n\nExample 2:\n\nInput: arr = [4,11]\nOutput: 44\n\nConstraints:\n\n- 2 <= arr.length <= 40\n- 1 <= arr[i] <= 15\n- It is guaranteed that the answer fits into a 32-bit signed integer (i.e., it is less than 2^31).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4]) == 20\n assert candidate(arr = [3, 2, 1]) == 8\n assert candidate(arr = [15, 13, 5, 3, 15]) == 500\n assert candidate(arr = [4, 11]) == 44\n assert candidate(arr = [7, 12, 8, 10]) == 284\n assert candidate(arr = [3, 5, 6, 2, 5]) == 85\n assert candidate(arr = [7, 10, 2, 8, 1]) == 174\n assert candidate(arr = [8, 12, 15, 2, 5, 7]) == 426\n assert candidate(arr = [1, 2, 3, 4, 5]) == 40\n assert candidate(arr = [6, 2, 4]) == 32\n assert candidate(arr = [3, 5, 1, 2, 4]) == 45\n assert candidate(arr = [2, 3, 1, 4]) == 21\n assert candidate(arr = [3, 5, 2, 1, 4]) == 45\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1120\n assert candidate(arr = [5, 4, 7, 2, 11, 6]) == 212\n assert candidate(arr = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1120\n assert candidate(arr = [5, 7, 8, 6, 2, 3]) == 163\n assert candidate(arr = [5, 4, 3, 2, 1, 6, 7]) == 112\n assert candidate(arr = [5, 2, 3, 1, 4, 6, 7]) == 113\n assert candidate(arr = [8, 7, 6, 5, 4, 3, 2, 1]) == 168\n assert candidate(arr = [13, 15, 7, 9, 8, 11, 14, 12, 5, 6, 2, 3, 1, 4, 10]) == 1216\n assert candidate(arr = [13, 7, 11, 10, 15, 2, 1, 12, 8, 6, 5, 9, 3, 4]) == 1037\n assert candidate(arr = [5, 10, 9, 2, 3, 15, 12, 8]) == 599\n assert candidate(arr = [7, 1, 9, 8, 4, 2, 5]) == 210\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 1120\n assert candidate(arr = [15, 9, 5, 6, 11, 8, 12, 13, 14, 7, 10, 4, 3, 2, 1]) == 1221\n assert candidate(arr = [12, 4, 6, 1, 5, 9, 7]) == 284\n assert candidate(arr = [11, 13, 10, 9, 2, 15, 5, 12, 7, 14]) == 1098\n assert candidate(arr = [10, 12, 7, 5, 4, 1, 6]) == 300\n assert candidate(arr = [5, 3, 2, 7, 9, 10, 8]) == 289\n assert candidate(arr = [13, 5, 1, 12, 8, 9]) == 401\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 11, 12, 13, 14, 15]) == 1134\n assert candidate(arr = [2, 1, 3, 4, 5, 6, 7]) == 112\n assert candidate(arr = [10, 5, 15, 3, 8, 7]) == 400\n assert candidate(arr = [10, 1, 14, 7, 13, 3, 5, 2, 8, 6, 4, 9, 11, 12]) == 1019\n assert candidate(arr = [8, 3, 9, 6, 1, 10, 2]) == 266\n assert candidate(arr = [7, 11, 14, 13, 5, 15, 10]) == 838\n assert candidate(arr = [13, 7, 12, 1, 8, 5, 9, 4]) == 504\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 301\n assert candidate(arr = [8, 5, 1, 9, 2, 4, 3, 10, 6, 7, 11, 12, 14, 13, 15]) == 1177\n assert candidate(arr = [3, 15, 2, 8, 9, 11, 5, 10, 7, 6, 12, 4]) == 864\n assert candidate(arr = [1, 3, 2, 6, 8, 5, 4, 7, 9, 10]) == 348\n assert candidate(arr = [2, 15, 8, 3, 10, 6, 7, 4, 11, 1, 9, 5, 12, 14, 13]) == 1229\n assert candidate(arr = [13, 15, 1, 5, 3]) == 290\n assert candidate(arr = [3, 4, 5, 2, 6, 7, 8, 1]) == 178\n assert candidate(arr = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 480\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 220\n assert candidate(arr = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 330\n assert candidate(arr = [10, 2, 5, 1, 3]) == 78\n assert candidate(arr = [11, 6, 5, 9, 3, 8, 2, 4, 7]) == 371\n assert candidate(arr = [14, 10, 1, 2, 15, 12, 8]) == 648\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1120\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1120\n assert candidate(arr = [12, 7, 11, 14, 10, 13, 6]) == 767\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(arr = [5, 1, 3, 2, 10, 7, 4]) == 172\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]) == 30\n assert candidate(arr = [5, 3, 8, 6, 2, 4, 1, 9]) == 211\n assert candidate(arr = [7, 14, 4, 14, 13, 2, 6, 13]) == 791\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 330\n assert candidate(arr = [5, 3, 8, 1, 4, 7]) == 143\n assert candidate(arr = [6, 9, 4, 10, 5, 8, 7, 3, 11, 1, 12, 2, 13, 14, 15]) == 1202\n assert candidate(arr = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]) == 1260\n assert candidate(arr = [13, 15, 1, 7, 2]) == 321\n assert candidate(arr = [8, 3, 1, 14, 10, 6, 7, 2, 13, 9, 5, 4, 11, 12]) == 1029\n assert candidate(arr = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9]) == 1188\n assert candidate(arr = [12, 15, 8, 3, 10, 6]) == 494\n assert candidate(arr = [15, 13, 11, 9, 7, 5, 3, 1]) == 553\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1120\n assert candidate(arr = [15, 10, 2, 3, 5, 1, 8, 6, 14, 7]) == 642\n assert candidate(arr = [15, 8, 3, 10, 6, 7, 4, 11, 1, 9, 2, 12, 5, 14, 13]) == 1232\n assert candidate(arr = [3, 5, 1, 9, 2, 4, 8, 10, 6, 7, 11, 12, 14, 13, 15]) == 1181\n assert candidate(arr = [2, 9, 3, 5, 6, 4]) == 141\n assert candidate(arr = [8, 5, 3, 2, 4, 6, 7]) == 166\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == 553\n assert candidate(arr = [10, 6, 8, 3, 4, 12, 5, 14]) == 520\n assert candidate(arr = [1, 5, 2, 3, 6, 4, 7]) == 122\n assert candidate(arr = [8, 5, 9, 3, 6]) == 184\n assert candidate(arr = [7, 4, 9, 2, 5, 1, 8]) == 218\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, 5]) == 800\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(arr = [8, 6, 10, 5, 12, 9, 7, 3, 11, 1, 4]) == 661\n assert candidate(arr = [12, 7, 4, 9, 2, 8, 5, 3]) == 342\n assert candidate(arr = [7, 6, 8, 2, 10, 5, 1, 3, 9, 4]) == 383\n assert candidate(arr = [6, 9, 3, 7, 5, 1, 4]) == 197\n assert candidate(arr = [6, 5, 8, 10, 3, 9, 1, 14, 13, 2, 4, 7, 11, 12, 15]) == 1217\n assert candidate(arr = [4, 7, 10, 2, 13, 15, 5, 3, 8, 6, 9, 1, 14, 12, 11]) == 1263\n assert candidate(arr = [8, 9, 3, 8, 15, 2]) == 333\n assert candidate(arr = [8, 3, 6, 1, 4, 7, 10, 2, 9, 5]) == 377\n assert candidate(arr = [8, 9, 10, 7, 6, 5, 4, 3, 2, 1]) == 344\n assert candidate(arr = [5, 3, 8, 6, 2, 4, 7, 1, 10, 9]) == 362\n assert candidate(arr = [7, 8, 6, 5, 4, 3, 2, 1]) == 174\n", "comparison": "exact"}, "public_tests": ["[6,2,4]", "[4,11]"], "hints": ["Do a DP, where dp(i, j) is the answer for the subarray arr[i]..arr[j].", "For each possible way to partition the subarray i <= k < j, the answer is max(arr[i]..arr[k]) * max(arr[k+1]..arr[j]) + dp(i, k) + dp(k+1, j)."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().mctFromLeafValues", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:12+00:00", "tests_total": 108, "tests_dropped": 16, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "stack", "greedy", "monotonic-stack", "cartesian-tree"]}, "language": "python", "interface": {"raw_signature": "def mctFromLeafValues(self, arr: list[int]) -> int:", "container": "Solution", "callable": "mctFromLeafValues", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1131, "task_id": "maximum-of-absolute-value-expression", "difficulty": "Medium", "problem_description": "Given two arrays of integers with equal lengths, return the maximum value of:\n\n|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|\n\nwhere the maximum is taken over all 0 <= i, j < arr1.length.\n\nExample 1:\n\nInput: arr1 = [1,2,3,4], arr2 = [-1,4,5,6]\nOutput: 13\n\nExample 2:\n\nInput: arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4]\nOutput: 20\n\nConstraints:\n\n- 2 <= arr1.length == arr2.length <= 40000\n- -10^6 <= arr1[i], arr2[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [1, -2, -5, 0, 10],arr2 = [0, -2, -1, -7, -4]) == 20\n assert candidate(arr1 = [1, 3, 5, 7],arr2 = [2, 4, 6, 8]) == 15\n assert candidate(arr1 = [-1, -2, -3, -4, -5],arr2 = [1, 2, 3, 4, 5]) == 12\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [9, 7, 5, 3, 1]) == 20\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0],arr2 = [0, 0, 0, 0, 0, 0]) == 5\n assert candidate(arr1 = [-1000000, 1000000],arr2 = [1000000, -1000000]) == 4000001\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [0, 0, 0, 0]) == 3\n assert candidate(arr1 = [1, 2, 3, 4],arr2 = [-1, 4, 5, 6]) == 13\n assert candidate(arr1 = [1000000, -1000000],arr2 = [-1000000, 1000000]) == 4000001\n assert candidate(arr1 = [5, 5, 5, 5],arr2 = [5, 5, 5, 5]) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 918\n assert candidate(arr1 = [-1000000, -900000, -800000, -700000, -600000, -500000, -400000, -300000, -200000, -100000],arr2 = [-100000, -200000, -300000, -400000, -500000, -600000, -700000, -800000, -900000, -1000000]) == 1800009\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 38\n assert candidate(arr1 = [1, -2, 3, -4, 5],arr2 = [-5, 4, -3, 2, -1]) == 15\n assert candidate(arr1 = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5],arr2 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) == 23\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 45\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 108\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 57\n assert candidate(arr1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 11\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 189\n assert candidate(arr1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],arr2 = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 18009\n assert candidate(arr1 = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500],arr2 = [-1000, 1000, -900, 900, -800, 800, -700, 700, -600, 600]) == 2209\n assert candidate(arr1 = [-1, 1, -2, 2, -3, 3],arr2 = [-3, 3, -2, 2, -1, 1]) == 13\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 30\n assert candidate(arr1 = [123456, -234567, 345678, -456789, 567890],arr2 = [567890, -456789, 345678, -234567, 123456]) == 1382713\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 27\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],arr2 = [-512, -256, -128, -64, -32, -16, -8, -4, -2, -1]) == 1031\n assert candidate(arr1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],arr2 = [1000, -1000, 900, -900, 800, -800, 700, -700, 600, -600]) == 2003\n assert candidate(arr1 = [1000000, 999999, 999998, 999997, 999996],arr2 = [0, 1, 2, 3, 4]) == 12\n assert candidate(arr1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],arr2 = [5, -5, 4, -4, 3, -3, 2, -2, 1, -1]) == 21\n assert candidate(arr1 = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],arr2 = [-10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 31\n assert candidate(arr1 = [-100000, 100000, -50000, 50000, -25000, 25000],arr2 = [25000, -25000, 50000, -50000, 100000, -100000]) == 250005\n assert candidate(arr1 = [1000000, 0, -1000000, 500000, -500000],arr2 = [-1000000, 1000000, 0, -500000, 500000]) == 3000004\n assert candidate(arr1 = [1000000, -1000000, 500000, -500000],arr2 = [-1000000, 1000000, -500000, 500000]) == 4000001\n assert candidate(arr1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],arr2 = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 23\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 42\n assert candidate(arr1 = [5, 6, 8, 10, 15, 20, 30, 40, 50, 60],arr2 = [60, 50, 40, 30, 20, 15, 10, 8, 6, 5]) == 119\n assert candidate(arr1 = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],arr2 = [999991, 999992, 999993, 999994, 999995, 999996, 999997, 999998, 999999, 1000000]) == 27\n assert candidate(arr1 = [-1000000, 0, 1000000, -500000, 500000],arr2 = [500000, -500000, 0, 1000000, -1000000]) == 3000004\n assert candidate(arr1 = [500000, 400000, 300000, 200000, 100000, 0, -100000, -200000, -300000, -400000],arr2 = [-500000, -400000, -300000, -200000, -100000, 0, 100000, 200000, 300000, 400000]) == 1800009\n assert candidate(arr1 = [1, -1, 2, -2, 3, -3],arr2 = [1, 2, 3, -1, -2, -3]) == 14\n assert candidate(arr1 = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],arr2 = [-1000000, -999999, -999998, -999997, -999996, -999995, -999994, -999993, -999992, -999991]) == 27\n assert candidate(arr1 = [10, -10, 20, -20, 30, -30],arr2 = [-30, 30, -20, 20, -10, 10]) == 85\n assert candidate(arr1 = [10000, -10000, 20000, -20000, 30000, -30000],arr2 = [-30000, 30000, -20000, 20000, -10000, 10000]) == 80005\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 10\n assert candidate(arr1 = [1000000, -1000000, 1000000, -1000000, 1000000, -1000000, 1000000, -1000000, 1000000, -1000000],arr2 = [-1000000, 1000000, -1000000, 1000000, -1000000, 1000000, -1000000, 1000000, -1000000, 1000000]) == 4000009\n assert candidate(arr1 = [1000000, 500000, -500000, -1000000],arr2 = [-1000000, 500000, 1000000, -500000]) == 3500002\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [-1, 1, -1, 1, -1]) == 5\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [-100, -200, -300, -400, -500]) == 804\n assert candidate(arr1 = [1000000, -1000000, 500000, -500000],arr2 = [-500000, 500000, -1000000, 1000000]) == 3000003\n assert candidate(arr1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1809\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [900, 800, 700, 600, 500]) == 804\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 27\n assert candidate(arr1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(arr1 = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5],arr2 = [5, -5, 4, -4, 3, -3, 2, -2, 1, -1, 0]) == 21\n assert candidate(arr1 = [42, 17, 9, 23, 5, 6, 8],arr2 = [3, 8, 1, 4, 7, 2, 9]) == 46\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 9\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [-10, -20, -30, -40, -50]) == 84\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 108\n assert candidate(arr1 = [1000000, 500000, 0, -500000, -1000000],arr2 = [-1000000, -500000, 0, 500000, 1000000]) == 4000004\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 189\n assert candidate(arr1 = [1, -100, 100, 0, 50, -50, 25, -25, 75, -75],arr2 = [100, 1, -1, 50, -50, 100, -100, 0, 75, -75]) == 301\n assert candidate(arr1 = [-1000000, 0, 1000000, -1000000, 0, 1000000],arr2 = [0, 1000000, -1000000, 0, 1000000, -1000000]) == 3000005\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 19\n assert candidate(arr1 = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],arr2 = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 10\n assert candidate(arr1 = [1000000, -1000000, 1000000, -1000000, 1000000],arr2 = [-1000000, 1000000, -1000000, 1000000, -1000000]) == 4000003\n assert candidate(arr1 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],arr2 = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 189\n assert candidate(arr1 = [1, 10, 100, 1000, 10000, 100000, 1000000, -1, -10, -100],arr2 = [1000000, 100000, 10000, 1000, 100, 10, 1, -1000000, -100000, -10000]) == 2000009\n assert candidate(arr1 = [-1000000, -500000, 0, 500000, 1000000],arr2 = [1000000, 500000, 0, -500000, -1000000]) == 4000004\n assert candidate(arr1 = [123456, -123456, 234567, -234567, 345678, -345678],arr2 = [-345678, 345678, -234567, 234567, -123456, 123456]) == 938273\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 27\n assert candidate(arr1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],arr2 = [-5, 5, -4, 4, -3, 3, -2, 2, -1, 1]) == 21\n assert candidate(arr1 = [123456, -123456, 654321, -654321, 234567, -234567],arr2 = [234567, -234567, 123456, -123456, 654321, -654321]) == 1777777\n assert candidate(arr1 = [-1, 0, 1, -2, 2, -3, 3],arr2 = [3, -3, 2, -2, 1, -1, 0]) == 13\n assert candidate(arr1 = [0, 1, 0, 1, 0, 1, 0],arr2 = [1, 0, 1, 0, 1, 0, 1]) == 7\n assert candidate(arr1 = [1000000, -1000000, 1000000, -1000000, 1000000],arr2 = [0, 1000000, 0, 1000000, 0]) == 3000003\n assert candidate(arr1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000],arr2 = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 14007\n assert candidate(arr1 = [1000000, 500000, -500000, -1000000, 0],arr2 = [0, 1000000, -1000000, 500000, -500000]) == 3000001\n assert candidate(arr1 = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5],arr2 = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == 23\n assert candidate(arr1 = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],arr2 = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 13\n assert candidate(arr1 = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1]) == 30\n assert candidate(arr1 = [-1000000, 1000000, -1000000, 1000000, -1000000, 1000000],arr2 = [1000000, -1000000, 1000000, -1000000, 1000000, -1000000]) == 4000005\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [50, 40, 30, 20, 10]) == 84\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 57\n assert candidate(arr1 = [100000, 200000, 300000, 400000, 500000],arr2 = [500000, 400000, 300000, 200000, 100000]) == 800004\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [-5, -4, -3, -2, -1]) == 12\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [-1, -1, -1, -1, -1]) == 4\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n[-1,4,5,6]", "[1,-2,-5,0,10]\n[0,-2,-1,-7,-4]"], "hints": ["Use the idea that abs(A) + abs(B) = max(A+B, A-B, -A+B, -A-B)."], "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().maxAbsValExpr", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:15+00:00", "tests_total": 94, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def maxAbsValExpr(self, arr1: list[int], arr2: list[int]) -> int:", "container": "Solution", "callable": "maxAbsValExpr", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1137, "task_id": "n-th-tribonacci-number", "difficulty": "Easy", "problem_description": "The Tribonacci sequence T_n is defined as follows:\n\nT_0 = 0, T_1 = 1, T_2 = 1, and T_{n+3} = T_n + T_{n+1} + T_{n+2} for n >= 0.\n\nGiven n, return the value of T_n.\n\nExample 1:\n\nInput: n = 4\nOutput: 4\nExplanation:\nT_3 = 0 + 1 + 1 = 2\nT_4 = 1 + 1 + 2 = 4\n\nExample 2:\n\nInput: n = 25\nOutput: 1389537\n\nConstraints:\n\n- 0 <= n <= 37\n- The answer is guaranteed to fit within a 32-bit integer, ie. answer <= 2^31 - 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 2\n assert candidate(n = 4) == 4\n assert candidate(n = 37) == 2082876103\n assert candidate(n = 2) == 1\n assert candidate(n = 1) == 1\n assert candidate(n = 25) == 1389537\n assert candidate(n = 30) == 29249425\n assert candidate(n = 15) == 3136\n assert candidate(n = 22) == 223317\n assert candidate(n = 12) == 504\n assert candidate(n = 35) == 615693474\n assert candidate(n = 26) == 2555757\n assert candidate(n = 27) == 4700770\n assert candidate(n = 18) == 19513\n assert candidate(n = 20) == 66012\n assert candidate(n = 10) == 149\n assert candidate(n = 5) == 7\n", "comparison": "exact"}, "public_tests": ["4", "25"], "hints": ["Make an array F of length 38, and set F[0] = 0, F[1] = F[2] = 1.", "Now write a loop where you set F[n+3] = F[n] + F[n+1] + F[n+2], and return F[n]."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().tribonacci", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:27+00:00", "tests_total": 18, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def tribonacci(self, n: int) -> int:", "container": "Solution", "callable": "tribonacci", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1138, "task_id": "alphabet-board-path", "difficulty": "Medium", "problem_description": "On an alphabet board, we start at position (0, 0), corresponding to character board[0][0].\n\nHere, board = [\"abcde\", \"fghij\", \"klmno\", \"pqrst\", \"uvwxy\", \"z\"], as shown in the diagram below.\n\nWe may make the following moves:\n\n- 'U' moves our position up one row, if the position exists on the board;\n- 'D' moves our position down one row, if the position exists on the board;\n- 'L' moves our position left one column, if the position exists on the board;\n- 'R' moves our position right one column, if the position exists on the board;\n- '!' adds the character board[r][c] at our current position (r, c) to the answer.\n\n(Here, the only positions that exist on the board are positions with letters on them.)\n\nReturn a sequence of moves that makes our answer equal to target in the minimum number of moves. You may return any path that does so.\n\nExample 1:\n\nInput: target = \"leet\"\nOutput: \"DDR!UURRR!!DDD!\"\n\nExample 2:\n\nInput: target = \"code\"\nOutput: \"RR!DDRR!UUL!R!\"\n\nConstraints:\n\n- 1 <= target.length <= 100\n- target consists only of English lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = \"azaz\") == \"!DDDDD!UUUUU!DDDDD!\"\n assert candidate(target = \"zm\") == \"DDDDD!UUURR!\"\n assert candidate(target = \"abcde\") == \"!R!R!R!R!\"\n assert candidate(target = \"leet\") == \"RDD!UURRR!!DDD!\"\n assert candidate(target = \"zuz\") == \"DDDDD!U!D!\"\n assert candidate(target = \"abc\") == \"!R!R!\"\n assert candidate(target = \"zb\") == \"DDDDD!UUUUUR!\"\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyzzzzz\") == \"!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!!!!!\"\n assert candidate(target = \"zz\") == \"DDDDD!!\"\n assert candidate(target = \"abcdefghijklmnopqrstuvwxy\") == \"!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!\"\n assert candidate(target = \"xyz\") == \"RRRDDDD!R!LLLLD!\"\n assert candidate(target = \"zyxwvutsrqponmlkjihgfedcba\") == \"DDDDD!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!\"\n assert candidate(target = \"zbcd\") == \"DDDDD!UUUUUR!R!R!\"\n assert candidate(target = \"zdz\") == \"DDDDD!UUUUURRR!LLLDDDDD!\"\n assert candidate(target = \"a\") == \"!\"\n assert candidate(target = \"mnopqrstuvwxyzz\") == \"RRDD!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!!\"\n assert candidate(target = \"zzz\") == \"DDDDD!!!\"\n assert candidate(target = \"code\") == \"RR!RRDD!LUU!R!\"\n assert candidate(target = \"zzzzz\") == \"DDDDD!!!!!\"\n assert candidate(target = \"az\") == \"!DDDDD!\"\n assert candidate(target = \"algorithms\") == \"!RDD!U!RRRD!LLD!UUR!RDD!LLUU!D!RD!\"\n assert candidate(target = \"inputs\") == \"RRRD!D!LLLD!D!URRRR!L!\"\n assert candidate(target = \"hello\") == \"RRD!URR!LLLDD!!RRR!\"\n assert candidate(target = \"elephant\") == \"RRRR!LLLDD!UURRR!LLLLDDD!UURR!LLU!RRRDD!RD!\"\n assert candidate(target = \"alphabet\") == \"!RDD!LD!UURR!LLU!R!RRR!DDD!\"\n assert candidate(target = \"qrstuvwxyza\") == \"RDDD!R!R!R!LLLLD!R!R!R!R!LLLLD!UUUUU!\"\n assert candidate(target = \"minimum\") == \"RRDD!UR!D!U!LD!LLDD!UURR!\"\n assert candidate(target = \"zxywvutsrqponmlkjihgfedcba\") == \"DDDDD!URRR!R!LL!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!\"\n assert candidate(target = \"fish\") == \"D!RRR!DD!LUU!\"\n assert candidate(target = \"snake\") == \"RRRDDD!U!LLLUU!DD!UURRRR!\"\n assert candidate(target = \"uvwxyz\") == \"DDDD!R!R!R!R!LLLLD!\"\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"DDDDD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n assert candidate(target = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\") == \"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!R!\"\n assert candidate(target = \"whale\") == \"RRDDDD!UUU!LLU!RDD!UURRR!\"\n assert candidate(target = \"mnopqrstuvwxyzabcde\") == \"RRDD!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!UUUUU!R!R!R!R!\"\n assert candidate(target = \"rhythm\") == \"RRDDD!UU!RRDDD!U!LLUU!D!\"\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\") == \"!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!\"\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"DDDDD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n assert candidate(target = \"testcase\") == \"RRRRDDD!UUU!LDDD!R!LLUUU!LL!RRRDDD!UUUR!\"\n assert candidate(target = \"hellofromtheotherside\") == \"RRD!URR!LLLDD!!RRR!LLLLU!RRDD!URR!LL!RRD!LLUU!URR!DD!D!LLUU!URR!LLDDD!R!UU!U!R!\"\n assert candidate(target = \"pythonprogramming\") == \"DDD!RRRRD!U!LLUU!RRD!L!LLLD!RR!URR!LLLU!RDD!LLUUU!RRDD!!UR!D!LLU!\"\n assert candidate(target = \"qpwoeiuytrmnbvcxzlkjhgfdsaz\") == \"RDDD!L!RRD!UURR!UU!LD!LLLDDD!RRRR!U!LL!U!R!LLUU!DDDD!UUUUR!RDDDD!LLLD!UUUR!L!URRRR!LL!L!L!URRR!DDD!LLLUUU!DDDDD!\"\n assert candidate(target = \"quicksand\") == \"RDDD!LD!UUURRR!LU!LLDD!RRRD!LLLUUU!RRRDD!UU!\"\n assert candidate(target = \"abacaxabacax\") == \"!R!L!RR!LL!RRRDDDD!LLLUUUU!R!L!RR!LL!RRRDDDD!\"\n assert candidate(target = \"movesteps\") == \"RRDD!RR!LLLDD!UUUURRR!LDDD!R!UUU!LLLLDDD!RRR!\"\n assert candidate(target = \"zzazzazzazz\") == \"DDDDD!!UUUUU!DDDDD!!UUUUU!DDDDD!!UUUUU!DDDDD!!\"\n assert candidate(target = \"ddddddddeeeeeeeeedddddddd\") == \"RRR!!!!!!!!R!!!!!!!!!L!!!!!!!!\"\n assert candidate(target = \"crocodile\") == \"RR!DDD!URR!LLUU!RRDD!LUU!D!LLD!UURRR!\"\n assert candidate(target = \"aaabbbcccddd\") == \"!!!R!!!R!!!R!!!\"\n assert candidate(target = \"microsoft\") == \"RRDD!UR!LU!DDD!URR!LD!UR!LLLLU!RRRRDD!\"\n assert candidate(target = \"mnopqrstuvwxyza\") == \"RRDD!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!UUUUU!\"\n assert candidate(target = \"uvwxyzz\") == \"DDDD!R!R!R!R!LLLLD!!\"\n assert candidate(target = \"board\") == \"R!RRRDD!LLLLUU!RRDDD!UUUR!\"\n assert candidate(target = \"solution\") == \"RRRDDD!UR!LLL!LDD!URRRR!LUU!RD!L!\"\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyzaa\") == \"!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!UUUUU!!\"\n assert candidate(target = \"qpwoeirutyalskdjfhgzxcvbnm\") == \"RDDD!L!RRD!UURR!UU!LD!LDD!LLD!URRRR!D!LLLLUUUU!RDD!RRD!LLLU!UURRR!RD!LLLL!RR!L!LDDDD!URRR!LUUUU!LDDDD!UUUU!RRDD!L!\"\n assert candidate(target = \"xyzzzyxyzzz\") == \"RRRDDDD!R!LLLLD!!!URRRR!L!R!LLLLD!!!\"\n assert candidate(target = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == \"RRDD!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!\"\n assert candidate(target = \"challenge\") == \"RR!D!LLU!RDD!!UURRR!LDD!LLU!URRR!\"\n assert candidate(target = \"mnopqrstu\") == \"RRDD!R!R!LLLLD!R!R!R!R!LLLLD!\"\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"DDDDD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n assert candidate(target = \"giraffe\") == \"RD!RR!LDD!LLUUU!D!!URRRR!\"\n assert candidate(target = \"zyxwvutsrqponmlkjihgfedcbaaabbbcccddd\") == \"DDDDD!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!!!R!!!R!!!R!!!\"\n assert candidate(target = \"dolphin\") == \"RRR!RDD!LLL!LD!UURR!R!D!\"\n assert candidate(target = \"efficient\") == \"RRRR!LLLLD!!RRR!LU!RD!UR!LDD!RD!\"\n assert candidate(target = \"hellothere\") == \"RRD!URR!LLLDD!!RRR!D!LLUU!URR!LLDDD!UUURR!\"\n assert candidate(target = \"thequickbrownfoxjumpsoverthelazydog\") == \"RRRRDDD!LLUU!URR!LLLDDD!LD!UUURRR!LU!LLDD!UUR!RDDD!URR!LLDD!UUR!LLLU!RRRRD!LDD!UUUR!LLLLDDD!UURR!LLD!RRR!UR!LLLDD!UUUURRR!LLDDD!RR!LLUU!URR!LLLDD!LUU!DDDDD!URRRR!LUUUU!RDD!LLLU!\"\n assert candidate(target = \"mississippi\") == \"RRDD!UR!DD!!UU!DD!!UU!LLLDD!!UURRR!\"\n assert candidate(target = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"!!R!!R!!R!!R!!LLLLD!!R!!R!!R!!R!!LLLLD!!R!!R!!R!!R!!LLLLD!!R!!R!!R!!R!!LLLLD!!R!!R!!R!!R!!LLLLD!!\"\n assert candidate(target = \"dynamic\") == \"RRR!RDDDD!LUU!LLLUU!RRDD!UR!LU!\"\n assert candidate(target = \"programming\") == \"DDD!RR!URR!LLLU!RDD!LLUUU!RRDD!!UR!D!LLU!\"\n assert candidate(target = \"world\") == \"RRDDDD!UURR!LLD!LU!UURR!\"\n assert candidate(target = \"alphabetboardpath\") == \"!RDD!LD!UURR!LLU!R!RRR!DDD!LLLUUU!RRRDD!LLLLUU!RRDDD!UUUR!LLLDDD!UUU!RRRRDDD!LLUU!\"\n assert candidate(target = \"zzzz\") == \"DDDDD!!!!\"\n assert candidate(target = \"jump\") == \"RRRRD!LLLLDDD!UURR!LLD!\"\n assert candidate(target = \"interview\") == \"RRRD!D!RD!UUU!LLDDD!LD!UUURR!UR!LLDDDD!\"\n assert candidate(target = \"python\") == \"DDD!RRRRD!U!LLUU!RRD!L!\"\n assert candidate(target = \"qrstuvwxyzaa\") == \"RDDD!R!R!R!LLLLD!R!R!R!R!LLLLD!UUUUU!!\"\n assert candidate(target = \"xylophone\") == \"RRRDDDD!R!LLLUU!RRR!LLLLD!UURR!RRD!L!UUR!\"\n assert candidate(target = \"supercalifragilisticexpialidocious\") == \"RRRDDD!LLLD!U!UUURRRR!LLDDD!UUU!LL!RDD!URR!LLL!RRDD!LLUUU!RD!RR!LLD!URR!DD!R!LUU!LU!RR!LDDDD!LLLU!UURRR!LLLU!RDD!URR!U!RDD!LLUU!RD!RD!LLLLDD!URRR!\"\n assert candidate(target = \"quickbrownfox\") == \"RDDD!LD!UUURRR!LU!LLDD!UUR!RDDD!URR!LLDD!UUR!LLLU!RRRRD!LDD!\"\n assert candidate(target = \"complex\") == \"RR!RRDD!LL!LLD!UR!UURRR!LDDDD!\"\n assert candidate(target = \"hellozworld\") == \"RRD!URR!LLLDD!!RRR!LLLLDDD!URR!UURR!LLD!LU!UURR!\"\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyzz\") == \"!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!!\"\n assert candidate(target = \"tiger\") == \"RRRRDDD!LUU!LL!URRR!LLDDD!\"\n assert candidate(target = \"lxyzzzz\") == \"RDD!RRDD!R!LLLLD!!!!\"\n assert candidate(target = \"abcdefghiz\") == \"!R!R!R!R!LLLLD!R!R!R!LLLDDDD!\"\n assert candidate(target = \"leetcode\") == \"RDD!UURRR!!DDD!LLUUU!RRDD!LUU!R!\"\n assert candidate(target = \"xyzzyx\") == \"RRRDDDD!R!LLLLD!!URRRR!L!\"\n assert candidate(target = \"bza\") == \"R!LDDDDD!UUUUU!\"\n assert candidate(target = \"mnonmlkjihgfedcba\") == \"RRDD!R!R!L!L!L!L!URRRR!L!L!L!L!URRRR!L!L!L!L!\"\n assert candidate(target = \"algorithm\") == \"!RDD!U!RRRD!LLD!UUR!RDD!LLUU!D!\"\n assert candidate(target = \"sequence\") == \"RRRDDD!UUUR!LLLDDD!LD!UUUURRRR!LDD!LUU!RR!\"\n assert candidate(target = \"leetcodeisfun\") == \"RDD!UURRR!!DDD!LLUUU!RRDD!LUU!R!LD!DD!LLLUU!DDD!UURRR!\"\n assert candidate(target = \"programmingisfun\") == \"DDD!RR!URR!LLLU!RDD!LLUUU!RRDD!!UR!D!LLU!RR!DD!LLLUU!DDD!UURRR!\"\n assert candidate(target = \"datastructures\") == \"RRR!LLL!RRRRDDD!LLLLUUU!RRRDDD!R!LL!LLD!UUUURR!RRDDD!LLLLD!URR!UUURR!LDDD!\"\n assert candidate(target = \"zzzzzzzzzz\") == \"DDDDD!!!!!!!!!!\"\n assert candidate(target = \"example\") == \"RRRR!LDDDD!LLLUUUU!RRDD!LLD!UR!UURRR!\"\n assert candidate(target = \"mnonmonmnonmo\") == \"RRDD!R!R!L!L!RR!L!L!R!R!L!L!RR!\"\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyza\") == \"!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!R!R!R!R!LLLLD!UUUUU!\"\n assert candidate(target = \"question\") == \"RDDD!LD!UUUURRRR!LDDD!R!LUU!RD!L!\"\n", "comparison": "exact"}, "public_tests": ["\"leet\"", "\"code\""], "hints": ["Create a hashmap from letter to position on the board.", "Now for each letter, try moving there in steps, where at each step you check if it is inside the boundaries of the board."], "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().alphabetBoardPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:29+00:00", "tests_total": 103, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def alphabetBoardPath(self, target: str) -> str:", "container": "Solution", "callable": "alphabetBoardPath", "parameters": [{"name": "target", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1139, "task_id": "largest-1-bordered-square", "difficulty": "Medium", "problem_description": "Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid.\n\nExample 1:\n\nInput: grid = [[1,1,1],[1,0,1],[1,1,1]]\nOutput: 9\n\nExample 2:\n\nInput: grid = [[1,1,0,0]]\nOutput: 1\n\nConstraints:\n\n- 1 <= grid.length <= 100\n- 1 <= grid[0].length <= 100\n- grid[i][j] is 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 0, 1]]) == 1\n assert candidate(grid = [[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]]) == 25\n assert candidate(grid = [[1, 0], [0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\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, 0, 1, 0], [1, 1, 1, 1], [0, 1, 1, 0], [1, 1, 1, 1]]) == 4\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 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0]]) == 1\n assert candidate(grid = [[1, 1], [1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 1, 1, 1, 1]]) == 9\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]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1]]) == 9\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, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 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, 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]]) == 49\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1]]) == 16\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, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 64\n assert candidate(grid = [[1, 1, 0, 1, 1, 1], [1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 0, 1], [1, 1, 0, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 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(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 0, 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, 0, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(grid = [[1, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 1, 1]]) == 9\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]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 36\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 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, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 64\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 9\n assert candidate(grid = [[1, 1, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 64\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 0, 0, 1, 0, 0], [1, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0], [1, 1, 1, 1, 0, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 9\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, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 49\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0]]) == 1\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, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 81\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, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 0, 1, 0], [1, 1, 1, 0, 0, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 0, 0, 1, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 1, 0]]) == 9\n assert candidate(grid = [[1, 0, 0, 0, 0, 1, 1, 1, 0, 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, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 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, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0]]) == 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, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 4\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, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 0, 1, 0, 0, 0], [1, 1, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 0, 1], [1, 0, 0, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[1,1,1],[1,0,1],[1,1,1]]", "[[1,1,0,0]]"], "hints": ["For each square, know how many ones are up, left, down, and right of this square. You can find it in O(N^2) using dynamic programming.", "Now for each square ( O(N^3) ), we can evaluate whether that square is 1-bordered in O(1)."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largest1BorderedSquare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:32+00:00", "tests_total": 64, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def largest1BorderedSquare(self, grid: List[List[int]]) -> int:", "container": "Solution", "callable": "largest1BorderedSquare", "parameters": [{"name": "grid", "type": "List[List[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1140, "task_id": "stone-game-ii", "difficulty": "Medium", "problem_description": "Alice and Bob continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to end with the most stones.\n\nAlice and Bob take turns, with Alice starting first.\n\nOn each player's turn, that player can take all the stones in the first X remaining piles, where 1 <= X <= 2M. Then, we set M = max(M, X). Initially, M = 1.\n\nThe game continues until all the stones have been taken.\n\nAssuming Alice and Bob play optimally, return the maximum number of stones Alice can get.\n\nExample 1:\n\nInput: piles = [2,7,9,4,4]\nOutput: 10\nExplanation:\n- If Alice takes one pile at the beginning, Bob takes two piles, then Alice takes 2 piles again. Alice can get 2 + 4 + 4 = 10 stones in total.\n- If Alice takes two piles at the beginning, then Bob can take all three piles left. In this case, Alice get 2 + 7 = 9 stones in total.\n\nSo we return 10 since it's larger.\n\nExample 2:\n\nInput: piles = [1,2,3,4,5,100]\nOutput: 104\n\nConstraints:\n\n- 1 <= piles.length <= 100\n- 1 <= piles[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 2, 3, 4, 5, 100]) == 104\n assert candidate(piles = [10]) == 10\n assert candidate(piles = [100, 100, 100, 100]) == 200\n assert candidate(piles = [1, 2, 3]) == 3\n assert candidate(piles = [1, 100, 1, 100, 1, 100]) == 102\n assert candidate(piles = [3, 6, 9, 12]) == 15\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3]) == 12\n assert candidate(piles = [8, 5, 7, 3, 8, 9]) == 24\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3]) == 12\n assert candidate(piles = [10, 20, 30, 40, 50]) == 80\n assert candidate(piles = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 48\n assert candidate(piles = [5, 4, 3, 2, 1]) == 9\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(piles = [3, 3, 3, 3, 3, 3]) == 9\n assert candidate(piles = [2, 7, 9, 4, 4]) == 10\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 260\n assert candidate(piles = [1, 100, 100, 1]) == 101\n assert candidate(piles = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(piles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 57\n assert candidate(piles = [1, 2, 3, 4, 5, 100, 1, 2, 3, 4, 5, 100, 1, 2, 3, 4, 5, 100, 1, 2, 3, 4, 5, 100]) == 237\n assert candidate(piles = [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]) == 25360\n assert candidate(piles = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 128\n assert candidate(piles = [7, 14, 28, 56, 112, 224, 448, 896]) == 861\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 47\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(piles = [5, 3, 9, 1, 10, 12, 8, 7, 6, 11, 4, 2]) == 39\n assert candidate(piles = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 540\n assert candidate(piles = [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]) == 172\n assert candidate(piles = [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]) == 466\n assert candidate(piles = [3, 8, 4, 5, 12, 10]) == 17\n assert candidate(piles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 59\n assert candidate(piles = [5, 15, 20, 10, 35, 25, 40]) == 85\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 34\n assert candidate(piles = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 300\n assert candidate(piles = [5, 3, 7, 2, 9, 11, 4, 6, 8, 10, 1, 12, 14, 13]) == 54\n assert candidate(piles = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 210\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 108\n assert candidate(piles = [3, 6, 7, 10, 20, 5, 15, 25, 30, 1]) == 59\n assert candidate(piles = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 114\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 108\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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(piles = [10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 15308\n assert candidate(piles = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 300\n assert candidate(piles = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 505\n assert candidate(piles = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 3000\n assert candidate(piles = [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]) == 32\n assert candidate(piles = [3, 2, 10, 7, 8, 9, 1, 2, 10, 5]) == 28\n assert candidate(piles = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 913\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 205\n assert candidate(piles = [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]) == 140\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, 1, 1, 1, 1, 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(piles = [21, 22, 23, 24, 25, 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]) == 537\n assert candidate(piles = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 5005\n assert candidate(piles = [5, 3, 8, 9, 1, 2, 4, 6, 7, 10, 11, 12]) == 42\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]) == 163\n assert candidate(piles = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 235\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(piles = [3, 1, 5, 6, 8, 9, 2, 4, 7, 10]) == 28\n assert candidate(piles = [3, 8, 7, 2, 10, 5, 6, 4, 9, 1]) == 31\n assert candidate(piles = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 123\n assert candidate(piles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 34\n assert candidate(piles = [300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2410\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 10800\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 113\n assert candidate(piles = [100, 1, 1, 1, 100, 1, 1, 1, 100, 1]) == 204\n assert candidate(piles = [1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000]) == 15000\n assert candidate(piles = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 2300\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]) == 16\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2600\n assert candidate(piles = [50, 25, 100, 75, 200, 150, 300, 125, 350, 225, 400, 275, 450, 325, 500, 375, 550, 425, 600, 475]) == 3025\n assert candidate(piles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(piles = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 60\n assert candidate(piles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 150\n assert candidate(piles = [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]) == 86\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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 410\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 600\n assert candidate(piles = [34, 54, 74, 94, 114, 134, 154, 174, 194, 214, 234, 254, 274, 294, 314, 334, 354, 374, 394, 414, 434, 454, 474, 494, 514, 534, 554, 574, 594, 614, 634, 654, 674, 694, 714, 734, 754, 774, 794, 814, 834, 854, 874, 894, 914, 934, 954, 974, 994]) == 12668\n assert candidate(piles = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 327\n assert candidate(piles = [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, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 694\n assert candidate(piles = [5, 3, 7, 8, 4, 2, 6, 1, 9, 10, 11, 12]) == 43\n assert candidate(piles = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 288\n assert candidate(piles = [5, 1, 4, 2, 3, 6, 9, 8, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 235\n assert candidate(piles = [4, 6, 2, 8, 10, 5, 7, 3, 9, 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]) == 916\n assert candidate(piles = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 1103\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 109\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 64\n assert candidate(piles = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5, 9995, 6, 9994, 7, 9993, 8, 9992, 9, 9991, 10, 9990, 11, 9989, 12, 9988, 13, 9987, 14, 9986, 15, 9985, 16, 9984, 17, 9983, 18, 9982, 19, 9981, 20, 9980, 21, 9979, 22, 9978, 23, 9977, 24, 9976, 25, 9975, 26, 9974, 27, 9973, 28, 9972, 29, 9971, 30, 9970, 31, 9969, 32, 9968, 33, 9967, 34, 9966, 35, 9965, 36, 9964, 37, 9963, 38, 9962, 39, 9961, 40, 9960, 41, 9959, 42, 9958, 43, 9957, 44, 9956, 45, 9955, 46, 9954, 47, 9953, 48, 9952, 49, 9951, 50]) == 250050\n assert candidate(piles = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 114\n assert candidate(piles = [23, 35, 18, 41, 7, 25, 38, 13, 29, 22, 33, 3, 19, 27, 15, 32, 6, 24, 20, 21, 8, 14, 16, 30, 34, 9, 26, 17, 31, 12, 28, 10, 36, 37, 4, 5, 11, 39, 40, 2, 42]) == 470\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, 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]) == 2526\n assert candidate(piles = [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]) == 2330\n assert candidate(piles = [5, 8, 12, 21, 14, 9, 10, 4, 15, 6, 11, 3, 17, 7, 2, 13, 18, 20, 1, 16]) == 112\n", "comparison": "exact"}, "public_tests": ["[2,7,9,4,4]", "[1,2,3,4,5,100]"], "hints": ["Use dynamic programming: the states are (i, m) for the answer of piles[i:] and that given m."], "metadata": {"canonical_parameter_names": ["piles"], "leetcode_dataset_entry_point": "Solution().stoneGameII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:34+00:00", "tests_total": 96, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "minimax-algorithm", "prefix-sum", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGameII(self, piles: list[int]) -> int:", "container": "Solution", "callable": "stoneGameII", "parameters": [{"name": "piles", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1143, "task_id": "longest-common-subsequence", "difficulty": "Medium", "problem_description": "Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.\n\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\n- For example, \"ace\" is a subsequence of \"abcde\".\n\nA common subsequence of two strings is a subsequence that is common to both strings.\n\nExample 1:\n\nInput: text1 = \"abcde\", text2 = \"ace\"\nOutput: 3\nExplanation: The longest common subsequence is \"ace\" and its length is 3.\n\nExample 2:\n\nInput: text1 = \"abc\", text2 = \"abc\"\nOutput: 3\nExplanation: The longest common subsequence is \"abc\" and its length is 3.\n\nExample 3:\n\nInput: text1 = \"abc\", text2 = \"def\"\nOutput: 0\nExplanation: There is no such common subsequence, so the result is 0.\n\nConstraints:\n\n- 1 <= text1.length, text2.length <= 1000\n- text1 and text2 consist of only lowercase English characters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text1 = \"a\",text2 = \"b\") == 0\n assert candidate(text1 = \"xyz\",text2 = \"zyx\") == 1\n assert candidate(text1 = \"ezupkr\",text2 = \"ubmrapg\") == 2\n assert candidate(text1 = \"abcde\",text2 = \"ace\") == 3\n assert candidate(text1 = \"abc\",text2 = \"def\") == 0\n assert candidate(text1 = \"aabcc\",text2 = \"dbbca\") == 2\n assert candidate(text1 = \"programming\",text2 = \"gaming\") == 6\n assert candidate(text1 = \"ylqpfxxqy\",text2 = \"wxqxalnnsow\") == 2\n assert candidate(text1 = \"pqr\",text2 = \"stu\") == 0\n assert candidate(text1 = \"abcdgh\",text2 = \"aedfhr\") == 3\n assert candidate(text1 = \"hofubmnyg\",text2 = \"hvmpywxck\") == 3\n assert candidate(text1 = \"abcdef\",text2 = \"z\") == 0\n assert candidate(text1 = \"mhunuzqrkz\",text2 = \"dhlmfpnqjk\") == 4\n assert candidate(text1 = \"abcdefg\",text2 = \"abdfg\") == 5\n assert candidate(text1 = \"a\",text2 = \"a\") == 1\n assert candidate(text1 = \"xyz\",text2 = \"abc\") == 0\n assert candidate(text1 = \"psnw\",text2 = \"vozbbmloqjbpbprqs\") == 2\n assert candidate(text1 = \"abcxyz\",text2 = \"xyzabc\") == 3\n assert candidate(text1 = \"abc\",text2 = \"abc\") == 3\n assert candidate(text1 = \"abcdef\",text2 = \"zabcf\") == 4\n assert candidate(text1 = \"oxcpqrsvwf\",text2 = \"shmtulqrypy\") == 2\n assert candidate(text1 = \"abcdxyz\",text2 = \"xyzabcd\") == 4\n assert candidate(text1 = \"aaaa\",text2 = \"aa\") == 2\n assert candidate(text1 = \"aggtab\",text2 = \"gxtxayb\") == 4\n assert candidate(text1 = \"abcxyzabc\",text2 = \"xyzabcxyz\") == 6\n assert candidate(text1 = \"aaaaaa\",text2 = \"aaaaaa\") == 6\n assert candidate(text1 = \"abacdfgdcaba\",text2 = \"abacdgfdcaba\") == 11\n assert candidate(text1 = \"aabccbb\",text2 = \"dbbcbab\") == 4\n assert candidate(text1 = \"longerstringone\",text2 = \"short\") == 3\n assert candidate(text1 = \"mississippi\",text2 = \"pississippi\") == 10\n assert candidate(text1 = \"abracadabra\",text2 = \"avadakedavra\") == 7\n assert candidate(text1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",text2 = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(text1 = \"aquickbrownfoxjumpsoverthelazydog\",text2 = \"lazydog\") == 7\n assert candidate(text1 = \"abcdefghij\",text2 = \"acegik\") == 5\n assert candidate(text1 = \"abcdpqrs\",text2 = \"efghijkl\") == 0\n assert candidate(text1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",text2 = \"abcdefghi\") == 9\n assert candidate(text1 = \"xyzxyzxyz\",text2 = \"zyxzyxzyx\") == 5\n assert candidate(text1 = \"zyxwvutsrqponmlkjihgfedcba\",text2 = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(text1 = \"abcdabcdabcdabcdabcdabcdabcdabcd\",text2 = \"zyxwvutsrqponmlkjihgfedcba\") == 4\n assert candidate(text1 = \"abcdefghijklmnopqrstuvwxyz\",text2 = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(text1 = \"longestcommonsubsequence\",text2 = \"shortestsub\") == 7\n assert candidate(text1 = \"mississippi\",text2 = \"ississippi\") == 10\n assert candidate(text1 = \"aaaaabaaaabaaaabaaaa\",text2 = \"bbbaabbaabbaabbaab\") == 11\n assert candidate(text1 = \"abcdeabcdeabcde\",text2 = \"deabcdea\") == 8\n assert candidate(text1 = \"interpersonal\",text2 = \"personality\") == 8\n assert candidate(text1 = \"aaaaabbbb\",text2 = \"ababababab\") == 6\n assert candidate(text1 = \"abcdefg\",text2 = \"hijklmn\") == 0\n assert candidate(text1 = \"pqrstuvwxyzabcdefghijklmno\",text2 = \"mnopqrstuvwxyzabcdefghijkl\") == 23\n assert candidate(text1 = \"pwwkew\",text2 = \"wkepwkew\") == 5\n assert candidate(text1 = \"aaaaaaab\",text2 = \"bbbbbaaa\") == 3\n assert candidate(text1 = \"abcdexyz\",text2 = \"zyxeabcd\") == 4\n assert candidate(text1 = \"thisisaverylongstring\",text2 = \"shisivaverylongstring\") == 19\n assert candidate(text1 = \"acbdefgh\",text2 = \"bdfg\") == 4\n assert candidate(text1 = \"abc\",text2 = \"cba\") == 1\n assert candidate(text1 = \"abacabadabacaba\",text2 = \"abacabadabacab\") == 14\n assert candidate(text1 = \"abcabcabcabcabcabcabcabcabcabcabc\",text2 = \"abcabcabcabc\") == 12\n assert candidate(text1 = \"aaaabbbbcccc\",text2 = \"bbcccaabbbccc\") == 8\n assert candidate(text1 = \"aaaaabbbbbbccccccdddddeeeeeeeeeffffff\",text2 = \"dddddeeeeeeeeeccccccbbbbaaaaaa\") == 14\n assert candidate(text1 = \"aaaaaaaaaa\",text2 = \"aaaaaaaaaa\") == 10\n assert candidate(text1 = \"ab\",text2 = \"ba\") == 1\n assert candidate(text1 = \"aaaaaaabbbbbbbccccccdddddd\",text2 = \"abcde\") == 4\n assert candidate(text1 = \"ababcabcabc\",text2 = \"abcabcabc\") == 9\n assert candidate(text1 = \"abcdefghijk\",text2 = \"lmnopqrstuvwxyz\") == 0\n assert candidate(text1 = \"aabccba\",text2 = \"abcabcabc\") == 5\n assert candidate(text1 = \"abcdefghijlkmnopqrstuvwxyz\",text2 = \"zxywvutsrqponmlkjihgfedcba\") == 2\n assert candidate(text1 = \"repeatedrepeated\",text2 = \"repeated\") == 8\n assert candidate(text1 = \"abcdefghij\",text2 = \"acegikmopq\") == 5\n assert candidate(text1 = \"aabbccddeeffgghhiijj\",text2 = \"jjiihhggffeeddccbbaa\") == 2\n assert candidate(text1 = \"supercalifragilisticexpialidocious\",text2 = \"superfragilistic\") == 16\n assert candidate(text1 = \"aaaaaaabbbbbbbcccccc\",text2 = \"bbbbbbccccccdddddd\") == 12\n assert candidate(text1 = \"abcdefghigklmnopqrstuvwxyz\",text2 = \"zzzyyxxwwvvuuttrrqqppoonnmmllkkjjiihhggeeffddeeccbbbaa\") == 2\n assert candidate(text1 = \"abracadabraabracadabra\",text2 = \"alacazamalacazam\") == 10\n assert candidate(text1 = \"abcabcabcabcabcabcabcabcabcabc\",text2 = \"abcabcabc\") == 9\n assert candidate(text1 = \"abababababababababababababababab\",text2 = \"babababababababababababababababa\") == 31\n assert candidate(text1 = \"randomsequence\",text2 = \"sequence\") == 8\n assert candidate(text1 = \"abcdeabcdeabcde\",text2 = \"cdecdecdecde\") == 9\n assert candidate(text1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",text2 = \"mnopqrstuvwxyz\") == 14\n assert candidate(text1 = \"aaaaaaabaaaaaa\",text2 = \"bbbbbbbbaaaaaa\") == 7\n assert candidate(text1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\",text2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\") == 26\n assert candidate(text1 = \"abcdeabcdeabcde\",text2 = \"deabcdeabcdeabcdeab\") == 15\n assert candidate(text1 = \"abcdexyz\",text2 = \"xyzabcd\") == 4\n assert candidate(text1 = \"aaaabbbb\",text2 = \"bbaaaa\") == 4\n assert candidate(text1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",text2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 29\n assert candidate(text1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",text2 = \"ultramicroscopically\") == 18\n assert candidate(text1 = \"dynamicprogramming\",text2 = \"rhythmprogramming\") == 13\n assert candidate(text1 = \"aaaa\",text2 = \"bbbb\") == 0\n assert candidate(text1 = \"abcdpqrsabcd\",text2 = \"dcbapqrscba\") == 6\n assert candidate(text1 = \"longestcommonsubsequence\",text2 = \"shortestsubsequence\") == 15\n assert candidate(text1 = \"abacabadabacaba\",text2 = \"abacabadabacaba\") == 15\n assert candidate(text1 = \"findlongestcommonsubsequence\",text2 = \"longestsubsequence\") == 18\n assert candidate(text1 = \"xyxzyzyxyzyx\",text2 = \"zyzyxzyxzyzyxzyzyx\") == 12\n assert candidate(text1 = \"abcdefghijklnmopqrstuvwxyz\",text2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 25\n assert candidate(text1 = \"abcdefghigklmnopqrstuvwxyz\",text2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 25\n assert candidate(text1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",text2 = \"supercalifragilisticexpialidocious\") == 17\n assert candidate(text1 = \"papiermuh\",text2 = \"leidermuz\") == 5\n assert candidate(text1 = \"abcdabcdabcdabcdabcdabcdabcdabcd\",text2 = \"cdabcdabcdabcdabcdabcdabcdabcdabc\") == 31\n assert candidate(text1 = \"pwwkew\",text2 = \"wkep\") == 3\n assert candidate(text1 = \"xyxzyxyxzyx\",text2 = \"zyxzyxzyxzyx\") == 10\n assert candidate(text1 = \"xyzzaz\",text2 = \"yza\") == 3\n assert candidate(text1 = \"commonsubstring\",text2 = \"substring\") == 9\n assert candidate(text1 = \"abcde\",text2 = \"edcba\") == 1\n assert candidate(text1 = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",text2 = \"ababababcabcacacacaddaddaeaeaeafaafagagahaiai\") == 20\n assert candidate(text1 = \"abcdabcdabcd\",text2 = \"dcbaabcd\") == 6\n assert candidate(text1 = \"aaaaabaaaacaaaaadaaaaa\",text2 = \"aaabaaaaaaacaaaaaa\") == 17\n assert candidate(text1 = \"thisisaverylongstringthatshouldtestthelimits\",text2 = \"stringthatshouldtest\") == 20\n assert candidate(text1 = \"mississippi\",text2 = \"issipi\") == 6\n assert candidate(text1 = \"longestcommonsubsequence\",text2 = \"shortcommonsequence\") == 16\n assert candidate(text1 = \"abcdabcdabcd\",text2 = \"ddd\") == 3\n assert candidate(text1 = \"longestcommonsubsequence\",text2 = \"commonsubsequences\") == 17\n assert candidate(text1 = \"longstringwithnocommonsubsequence\",text2 = \"anotherlongstringwithoutcommonsubsequence\") == 32\n assert candidate(text1 = \"abcdefghijabcdefghijabcdefghij\",text2 = \"abcdefghijabcdefghij\") == 20\n assert candidate(text1 = \"lclcl\",text2 = \"clcl\") == 4\n assert candidate(text1 = \"thequickbrownfoxjumpsoverthelazydog\",text2 = \"quickbrownfoxjumpsoverthelazydo\") == 31\n assert candidate(text1 = \"longestcommonsubsequenceproblem\",text2 = \"programmingproblemsolving\") == 12\n assert candidate(text1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",text2 = \"azbycxdwevfugthsirjqkplohnmgpfnoreqmtpslknjihgfedcba\") == 17\n assert candidate(text1 = \"abcabcabcabc\",text2 = \"cbacbacbacba\") == 7\n assert candidate(text1 = \"abcdeabcdeabcdeabcdeabcdeabcdeabcde\",text2 = \"abcdeabcde\") == 10\n assert candidate(text1 = \"xyzxyzxyzxyz\",text2 = \"zyxzyxzyxzyx\") == 7\n assert candidate(text1 = \"aabaaaabaaaaabaaaabaaabaaa\",text2 = \"abaababaabaaaaabaaabaaaaabaaaab\") == 24\n assert candidate(text1 = \"qwertypasdfghjklzxcvbnm\",text2 = \"qwertyuiopasdfghjklzxcvbnm\") == 23\n assert candidate(text1 = \"aabbccddeeff\",text2 = \"abcdefabcdef\") == 7\n assert candidate(text1 = \"abcxyzdefghijklmnopqrstuvwxyz\",text2 = \"xyzabcghijklmnopqrstuvwxyzdef\") == 23\n assert candidate(text1 = \"abcdabcdabcdabcd\",text2 = \"abcabcabcabc\") == 12\n assert candidate(text1 = \"thisisatestcase\",text2 = \"testingthestcase\") == 11\n assert candidate(text1 = \"abacabadabacaba\",text2 = \"cabacabacabaca\") == 12\n assert candidate(text1 = \"dynamicprogramming\",text2 = \"longestincreasingsubsequence\") == 8\n assert candidate(text1 = \"abcdefg\",text2 = \"xyz\") == 0\n assert candidate(text1 = \"thisisatest\",text2 = \"testingthest\") == 7\n assert candidate(text1 = \"aaaaaaa\",text2 = \"aaaaaaaaa\") == 7\n assert candidate(text1 = \"longestcommonsubsequence\",text2 = \"commonsequences\") == 14\n assert candidate(text1 = \"abracadabra\",text2 = \"alacazam\") == 5\n assert candidate(text1 = \"mississippi\",text2 = \"issip\") == 5\n assert candidate(text1 = \"thisisareallylongstringthatweneedtocheck\",text2 = \"thisstringislong\") == 11\n assert candidate(text1 = \"abcdabcde\",text2 = \"abcde\") == 5\n assert candidate(text1 = \"abcdefghij\",text2 = \"jihgfedcba\") == 1\n assert candidate(text1 = \"abababababababab\",text2 = \"babababababababa\") == 15\n assert candidate(text1 = \"mississippi\",text2 = \"mississsippississippi\") == 11\n assert candidate(text1 = \"aaaaabbbbbcccc\",text2 = \"cccbbaaaa\") == 4\n", "comparison": "exact"}, "public_tests": ["\"abcde\"\n\"ace\"", "\"abc\"\n\"abc\"", "\"abc\"\n\"def\""], "hints": ["Try dynamic programming. DP[i][j] represents the longest common subsequence of text1[0 ... i] & text2[0 ... j].", "DP[i][j] = DP[i - 1][j - 1] + 1 , if text1[i] == text2[j] DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]) , otherwise"], "metadata": {"canonical_parameter_names": ["text1", "text2"], "leetcode_dataset_entry_point": "Solution().longestCommonSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:36+00:00", "tests_total": 146, "tests_dropped": 8, "flags": [], "topic_tags": ["string", "dynamic-programming", "longest-common-subsequence"]}, "language": "python", "interface": {"raw_signature": "def longestCommonSubsequence(self, text1: str, text2: str) -> int:", "container": "Solution", "callable": "longestCommonSubsequence", "parameters": [{"name": "text1", "type": "str"}, {"name": "text2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1144, "task_id": "decrease-elements-to-make-array-zigzag", "difficulty": "Medium", "problem_description": "Given an array nums of integers, a move consists of choosing any element and decreasing it by 1.\n\nAn array A is a zigzag array if either:\n\n- Every even-indexed element is greater than adjacent elements, ie. A[0] > A[1] < A[2] > A[3] < A[4] > ...\n- OR, every odd-indexed element is greater than adjacent elements, ie. A[0] < A[1] > A[2] < A[3] > A[4] < ...\n\nReturn the minimum number of moves to transform the given array nums into a zigzag array.\n\nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 2\nExplanation: We can decrease 2 to 0 or 3 to 1.\n\nExample 2:\n\nInput: nums = [9,6,1,6,2]\nOutput: 4\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 3, 2, 2, 3, 1]) == 4\n assert candidate(nums = [1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [9, 6, 1, 6, 2]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9]) == 6\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [10, 9, 4, 7, 3, 8, 15]) == 10\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 4\n assert candidate(nums = [2, 7, 10, 9, 8, 9]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [4, 3, 2, 1, 2, 3]) == 4\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, 4, 3, 2, 5]) == 4\n assert candidate(nums = [1, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1000, 1, 1000, 1, 1000]) == 0\n assert candidate(nums = [1, 1000, 1, 1000, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4]) == 3\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [10, 4, 4, 10, 10]) == 8\n assert candidate(nums = [1, 2, 3]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7]) == 6\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000]) == 2\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 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]) == 20\n assert candidate(nums = [1, 3, 2, 2, 3, 1, 4, 3]) == 4\n assert candidate(nums = [1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 9]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 0\n assert candidate(nums = [1, 4, 2, 5, 3, 6, 4, 7, 5, 8]) == 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\n assert candidate(nums = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 0\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]) == 12\n assert candidate(nums = [100, 101, 102, 101, 100, 101, 102, 101, 100, 101]) == 4\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 8\n assert candidate(nums = [3, 2, 1, 2, 3, 2, 1, 2, 3, 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]) == 10\n assert candidate(nums = [5, 3, 8, 1, 6, 2, 9, 4]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 6\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35]) == 0\n assert candidate(nums = [5, 1, 3, 1, 3, 1, 3]) == 0\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 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 6\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 5\n assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000]) == 0\n assert candidate(nums = [7, 1, 8, 2, 9, 3, 10, 4, 11, 5]) == 0\n assert candidate(nums = [4, 1, 1, 3, 2, 1, 5]) == 4\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, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 0\n assert candidate(nums = [5, 1, 3, 1, 5, 1, 3, 1, 5]) == 0\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 6\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(nums = [1, 3, 2, 2, 3, 1, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [5, 1, 4, 2, 3, 1, 3, 2, 1, 4, 5, 2, 1, 3]) == 11\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 18\n assert candidate(nums = [1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000]) == 0\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 0\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(nums = [2, 3, 1, 4, 5, 3, 6, 7, 5, 8, 9, 7]) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 12\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, 3, 2, 2, 3, 1, 4, 5, 6, 7]) == 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]) == 10\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 8, 7, 9]) == 0\n assert candidate(nums = [2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10, 11]) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums = [3, 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, 10, 3, 8, 5, 6, 7, 2, 9, 4, 11]) == 18\n assert candidate(nums = [100, 1, 101, 1, 102, 1, 103, 1, 104, 1, 105, 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]) == 18\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 8\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 2\n assert candidate(nums = [1000, 999, 1000, 999, 1000, 999, 1000]) == 0\n assert candidate(nums = [10, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9]) == 2\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 8\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]) == 10\n assert candidate(nums = [1, 3, 2, 2, 3, 1, 4, 2]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [1000, 999, 1000, 999, 1000, 999, 1000, 999]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6]) == 8\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8]) == 12\n assert candidate(nums = [8, 9, 7, 6, 7, 8, 9, 10, 11]) == 7\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1]) == 0\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\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]) == 18\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 0\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\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 = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 66\n assert candidate(nums = [7, 10, 9, 10, 7, 10, 9, 10, 7]) == 0\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 88\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 44\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [10, 1, 20, 3, 30, 5, 40, 7, 50, 9, 60, 11, 70, 13, 80, 15, 90, 17, 100, 19]) == 0\n assert candidate(nums = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 0\n assert candidate(nums = [2, 10, 3, 8, 4, 7, 5, 6, 6, 5]) == 2\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7]) == 4\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(nums = [1, 3, 2, 2, 3, 1, 4, 3, 2, 5]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(nums = [1, 3, 2, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1]) == 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]) == 99\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 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 8\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 0\n assert candidate(nums = [1, 3, 5, 3, 1, 3, 5, 3, 1]) == 6\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 10\n assert candidate(nums = [1, 3, 2, 2, 3, 1, 4, 4, 5]) == 5\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986]) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6]) == 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, 2, 1]) == 0\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, 3, 2, 1, 3, 2, 1]) == 25\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[9,6,1,6,2]"], "hints": ["Do each case (even indexed is greater, odd indexed is greater) separately. In say the even case, you should decrease each even-indexed element until it is lower than its immediate neighbors."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().movesToMakeZigzag", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:38+00:00", "tests_total": 148, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "python", "interface": {"raw_signature": "def movesToMakeZigzag(self, nums: list[int]) -> int:", "container": "Solution", "callable": "movesToMakeZigzag", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1147, "task_id": "longest-chunked-palindrome-decomposition", "difficulty": "Hard", "problem_description": "You are given a string text. You should split it to k substrings (subtext_1, subtext_2, ..., subtext_k) such that:\n\n- subtext_i is a non-empty string.\n- The concatenation of all the substrings is equal to text (i.e., subtext_1 + subtext_2 + ... + subtext_k == text).\n- subtext_i == subtext_{k - i + 1} for all valid values of i (i.e., 1 <= i <= k).\n\nReturn the largest possible value of k.\n\nExample 1:\n\nInput: text = \"ghiabcdefhelloadamhelloabcdefghi\"\nOutput: 7\nExplanation: We can split the string on \"(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)\".\n\nExample 2:\n\nInput: text = \"merchant\"\nOutput: 1\nExplanation: We can split the string on \"(merchant)\".\n\nExample 3:\n\nInput: text = \"antaprezatepzapreanta\"\nOutput: 11\nExplanation: We can split the string on \"(a)(nt)(a)(pre)(za)(tep)(za)(pre)(a)(nt)(a)\".\n\nConstraints:\n\n- 1 <= text.length <= 1000\n- text consists only of lowercase English characters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"abcabc\") == 2\n assert candidate(text = \"abcabcabc\") == 3\n assert candidate(text = \"level\") == 5\n assert candidate(text = \"zyxzyxzyx\") == 3\n assert candidate(text = \"madam\") == 5\n assert candidate(text = \"aaaaa\") == 5\n assert candidate(text = \"merchant\") == 1\n assert candidate(text = \"aabbccddeedccbbaa\") == 15\n assert candidate(text = \"repaper\") == 7\n assert candidate(text = \"ghiabcdefhelloadamhelloabcdefghi\") == 7\n assert candidate(text = \"aaa\") == 3\n assert candidate(text = \"antaprezatepzapreanta\") == 11\n assert candidate(text = \"abcdabcdabcdabcd\") == 4\n assert candidate(text = \"abacaba\") == 7\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(text = \"xyzzyx\") == 6\n assert candidate(text = \"abcddcba\") == 8\n assert candidate(text = \"rotor\") == 5\n assert candidate(text = \"abcdedcba\") == 9\n assert candidate(text = \"refer\") == 5\n assert candidate(text = \"redder\") == 6\n assert candidate(text = \"peep\") == 4\n assert candidate(text = \"abba\") == 4\n assert candidate(text = \"racecar\") == 7\n assert candidate(text = \"civic\") == 5\n assert candidate(text = \"abcdabcd\") == 2\n assert candidate(text = \"a\") == 1\n assert candidate(text = \"abcabcabcabcabcabc\") == 6\n assert candidate(text = \"xyzzyxxyzzyx\") == 12\n assert candidate(text = \"noon\") == 4\n assert candidate(text = \"deified\") == 7\n assert candidate(text = \"racecarlevelracecar\") == 19\n assert candidate(text = \"deed\") == 4\n assert candidate(text = \"abccba\") == 6\n assert candidate(text = \"abab\") == 2\n assert candidate(text = \"aabbccddeeddccbbaa\") == 18\n assert candidate(text = \"abcba\") == 5\n assert candidate(text = \"abcdeedcba\") == 10\n assert candidate(text = \"levellevel\") == 10\n assert candidate(text = \"ababababab\") == 5\n assert candidate(text = \"bananaananabayananabanana\") == 13\n assert candidate(text = \"abcdabcabcabcabcd\") == 5\n assert candidate(text = \"racecarannakayakracecar\") == 15\n assert candidate(text = \"abcabcabcabcabcabcabc\") == 7\n assert candidate(text = \"xxyyxxyyxyyxxyyxxyy\") == 5\n assert candidate(text = \"xylophonephoneyloxyxylophonephoneyloxy\") == 10\n assert candidate(text = \"leveloneleveltwolevelonelevel\") == 23\n assert candidate(text = \"aaaaabaaaabaaaa\") == 13\n assert candidate(text = \"abacababacaba\") == 13\n assert candidate(text = \"rotorcarrot\") == 3\n assert candidate(text = \"leveloneonetwothreefourthreefourtwoonelevel\") == 15\n assert candidate(text = \"aaaaabaaaabaaaaaaaabaaaaabaaaabaaaa\") == 27\n assert candidate(text = \"noonnoonnoonnoonnoonnoon\") == 24\n assert candidate(text = \"annakayakannakayakannakayakannakayakannakayak\") == 5\n assert candidate(text = \"abcdefghihgfedcbaabcdefghihgfedcba\") == 34\n assert candidate(text = \"abcdefgfedcbaabcdefgfedcbaabcdefgfedcba\") == 39\n assert candidate(text = \"abacabaabacaba\") == 14\n assert candidate(text = \"qwertyuiopasdfghjklzxcvbnmmnbvcxzlkjhgfdsapoiuytrewq\") == 52\n assert candidate(text = \"madamimadamimadam\") == 17\n assert candidate(text = \"kayak\") == 5\n assert candidate(text = \"thisisaverylongstringwhichdoesnotrepeatthisisaverylongstring\") == 3\n assert candidate(text = \"deifiedrotorcarcaretordeified\") == 21\n assert candidate(text = \"madamimadamimadamimadamimadam\") == 29\n assert candidate(text = \"noonnoonnoonnoonnoonnoonnoonnoon\") == 32\n assert candidate(text = \"deifiedrotordeified\") == 19\n assert candidate(text = \"noonracecarnoon\") == 15\n assert candidate(text = \"madamimadam\") == 11\n assert candidate(text = \"repaperdeified\") == 1\n assert candidate(text = \"deededeed\") == 9\n assert candidate(text = \"ananaananaananananananananananana\") == 15\n assert candidate(text = \"racecarlevelracecarlevelracecarlevel\") == 3\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 18\n assert candidate(text = \"racecarlevelmadamracecar\") == 15\n assert candidate(text = \"leveloneonelevel\") == 12\n assert candidate(text = \"xyzyxzyzyxzyzyxzyx\") == 15\n assert candidate(text = \"abcdefghihgfedcba\") == 17\n assert candidate(text = \"abbaabbaabbaabbaabba\") == 20\n assert candidate(text = \"abacabaabacabaabacaba\") == 21\n assert candidate(text = \"abcdabcdeedcbadcbabcd\") == 3\n assert candidate(text = \"abccbaabccba\") == 12\n assert candidate(text = \"abracadabra\") == 7\n assert candidate(text = \"madammadam\") == 10\n assert candidate(text = \"aaaaaaaaabbbbbbbbbbbbbbbccccccccccccccccccccdd\") == 1\n assert candidate(text = \"deifiedrotorleveldeified\") == 15\n assert candidate(text = \"racecarlevelracecarlevelracecarlevelracecarlevel\") == 4\n assert candidate(text = \"madaminnadammadam\") == 11\n assert candidate(text = \"leveldeifiedmadamdeifiedlevel\") == 29\n assert candidate(text = \"abacabacabacabac\") == 4\n assert candidate(text = \"aaaabbbbccccaaaabbbbcccc\") == 2\n assert candidate(text = \"noonnoonnoon\") == 12\n assert candidate(text = \"xyzyxzyzyxzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyxzyzyx\") == 33\n assert candidate(text = \"abcdefgabcdefgabcdefg\") == 3\n assert candidate(text = \"abracadabraabracadabra\") == 14\n assert candidate(text = \"civiccivic\") == 10\n assert candidate(text = \"annakayakannakayakannakayakannakayakannakayakannakayakannakayak\") == 7\n assert candidate(text = \"rotorcarrots\") == 1\n assert candidate(text = \"abracadabraacarab\") == 11\n assert candidate(text = \"kayakkayakkayak\") == 15\n assert candidate(text = \"nun\") == 3\n assert candidate(text = \"annakayakannakayakannakayak\") == 3\n assert candidate(text = \"rotorlevelrotor\") == 15\n assert candidate(text = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 2\n assert candidate(text = \"aabbccddeeddccbaa\") == 7\n assert candidate(text = \"abbaabbaabba\") == 12\n assert candidate(text = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 8\n assert candidate(text = \"levellevellevellevel\") == 20\n assert candidate(text = \"abccbaabccbaabccba\") == 18\n assert candidate(text = \"abcdeedcbaabcdeedcbaabcdeedcba\") == 30\n assert candidate(text = \"abcdefgfedcbaabcdefg\") == 3\n assert candidate(text = \"levelmadamlevel\") == 15\n assert candidate(text = \"abcabcabcabc\") == 4\n assert candidate(text = \"abacabadabacabaabacabadabacaba\") == 30\n assert candidate(text = \"rotorcarcaretor\") == 7\n assert candidate(text = \"annakayakannakayakannakayakannakayak\") == 4\n assert candidate(text = \"levellevellevellevellevellevellevellevellevellevellevellevel\") == 60\n assert candidate(text = \"levellevellevellevellevellevel\") == 30\n assert candidate(text = \"aaaaabbbbbaaaabbbbbaaaaa\") == 24\n assert candidate(text = \"abcdabcabcabcd\") == 4\n assert candidate(text = \"aaaabbbbccccbbbbaaaa\") == 20\n assert candidate(text = \"madamimadamimadamimadamimadamimadamimadamimadam\") == 47\n assert candidate(text = \"abcdxyzyxzyxcddcbaabcdxyzyxzyxcddcba\") == 18\n assert candidate(text = \"abacabadabacabadabacaba\") == 23\n assert candidate(text = \"deifieddeified\") == 14\n assert candidate(text = \"deifiedracecardeified\") == 21\n assert candidate(text = \"noonnoonnoonnoon\") == 16\n assert candidate(text = \"radar\") == 5\n assert candidate(text = \"abacabadabacaba\") == 15\n assert candidate(text = \"annakayakannakayak\") == 2\n assert candidate(text = \"abcdabcdefgabcdefgdcba\") == 10\n assert candidate(text = \"racecarannakayak\") == 1\n assert candidate(text = \"abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 44\n assert candidate(text = \"abacabadabacabad\") == 2\n assert candidate(text = \"rotorrotor\") == 10\n assert candidate(text = \"abcabcabcabcabc\") == 5\n assert candidate(text = \"abracadabracadabra\") == 11\n assert candidate(text = \"levellevellevellevellevel\") == 25\n assert candidate(text = \"aaaaaabaaaaa\") == 11\n assert candidate(text = \"aabbccddeedcbaabbccdd\") == 3\n assert candidate(text = \"hellohellobellohellobellohello\") == 4\n assert candidate(text = \"xyzzxyzzxyzz\") == 3\n assert candidate(text = \"xxyyzzzyyxxyyyzzzzyyxx\") == 15\n assert candidate(text = \"aabbccddeeeedddccbbaaa\") == 5\n assert candidate(text = \"deifiedrotor\") == 1\n assert candidate(text = \"abcdeedcbaabcdeedcba\") == 20\n assert candidate(text = \"abababababababab\") == 8\n assert candidate(text = \"abacabaabacabaabacabaabacaba\") == 28\n assert candidate(text = \"aaaabbbbccccddddeeeeffffeeeeggggccccbbbbaaaaffff\") == 1\n assert candidate(text = \"wow\") == 3\n assert candidate(text = \"abcdabccbaabcd\") == 8\n assert candidate(text = \"abcabcabcabcabcabcabcd\") == 1\n assert candidate(text = \"abcxyzzyxcba\") == 12\n assert candidate(text = \"racecarlevelracecarlevelracecarlevelracecarlevelracecarlevel\") == 5\n assert candidate(text = \"madamimadamimadamimadamimadamimadam\") == 35\n assert candidate(text = \"noonabbadacabbaaddaabbnoon\") == 15\n assert candidate(text = \"xyzzyxzyxzyxzyxzyxzyxzyxyz\") == 15\n assert candidate(text = \"levellevellevellevellevellevellevellevel\") == 40\n assert candidate(text = \"abababababababababababab\") == 12\n assert candidate(text = \"mississippiississimississimississippi\") == 17\n assert candidate(text = \"aabbccddeedcba\") == 3\n assert candidate(text = \"xyzyxzyzyxzyx\") == 11\n assert candidate(text = \"aaaaabaaa\") == 7\n assert candidate(text = \"abcdcdeabcdcdeabcdcdeabcd\") == 7\n assert candidate(text = \"racecarracecar\") == 14\n assert candidate(text = \"rotorrotorrotor\") == 15\n assert candidate(text = \"racecarlevelracecarlevel\") == 2\n assert candidate(text = \"kayakkayak\") == 10\n assert candidate(text = \"noonnoon\") == 8\n assert candidate(text = \"racecarlevelmadamracecarlevelmadam\") == 2\n assert candidate(text = \"abcxyzzyxcbaabcxyzzyxcba\") == 24\n assert candidate(text = \"redividerrotorredivider\") == 23\n assert candidate(text = \"ababababababababababababababababab\") == 17\n assert candidate(text = \"referrefer\") == 10\n assert candidate(text = \"noonnoonnoonnoonnoonnoonnoonnoonnoonnoon\") == 40\n assert candidate(text = \"madamimadamimadamimadam\") == 23\n assert candidate(text = \"abbaabbaabbaabba\") == 16\n assert candidate(text = \"mississippi\") == 1\n assert candidate(text = \"aabbccddeedccbbaaa\") == 5\n assert candidate(text = \"abcdeabcdeabcde\") == 3\n assert candidate(text = \"racecarracecarracecar\") == 21\n assert candidate(text = \"redivider\") == 9\n assert candidate(text = \"thisisaverylongstringwithnorepeatedpattern\") == 1\n", "comparison": "exact"}, "public_tests": ["\"ghiabcdefhelloadamhelloabcdefghi\"", "\"merchant\"", "\"antaprezatepzapreanta\""], "hints": ["Using a rolling hash, we can quickly check whether two strings are equal.", "Use that as the basis of a dp."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().longestDecomposition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:43+00:00", "tests_total": 181, "tests_dropped": 0, "flags": [], "topic_tags": ["two-pointers", "string", "dynamic-programming", "greedy", "rolling-hash", "hash-function"]}, "language": "python", "interface": {"raw_signature": "def longestDecomposition(self, text: str) -> int:", "container": "Solution", "callable": "longestDecomposition", "parameters": [{"name": "text", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1154, "task_id": "day-of-the-year", "difficulty": "Easy", "problem_description": "Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.\n\nExample 1:\n\nInput: date = \"2019-01-09\"\nOutput: 9\nExplanation: Given date is the 9th day of the year in 2019.\n\nExample 2:\n\nInput: date = \"2019-02-10\"\nOutput: 41\n\nConstraints:\n\n- date.length == 10\n- date[4] == date[7] == '-', and all other date[i]'s are digits\n- date represents a calendar date between Jan 1^st, 1900 and Dec 31^st, 2019.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date = \"2017-03-01\") == 60\n assert candidate(date = \"2019-01-09\") == 9\n assert candidate(date = \"1900-02-28\") == 59\n assert candidate(date = \"2000-03-01\") == 61\n assert candidate(date = \"2018-08-20\") == 232\n assert candidate(date = \"2019-06-30\") == 181\n assert candidate(date = \"1900-12-31\") == 365\n assert candidate(date = \"2019-06-15\") == 166\n assert candidate(date = \"2019-02-10\") == 41\n assert candidate(date = \"1901-01-01\") == 1\n assert candidate(date = \"2000-02-29\") == 60\n assert candidate(date = \"2019-11-15\") == 319\n assert candidate(date = \"2019-05-25\") == 145\n assert candidate(date = \"2019-12-31\") == 365\n assert candidate(date = \"2016-03-01\") == 61\n assert candidate(date = \"2021-01-01\") == 1\n assert candidate(date = \"2018-08-22\") == 234\n assert candidate(date = \"2020-02-29\") == 60\n assert candidate(date = \"1900-01-01\") == 1\n assert candidate(date = \"2016-02-29\") == 60\n assert candidate(date = \"2019-07-17\") == 198\n assert candidate(date = \"1999-02-28\") == 59\n assert candidate(date = \"2019-12-15\") == 349\n assert candidate(date = \"2019-09-05\") == 248\n assert candidate(date = \"2019-06-21\") == 172\n assert candidate(date = \"2023-02-28\") == 59\n assert candidate(date = \"2020-12-31\") == 366\n assert candidate(date = \"2018-06-30\") == 181\n assert candidate(date = \"2019-09-30\") == 273\n assert candidate(date = \"2019-07-25\") == 206\n assert candidate(date = \"2023-01-01\") == 1\n assert candidate(date = \"2019-10-15\") == 288\n assert candidate(date = \"2019-08-15\") == 227\n assert candidate(date = \"2004-02-29\") == 60\n assert candidate(date = \"2018-03-15\") == 74\n assert candidate(date = \"2019-03-01\") == 60\n assert candidate(date = \"2019-07-18\") == 199\n assert candidate(date = \"2019-12-19\") == 353\n assert candidate(date = \"2019-03-20\") == 79\n assert candidate(date = \"2021-12-31\") == 365\n assert candidate(date = \"1996-06-30\") == 182\n assert candidate(date = \"2019-08-05\") == 217\n assert candidate(date = \"2019-06-25\") == 176\n assert candidate(date = \"1900-03-01\") == 60\n assert candidate(date = \"2019-12-20\") == 354\n assert candidate(date = \"2018-03-01\") == 60\n assert candidate(date = \"2024-02-29\") == 60\n assert candidate(date = \"2019-12-05\") == 339\n assert candidate(date = \"2019-06-05\") == 156\n assert candidate(date = \"2001-02-28\") == 59\n assert candidate(date = \"2017-04-30\") == 120\n assert candidate(date = \"2018-02-28\") == 59\n assert candidate(date = \"2019-01-01\") == 1\n assert candidate(date = \"2017-01-01\") == 1\n assert candidate(date = \"2019-05-31\") == 151\n assert candidate(date = \"2016-12-31\") == 366\n assert candidate(date = \"2019-10-10\") == 283\n assert candidate(date = \"2012-06-17\") == 169\n assert candidate(date = \"2024-06-30\") == 182\n assert candidate(date = \"2000-02-28\") == 59\n assert candidate(date = \"2019-04-25\") == 115\n assert candidate(date = \"2004-03-01\") == 61\n assert candidate(date = \"2023-12-31\") == 365\n assert candidate(date = \"1987-07-04\") == 185\n assert candidate(date = \"2019-06-10\") == 161\n assert candidate(date = \"2019-10-31\") == 304\n assert candidate(date = \"2019-08-10\") == 222\n assert candidate(date = \"2019-01-31\") == 31\n assert candidate(date = \"2019-12-30\") == 364\n assert candidate(date = \"2018-07-24\") == 205\n assert candidate(date = \"2020-01-01\") == 1\n assert candidate(date = \"2019-07-10\") == 191\n assert candidate(date = \"2019-02-28\") == 59\n assert candidate(date = \"2019-08-22\") == 234\n assert candidate(date = \"2023-03-01\") == 60\n assert candidate(date = \"2019-11-10\") == 314\n assert candidate(date = \"2021-11-11\") == 315\n assert candidate(date = \"2024-02-28\") == 59\n assert candidate(date = \"2021-03-01\") == 60\n assert candidate(date = \"2019-10-05\") == 278\n assert candidate(date = \"1955-10-31\") == 304\n assert candidate(date = \"2020-02-28\") == 59\n assert candidate(date = \"2019-12-01\") == 335\n assert candidate(date = \"2019-05-15\") == 135\n assert candidate(date = \"1899-12-31\") == 365\n assert candidate(date = \"2000-01-01\") == 1\n assert candidate(date = \"2100-02-28\") == 59\n assert candidate(date = \"1904-02-28\") == 59\n assert candidate(date = \"2019-03-30\") == 89\n assert candidate(date = \"1999-12-31\") == 365\n assert candidate(date = \"2019-11-30\") == 334\n assert candidate(date = \"2012-02-29\") == 60\n assert candidate(date = \"2019-07-15\") == 196\n assert candidate(date = \"2019-04-30\") == 120\n assert candidate(date = \"2019-08-31\") == 243\n assert candidate(date = \"1904-12-31\") == 366\n assert candidate(date = \"2020-07-15\") == 197\n assert candidate(date = \"2019-09-27\") == 270\n assert candidate(date = \"2019-01-02\") == 2\n assert candidate(date = \"1916-04-15\") == 106\n assert candidate(date = \"2019-03-31\") == 90\n assert candidate(date = \"2024-03-01\") == 61\n assert candidate(date = \"2019-05-20\") == 140\n assert candidate(date = \"2018-08-31\") == 243\n assert candidate(date = \"1904-02-29\") == 60\n assert candidate(date = \"2019-04-01\") == 91\n assert candidate(date = \"2019-11-20\") == 324\n assert candidate(date = \"2019-09-15\") == 258\n assert candidate(date = \"2019-10-12\") == 285\n assert candidate(date = \"2019-09-10\") == 253\n assert candidate(date = \"2019-12-25\") == 359\n assert candidate(date = \"2019-11-01\") == 305\n assert candidate(date = \"2019-08-09\") == 221\n assert candidate(date = \"2019-03-25\") == 84\n assert candidate(date = \"2020-03-01\") == 61\n assert candidate(date = \"2019-12-10\") == 344\n assert candidate(date = \"2019-11-05\") == 309\n assert candidate(date = \"2019-07-31\") == 212\n assert candidate(date = \"2019-11-08\") == 312\n", "comparison": "exact"}, "public_tests": ["\"2019-01-09\"", "\"2019-02-10\""], "hints": ["Have a integer array of how many days there are per month. February gets one extra day if its a leap year. Then, we can manually count the ordinal as day + (number of days in months before this one)."], "metadata": {"canonical_parameter_names": ["date"], "leetcode_dataset_entry_point": "Solution().dayOfYear", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:54+00:00", "tests_total": 119, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def dayOfYear(self, date: str) -> int:", "container": "Solution", "callable": "dayOfYear", "parameters": [{"name": "date", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1155, "task_id": "number-of-dice-rolls-with-target-sum", "difficulty": "Medium", "problem_description": "You have n dice, and each dice has k faces numbered from 1 to k.\n\nGiven three integers n, k, and target, return the number of possible ways (out of the k^n total ways) to roll the dice, so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 1, k = 6, target = 3\nOutput: 1\nExplanation: You throw one die with 6 faces.\nThere is only one way to get a sum of 3.\n\nExample 2:\n\nInput: n = 2, k = 6, target = 7\nOutput: 6\nExplanation: You throw two dice, each with 6 faces.\nThere are 6 ways to get a sum of 7: 1+6, 2+5, 3+4, 4+3, 5+2, 6+1.\n\nExample 3:\n\nInput: n = 30, k = 30, target = 500\nOutput: 222616187\nExplanation: The answer must be returned modulo 10^9 + 7.\n\nConstraints:\n\n- 1 <= n, k <= 30\n- 1 <= target <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,k = 10,target = 100) == 794915145\n assert candidate(n = 4,k = 6,target = 12) == 125\n assert candidate(n = 30,k = 30,target = 500) == 222616187\n assert candidate(n = 2,k = 6,target = 7) == 6\n assert candidate(n = 10,k = 5,target = 30) == 856945\n assert candidate(n = 3,k = 4,target = 8) == 12\n assert candidate(n = 3,k = 2,target = 5) == 3\n assert candidate(n = 5,k = 4,target = 10) == 101\n assert candidate(n = 1,k = 6,target = 3) == 1\n assert candidate(n = 2,k = 2,target = 3) == 2\n assert candidate(n = 15,k = 4,target = 40) == 83372562\n assert candidate(n = 10,k = 10,target = 50) == 374894389\n assert candidate(n = 5,k = 5,target = 10) == 121\n assert candidate(n = 5,k = 10,target = 15) == 996\n assert candidate(n = 3,k = 2,target = 4) == 3\n assert candidate(n = 25,k = 20,target = 400) == 239696222\n assert candidate(n = 10,k = 5,target = 25) == 473694\n assert candidate(n = 18,k = 8,target = 100) == 428096078\n assert candidate(n = 26,k = 10,target = 130) == 900662957\n assert candidate(n = 28,k = 20,target = 250) == 754162082\n assert candidate(n = 30,k = 30,target = 800) == 740208408\n assert candidate(n = 29,k = 13,target = 385) == 0\n assert candidate(n = 15,k = 5,target = 60) == 49360405\n assert candidate(n = 27,k = 18,target = 380) == 570408071\n assert candidate(n = 27,k = 11,target = 243) == 976265632\n assert candidate(n = 14,k = 7,target = 98) == 1\n assert candidate(n = 12,k = 15,target = 120) == 545528539\n assert candidate(n = 25,k = 6,target = 100) == 165343714\n assert candidate(n = 19,k = 14,target = 260) == 134596\n assert candidate(n = 15,k = 8,target = 120) == 1\n assert candidate(n = 30,k = 5,target = 125) == 699555125\n assert candidate(n = 30,k = 12,target = 200) == 740079054\n assert candidate(n = 25,k = 10,target = 150) == 166392150\n assert candidate(n = 26,k = 12,target = 200) == 768259128\n assert candidate(n = 17,k = 9,target = 145) == 735471\n assert candidate(n = 22,k = 14,target = 280) == 879336869\n assert candidate(n = 27,k = 11,target = 220) == 441656611\n assert candidate(n = 30,k = 10,target = 150) == 793899040\n assert candidate(n = 16,k = 11,target = 105) == 811426869\n assert candidate(n = 30,k = 10,target = 250) == 128709914\n assert candidate(n = 22,k = 9,target = 180) == 44386487\n assert candidate(n = 28,k = 15,target = 350) == 471189138\n assert candidate(n = 15,k = 10,target = 150) == 1\n assert candidate(n = 30,k = 5,target = 90) == 337060208\n assert candidate(n = 18,k = 10,target = 150) == 182972231\n assert candidate(n = 29,k = 25,target = 400) == 266275143\n assert candidate(n = 30,k = 6,target = 150) == 37027173\n assert candidate(n = 24,k = 9,target = 155) == 405028518\n assert candidate(n = 18,k = 7,target = 120) == 100947\n assert candidate(n = 22,k = 7,target = 120) == 404679730\n assert candidate(n = 18,k = 8,target = 120) == 747503719\n assert candidate(n = 24,k = 14,target = 160) == 26411763\n assert candidate(n = 20,k = 15,target = 250) == 504797596\n assert candidate(n = 30,k = 6,target = 100) == 449826955\n assert candidate(n = 24,k = 15,target = 300) == 688942594\n assert candidate(n = 27,k = 11,target = 170) == 11802847\n assert candidate(n = 19,k = 9,target = 125) == 406671426\n assert candidate(n = 12,k = 7,target = 84) == 1\n assert candidate(n = 20,k = 20,target = 200) == 270319085\n assert candidate(n = 10,k = 15,target = 150) == 1\n assert candidate(n = 26,k = 9,target = 180) == 843161626\n assert candidate(n = 16,k = 6,target = 80) == 248705155\n assert candidate(n = 12,k = 3,target = 30) == 8074\n assert candidate(n = 18,k = 8,target = 150) == 0\n assert candidate(n = 22,k = 10,target = 155) == 612108463\n assert candidate(n = 22,k = 15,target = 180) == 215154082\n assert candidate(n = 28,k = 12,target = 200) == 507319147\n assert candidate(n = 20,k = 8,target = 100) == 891516101\n assert candidate(n = 28,k = 9,target = 252) == 1\n assert candidate(n = 20,k = 8,target = 160) == 1\n assert candidate(n = 20,k = 20,target = 350) == 690236765\n assert candidate(n = 25,k = 12,target = 150) == 800893074\n assert candidate(n = 12,k = 12,target = 75) == 6445237\n assert candidate(n = 30,k = 12,target = 360) == 1\n assert candidate(n = 19,k = 13,target = 221) == 611881535\n assert candidate(n = 20,k = 20,target = 400) == 1\n assert candidate(n = 28,k = 6,target = 100) == 333372447\n assert candidate(n = 14,k = 7,target = 90) == 203294\n assert candidate(n = 25,k = 6,target = 120) == 253411631\n assert candidate(n = 18,k = 6,target = 100) == 1078497\n assert candidate(n = 16,k = 7,target = 80) == 150185177\n assert candidate(n = 29,k = 7,target = 195) == 30259499\n assert candidate(n = 27,k = 30,target = 800) == 254186856\n assert candidate(n = 19,k = 25,target = 450) == 359043931\n assert candidate(n = 20,k = 10,target = 150) == 366736536\n assert candidate(n = 28,k = 12,target = 250) == 782356560\n assert candidate(n = 30,k = 25,target = 750) == 1\n assert candidate(n = 12,k = 7,target = 85) == 0\n assert candidate(n = 30,k = 25,target = 400) == 656098604\n assert candidate(n = 22,k = 9,target = 175) == 592474733\n assert candidate(n = 22,k = 8,target = 160) == 781347627\n assert candidate(n = 28,k = 18,target = 450) == 94890353\n assert candidate(n = 20,k = 15,target = 350) == 0\n assert candidate(n = 24,k = 18,target = 360) == 517019157\n assert candidate(n = 18,k = 12,target = 250) == 0\n assert candidate(n = 22,k = 15,target = 170) == 332380631\n assert candidate(n = 14,k = 20,target = 180) == 267746915\n assert candidate(n = 22,k = 6,target = 132) == 1\n assert candidate(n = 27,k = 18,target = 350) == 91344166\n assert candidate(n = 12,k = 12,target = 100) == 201258020\n assert candidate(n = 17,k = 9,target = 130) == 241842734\n assert candidate(n = 25,k = 15,target = 300) == 861212713\n assert candidate(n = 18,k = 7,target = 90) == 183069607\n assert candidate(n = 25,k = 20,target = 300) == 161591689\n assert candidate(n = 20,k = 10,target = 180) == 522663924\n assert candidate(n = 28,k = 15,target = 300) == 813819263\n assert candidate(n = 22,k = 7,target = 130) == 712806895\n assert candidate(n = 30,k = 20,target = 500) == 541650286\n", "comparison": "exact"}, "public_tests": ["1\n6\n3", "2\n6\n7", "30\n30\n500"], "hints": ["Use dynamic programming. The states are how many dice are remaining, and what sum total you have rolled so far."], "metadata": {"canonical_parameter_names": ["n", "k", "target"], "leetcode_dataset_entry_point": "Solution().numRollsToTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:56+00:00", "tests_total": 108, "tests_dropped": 0, "flags": [], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numRollsToTarget(self, n: int, k: int, target: int) -> int:", "container": "Solution", "callable": "numRollsToTarget", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1156, "task_id": "swap-for-longest-repeated-character-substring", "difficulty": "Medium", "problem_description": "You are given a string text. You can swap two of the characters in the text.\n\nReturn the length of the longest substring with repeated characters.\n\nExample 1:\n\nInput: text = \"ababa\"\nOutput: 3\nExplanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is \"aaa\" with length 3.\n\nExample 2:\n\nInput: text = \"aaabaaa\"\nOutput: 6\nExplanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring \"aaaaaa\" with length 6.\n\nExample 3:\n\nInput: text = \"aaaaa\"\nOutput: 5\nExplanation: No need to swap, longest repeated character substring is \"aaaaa\" with length is 5.\n\nConstraints:\n\n- 1 <= text.length <= 2 * 10^4\n- text consist of lowercase English characters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"ababababab\") == 3\n assert candidate(text = \"abababababababab\") == 3\n assert candidate(text = \"ababa\") == 3\n assert candidate(text = \"aaaaa\") == 5\n assert candidate(text = \"zzzzzzzzzz\") == 10\n assert candidate(text = \"aabbccddeeffgg\") == 2\n assert candidate(text = \"aabbccdd\") == 2\n assert candidate(text = \"abacabadabacaba\") == 3\n assert candidate(text = \"abbcccddddeeefffggghhh\") == 4\n assert candidate(text = \"zzzxxzzz\") == 4\n assert candidate(text = \"aabbaa\") == 3\n assert candidate(text = \"ababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 3\n assert candidate(text = \"abcdefgabcdefgabcdefg\") == 2\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 106\n assert candidate(text = \"abcdabcabc\") == 2\n assert candidate(text = \"abbcccddddeee\") == 4\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzz\") == 20\n assert candidate(text = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 3\n assert candidate(text = \"ababcababcab\") == 3\n assert candidate(text = \"aabbccddeeffgghhii\") == 2\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(text = \"aaabaaa\") == 6\n assert candidate(text = \"aabacaaa\") == 5\n assert candidate(text = \"abcdefgabcdefg\") == 2\n assert candidate(text = \"abcde\") == 1\n assert candidate(text = \"aaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaab\") == 4\n assert candidate(text = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(text = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 3\n assert candidate(text = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\") == 4\n assert candidate(text = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 2\n assert candidate(text = \"abababababababababababababab\") == 3\n assert candidate(text = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadaba\") == 3\n assert candidate(text = \"aabbccccaaaabbccccaaaabbccccaaaabbccccaaaabbccccaaaabbccccaaaabbccccaaaabbccccaaaabbccccaaaa\") == 5\n assert candidate(text = \"abacabadabacab\") == 3\n assert candidate(text = \"aabbccccddddddaaaabbbcccc\") == 6\n assert candidate(text = \"abracadabraabracadabraabracadabra\") == 3\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 2\n assert candidate(text = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddaaaaaaaaaabbbbbbbbbbccccccccccddddddddddaaaaaaaaaabbbbbbbbbb\") == 11\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvuutsrqponmlkjihgfedcba\") == 3\n assert candidate(text = \"abababababababababababababababababababababababababababababababababababababababababababababab\") == 3\n assert candidate(text = \"xyzyxyzyxyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\") == 3\n assert candidate(text = \"aaaaabbbbbbccccccdddddeeeeeffffffffgggggghhhhhhiiiiiiijjjjjjkkkkkkklllllllmmmmmmmnnnnnnnooooooo\") == 8\n assert candidate(text = \"aabccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccbaabbccba\") == 3\n assert candidate(text = \"aabbaabbaaabbbaabbaabbaabb\") == 4\n assert candidate(text = \"qqqqwweerrttyyuiioopplkkjjhhggffddssaazzzxxxxccvvbbnmm\") == 4\n assert candidate(text = \"aabbaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 3\n assert candidate(text = \"ppppooooiiiiuuuueeeeooooooooaaaaaaaaaaaaaaaaaabbbbbbbbbbbb\") == 18\n assert candidate(text = \"abccbaabccbaabccbaabccba\") == 3\n assert candidate(text = \"abcabcabcabcabcabc\") == 2\n assert candidate(text = \"abcdabcabcdabcabcdabcabcd\") == 2\n assert candidate(text = \"aabbaaabbbaaabbaabbbaa\") == 4\n assert candidate(text = \"aabbbccddddeeefffggg\") == 4\n assert candidate(text = \"aabbaaabbbaaaabbbbaaabbbbaaaabbbbaaabbbbaaaabbbbaaabbbbaaaabbbbaaabbbbaaaabbbbaaabbbbaaaabb\") == 5\n assert candidate(text = \"xyzzzzzzzzzzzzzyxzzzzzzzzzzzzzyx\") == 14\n assert candidate(text = \"abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde\") == 2\n assert candidate(text = \"abcdeedcbaedcbaedcba\") == 3\n", "comparison": "exact"}, "public_tests": ["\"bbaababbba\"", "\"bbabbbbbaaba\"", "\"abaaaaabbbbbaa\""], "hints": ["There are two cases: a block of characters, or two blocks of characters between one different character. By keeping a run-length encoded version of the string, we can easily check these cases."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().maxRepOpt1", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:11:58+00:00", "tests_total": 56, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maxRepOpt1(self, text: str) -> int:", "container": "Solution", "callable": "maxRepOpt1", "parameters": [{"name": "text", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1160, "task_id": "find-words-that-can-be-formed-by-characters", "difficulty": "Easy", "problem_description": "You are given an array of strings words and a string chars.\n\nA string is good if it can be formed by characters from chars (each character can only be used once for each word in words).\n\nReturn the sum of lengths of all good strings in words.\n\nExample 1:\n\nInput: words = [\"cat\",\"bt\",\"hat\",\"tree\"], chars = \"atach\"\nOutput: 6\nExplanation: The strings that can be formed are \"cat\" and \"hat\" so the answer is 3 + 3 = 6.\n\nExample 2:\n\nInput: words = [\"hello\",\"world\",\"leetcode\"], chars = \"welldonehoneyr\"\nOutput: 10\nExplanation: The strings that can be formed are \"hello\" and \"world\" so the answer is 5 + 5 = 10.\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length, chars.length <= 100\n- words[i] and chars consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abcd', 'ab', 'bc', 'cd'],chars = \"abcd\") == 10\n assert candidate(words = ['cat', 'bt', 'hat', 'tree'],chars = \"atach\") == 6\n assert candidate(words = ['zxcvbnm', 'asdfghjkl', 'qwertyuiop'],chars = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(words = ['abc', 'def', 'ghi'],chars = \"abcdefghi\") == 9\n assert candidate(words = ['xyz', 'zyx', 'wxy'],chars = \"xyzzyxw\") == 9\n assert candidate(words = ['apple', 'banana', 'cherry'],chars = \"abc\") == 0\n assert candidate(words = ['abc', 'abc', 'abc'],chars = \"aabbcc\") == 9\n assert candidate(words = ['test', 'case', 'word'],chars = \"tcws\") == 0\n assert candidate(words = ['a', 'b', 'c'],chars = \"abcde\") == 3\n assert candidate(words = ['a', 'b', 'c'],chars = \"abcabcabc\") == 3\n assert candidate(words = ['abcd', 'dcba', 'abcd'],chars = \"abcd\") == 12\n assert candidate(words = ['hello', 'world', 'leetcode'],chars = \"welldonehoneyr\") == 10\n assert candidate(words = ['zzz', 'yyy', 'xxx'],chars = \"zyxzyx\") == 0\n assert candidate(words = ['one', 'two', 'three'],chars = \"onetwothree\") == 11\n assert candidate(words = ['zzz', 'yyy', 'xxx'],chars = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(words = ['a', 'b', 'c'],chars = \"abc\") == 3\n assert candidate(words = ['apple', 'apple', 'apple'],chars = \"ppale\") == 15\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa'],chars = \"aaaaa\") == 10\n assert candidate(words = ['aabbcc', 'abc', 'abc'],chars = \"aabbcc\") == 12\n assert candidate(words = ['aaa', 'bbb', 'ccc'],chars = \"aabbcc\") == 0\n assert candidate(words = ['abcd', 'efgh', 'ijkl'],chars = \"abcdefgh\") == 8\n assert candidate(words = ['aaa', 'bbb', 'ccc'],chars = \"abc\") == 0\n assert candidate(words = ['apple', 'banana', 'cherry'],chars = \"abcde\") == 0\n assert candidate(words = ['test', 'code', 'contest'],chars = \"testcode\") == 8\n assert candidate(words = ['challenge', 'python', 'code', 'fun'],chars = \"nclhpgfouitay\") == 9\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(words = ['programming', 'language', 'python', 'java'],chars = \"npgmajoasrivl\") == 4\n assert candidate(words = ['banana', 'ananas', 'panama', 'manana'],chars = \"anamnb\") == 0\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'ddee', 'eeff', 'ffgg', 'gghh', 'hhiijj', 'kkll', 'mmnn', 'oorr', 'ppqq', 'sstt', 'uuvv', 'wwxx', 'yyzz'],chars = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 66\n assert candidate(words = ['complex', 'words', 'here'],chars = \"owcpxlehre\") == 4\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abacax'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],chars = \"oentwfhivxsg\") == 21\n assert candidate(words = ['xxyyzz', 'yyzzxx', 'zzxxyy'],chars = \"xyzxyz\") == 18\n assert candidate(words = ['aabbccddeeff', 'aabbccddeeffgg', 'aabbccddeeffgghh', 'aabbccddeeffgghhiijj'],chars = \"aabbccddeeffgghhiijj\") == 62\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z'],chars = \"zzzzzzzzzz\") == 10\n assert candidate(words = ['xylophone', 'guitar', 'drum', 'bassoon', 'violin'],chars = \"guitardrumxyz\") == 10\n assert candidate(words = ['leetcode', 'challenge', 'contest', 'question'],chars = \"oelhctganegqisun\") == 8\n assert candidate(words = ['abacax', 'banana', 'grape'],chars = \"aaabbnagpr\") == 0\n assert candidate(words = ['ab', 'ba', 'abc', 'bca', 'acb', 'cab', 'cba', 'bac', 'bca', 'acb', 'cab', 'cba', 'bac', 'bca', 'acb', 'cab', 'cba', 'bac', 'bca', 'acb', 'cab', 'cba', 'bac', 'bca', 'acb', 'cab', 'cba', 'bac', 'bca', 'acb', 'cab', 'cba'],chars = \"abc\") == 94\n assert candidate(words = ['alibaba', 'babala', 'baliba', 'lalala'],chars = \"balibalab\") == 19\n assert candidate(words = ['aabbcc', 'bbccdd', 'aaccdd'],chars = \"aabbbccdd\") == 18\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'hgfedcb', 'fedcbghij'],chars = \"abcdefghij\") == 36\n assert candidate(words = ['aabbccddeeffgg', 'bbccddeeffgghh', 'ccddeeffgghhiijj'],chars = \"abcdefghij\") == 0\n assert candidate(words = ['algorithm', 'data', 'structure', 'binary', 'search'],chars = \"lgarithmtdastrucetubynrseahc\") == 25\n assert candidate(words = ['abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefghijk'],chars = \"abcdefghij\") == 27\n assert candidate(words = ['abcdabcd', 'dcbaabcd', 'abcd', 'abcd'],chars = \"abcdabcd\") == 24\n assert candidate(words = ['programming', 'challenge', 'difficulty', 'algorithm'],chars = \"progaminld\") == 0\n assert candidate(words = ['aabbcc', 'aabbc', 'aabb', 'aa', 'a'],chars = \"aabbbcccc\") == 18\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(words = ['multiple', 'words', 'with', 'same', 'letters'],chars = \"mlpuwihswtael\") == 16\n assert candidate(words = ['abcd', 'abcde', 'abcdef'],chars = \"abcdefg\") == 15\n assert candidate(words = ['hello', 'world', 'python', 'programming'],chars = \"helloworldpython\") == 16\n assert candidate(words = ['abc', 'abcd', 'abcde', 'abcdef', 'abcdefg'],chars = \"abcdefg\") == 25\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'zz', 'yy', 'xx'],chars = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 58\n assert candidate(words = ['optimization', 'algorithm', 'datastructure'],chars = \"odginatrlhms\") == 9\n assert candidate(words = ['short', 'longerword', 'evenlonger', 'longestword', 'tiny'],chars = \"longestword\") == 11\n assert candidate(words = ['algorithm', 'data', 'structure'],chars = \"algorithmdstuct\") == 9\n assert candidate(words = ['aabbcc', 'abcabc', 'abacbc'],chars = \"aabbcc\") == 18\n assert candidate(words = ['aabbccddeeff', 'gghhiijjkk', 'llmmnnoopp', 'qqrrssttuu', 'vvwwxxyyzz'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(words = ['mississippi', 'tennessee', 'delaware', 'georgia', 'alabama'],chars = \"mississippitennessegeorgiaalamaba\") == 34\n assert candidate(words = ['unique', 'words', 'here'],chars = \"unewordhsere\") == 9\n assert candidate(words = ['x', 'xx', 'xxx', 'xxxx', 'xxxxx', 'xxxxxx', 'xxxxxxx', 'xxxxxxxx', 'xxxxxxxxx', 'xxxxxxxxxx'],chars = \"x\") == 1\n assert candidate(words = ['abcd', 'dcba', 'dcba', 'abcd', 'abcd'],chars = \"abcdabcdabcd\") == 20\n assert candidate(words = ['aaaaaabbbbcccc', 'bbbbbcccccc', 'cccccccc', 'ddddd'],chars = \"aabbbccccdddd\") == 0\n assert candidate(words = ['repeated', 'repeated', 'repeated', 'repeated'],chars = \"repeead\") == 0\n assert candidate(words = ['programming', 'code', 'challenge'],chars = \"mprogainlce\") == 0\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],chars = \"abc\") == 18\n assert candidate(words = ['repeat', 'repear', 'preear', 'pareer'],chars = \"reapeart\") == 24\n assert candidate(words = ['unique', 'unigue', 'uneque'],chars = \"unequiq\") == 6\n assert candidate(words = ['programming', 'is', 'fun'],chars = \"gimnoprrstu\") == 2\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi'],chars = \"misp\") == 0\n assert candidate(words = ['abcdefg', 'bcdefga', 'cdefgab'],chars = \"abcdefg\") == 21\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcde', 'edcba'],chars = \"abcdefghijabcdefghij\") == 30\n assert candidate(words = ['abcd', 'dcba', 'abdc', 'dabc'],chars = \"abcd\") == 16\n assert candidate(words = ['unique', 'characters', 'only', 'here'],chars = \"uneicharstolonhyer\") == 8\n assert candidate(words = ['repeated', 'letters', 'example'],chars = \"repateledmx\") == 15\n assert candidate(words = ['programming', 'python', 'java', 'coding'],chars = \"gnimmargorpthonavajgnidoc\") == 21\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(words = ['mississippi', 'missouri', 'mismatch', 'miss'],chars = \"mississippi\") == 15\n assert candidate(words = ['abcdefghijk', 'klmno', 'pqrstuvw', 'xyz', 'mnopqr', 'stuv', 'wxyz'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 41\n assert candidate(words = ['abacax', 'banana', 'grape'],chars = \"aabacax\") == 6\n assert candidate(words = ['programming', 'python', 'java'],chars = \"pgoramythnvaj\") == 10\n assert candidate(words = ['unique', 'words', 'only', 'once'],chars = \"nuqowinco\") == 0\n assert candidate(words = ['programming', 'python', 'java', 'algorithm'],chars = \"pgmnoaahjy\") == 0\n assert candidate(words = ['aabbccddeeff', 'zzzzzzzzzz', 'yyyyyyyyyy'],chars = \"abcdefzy\") == 0\n assert candidate(words = ['aaaaaaaa', 'bbbbbbbb', 'cccccccc', 'dddddddd'],chars = \"abcd\") == 0\n assert candidate(words = ['longerword', 'evenlongerword', 'superduperlongword'],chars = \"lorenwdsupem\") == 0\n assert candidate(words = ['repeated', 'characters', 'here', 'are', 'some'],chars = \"reepeaddttcharseom\") == 19\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],chars = \"enifxsv\") == 7\n assert candidate(words = ['testtest', 'testtest', 'testtest'],chars = \"ttttseeeesss\") == 24\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgfe'],chars = \"abcdefgh\") == 16\n assert candidate(words = ['qwerty', 'asdfgh', 'zxcvbn'],chars = \"qwertyasdfghzxcvbn\") == 18\n assert candidate(words = ['abacax', 'bacax', 'cax', 'ax', 'x'],chars = \"abacax\") == 17\n assert candidate(words = ['mississippi', 'babbling', 'bookkeeper'],chars = \"bmkpeorins\") == 0\n assert candidate(words = ['repeated', 'characters', 'example', 'strings', 'test'],chars = \"eeptxsa\") == 0\n assert candidate(words = ['this', 'is', 'a', 'test', 'case'],chars = \"tastciehins\") == 15\n assert candidate(words = ['banana', 'bandana', 'bandanna'],chars = \"bandanabandana\") == 21\n assert candidate(words = ['encyclopedia', 'dictionary', 'thesaurus'],chars = \"ctheosuraind\") == 0\n assert candidate(words = ['longword', 'another', 'wordset'],chars = \"longanotwrheds\") == 22\n assert candidate(words = ['repeated', 'characters', 'in', 'strings'],chars = \"repachint\") == 2\n assert candidate(words = ['unique', 'words', 'only', 'once'],chars = \"euqinowrsc\") == 4\n assert candidate(words = ['encyclopedia', 'dictionary', 'encyclopedia', 'encyclopediab'],chars = \"encyclopedia\") == 24\n assert candidate(words = ['banana', 'apple', 'orange', 'grape', 'peach'],chars = \"aapplleeorrnggbnpppe\") == 16\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'],chars = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(words = ['abracadabra', 'barack', 'rac', 'cabra'],chars = \"abracadabra\") == 19\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yz'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(words = ['algorithm', 'datastructure', 'programming'],chars = \"datastructureprogramming\") == 24\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],chars = \"onethreefourfive\") == 16\n assert candidate(words = ['mississippi', 'baby', 'racecar', 'level', 'rotor'],chars = \"ississippiabaycerracelevrotor\") == 12\n assert candidate(words = ['repetition', 'representation', 'reform'],chars = \"repitnfom\") == 0\n assert candidate(words = ['longwordhere', 'anotherlongword', 'shortword'],chars = \"lnwordhertahoes\") == 9\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(words = ['abcd', 'abce', 'abcf'],chars = \"abcd\") == 4\n assert candidate(words = ['abcd', 'abac', 'aabc', 'abcc', 'accc'],chars = \"abcc\") == 4\n assert candidate(words = ['mississippi', 'elephant', 'umbrella', 'java', 'python'],chars = \"ieelmpstuvy\") == 0\n assert candidate(words = ['aabbcc', 'abcabc', 'ccabba', 'baccab'],chars = \"aabbcc\") == 24\n assert candidate(words = ['algorithm', 'data', 'structure'],chars = \"gahlimstrucotad\") == 13\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yzabcd', 'efghij', 'klmnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnopqr', 'stuvwx'],chars = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 76\n assert candidate(words = ['abcdabcd', 'abcdabcdabcd', 'abcdabcdabcdabcd', 'abcd'],chars = \"abcdabcdabcdabcd\") == 40\n assert candidate(words = ['supercalifragilisticexpialidocious', 'antidisestablishmentarianism', 'floccinaucinihilipilification'],chars = \"supercalifragilisticexpialidociousantidisestablishmentarianismfloccinaucinihilipilification\") == 91\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcde'],chars = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzz\") == 71\n assert candidate(words = ['elephant', 'giraffe', 'hippopotamus'],chars = \"eplhgaifeotmups\") == 0\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat'],chars = \"eprta\") == 0\n assert candidate(words = ['hello', 'world', 'leetcode', 'challenge'],chars = \"helloworldleetcodechallenge\") == 27\n assert candidate(words = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz'],chars = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(words = ['stackoverflow', 'overflow', 'underflow', 'flow'],chars = \"flowover\") == 12\n assert candidate(words = ['supercalifragilisticexpialidocious', 'supercalifragilistic', 'califragilistic', 'expialidocious'],chars = \"supercalifragilisticexpialidocious\") == 83\n assert candidate(words = ['umbrella', 'balloon', 'orange'],chars = \"mnbaylobnragoe\") == 6\n assert candidate(words = ['xylophone', 'triangle', 'piano', 'drum', 'guitar'],chars = \"tpirangedumxylophone\") == 32\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyz'],chars = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(words = ['character', 'char', 'act', 'react', 'actchar'],chars = \"character\") == 28\n assert candidate(words = ['programming', 'language', 'python', 'java', 'javascript', 'c', 'cpp'],chars = \"pgoramlngyjtahivsc\") == 21\n", "comparison": "exact"}, "public_tests": ["[\"cat\",\"bt\",\"hat\",\"tree\"]\n\"atach\"", "[\"hello\",\"world\",\"leetcode\"]\n\"welldonehoneyr\""], "hints": ["Solve the problem for each string in words independently.", "Now try to think in frequency of letters.", "Count how many times each character occurs in string chars.", "To form a string using characters from chars, the frequency of each character in chars must be greater than or equal the frequency of that character in the string to be formed."], "metadata": {"canonical_parameter_names": ["words", "chars"], "leetcode_dataset_entry_point": "Solution().countCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:00+00:00", "tests_total": 134, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def countCharacters(self, words: list[str], chars: str) -> int:", "container": "Solution", "callable": "countCharacters", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "chars", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1162, "task_id": "as-far-from-land-as-possible", "difficulty": "Medium", "problem_description": "Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized, and return the distance. If no land or water exists in the grid, return -1.\n\nThe distance used in this problem is the Manhattan distance: the distance between two cells (x0, y0) and (x1, y1) is |x0 - x1| + |y0 - y1|.\n\nExample 1:\n\nInput: grid = [[1,0,1],[0,0,0],[1,0,1]]\nOutput: 2\nExplanation: The cell (1, 1) is as far as possible from all the land with distance 2.\n\nExample 2:\n\nInput: grid = [[1,0,0],[0,0,0],[0,0,0]]\nOutput: 4\nExplanation: The cell (2, 2) is as far as possible from all the land with distance 4.\n\nConstraints:\n\n- n == grid.length\n- n == grid[i].length\n- 1 <= n <= 100\n- grid[i][j] is 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == -1\n assert candidate(grid = [[1, 0, 1, 0], [0, 0, 0, 0], [1, 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]]) == 6\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 4\n assert candidate(grid = [[0, 1, 0, 0], [1, 0, 1, 1], [0, 1, 0, 0], [1, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 0], [0, 0, 0], [0, 0, 0]]) == 4\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 1], [0, 0, 0], [1, 0, 1]]) == 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, 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]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[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]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[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, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1]]) == 5\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) == 2\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, 1, 0, 0]]) == 4\n assert candidate(grid = [[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]]) == 3\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]) == 6\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], [0, 0, 0, 0, 0, 0, 0]]) == 7\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]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 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, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 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]]) == 7\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]]) == 4\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, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) == 2\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 1\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]]) == 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, 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], [0, 0, 0, 0, 0, 0, 0, 0]]) == 6\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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 9\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]]) == 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], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 6\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, 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]]) == 8\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == 2\n assert candidate(grid = [[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, 1, 0], [0, 0, 0, 0, 0, 0]]) == 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, 1, 0]]) == 7\n assert candidate(grid = [[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]]) == 4\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, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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]]) == 8\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]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 3\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, 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], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 4\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, 1]]) == 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, 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]]) == 6\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]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == 4\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, 1]]) == 5\n assert candidate(grid = [[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, 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]]) == 4\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, 1, 0, 0, 0]]) == 3\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]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 7\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]]) == 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, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[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, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\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]]) == 2\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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]]) == 8\n", "comparison": "exact"}, "public_tests": ["[[1,0,1],[0,0,0],[1,0,1]]", "[[1,0,0],[0,0,0],[0,0,0]]"], "hints": ["Can you think of this problem in a backwards way ?", "Imagine expanding outward from each land cell. What kind of search does that ?", "Use BFS starting from all land cells in the same time.", "When do you reach the furthest water cell?"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:05+00:00", "tests_total": 62, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1163, "task_id": "last-substring-in-lexicographical-order", "difficulty": "Hard", "problem_description": "Given a string s, return the last substring of s in lexicographical order.\n\nExample 1:\n\nInput: s = \"abab\"\nOutput: \"bab\"\nExplanation: The substrings are [\"a\", \"ab\", \"aba\", \"abab\", \"b\", \"ba\", \"bab\"]. The lexicographically maximum substring is \"bab\".\n\nExample 2:\n\nInput: s = \"leetcode\"\nOutput: \"tcode\"\n\nConstraints:\n\n- 1 <= s.length <= 4 * 10^5\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abab\") == \"bab\"\n assert candidate(s = \"mississippi\") == \"ssissippi\"\n assert candidate(s = \"abcdabcdabcd\") == \"dabcdabcd\"\n assert candidate(s = \"banana\") == \"nana\"\n assert candidate(s = \"zyxzy\") == \"zyxzy\"\n assert candidate(s = \"zyxzyxzyx\") == \"zyxzyxzyx\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aaa\") == \"aaa\"\n assert candidate(s = \"abcd\") == \"d\"\n assert candidate(s = \"akjflaweproqwoijrpprpwlekfawpqwlekfqpwoqpwlekjqwlkfqpwlkerpqwlkfjqwlekflpqwlekfqpwlkerpqwlekfqwlekjfqpwekfqpwlkjqwlekjfqpwlkerpqwlekfpwoqwjfwqppqwjflawejqawlkjqwlkfjqwlkfjqwlkfjqwlkfjqwlekjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkj\") == \"wqppqwjflawejqawlkjqwlkfjqwlkfjqwlkfjqwlkfjqwlekjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkjqwlekjqwlekjqwlekjqwlekjqwlekjqwlkj\"\n assert candidate(s = \"leetcode\") == \"tcode\"\n assert candidate(s = \"aaaa\") == \"aaaa\"\n assert candidate(s = \"aabbccddeeff\") == \"ff\"\n assert candidate(s = \"abcdabceabcdabcdabcdabceabcdabcdabcd\") == \"eabcdabcdabcdabceabcdabcdabcd\"\n assert candidate(s = \"aaaabbbbccccdddd\") == \"dddd\"\n assert candidate(s = \"leetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcode\") == \"tcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcode\"\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaabaaaaaaaabaaaaaaaaaabaaaaaaaaaaabaaaaaaaaaaa\") == \"baaaabaaaaabaaaaaaabaaaaaaaabaaaaaaaaaabaaaaaaaaaaabaaaaaaaaaaa\"\n assert candidate(s = \"aaaabaaaabaaaaaa\") == \"baaaabaaaaaa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(s = \"ababababababababababab\") == \"babababababababababab\"\n assert candidate(s = \"ananananananananananananananan\") == \"nanananananananananananananan\"\n assert candidate(s = \"aaaabbaaaabbaaa\") == \"bbaaaabbaaa\"\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == \"bbaabbaabbaabbaabb\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"thisisaverylongstringwithseveralrepeatedsubstringsrepeated\") == \"ylongstringwithseveralrepeatedsubstringsrepeated\"\n assert candidate(s = \"leetcodeloveleetcode\") == \"veleetcode\"\n assert candidate(s = \"abababababababababab\") == \"bababababababababab\"\n assert candidate(s = \"bcbcbcbcbcbcbcbc\") == \"cbcbcbcbcbcbcbc\"\n assert candidate(s = \"anananananananan\") == \"nananananananan\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"dabcdabcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"xyxxyxyxxyxyxxyxyxyxxyxyx\") == \"yxyxyxxyxyx\"\n assert candidate(s = \"abababababababa\") == \"bababababababa\"\n assert candidate(s = \"abracadabra\") == \"racadabra\"\n assert candidate(s = \"aaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaab\") == \"baaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaab\"\n assert candidate(s = \"abcdbacdcbac\") == \"dcbac\"\n assert candidate(s = \"zzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzz\"\n assert candidate(s = \"bbaaabbaaabbaaa\") == \"bbaaabbaaabbaaa\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaab\") == \"b\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffff\") == \"ffff\"\n assert candidate(s = \"abracadabraabracadabraabracadabraabracadabraabracadabra\") == \"racadabraabracadabraabracadabraabracadabraabracadabra\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"acbbccddeeefffggghhhh\") == \"hhhh\"\n assert candidate(s = \"racecar\") == \"racecar\"\n assert candidate(s = \"aaaaaaaaaaab\") == \"b\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == \"cabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdexyzxyzxyzxyzxyzxyzxyzxyzxyz\") == \"zxyzxyzxyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"rollingstonesrollingstonesrollingstones\") == \"tonesrollingstonesrollingstones\"\n assert candidate(s = \"abcdedcbaedcba\") == \"edcbaedcba\"\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydogaquickbrownfoxjumpsoverthelazydog\") == \"zydogaquickbrownfoxjumpsoverthelazydog\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"zzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"ababababababab\") == \"babababababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"zabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"bananaananabananaananabananaananaba\") == \"nanabananaananabananaananaba\"\n assert candidate(s = \"bbaaaaaaaaaaaaaaaaaaab\") == \"bbaaaaaaaaaaaaaaaaaaab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aazzzzzaazzzzz\") == \"zzzzzaazzzzz\"\n assert candidate(s = \"mmmmmmmllllllllkkkkkkkkjjjjjjjjiiiiiiiioooooooonnnnnnnmmm\") == \"oooooooonnnnnnnmmm\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaab\") == \"baaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(s = \"aabbccddeeffgg\") == \"gg\"\n assert candidate(s = \"leetcodeisacodeleetcode\") == \"tcodeisacodeleetcode\"\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"zz\"\n assert candidate(s = \"zzzzzyzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzz\"\n assert candidate(s = \"xyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyx\") == \"zyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyxyzyxzyx\"\n assert candidate(s = \"bananaananabananananaba\") == \"nanananaba\"\n assert candidate(s = \"zzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzz\"\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccccdddddddddddddddddddd\") == \"dddddddddddddddddddd\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"racecarbananaappleorangeorangeapplebananaorangeorangeapplebananaorange\") == \"rbananaappleorangeorangeapplebananaorangeorangeapplebananaorange\"\n assert candidate(s = \"abcdefgzyxwvutsrqpomnlkjihgfedcba\") == \"zyxwvutsrqpomnlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"zz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaabb\") == \"bb\"\n assert candidate(s = \"abcdzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aaaaaaabbbbbbbccccccdddddeeeeeeffffffff\") == \"ffffffff\"\n assert candidate(s = \"bbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == \"bbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaaabaaaaaaaaaab\") == \"baaaaaaaaaabaaaaaaaaaab\"\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcba\") == \"edcbaabcdedcbaabcdedcbaabcdedcbaabcdedcbaabcdedcba\"\n", "comparison": "exact"}, "public_tests": ["\"abab\"", "\"leetcode\""], "hints": ["Assume that the answer is a sub-string from index i to j. If you add the character at index j+1 you get a better answer.", "The answer is always a suffix of the given string.", "Since the limits are high, we need an efficient data structure.", "Use suffix array."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().lastSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:07+00:00", "tests_total": 80, "tests_dropped": 1, "flags": [], "topic_tags": ["two-pointers", "string", "lyndon-factorization"]}, "language": "python", "interface": {"raw_signature": "def lastSubstring(self, s: str) -> str:", "container": "Solution", "callable": "lastSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1169, "task_id": "invalid-transactions", "difficulty": "Medium", "problem_description": "A transaction is possibly invalid if:\n\n- the amount exceeds $1000, or;\n- if it occurs within (and including) 60 minutes of another transaction with the same name in a different city.\n\nYou are given an array of strings transaction where transactions[i] consists of comma-separated values representing the name, time (in minutes), amount, and city of the transaction.\n\nReturn a list of transactions that are possibly invalid. You may return the answer in any order.\n\nExample 1:\n\nInput: transactions = [\"alice,20,800,mtv\",\"alice,50,100,beijing\"]\nOutput: [\"alice,20,800,mtv\",\"alice,50,100,beijing\"]\nExplanation: The first transaction is invalid because the second transaction occurs within a difference of 60 minutes, have the same name and is in a different city. Similarly the second one is invalid too.\n\nExample 2:\n\nInput: transactions = [\"alice,20,800,mtv\",\"alice,50,1200,mtv\"]\nOutput: [\"alice,50,1200,mtv\"]\n\nExample 3:\n\nInput: transactions = [\"alice,20,800,mtv\",\"bob,50,1200,mtv\"]\nOutput: [\"bob,50,1200,mtv\"]\n\nConstraints:\n\n- transactions.length <= 1000\n- Each transactions[i] takes the form \"{name},{time},{amount},{city}\"\n- Each {name} and {city} consist of lowercase English letters, and have lengths between 1 and 10.\n- Each {time} consist of digits, and represent an integer between 0 and 1000.\n- Each {amount} consist of digits, and represent an integer between 0 and 2000.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,50,1200,mtv']), ['alice,50,1200,mtv'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,50,100,beijing', 'bob,25,800,mtv', 'bob,100,100,beijing']), ['alice,20,800,mtv', 'alice,50,100,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,20,600,mtv', 'alice,30,1100,newyork', 'bob,40,100,beijing']), ['alice,10,500,mtv', 'bob,20,600,mtv', 'alice,30,1100,newyork', 'bob,40,100,beijing'])\n assert answers_match(candidate(transactions=['alice,20,1100,mtv', 'bob,50,2000,mtv', 'alice,100,1000,beijing']), ['alice,20,1100,mtv', 'bob,50,2000,mtv'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,50,100,mtv', 'alice,61,100,mtv']), [])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,60,100,mtv', 'alice,120,100,beijing']), ['alice,60,100,mtv', 'alice,120,100,beijing'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,20,1000,mtv', 'alice,21,800,beijing']), ['alice,20,800,mtv', 'alice,20,1000,mtv', 'alice,21,800,beijing'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'bob,50,1200,mtv']), ['bob,50,1200,mtv'])\n assert answers_match(candidate(transactions=['alice,20,1500,mtv', 'alice,21,100,beijing', 'alice,22,2000,mtv']), ['alice,20,1500,mtv', 'alice,21,100,beijing', 'alice,22,2000,mtv'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'bob,20,800,mtv', 'alice,50,100,beijing']), ['alice,20,800,mtv', 'alice,50,100,beijing'])\n assert answers_match(candidate(transactions=['alice,20,1500,mtv', 'alice,25,800,mtv', 'alice,30,1200,beijing']), ['alice,20,1500,mtv', 'alice,25,800,mtv', 'alice,30,1200,beijing'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'bob,50,1200,mtv', 'alice,60,1200,mtv', 'bob,120,1200,beijing']), ['bob,50,1200,mtv', 'alice,60,1200,mtv', 'bob,120,1200,beijing'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,20,1000,mtv', 'alice,20,1001,mtv']), ['alice,20,1001,mtv'])\n assert answers_match(candidate(transactions=['alice,20,1500,mtv', 'alice,20,100,beijing', 'alice,50,1200,mtv']), ['alice,20,1500,mtv', 'alice,20,100,beijing', 'alice,50,1200,mtv'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'bob,20,800,mtv', 'alice,80,800,beijing']), ['alice,20,800,mtv', 'alice,80,800,beijing'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,50,100,beijing']), ['alice,20,800,mtv', 'alice,50,100,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,10,600,mtv', 'alice,20,1200,newyork', 'bob,20,600,newyork', 'alice,30,600,beijing', 'bob,30,600,mtv', 'alice,40,600,newyork', 'bob,40,600,beijing', 'charlie,50,700,mtv', 'charlie,55,700,newyork', 'charlie,60,700,beijing', 'dave,5,800,mtv', 'dave,7,900,newyork', 'dave,10,1000,beijing', 'dave,15,1100,mtv']), ['alice,10,500,mtv', 'bob,10,600,mtv', 'alice,20,1200,newyork', 'bob,20,600,newyork', 'alice,30,600,beijing', 'bob,30,600,mtv', 'alice,40,600,newyork', 'bob,40,600,beijing', 'charlie,50,700,mtv', 'charlie,55,700,newyork', 'charlie,60,700,beijing', 'dave,5,800,mtv', 'dave,7,900,newyork', 'dave,10,1000,beijing', 'dave,15,1100,mtv'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,70,500,mtv', 'alice,130,500,newyork', 'alice,190,500,mtv', 'alice,250,500,beijing', 'bob,10,1200,newyork', 'bob,70,1200,beijing', 'bob,130,1200,mtv', 'bob,190,1200,newyork', 'bob,250,1200,beijing']), ['alice,70,500,mtv', 'alice,130,500,newyork', 'alice,190,500,mtv', 'alice,250,500,beijing', 'bob,10,1200,newyork', 'bob,70,1200,beijing', 'bob,130,1200,mtv', 'bob,190,1200,newyork', 'bob,250,1200,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,70,600,mtv', 'alice,120,800,newyork', 'alice,130,1100,newyork']), ['alice,70,600,mtv', 'alice,120,800,newyork', 'alice,130,1100,newyork'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,70,1500,beijing', 'alice,130,1100,mtv', 'alice,190,900,beijing', 'bob,20,600,mtv', 'bob,80,1500,beijing', 'bob,140,1100,mtv', 'bob,200,900,beijing']), ['alice,10,500,mtv', 'alice,70,1500,beijing', 'alice,130,1100,mtv', 'alice,190,900,beijing', 'bob,20,600,mtv', 'bob,80,1500,beijing', 'bob,140,1100,mtv', 'bob,200,900,beijing'])\n assert answers_match(candidate(transactions=['ivan,10,1300,madrid', 'ivan,40,800,madrid', 'ivan,70,1100,barcelona', 'ivan,100,1200,madrid', 'ivan,130,900,valencia', 'ivan,160,1000,madrid', 'ivan,190,800,barcelona', 'ivan,220,1500,madrid', 'ivan,250,600,valencia', 'ivan,280,1200,madrid', 'ivan,310,800,barcelona', 'ivan,340,900,madrid', 'ivan,370,700,valencia', 'ivan,400,1500,madrid']), ['ivan,10,1300,madrid', 'ivan,40,800,madrid', 'ivan,70,1100,barcelona', 'ivan,100,1200,madrid', 'ivan,130,900,valencia', 'ivan,160,1000,madrid', 'ivan,190,800,barcelona', 'ivan,220,1500,madrid', 'ivan,250,600,valencia', 'ivan,280,1200,madrid', 'ivan,310,800,barcelona', 'ivan,340,900,madrid', 'ivan,370,700,valencia', 'ivan,400,1500,madrid'])\n assert answers_match(candidate(transactions=['frank,10,1200,mtv', 'frank,20,1000,beijing', 'frank,30,1500,mtv', 'frank,40,900,newyork', 'frank,50,1100,mtv', 'frank,60,800,beijing', 'frank,70,1000,newyork']), ['frank,10,1200,mtv', 'frank,20,1000,beijing', 'frank,30,1500,mtv', 'frank,40,900,newyork', 'frank,50,1100,mtv', 'frank,60,800,beijing', 'frank,70,1000,newyork'])\n assert answers_match(candidate(transactions=['eve,5,1000,berlin', 'eve,10,100,berlin', 'eve,70,1100,berlin', 'eve,120,1200,berlin', 'eve,180,1300,berlin']), ['eve,70,1100,berlin', 'eve,120,1200,berlin', 'eve,180,1300,berlin'])\n assert answers_match(candidate(transactions=['jane,10,900,sanfrancisco', 'jane,20,1100,sanfrancisco', 'jane,30,800,sanfrancisco', 'jane,40,1200,losangeles', 'jane,50,1000,losangeles', 'jane,60,950,sanfrancisco', 'jane,70,1050,sanfrancisco', 'jane,80,850,losangeles', 'jane,90,1150,sanfrancisco']), ['jane,10,900,sanfrancisco', 'jane,20,1100,sanfrancisco', 'jane,30,800,sanfrancisco', 'jane,40,1200,losangeles', 'jane,50,1000,losangeles', 'jane,60,950,sanfrancisco', 'jane,70,1050,sanfrancisco', 'jane,80,850,losangeles', 'jane,90,1150,sanfrancisco'])\n assert answers_match(candidate(transactions=['ivan,10,900,moscow', 'ivan,20,1100,moscow', 'ivan,30,800,moscow', 'ivan,40,1200,stuttgart', 'ivan,50,1000,stuttgart', 'ivan,60,950,moscow', 'ivan,70,1050,moscow', 'ivan,80,850,stuttgart']), ['ivan,10,900,moscow', 'ivan,20,1100,moscow', 'ivan,30,800,moscow', 'ivan,40,1200,stuttgart', 'ivan,50,1000,stuttgart', 'ivan,60,950,moscow', 'ivan,70,1050,moscow', 'ivan,80,850,stuttgart'])\n assert answers_match(candidate(transactions=['eve,5,1500,mtv', 'eve,65,1100,beijing', 'eve,70,500,mtv', 'eve,130,1000,newyork', 'eve,135,800,mtv', 'eve,190,1100,beijing']), ['eve,5,1500,mtv', 'eve,65,1100,beijing', 'eve,70,500,mtv', 'eve,130,1000,newyork', 'eve,135,800,mtv', 'eve,190,1100,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,10,600,mtv', 'alice,20,1200,newyork', 'bob,20,600,newyork', 'alice,30,600,beijing', 'bob,30,600,mtv', 'alice,40,600,newyork', 'bob,40,600,beijing', 'charlie,50,700,mtv', 'charlie,55,700,newyork', 'charlie,60,700,beijing']), ['alice,10,500,mtv', 'bob,10,600,mtv', 'alice,20,1200,newyork', 'bob,20,600,newyork', 'alice,30,600,beijing', 'bob,30,600,mtv', 'alice,40,600,newyork', 'bob,40,600,beijing', 'charlie,50,700,mtv', 'charlie,55,700,newyork', 'charlie,60,700,beijing'])\n assert answers_match(candidate(transactions=['dave,5,500,boston', 'dave,30,1100,boston', 'dave,35,600,ny', 'dave,45,900,boston', 'dave,70,1500,ny']), ['dave,5,500,boston', 'dave,30,1100,boston', 'dave,35,600,ny', 'dave,45,900,boston', 'dave,70,1500,ny'])\n assert answers_match(candidate(transactions=['ian,10,500,tokyo', 'ian,20,600,tokyo', 'ian,30,700,tokyo', 'ian,40,800,tokyo', 'ian,50,900,tokyo', 'ian,60,1000,tokyo', 'ian,70,1100,tokyo', 'ian,80,1200,tokyo', 'ian,90,1300,tokyo', 'ian,100,1400,tokyo', 'ian,110,1500,tokyo', 'ian,120,1600,tokyo', 'ian,130,1700,tokyo', 'ian,140,1800,tokyo', 'ian,150,1900,tokyo', 'ian,160,1500,osaka', 'ian,170,1600,osaka', 'ian,180,1700,osaka', 'ian,190,1800,osaka', 'ian,200,1900,osaka']), ['ian,70,1100,tokyo', 'ian,80,1200,tokyo', 'ian,90,1300,tokyo', 'ian,100,1400,tokyo', 'ian,110,1500,tokyo', 'ian,120,1600,tokyo', 'ian,130,1700,tokyo', 'ian,140,1800,tokyo', 'ian,150,1900,tokyo', 'ian,160,1500,osaka', 'ian,170,1600,osaka', 'ian,180,1700,osaka', 'ian,190,1800,osaka', 'ian,200,1900,osaka'])\n assert answers_match(candidate(transactions=['grace,10,800,toronto', 'grace,30,700,toronto', 'grace,60,1200,vancouver', 'grace,90,600,toronto', 'grace,120,800,toronto', 'grace,150,900,montreal', 'grace,180,1500,toronto', 'grace,210,700,vancouver', 'grace,240,600,montreal', 'grace,270,1100,toronto', 'grace,300,900,vancouver', 'grace,330,800,montreal']), ['grace,10,800,toronto', 'grace,30,700,toronto', 'grace,60,1200,vancouver', 'grace,90,600,toronto', 'grace,120,800,toronto', 'grace,150,900,montreal', 'grace,180,1500,toronto', 'grace,210,700,vancouver', 'grace,240,600,montreal', 'grace,270,1100,toronto', 'grace,300,900,vancouver', 'grace,330,800,montreal'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,10,1200,beijing', 'alice,20,500,newyork', 'bob,10,300,mtv', 'bob,11,1500,beijing']), ['alice,10,500,mtv', 'alice,10,1200,beijing', 'alice,20,500,newyork', 'bob,10,300,mtv', 'bob,11,1500,beijing'])\n assert answers_match(candidate(transactions=['charlie,10,1000,paris', 'charlie,50,2000,london', 'charlie,60,1500,paris', 'charlie,120,800,london']), ['charlie,10,1000,paris', 'charlie,50,2000,london', 'charlie,60,1500,paris', 'charlie,120,800,london'])\n assert answers_match(candidate(transactions=['frank,10,500,seattle', 'frank,20,500,sanfrancisco', 'frank,30,1500,seattle', 'frank,90,700,sanfrancisco', 'frank,150,1200,seattle']), ['frank,10,500,seattle', 'frank,20,500,sanfrancisco', 'frank,30,1500,seattle', 'frank,90,700,sanfrancisco', 'frank,150,1200,seattle'])\n assert answers_match(candidate(transactions=['grace,10,1500,chicago', 'grace,20,1600,chicago', 'grace,30,1700,chicago', 'grace,40,1800,chicago', 'grace,50,1900,chicago', 'grace,60,1500,paris', 'grace,70,1600,paris', 'grace,80,1700,paris', 'grace,90,1800,paris', 'grace,100,1900,paris']), ['grace,10,1500,chicago', 'grace,20,1600,chicago', 'grace,30,1700,chicago', 'grace,40,1800,chicago', 'grace,50,1900,chicago', 'grace,60,1500,paris', 'grace,70,1600,paris', 'grace,80,1700,paris', 'grace,90,1800,paris', 'grace,100,1900,paris'])\n assert answers_match(candidate(transactions=['grace,10,1000,mtv', 'grace,20,1100,newyork', 'grace,30,900,beijing', 'grace,90,1100,newyork', 'grace,150,1000,beijing', 'grace,210,1500,mtv', 'grace,220,800,newyork', 'grace,300,1200,beijing', 'grace,350,1100,mtv']), ['grace,10,1000,mtv', 'grace,20,1100,newyork', 'grace,30,900,beijing', 'grace,90,1100,newyork', 'grace,150,1000,beijing', 'grace,210,1500,mtv', 'grace,220,800,newyork', 'grace,300,1200,beijing', 'grace,350,1100,mtv'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,50,1000,newyork', 'alice,70,900,beijing', 'bob,40,1000,mtv', 'bob,120,1500,newyork']), ['alice,20,800,mtv', 'alice,50,1000,newyork', 'alice,70,900,beijing', 'bob,120,1500,newyork'])\n assert answers_match(candidate(transactions=['charlie,10,1500,paris', 'charlie,20,1000,boston', 'charlie,30,500,paris', 'charlie,40,1200,newyork', 'charlie,50,800,boston']), ['charlie,10,1500,paris', 'charlie,20,1000,boston', 'charlie,30,500,paris', 'charlie,40,1200,newyork', 'charlie,50,800,boston'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,70,1000,mtv', 'alice,130,1100,newyork', 'alice,190,900,mtv', 'alice,250,100,beijing']), ['alice,70,1000,mtv', 'alice,130,1100,newyork', 'alice,190,900,mtv', 'alice,250,100,beijing'])\n assert answers_match(candidate(transactions=['charlie,10,900,paris', 'david,15,1100,london', 'charlie,20,700,paris', 'david,60,800,paris']), ['david,15,1100,london', 'david,60,800,paris'])\n assert answers_match(candidate(transactions=['ivan,1,1000,boston', 'ivan,10,500,boston', 'ivan,60,1500,newyork', 'ivan,65,2000,chicago', 'ivan,120,800,newyork', 'ivan,125,1200,lasvegas', 'ivan,180,600,newyork']), ['ivan,1,1000,boston', 'ivan,10,500,boston', 'ivan,60,1500,newyork', 'ivan,65,2000,chicago', 'ivan,120,800,newyork', 'ivan,125,1200,lasvegas', 'ivan,180,600,newyork'])\n assert answers_match(candidate(transactions=['frank,1,1100,chicago', 'frank,10,600,chicago', 'frank,11,2000,newyork', 'frank,20,500,chicago', 'frank,30,3000,newyork', 'frank,40,1500,chicago']), ['frank,1,1100,chicago', 'frank,10,600,chicago', 'frank,11,2000,newyork', 'frank,20,500,chicago', 'frank,30,3000,newyork', 'frank,40,1500,chicago'])\n assert answers_match(candidate(transactions=['charlie,10,1500,nyc', 'david,20,1100,paris', 'charlie,30,1200,nyc', 'david,40,900,london', 'charlie,60,1000,paris']), ['charlie,10,1500,nyc', 'david,20,1100,paris', 'charlie,30,1200,nyc', 'david,40,900,london', 'charlie,60,1000,paris'])\n assert answers_match(candidate(transactions=['dave,5,2500,london', 'eve,10,1100,london', 'dave,15,600,birmingham', 'eve,20,400,london', 'dave,25,900,glasgow', 'eve,30,1000,birmingham']), ['dave,5,2500,london', 'eve,10,1100,london', 'dave,15,600,birmingham', 'eve,20,400,london', 'dave,25,900,glasgow', 'eve,30,1000,birmingham'])\n assert answers_match(candidate(transactions=['hank,5,900,chicago', 'hank,35,800,chicago', 'hank,65,700,losangeles', 'hank,95,1500,chicago', 'hank,125,600,losangeles', 'hank,155,1200,chicago', 'hank,185,800,losangeles', 'hank,215,900,chicago', 'hank,245,700,losangeles', 'hank,275,1500,chicago', 'hank,305,600,losangeles', 'hank,335,1200,chicago', 'hank,365,800,losangeles', 'hank,395,900,chicago']), ['hank,5,900,chicago', 'hank,35,800,chicago', 'hank,65,700,losangeles', 'hank,95,1500,chicago', 'hank,125,600,losangeles', 'hank,155,1200,chicago', 'hank,185,800,losangeles', 'hank,215,900,chicago', 'hank,245,700,losangeles', 'hank,275,1500,chicago', 'hank,305,600,losangeles', 'hank,335,1200,chicago', 'hank,365,800,losangeles', 'hank,395,900,chicago'])\n assert answers_match(candidate(transactions=['heidi,1,1000,boston', 'heidi,60,1000,newyork', 'heidi,120,1000,boston', 'heidi,180,1000,newyork', 'heidi,240,1000,boston', 'heidi,300,1000,newyork']), ['heidi,1,1000,boston', 'heidi,60,1000,newyork', 'heidi,120,1000,boston', 'heidi,180,1000,newyork', 'heidi,240,1000,boston', 'heidi,300,1000,newyork'])\n assert answers_match(candidate(transactions=['heidi,10,900,berlin', 'heidi,20,1100,berlin', 'heidi,30,800,berlin', 'heidi,40,1200,munich', 'heidi,50,1000,munich', 'heidi,60,950,berlin', 'heidi,70,1050,berlin']), ['heidi,10,900,berlin', 'heidi,20,1100,berlin', 'heidi,30,800,berlin', 'heidi,40,1200,munich', 'heidi,50,1000,munich', 'heidi,60,950,berlin', 'heidi,70,1050,berlin'])\n assert answers_match(candidate(transactions=['grace,10,900,rome', 'grace,20,1100,rome', 'grace,30,800,rome', 'grace,40,1200,paris', 'grace,50,1000,paris', 'grace,60,950,rome']), ['grace,10,900,rome', 'grace,20,1100,rome', 'grace,30,800,rome', 'grace,40,1200,paris', 'grace,50,1000,paris', 'grace,60,950,rome'])\n assert answers_match(candidate(transactions=['grace,10,500,mtv', 'grace,110,600,mtv', 'grace,210,1100,newyork', 'grace,310,100,beijing', 'grace,410,1300,mtv', 'grace,510,1000,beijing']), ['grace,210,1100,newyork', 'grace,410,1300,mtv'])\n assert answers_match(candidate(transactions=['ivan,10,500,chicago', 'ivan,20,500,chicago', 'ivan,25,1000,boston', 'ivan,30,600,boston', 'ivan,85,700,chicago', 'ivan,90,2000,boston', 'ivan,140,1200,chicago', 'ivan,180,800,boston']), ['ivan,10,500,chicago', 'ivan,20,500,chicago', 'ivan,25,1000,boston', 'ivan,30,600,boston', 'ivan,85,700,chicago', 'ivan,90,2000,boston', 'ivan,140,1200,chicago', 'ivan,180,800,boston'])\n assert answers_match(candidate(transactions=['frank,10,500,sf', 'frank,20,600,sf', 'frank,30,700,sf', 'frank,40,800,sf', 'frank,50,900,sf', 'frank,60,1000,sf', 'frank,70,1100,sf', 'frank,80,1200,sf', 'frank,90,1300,sf', 'frank,100,1400,sf']), ['frank,90,1300,sf', 'frank,100,1400,sf', 'frank,70,1100,sf', 'frank,80,1200,sf'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'alice,50,1200,beijing', 'alice,120,1000,mtv', 'bob,20,600,mtv', 'bob,80,600,newyork', 'bob,150,600,mtv']), ['alice,20,800,mtv', 'alice,50,1200,beijing', 'bob,20,600,mtv', 'bob,80,600,newyork'])\n assert answers_match(candidate(transactions=['alice,20,800,mtv', 'bob,50,1200,mtv', 'charlie,30,1500,newyork', 'dave,40,100,beijing', 'eve,60,900,mtv', 'frank,80,2000,newyork', 'grace,100,1100,beijing']), ['bob,50,1200,mtv', 'charlie,30,1500,newyork', 'frank,80,2000,newyork', 'grace,100,1100,beijing'])\n assert answers_match(candidate(transactions=['alice,10,1000,mtv', 'bob,20,1100,mtv', 'charlie,30,900,newyork', 'dave,40,100,beijing', 'eve,60,900,mtv', 'frank,80,2000,newyork', 'grace,100,1100,beijing', 'heidi,120,1000,mtv', 'ivan,140,1200,newyork', 'juliet,160,1300,beijing', 'karen,180,1400,mtv', 'leo,200,1500,newyork', 'mike,220,1600,beijing']), ['bob,20,1100,mtv', 'frank,80,2000,newyork', 'grace,100,1100,beijing', 'ivan,140,1200,newyork', 'juliet,160,1300,beijing', 'karen,180,1400,mtv', 'leo,200,1500,newyork', 'mike,220,1600,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,20,600,mtv', 'charlie,30,1100,newyork', 'dave,40,100,beijing', 'eve,50,900,mtv', 'frank,60,500,newyork', 'grace,70,1500,mtv', 'heidi,80,600,beijing']), ['charlie,30,1100,newyork', 'grace,70,1500,mtv'])\n assert answers_match(candidate(transactions=['grace,5,300,losangeles', 'grace,10,1500,lasvegas', 'grace,15,800,lasvegas', 'grace,75,1000,losangeles', 'grace,80,600,lasvegas', 'grace,130,900,losangeles']), ['grace,5,300,losangeles', 'grace,10,1500,lasvegas', 'grace,15,800,lasvegas', 'grace,75,1000,losangeles', 'grace,80,600,lasvegas', 'grace,130,900,losangeles'])\n assert answers_match(candidate(transactions=['frank,5,500,mtv', 'frank,20,1500,mtv', 'frank,30,1000,newyork', 'frank,70,900,newyork', 'frank,90,800,beijing', 'frank,120,700,beijing', 'frank,150,1200,mtv', 'frank,170,1100,newyork']), ['frank,5,500,mtv', 'frank,20,1500,mtv', 'frank,30,1000,newyork', 'frank,70,900,newyork', 'frank,90,800,beijing', 'frank,120,700,beijing', 'frank,150,1200,mtv', 'frank,170,1100,newyork'])\n assert answers_match(candidate(transactions=['grace,5,900,sanfrancisco', 'grace,10,1200,sanfrancisco', 'grace,20,800,sanfrancisco', 'grace,25,1000,sanfrancisco', 'grace,30,600,sanfrancisco', 'grace,40,1200,sanfrancisco']), ['grace,10,1200,sanfrancisco', 'grace,40,1200,sanfrancisco'])\n assert answers_match(candidate(transactions=['eve,10,1500,mtv', 'eve,10,900,newyork', 'eve,60,1000,beijing', 'eve,110,1100,newyork', 'eve,150,1200,mtv', 'eve,200,1300,beijing']), ['eve,10,1500,mtv', 'eve,10,900,newyork', 'eve,60,1000,beijing', 'eve,110,1100,newyork', 'eve,150,1200,mtv', 'eve,200,1300,beijing'])\n assert answers_match(candidate(transactions=['eve,10,500,boston', 'eve,40,600,boston', 'eve,70,550,boston', 'eve,100,900,boston', 'eve,130,1100,boston']), ['eve,130,1100,boston'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,20,600,mtv', 'alice,30,1100,newyork', 'bob,40,100,beijing', 'alice,50,900,mtv', 'alice,60,500,newyork']), ['alice,10,500,mtv', 'bob,20,600,mtv', 'alice,30,1100,newyork', 'bob,40,100,beijing', 'alice,50,900,mtv', 'alice,60,500,newyork'])\n assert answers_match(candidate(transactions=['frank,10,1200,newyork', 'frank,40,800,chicago', 'frank,60,1500,boston', 'frank,100,1100,boston', 'frank,140,1000,chicago']), ['frank,10,1200,newyork', 'frank,40,800,chicago', 'frank,60,1500,boston', 'frank,100,1100,boston', 'frank,140,1000,chicago'])\n assert answers_match(candidate(transactions=['charlie,10,1000,mtv', 'charlie,15,900,newyork', 'dave,30,1100,beijing', 'dave,60,1200,newyork', 'dave,80,1300,mtv']), ['charlie,10,1000,mtv', 'charlie,15,900,newyork', 'dave,30,1100,beijing', 'dave,60,1200,newyork', 'dave,80,1300,mtv'])\n assert answers_match(candidate(transactions=['hannah,10,1500,mtv', 'hannah,20,1000,beijing', 'hannah,30,1200,mtv', 'hannah,40,800,newyork', 'hannah,50,1100,mtv', 'hannah,60,900,beijing', 'hannah,70,1000,newyork', 'hannah,80,1300,mtv', 'hannah,90,1000,beijing']), ['hannah,10,1500,mtv', 'hannah,20,1000,beijing', 'hannah,30,1200,mtv', 'hannah,40,800,newyork', 'hannah,50,1100,mtv', 'hannah,60,900,beijing', 'hannah,70,1000,newyork', 'hannah,80,1300,mtv', 'hannah,90,1000,beijing'])\n assert answers_match(candidate(transactions=['alice,10,1500,mtv', 'bob,20,1200,beijing', 'alice,30,1300,newyork', 'bob,40,1400,mtv', 'alice,50,1600,newyork', 'bob,60,1100,newyork']), ['alice,10,1500,mtv', 'bob,20,1200,beijing', 'alice,30,1300,newyork', 'bob,40,1400,mtv', 'alice,50,1600,newyork', 'bob,60,1100,newyork'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,20,800,beijing', 'alice,30,1100,mtv', 'bob,10,500,mtv', 'bob,20,800,beijing', 'bob,30,1100,mtv', 'charlie,10,500,newyork', 'charlie,20,800,newyork', 'charlie,30,1100,newyork']), ['alice,10,500,mtv', 'alice,20,800,beijing', 'alice,30,1100,mtv', 'bob,10,500,mtv', 'bob,20,800,beijing', 'bob,30,1100,mtv', 'charlie,30,1100,newyork'])\n assert answers_match(candidate(transactions=['alice,10,1500,mtv', 'alice,70,900,beijing', 'bob,30,600,mtv', 'bob,100,1200,newyork', 'charlie,50,1300,mtv', 'charlie,110,1000,beijing']), ['alice,10,1500,mtv', 'alice,70,900,beijing', 'bob,100,1200,newyork', 'charlie,50,1300,mtv', 'charlie,110,1000,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'alice,70,1500,beijing', 'bob,20,600,mtv', 'bob,80,1500,beijing', 'charlie,30,1100,newyork', 'charlie,90,1500,newyork', 'dave,40,100,beijing', 'dave,100,1500,beijing']), ['alice,10,500,mtv', 'alice,70,1500,beijing', 'bob,20,600,mtv', 'bob,80,1500,beijing', 'charlie,30,1100,newyork', 'charlie,90,1500,newyork', 'dave,100,1500,beijing'])\n assert answers_match(candidate(transactions=['eve,15,1200,chicago', 'eve,20,900,chicago', 'eve,75,1000,boston', 'eve,80,600,boston', 'eve,130,800,chicago']), ['eve,15,1200,chicago', 'eve,20,900,chicago', 'eve,75,1000,boston', 'eve,80,600,boston', 'eve,130,800,chicago'])\n assert answers_match(candidate(transactions=['charlie,10,1500,london', 'charlie,40,900,paris', 'charlie,90,1100,london', 'dave,20,800,berlin', 'dave,70,800,berlin', 'dave,110,800,moscow', 'eve,30,500,rome', 'eve,90,2000,venice', 'eve,150,400,london']), ['charlie,10,1500,london', 'charlie,40,900,paris', 'charlie,90,1100,london', 'dave,70,800,berlin', 'dave,110,800,moscow', 'eve,30,500,rome', 'eve,90,2000,venice', 'eve,150,400,london'])\n assert answers_match(candidate(transactions=['heidi,1,2000,newyork', 'heidi,5,500,newyork', 'heidi,10,1000,boston', 'heidi,15,600,boston', 'heidi,30,700,newyork', 'heidi,65,2000,boston', 'heidi,120,800,newyork']), ['heidi,1,2000,newyork', 'heidi,5,500,newyork', 'heidi,10,1000,boston', 'heidi,15,600,boston', 'heidi,30,700,newyork', 'heidi,65,2000,boston', 'heidi,120,800,newyork'])\n assert answers_match(candidate(transactions=['alice,10,1500,mtv', 'alice,15,1600,newyork', 'alice,20,1700,beijing', 'alice,25,1800,mtv', 'alice,30,1900,newyork', 'alice,35,2000,beijing']), ['alice,10,1500,mtv', 'alice,15,1600,newyork', 'alice,20,1700,beijing', 'alice,25,1800,mtv', 'alice,30,1900,newyork', 'alice,35,2000,beijing'])\n assert answers_match(candidate(transactions=['alice,10,1500,mtv', 'bob,20,800,newyork', 'alice,30,900,beijing', 'alice,60,1000,mtv', 'bob,80,1100,newyork', 'alice,120,800,mtv', 'bob,140,900,beijing']), ['alice,10,1500,mtv', 'alice,30,900,beijing', 'alice,60,1000,mtv', 'bob,80,1100,newyork', 'bob,140,900,beijing'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,10,600,mtv', 'alice,20,1200,newyork', 'bob,20,600,newyork', 'alice,30,600,beijing', 'bob,30,600,mtv', 'alice,40,600,newyork', 'bob,40,600,beijing']), ['alice,10,500,mtv', 'bob,10,600,mtv', 'alice,20,1200,newyork', 'bob,20,600,newyork', 'alice,30,600,beijing', 'bob,30,600,mtv', 'alice,40,600,newyork', 'bob,40,600,beijing'])\n assert answers_match(candidate(transactions=['frank,10,700,boston', 'frank,30,1500,boston', 'frank,60,900,boston', 'frank,90,1200,newyork', 'frank,120,1100,paris', 'frank,150,800,boston', 'frank,180,1200,boston', 'frank,210,1100,paris', 'frank,240,800,boston', 'frank,270,1500,newyork']), ['frank,30,1500,boston', 'frank,60,900,boston', 'frank,90,1200,newyork', 'frank,120,1100,paris', 'frank,150,800,boston', 'frank,180,1200,boston', 'frank,210,1100,paris', 'frank,240,800,boston', 'frank,270,1500,newyork'])\n assert answers_match(candidate(transactions=['alice,5,500,mtv', 'bob,10,1500,beijing', 'alice,15,500,mtv', 'bob,20,1000,beijing', 'alice,25,500,beijing', 'bob,30,1000,newyork']), ['alice,5,500,mtv', 'bob,10,1500,beijing', 'alice,15,500,mtv', 'bob,20,1000,beijing', 'alice,25,500,beijing', 'bob,30,1000,newyork'])\n assert answers_match(candidate(transactions=['alice,10,500,mtv', 'bob,10,500,beijing', 'alice,70,1500,newyork', 'bob,70,1500,mtv', 'alice,120,2000,newyork', 'bob,120,2000,beijing']), ['alice,10,500,mtv', 'bob,10,500,beijing', 'alice,70,1500,newyork', 'bob,70,1500,mtv', 'alice,120,2000,newyork', 'bob,120,2000,beijing'])\n assert answers_match(candidate(transactions=['alice,10,1500,mtv', 'alice,20,800,beijing', 'alice,30,1100,mtv', 'bob,10,1500,newyork', 'bob,20,700,beijing', 'bob,30,900,newyork']), ['alice,10,1500,mtv', 'alice,20,800,beijing', 'alice,30,1100,mtv', 'bob,10,1500,newyork', 'bob,20,700,beijing', 'bob,30,900,newyork'])\n assert answers_match(candidate(transactions=['hannah,10,1000,moscow', 'hannah,20,900,moscow', 'hannah,30,800,moscow', 'hannah,40,700,moscow', 'hannah,50,600,moscow', 'hannah,60,1000,moscow', 'hannah,70,900,moscow', 'hannah,80,800,moscow', 'hannah,90,700,moscow', 'hannah,100,600,moscow', 'hannah,110,1500,paris', 'hannah,120,1600,paris', 'hannah,130,1700,paris', 'hannah,140,1800,paris', 'hannah,150,1900,paris']), ['hannah,50,600,moscow', 'hannah,60,1000,moscow', 'hannah,70,900,moscow', 'hannah,80,800,moscow', 'hannah,90,700,moscow', 'hannah,100,600,moscow', 'hannah,110,1500,paris', 'hannah,120,1600,paris', 'hannah,130,1700,paris', 'hannah,140,1800,paris', 'hannah,150,1900,paris'])\n", "comparison": "unordered"}, "public_tests": ["[\"alice,20,800,mtv\",\"alice,50,100,beijing\"]", "[\"alice,20,800,mtv\",\"alice,50,1200,mtv\"]", "[\"alice,20,800,mtv\",\"bob,50,1200,mtv\"]"], "hints": ["Split each string into four arrays.", "For each transaction check if it's invalid, you can do this with just a loop with help of the four arrays generated on step 1.", "At the end you perform O(N ^ 2) operations."], "metadata": {"canonical_parameter_names": ["transactions"], "leetcode_dataset_entry_point": "Solution().invalidTransactions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:16+00:00", "tests_total": 78, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def invalidTransactions(self, transactions: List[str]) -> List[str]:", "container": "Solution", "callable": "invalidTransactions", "parameters": [{"name": "transactions", "type": "List[str]"}], "return_type": "List[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1170, "task_id": "compare-strings-by-frequency-of-the-smallest-character", "difficulty": "Medium", "problem_description": "Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = \"dcce\" then f(s) = 2 because the lexicographically smallest character is 'c', which has a frequency of 2.\n\nYou are given an array of strings words and another array of query strings queries. For each query queries[i], count the number of words in words such that f(queries[i]) < f(W) for each W in words.\n\nReturn an integer array answer, where each answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: queries = [\"cbd\"], words = [\"zaaaz\"]\nOutput: [1]\nExplanation: On the first query we have f(\"cbd\") = 1, f(\"zaaaz\") = 3 so f(\"cbd\") < f(\"zaaaz\").\n\nExample 2:\n\nInput: queries = [\"bbb\",\"cc\"], words = [\"a\",\"aa\",\"aaa\",\"aaaa\"]\nOutput: [1,2]\nExplanation: On the first query only f(\"bbb\") < f(\"aaaa\"). On the second query both f(\"aaa\") and f(\"aaaa\") are both > f(\"cc\").\n\nConstraints:\n\n- 1 <= queries.length <= 2000\n- 1 <= words.length <= 2000\n- 1 <= queries[i].length, words[i].length <= 10\n- queries[i][j], words[i][j] consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = ['ccc'],words = ['a', 'bb', 'ccc', 'dddd']) == [1]\n assert candidate(queries = ['a', 'b', 'c'],words = ['d', 'e', 'f', 'g']) == [0, 0, 0]\n assert candidate(queries = ['abc', 'def'],words = ['ghi', 'jkl']) == [0, 0]\n assert candidate(queries = ['zzz'],words = ['aaa', 'bbb', 'ccc']) == [0]\n assert candidate(queries = ['abc', 'bcd'],words = ['def', 'ghi']) == [0, 0]\n assert candidate(queries = ['aaa', 'bbb', 'ccc'],words = ['ddd', 'eee', 'fff']) == [0, 0, 0]\n assert candidate(queries = ['a', 'aa', 'aaa'],words = ['b', 'bb', 'bbb', 'bbbb']) == [3, 2, 1]\n assert candidate(queries = ['cbd'],words = ['zaaaz']) == [1]\n assert candidate(queries = ['bbb', 'cc'],words = ['a', 'aa', 'aaa', 'aaaa']) == [1, 2]\n assert candidate(queries = ['a'],words = ['b', 'c', 'd']) == [0]\n assert candidate(queries = ['abc', 'bcd'],words = ['cde', 'def', 'efg']) == [0, 0]\n assert candidate(queries = ['xyz'],words = ['aaa', 'bbb', 'ccc', 'ddd', 'eee']) == [5]\n assert candidate(queries = ['a', 'aa'],words = ['b', 'bb', 'bbb']) == [2, 1]\n assert candidate(queries = ['xyz'],words = ['abc', 'def', 'ghi']) == [0]\n assert candidate(queries = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words = ['k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't']) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = ['zz', 'zaz', 'zzz'],words = ['aaa', 'aa', 'a', 'aaaaa', 'aaaa', 'aaaab']) == [4, 5, 3]\n assert candidate(queries = ['aabbcc', 'ddeeff', 'gghhii'],words = ['jjkkll', 'mmnnoo', 'ppqqrr', 'ssttuu']) == [0, 0, 0]\n assert candidate(queries = ['aaa', 'aab', 'aac'],words = ['bbb', 'bbc', 'bba', 'abb', 'aba', 'aab']) == [0, 1, 1]\n assert candidate(queries = ['ab', 'bc', 'cd'],words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']) == [0, 0, 0]\n assert candidate(queries = ['abcd', 'dcba', 'abcd', 'dcba'],words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == [0, 0, 0, 0]\n assert candidate(queries = ['abcd', 'abdc', 'acdb'],words = ['bcde', 'cdef', 'defg', 'efgh']) == [0, 0, 0]\n assert candidate(queries = ['aaaa', 'bbb', 'cc'],words = ['zzzz', 'zzz', 'zz', 'z']) == [0, 1, 2]\n assert candidate(queries = ['a', 'b', 'c', 'd', 'e', 'f'],words = ['g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']) == [0, 0, 0, 0, 0, 0]\n assert candidate(queries = ['abcdabcd', 'bcdbcd', 'cdcdcd'],words = ['ddd', 'dddd', 'ddddd']) == [3, 3, 2]\n assert candidate(queries = ['a', 'a', 'a', 'a'],words = ['b', 'b', 'b', 'b']) == [0, 0, 0, 0]\n assert candidate(queries = ['abcde', 'bcdef', 'cdefg'],words = ['defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm']) == [0, 0, 0]\n assert candidate(queries = ['zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz'],words = ['zzzz', 'zzz', 'zz', 'z', 'a']) == [0, 0, 0, 0, 1]\n assert candidate(queries = ['hello', 'world'],words = ['python', 'java', 'csharp', 'ruby', 'swift']) == [1, 1]\n assert candidate(queries = ['abcd', 'ab', 'abc'],words = ['abcd', 'abc', 'ab', 'a']) == [0, 0, 0]\n assert candidate(queries = ['x', 'xx', 'xxx', 'xxxx', 'xxxxx'],words = ['y', 'yy', 'yyy', 'yyyy', 'yyyyy', 'yyyyyy']) == [5, 4, 3, 2, 1]\n assert candidate(queries = ['xyxzyz', 'yzyzyx', 'zxzyxz'],words = ['zxyzxy', 'xyzxyz', 'yzxyzx', 'zyxzyz']) == [0, 3, 0]\n assert candidate(queries = ['abcdefghij', 'bcdefghijk', 'cdefghijkl'],words = ['defghijklm', 'efghijklmn', 'fghijklmno', 'ghijklmnop', 'hijklmnopq', 'ijklmnopqr']) == [0, 0, 0]\n assert candidate(queries = ['xyz', 'xyzz', 'xyzzz'],words = ['wxyz', 'wwxyz', 'wwwxyz', 'wwwwxyz']) == [3, 3, 3]\n assert candidate(queries = ['zzzzzz', 'yyyyyy', 'xxxxxx'],words = ['wwwwww', 'vvvvvv', 'uuuuuu', 'tttttt']) == [0, 0, 0]\n assert candidate(queries = ['aabbcc', 'bbccdd', 'ccddee', 'ddeeff', 'eeffgg'],words = ['ffgghh', 'gghhiijj', 'hhiijjkk', 'iijjkkll', 'jjkkllmm']) == [0, 0, 0, 0, 0]\n assert candidate(queries = ['abcdef', 'bcdefg', 'cdefgh'],words = ['defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm', 'ijklmn']) == [0, 0, 0]\n assert candidate(queries = ['zzz', 'zzzz'],words = ['aaaaa', 'aaa', 'aa', 'a']) == [1, 1]\n assert candidate(queries = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz']) == [5, 4, 3, 2, 1]\n assert candidate(queries = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z'],words = ['zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z', 'a']) == [1, 2, 3, 4, 5]\n assert candidate(queries = ['zzz', 'zz', 'z'],words = ['aaa', 'aa', 'a', 'aaaa']) == [1, 2, 3]\n assert candidate(queries = ['aabbcc', 'bbaacc', 'ccaabb'],words = ['aabbb', 'bbccc', 'ccaaa', 'abcabc', 'aabbccaa']) == [2, 2, 2]\n assert candidate(queries = ['aab', 'abb', 'abc'],words = ['aab', 'abb', 'abc', 'acc', 'bac', 'bca', 'cab', 'cba', 'cca']) == [0, 1, 1]\n assert candidate(queries = ['aaaaab', 'aaaabb', 'aaabbb', 'aabbbb', 'abbbbb'],words = ['bbbbb', 'bbbb', 'bbb', 'bb', 'b']) == [0, 1, 2, 3, 4]\n assert candidate(queries = ['apple', 'banana', 'cherry'],words = ['date', 'elderberry', 'fig', 'grape', 'kiwi', 'lemon', 'mango', 'nectarine', 'orange', 'papaya']) == [2, 0, 2]\n assert candidate(queries = ['apple', 'banana', 'cherry'],words = ['date', 'fig', 'grape', 'kiwi']) == [1, 0, 1]\n assert candidate(queries = ['aabbcc', 'bbaacc', 'ccaabb'],words = ['aabbc', 'bbccc', 'ccaab', 'aaabb', 'bbcca', 'ccaab']) == [1, 1, 1]\n assert candidate(queries = ['apple', 'banana', 'cherry'],words = ['date', 'elderberry', 'fig', 'grape']) == [0, 0, 0]\n assert candidate(queries = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z'],words = ['aaaaa', 'aaaa', 'aaa', 'aa', 'a']) == [0, 1, 2, 3, 4]\n assert candidate(queries = ['mnopqr', 'nopqrs', 'opqrst'],words = ['pqrsqt', 'qrstuv', 'rstuvw', 'stuvwx', 'tuvwxy', 'uvwxyx']) == [0, 0, 0]\n assert candidate(queries = ['zzz', 'yyy', 'xxx'],words = ['www', 'vvv', 'uuu', 'ttt', 'ss']) == [0, 0, 0]\n assert candidate(queries = ['aabbcc', 'bbccdd', 'ccddeeff'],words = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij']) == [0, 0, 0]\n assert candidate(queries = ['abcd', 'abc', 'ab'],words = ['zzzz', 'zzz', 'zz', 'z']) == [3, 3, 3]\n assert candidate(queries = ['aabbcc', 'bbccdd', 'ccddaa'],words = ['ddeeff', 'eeffgg', 'ffgghh']) == [0, 0, 0]\n assert candidate(queries = ['aab', 'aabbb', 'aabbbb'],words = ['b', 'bb', 'bbb', 'bbbb', 'bbbbb', 'bbbbbb', 'bbbbbbb']) == [5, 5, 5]\n assert candidate(queries = ['abcd', 'abcde', 'abcdef'],words = ['bcdefg', 'cdefgh', 'defghi', 'efghij']) == [0, 0, 0]\n assert candidate(queries = ['abcd', 'abdc', 'adcb'],words = ['bcde', 'dcbe', 'debc', 'edcb']) == [0, 0, 0]\n assert candidate(queries = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab'],words = ['cdefghi', 'defghij', 'efghijk', 'fghijkl', 'ghijklm']) == [0, 0, 0, 0]\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],words = ['stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv']) == [0, 0, 0]\n assert candidate(queries = ['apple', 'banana', 'cherry'],words = ['date', 'fig', 'grape', 'kiwi', 'lemon', 'mango']) == [1, 0, 1]\n assert candidate(queries = ['abcd', 'abdc', 'aabc'],words = ['aaa', 'aaab', 'baaab', 'baaabbb']) == [4, 4, 4]\n assert candidate(queries = ['a', 'b', 'c', 'd', 'e', 'f'],words = ['g', 'h', 'i', 'j', 'k', 'l', 'm']) == [0, 0, 0, 0, 0, 0]\n assert candidate(queries = ['zzz', 'zzzz', 'zzzzz'],words = ['zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz']) == [4, 4, 4]\n assert candidate(queries = ['zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z'],words = ['aaaaaa', 'aaaaa', 'aaaa', 'aaa', 'aa', 'a']) == [0, 1, 2, 3, 4, 5]\n assert candidate(queries = ['abcdef', 'bcdefg', 'cdefgh'],words = ['defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm']) == [0, 0, 0]\n assert candidate(queries = ['xylophone', 'guitar', 'piano'],words = ['flute', 'harmonica', 'trumpet', 'violin', 'cello', 'saxophone', 'trombone', 'tuba']) == [2, 2, 2]\n assert candidate(queries = ['zz', 'yy', 'xx'],words = ['ww', 'vv', 'uu', 'tt', 'ss', 'rr', 'qq', 'pp', 'oo', 'nn']) == [0, 0, 0]\n assert candidate(queries = ['abcxyz', 'zzzz', 'uvw'],words = ['mnop', 'qrst', 'xyz', 'aabbcc']) == [1, 0, 1]\n assert candidate(queries = ['mnop', 'qrst', 'uvwx', 'yzab', 'cdef'],words = ['efgh', 'ghij', 'ijkl', 'klmn', 'lmno']) == [0, 0, 0, 0, 0]\n assert candidate(queries = ['zzz', 'yyy', 'xxx'],words = ['www', 'vvv', 'uuu', 'ttt']) == [0, 0, 0]\n assert candidate(queries = ['xyzz', 'zzyx', 'zzyy'],words = ['zzzz', 'zzyz', 'zyzz', 'zzzy', 'zyyz', 'zyzy', 'zyzz', 'zzzyz']) == [3, 3, 1]\n assert candidate(queries = ['a', 'b', 'c', 'd', 'e'],words = ['f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']) == [0, 0, 0, 0, 0]\n assert candidate(queries = ['zzz', 'zzzz', 'zzzzz'],words = ['zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == [5, 5, 5]\n assert candidate(queries = ['aaaaa', 'bbb', 'cccc'],words = ['ddd', 'eee', 'ffff', 'ggggg']) == [0, 2, 1]\n assert candidate(queries = ['mnop', 'qrst', 'uvwx', 'yzab'],words = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == [0, 0, 0, 0]\n assert candidate(queries = ['zzzz', 'yyyy', 'xxxx', 'wwww'],words = ['vvvv', 'uuuu', 'tttt', 'ssss', 'rrrr', 'qqqq', 'pppp', 'oooo', 'nnnn', 'mmmm']) == [0, 0, 0, 0]\n assert candidate(queries = ['abcd', 'abcde', 'abcdef'],words = ['bcde', 'bcdef', 'bcdefg', 'bcdefgh', 'bcdefghi', 'bcdefghij']) == [0, 0, 0]\n assert candidate(queries = ['zzz', 'yyy', 'xxx'],words = ['www', 'vvv', 'uuu', 'ttt', 'sss']) == [0, 0, 0]\n assert candidate(queries = ['abc', 'abcd', 'abcde', 'abcdef'],words = ['bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl']) == [0, 0, 0, 0]\n assert candidate(queries = ['xyz', 'xyzz', 'xyzzz'],words = ['uvw', 'uvwv', 'uvwvv', 'uvwvvv', 'uvwvvvv', 'uvwvvvvv']) == [0, 0, 0]\n assert candidate(queries = ['aabbcc', 'bbccdd', 'ccddee'],words = ['ddeeff', 'eeffgg', 'ffgghh', 'gghhii']) == [0, 0, 0]\n assert candidate(queries = ['zzzzz', 'yyyyy', 'xxxxx'],words = ['wwwww', 'vvvvv', 'uuuuu', 'ttttt', 'sssss']) == [0, 0, 0]\n assert candidate(queries = ['abcdefgh', 'hgfedcba', 'fedcbahg'],words = ['ghfedcba', 'ahgfedcb', 'bahgfedc', 'cbahgfed', 'dcbahegf', 'efgdcba', 'gfedcba', 'hgfedcb', 'abcdefgh']) == [0, 0, 0]\n assert candidate(queries = ['ab', 'abc', 'abcd'],words = ['bc', 'bcd', 'bcde', 'bcdef', 'bcdefg', 'bcdefgh']) == [0, 0, 0]\n assert candidate(queries = ['zzzzzzzzzz', 'zzzzzzzzz', 'zzzzzzzz', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z'],words = ['aaaaaaaaaa', 'aaaaaaaaa', 'aaaaaaaa', 'aaaaaaa', 'aaaaaa', 'aaaaa', 'aaaa', 'aaa', 'aa', 'a']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = ['zz', 'yy', 'xx', 'ww', 'vv'],words = ['uu', 'tt', 'ss', 'rr', 'qq', 'pp', 'oo', 'nn', 'mm', 'll']) == [0, 0, 0, 0, 0]\n assert candidate(queries = ['abcdef', 'ghijkl', 'mnopqr'],words = ['stuvwx', 'yzabcd', 'efghij', 'klmnop']) == [0, 0, 0]\n assert candidate(queries = ['mmmmmm', 'nnnnnn', 'oooooo', 'pppppp'],words = ['qqqqqq', 'rrrrrr', 'ssssss', 'tttttt']) == [0, 0, 0, 0]\n assert candidate(queries = ['qwerty', 'asdfgh', 'zxcvbn'],words = ['poiuyt', 'lkjhgf', 'mnbvcx', 'tyuiop', 'ghjklcvbnm']) == [0, 0, 0]\n assert candidate(queries = ['xyz', 'zyx', 'yxz'],words = ['qrs', 'rsq', 'srq']) == [0, 0, 0]\n assert candidate(queries = ['aaaaaaaa', 'bbbbbbbb', 'cccccccc'],words = ['dddddddd', 'eeeeeeee', 'ffffffff', 'gggggggg', 'hhhhhhhh', 'iiiiiiii', 'jjjjjjjj', 'kkkkkkkk', 'llllllll']) == [0, 0, 0]\n assert candidate(queries = ['ab', 'bc', 'cd', 'de', 'ef'],words = ['zz', 'zy', 'yx', 'xw', 'vw', 'uv', 'tu', 'ts', 'sr', 'rq', 'qp', 'po', 'on', 'nm', 'ml', 'lk', 'kj', 'ji', 'ih', 'hg', 'gf', 'fe', 'ed', 'dc', 'cb', 'ba']) == [1, 1, 1, 1, 1]\n assert candidate(queries = ['apple', 'banana', 'cherry'],words = ['date', 'elderberry', 'fig', 'grape', 'honeydew']) == [0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["[\"cbd\"]\n[\"zaaaz\"]", "[\"bbb\",\"cc\"]\n[\"a\",\"aa\",\"aaa\",\"aaaa\"]"], "hints": ["For each string from words calculate the leading count and store it in an array, then sort the integer array.", "For each string from queries calculate the leading count \"p\" and in base of the sorted array calculated on the step 1 do a binary search to count the number of items greater than \"p\"."], "metadata": {"canonical_parameter_names": ["queries", "words"], "leetcode_dataset_entry_point": "Solution().numSmallerByFrequency", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:18+00:00", "tests_total": 100, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "hash-table", "string", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numSmallerByFrequency(self, queries: list[str], words: list[str]) -> list[int]:", "container": "Solution", "callable": "numSmallerByFrequency", "parameters": [{"name": "queries", "type": "list[str]"}, {"name": "words", "type": "list[str]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1175, "task_id": "prime-arrangements", "difficulty": "Easy", "problem_description": "Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.)\n\n(Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers both smaller than it.)\n\nSince the answer may be large, return the answer modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 5\nOutput: 12\nExplanation: For example [1,2,5,4,3] is a valid permutation, but [5,2,3,4,1] is not because the prime number 5 is at index 1.\n\nExample 2:\n\nInput: n = 100\nOutput: 682289015\n\nConstraints:\n\n- 1 <= n <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 30) == 13697484\n assert candidate(n = 99) == 75763854\n assert candidate(n = 75) == 918450925\n assert candidate(n = 20) == 344376809\n assert candidate(n = 2) == 1\n assert candidate(n = 19) == 445364737\n assert candidate(n = 100) == 682289015\n assert candidate(n = 50) == 451768713\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 17280\n assert candidate(n = 5) == 12\n assert candidate(n = 97) == 519081041\n assert candidate(n = 3) == 2\n assert candidate(n = 61) == 250895270\n assert candidate(n = 47) == 627742601\n assert candidate(n = 70) == 892906519\n assert candidate(n = 60) == 125049738\n assert candidate(n = 40) == 965722612\n assert candidate(n = 4) == 4\n assert candidate(n = 37) == 546040181\n assert candidate(n = 98) == 892915734\n assert candidate(n = 73) == 78238453\n assert candidate(n = 80) == 405243354\n assert candidate(n = 89) == 673469112\n assert candidate(n = 85) == 430788419\n assert candidate(n = 83) == 913651722\n assert candidate(n = 90) == 448961084\n", "comparison": "exact"}, "public_tests": ["5", "100"], "hints": ["Solve the problem for prime numbers and composite numbers separately.", "Multiply the number of permutations of prime numbers over prime indices with the number of permutations of composite numbers over composite indices.", "The number of permutations equals the factorial."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numPrimeArrangements", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:23+00:00", "tests_total": 27, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "primality-test", "sieve-theory", "prime-number-sieve"]}, "language": "python", "interface": {"raw_signature": "def numPrimeArrangements(self, n: int) -> int:", "container": "Solution", "callable": "numPrimeArrangements", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1177, "task_id": "can-make-palindrome-from-substring", "difficulty": "Medium", "problem_description": "You are given a string s and array queries where queries[i] = [left_i, right_i, k_i]. We may rearrange the substring s[left_i...right_i] for each query and then choose up to k_i of them to replace with any lowercase English letter.\n\nIf the substring is possible to be a palindrome string after the operations above, the result of the query is true. Otherwise, the result is false.\n\nReturn a boolean array answer where answer[i] is the result of the i^th query queries[i].\n\nNote that each letter is counted individually for replacement, so if, for example s[left_i...right_i] = \"aaa\", and k_i = 2, we can only replace two of the letters. Also, note that no query modifies the initial string s.\n\nExample :\n\nInput: s = \"abcda\", queries = [[3,3,0],[1,2,0],[0,3,1],[0,3,2],[0,4,1]]\nOutput: [true,false,false,true,true]\nExplanation:\nqueries[0]: substring = \"d\", is palidrome.\nqueries[1]: substring = \"bc\", is not palidrome.\nqueries[2]: substring = \"abcd\", is not palidrome after replacing only 1 character.\nqueries[3]: substring = \"abcd\", could be changed to \"abba\" which is palidrome. Also this can be changed to \"baab\" first rearrange it \"bacd\" then replace \"cd\" with \"ab\".\nqueries[4]: substring = \"abcda\", could be changed to \"abcba\" which is palidrome.\n\nExample 2:\n\nInput: s = \"lyb\", queries = [[0,1,0],[2,2,1]]\nOutput: [false,true]\n\nConstraints:\n\n- 1 <= s.length, queries.length <= 10^5\n- 0 <= left_i <= right_i < s.length\n- 0 <= k_i <= s.length\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",queries = [[0, 2, 1], [1, 3, 1]]) == [True, True]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",queries = [[0, 25, 12], [0, 25, 13], [0, 25, 14]]) == [False, True, True]\n assert candidate(s = \"zaz\",queries = [[0, 2, 1], [0, 1, 0], [1, 2, 0]]) == [True, False, False]\n assert candidate(s = \"abcda\",queries = [[3, 3, 0], [1, 2, 0], [0, 3, 1], [0, 3, 2], [0, 4, 1]]) == [True, False, False, True, True]\n assert candidate(s = \"aaaa\",queries = [[0, 3, 0], [1, 2, 0]]) == [True, True]\n assert candidate(s = \"aabbc\",queries = [[0, 4, 2], [1, 3, 1]]) == [True, True]\n assert candidate(s = \"aaaa\",queries = [[0, 3, 0], [0, 2, 0], [1, 3, 0]]) == [True, True, True]\n assert candidate(s = \"aabbc\",queries = [[0, 4, 1], [1, 3, 0]]) == [True, True]\n assert candidate(s = \"lyb\",queries = [[0, 1, 0], [2, 2, 1]]) == [False, True]\n assert candidate(s = \"abcd\",queries = [[0, 0, 0], [1, 1, 0], [2, 2, 0], [3, 3, 0], [0, 3, 2]]) == [True, True, True, True, True]\n assert candidate(s = \"abcdedcba\",queries = [[0, 8, 0], [1, 7, 1], [2, 6, 2]]) == [True, True, True]\n assert candidate(s = \"abcd\",queries = [[0, 0, 0], [1, 1, 0], [2, 2, 0], [3, 3, 0], [0, 3, 2], [0, 3, 3]]) == [True, True, True, True, True, True]\n assert candidate(s = \"aabbc\",queries = [[0, 4, 0], [0, 4, 1], [0, 4, 2]]) == [True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 10, 3], [2, 8, 2], [0, 4, 1]]) == [True, True, True]\n assert candidate(s = \"abcdefghijkilmnopqrstuvwxyz\",queries = [[0, 25, 12], [1, 24, 11], [2, 23, 10], [3, 22, 9], [4, 21, 8], [5, 20, 7], [6, 19, 6]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 0], [2, 4, 0], [0, 5, 1], [1, 4, 1]]) == [True, True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 1], [1, 5, 1], [2, 6, 1], [3, 7, 1], [4, 8, 1], [5, 9, 1], [6, 10, 1]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 12], [10, 20, 5], [30, 40, 10], [25, 45, 20]]) == [True, True, True, True]\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",queries = [[0, 9, 4], [10, 19, 5], [20, 29, 6], [30, 39, 7], [0, 39, 20]]) == [True, True, True, True, True]\n assert candidate(s = \"almostapalindromeexample\",queries = [[0, 20, 5], [5, 15, 3], [10, 20, 6], [0, 20, 8], [5, 15, 2]]) == [True, False, True, True, False]\n assert candidate(s = \"a\",queries = [[0, 0, 0], [0, 0, 1]]) == [True, True]\n assert candidate(s = \"abcdefghij\",queries = [[0, 4, 2], [5, 9, 2], [0, 9, 4], [0, 9, 5], [2, 7, 2]]) == [True, True, False, True, False]\n assert candidate(s = \"anagram\",queries = [[0, 6, 3], [1, 5, 2], [2, 4, 1], [0, 5, 2], [1, 4, 1], [2, 3, 0]]) == [True, True, True, True, False, False]\n assert candidate(s = \"palindrome\",queries = [[0, 7, 3], [1, 6, 2], [2, 5, 1], [0, 6, 2], [1, 5, 1]]) == [False, False, False, False, False]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 0], [2, 4, 0], [0, 5, 1], [1, 4, 1], [0, 4, 2]]) == [True, True, True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 1], [0, 6, 2], [0, 8, 3], [0, 10, 4], [1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 3], [6, 10, 4]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 4, 1], [5, 9, 2], [10, 14, 3], [0, 14, 7], [0, 14, 8], [0, 14, 9]]) == [True, True, True, True, True, True]\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",queries = [[0, 25, 12], [10, 20, 5], [0, 15, 8], [5, 25, 15], [0, 10, 3]]) == [False, True, True, True, False]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 13], [10, 40, 15], [20, 30, 10]]) == [True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 25], [10, 30, 15], [0, 26, 13], [27, 51, 13], [13, 39, 20]]) == [True, True, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 0], [2, 4, 0], [0, 5, 1], [1, 4, 1], [2, 3, 1], [0, 4, 2], [1, 3, 2], [0, 3, 3], [0, 2, 2]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(s = \"noonnoonnoon\",queries = [[0, 3, 1], [4, 7, 1], [8, 11, 1], [0, 11, 2], [0, 11, 3], [0, 11, 4]]) == [True, True, True, True, True, True]\n assert candidate(s = \"aaaaabbbbbccccddddeeeeeffffffggggghhhhhhiiiiii\",queries = [[0, 41, 20], [5, 35, 15], [10, 30, 10], [0, 41, 25], [15, 35, 8]]) == [True, True, True, True, True]\n assert candidate(s = \"thisisaverylongstringwithseveralcharacters\",queries = [[0, 4, 1], [5, 9, 2], [10, 14, 3], [15, 19, 4], [20, 24, 5], [0, 25, 10]]) == [True, True, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 26], [0, 50, 25], [10, 40, 15], [15, 35, 10], [20, 30, 5]]) == [True, True, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 0], [2, 4, 0], [0, 3, 1], [3, 6, 1], [1, 4, 1], [2, 5, 1]]) == [True, True, True, False, False, True, True]\n assert candidate(s = \"aaabbbccc\",queries = [[0, 8, 3], [0, 2, 1], [3, 5, 1], [6, 8, 1]]) == [True, True, True, True]\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",queries = [[0, 25, 12], [0, 25, 13], [0, 25, 14], [0, 12, 6], [13, 25, 6]]) == [False, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 50, 13], [0, 50, 14], [0, 25, 10], [25, 50, 10]]) == [True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 9, 1], [8, 10, 1]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",queries = [[0, 25, 12], [3, 22, 9], [5, 19, 8], [7, 15, 4], [10, 14, 2]]) == [False, False, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 1], [2, 4, 0], [0, 2, 0], [3, 5, 0]]) == [True, True, True, False, False]\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",queries = [[0, 25, 12], [0, 25, 13], [0, 25, 14], [0, 25, 15]]) == [False, True, True, True]\n assert candidate(s = \"abcdabcdabcdabcd\",queries = [[0, 15, 7], [1, 14, 7], [2, 13, 7], [3, 12, 6], [4, 11, 6], [5, 10, 5], [6, 9, 4]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 14, 3], [5, 10, 2], [2, 12, 4]]) == [True, True, True]\n assert candidate(s = \"abcdefghij\",queries = [[0, 9, 5], [1, 8, 4], [2, 7, 3], [3, 6, 2], [4, 5, 1], [0, 8, 4], [1, 7, 3], [2, 6, 2], [3, 5, 1], [0, 7, 3], [1, 6, 2], [2, 5, 1], [0, 6, 2], [1, 5, 1], [0, 5, 1]]) == [True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(s = \"ab\",queries = [[0, 1, 0], [0, 1, 1]]) == [False, True]\n assert candidate(s = \"noon\",queries = [[0, 3, 0], [1, 2, 0], [0, 2, 0], [1, 3, 1], [0, 1, 0], [2, 3, 0]]) == [True, True, True, True, False, False]\n assert candidate(s = \"aaaabbbbcccc\",queries = [[0, 9, 3], [1, 8, 3], [2, 7, 3], [3, 6, 2], [4, 5, 1], [0, 5, 3], [5, 10, 3]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 1], [0, 9, 2], [4, 9, 2], [0, 10, 3], [0, 10, 2]]) == [True, True, True, True, True]\n assert candidate(s = \"aabbaa\",queries = [[0, 5, 1], [1, 4, 0], [2, 3, 1]]) == [True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 13], [5, 46, 25], [10, 41, 17], [15, 36, 10], [20, 31, 5]]) == [True, True, True, True, True]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 14, 3], [2, 12, 4], [5, 9, 2], [1, 13, 5]]) == [True, True, True, True]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 14, 3], [1, 13, 3], [2, 12, 3], [3, 11, 3], [4, 10, 3], [5, 9, 3], [6, 8, 3]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 1], [4, 10, 2], [0, 10, 2], [0, 10, 3], [0, 10, 4], [0, 10, 5]]) == [True, True, True, True, True, True]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",queries = [[0, 25, 12], [1, 24, 12], [2, 23, 12], [3, 22, 12], [4, 21, 12]]) == [False, True, True, True, True]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",queries = [[0, 51, 25], [10, 40, 15], [25, 50, 10], [0, 51, 13], [20, 30, 5]]) == [True, True, False, True, True]\n assert candidate(s = \"level\",queries = [[0, 4, 0], [1, 3, 0], [2, 2, 0], [0, 3, 1], [1, 2, 1]]) == [True, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgg\",queries = [[0, 5, 2], [0, 11, 3], [0, 7, 2], [7, 11, 2]]) == [True, True, True, True]\n assert candidate(s = \"banana\",queries = [[0, 5, 2], [1, 4, 1], [2, 3, 0], [0, 3, 1], [1, 2, 0], [3, 5, 2]]) == [True, True, False, True, False, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 1], [4, 10, 2], [1, 7, 2], [0, 10, 2], [3, 6, 1]]) == [True, True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 4, 2], [1, 3, 0], [0, 10, 4], [5, 9, 1], [2, 8, 3]]) == [True, True, True, True, True]\n assert candidate(s = \"mamad\",queries = [[3, 3, 0], [1, 2, 0], [0, 3, 1], [0, 3, 2], [0, 4, 1]]) == [True, False, True, True, True]\n assert candidate(s = \"nootnoitnoitnoitnoit\",queries = [[0, 17, 8], [1, 16, 7], [2, 15, 6], [3, 14, 5], [4, 13, 4]]) == [True, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 13], [5, 45, 25], [10, 40, 10], [0, 51, 26], [25, 51, 20]]) == [True, True, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 1], [0, 4, 2]]) == [True, True, True]\n assert candidate(s = \"abacaxb\",queries = [[0, 6, 2], [0, 3, 1], [3, 6, 1], [0, 6, 3]]) == [True, True, False, True]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 14, 3], [5, 10, 2], [0, 6, 1], [7, 13, 2], [1, 13, 6]]) == [True, True, True, True, True]\n assert candidate(s = \"mamamamamamamama\",queries = [[0, 13, 3], [1, 12, 4], [2, 11, 2], [3, 10, 1], [4, 9, 0]]) == [True, True, True, True, False]\n assert candidate(s = \"repeatedcharactersinthisstring\",queries = [[0, 24, 10], [5, 15, 5], [10, 20, 8], [0, 24, 12], [5, 15, 3]]) == [True, True, True, True, True]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",queries = [[0, 51, 25], [0, 51, 26], [0, 51, 27], [13, 27, 7], [25, 51, 13]]) == [True, True, True, True, True]\n assert candidate(s = \"banana\",queries = [[0, 5, 1], [1, 4, 1], [2, 3, 1], [0, 3, 2], [1, 2, 2], [3, 4, 2], [2, 5, 2]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"noonnoonnoon\",queries = [[0, 5, 1], [6, 11, 2], [0, 11, 3], [3, 8, 2], [0, 11, 6]]) == [True, True, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 4, 0], [1, 3, 1], [2, 2, 0], [0, 6, 2]]) == [False, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 6, 0], [1, 5, 0], [2, 4, 0], [0, 5, 1], [1, 4, 1], [2, 3, 1]]) == [True, True, True, True, True, True]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",queries = [[0, 25, 12], [26, 51, 13], [0, 51, 26], [13, 38, 18]]) == [False, True, True, True]\n assert candidate(s = \"abcdefgfedcba\",queries = [[0, 12, 0], [1, 11, 1], [2, 10, 2], [3, 9, 3], [4, 8, 4]]) == [True, True, True, True, True]\n assert candidate(s = \"xyzxyzxyzxyzxyz\",queries = [[0, 14, 4], [1, 13, 4], [2, 12, 4], [3, 11, 4], [4, 10, 4], [5, 9, 4]]) == [True, True, True, True, True, True]\n assert candidate(s = \"thisisaverylongandrandomstringfornumberofqueries\",queries = [[0, 40, 15], [10, 35, 10], [20, 30, 5], [0, 40, 20], [15, 25, 8]]) == [True, True, True, True, True]\n assert candidate(s = \"xyzzyx\",queries = [[0, 5, 2], [1, 4, 1], [2, 3, 0]]) == [True, True, True]\n assert candidate(s = \"xyzzazxy\",queries = [[0, 7, 2], [1, 6, 1], [2, 5, 0]]) == [True, False, False]\n assert candidate(s = \"abababababababab\",queries = [[0, 15, 4], [0, 7, 3], [8, 15, 3], [0, 15, 7]]) == [True, True, True, True]\n assert candidate(s = \"abcdefghij\",queries = [[0, 9, 4], [0, 4, 2], [5, 9, 2], [0, 9, 5]]) == [False, True, True, True]\n assert candidate(s = \"palindromechecker\",queries = [[0, 12, 6], [1, 11, 5], [2, 10, 4], [3, 9, 3], [4, 8, 2]]) == [True, True, True, True, True]\n assert candidate(s = \"mississippi\",queries = [[0, 10, 3], [1, 9, 2], [2, 8, 1], [0, 10, 4], [3, 7, 2]]) == [True, True, True, True, True]\n assert candidate(s = \"aabbaa\",queries = [[0, 5, 0], [0, 2, 0], [1, 4, 0], [2, 3, 0]]) == [True, True, True, True]\n assert candidate(s = \"noonnoon\",queries = [[0, 7, 1], [1, 6, 1], [2, 5, 1], [3, 4, 0], [0, 3, 1], [4, 7, 1], [1, 5, 1]]) == [True, True, True, True, True, True, True]\n assert candidate(s = \"qpalzmw\",queries = [[0, 6, 2], [1, 5, 2], [2, 4, 2], [3, 6, 2], [0, 5, 3]]) == [False, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 12], [0, 51, 13], [0, 51, 14], [26, 51, 6], [0, 25, 12], [26, 51, 13]]) == [True, True, True, True, True, True]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 51, 13], [10, 30, 15], [20, 40, 20], [35, 49, 8]]) == [True, True, True, True]\n assert candidate(s = \"racecar\",queries = [[0, 4, 0], [0, 5, 1], [0, 6, 1], [1, 5, 1]]) == [False, True, True, True]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",queries = [[0, 51, 25], [5, 45, 20], [10, 40, 15]]) == [True, True, True]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 3, 1], [0, 4, 1], [1, 5, 2], [2, 6, 1], [3, 7, 2], [4, 8, 3]]) == [True, True, True, True, True, True]\n", "comparison": "exact"}, "public_tests": ["\"abcda\"\n[[3,3,0],[1,2,0],[0,3,1],[0,3,2],[0,4,1]]", "\"lyb\"\n[[0,1,0],[2,2,1]]"], "hints": ["Since we can rearrange the substring, all we care about is the frequency of each character in that substring.", "How to find the character frequencies efficiently ?", "As a preprocess, calculate the accumulate frequency of all characters for all prefixes of the string.", "How to check if a substring can be changed to a palindrome given its characters frequency ?", "Count the number of odd frequencies, there can be at most one odd frequency in a palindrome."], "metadata": {"canonical_parameter_names": ["s", "queries"], "leetcode_dataset_entry_point": "Solution().canMakePaliQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:27+00:00", "tests_total": 93, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def canMakePaliQueries(self, s: str, queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "canMakePaliQueries", "parameters": [{"name": "s", "type": "str"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1178, "task_id": "number-of-valid-words-for-each-puzzle", "difficulty": "Hard", "problem_description": "With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:\n- word contains the first letter of puzzle.\n- For each letter in word, that letter is in puzzle.\n - For example, if the puzzle is \"abcdefg\", then valid words are \"faced\", \"cabbage\", and \"baggage\", while\n - invalid words are \"beefed\" (does not include 'a') and \"based\" (includes 's' which is not in the puzzle).\n\nReturn an array answer, where answer[i] is the number of words in the given word list words that is valid with respect to the puzzle puzzles[i].\n\nExample 1:\n\nInput: words = [\"aaaa\",\"asas\",\"able\",\"ability\",\"actt\",\"actor\",\"access\"], puzzles = [\"aboveyz\",\"abrodyz\",\"abslute\",\"absoryz\",\"actresz\",\"gaswxyz\"]\nOutput: [1,1,3,2,4,0]\nExplanation:\n1 valid word for \"aboveyz\" : \"aaaa\"\n1 valid word for \"abrodyz\" : \"aaaa\"\n3 valid words for \"abslute\" : \"aaaa\", \"asas\", \"able\"\n2 valid words for \"absoryz\" : \"aaaa\", \"asas\"\n4 valid words for \"actresz\" : \"aaaa\", \"asas\", \"actt\", \"access\"\nThere are no valid words for \"gaswxyz\" cause none of the words in the list contains letter 'g'.\n\nExample 2:\n\nInput: words = [\"apple\",\"pleas\",\"please\"], puzzles = [\"aelwxyz\",\"aelpxyz\",\"aelpsxy\",\"saelpxy\",\"xaelpsy\"]\nOutput: [0,1,3,2,0]\n\nConstraints:\n\n- 1 <= words.length <= 10^5\n- 4 <= words[i].length <= 50\n- 1 <= puzzles.length <= 10^4\n- puzzles[i].length == 7\n- words[i] and puzzles[i] consist of lowercase English letters.\n- Each puzzles[i] does not contain repeated characters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['apple', 'pleas', 'please'],puzzles = ['aelwxyz', 'aelpxyz', 'aelpsxy', 'saelpxy', 'xaelpsy']) == [0, 1, 3, 2, 0]\n assert candidate(words = ['aaaa', 'asas', 'able', 'ability', 'actt', 'actor', 'access'],puzzles = ['aboveyz', 'abrodyz', 'abslute', 'absoryz', 'actresz', 'gaswxyz']) == [1, 1, 3, 2, 4, 0]\n assert candidate(words = ['abcdefg'],puzzles = ['abcdefg']) == [1]\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm', 'abcp', 'abcd', 'abcde', 'abcdf', 'abcde', 'abcde', 'abcdf'],puzzles = ['abcdefg', 'gfedcba', 'agfedcb', 'bagfedc', 'cagfedb', 'defghij', 'ghijklm', 'ijklmno', 'jklmnop', 'klmnopq', 'lmnopqr', 'mnopqrs', 'nopqrst', 'opqrstu', 'pqrstuv', 'qrstuvw', 'rstuvwx', 'stuvwxy', 'tuvwxyz']) == [10, 1, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['banana', 'orange', 'apple', 'grape', 'melon', 'kiwi', 'watermelon', 'strawberry', 'blueberry', 'raspberry', 'blackberry', 'mango', 'papaya', 'pineapple'],puzzles = ['aegimno', 'abegijm', 'aceimnu', 'agikmnp', 'agiknpw', 'aegilmn', 'bcehikn', 'abefhij', 'acdefln', 'acdelpw', 'aeghijn', 'aeiklnt', 'agilnop', 'abcklmn']) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1]\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl', 'hijklm'],puzzles = ['abcdefg', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'fghijkl', 'ghijklm', 'hijklmn']) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccddaa', 'aabbdd', 'bbccdd', 'aaccbb', 'aaddee', 'bbffee', 'ccddee', 'ddeeff', 'aabb', 'bbcc', 'ccdd', 'aadd', 'bbeeff', 'ddeegg'],puzzles = ['abcdeff', 'aabbbcc', 'ccdddee', 'bbffeea', 'ddeeggh', 'ffggggg', 'aabbccc', 'dddeeff', 'aabbccf', 'aabbbcc', 'aacceeg', 'bbddeee', 'cdddeee', 'ddeeffe', 'eefffgg', 'bbbeeee']) == [8, 4, 2, 3, 1, 0, 4, 1, 4, 4, 0, 0, 2, 1, 0, 0]\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'abbcdd', 'ddeebf', 'ffgghh', 'iiijjk', 'kkllmm', 'nnoopp', 'qqrstu', 'vwxyzw', 'abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab'],puzzles = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'fghijkl', 'ghijklm', 'hijklmn', 'ijklmno', 'jklmnop', 'klmnopq', 'lmnopqr', 'mnopqrs', 'nopqrst', 'opqrstu', 'pqrstuv', 'qrstuvw', 'rstuvwx', 'stuvwxy', 'tuvwxyz', 'uvwxyzx', 'vwxyzwy']) == [5, 1, 1, 2, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(words = ['algorithm', 'data', 'structure', 'binary', 'tree', 'graph', 'queue', 'stack', 'hashmap', 'trie', 'heap', 'array', 'linkedlist', 'hashset', 'deque', 'priorityqueue', 'bloomfilter', 'bitmask', 'segmenttree', 'binarysearchtree'],puzzles = ['hsdcafr', 'gimnhpt', 'qertabc', 'xylotzp', 'qexhtab', 'qabctrs', 'dhracgp', 'fgihmpr', 'afbnmpt', 'bcdehmp']) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(words = ['programming', 'coding', 'debugging', 'optimization', 'compilation', 'execution', 'interpretation', 'software'],puzzles = ['cpdibqr', 'gingqru', 'eohpamg', 'spgroit', 'qtoadfn', 'hpramgi', 'ironsgd', 'digspqr']) == [0, 0, 0, 0, 0, 0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["[\"aaaa\",\"asas\",\"able\",\"ability\",\"actt\",\"actor\",\"access\"]\n[\"aboveyz\",\"abrodyz\",\"abslute\",\"absoryz\",\"actresz\",\"gaswxyz\"]", "[\"apple\",\"pleas\",\"please\"]\n[\"aelwxyz\",\"aelpxyz\",\"aelpsxy\",\"saelpxy\",\"xaelpsy\"]"], "hints": ["Exploit the fact that the length of the puzzle is only 7.", "Use bit-masks to represent the word and puzzle strings.", "For each puzzle, count the number of words whose bit-mask is a sub-mask of the puzzle's bit-mask."], "metadata": {"canonical_parameter_names": ["words", "puzzles"], "leetcode_dataset_entry_point": "Solution().findNumOfValidWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:30+00:00", "tests_total": 68, "tests_dropped": 58, "flags": [], "topic_tags": ["array", "hash-table", "string", "bit-manipulation", "trie"]}, "language": "python", "interface": {"raw_signature": "def findNumOfValidWords(self, words: list[str], puzzles: list[str]) -> list[int]:", "container": "Solution", "callable": "findNumOfValidWords", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "puzzles", "type": "list[str]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1184, "task_id": "distance-between-bus-stops", "difficulty": "Easy", "problem_description": "A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n.\n\nThe bus goes along both directions i.e. clockwise and counterclockwise.\n\nReturn the shortest distance between the given start and destination stops.\n\nExample 1:\n\nInput: distance = [1,2,3,4], start = 0, destination = 1\nOutput: 1\nExplanation: Distance between 0 and 1 is 1 or 9, minimum is 1.\n\nExample 2:\n\nInput: distance = [1,2,3,4], start = 0, destination = 2\nOutput: 3\nExplanation: Distance between 0 and 2 is 3 or 7, minimum is 3.\n\nExample 3:\n\nInput: distance = [1,2,3,4], start = 0, destination = 3\nOutput: 4\nExplanation: Distance between 0 and 3 is 6 or 4, minimum is 4.\n\nConstraints:\n\n- 1 <= n <= 10^4\n- distance.length == n\n- 0 <= start, destination < n\n- 0 <= distance[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(distance = [7, 10, 1, 12, 11, 14, 5, 0],start = 7,destination = 2) == 17\n assert candidate(distance = [1, 2, 3, 4],start = 0,destination = 2) == 3\n assert candidate(distance = [4, 3, 2],start = 0,destination = 2) == 2\n assert candidate(distance = [1, 2, 3, 4],start = 0,destination = 1) == 1\n assert candidate(distance = [3, 6, 7, 2, 9, 12, 5, 10, 15, 8],start = 3,destination = 7) == 28\n assert candidate(distance = [3, 6, 7, 2, 9, 12, 5, 10, 1],start = 6,destination = 8) == 15\n assert candidate(distance = [3, 6, 7, 2, 9, 12, 5, 10, 15, 8],start = 5,destination = 9) == 35\n assert candidate(distance = [3, 6, 7, 2, 9, 12, 5, 10, 1],start = 5,destination = 8) == 27\n assert candidate(distance = [1, 2, 3, 4],start = 0,destination = 3) == 4\n assert candidate(distance = [3, 4, 5, 1, 2],start = 2,destination = 1) == 4\n assert candidate(distance = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,destination = 9) == 1000\n assert candidate(distance = [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],start = 10,destination = 20) == 1950\n assert candidate(distance = [5, 8, 12, 4, 6, 7, 9, 3, 10, 1, 11],start = 2,destination = 6) == 29\n assert candidate(distance = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],start = 3,destination = 17) == 441\n assert candidate(distance = [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],start = 24,destination = 50) == 1625\n assert candidate(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, 25],start = 10,destination = 20) == 155\n assert candidate(distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 15,destination = 5) == 105\n assert candidate(distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 4,destination = 13) == 39\n assert candidate(distance = [5, 8, 12, 15, 20, 25, 30, 35, 40, 45, 50],start = 2,destination = 8) == 137\n assert candidate(distance = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],start = 5,destination = 10) == 230\n assert candidate(distance = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],start = 12,destination = 5) == 106\n assert candidate(distance = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],start = 7,destination = 3) == 22000\n assert candidate(distance = [2, 10, 3, 5, 1, 7, 8, 6, 9, 4, 12, 11],start = 4,destination = 11) == 31\n assert candidate(distance = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],start = 0,destination = 10) == 105\n assert candidate(distance = [15, 20, 25, 30, 35, 40, 45, 50],start = 0,destination = 7) == 50\n assert candidate(distance = [7, 5, 3, 1, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],start = 6,destination = 13) == 92\n assert candidate(distance = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],start = 8,destination = 17) == 4650\n assert candidate(distance = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 9,destination = 1) == 1100\n assert candidate(distance = [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],start = 25,destination = 5) == 1550\n assert candidate(distance = [100, 200, 150, 100, 50, 250, 300, 50, 100, 200, 150, 250],start = 3,destination = 11) == 700\n assert candidate(distance = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],start = 0,destination = 50) == 75\n assert candidate(distance = [100, 200, 300, 400, 500],start = 1,destination = 3) == 500\n assert candidate(distance = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],start = 25,destination = 5) == 50\n assert candidate(distance = [7, 3, 8, 4, 2, 9, 1, 6, 5],start = 5,destination = 3) == 6\n assert candidate(distance = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260],start = 5,destination = 18) == 702\n assert candidate(distance = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240],start = 10,destination = 18) == 1128\n assert candidate(distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 12,destination = 7) == 50\n assert candidate(distance = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],start = 18,destination = 3) == 90\n assert candidate(distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,destination = 19) == 20\n assert candidate(distance = [50, 40, 30, 20, 10, 5, 2, 1, 9, 8, 7, 6, 4, 3, 2],start = 4,destination = 11) == 42\n assert candidate(distance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0,destination = 19) == 1\n assert candidate(distance = [9, 8, 7, 6, 5, 4, 3, 2, 1],start = 3,destination = 7) == 18\n assert candidate(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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0,destination = 100) == 30\n assert candidate(distance = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 0,destination = 5) == 150\n assert candidate(distance = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],start = 7,destination = 2) == 225\n assert candidate(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, 25, 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 = 23,destination = 17) == 123\n assert candidate(distance = [23, 17, 11, 5, 3, 8, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157],start = 15,destination = 25) == 940\n assert candidate(distance = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 9,destination = 0) == 100\n assert candidate(distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 8,destination = 3) == 25\n assert candidate(distance = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],start = 4,destination = 11) == 245\n assert candidate(distance = [9, 8, 7, 6, 5, 4, 3, 2, 1],start = 2,destination = 7) == 20\n assert candidate(distance = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717],start = 19,destination = 5) == 3388\n assert candidate(distance = [4, 5, 6, 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 = 10,destination = 20) == 185\n assert candidate(distance = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],start = 6,destination = 13) == 5000\n assert candidate(distance = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 2,destination = 7) == 250\n assert candidate(distance = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 3,destination = 14) == 57\n assert candidate(distance = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 2,destination = 6) == 180\n assert candidate(distance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 14,destination = 6) == 36\n assert candidate(distance = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],start = 2,destination = 9) == 104\n assert candidate(distance = [5, 10, 15, 20, 25, 30, 35, 40],start = 1,destination = 6) == 80\n assert candidate(distance = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300],start = 0,destination = 12) == 1300\n assert candidate(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, 1, 1, 1, 1, 1, 1],start = 0,destination = 29) == 3\n assert candidate(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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0,destination = 39) == 8\n assert candidate(distance = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 5,destination = 2) == 1200\n assert candidate(distance = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 0,destination = 9) == 100\n assert candidate(distance = [7, 3, 5, 2, 8, 6, 4, 1, 9, 11, 13, 15, 17],start = 5,destination = 10) == 31\n assert candidate(distance = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],start = 5,destination = 11) == 54\n assert candidate(distance = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77],start = 0,destination = 10) == 77\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n0\n1", "[1,2,3,4]\n0\n2", "[1,2,3,4]\n0\n3"], "hints": ["Find the distance between the two stops if the bus moved in clockwise or counterclockwise directions."], "metadata": {"canonical_parameter_names": ["distance", "start", "destination"], "leetcode_dataset_entry_point": "Solution().distanceBetweenBusStops", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:42+00:00", "tests_total": 68, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def distanceBetweenBusStops(self, distance: List[int], start: int, destination: int) -> int:", "container": "Solution", "callable": "distanceBetweenBusStops", "parameters": [{"name": "distance", "type": "List[int]"}, {"name": "start", "type": "int"}, {"name": "destination", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1185, "task_id": "day-of-the-week", "difficulty": "Easy", "problem_description": "Given a date, return the corresponding day of the week for that date.\n\nThe input is given as three integers representing the day, month and year respectively.\n\nReturn the answer as one of the following values {\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"}.\n\nNote: January 1, 1971 was a Friday.\n\nExample 1:\n\nInput: day = 31, month = 8, year = 2019\nOutput: \"Saturday\"\n\nExample 2:\n\nInput: day = 18, month = 7, year = 1999\nOutput: \"Sunday\"\n\nExample 3:\n\nInput: day = 15, month = 8, year = 1993\nOutput: \"Sunday\"\n\nConstraints:\n\n- The given dates are valid dates between the years 1971 and 2100.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(day = 31,month = 12,year = 2100) == \"Friday\"\n assert candidate(day = 15,month = 8,year = 1993) == \"Sunday\"\n assert candidate(day = 10,month = 9,year = 2023) == \"Sunday\"\n assert candidate(day = 18,month = 7,year = 1999) == \"Sunday\"\n assert candidate(day = 31,month = 8,year = 2019) == \"Saturday\"\n assert candidate(day = 4,month = 7,year = 2023) == \"Tuesday\"\n assert candidate(day = 25,month = 12,year = 2023) == \"Monday\"\n assert candidate(day = 29,month = 2,year = 2004) == \"Sunday\"\n assert candidate(day = 1,month = 1,year = 1971) == \"Friday\"\n assert candidate(day = 29,month = 2,year = 2000) == \"Tuesday\"\n assert candidate(day = 28,month = 2,year = 1900) == \"Wednesday\"\n assert candidate(day = 14,month = 2,year = 2000) == \"Monday\"\n assert candidate(day = 31,month = 10,year = 1984) == \"Wednesday\"\n assert candidate(day = 1,month = 3,year = 1999) == \"Monday\"\n assert candidate(day = 14,month = 3,year = 2047) == \"Thursday\"\n assert candidate(day = 15,month = 6,year = 2050) == \"Wednesday\"\n assert candidate(day = 30,month = 4,year = 2020) == \"Thursday\"\n assert candidate(day = 7,month = 11,year = 2025) == \"Friday\"\n assert candidate(day = 1,month = 9,year = 2001) == \"Saturday\"\n", "comparison": "exact"}, "public_tests": ["31\n8\n2019", "18\n7\n1999", "15\n8\n1993"], "hints": ["Sum up the number of days for the years before the given year.", "Handle the case of a leap year.", "Find the number of days for each month of the given year."], "metadata": {"canonical_parameter_names": ["day", "month", "year"], "leetcode_dataset_entry_point": "Solution().dayOfTheWeek", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:44+00:00", "tests_total": 19, "tests_dropped": 0, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def dayOfTheWeek(self, day: int, month: int, year: int) -> str:", "container": "Solution", "callable": "dayOfTheWeek", "parameters": [{"name": "day", "type": "int"}, {"name": "month", "type": "int"}, {"name": "year", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1186, "task_id": "maximum-subarray-sum-with-one-deletion", "difficulty": "Medium", "problem_description": "Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element left and the sum of the remaining elements is maximum possible.\n\nNote that the subarray needs to be non-empty after deleting one element.\n\nExample 1:\n\nInput: arr = [1,-2,0,3]\nOutput: 4\nExplanation: Because we can choose [1, -2, 0, 3] and drop -2, thus the subarray [1, 0, 3] becomes the maximum value.\n\nExample 2:\n\nInput: arr = [1,-2,-2,3]\nOutput: 3\nExplanation: We just choose [3] and it's the maximum sum.\n\nExample 3:\n\nInput: arr = [-1,-1,-1,-1]\nOutput: -1\nExplanation: The final subarray needs to be non-empty. You can't choose [-1] and delete -1 from it, then get an empty subarray to make the sum equals to 0.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- -10^4 <= arr[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [-1, 0, -2, 3, 4, -5, 3]) == 10\n assert candidate(arr = [5, -1, 5, -1, 5]) == 14\n assert candidate(arr = [2, 3, -2, 5, -3]) == 10\n assert candidate(arr = [-10000]) == -10000\n assert candidate(arr = [5, -3, -2, 7, 1]) == 11\n assert candidate(arr = [2, 1, -2, -5, -2]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5]) == 25\n assert candidate(arr = [1, -2, 0, 3]) == 4\n assert candidate(arr = [10000, -5000, 3000, -2000, 1000]) == 13000\n assert candidate(arr = [-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 10\n assert candidate(arr = [-1, -1, -1, -1]) == -1\n assert candidate(arr = [100, -1, 50, -100, 200]) == 349\n assert candidate(arr = [-10000, 5000, -3000, 2000, -1000]) == 7000\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [-1, 0, -2, 3, 4, -5, 1]) == 8\n assert candidate(arr = [10000, -5000, 5000, -10000, 10000]) == 20000\n assert candidate(arr = [5, -1, 5, -2, 3, -3, 7]) == 17\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5]) == 15\n assert candidate(arr = [-1, 0, 1, -2, 2]) == 3\n assert candidate(arr = [0, 0, 0, 0, 0]) == 0\n assert candidate(arr = [-10000, 10000]) == 10000\n assert candidate(arr = [-10000, 10000, -10000, 10000]) == 20000\n assert candidate(arr = [5, -1, 5]) == 10\n assert candidate(arr = [1, -2, -2, 3]) == 3\n assert candidate(arr = [-5, -4, -3, -2, -1]) == -1\n assert candidate(arr = [-2, -3, 4, -1, -2, 1, 5, -3]) == 9\n assert candidate(arr = [0, 0, 0, 0, 0]) == 0\n assert candidate(arr = [-2, -3, -1, -5]) == -1\n assert candidate(arr = [100, -50, 50, -25, 25, -75, 75, -100, 100]) == 200\n assert candidate(arr = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 28\n assert candidate(arr = [1, 2, 3, 4, -10, 5, 6, 7]) == 28\n assert candidate(arr = [-1, -2, -3, -4, 5, 4, 3, 2, 1, -5, -1, -1, -1, 10]) == 22\n assert candidate(arr = [1, -3, 2, 1, -1, 3, -2, 3, 4, -5]) == 12\n assert candidate(arr = [10, -3, 4, -2, -1, 10, -5, 20, -15]) == 38\n assert candidate(arr = [100, -1, 200, -2, 300, -3, 400, -4, 500, -5]) == 1494\n assert candidate(arr = [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1]) == 4\n assert candidate(arr = [-10, 1, 2, 3, -4, 5, 6, -7, 8, 9, -10, 11, 12, -13]) == 46\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 15\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, -9, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(arr = [10, 20, 30, -5, -10, -15, -20, 50, 60, 70]) == 210\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 9\n assert candidate(arr = [100, -50, 50, -100, 200, -300, 400, -500, 600]) == 1000\n assert candidate(arr = [3, -2, 5, -1, 4, -3, 2, -2]) == 11\n assert candidate(arr = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 15\n assert candidate(arr = [-1, -2, -3, -4, 5, 6, 7, -8, 9, -10, 11]) == 30\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, -50]) == 28\n assert candidate(arr = [1, 2, 3, -6, 4, 5, -3, 2]) == 15\n assert candidate(arr = [5, -3, 8, -1, 6, -4, 9, -2, 7, -5, 10]) == 35\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -100, 11, 12, 13, 14, 15]) == 120\n assert candidate(arr = [1, 2, -5, 1, 2, -1, 5, -1, -2, 3, 4, -2, 3, 4]) == 19\n assert candidate(arr = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11]) == 20\n assert candidate(arr = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 9\n assert candidate(arr = [-10, 100, -50, 50, -25, 25, -75, 75]) == 175\n assert candidate(arr = [1, -2, 3, -4, 5, -6, 7, -8, 9]) == 16\n assert candidate(arr = [10, -3, 4, -2, -1, 10, -5, 1, 2, -1]) == 21\n assert candidate(arr = [10, 20, 30, 40, 50, -100, 10, 20, 30, 40, 50, -100, 10, 20, 30, 40, 50]) == 350\n assert candidate(arr = [-10, -20, 30, -40, 50, -60, 70, -80, 90]) == 160\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) == 1\n assert candidate(arr = [1, -4, 2, -3, 5, -6, 7]) == 12\n assert candidate(arr = [10, -5, -7, 3, 15, -10, 6, -4, 5]) == 25\n assert candidate(arr = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 36\n assert candidate(arr = [-10, -20, -30, 15, 25, 35, -45, 55, 65, 75]) == 270\n assert candidate(arr = [10, -1, 20, -2, 30, -3, 40, -4, 50, -5, 60, -6, 70, -7]) == 265\n assert candidate(arr = [100, 200, 300, -500, 100, 200, 300, -500, 100, 200, 300]) == 1300\n assert candidate(arr = [1, 2, 3, -6, 1, 2, 3, -6, 1, 2, 3, -6, 1, 2, 3]) == 12\n assert candidate(arr = [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 18\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4]) == 7\n assert candidate(arr = [20, -10, -5, -1, 5, 10, -15, 5, 10, -10, -5, 5]) == 34\n assert candidate(arr = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120]) == 220\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14]) == -1\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 2\n assert candidate(arr = [-1, -1, -1, -1, 5, -1, -1, -1, -1]) == 5\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14]) == 26\n assert candidate(arr = [1000, -500, 2000, -1000, 3000, -1500, 4000, -2000, 5000]) == 12000\n assert candidate(arr = [5, -2, -3, 5, -2, -3, 5]) == 8\n assert candidate(arr = [-1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == -100\n assert candidate(arr = [-5, -2, -4, -1, -3, -2, -5]) == -1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(arr = [1, 2, 3, -6, 4, 5, 6, -10, 7, 8, 9]) == 39\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(arr = [3, -1, -1, -1, 3, -1, -1, -1, 3]) == 4\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6]) == 11\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, -5000, 6000, 7000, 8000, 9000]) == 45000\n assert candidate(arr = [10, -3, 4, -1, -2, 1, 5, -3, 4, -2, 0, 1]) == 18\n assert candidate(arr = [100, -101, 200, -201, 300, -301, 400, -401]) == 700\n assert candidate(arr = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 16\n assert candidate(arr = [-15, 14, -13, 12, -11, 10, -9, 8, -7, 6, -5, 4, -3, 2, -1]) == 26\n assert candidate(arr = [10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 10\n assert candidate(arr = [1, 1, 1, 1, -1, -1, -1, -1, 2, 2, 2, 2, -2, -2, -2, -2]) == 9\n assert candidate(arr = [1, 2, 3, -1, -2, -3, 4, 5, 6, -7, 8, 9, 10]) == 42\n assert candidate(arr = [100, -50, 200, -100, 300, -150, 400, -200, 500]) == 1200\n assert candidate(arr = [-1, -2, 3, 4, -5, 6, -7, 8]) == 16\n assert candidate(arr = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5]) == 9\n assert candidate(arr = [1, 2, 3, -6, 1, 2, 3, -6, 1, 2, 3]) == 12\n assert candidate(arr = [-5, 4, -2, 3, -4, 4, -1, -2, 4, 3]) == 13\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(arr = [-1, -2, -3, -4, -5, 10, 1, 2, 3, -1, -2, -3, -4, -5]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(arr = [1, -10, 2, -20, 3, -30, 4, -40, 5, -50]) == 9\n assert candidate(arr = [-1, 4, -2, 3, -2, 3, 7, -5, 1]) == 15\n assert candidate(arr = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0]) == 2\n assert candidate(arr = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 1800\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -1\n assert candidate(arr = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 15\n assert candidate(arr = [100, -1, -1, -1, -1, -1, -1, -1, 100]) == 194\n assert candidate(arr = [5, -3, 8, -1, -2, 7, -4, 9, -6, 10]) == 29\n assert candidate(arr = [100, -100, 200, -200, 300, -300, 400, -400]) == 700\n assert candidate(arr = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 180\n assert candidate(arr = [3, -1, -1, 4, -10, 2, 1, -1, 2, 1, -5, 4]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, -10, 6, 7, 8, 9, 10]) == 55\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(arr = [10, -5, 1, -3, 2, -1, 5, -2, 3, -4, 6]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, -100, 1, 2, 3, 4, 5]) == 30\n assert candidate(arr = [1000, -500, 100, -50, 10, -5, 1, -1, 0, 1, -1, 10, -10, 100, -100, 500, -500]) == 1555\n assert candidate(arr = [100, -50, 200, -300, 400, -500, 600, -700, 800]) == 1400\n assert candidate(arr = [1, -3, 2, 1, -1, 3, -2, 3]) == 8\n assert candidate(arr = [100, -1000, 500, -300, 200, -100, 400, -500, 600]) == 1300\n assert candidate(arr = [1, 2, -3, 4, -5, 6, -7, 8, -9]) == 14\n assert candidate(arr = [1, 2, -5, 1, 2, -1]) == 6\n assert candidate(arr = [-1, 4, -2, 5, -5, 2, -1, 3, -3, 2]) == 11\n assert candidate(arr = [-100, -101, -102, -103, -104, -105]) == -100\n assert candidate(arr = [1, 1, 1, 1, -5, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, -10, 1, 2, 3, 4]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 110\n assert candidate(arr = [-5, -2, -1, -3, -4, -6, -1, -2, -3]) == -1\n assert candidate(arr = [3, -2, 2, -3, 4, -1, -2, 1, 5, -3]) == 10\n assert candidate(arr = [10, -20, 30, -40, 50, -60, 70, -80, 90]) == 160\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == 15\n assert candidate(arr = [1, 2, 3, -6, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 55\n assert candidate(arr = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000]) == 7000\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 18\n assert candidate(arr = [-1, 4, -2, 3, -2, 3, -1, 2, -3, 5]) == 12\n assert candidate(arr = [-1, 4, -2, 3, -2, 3, -1, 2, 1]) == 10\n assert candidate(arr = [100, -1, -2, -3, 100, -1, -2, -3, 100]) == 291\n assert candidate(arr = [7, -4, 3, -6, 2, 1, -5, 4, 3, -1]) == 11\n assert candidate(arr = [3, -1, -1, 3, -1, 3, -1, 3, -1, 3, -1]) == 11\n", "comparison": "exact"}, "public_tests": ["[1,-2,0,3]", "[1,-2,-2,3]", "[-1,-1,-1,-1]"], "hints": ["How to solve this problem if no deletions are allowed ?", "Try deleting each element and find the maximum subarray sum to both sides of that element.", "To do that efficiently, use the idea of Kadane's algorithm."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().maximumSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:46+00:00", "tests_total": 139, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def maximumSum(self, arr: list[int]) -> int:", "container": "Solution", "callable": "maximumSum", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1187, "task_id": "make-array-strictly-increasing", "difficulty": "Hard", "problem_description": "Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing.\n\nIn one operation, you can choose two indices 0 <= i < arr1.length and 0 <= j < arr2.length and do the assignment arr1[i] = arr2[j].\n\nIf there is no way to make arr1 strictly increasing, return -1.\n\nExample 1:\n\nInput: arr1 = [1,5,3,6,7], arr2 = [1,3,2,4]\nOutput: 1\nExplanation: Replace 5 with 2, then arr1 = [1, 2, 3, 6, 7].\n\nExample 2:\n\nInput: arr1 = [1,5,3,6,7], arr2 = [4,3,1]\nOutput: 2\nExplanation: Replace 5 with 3 and then replace 3 with 4. arr1 = [1, 3, 4, 6, 7].\n\nExample 3:\n\nInput: arr1 = [1,5,3,6,7], arr2 = [1,6,3,3]\nOutput: -1\nExplanation: You can't make arr1 strictly increasing.\n\nConstraints:\n\n- 1 <= arr1.length, arr2.length <= 2000\n- 0 <= arr1[i], arr2[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [1, 3, 5, 7],arr2 = [2, 4, 6, 8]) == 0\n assert candidate(arr1 = [1, 5, 3, 6, 7],arr2 = [1, 6, 3, 3]) == -1\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9]) == 0\n assert candidate(arr1 = [1, 5, 3, 6, 7],arr2 = [1, 3, 2, 4]) == 1\n assert candidate(arr1 = [10, 11, 12],arr2 = [5, 6, 7]) == 0\n assert candidate(arr1 = [1],arr2 = [2]) == 0\n assert candidate(arr1 = [1, 5, 3, 6, 7],arr2 = [4, 3, 1]) == 2\n assert candidate(arr1 = [5, 4, 3, 2, 1],arr2 = [1, 2, 3, 4, 5]) == 4\n assert candidate(arr1 = [1, 2, 3, 4],arr2 = [2, 3, 4, 5]) == 0\n assert candidate(arr1 = [10, 9, 8, 7, 6],arr2 = [1, 2, 3, 4, 5]) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr1 = [1, 10, 20, 30],arr2 = [5, 15, 25, 35]) == 0\n assert candidate(arr1 = [1, 2, 2, 3, 4],arr2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(arr1 = [10, 9, 8, 7, 6],arr2 = [5, 4, 3, 2, 1]) == 4\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2]) == -1\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [1, 1, 1],arr2 = [2, 2, 2]) == -1\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2]) == -1\n assert candidate(arr1 = [1, 2000],arr2 = [1000]) == 0\n assert candidate(arr1 = [10, 20, 30],arr2 = [5, 15, 25, 35]) == 0\n assert candidate(arr1 = [1, 2, 3],arr2 = [1, 2, 3]) == 0\n assert candidate(arr1 = [1, 2, 3],arr2 = [4, 5, 6]) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5]) == 4\n assert candidate(arr1 = [1, 2, 2, 3, 4],arr2 = [3, 4, 5]) == 3\n assert candidate(arr1 = [1, 2, 2, 4, 3, 5, 6, 7, 8],arr2 = [2, 3, 5, 7, 9]) == -1\n assert candidate(arr1 = [1, 3, 2, 5, 4],arr2 = [2, 3, 4, 5, 6, 7]) == 2\n assert candidate(arr1 = [1, 2, 2, 3, 3, 4, 5],arr2 = [2, 3, 4, 5, 6, 7, 8]) == 5\n assert candidate(arr1 = [1, 3, 3, 3, 3],arr2 = [2, 4, 6, 8, 10]) == 3\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(arr1 = [1, 3, 2, 5, 4],arr2 = [2, 2, 2, 2, 2, 2]) == -1\n assert candidate(arr1 = [1, 100, 200, 300, 400],arr2 = [2, 150, 250, 350]) == 0\n assert candidate(arr1 = [1, 2, 2, 2, 2],arr2 = [3, 4, 5, 6, 7]) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(arr1 = [10, 9, 8, 7, 6],arr2 = [1, 2, 3, 4, 5, 11, 12]) == 4\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr1 = [1, 10, 9, 10, 9, 10],arr2 = [2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(arr1 = [1, 100, 200, 300, 400],arr2 = [50, 150, 250, 350]) == 0\n assert candidate(arr1 = [1, 2, 3, 10, 1],arr2 = [4, 5, 6, 7, 8, 9]) == 2\n assert candidate(arr1 = [5, 2, 1, 3, 4],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [15, 25, 35, 45, 55]) == 0\n assert candidate(arr1 = [1, 3, 3, 4, 5],arr2 = [2, 2, 2, 6, 7]) == 1\n assert candidate(arr1 = [1, 5, 2, 3, 4, 6, 7, 8, 9, 10],arr2 = [1, 2, 3, 4, 5]) == 4\n assert candidate(arr1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6],arr2 = [2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(arr1 = [1, 100, 2, 101, 3, 102, 4],arr2 = [50, 51, 52, 53, 54]) == -1\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr1 = [10, 5, 3, 8, 2],arr2 = [1, 4, 6, 9, 11]) == 3\n assert candidate(arr1 = [1, 5, 9, 13, 17, 21],arr2 = [2, 6, 10, 14, 18, 22]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 0\n assert candidate(arr1 = [1, 2, 10, 3, 4],arr2 = [5, 6, 7, 8, 9]) == 3\n assert candidate(arr1 = [3, 2, 1],arr2 = [4, 5, 6]) == 2\n assert candidate(arr1 = [1, 3, 2, 4, 5],arr2 = [1, 2, 3, 4, 5]) == 2\n assert candidate(arr1 = [5, 4, 3, 2, 1],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(arr1 = [10, 10, 10, 10],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(arr1 = [1, 2, 2, 2, 2],arr2 = [2, 2, 2, 2, 2]) == -1\n assert candidate(arr1 = [1, 5, 5, 5, 5],arr2 = [2, 3, 4, 6, 7, 8]) == 3\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [5, 5, 5, 5, 5],arr2 = [6, 6, 6, 6, 6]) == -1\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [8, 9, 10, 11, 12]) == 0\n assert candidate(arr1 = [5, 25, 100, 150, 200],arr2 = [1, 20, 50, 125]) == 0\n assert candidate(arr1 = [1, 5, 3, 6, 7, 8, 2, 10, 11, 12],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr1 = [1, 5, 3, 6, 7],arr2 = [2, 4, 6, 8, 10, 12, 14]) == 1\n assert candidate(arr1 = [5, 6, 3, 4, 8, 9],arr2 = [2, 3, 7, 8, 11]) == -1\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr1 = [3, 1, 1, 3],arr2 = [2, 4]) == -1\n assert candidate(arr1 = [1, 2, 3, 1, 2, 3],arr2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(arr1 = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [5, 5, 5, 5, 5]) == 0\n assert candidate(arr1 = [1, 2, 2, 3, 4],arr2 = [2, 3, 4, 5]) == 3\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55]) == 0\n assert candidate(arr1 = [5, 4, 3, 2, 1],arr2 = [6, 7, 8, 9, 10]) == 4\n assert candidate(arr1 = [5, 6, 7, 8, 9, 10],arr2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(arr1 = [1, 10, 20, 30, 40],arr2 = [5, 15, 25, 35]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13],arr2 = [2, 4, 6, 8, 10, 12, 14]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(arr1 = [1, 3, 3, 5, 7],arr2 = [2, 2, 4, 6, 8]) == 1\n assert candidate(arr1 = [1, 9, 8, 7, 6],arr2 = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr1 = [1, 2, 2, 3, 3, 4, 4],arr2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(arr1 = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 100],arr2 = [2, 5, 8, 9]) == 0\n assert candidate(arr1 = [1, 1000000000, 2, 999999999, 3],arr2 = [500000000, 600000000, 700000000, 800000000, 900000000]) == 4\n assert candidate(arr1 = [3, 3, 3, 3, 3],arr2 = [1, 2, 2, 2, 4, 5]) == 4\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(arr1 = [5, 14, 13, 8, 12],arr2 = [1, 4, 3, 9, 11, 10]) == 3\n assert candidate(arr1 = [10, 9, 8, 7, 6],arr2 = [1, 2, 3, 4, 5]) == 4\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55]) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [150, 250, 350, 450, 550]) == 0\n assert candidate(arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 9\n assert candidate(arr1 = [1, 10, 10, 10, 1],arr2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr1 = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],arr2 = [2, 5, 8, 11, 14]) == -1\n assert candidate(arr1 = [1, 2, 3, 100, 100],arr2 = [4, 5, 6, 7]) == 1\n assert candidate(arr1 = [5, 5, 5, 5, 5],arr2 = [1, 2, 3, 4, 5]) == 4\n assert candidate(arr1 = [9, 8, 7, 6, 5],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(arr1 = [100, 200, 150, 300, 250],arr2 = [120, 160, 180, 220, 260]) == 2\n assert candidate(arr1 = [1, 2, 2, 2, 2],arr2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(arr1 = [5, 5, 5, 5, 5, 5, 5],arr2 = [1, 2, 3, 4, 5, 6, 7]) == 6\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [5, 6, 7, 8, 9]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5]) == 0\n assert candidate(arr1 = [1, 10, 20, 30, 40],arr2 = [5, 15, 25, 35, 45]) == 0\n assert candidate(arr1 = [1, 5, 3, 6, 7, 8, 9],arr2 = [1, 3, 2, 4, 5, 6, 7]) == 1\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr1 = [1, 2, 2, 3, 4],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr1 = [6, 7, 8, 10, 9],arr2 = [2, 3, 5, 6, 11, 13, 15]) == 1\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr1 = [100, 90, 80, 70, 60],arr2 = [55, 65, 75, 85, 95, 105]) == 4\n assert candidate(arr1 = [1, 1000000000, 1, 1000000000, 1],arr2 = [2, 3, 4, 5]) == 4\n assert candidate(arr1 = [1, 50, 200, 250, 300],arr2 = [2, 20, 100, 225]) == 0\n assert candidate(arr1 = [10, 12, 14, 16, 18],arr2 = [9, 11, 13, 15, 17]) == 0\n assert candidate(arr1 = [1, 2, 2, 4, 5],arr2 = [1, 3, 5]) == 1\n assert candidate(arr1 = [1, 3, 2, 4, 3, 5],arr2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(arr1 = [1, 20, 3, 40, 5],arr2 = [2, 19, 4, 39, 6]) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr1 = [1000000000, 1000000000, 1000000000],arr2 = [500000000, 500000000, 500000000]) == -1\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 11, 12, 13, 14, 15]) == 0\n assert candidate(arr1 = [1, 5, 9, 13, 17],arr2 = [2, 6, 10, 14, 18]) == 0\n assert candidate(arr1 = [1, 3, 2, 4, 6, 5, 7, 8, 10, 9],arr2 = [2, 5, 6, 8, 9, 11]) == -1\n assert candidate(arr1 = [2000, 1999, 1998, 1997, 1996],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [25, 35, 45, 55, 65]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [1, 10, 100, 1000, 10000],arr2 = [5000, 500, 50, 5, 50000]) == 0\n assert candidate(arr1 = [5, 3, 4, 2, 1],arr2 = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(arr1 = [1, 9, 5, 7, 3],arr2 = [2, 4, 6, 8, 10]) == 2\n assert candidate(arr1 = [10, 20, 30, 25, 40, 50],arr2 = [15, 22, 28, 35, 45, 55]) == 1\n assert candidate(arr1 = [1000000000, 1000000000, 1000000000],arr2 = [1, 2, 3]) == 2\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 0\n assert candidate(arr1 = [1, 3, 2, 4, 5, 6],arr2 = [2, 3, 4, 5, 6, 7]) == 2\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 0\n assert candidate(arr1 = [1, 3, 20, 30, 100],arr2 = [2, 15, 25, 90]) == 0\n assert candidate(arr1 = [1, 3, 2, 4, 3, 5, 4],arr2 = [2, 3, 4, 5, 6, 7]) == 5\n", "comparison": "exact"}, "public_tests": ["[1,5,3,6,7]\n[1,3,2,4]", "[1,5,3,6,7]\n[4,3,1]", "[1,5,3,6,7]\n[1,6,3,3]"], "hints": ["Use dynamic programming.", "The state would be the index in arr1 and the index of the previous element in arr2 after sorting it and removing duplicates."], "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().makeArrayIncreasing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:48+00:00", "tests_total": 145, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "binary-search", "dynamic-programming", "sorting", "longest-increasing-subsequence"]}, "language": "python", "interface": {"raw_signature": "def makeArrayIncreasing(self, arr1: list[int], arr2: list[int]) -> int:", "container": "Solution", "callable": "makeArrayIncreasing", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1189, "task_id": "maximum-number-of-balloons", "difficulty": "Easy", "problem_description": "Given a string text, you want to use the characters of text to form as many instances of the word \"balloon\" as possible.\n\nYou can use each character in text at most once. Return the maximum number of instances that can be formed.\n\nExample 1:\n\nInput: text = \"nlaebolko\"\nOutput: 1\n\nExample 2:\n\nInput: text = \"loonbalxballpoon\"\nOutput: 2\n\nExample 3:\n\nInput: text = \"leetcode\"\nOutput: 0\n\nConstraints:\n\n- 1 <= text.length <= 10^4\n- text consists of lower case English letters only.\n\nNote: This question is the same as 2287: Rearrange Characters to Make Target String.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"bbaalllooonn\") == 1\n assert candidate(text = \"ppooaallbboonn\") == 1\n assert candidate(text = \"leetcode\") == 0\n assert candidate(text = \"balloonballoonballoonballoonballoon\") == 5\n assert candidate(text = \"loonbalxballpoon\") == 2\n assert candidate(text = \"aabbccddeeffgghhiijjkklmmooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(text = \"axbxcxdxeoylno\") == 0\n assert candidate(text = \"bbonnallloo\") == 1\n assert candidate(text = \"bal\") == 0\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(text = \"ballon\") == 0\n assert candidate(text = \"balon\") == 0\n assert candidate(text = \"bnlbaonlbaonlbaon\") == 1\n assert candidate(text = \"balloonballoon\") == 2\n assert candidate(text = \"abcde\") == 0\n assert candidate(text = \"nlaebolko\") == 1\n assert candidate(text = \"balblablaballlaalllooonnnnnnnnn\") == 1\n assert candidate(text = \"balloonballoonballoon\") == 3\n assert candidate(text = \"bbbaalllllooooonnnnballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 12\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 10\n assert candidate(text = \"bbbbbaaaaaallllllloooooonnnnnn\") == 3\n assert candidate(text = \"abracadabraballoonballoon\") == 2\n assert candidate(text = \"bnlaebolkoonnballoon\") == 2\n assert candidate(text = \"blbaloonnnballoonballoonballoonballoonballoonballoonballoonballoon\") == 9\n assert candidate(text = \"bablllooonnnballoon\") == 2\n assert candidate(text = \"blllllaaaaoonnballoon\") == 2\n assert candidate(text = \"bnaloonballoonballoonballoon\") == 3\n assert candidate(text = \"balllllllllooooooonnnnnnnnn\") == 1\n assert candidate(text = \"balbalbalbalbal\") == 0\n assert candidate(text = \"baloonballoonballoon\") == 2\n assert candidate(text = \"bnllobbannolllobnballoon\") == 2\n assert candidate(text = \"balloonballlooballlloon\") == 2\n assert candidate(text = \"baanlloonnn\") == 1\n assert candidate(text = \"balloonballoonbaloonballoonbaloonballoonballoonbaloon\") == 6\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoon\") == 7\n assert candidate(text = \"balooba\") == 0\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 16\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 11\n assert candidate(text = \"abcdeballoonabcde\") == 1\n assert candidate(text = \"bbaallonnnbballoonnballoonballoon\") == 3\n assert candidate(text = \"lnoobaalllnobo\") == 2\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 14\n assert candidate(text = \"blbaloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 16\n assert candidate(text = \"balonbalonbalonbalon\") == 2\n assert candidate(text = \"balloonyballoonballoon\") == 3\n assert candidate(text = \"balloonballoonballoonballoonballoonballoon\") == 6\n assert candidate(text = \"blbloonnbaalononballoon\") == 2\n assert candidate(text = \"ballbaloonn\") == 1\n assert candidate(text = \"loballoonbaloonballoon\") == 3\n assert candidate(text = \"balloonballoonballoonbaloonbaloonballoon\") == 5\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 17\n assert candidate(text = \"ballbalbalbalbalbalbal\") == 0\n assert candidate(text = \"balloonballoonbaloon\") == 2\n assert candidate(text = \"nballoonballoonballoonbaloon\") == 3\n assert candidate(text = \"abbblllooonnnn\") == 1\n assert candidate(text = \"balllllllllooooonnnnnn\") == 1\n assert candidate(text = \"balonbalonbalonbalonbalonbalonbalon\") == 3\n assert candidate(text = \"balloonbaloon\") == 1\n assert candidate(text = \"balllonballlonballlon\") == 1\n assert candidate(text = \"balloonbaloonballoonballoonballoon\") == 4\n assert candidate(text = \"balloonbaloonballoonballoon\") == 3\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 12\n assert candidate(text = \"baloobaloobalooballoonballoon\") == 2\n assert candidate(text = \"noenolbballo\") == 1\n assert candidate(text = \"bllbaaoonnnballoon\") == 2\n assert candidate(text = \"baloonbaloonbaloonbaloonbaloonbaloonbaloonbaloon\") == 4\n assert candidate(text = \"bbbbbaaaaalllllooooonn\") == 2\n assert candidate(text = \"balloonballoonbaloonballoonbaloonballoonballoonbaloonballoon\") == 7\n assert candidate(text = \"ballooballloonballoonbaloon\") == 3\n assert candidate(text = \"balloonballoonbaloonballoonbaloonballoonballoonbaloonbaloonballoon\") == 8\n assert candidate(text = \"balbaloobnoallnoobbaalllnoonnoob\") == 3\n assert candidate(text = \"balloonballoonballoonbaloonbaloon\") == 4\n assert candidate(text = \"abcbabcabcabc\") == 0\n assert candidate(text = \"blablablablablablablablablablaloboon\") == 1\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzballoon\") == 2\n assert candidate(text = \"bloonboonballoonbalo\") == 2\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 15\n assert candidate(text = \"ballonballoonballoon\") == 2\n assert candidate(text = \"balloonballoonballoonballoon\") == 4\n assert candidate(text = \"ballooonnballoon\") == 2\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 13\n assert candidate(text = \"bloonbaloonballonballoonballoon\") == 4\n assert candidate(text = \"bnaloonballoonballoon\") == 2\n assert candidate(text = \"loonballballoon\") == 2\n assert candidate(text = \"baloobaloobaloobalooballoona\") == 1\n assert candidate(text = \"blllaaooonnballoon\") == 2\n assert candidate(text = \"lalalallballboonbaloon\") == 2\n assert candidate(text = \"balllonballlonballlonballlon\") == 2\n assert candidate(text = \"ballooonballoonballoonballoon\") == 4\n assert candidate(text = \"bbbbbaaaaalllllooooonnnn\") == 2\n assert candidate(text = \"balllllllllllooonnnnballoon\") == 2\n assert candidate(text = \"ballooonballoonballoonballoonballoon\") == 5\n assert candidate(text = \"xxxxxyyyyyzzzzzbbaalllooonn\") == 1\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoon\") == 8\n assert candidate(text = \"abbaalllllooonnxxxx\") == 1\n assert candidate(text = \"balonbalonbalon\") == 1\n assert candidate(text = \"baaalllooonnballoonballoon\") == 3\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyzballoon\") == 1\n assert candidate(text = \"lllaaabbbooonnn\") == 1\n assert candidate(text = \"bbaalllllooonnballoon\") == 2\n assert candidate(text = \"baloonbaloonbaloonbaloonbaloon\") == 2\n assert candidate(text = \"baloobaloobaloobaloobalooballoon\") == 1\n assert candidate(text = \"balloonbaloonbaloonbaloonbaloon\") == 3\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoonballoon\") == 18\n assert candidate(text = \"balloonballoonballoonbaloonbaloonbaloonballoon\") == 5\n assert candidate(text = \"balllllloooneeeennn\") == 1\n assert candidate(text = \"lloonnbbaaallooonnxx\") == 2\n assert candidate(text = \"ballballoonloonballoon\") == 3\n assert candidate(text = \"balltooloon\") == 1\n assert candidate(text = \"xxxxxxxxxxxxxxxx\") == 0\n assert candidate(text = \"balloonballoonballoonballoonballoonballoonballoonballoonballoon\") == 9\n assert candidate(text = \"ballllooooooonnn\") == 1\n assert candidate(text = \"balllllooonnnnballoon\") == 2\n assert candidate(text = \"looballonnoballoon\") == 2\n assert candidate(text = \"balllllllllllllllllllllllllllllllllooonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnballoon\") == 2\n assert candidate(text = \"bnllobbannolllobnballoonbnllobbannolllobnballoon\") == 4\n", "comparison": "exact"}, "public_tests": ["\"nlaebolko\"", "\"loonbalxballpoon\"", "\"leetcode\""], "hints": ["Count the frequency of letters in the given string.", "Find the letter than can make the minimum number of instances of the word \"balloon\"."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().maxNumberOfBalloons", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:50+00:00", "tests_total": 117, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def maxNumberOfBalloons(self, text: str) -> int:", "container": "Solution", "callable": "maxNumberOfBalloons", "parameters": [{"name": "text", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1190, "task_id": "reverse-substrings-between-each-pair-of-parentheses", "difficulty": "Medium", "problem_description": "You are given a string s that consists of lower case English letters and brackets.\n\nReverse the strings in each pair of matching parentheses, starting from the innermost one.\n\nYour result should not contain any brackets.\n\nExample 1:\n\nInput: s = \"(abcd)\"\nOutput: \"dcba\"\n\nExample 2:\n\nInput: s = \"(u(love)i)\"\nOutput: \"iloveu\"\nExplanation: The substring \"love\" is reversed first, then the whole string is reversed.\n\nExample 3:\n\nInput: s = \"(ed(et(oc))el)\"\nOutput: \"leetcode\"\nExplanation: First, we reverse the substring \"oc\", then \"etco\", and finally, the whole string.\n\nConstraints:\n\n- 1 <= s.length <= 2000\n- s only contains lower case English characters and parentheses.\n- It is guaranteed that all parentheses are balanced.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(a(b(c)d)e)\") == \"ebcda\"\n assert candidate(s = \"(a(b)c(d(e)f)g)\") == \"gdefcba\"\n assert candidate(s = \"(abc)(def)\") == \"cbafed\"\n assert candidate(s = \"(a(b)c(d)e(f)g)\") == \"gfedcba\"\n assert candidate(s = \"(z)\") == \"z\"\n assert candidate(s = \"(abcd)\") == \"dcba\"\n assert candidate(s = \"a(b)c(d(e)f)g\") == \"abcfedg\"\n assert candidate(s = \"(ed(et(oc))el)\") == \"leetcode\"\n assert candidate(s = \"x(abc)d(efg)h(ij(k(lm)n)op)q\") == \"xcbadgfehpokmlnjiq\"\n assert candidate(s = \"abcdefghij(klmnop(qrstuvwxyz))\") == \"abcdefghijqrstuvwxyzponmlk\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"(abc)d(efg)\") == \"cbadgfe\"\n assert candidate(s = \"(a(b(c)d)e(f(g)h)i\") == \"(adcbehgfi\"\n assert candidate(s = \"()\") == \"\"\n assert candidate(s = \"a(bcdefghijkl(mno)p)q\") == \"apmnolkjihgfedcbq\"\n assert candidate(s = \"(a)\") == \"a\"\n assert candidate(s = \"(u(love)i)\") == \"iloveu\"\n assert candidate(s = \"ab(c(d(e(fg)h)i)j)k\") == \"abjdhfgeick\"\n assert candidate(s = \"(a(b(c(d(e(f(g(h)i)j)k)l)m)n)o\") == \"(anclejghifkdmbo\"\n assert candidate(s = \"x(y(z(wvu)tsr)qpo)nm\") == \"xopqzuvwtsrynm\"\n assert candidate(s = \"(a(b(c)d)e(f(g(h)i)j)k)l\") == \"kfihgjebcdal\"\n assert candidate(s = \"a(bc(def(ghi)jkl)mno(pqr(stu)vwx)y(z))\") == \"azypqrutsvwxonmdefihgjklcb\"\n assert candidate(s = \"a(b(c)d(e(f(g)h)i)j(k(l(m)n)o)p\") == \"a(bcdifghejolmnkp\"\n assert candidate(s = \"a(bc(def(ghi(jkl(mno)pqr)stu)vwx(yz))\") == \"a(bcyzxwvghirqpmnolkjstufed\"\n assert candidate(s = \"a(b(c)d(e(f(g(h)i)j)k)l)m\") == \"alejghifkdcbm\"\n assert candidate(s = \"x(y(z))a(b(c)d)e(f(g(h)i)j)k\") == \"xzyadcbejghifk\"\n assert candidate(s = \"x(y(z))w\") == \"xzyw\"\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(y(x(w(v(u(t(s(r(q(p(o(n(m(l(k(j(i(h(g(f(e(d(c(b(a))))))))))))))))))))\") == \"(a(b(c(d(e(fhjlnprtvxzywusqomkigz(y(x(w(v(usqomkigecabdfhjlnprt\"\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(bdfyhwjulsnqpormtkvixgzec\"\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(egikmoqsuwyzxvtrpnljhf(a(b(c(d(e(fhjlnprtvxzywusqomkig\"\n assert candidate(s = \"(abc)(def)((ghi)(jkl))(mno)(pqr)((stu)(vwx))(yz)\") == \"cbafedjklghionmrqpvwxstuzy\"\n assert candidate(s = \"(a(b(c(d(e(f(g(h(i))))))))\") == \"(acegihfdb\"\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(y(x(w(v(u(t(s(r(q(p(o(n(m(l(k(j(i(h(g(f(e(d(c(b(a))))))))))))))))))))\") == \"(a(bdfyhwjulsnqpormtkvixgzecz(y(x(w(v(usqomkigecabdfhjlnprt\"\n assert candidate(s = \"p(q(r(s)t)u)v(w(x(y(z))w)v)u\") == \"purstqvvxzywwu\"\n assert candidate(s = \"a(b(c(d(e(f(g)h)i)j)k)l)m\") == \"alcjehgfidkbm\"\n assert candidate(s = \"(a(bc)de)\") == \"edbca\"\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(yz))))))))))\") == \"(anclejghifkdmboqsuwyzxvtrp\"\n assert candidate(s = \"a(bc(def(ghi(jkl(mno(pqr(stu(vwx(yz)))))))))b\") == \"adefjklpqrvwxzyutsonmihgcbb\"\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)\") == \"(anclejghifkdmbozqxsvutwryp\"\n assert candidate(s = \"abcdefgh(ijklmnopqrstuvwxyz)\") == \"abcdefghzyxwvutsrqponmlkji\"\n assert candidate(s = \"(abc(def(ghi(jkl(mno)pqr)stu)vwx(yz))(abc(def(ghi(jkl(mno)pqr)stu)vwx(yz))\") == \"(abcyzxwvghirqpmnolkjstufed(abcyzxwvghirqpmnolkjstufed\"\n assert candidate(s = \"(abcdefgh)ijklmnopqrstuvwxyz\") == \"hgfedcbaijklmnopqrstuvwxyz\"\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(vw)x)y)z)))\") == \"anclejghifkdmbo(prztxvwuysq\"\n assert candidate(s = \"a(b(c)d(e(f)g)h)i\") == \"ahefgdcbi\"\n assert candidate(s = \"((abc)(def))\") == \"defabc\"\n assert candidate(s = \"(a(b(c)d)e(f(g(h)i)j)k)\") == \"kfihgjebcda\"\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)))\") == \"(acnejghifklmdotqrspuxwvyzb\"\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)))\") == \"ayzxuvwtqrspknmlojehgfidcb\"\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(u(v(w(x)y)z))))))))))))))\") == \"prtvxzvyxwzuywusqobmdkfihgjelcna\"\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)yz\") == \"adcbejghifkrmponqlsxuvwtyz\"\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))\") == \"zyvwxupsrqtobmdkfihgjelcna\"\n assert candidate(s = \"(a(b(c)d)e(f(g)h)i)\") == \"ifghebcda\"\n assert candidate(s = \"abc(def(ghi)jkl)(mno(pqr)stu)(vw(x(yz)))\") == \"abclkjghifedutspqronmxzywv\"\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))))))))))))))))))))b)c\") == \"a(b(c(d(ebgikmoqsuwyzxvtrpnljhfc\"\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)))))))))\") == \"acegizkxmvotqrspunwlyjhfdb\"\n assert candidate(s = \"(ab)(cd)(ef)(gh)(ij)(kl)(mn)(op)(qr)(st)(uv)(wx)(yz)\") == \"badcfehgjilknmporqtsvuxwzy\"\n assert candidate(s = \"(abcdefgh(i(jklm(nopq)rst)uv)wxyz)\") == \"zyxwitsrnopqmlkjuvhgfedcba\"\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)))\") == \"(anclejghifkdmboqzsxwvutyrp\"\n assert candidate(s = \"(p(q(r)s)t)(u(v(w)x)y)\") == \"tqrspyvwxu\"\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\") == \"anclejghifkdmbotqrspu\"\n assert candidate(s = \"(ab(cd(ef(gh(ij)kl)mn)op)qr)st\") == \"rqcdnmghjiklfeopbast\"\n assert candidate(s = \"(x(y(z)))\") == \"yzx\"\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)u)v)w)x)y(z))\") == \"zypwrutyvwxuzsvqxobmdkfihgjelcna\"\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)\") == \"upsrqtolmnkdifghejcba\"\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))))))))))))))))j)\") == \"(cbahefgdijkmoqsuwyzxvtrpnlj\"\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)\") == \"(avcnelghijkfmdotqrspub\"\n assert candidate(s = \"x(y(z))\") == \"xzy\"\n assert candidate(s = \"x(a(y(b(z(c)d)e)f)g)h(i(j(k(l)m)n)o)p\") == \"xgyezcdbfahojmlknip\"\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)u)v)w)x)y(z))w)x)y(z)\") == \"xpzyrwtuvyxwzuvsxqwobmdkfihgjelcnayz\"\n assert candidate(s = \"(ab)(cd)((ef)(gh))(ij(kl(mn(op)qr)st)(uv(w(x(yz))))\") == \"badcghef(ijtsmnpoqrlkwyzxvu\"\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(fhjlnprtvxzywusqomkig\"\n assert candidate(s = \"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))))))))))))))))))))\") == \"xwzyv(usqomkigecabdfhjlnprt\"\n assert candidate(s = \"((((((((((((a))))))))))))\") == \"a\"\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))\") == \"(pyrwtuvsxqzobmdkfihgjelcna\"\n assert candidate(s = \"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)))\") == \"xzyadcbejghifknmloyzxuvwtqrsp\"\n assert candidate(s = \"(a(b(c(d(e(f(g)))))))\") == \"bdfgeca\"\n assert candidate(s = \"m(n(o(p(q(r(s(t(u(v(w(x(y(z(abc)def)ghi)jkl)mno)pqr)stu)vwx)yzz)\") == \"m(n(o(p(q(rzzytutsvonmxihgzcbadefyjklwpqruvwxs\"\n assert candidate(s = \"(p(q(r(s(t(u(v(w(x(y(z)))))))))))\") == \"qsuwyzxvtrp\"\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))))))))))))))))))))b\") == \"a(b(c(d(e(fhjlnprtvxzywusqomkigb\"\n assert candidate(s = \"(p(q(r(s(t(u)v)w)x)y)z)\") == \"zqxsvutwryp\"\n assert candidate(s = \"(abc(def(ghi(jkl(mno(pqr(stu(vwx(yz)))))))))\") == \"defjklpqrvwxzyutsonmihgcba\"\n assert candidate(s = \"a(b(c(d(e(f(g)h)i)j)k)l)\") == \"alcjehgfidkb\"\n assert candidate(s = \"(a(b(c(d(e(f(g(h(ij)kl)mno)pqr)stu)vw)xy)z)\") == \"(azcwverqpglkijhmnofstudxyb\"\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))\") == \"zypsrqtwvuxobmdkfihgjelcna\"\n assert candidate(s = \"(a(bc(def)ghi)jkl)\") == \"lkjbcfedghia\"\n assert candidate(s = \"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))))))))))))))))))))\") == \"x(yz(w(v(usqomkigecabdfhjlnprt\"\n assert candidate(s = \"((a(b)c)(d(e(f)g)h)i(j(k(l(m)n)o)p)q\") == \"(cbahefgdipknmlojq\"\n assert candidate(s = \"abc(def(ghi(jkl(mno(pqr(stu(vwx)y(z)))))))\") == \"abcghimnostuxwvyzrqplkjfed\"\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))))\") == \"(acnejghifklmdotqrspuxwvyzbbzyvwxupsrqtodmlkfihgjenca\"\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))))))))))))))))))))l(m(n(o(p(q(r(s(t(u(v(w(x(y(z))))))))))))))))\") == \"(a(b(c(dfhjlnprtvxzywusqomkiglnprtvxzywusqome\"\n assert candidate(s = \"(a(b(c(d(e(f)g)h)i)j)\") == \"(ajchefgdib\"\n assert candidate(s = \"x(y(z((a)(b))c)d)e\") == \"xdzbacye\"\n assert candidate(s = \"(a(b(c(d(e(f(g(h(i(jk)lm)n)o)p)q)r)s)t)u)\") == \"ubsdqfohmljkingpercta\"\n", "comparison": "exact"}, "public_tests": ["\"(abcd)\"", "\"(u(love)i)\"", "\"(ed(et(oc))el)\""], "hints": ["Find all brackets in the string.", "Does the order of the reverse matter ?", "The order does not matter."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().reverseParentheses", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:53+00:00", "tests_total": 93, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def reverseParentheses(self, s: str) -> str:", "container": "Solution", "callable": "reverseParentheses", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1191, "task_id": "k-concatenation-maximum-sum", "difficulty": "Medium", "problem_description": "Given an integer array arr and an integer k, modify the array by repeating it k times.\n\nFor example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2].\n\nReturn the maximum sub-array sum in the modified array. Note that the length of the sub-array can be 0 and its sum in that case is 0.\n\nAs the answer can be very large, return the answer modulo 10^9 + 7.\n\nExample 1:\n\nInput: arr = [1,2], k = 3\nOutput: 9\n\nExample 2:\n\nInput: arr = [1,-2,1], k = 5\nOutput: 2\n\nExample 3:\n\nInput: arr = [-1,-2], k = 7\nOutput: 0\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= k <= 10^5\n- -10^4 <= arr[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1],k = 1) == 1\n assert candidate(arr = [-1, 0, 1],k = 3) == 1\n assert candidate(arr = [1, -2, 1],k = 5) == 2\n assert candidate(arr = [3, -2, 2, -3],k = 3) == 3\n assert candidate(arr = [10000, -10000],k = 2) == 10000\n assert candidate(arr = [10000, -10000],k = 100000) == 10000\n assert candidate(arr = [-10000, 10000],k = 100000) == 10000\n assert candidate(arr = [5, -1, 5],k = 3) == 27\n assert candidate(arr = [-1],k = 1) == 0\n assert candidate(arr = [0, 0, 0],k = 100000) == 0\n assert candidate(arr = [-1, -2, -3, -4, -5],k = 1) == 0\n assert candidate(arr = [3, -2, 2, -3],k = 5) == 3\n assert candidate(arr = [5],k = 1) == 5\n assert candidate(arr = [1, 2],k = 3) == 9\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 15\n assert candidate(arr = [0, 0, 0],k = 1) == 0\n assert candidate(arr = [1, -1, 1, -1, 1, -1],k = 100000) == 1\n assert candidate(arr = [1, -10, 1],k = 1) == 1\n assert candidate(arr = [5],k = 10) == 50\n assert candidate(arr = [-1, -2],k = 7) == 0\n assert candidate(arr = [1, 1, 1],k = 100000) == 300000\n assert candidate(arr = [-5],k = 1) == 0\n assert candidate(arr = [10000, -9999],k = 2) == 10001\n assert candidate(arr = [5, -1, 3, -2, 5],k = 10) == 100\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 15\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 540\n assert candidate(arr = [-5, -1, -8, -9],k = 4) == 0\n assert candidate(arr = [-1, -2, -3, -4, -5],k = 50000) == 0\n assert candidate(arr = [-10, 5, -5, 10, -10, 5],k = 7) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 275\n assert candidate(arr = [100, -50, 200, -150, 300, -250, 400, -350, 500, -450],k = 7) == 2200\n assert candidate(arr = [0, 0, 0, 0, 0],k = 100000) == 0\n assert candidate(arr = [-10, -20, -30, -40, -50],k = 2) == 0\n assert candidate(arr = [10, -9, 10, -9, 10, -9, 10, -9, 10, -9],k = 50000) == 250009\n assert candidate(arr = [7, -2, 5, -1, 3, -3, 2, 1],k = 100) == 1200\n assert candidate(arr = [5, -1, 5],k = 100000) == 900000\n assert candidate(arr = [3, -4, 2, -3, -1, 7, -5],k = 10) == 7\n assert candidate(arr = [-10, 100, -1, 100, -100],k = 2) == 288\n assert candidate(arr = [-5, -3, -1, 2, 4, 6],k = 2) == 15\n assert candidate(arr = [1, 2, -3, 4, -5, 6],k = 100000) == 500001\n assert candidate(arr = [100, -200, 300, -400, 500],k = 1000) == 300200\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 100000) == 0\n assert candidate(arr = [5, -1, 5],k = 10) == 90\n assert candidate(arr = [-10, 9, -20, 10, -30, 20, -40, 30, -50, 40],k = 5) == 40\n assert candidate(arr = [1000, -1000, 2000, -2000, 3000, -3000],k = 50000) == 3000\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 100000) == 1\n assert candidate(arr = [5, -1, 2, 3, -2],k = 10) == 72\n assert candidate(arr = [5, -1, 3, -4, 2],k = 10) == 52\n assert candidate(arr = [5, -1, 3, -4, 2, 6, -5],k = 10) == 65\n assert candidate(arr = [10, -3, 4, -2, -1, 10],k = 7) == 126\n assert candidate(arr = [-5, -1, -2, -3, -2],k = 4) == 0\n assert candidate(arr = [-5, -1, -8, -2, -4],k = 50000) == 0\n assert candidate(arr = [10000, -9999, 10000, -9999],k = 50000) == 109999\n assert candidate(arr = [-10000, 10000, -9999, 9999, -9998, 9998],k = 50000) == 10000\n assert candidate(arr = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 100000) == 0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0],k = 100000) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 550\n assert candidate(arr = [-5, 5, -10, 10, -15, 15],k = 3) == 15\n assert candidate(arr = [-1, 0, 1],k = 100000) == 1\n assert candidate(arr = [10000, -5000, 2000, -3000, 1000],k = 50000) == 250005000\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 50000) == 1\n assert candidate(arr = [10000, -9999, 10000, -9999, 10000],k = 50000) == 500100000\n assert candidate(arr = [1, -3, 2, 1, -1],k = 1) == 3\n assert candidate(arr = [10, 20, 30, 40, 50],k = 100000) == 15000000\n assert candidate(arr = [10000, -9999],k = 10) == 10009\n assert candidate(arr = [5, -3, 5, -2, 4, -1],k = 10) == 81\n assert candidate(arr = [0, 0, 0, 0, 0],k = 50000) == 0\n assert candidate(arr = [-1, -2, -3, -4],k = 3) == 0\n assert candidate(arr = [100, -1, 1, -1, 1, -1, 100],k = 5) == 995\n assert candidate(arr = [10, -20, 10, -20, 10],k = 4) == 20\n assert candidate(arr = [-1, -2, -3, -4, -5],k = 100000) == 0\n assert candidate(arr = [-10, 1, -2, 3, -4, 5, -6, 7, -8, 9],k = 3) == 9\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 100000) == 999999937\n assert candidate(arr = [1, -1, 1, -1, 1],k = 5) == 5\n assert candidate(arr = [0, 0, 0, 0],k = 100000) == 0\n assert candidate(arr = [1, -1, 1, -1, 1],k = 100000) == 100000\n assert candidate(arr = [1, -1, 1, -1, 1],k = 99999) == 99999\n assert candidate(arr = [-5, -4, -3, -2, -1],k = 50000) == 0\n assert candidate(arr = [-1, 0, -2],k = 3) == 0\n assert candidate(arr = [10, -3, 4, -1, -2, 1, 5, -3],k = 50) == 553\n assert candidate(arr = [-10, -20, -30, -40],k = 100000) == 0\n assert candidate(arr = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 10) == 15\n assert candidate(arr = [-5, -1, -8, -9],k = 2) == 0\n assert candidate(arr = [7, 1, 5, -3, 6, 7],k = 7) == 161\n assert candidate(arr = [-1, -2, -3, -4, -5],k = 7) == 0\n assert candidate(arr = [10000, -10000, 10000, -10000],k = 10000) == 10000\n assert candidate(arr = [-1, -2, -3, -4, -5],k = 2) == 0\n assert candidate(arr = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 50000) == 10000\n assert candidate(arr = [10, -9, 1, 2, 3],k = 50000) == 350003\n assert candidate(arr = [10000, -9999, 10000, -9999, 10000],k = 100000) == 199993\n assert candidate(arr = [100, -50, 25, -25, 10],k = 6) == 400\n assert candidate(arr = [5, -3, 5, -2, 1, 3],k = 10) == 90\n assert candidate(arr = [5, -3, 5, -2, 7, -1],k = 4) == 45\n assert candidate(arr = [-1, 4, -2, 3, -2],k = 100000) == 200003\n assert candidate(arr = [5, -4, 6, -3, 4],k = 10) == 80\n assert candidate(arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 5) == 0\n assert candidate(arr = [10000, -9999],k = 10000) == 19999\n assert candidate(arr = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991],k = 5000) == 34995\n assert candidate(arr = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 100) == 50\n assert candidate(arr = [1, -1, 1, -1, 1, -1, 1],k = 100000) == 100000\n assert candidate(arr = [9, -4, 5, 1, -2, -3, 7],k = 100) == 1300\n assert candidate(arr = [-1, -2, -3, -4, -5],k = 3) == 0\n assert candidate(arr = [-5, -2, -3, -1],k = 3) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2]\n3", "[1,-2,1]\n5", "[-1,-2]\n7"], "hints": ["How to solve the problem for k=1 ?", "Use Kadane's algorithm for k=1.", "What are the possible cases for the answer ?", "The answer is the maximum between, the answer for k=1, the sum of the whole array multiplied by k, or the maximum suffix sum plus the maximum prefix sum plus (k-2) multiplied by the whole array sum for k > 1."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().kConcatenationMaxSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:55+00:00", "tests_total": 106, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def kConcatenationMaxSum(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "kConcatenationMaxSum", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1192, "task_id": "critical-connections-in-a-network", "difficulty": "Hard", "problem_description": "There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [a_i, b_i] represents a connection between servers a_i and b_i. Any server can reach other servers directly or indirectly through the network.\n\nA critical connection is a connection that, if removed, will make some servers unable to reach some other server.\n\nReturn all critical connections in the network in any order.\n\nExample 1:\n\nInput: n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]\nOutput: [[1,3]]\nExplanation: [[3,1]] is also accepted.\n\nExample 2:\n\nInput: n = 2, connections = [[0,1]]\nOutput: [[0,1]]\n\nConstraints:\n\n- 2 <= n <= 10^5\n- n - 1 <= connections.length <= 10^5\n- 0 <= a_i, b_i <= n - 1\n- a_i != b_i\n- There are no repeated connections.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=7, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [1, 5]]), [])\n assert answers_match(candidate(n=6, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [2, 4]]), [])\n assert answers_match(candidate(n=6, connections=[[0, 1], [1, 2], [2, 0], [1, 3], [3, 4], [4, 5], [5, 3]]), [[1, 3]])\n assert answers_match(candidate(n=5, connections=[[0, 1], [0, 2], [1, 3], [2, 4]]), [[1, 3], [0, 1], [2, 4], [0, 2]])\n assert answers_match(candidate(n=5, connections=[[0, 1], [0, 2], [1, 2], [1, 3], [1, 4]]), [[1, 3], [1, 4]])\n assert answers_match(candidate(n=5, connections=[[0, 1], [0, 2], [1, 3], [2, 3], [2, 4]]), [[2, 4]])\n assert answers_match(candidate(n=4, connections=[[0, 1], [1, 2], [2, 0], [1, 3]]), [[1, 3]])\n assert answers_match(candidate(n=5, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [2, 4]]), [])\n assert answers_match(candidate(n=2, connections=[[0, 1]]), [[0, 1]])\n assert answers_match(candidate(n=6, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]), [])\n assert answers_match(candidate(n=3, connections=[[0, 1], [1, 2]]), [[1, 2], [0, 1]])\n assert answers_match(candidate(n=15, connections=[[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, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5]]), [])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 6], [2, 5], [3, 4]]), [])\n assert answers_match(candidate(n=25, connections=[[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], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23]]), [])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [1, 5], [2, 6], [3, 7]]), [])\n assert answers_match(candidate(n=7, connections=[[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6]]), [])\n assert answers_match(candidate(n=9, connections=[[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]]), [])\n assert answers_match(candidate(n=20, connections=[[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]]), [[14, 15], [13, 14], [12, 13], [11, 12], [10, 11], [9, 10], [8, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2], [0, 1]])\n assert answers_match(candidate(n=10, connections=[[0, 1], [0, 2], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]), [[3, 4], [1, 3]])\n assert answers_match(candidate(n=15, connections=[[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, 5], [3, 7], [6, 10]]), [])\n assert answers_match(candidate(n=12, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [1, 3], [4, 6], [7, 9], [2, 10]]), [])\n assert answers_match(candidate(n=20, connections=[[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, 10], [11, 16], [3, 8], [0, 15]]), [])\n assert answers_match(candidate(n=12, connections=[[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, 3], [5, 7], [8, 11]]), [])\n assert answers_match(candidate(n=12, connections=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 5]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [4, 7], [2, 8]]), [])\n assert answers_match(candidate(n=20, connections=[[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], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 10], [10, 11], [0, 5], [5, 10], [10, 15]]), [])\n assert answers_match(candidate(n=9, connections=[[0, 1], [0, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4], [3, 8], [3, 4]]), [])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 5], [0, 5], [1, 6], [2, 7], [3, 4]]), [])\n assert answers_match(candidate(n=7, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [1, 3], [4, 5], [5, 6], [6, 1]]), [])\n assert answers_match(candidate(n=20, connections=[[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], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]), [])\n assert answers_match(candidate(n=7, connections=[[0, 1], [0, 2], [1, 2], [1, 3], [1, 4], [2, 3], [3, 5], [4, 5], [5, 6], [4, 6]]), [])\n assert answers_match(candidate(n=20, connections=[[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]]), [])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [3, 5], [1, 4], [2, 6], [0, 7]]), [])\n assert answers_match(candidate(n=30, connections=[[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], [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]]), [])\n assert answers_match(candidate(n=11, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 5]]), [[9, 10], [8, 9], [7, 8], [6, 7], [5, 6]])\n assert answers_match(candidate(n=7, connections=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [5, 6], [0, 3]]), [[0, 2]])\n assert answers_match(candidate(n=11, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [1, 5], [3, 7], [6, 0]]), [])\n assert answers_match(candidate(n=15, connections=[[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, 4], [2, 5], [3, 6], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14]]), [])\n assert answers_match(candidate(n=9, connections=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 5], [5, 6]]), [[3, 7], [3, 8], [1, 3]])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]), [[8, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2], [0, 1]])\n assert answers_match(candidate(n=15, connections=[[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], [3, 7], [1, 8], [2, 9], [0, 11], [5, 13]]), [])\n assert answers_match(candidate(n=12, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 5], [5, 0]]), [])\n assert answers_match(candidate(n=12, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [2, 8], [4, 6]]), [])\n assert answers_match(candidate(n=15, connections=[[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, 13], [13, 14], [14, 10]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [1, 3], [5, 7]]), [])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 0], [2, 4], [4, 5], [5, 6], [6, 7], [7, 4]]), [[2, 4]])\n assert answers_match(candidate(n=10, connections=[[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]), [])\n assert answers_match(candidate(n=10, connections=[[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]]), [])\n assert answers_match(candidate(n=12, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [1, 7], [3, 9], [5, 11]]), [])\n assert answers_match(candidate(n=12, connections=[[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], [5, 7]]), [])\n assert answers_match(candidate(n=15, connections=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14], [10, 14]]), [[0, 1], [0, 2]])\n assert answers_match(candidate(n=9, connections=[[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 5], [3, 7], [4, 6], [4, 8]]), [])\n assert answers_match(candidate(n=15, connections=[[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], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13]]), [])\n assert answers_match(candidate(n=20, connections=[[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]]), [])\n assert answers_match(candidate(n=7, connections=[[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [3, 4], [4, 5], [4, 6], [5, 6], [0, 4]]), [])\n assert answers_match(candidate(n=20, connections=[[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], [10, 15], [5, 12]]), [])\n assert answers_match(candidate(n=20, connections=[[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, 10], [10, 15], [0, 5], [5, 15], [10, 18], [15, 18]]), [])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 4], [2, 5], [3, 6]]), [])\n assert answers_match(candidate(n=10, connections=[[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]]), [])\n assert answers_match(candidate(n=15, connections=[[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, 13]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [1, 3], [3, 5], [5, 7], [7, 9]]), [])\n assert answers_match(candidate(n=15, connections=[[0, 1], [0, 2], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 5], [4, 8], [6, 9], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14]]), [[6, 9], [4, 8]])\n assert answers_match(candidate(n=7, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [2, 5]]), [])\n assert answers_match(candidate(n=15, connections=[[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], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 9], [9, 6]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9]]), [[0, 1], [0, 2]])\n assert answers_match(candidate(n=8, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [1, 5]]), [])\n assert answers_match(candidate(n=10, connections=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]), [[4, 5], [3, 4], [2, 3], [1, 2], [0, 1]])\n assert answers_match(candidate(n=15, connections=[[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, 10], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10]]), [])\n assert answers_match(candidate(n=16, connections=[[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, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15]]), [])\n", "comparison": "unordered"}, "public_tests": ["4\n[[0,1],[1,2],[2,0],[1,3]]", "2\n[[0,1]]"], "hints": ["Use Tarjan's algorithm."], "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().criticalConnections", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:12:57+00:00", "tests_total": 71, "tests_dropped": 0, "flags": ["any_order", "has_images"], "topic_tags": ["depth-first-search", "graph", "biconnected-component", "bridge-graph"]}, "language": "python", "interface": {"raw_signature": "def criticalConnections(self, n: int, connections: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "criticalConnections", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1200, "task_id": "minimum-absolute-difference", "difficulty": "Easy", "problem_description": "Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.\n\nReturn a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows\n\n- a, b are from arr\n- a < b\n- b - a equals to the minimum absolute difference of any two elements in arr\n\nExample 1:\n\nInput: arr = [4,2,1,3]\nOutput: [[1,2],[2,3],[3,4]]\nExplanation: The minimum absolute difference is 1. List all pairs with difference equal to 1 in ascending order.\n\nExample 2:\n\nInput: arr = [1,3,6,10,15]\nOutput: [[1,3]]\n\nExample 3:\n\nInput: arr = [3,8,-10,23,19,-4,-14,27]\nOutput: [[-14,-10],[19,23],[23,27]]\n\nConstraints:\n\n- 2 <= arr.length <= 10^5\n- -10^6 <= arr[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 1, 4, 1, 3]) == [[1, 1]]\n assert candidate(arr = [4, 2, 1, 3]) == [[1, 2], [2, 3], [3, 4]]\n assert candidate(arr = [3, 8, -10, 23, 19, -4, -14, 27]) == [[-14, -10], [19, 23], [23, 27]]\n assert candidate(arr = [100000, -100000, 0]) == [[-100000, 0], [0, 100000]]\n assert candidate(arr = [1, 3, 6, 10, 15]) == [[1, 3]]\n assert candidate(arr = [100000, -100000, 50000, -50000]) == [[-100000, -50000], [50000, 100000]]\n assert candidate(arr = [-5, -2, -6, -3, -4]) == [[-6, -5], [-5, -4], [-4, -3], [-3, -2]]\n assert candidate(arr = [1, 2]) == [[1, 2]]\n assert candidate(arr = [-1, 2, 1, -4]) == [[1, 2]]\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]\n assert candidate(arr = [10, 5, 2, 3, 18]) == [[2, 3]]\n assert candidate(arr = [5, 1, 4, 1, 2]) == [[1, 1]]\n assert candidate(arr = [-5, -2, -4, -1]) == [[-5, -4], [-2, -1]]\n assert candidate(arr = [0, 100, 200, 300]) == [[0, 100], [100, 200], [200, 300]]\n assert candidate(arr = [500000, 499999, 499998, 499997, 499996, 499995, 499994, 499993, 499992, 499991, 499990, 499989, 499988, 499987, 499986]) == [[499986, 499987], [499987, 499988], [499988, 499989], [499989, 499990], [499990, 499991], [499991, 499992], [499992, 499993], [499993, 499994], [499994, 499995], [499995, 499996], [499996, 499997], [499997, 499998], [499998, 499999], [499999, 500000]]\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153]) == [[1, 3]]\n assert candidate(arr = [7, 22, 15, 8, 30, 19, 5, 27, 12, 3]) == [[7, 8]]\n assert candidate(arr = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520]) == [[500, 501], [501, 502], [502, 503], [503, 504], [504, 505], [505, 506], [506, 507], [507, 508], [508, 509], [509, 510], [510, 511], [511, 512], [512, 513], [513, 514], [514, 515], [515, 516], [516, 517], [517, 518], [518, 519], [519, 520]]\n assert candidate(arr = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == [[-10, -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, 6], [6, 7], [7, 8], [8, 9], [9, 10]]\n assert candidate(arr = [1, 1000000, 500000, 750000, 250000, 125000, 375000, 625000, 875000]) == [[1, 125000]]\n assert candidate(arr = [1, 2, 3, 5, 6, 8, 9, 10, 12, 13, 15, 16, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31]) == [[1, 2], [2, 3], [5, 6], [8, 9], [9, 10], [12, 13], [15, 16], [18, 19], [21, 22], [24, 25], [27, 28], [30, 31]]\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [[1, 3]]\n assert candidate(arr = [5, 3, 1, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [[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]]\n assert candidate(arr = [1000000, -1000000, 500000, -500000, 0]) == [[-1000000, -500000], [-500000, 0], [0, 500000], [500000, 1000000]]\n assert candidate(arr = [1, 1000000, 2, 999999, 3, 999998]) == [[1, 2], [2, 3], [999998, 999999], [999999, 1000000]]\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, 59]) == [[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, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41], [41, 43], [43, 45], [45, 47], [47, 49], [49, 51], [51, 53], [53, 55], [55, 57], [57, 59]]\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [[2, 3]]\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [[1, 2], [2, 3]]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, -1, -10, -100, -1000, -10000, -100000, -1000000]) == [[-1, 1]]\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000]) == [[-50000, -25000], [25000, 50000]]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [[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]]\n assert candidate(arr = [999999, -999999, 500000, -500000, 250000, -250000, 750000, -750000]) == [[-999999, -750000], [750000, 999999]]\n assert candidate(arr = [-1, -3, -2, -5, -4, -6, -7, -8, -9, -10]) == [[-10, -9], [-9, -8], [-8, -7], [-7, -6], [-6, -5], [-5, -4], [-4, -3], [-3, -2], [-2, -1]]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]]\n assert candidate(arr = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == [[-10, -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, 6], [6, 7], [7, 8], [8, 9], [9, 10]]\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [[-100, -90], [-90, -80], [-80, -70], [-70, -60], [-60, -50], [-50, -40], [-40, -30], [-30, -20], [-20, -10], [-10, 0], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50]]\n assert candidate(arr = [1000000, -1000000, 500000, -500000, 250000, -250000]) == [[-500000, -250000], [250000, 500000]]\n assert candidate(arr = [-3, -1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [[-1, 0]]\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989]) == [[999989, 999990], [999990, 999991], [999991, 999992], [999992, 999993], [999993, 999994], [999994, 999995], [999995, 999996], [999996, 999997], [999997, 999998], [999998, 999999], [999999, 1000000]]\n assert candidate(arr = [1000, 1001, 1003, 1006, 1010, 1015, 1021, 1028, 1036, 1045, 1055, 1066, 1078, 1091, 1105, 1120]) == [[1000, 1001]]\n assert candidate(arr = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, -1100, -1200, -1300]) == [[-1300, -1200], [-1200, -1100], [-1100, -1000], [-1000, -900], [-900, -800], [-800, -700], [-700, -600], [-600, -500], [-500, -400], [-400, -300], [-300, -200], [-200, -100]]\n assert candidate(arr = [-1000000, -999999, -999998, -999997, -999996]) == [[-1000000, -999999], [-999999, -999998], [-999998, -999997], [-999997, -999996]]\n assert candidate(arr = [-1000, -500, -250, -125, -62, -31, -15, -7, -3, -1, 0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]) == [[-1, 0], [0, 1]]\n assert candidate(arr = [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]) == [[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], [2100, 2200], [2200, 2300], [2300, 2400], [2400, 2500]]\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 1001, 2001, 3001, 4001, 5001]) == [[1000, 1001], [2000, 2001], [3000, 3001], [4000, 4001], [5000, 5001]]\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == [[1, 3]]\n assert candidate(arr = [100, 200, 300, 400, 500, 101, 201, 301, 401, 501]) == [[100, 101], [200, 201], [300, 301], [400, 401], [500, 501]]\n assert candidate(arr = [34, -56, 78, -90, 123, -123, 45, -45, 67, -67, 89, -89]) == [[-90, -89]]\n assert candidate(arr = [1, 1000000, 2, 999999, 3, 999998, 4, 999997]) == [[1, 2], [2, 3], [3, 4], [999997, 999998], [999998, 999999], [999999, 1000000]]\n assert candidate(arr = [123456, 654321, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999]) == [[111111, 123456], [654321, 666666]]\n assert candidate(arr = [-1000000, 1000000, -999999, 999999, -999998, 999998, -999997, 999997, -999996, 999996]) == [[-1000000, -999999], [-999999, -999998], [-999998, -999997], [-999997, -999996], [999996, 999997], [999997, 999998], [999998, 999999], [999999, 1000000]]\n assert candidate(arr = [100000, -100000, 50000, -50000, 0, 25000, -25000]) == [[-50000, -25000], [-25000, 0], [0, 25000], [25000, 50000]]\n assert candidate(arr = [5, 9, 15, 22, 30, 38, 47, 57, 68, 80, 93, 107, 122, 138, 155]) == [[5, 9]]\n assert candidate(arr = [5, 3, 1, 4, 2, 8, 6, 7, 10, 9]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [[1, 1], [3, 3], [5, 5], [5, 5]]\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992]) == [[999992, 999993], [999993, 999994], [999994, 999995], [999995, 999996], [999996, 999997], [999997, 999998], [999998, 999999], [999999, 1000000]]\n assert candidate(arr = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550]) == [[100, 150], [150, 200], [200, 250], [250, 300], [300, 350], [350, 400], [400, 450], [450, 500], [500, 550]]\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000]) == [[-100000, -75000], [-75000, -50000], [-50000, -25000], [25000, 50000], [50000, 75000], [75000, 100000]]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [[1, 2]]\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == [[1000, 2000], [2000, 3000], [3000, 4000], [4000, 5000], [5000, 6000], [6000, 7000], [7000, 8000], [8000, 9000], [9000, 10000], [10000, 11000], [11000, 12000], [12000, 13000], [13000, 14000], [14000, 15000]]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]\n assert candidate(arr = [10, 2, 8, 4, 6, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [[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]]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [[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]]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == [[-40, -30], [-30, -20], [-20, -10], [-10, 0], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]\n assert candidate(arr = [-1000000, 1000000, 0, -1, 1, -2, 2, -3, 3, -4, 4]) == [[-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]\n assert candidate(arr = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == [[1, 2], [2, 3], [3, 4], [4, 5], [999996, 999997], [999997, 999998], [999998, 999999], [999999, 1000000]]\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]) == [[1, 2], [2, 3], [3, 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]]\n assert candidate(arr = [1, 3, 6, 8, 10, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == [[1, 3], [6, 8], [8, 10], [10, 12]]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000]) == [[1, 10]]\n assert candidate(arr = [-10, -20, -30, -40, -50, 10, 20, 30, 40, 50]) == [[-50, -40], [-40, -30], [-30, -20], [-20, -10], [10, 20], [20, 30], [30, 40], [40, 50]]\n assert candidate(arr = [5, 3, 8, 6, 7, 2, 4, 1, 9, 10]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]\n assert candidate(arr = [243, 456, 123, 789, 101, 321, 654, 987, 123, 456, 789, 101, 321, 654, 987]) == [[101, 101], [123, 123], [321, 321], [456, 456], [654, 654], [789, 789], [987, 987]]\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], [2, 3], [3, 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(arr = [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]) == [[1, 5], [5, 9], [9, 13], [13, 17], [17, 21], [21, 25], [25, 29], [29, 33], [33, 37], [37, 41], [41, 45], [45, 49], [49, 53], [53, 57], [57, 61], [61, 65], [65, 69], [69, 73], [73, 77], [77, 81], [81, 85], [85, 89], [89, 93], [93, 97]]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [[-10, -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, 6], [6, 7], [7, 8], [8, 9]]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [[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]]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [[-10, -9], [-9, -8], [-8, -7], [-7, -6], [-6, -5], [-5, -4], [-4, -3], [-3, -2], [-2, -1]]\n assert candidate(arr = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15]) == [[1, 2], [2, 3], [5, 6], [8, 9], [11, 12], [14, 15]]\n assert candidate(arr = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == [[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]]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [[-20, -19], [-19, -18], [-18, -17], [-17, -16], [-16, -15], [-15, -14], [-14, -13], [-13, -12], [-12, -11], [-11, -10], [-10, -9], [-9, -8], [-8, -7], [-7, -6], [-6, -5], [-5, -4], [-4, -3], [-3, -2], [-2, -1]]\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == [[999990, 999991], [999991, 999992], [999992, 999993], [999993, 999994], [999994, 999995], [999995, 999996], [999996, 999997], [999997, 999998], [999998, 999999]]\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]) == [[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]]\n assert candidate(arr = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010, 100011, 100012, 100013, 100014]) == [[100000, 100001], [100001, 100002], [100002, 100003], [100003, 100004], [100004, 100005], [100005, 100006], [100006, 100007], [100007, 100008], [100008, 100009], [100009, 100010], [100010, 100011], [100011, 100012], [100012, 100013], [100013, 100014]]\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == [[7, 14], [14, 21], [21, 28], [28, 35], [35, 42], [42, 49], [49, 56], [56, 63], [63, 70]]\n assert candidate(arr = [234, 534, 123, 999, 456, 12, 78, 345, 876, 543, 213, 678, 987, 1234, 5678]) == [[534, 543]]\n assert candidate(arr = [5, 23, 7, 11, 3, 15, 2, 18, 6, 14, 8, 12, 10, 4, 17, 19, 13, 9, 1, 16, 20, 21, 22]) == [[1, 2], [2, 3], [3, 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]]\n assert candidate(arr = [100000, 99998, 99999, 100001, 99997]) == [[99997, 99998], [99998, 99999], [99999, 100000], [100000, 100001]]\n assert candidate(arr = [123456, 654321, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1000000]) == [[999999, 1000000]]\n assert candidate(arr = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420]) == [[42, 84], [84, 126], [126, 168], [168, 210], [210, 252], [252, 294], [294, 336], [336, 378], [378, 420]]\n assert candidate(arr = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900]) == [[-900, -800], [-800, -700], [-700, -600], [-600, -500], [-500, -400], [-400, -300], [-300, -200], [-200, -100], [-100, 0], [0, 100], [100, 200], [200, 300], [300, 400], [400, 500]]\n assert candidate(arr = [1000, 1001, 1003, 1006, 1010, 1015, 1021, 1028, 1036, 1045]) == [[1000, 1001]]\n assert candidate(arr = [-1000000, 1000000, -500000, 500000, 0]) == [[-1000000, -500000], [-500000, 0], [0, 500000], [500000, 1000000]]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == [[1, 2]]\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231]) == [[1, 3]]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [[1, 2]]\n assert candidate(arr = [-100, -99, -97, -94, -90, -85, -80, -75, -70, -65]) == [[-100, -99]]\n", "comparison": "exact"}, "public_tests": ["[4,2,1,3]", "[1,3,6,10,15]", "[3,8,-10,23,19,-4,-14,27]"], "hints": ["Find the minimum absolute difference between two elements in the array.", "The minimum absolute difference must be a difference between two consecutive elements in the sorted array."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minimumAbsDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:08+00:00", "tests_total": 101, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minimumAbsDifference(self, arr: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "minimumAbsDifference", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1201, "task_id": "ugly-number-iii", "difficulty": "Medium", "problem_description": "An ugly number is a positive integer that is divisible by a, b, or c.\n\nGiven four integers n, a, b, and c, return the n^th ugly number.\n\nExample 1:\n\nInput: n = 3, a = 2, b = 3, c = 5\nOutput: 4\nExplanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3^rd is 4.\n\nExample 2:\n\nInput: n = 4, a = 2, b = 3, c = 4\nOutput: 6\nExplanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4^th is 6.\n\nExample 3:\n\nInput: n = 5, a = 2, b = 11, c = 13\nOutput: 10\nExplanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5^th is 10.\n\nConstraints:\n\n- 1 <= n, a, b, c <= 10^9\n- 1 <= a * b * c <= 10^18\n- It is guaranteed that the result will be in range [1, 2 * 10^9].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,a = 2,b = 3,c = 4) == 6\n assert candidate(n = 1,a = 2,b = 3,c = 5) == 2\n assert candidate(n = 3,a = 2,b = 3,c = 5) == 4\n assert candidate(n = 10,a = 2,b = 7,c = 13) == 16\n assert candidate(n = 10,a = 5,b = 7,c = 15) == 30\n assert candidate(n = 10,a = 6,b = 8,c = 14) == 32\n assert candidate(n = 5,a = 2,b = 11,c = 13) == 10\n assert candidate(n = 1000000,a = 2,b = 217983653,c = 336916467) == 2000000\n assert candidate(n = 10,a = 6,b = 7,c = 8) == 28\n assert candidate(n = 1000000,a = 11,b = 17,c = 19) == 5279350\n assert candidate(n = 100,a = 15,b = 25,c = 35) == 925\n assert candidate(n = 100000000,a = 41,b = 89,c = 97) == 2000000000\n assert candidate(n = 1000,a = 10,b = 20,c = 30) == 10000\n assert candidate(n = 500000,a = 17,b = 23,c = 29) == 3822991\n assert candidate(n = 1000000,a = 7,b = 17,c = 19) == 4242027\n assert candidate(n = 500,a = 7,b = 11,c = 13) == 1782\n assert candidate(n = 89,a = 23,b = 31,c = 41) == 902\n assert candidate(n = 500000,a = 7,b = 11,c = 13) == 1781136\n assert candidate(n = 1000000,a = 13,b = 17,c = 19) == 5651417\n assert candidate(n = 100,a = 23,b = 47,c = 83) == 1328\n assert candidate(n = 25,a = 12,b = 18,c = 30) == 204\n assert candidate(n = 200000,a = 89,b = 97,c = 101) == 6427123\n assert candidate(n = 1000000,a = 2,b = 11,c = 17) == 1747664\n assert candidate(n = 10000,a = 11,b = 19,c = 29) == 59367\n assert candidate(n = 1000000,a = 3,b = 17,c = 19) == 2465649\n assert candidate(n = 999999,a = 5,b = 6,c = 7) == 2333330\n assert candidate(n = 1500,a = 2,b = 5,c = 17) == 2405\n assert candidate(n = 1000000,a = 3,b = 11,c = 17) == 2327802\n assert candidate(n = 100,a = 10,b = 15,c = 20) == 750\n assert candidate(n = 100000,a = 13,b = 17,c = 19) == 565148\n assert candidate(n = 100000,a = 5,b = 7,c = 11) == 265518\n assert candidate(n = 100000,a = 11,b = 13,c = 17) == 475735\n assert candidate(n = 500,a = 11,b = 19,c = 23) == 2838\n assert candidate(n = 1000000,a = 5,b = 11,c = 13) == 3042555\n assert candidate(n = 1000000,a = 3,b = 7,c = 13) == 2116281\n assert candidate(n = 10000000,a = 29,b = 61,c = 67) == 155073912\n assert candidate(n = 50,a = 17,b = 23,c = 29) == 374\n assert candidate(n = 1234567,a = 3,b = 5,c = 7) == 2274202\n assert candidate(n = 1000000,a = 11,b = 13,c = 19) == 4877917\n assert candidate(n = 250000,a = 47,b = 53,c = 61) == 4505704\n assert candidate(n = 7,a = 11,b = 13,c = 17) == 34\n assert candidate(n = 30,a = 4,b = 6,c = 8) == 90\n assert candidate(n = 200000,a = 13,b = 17,c = 19) == 1130285\n assert candidate(n = 999999,a = 2,b = 3,c = 4) == 1499998\n assert candidate(n = 100000,a = 31,b = 37,c = 41) == 1228811\n assert candidate(n = 100,a = 7,b = 13,c = 17) == 391\n assert candidate(n = 750000,a = 31,b = 37,c = 41) == 9216182\n assert candidate(n = 10000000,a = 3,b = 5,c = 7) == 18421053\n assert candidate(n = 150,a = 2,b = 3,c = 5) == 205\n assert candidate(n = 500000000,a = 2,b = 217983653,c = 336916467) == 999999994\n assert candidate(n = 1000000,a = 7,b = 14,c = 21) == 7000000\n assert candidate(n = 100,a = 4,b = 6,c = 8) == 300\n assert candidate(n = 50000,a = 19,b = 23,c = 29) == 399779\n assert candidate(n = 250,a = 4,b = 6,c = 8) == 750\n assert candidate(n = 1000000,a = 11,b = 13,c = 17) == 4757346\n assert candidate(n = 30,a = 17,b = 23,c = 29) == 230\n assert candidate(n = 2000000,a = 11,b = 19,c = 29) == 11872682\n assert candidate(n = 50,a = 10,b = 15,c = 20) == 375\n assert candidate(n = 50000000,a = 37,b = 79,c = 83) == 981984141\n assert candidate(n = 750,a = 6,b = 14,c = 21) == 3150\n assert candidate(n = 100,a = 2,b = 3,c = 5) == 136\n assert candidate(n = 1000000,a = 2,b = 4,c = 8) == 2000000\n assert candidate(n = 50,a = 13,b = 17,c = 19) == 285\n assert candidate(n = 150000,a = 13,b = 17,c = 19) == 847717\n assert candidate(n = 50000,a = 3,b = 5,c = 7) == 92105\n assert candidate(n = 1000,a = 3,b = 7,c = 11) == 2082\n assert candidate(n = 1000000,a = 2,b = 3,c = 7) == 1400000\n assert candidate(n = 1000000,a = 2,b = 5,c = 7) == 1521738\n assert candidate(n = 999999,a = 23,b = 31,c = 41) == 10318743\n assert candidate(n = 10,a = 2,b = 3,c = 5) == 14\n assert candidate(n = 999999999,a = 3,b = 5,c = 7) == 1842105261\n assert candidate(n = 1000000,a = 7,b = 11,c = 13) == 3562279\n assert candidate(n = 2000000,a = 3,b = 5,c = 7) == 3684212\n assert candidate(n = 30,a = 9,b = 21,c = 28) == 180\n assert candidate(n = 500000,a = 25,b = 45,c = 65) == 7276125\n assert candidate(n = 1000000,a = 2,b = 17,c = 19) == 1804468\n assert candidate(n = 1000000,a = 2,b = 13,c = 19) == 1776978\n assert candidate(n = 5000,a = 17,b = 37,c = 41) == 46904\n assert candidate(n = 1000000,a = 3,b = 6,c = 9) == 3000000\n assert candidate(n = 1000,a = 123,b = 456,c = 789) == 86838\n assert candidate(n = 500000,a = 6,b = 10,c = 15) == 1875000\n assert candidate(n = 100,a = 4,b = 9,c = 25) == 276\n assert candidate(n = 600000,a = 59,b = 61,c = 67) == 12632448\n assert candidate(n = 300000,a = 3,b = 5,c = 11) == 582354\n assert candidate(n = 10,a = 3,b = 3,c = 3) == 30\n assert candidate(n = 1000000,a = 3,b = 5,c = 11) == 1941177\n assert candidate(n = 100,a = 2,b = 2,c = 3) == 150\n assert candidate(n = 7,a = 5,b = 7,c = 11) == 20\n assert candidate(n = 750000,a = 2,b = 3,c = 6) == 1125000\n assert candidate(n = 500000,a = 2,b = 2,c = 3) == 750000\n assert candidate(n = 1000,a = 11,b = 22,c = 33) == 11000\n assert candidate(n = 50,a = 4,b = 6,c = 8) == 150\n assert candidate(n = 200,a = 7,b = 11,c = 13) == 714\n assert candidate(n = 20,a = 3,b = 5,c = 7) == 36\n assert candidate(n = 5000,a = 9,b = 14,c = 21) == 26250\n assert candidate(n = 1000000,a = 2,b = 7,c = 13) == 1654546\n assert candidate(n = 500,a = 100,b = 200,c = 300) == 50000\n assert candidate(n = 1000000,a = 3,b = 13,c = 19) == 2398058\n assert candidate(n = 1000000,a = 5,b = 10,c = 15) == 5000000\n assert candidate(n = 50,a = 2,b = 4,c = 8) == 100\n assert candidate(n = 1000000,a = 23,b = 53,c = 59) == 12914523\n assert candidate(n = 1000000,a = 5,b = 7,c = 11) == 2655170\n assert candidate(n = 1000000,a = 5,b = 17,c = 19) == 3488125\n assert candidate(n = 750000,a = 17,b = 23,c = 29) == 5734491\n assert candidate(n = 2500,a = 8,b = 15,c = 20) == 12500\n assert candidate(n = 500,a = 5,b = 17,c = 19) == 1745\n assert candidate(n = 800000,a = 29,b = 31,c = 37) == 8802636\n assert candidate(n = 100000,a = 19,b = 43,c = 47) == 1059864\n assert candidate(n = 30,a = 7,b = 11,c = 13) == 105\n assert candidate(n = 20000000,a = 31,b = 71,c = 73) == 339223049\n assert candidate(n = 20,a = 2,b = 3,c = 5) == 27\n assert candidate(n = 15,a = 4,b = 6,c = 8) == 44\n assert candidate(n = 1000000,a = 2,b = 5,c = 11) == 1571428\n assert candidate(n = 1000000,a = 7,b = 13,c = 17) == 3916458\n assert candidate(n = 25,a = 11,b = 13,c = 17) == 117\n assert candidate(n = 1000,a = 13,b = 29,c = 31) == 7280\n assert candidate(n = 1000000000,a = 10,b = 11,c = 12) == 2000000000\n assert candidate(n = 10000,a = 7,b = 11,c = 13) == 35623\n assert candidate(n = 1000000,a = 3,b = 5,c = 7) == 1842106\n assert candidate(n = 2000000,a = 5,b = 10,c = 15) == 10000000\n assert candidate(n = 1000,a = 4,b = 6,c = 8) == 3000\n assert candidate(n = 1000000,a = 5,b = 13,c = 17) == 3278930\n assert candidate(n = 6,a = 10,b = 15,c = 20) == 45\n", "comparison": "exact"}, "public_tests": ["3\n2\n3\n5", "4\n2\n3\n4", "5\n2\n11\n13"], "hints": ["Write a function f(k) to determine how many ugly numbers smaller than k. As f(k) is non-decreasing, try binary search.", "Find all ugly numbers in [1, LCM(a, b, c)] (LCM is Least Common Multiple). Use inclusion-exclusion principle to expand the result."], "metadata": {"canonical_parameter_names": ["n", "a", "b", "c"], "leetcode_dataset_entry_point": "Solution().nthUglyNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:10+00:00", "tests_total": 133, "tests_dropped": 10, "flags": [], "topic_tags": ["math", "binary-search", "combinatorics", "number-theory", "least-common-multiple", "euclidean-algorithm", "greatest-common-divisor", "inclusion-exclusion-principle"]}, "language": "python", "interface": {"raw_signature": "def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "nthUglyNumber", "parameters": [{"name": "n", "type": "int"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1202, "task_id": "smallest-string-with-swaps", "difficulty": "Medium", "problem_description": "You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.\n\nYou can swap the characters at any pair of indices in the given pairs any number of times.\n\nReturn the lexicographically smallest string that s can be changed to after using the swaps.\n\nExample 1:\n\nInput: s = \"dcab\", pairs = [[0,3],[1,2]]\nOutput: \"bacd\"\nExplaination:\nSwap s[0] and s[3], s = \"bcad\"\nSwap s[1] and s[2], s = \"bacd\"\n\nExample 2:\n\nInput: s = \"dcab\", pairs = [[0,3],[1,2],[0,2]]\nOutput: \"abcd\"\nExplaination:\nSwap s[0] and s[3], s = \"bcad\"\nSwap s[0] and s[2], s = \"acbd\"\nSwap s[1] and s[2], s = \"abcd\"\n\nExample 3:\n\nInput: s = \"cba\", pairs = [[0,1],[1,2]]\nOutput: \"abc\"\nExplaination:\nSwap s[0] and s[1], s = \"bca\"\nSwap s[1] and s[2], s = \"bac\"\nSwap s[0] and s[1], s = \"abc\"\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- 0 <= pairs.length <= 10^5\n- 0 <= pairs[i][0], pairs[i][1] < s.length\n- s only contains lower case English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"acbd\",pairs = [[0, 3], [1, 2]]) == \"abcd\"\n assert candidate(s = \"cba\",pairs = [[0, 1], [1, 2]]) == \"abc\"\n assert candidate(s = \"aabbcc\",pairs = [[0, 1], [2, 3], [4, 5]]) == \"aabbcc\"\n assert candidate(s = \"zyx\",pairs = [[0, 1], [1, 2]]) == \"xyz\"\n assert candidate(s = \"abcd\",pairs = [[0, 1], [1, 2], [2, 3]]) == \"abcd\"\n assert candidate(s = \"leetcode\",pairs = [[0, 2], [1, 3]]) == \"eeltcode\"\n assert candidate(s = \"dcab\",pairs = [[0, 3], [1, 2]]) == \"bacd\"\n assert candidate(s = \"dcab\",pairs = [[0, 3], [1, 2], [0, 2]]) == \"abcd\"\n assert candidate(s = \"qwe\",pairs = [[0, 2]]) == \"ewq\"\n assert candidate(s = \"abdc\",pairs = [[0, 3]]) == \"abdc\"\n assert candidate(s = \"vokh\",pairs = [[0, 1], [1, 3], [0, 3]]) == \"hokv\"\n assert candidate(s = \"abcdefgh\",pairs = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4]]) == \"abcdefgh\"\n assert candidate(s = \"jklmno\",pairs = [[0, 3], [1, 4], [2, 5], [0, 5], [1, 3]]) == \"jklmno\"\n assert candidate(s = \"dcabxy\",pairs = [[0, 3], [1, 2], [4, 5], [0, 2]]) == \"abcdxy\"\n assert candidate(s = \"aazaa\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == \"aaaaz\"\n assert candidate(s = \"aefdcba\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == \"aabcdef\"\n assert candidate(s = \"xyzabc\",pairs = [[0, 5], [1, 4], [2, 3], [0, 2]]) == \"abcxyz\"\n assert candidate(s = \"xyzabc\",pairs = [[0, 5], [1, 4], [2, 3]]) == \"cbazyx\"\n assert candidate(s = \"abcdeffedcba\",pairs = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [5, 7], [6, 7]]) == \"abcdeeffdcba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",pairs = [[0, 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]]) == \"mnbrcxuikjagdfshpolzytvewq\"\n assert candidate(s = \"bdcagf\",pairs = [[0, 3], [1, 4], [2, 5]]) == \"adcbgf\"\n assert candidate(s = \"racecar\",pairs = [[0, 6], [1, 5], [2, 4]]) == \"racecar\"\n assert candidate(s = \"abcdefghijk\",pairs = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == \"abcdefghijk\"\n assert candidate(s = \"abcdefg\",pairs = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == \"abcdefg\"\n assert candidate(s = \"leetcode\",pairs = [[0, 2], [1, 3], [4, 5], [6, 7]]) == \"eeltcode\"\n assert candidate(s = \"zyxzyx\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == \"xxyyzz\"\n assert candidate(s = \"abcdefghijk\",pairs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == \"abcdefghijk\"\n assert candidate(s = \"abacabad\",pairs = [[0, 2], [1, 3], [4, 6], [5, 7]]) == \"abacabad\"\n assert candidate(s = \"lkjihgfedcba\",pairs = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 5], [1, 6]]) == \"bcdefghijkla\"\n assert candidate(s = \"algorithm\",pairs = [[0, 6], [1, 5], [2, 4], [3, 7]]) == \"aighrltom\"\n assert candidate(s = \"abcd\",pairs = [[0, 1], [1, 2], [2, 3], [0, 3], [1, 2]]) == \"abcd\"\n assert candidate(s = \"acbdf\",pairs = [[0, 1], [0, 2], [1, 2], [3, 4]]) == \"abcdf\"\n assert candidate(s = \"aabbccddeeff\",pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11]]) == \"aabbccddeeff\"\n assert candidate(s = \"stuvwx\",pairs = [[0, 3], [1, 4], [2, 5], [0, 5], [1, 3], [2, 4]]) == \"stuvwx\"\n assert candidate(s = \"abcde\",pairs = [[0, 1], [0, 4], [1, 2], [2, 3]]) == \"abcde\"\n assert candidate(s = \"ympxz\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == \"mpxyz\"\n assert candidate(s = \"ekzpz\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == \"ekpzz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",pairs = [[0, 25], [1, 24], [2, 23], [3, 22], [4, 21]]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"fedcba\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == \"abcdef\"\n assert candidate(s = \"abacabadabacaba\",pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [1, 13]]) == \"aaaaaaabbbbccda\"\n assert candidate(s = \"abcdefg\",pairs = [[0, 3], [1, 4], [2, 5], [0, 5], [1, 2], [3, 4]]) == \"abcdefg\"\n assert candidate(s = \"hellothereeveryone\",pairs = [[0, 8], [1, 3], [2, 9], [5, 11], [6, 7], [12, 16], [13, 14], [15, 17]]) == \"heelotehrleveryeno\"\n assert candidate(s = \"dcabxyz\",pairs = [[0, 3], [1, 2], [3, 5], [4, 6]]) == \"bacdxyz\"\n assert candidate(s = \"xyzab\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 3]]) == \"abxyz\"\n assert candidate(s = \"uvuuvuvuvu\",pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9], [0, 9]]) == \"uuuuuuvvvv\"\n assert candidate(s = \"abcdefghijk\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == \"abcdefghijk\"\n assert candidate(s = \"uvazyx\",pairs = [[0, 5], [1, 4], [2, 3]]) == \"uvazyx\"\n assert candidate(s = \"xyzxyz\",pairs = [[0, 3], [1, 4], [2, 5]]) == \"xyzxyz\"\n assert candidate(s = \"abcdefghij\",pairs = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5]]) == \"abcdefghij\"\n assert candidate(s = \"programming\",pairs = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 9]]) == \"immangorprg\"\n assert candidate(s = \"ufyx\",pairs = [[0, 3], [1, 2], [0, 2], [1, 3]]) == \"fuxy\"\n assert candidate(s = \"lkjhgfedcba\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == \"abcdefghjkl\"\n assert candidate(s = \"aaaabbbbccccdddd\",pairs = [[0, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [0, 4], [1, 5], [2, 6], [3, 7], [0, 1], [2, 3], [4, 5], [6, 7]]) == \"aaaabbbbccccdddd\"\n assert candidate(s = \"abcdef\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 5]]) == \"abcdef\"\n assert candidate(s = \"nmosq\",pairs = [[0, 3], [1, 2], [2, 3], [3, 4]]) == \"mnoqs\"\n assert candidate(s = \"abcdefgh\",pairs = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [1, 4]]) == \"abcdefgh\"\n assert candidate(s = \"helloworld\",pairs = [[0, 8], [1, 7], [2, 6], [3, 5]]) == \"helloworld\"\n assert candidate(s = \"abcdefghij\",pairs = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 4], [2, 3], [0, 1], [8, 9]]) == \"abcdefghij\"\n assert candidate(s = \"abacabadaba\",pairs = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 5], [1, 4], [2, 3], [0, 1], [8, 9], [5, 6]]) == \"aaaaaabbbcd\"\n assert candidate(s = \"programming\",pairs = [[0, 8], [1, 7], [2, 6], [3, 5], [1, 9]]) == \"immargonprg\"\n assert candidate(s = \"zxcvbnmlkjhgfdsapoiuytrewq\",pairs = [[0, 23], [1, 22], [2, 21], [3, 20], [4, 19], [5, 18], [6, 17], [7, 16], [8, 15], [9, 14], [10, 13], [11, 12]]) == \"ercvbimlajdfghskponuytxzwq\"\n assert candidate(s = \"abcdefghij\",pairs = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == \"abcdefghij\"\n assert candidate(s = \"xyz\",pairs = [[0, 1], [1, 2], [2, 0]]) == \"xyz\"\n assert candidate(s = \"xzy\",pairs = [[0, 1], [1, 2], [0, 2], [1, 2], [0, 1]]) == \"xyz\"\n assert candidate(s = \"abcdefghijk\",pairs = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == \"abcdefghijk\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",pairs = [[0, 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]]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pairs = [[0, 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], [0, 13], [1, 14], [2, 15], [3, 16], [4, 17], [5, 18], [6, 19], [7, 20], [8, 21], [9, 22], [10, 23], [11, 24], [12, 25]]) == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcdefgh\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7]]) == \"abcdefgh\"\n assert candidate(s = \"aaabbbccc\",pairs = [[0, 1], [2, 3], [4, 5], [0, 5], [1, 4], [2, 8]]) == \"aaabbbccc\"\n assert candidate(s = \"abcdexyz\",pairs = [[0, 7], [1, 6], [2, 5], [3, 4]]) == \"abcdexyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",pairs = [[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]]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghij\",pairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == \"abcdefghij\"\n assert candidate(s = \"abcdef\",pairs = [[0, 5], [1, 4], [2, 3]]) == \"abcdef\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",pairs = [[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]]) == \"abcdefghijklmnopqrstuvwxyz\"\n", "comparison": "exact"}, "public_tests": ["\"dcab\"\n[[0,3],[1,2]]", "\"dcab\"\n[[0,3],[1,2],[0,2]]", "\"cba\"\n[[0,1],[1,2]]"], "hints": ["Think of it as a graph problem.", "Consider the pairs as connected nodes in the graph, what can you do with a connected component of indices ?", "We can sort each connected component alone to get the lexicographically minimum string."], "metadata": {"canonical_parameter_names": ["s", "pairs"], "leetcode_dataset_entry_point": "Solution().smallestStringWithSwaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:13+00:00", "tests_total": 74, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "depth-first-search", "breadth-first-search", "union-find", "sorting"]}, "language": "python", "interface": {"raw_signature": "def smallestStringWithSwaps(self, s: str, pairs: list[list[int]]) -> str:", "container": "Solution", "callable": "smallestStringWithSwaps", "parameters": [{"name": "s", "type": "str"}, {"name": "pairs", "type": "list[list[int]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1203, "task_id": "sort-items-by-groups-respecting-dependencies", "difficulty": "Hard", "problem_description": "There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging to it.\n\nReturn a sorted list of the items such that:\n\n- The items that belong to the same group are next to each other in the sorted list.\n- There are some relations between these items where beforeItems[i] is a list containing all the items that should come before the i-th item in the sorted array (to the left of the i-th item).\n\nReturn any solution if there is more than one solution and return an empty list if there is no solution.\n\nExample 1:\n\nInput: n = 8, m = 2, group = [-1,-1,1,0,0,1,0,-1], beforeItems = [[],[6],[5],[6],[3,6],[],[],[]]\nOutput: [6,3,4,1,5,2,0,7]\n\nExample 2:\n\nInput: n = 8, m = 2, group = [-1,-1,1,0,0,1,0,-1], beforeItems = [[],[6],[5],[6],[3],[],[4],[]]\nOutput: []\nExplanation: This is the same as example 1 except that 4 needs to be before 6 in the sorted list.\n\nConstraints:\n\n- 1 <= m <= n <= 3 * 10^4\n- group.length == beforeItems.length == n\n- -1 <= group[i] <= m - 1\n- 0 <= beforeItems[i].length <= n - 1\n- 0 <= beforeItems[i][j] <= n - 1\n- i != beforeItems[i][j]\n- beforeItems[i] does not contain duplicates elements.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8,m = 2,group = [-1, -1, 1, 0, 0, 1, 0, -1],beforeItems = [[], [6], [5], [6], [3, 6], [], [], []]) == [6, 3, 4, 5, 2, 0, 7, 1]\n assert candidate(n = 5,m = 3,group = [0, 0, 1, 1, -1],beforeItems = [[], [2], [3], [], [1, 3]]) == [3, 2, 0, 1, 4]\n assert candidate(n = 8,m = 2,group = [-1, -1, 1, 0, 0, 1, 0, -1],beforeItems = [[], [6], [5], [6], [3], [], [4], []]) == []\n assert candidate(n = 5,m = 3,group = [-1, 0, 0, 1, -1],beforeItems = [[], [2, 3], [3], [], []]) == [3, 0, 4, 2, 1]\n assert candidate(n = 3,m = 1,group = [-1, -1, -1],beforeItems = [[], [2], [1]]) == []\n assert candidate(n = 4,m = 2,group = [0, 0, 1, 1],beforeItems = [[], [2], [0], [1]]) == []\n assert candidate(n = 5,m = 1,group = [0, 0, 0, 0, 0],beforeItems = [[], [0], [0], [1, 2], [1]]) == [0, 1, 2, 4, 3]\n assert candidate(n = 6,m = 2,group = [1, 0, -1, -1, 0, 1],beforeItems = [[], [2, 3], [], [5], [], []]) == [0, 5, 2, 3, 1, 4]\n assert candidate(n = 10,m = 3,group = [0, 0, 0, 1, 1, 1, 2, 2, -1, -1],beforeItems = [[], [6], [7], [5, 8], [9], [3], [4], [], [], []]) == []\n assert candidate(n = 6,m = 3,group = [-1, 0, 0, 1, 1, 2],beforeItems = [[], [3], [4], [5], [], [1]]) == []\n assert candidate(n = 20,m = 5,group = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, -1, -1],beforeItems = [[1, 5], [6, 8], [3, 4], [7, 9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19], [], [], [], [], [], [], [], [], [], [], []]) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 6, 7, 8, 3, 4, 5, 1, 2, 0]\n assert candidate(n = 6,m = 3,group = [0, 0, 1, 1, -1, -1],beforeItems = [[2, 3], [3], [], [], [1, 5], [0]]) == [2, 3, 0, 1, 5, 4]\n assert candidate(n = 15,m = 4,group = [0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, -1, -1],beforeItems = [[], [4], [5], [6, 8], [9, 12], [10, 11], [9, 12], [], [], [7], [3, 13], [12], [5, 7, 8], [7], [0, 8, 10]]) == []\n assert candidate(n = 10,m = 5,group = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4],beforeItems = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0], [3, 4, 5, 6, 7, 8, 9], [2, 5, 6, 7, 8, 9], [2, 3, 6, 7, 8, 9], [2, 3, 4, 7, 8, 9], [2, 3, 4, 5, 8, 9], [2, 3, 4, 5, 6, 9], [2, 3, 4, 5, 6, 7, 9], [2, 3, 4, 5, 6, 7, 8]]) == []\n assert candidate(n = 12,m = 6,group = [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5],beforeItems = [[], [5], [6], [7], [8], [9], [10], [11], [1], [3], [4], [0]]) == []\n assert candidate(n = 15,m = 5,group = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, -1, -1, -1, -1, -1],beforeItems = [[1, 5], [6], [8, 10], [9, 11], [3, 7], [8], [0, 2], [1, 4], [13], [14], [12], [13], [14], [10], [11]]) == []\n assert candidate(n = 7,m = 3,group = [-1, 0, 0, 1, 1, 1, 2],beforeItems = [[3], [4, 5], [5], [6], [], [], [1]]) == []\n assert candidate(n = 9,m = 2,group = [0, 0, 0, 0, 1, 1, 1, 1, -1],beforeItems = [[4], [5], [6], [7], [], [], [], [], [0, 1, 2, 3]]) == [4, 5, 6, 7, 0, 1, 2, 3, 8]\n assert candidate(n = 12,m = 3,group = [0, 0, 1, 1, 2, 2, -1, -1, -1, -1, -1, -1],beforeItems = [[], [2, 3], [4], [5], [6], [7], [8], [9], [10], [11], [], []]) == [10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1]\n assert candidate(n = 10,m = 3,group = [0, 0, 1, 1, 2, 2, -1, -1, -1, -1],beforeItems = [[], [6], [5, 9], [6, 8], [3, 7], [8], [], [6], [1], [0]]) == []\n assert candidate(n = 8,m = 4,group = [0, 1, 2, 3, 2, 1, 0, -1],beforeItems = [[1, 2], [3, 4], [5, 6], [7], [], [], [], [1]]) == []\n assert candidate(n = 10,m = 4,group = [0, 0, 1, 1, 2, 2, 2, 3, 3, -1],beforeItems = [[1], [3], [4], [6], [7], [8], [9], [], [], [0]]) == []\n assert candidate(n = 9,m = 3,group = [-1, -1, 0, 0, 1, 1, 1, 2, -1],beforeItems = [[], [7], [6, 8], [5, 7], [1, 3], [1, 7, 8], [1, 5], [2, 8], [2, 3, 5, 6]]) == []\n assert candidate(n = 10,m = 2,group = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],beforeItems = [[], [2, 3, 4], [1, 3, 5], [2, 4, 6], [1, 5, 7], [2, 6, 8], [3, 5, 9], [4, 6], [5, 7], [6, 8]]) == []\n assert candidate(n = 7,m = 5,group = [0, 1, 2, 3, 4, -1, -1],beforeItems = [[1], [2], [3], [4], [], [0], [5]]) == [4, 3, 2, 1, 0, 5, 6]\n assert candidate(n = 12,m = 4,group = [0, 0, 1, 1, 2, 2, 3, 3, -1, -1, -1, -1],beforeItems = [[3, 4], [5, 6], [7, 8], [9, 10], [], [], [], [], [], [], [], []]) == [4, 5, 6, 7, 8, 9, 10, 11, 2, 3, 0, 1]\n assert candidate(n = 20,m = 5,group = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],beforeItems = [[], [2, 3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [], []]) == [18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1]\n assert candidate(n = 10,m = 3,group = [0, 0, 1, 1, 1, 2, 2, -1, -1, -1],beforeItems = [[3, 4], [4], [5, 6], [6], [], [], [], [1], [2], [5]]) == [5, 6, 2, 3, 4, 9, 0, 1, 8, 7]\n assert candidate(n = 9,m = 3,group = [0, 0, 0, 1, 1, 1, 2, 2, 2],beforeItems = [[1, 2], [2], [3], [4, 5], [5], [], [], [6], [7]]) == [5, 4, 3, 6, 7, 8, 2, 1, 0]\n assert candidate(n = 10,m = 3,group = [0, 0, 0, 1, 1, 1, -1, -1, -1, -1],beforeItems = [[], [6], [5], [8, 9], [6, 7], [3, 6], [], [], [], []]) == [6, 7, 8, 9, 3, 4, 5, 0, 1, 2]\n assert candidate(n = 15,m = 5,group = [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, -1, -1, -1, -1, -1],beforeItems = [[], [5], [6], [7], [8], [9], [10], [11], [12], [13], [0, 1], [2, 3], [4], [], []]) == []\n assert candidate(n = 11,m = 3,group = [0, 0, 1, 1, 2, 2, -1, -1, -1, -1, -1],beforeItems = [[], [4], [5], [6], [], [], [7], [8], [9], [10], [1]]) == [4, 5, 0, 1, 10, 9, 8, 7, 6, 2, 3]\n assert candidate(n = 15,m = 5,group = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],beforeItems = [[], [3], [1, 3], [11, 12], [7], [3, 7], [9], [6], [7], [14], [12], [3], [11], [12, 14], []]) == []\n assert candidate(n = 7,m = 3,group = [-1, -1, 0, 0, 1, 1, 2],beforeItems = [[3, 4], [6], [5], [6], [0], [1], [0]]) == []\n assert candidate(n = 12,m = 4,group = [0, 0, 1, 1, 2, 2, 3, 3, -1, -1, -1, -1],beforeItems = [[5, 9], [6], [8, 10], [9, 11], [3, 7], [8], [0, 2], [1, 4], [], [6], [1], [3]]) == []\n assert candidate(n = 20,m = 6,group = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1],beforeItems = [[], [2, 3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [], []]) == [18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1]\n assert candidate(n = 8,m = 3,group = [0, 0, 1, 1, 2, 2, -1, -1],beforeItems = [[1, 2, 3, 4, 5, 6, 7], [0], [0, 3, 4, 5, 6, 7], [2, 5, 6, 7], [2, 3, 6, 7], [2, 3, 4, 7], [2, 3, 4, 5], [2, 3, 4, 5, 6]]) == []\n assert candidate(n = 12,m = 6,group = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, -1],beforeItems = [[1, 3, 5], [0], [3, 4], [2], [1, 3], [4], [7], [6, 8], [5, 7], [6], [8, 9], [10]]) == []\n assert candidate(n = 10,m = 3,group = [0, 0, 1, 1, 2, 2, -1, -1, -1, -1],beforeItems = [[], [3, 6], [7, 8], [4], [5], [9], [0, 1], [], [], [2]]) == []\n assert candidate(n = 9,m = 4,group = [0, 0, 1, 1, 2, 2, 3, 3, -1],beforeItems = [[], [4], [5], [7], [8], [], [0, 1], [2, 3], [1]]) == []\n assert candidate(n = 10,m = 4,group = [0, 0, 1, 1, 2, 2, 3, 3, -1, -1],beforeItems = [[], [2, 5], [3, 6], [7], [8], [8], [9], [9], [3, 6], [7]]) == []\n assert candidate(n = 10,m = 4,group = [0, 1, 2, 3, 0, 1, 2, 3, -1, -1],beforeItems = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [0, 5, 8], [1, 6, 9], [0, 4, 7], [1, 3, 8], [2, 4, 9], [], []]) == []\n assert candidate(n = 12,m = 4,group = [0, 0, 1, 1, 2, 2, 3, 3, -1, -1, -1, -1],beforeItems = [[], [5, 6], [3], [5], [6], [7], [], [8], [11], [10], [9], [10]]) == []\n assert candidate(n = 16,m = 5,group = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, -1, -1, -1, -1, -1, -1],beforeItems = [[], [2, 3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [], []]) == [14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1]\n", "comparison": "exact"}, "public_tests": ["8\n2\n[-1,-1,1,0,0,1,0,-1]\n[[],[6],[5],[6],[3,6],[],[],[]]", "8\n2\n[-1,-1,1,0,0,1,0,-1]\n[[],[6],[5],[6],[3],[],[4],[]]"], "hints": ["Think of it as a graph problem.", "We need to find a topological order on the dependency graph.", "Build two graphs, one for the groups and another for the items."], "metadata": {"canonical_parameter_names": ["n", "m", "group", "beforeItems"], "leetcode_dataset_entry_point": "Solution().sortItems", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:15+00:00", "tests_total": 72, "tests_dropped": 28, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph", "topological-sort", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def sortItems(self, n: int, m: int, group: list[int], beforeItems: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "sortItems", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}, {"name": "group", "type": "list[int]"}, {"name": "beforeItems", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1207, "task_id": "unique-number-of-occurrences", "difficulty": "Easy", "problem_description": "Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise.\n\nExample 1:\n\nInput: arr = [1,2,2,1,1,3]\nOutput: true\nExplanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences.\n\nExample 2:\n\nInput: arr = [1,2]\nOutput: false\n\nExample 3:\n\nInput: arr = [-3,0,1,-3,1,1,1,-3,10,0]\nOutput: true\n\nConstraints:\n\n- 1 <= arr.length <= 1000\n- -1000 <= arr[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [-3, 0, 1, -3, 1, 1, 1, -3, 10, 0]) == True\n assert candidate(arr = [1, 2]) == False\n assert candidate(arr = [5]) == True\n assert candidate(arr = [5, 5, 5, 5, 5]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3]) == False\n assert candidate(arr = [-1, -1, -2, -2, -3, -3]) == False\n assert candidate(arr = [5, 5, 5, 5]) == True\n assert candidate(arr = [1]) == True\n assert candidate(arr = [1000, -1000, 0]) == False\n assert candidate(arr = [1, 2, 2, 1, 1, 3]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == False\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 4, 4, 4, 4]) == True\n assert candidate(arr = [1, -1, 1, -1, 1, -1]) == False\n assert candidate(arr = [1000, -1000, 1000, -1000]) == False\n assert candidate(arr = [1, 2, 3, 2, 1]) == False\n assert candidate(arr = [1000, 1000, -1000, -1000]) == False\n assert candidate(arr = [-1, -2, -3, -2, -1]) == False\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9]) == True\n assert candidate(arr = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == False\n assert candidate(arr = [1, 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]) == False\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, 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]) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\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, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == True\n assert candidate(arr = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000]) == False\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]) == False\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]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == False\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, 5]) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8]) == True\n assert candidate(arr = [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, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == False\n assert candidate(arr = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999]) == True\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [-500, -499, -498, -497, -496, -495, -494, -493, -492, -491]) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\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]) == True\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]) == False\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]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 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]) == False\n assert candidate(arr = [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10]) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == False\n assert candidate(arr = [1000, 1000, 1000, 999, 999, 998, 997, 996, 995, 994]) == False\n assert candidate(arr = [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, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == False\n assert candidate(arr = [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]) == True\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, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [-50, -50, -50, -50, -50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(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]) == True\n assert candidate(arr = [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(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 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(arr = [0, 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]) == True\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [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(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]) == False\n assert candidate(arr = [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]) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6]) == True\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == False\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]) == False\n assert candidate(arr = [-10, -20, -30, -40, -50, -50, -40, -30, -20, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(arr = [5, 5, 5, 5, 4, 4, 4, 3, 3, 2, 1]) == False\n assert candidate(arr = [10, 20, 20, 10, 30, 30, 30, 40, 40, 40, 40]) == False\n assert candidate(arr = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000]) == False\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984]) == False\n assert candidate(arr = [1000, -1000, 500, -500, 0, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(arr = [-5, -5, -5, -5, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(arr = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == False\n assert candidate(arr = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [10, 20, 10, 10, 30, 40, 40, 50, 50, 50]) == False\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]) == False\n assert candidate(arr = [10, 20, 20, 10, 30, 30, 30, 40, 40, 40, 40]) == False\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, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0]) == False\n assert candidate(arr = [0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6]) == False\n assert candidate(arr = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == False\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, 0, 0, 0, 0, 0, 0, 0]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [10, 20, 20, 10, 30, 40, 40, 40, 50, 50, 50, 50]) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,2,1,1,3]", "[1,2]", "[-3,0,1,-3,1,1,1,-3,10,0]"], "hints": ["Find the number of occurrences of each element in the array using a hash map.", "Iterate through the hash map and check if there is a repeated value."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().uniqueOccurrences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:17+00:00", "tests_total": 107, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def uniqueOccurrences(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "uniqueOccurrences", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1208, "task_id": "get-equal-substrings-within-budget", "difficulty": "Medium", "problem_description": "You are given two strings s and t of the same length and an integer maxCost.\n\nYou want to change s to t. Changing the i^th character of s to i^th character of t costs |s[i] - t[i]| (i.e., the absolute difference between the ASCII values of the characters).\n\nReturn the maximum length of a substring of s that can be changed to be the same as the corresponding substring of t with a cost less than or equal to maxCost. If there is no substring from s that can be changed to its corresponding substring from t, return 0.\n\nExample 1:\n\nInput: s = \"abcd\", t = \"bcdf\", maxCost = 3\nOutput: 3\nExplanation: \"abc\" of s can change to \"bcd\".\nThat costs 3, so the maximum length is 3.\n\nExample 2:\n\nInput: s = \"abcd\", t = \"cdef\", maxCost = 3\nOutput: 1\nExplanation: Each character in s costs 2 to change to character in t, so the maximum length is 1.\n\nExample 3:\n\nInput: s = \"abcd\", t = \"acde\", maxCost = 0\nOutput: 1\nExplanation: You cannot make any change, so the maximum length is 1.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- t.length == s.length\n- 0 <= maxCost <= 10^6\n- s and t consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a\",t = \"b\",maxCost = 1) == 1\n assert candidate(s = \"a\",t = \"a\",maxCost = 0) == 1\n assert candidate(s = \"krrgw\",t = \"grkwa\",maxCost = 3) == 1\n assert candidate(s = \"abcd\",t = \"abce\",maxCost = 1) == 4\n assert candidate(s = \"abcdefgh\",t = \"efghabcd\",maxCost = 10) == 2\n assert candidate(s = \"krrgw\",t = \"zjxss\",maxCost = 19) == 2\n assert candidate(s = \"zzzzz\",t = \"bbbbb\",maxCost = 100) == 4\n assert candidate(s = \"abcd\",t = \"cdef\",maxCost = 3) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",maxCost = 26) == 7\n assert candidate(s = \"pxezla\",t = \"sllerr\",maxCost = 5) == 1\n assert candidate(s = \"abcde\",t = \"bcdef\",maxCost = 5) == 5\n assert candidate(s = \"a\",t = \"b\",maxCost = 0) == 0\n assert candidate(s = \"abcd\",t = \"abcd\",maxCost = 10) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",maxCost = 25) == 7\n assert candidate(s = \"abcdabcdabcd\",t = \"dddddddddddd\",maxCost = 10) == 7\n assert candidate(s = \"abcd\",t = \"bcdf\",maxCost = 3) == 3\n assert candidate(s = \"abcde\",t = \"fghij\",maxCost = 10) == 2\n assert candidate(s = \"abcd\",t = \"acde\",maxCost = 0) == 1\n assert candidate(s = \"zzzzzzzzzz\",t = \"aaaaaaaaaa\",maxCost = 25) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",maxCost = 100) == 14\n assert candidate(s = \"aaaaabbbbbccccc\",t = \"bbbbbccccdaaaaa\",maxCost = 15) == 12\n assert candidate(s = \"a\",t = \"z\",maxCost = 25) == 1\n assert candidate(s = \"thisisaverylongstring\",t = \"thisisaverylongstring\",maxCost = 50) == 21\n assert candidate(s = \"abcde\",t = \"fghij\",maxCost = 15) == 3\n assert candidate(s = \"abracadabra\",t = \"abracadabra\",maxCost = 5) == 11\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\",maxCost = 100) == 4\n assert candidate(s = \"xylophone\",t = \"pneumonia\",maxCost = 20) == 5\n assert candidate(s = \"aabbaabbaabb\",t = \"bbaabbaabbab\",maxCost = 20) == 12\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosis\",maxCost = 0) == 45\n assert candidate(s = \"abcdefghij\",t = \"abcdefghij\",maxCost = 50) == 10\n assert candidate(s = \"thisisaverylongstringthatweneedtocompare\",t = \"thisisaverylongstringthatweneedtoreplace\",maxCost = 50) == 40\n assert candidate(s = \"xyzz\",t = \"zzyx\",maxCost = 10) == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",t = \"dddddddddddddddddddddddddddddddd\",maxCost = 200) == 32\n assert candidate(s = \"ababababababab\",t = \"bababababababa\",maxCost = 12) == 12\n assert candidate(s = \"mnopqr\",t = \"qrstuv\",maxCost = 12) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",maxCost = 0) == 26\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\",maxCost = 1300) == 52\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",maxCost = 50) == 10\n assert candidate(s = \"aaaabbbbcccc\",t = \"ccccbbbbaaaa\",maxCost = 16) == 12\n assert candidate(s = \"ababababab\",t = \"bababababa\",maxCost = 15) == 10\n assert candidate(s = \"abcabcabcabcabc\",t = \"abcabcabcabcabc\",maxCost = 0) == 15\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\",maxCost = 52) == 14\n assert candidate(s = \"ababababababababababababababababababababababababab\",t = \"bababababababababababababababababababababababababa\",maxCost = 25) == 25\n assert candidate(s = \"mississippi\",t = \"abababababa\",maxCost = 10) == 1\n assert candidate(s = \"abcdefghij\",t = \"abcdefghja\",maxCost = 9) == 9\n assert candidate(s = \"abcdefghij\",t = \"abcdefghkj\",maxCost = 2) == 10\n assert candidate(s = \"acabababcababcaba\",t = \"bacbababcababcaba\",maxCost = 25) == 17\n assert candidate(s = \"oneonetwoonetwo\",t = \"twoonetwoonetwo\",maxCost = 8) == 12\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzx\",maxCost = 50) == 29\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",maxCost = 0) == 52\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",maxCost = 100) == 14\n assert candidate(s = \"abcdabcdabcdabcdabcd\",t = \"dddddddddddddddddddd\",maxCost = 15) == 11\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",maxCost = 51) == 26\n assert candidate(s = \"thisisateststring\",t = \"jajajajajajajajaj\",maxCost = 50) == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",maxCost = 100) == 20\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\",maxCost = 200) == 28\n assert candidate(s = \"abcdefghij\",t = \"abcdefghij\",maxCost = 1) == 10\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",maxCost = 250) == 10\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",maxCost = 100) == 10\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",maxCost = 50) == 10\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"bbbbbbbbbbbbbbbbbbbbbbbbbb\",maxCost = 100) == 26\n assert candidate(s = \"abacabadabacaba\",t = \"xyzxyzxyzxyzxyz\",maxCost = 26) == 1\n assert candidate(s = \"samecharacters\",t = \"samecharacters\",maxCost = 0) == 14\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",t = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",maxCost = 30) == 1\n assert candidate(s = \"abcdefghij\",t = \"abcdefghjk\",maxCost = 1) == 9\n assert candidate(s = \"aabbccddeeff\",t = \"zzeeffgghhii\",maxCost = 15) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",maxCost = 25) == 25\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",maxCost = 0) == 48\n assert candidate(s = \"abcd\",t = \"acde\",maxCost = 2) == 3\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"defdefdefdefdefdef\",maxCost = 18) == 6\n assert candidate(s = \"aaaaabbbbbaaaa\",t = \"zzzzzaaaaazzzz\",maxCost = 40) == 6\n assert candidate(s = \"abcdabcdabcd\",t = \"abcdbacdabca\",maxCost = 15) == 12\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",maxCost = 25) == 25\n assert candidate(s = \"ab\",t = \"ba\",maxCost = 100) == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",maxCost = 100) == 4\n assert candidate(s = \"abacabadabacaba\",t = \"zyxwzyxwzyxwzyx\",maxCost = 50) == 2\n assert candidate(s = \"abcd\",t = \"xyzw\",maxCost = 12) == 0\n assert candidate(s = \"aaaabbbbccccdddd\",t = \"ddddccccbbbbaaaa\",maxCost = 20) == 12\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",t = \"zyxwzyxwzyxwzyxwzyxwzyxwzyxwzyxwzyxwzyxw\",maxCost = 50) == 2\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",maxCost = 30) == 7\n assert candidate(s = \"aaaaaaaaaa\",t = \"zzzzzzzzzz\",maxCost = 250) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",maxCost = 150) == 17\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\",t = \"zzyyzzyyzzyyzzyyzzyyzzyyzzyyzzyyzzyyzzyy\",maxCost = 150) == 6\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"qwertyuiopasdfghjklzxcvbnm\",maxCost = 0) == 26\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\",maxCost = 150) == 25\n assert candidate(s = \"zzzzzzzzzz\",t = \"aaaaaaaaaa\",maxCost = 100) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",maxCost = 26) == 25\n", "comparison": "exact"}, "public_tests": ["\"abcd\"\n\"bcdf\"\n3", "\"abcd\"\n\"cdef\"\n3", "\"abcd\"\n\"acde\"\n0"], "hints": ["Calculate the differences between s[i] and t[i].", "Use a sliding window to track the longest valid substring."], "metadata": {"canonical_parameter_names": ["s", "t", "maxCost"], "leetcode_dataset_entry_point": "Solution().equalSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:19+00:00", "tests_total": 95, "tests_dropped": 8, "flags": [], "topic_tags": ["string", "binary-search", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def equalSubstring(self, s: str, t: str, maxCost: int) -> int:", "container": "Solution", "callable": "equalSubstring", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}, {"name": "maxCost", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1209, "task_id": "remove-all-adjacent-duplicates-in-string-ii", "difficulty": "Medium", "problem_description": "You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left and the right side of the deleted substring to concatenate together.\n\nWe repeatedly make k duplicate removals on s until we no longer can.\n\nReturn the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique.\n\nExample 1:\n\nInput: s = \"abcd\", k = 2\nOutput: \"abcd\"\nExplanation: There's nothing to delete.\n\nExample 2:\n\nInput: s = \"deeedbbcccbdaa\", k = 3\nOutput: \"aa\"\nExplanation:\nFirst delete \"eee\" and \"ccc\", get \"ddbbbdaa\"\nThen delete \"bbb\", get \"dddaa\"\nFinally delete \"ddd\", get \"aa\"\n\nExample 3:\n\nInput: s = \"pbbcggttciiippooaais\", k = 2\nOutput: \"ps\"\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- 2 <= k <= 10^4\n- s only contains lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a\",k = 2) == \"a\"\n assert candidate(s = \"mississippi\",k = 2) == \"m\"\n assert candidate(s = \"deeedbbcccbdaa\",k = 3) == \"aa\"\n assert candidate(s = \"abcd\",k = 2) == \"abcd\"\n assert candidate(s = \"abcde\",k = 5) == \"abcde\"\n assert candidate(s = \"abcdabcdabcdabcd\",k = 4) == \"abcdabcdabcdabcd\"\n assert candidate(s = \"aabbccddeee\",k = 3) == \"aabbccdd\"\n assert candidate(s = \"aaaabbbccc\",k = 4) == \"bbbccc\"\n assert candidate(s = \"pbbcggttciiippooaais\",k = 2) == \"ps\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzz\",k = 5) == \"zzz\"\n assert candidate(s = \"aabbccddeee\",k = 2) == \"e\"\n assert candidate(s = \"zzzzzzzzzz\",k = 3) == \"z\"\n assert candidate(s = \"abababababababab\",k = 2) == \"abababababababab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 10) == \"\"\n assert candidate(s = \"abcabcabc\",k = 3) == \"abcabcabc\"\n assert candidate(s = \"aaabbbcccddd\",k = 3) == \"\"\n assert candidate(s = \"abcdabcdabcd\",k = 4) == \"abcdabcdabcd\"\n assert candidate(s = \"abcde\",k = 2) == \"abcde\"\n assert candidate(s = \"aaabbbccc\",k = 3) == \"\"\n assert candidate(s = \"nnnnttttuuuu\",k = 4) == \"\"\n assert candidate(s = \"aabbcc\",k = 2) == \"\"\n assert candidate(s = \"bbaabaaaabbbbccccdddd\",k = 3) == \"bbaababcd\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 5) == \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"abcdefghijaaaabbbbccccddddeeeeffffgggghhhhiiii\",k = 4) == \"abcdefghij\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\",k = 26) == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"mmnnmmllooonnmmllooonn\",k = 3) == \"mmnnmmllnnmmllnn\"\n assert candidate(s = \"pppppqqqppppqqqqqqqqq\",k = 5) == \"qqqppppqqqq\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzzzzzzz\",k = 4) == \"aabbccddeeefffggghhhjjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwwwxxxyyy\"\n assert candidate(s = \"xyxxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\",k = 3) == \"xyxxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxxyyyyyzzzzz\",k = 3) == \"ixxyyzz\"\n assert candidate(s = \"nnnnooooffffgggg\",k = 4) == \"\"\n assert candidate(s = \"aabbbccddeeefffggghhhiiijjjkkklllmmmnnooopppqqqrrrssstttuuuuvvvwwwxxyyzz\",k = 3) == \"aaccddnnuxxyyzz\"\n assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\",k = 5) == \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\"\n assert candidate(s = \"mississippiiiiiiiiii\",k = 5) == \"mississipp\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\",k = 3) == \"aabbccddinn\"\n assert candidate(s = \"pppqqqrrrssstttuuuvvvwwwww\",k = 5) == \"pppqqqrrrssstttuuuvvv\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqq\",k = 4) == \"aabbccddeeefffggghhh\"\n assert candidate(s = \"ppppqqqrrrssstttuuuvvvwwwwwxxxxyyyyzzzz\",k = 4) == \"qqqrrrssstttuuuvvvw\"\n assert candidate(s = \"abababababababababababababababab\",k = 3) == \"abababababababababababababababab\"\n assert candidate(s = \"mississippiississi\",k = 3) == \"mississippiississi\"\n assert candidate(s = \"abcabcabcabc\",k = 4) == \"abcabcabcabc\"\n assert candidate(s = \"zzzzyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 7) == \"zzzzyy\"\n assert candidate(s = \"abababababab\",k = 3) == \"abababababab\"\n assert candidate(s = \"mmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\",k = 3) == \"mm\"\n assert candidate(s = \"abcdefghijkllllllllllllmnopqrstuvwxyz\",k = 10) == \"abcdefghijkllmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 26) == \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"xyzzzzzzzzxy\",k = 6) == \"xyzzxy\"\n assert candidate(s = \"abcdefggggggfedcba\",k = 5) == \"abcdefgfedcba\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababab\",k = 20) == \"ababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 10) == \"qqqq\"\n assert candidate(s = \"zzzzzyzzzz\",k = 5) == \"yzzzz\"\n assert candidate(s = \"wwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzz\",k = 6) == \"wwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzzwwzzzzz\"\n assert candidate(s = \"pppppaaaabbbbcccccccdddddddd\",k = 4) == \"pccc\"\n assert candidate(s = \"aabaaaacccaaabbbcccbbccaa\",k = 3) == \"aababbccaa\"\n assert candidate(s = \"abcdefghijkllllllllllllmnopqrstuv\",k = 11) == \"abcdefghijklmnopqrstuv\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmmnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwxxxxxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\",k = 10) == \"hhhhhhhhxxx\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzz\",k = 6) == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyy\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",k = 6) == \"abcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"xyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzy\",k = 5) == \"xyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzy\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkk\",k = 4) == \"aabbccddeeefffggghhh\"\n assert candidate(s = \"pppppppppaaaabbbbccccdddd\",k = 4) == \"p\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 10) == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aabbccddeeefffggghhhiiijjjkkklllmnnnooopppqqqrrrssstttuuuvvvwwxxyyzz\",k = 3) == \"aabbccddmwwxxyyzz\"\n assert candidate(s = \"xyzzzzzzzzzzzyyxwwwwwwwwwwwwwxvvvvvvvvvvvvvuuuuuuuuuuuuuutttttttttttttsssssssssssssrrrrrrrrrrrrrqqqqqqqqqqqqqpnnnnnnnnnnnnnoommmmmmmmmmmmmllllllllllllllkkkkkkkkkkkkkkjjjjjjjjjjjjjjiiiiiiiiiiiiiiiihhhhhhhhhhhhhhhhhgggggggggggggggggffffffffffffffffeeeeeeeeeeeeeeeeedddddddddddddddddccccccccccccccccccbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaa\",k = 20) == \"xyzzzzzzzzzzzyyxwwwwwwwwwwwwwxvvvvvvvvvvvvvuuuuuuuuuuuuuutttttttttttttsssssssssssssrrrrrrrrrrrrrqqqqqqqqqqqqqpnnnnnnnnnnnnnoommmmmmmmmmmmmllllllllllllllkkkkkkkkkkkkkkjjjjjjjjjjjjjjiiiiiiiiiiiiiiiihhhhhhhhhhhhhhhhhgggggggggggggggggffffffffffffffffeeeeeeeeeeeeeeeeedddddddddddddddddccccccccccccccccccbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"mnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\",k = 2) == \"lkjihgfedcba\"\n assert candidate(s = \"mississippiissiippiiissipiissipiissipiissipiissipiissipiissipiissipiis\",k = 3) == \"mississippiissiippssipiissipiissipiissipiissipiissipiissipiissipiis\"\n assert candidate(s = \"aaabaaaabbbaaa\",k = 3) == \"ba\"\n assert candidate(s = \"aaaabbbbccccdddd\",k = 4) == \"\"\n assert candidate(s = \"zzzzzyyyxx\",k = 4) == \"zyyyxx\"\n assert candidate(s = \"zzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"zzzzzyyyyyxxxwwwwvvvvuuuuuuttttssssrrrrqqqqppppooooonnnnmmmmmllllkkkkjjjjiiihhhhggggffffeeee\",k = 5) == \"xxxwwwwvvvvuttttssssrrrrqqqqppppnnnnllllkkkkjjjjiiihhhhggggffffeeee\"\n assert candidate(s = \"xyzyxyzyxyzyxyzyxyzy\",k = 3) == \"xyzyxyzyxyzyxyzyxyzy\"\n assert candidate(s = \"ppppppqqqqqqrrrrrr\",k = 6) == \"\"\n assert candidate(s = \"abacabadabacabadabacabadabacabad\",k = 4) == \"abacabadabacabadabacabadabacabad\"\n assert candidate(s = \"xyzzzzxyzzzz\",k = 5) == \"xyzzzzxyzzzz\"\n assert candidate(s = \"abababababababababababababababab\",k = 7) == \"abababababababababababababababab\"\n assert candidate(s = \"abccbaabccbaabccba\",k = 3) == \"abccbaabccbaabccba\"\n assert candidate(s = \"aabbbbccccddddaaaabbbbccccddddaaaabbbbccccdddd\",k = 4) == \"aa\"\n assert candidate(s = \"aabbccddeeefffgghhiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwww\",k = 5) == \"aabbccddeeefffgghhiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwww\"\n assert candidate(s = \"aaaabaaaabaaaabaaaab\",k = 4) == \"\"\n assert candidate(s = \"aabbccddeeefff\",k = 2) == \"ef\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeefffffffff\",k = 10) == \"bbbbbbbbccccccccddddddddeeeeeeeeefffffffff\"\n assert candidate(s = \"zzzzzyyyyyxxxxxxwwwwvvvvvuuuuu\",k = 5) == \"xwwww\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\",k = 4) == \"\"\n assert candidate(s = \"aabbccccddeeeeffffgggghhhiiijjjkkk\",k = 4) == \"aabbddhhhiiijjjkkk\"\n assert candidate(s = \"mnopqrstuvw\",k = 2) == \"mnopqrstuvw\"\n assert candidate(s = \"zzzxxxyyyzzzxxxyyy\",k = 3) == \"\"\n assert candidate(s = \"abcdefghijklaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb\",k = 10) == \"abcdefghijklabbbbbbbb\"\n assert candidate(s = \"aabbccddeeefffggg\",k = 3) == \"aabbccdd\"\n assert candidate(s = \"qqqqwwwwrrrreeee\",k = 4) == \"\"\n assert candidate(s = \"mississippiissippi\",k = 4) == \"mississippiissippi\"\n assert candidate(s = \"zzzzzyyyyxxxxwwwwvvvvuuuu\",k = 5) == \"yyyyxxxxwwwwvvvvuuuu\"\n assert candidate(s = \"abcdefghijkllllllllllmnopqrstuvwxyz\",k = 10) == \"abcdefghijkmnopqrstuvwxyz\"\n assert candidate(s = \"zzzzzzzzzz\",k = 4) == \"zz\"\n assert candidate(s = \"abababababababababab\",k = 5) == \"abababababababababab\"\n assert candidate(s = \"qqwweerrttyyuuiiooppaassddffgghhjjkkllzzxciwoqjfqioejqwojfioqwjfiqwjefioqwjfeiqwjeofiqwjeofiqwjefiqwjf\",k = 2) == \"xciwoqjfqioejqwojfioqwjfiqwjefioqwjfeiqwjeofiqwjeofiqwjefiqwjf\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == \"zzzz\"\n assert candidate(s = \"mmnnnnoooopprrrssstttuuuuvvvvwwxxxyyyzzzzzz\",k = 6) == \"mmnnnnoooopprrrssstttuuuuvvvvwwxxxyyy\"\n assert candidate(s = \"aaaaaaaaabbbbbbbbccccccccddddddddd\",k = 8) == \"ad\"\n assert candidate(s = \"abcdefghijaaaaklmnopqrstuuvwxyz\",k = 3) == \"abcdefghijaklmnopqrstuuvwxyz\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnoooopppp\",k = 5) == \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnoooopppp\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 20) == \"qqqqqqqqqqqqqq\"\n assert candidate(s = \"abbaccccbaa\",k = 4) == \"abbabaa\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 10) == \"abcdefghijabcdefghijabcdefghij\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == \"\"\n assert candidate(s = \"abcdabcdabcdabcd\",k = 3) == \"abcdabcdabcdabcd\"\n", "comparison": "exact"}, "public_tests": ["\"abcd\"\n2", "\"deeedbbcccbdaa\"\n3", "\"pbbcggttciiippooaais\"\n2"], "hints": ["Use a stack to store the characters, when there are k same characters, delete them.", "To make it more efficient, use a pair to store the value and the count of each character."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().removeDuplicates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:21+00:00", "tests_total": 107, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "stack"]}, "language": "python", "interface": {"raw_signature": "def removeDuplicates(self, s: str, k: int) -> str:", "container": "Solution", "callable": "removeDuplicates", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1210, "task_id": "minimum-moves-to-reach-target-with-rotations", "difficulty": "Hard", "problem_description": "In an n*n grid, there is a snake that spans 2 cells and starts moving from the top left corner at (0, 0) and (0, 1). The grid has empty cells represented by zeros and blocked cells represented by ones. The snake wants to reach the lower right corner at (n-1, n-2) and (n-1, n-1).\n\nIn one move the snake can:\n\n- Move one cell to the right if there are no blocked cells there. This move keeps the horizontal/vertical position of the snake as it is.\n- Move down one cell if there are no blocked cells there. This move keeps the horizontal/vertical position of the snake as it is.\n- Rotate clockwise if it's in a horizontal position and the two cells under it are both empty. In that case the snake moves from (r, c) and (r, c+1) to (r, c) and (r+1, c).\n- Rotate counterclockwise if it's in a vertical position and the two cells to its right are both empty. In that case the snake moves from (r, c) and (r+1, c) to (r, c) and (r, c+1).\n\nReturn the minimum number of moves to reach the target.\n\nIf there is no way to reach the target, return -1.\n\nExample 1:\n\nInput: grid = [[0,0,0,0,0,1],\n [1,1,0,0,1,0],\n [0,0,0,0,1,1],\n [0,0,1,0,1,0],\n [0,1,1,0,0,0],\n [0,1,1,0,0,0]]\nOutput: 11\nExplanation:\nOne possible solution is [right, right, rotate clockwise, right, down, down, down, down, rotate counterclockwise, right, down].\n\nExample 2:\n\nInput: grid = [[0,0,1,1,1,1],\n [0,0,0,0,1,1],\n [1,1,0,0,0,1],\n [1,1,1,0,0,1],\n [1,1,1,0,0,1],\n [1,1,1,0,0,0]]\nOutput: 9\n\nConstraints:\n\n- 2 <= n <= 100\n- 0 <= grid[i][j] <= 1\n- It is guaranteed that the snake starts at empty cells.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 1], [0, 1, 0], [0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 1, 1], [0, 0, 0], [0, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 3\n assert candidate(grid = [[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, 0, 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, 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], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 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, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 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]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 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, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 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]]) == 13\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, 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]]) == 17\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[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, 0, 0, 0], [0, 0, 0, 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, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 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]]) == 17\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], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 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, 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]]) == 13\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, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 1, 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, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 0], [0, 1, 0, 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, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 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]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1, 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, 1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[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, 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]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 1], [0, 1, 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], [0, 0, 1, 0, 0, 1, 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, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1], [0, 1, 0, 0, 0, 1, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0, 0], [0, 0, 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 21\n assert candidate(grid = [[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, 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, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 1, 0, 0], [0, 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]]) == 19\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 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]]) == 13\n assert candidate(grid = [[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, 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[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, 1, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 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]]) == -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, 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]]) == 21\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 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, 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, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 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, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[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, 0, 0, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 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]]) == 17\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, 0]]) == 37\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]]) == 19\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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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], [0, 1, 1, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 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, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 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, 0, 0]]) == 13\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]]) == 17\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 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, 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, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 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\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 1, 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]]) == 13\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, 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]]) == 13\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 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, 0, 0, 0, 0], [0, 1, 1, 1, 1, 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, 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, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 1, 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], [0, 1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 13\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]]) == 23\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 1, 1], [0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 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, 0, 0, 0, 0]]) == -1\n", "comparison": "exact"}, "public_tests": ["[[0,0,0,0,0,1],[1,1,0,0,1,0],[0,0,0,0,1,1],[0,0,1,0,1,0],[0,1,1,0,0,0],[0,1,1,0,0,0]]\r", "[[0,0,1,1,1,1],[0,0,0,0,1,1],[1,1,0,0,0,1],[1,1,1,0,0,1],[1,1,1,0,0,1],[1,1,1,0,0,0]]\r"], "hints": ["Use BFS to find the answer.", "The state of the BFS is the position (x, y) along with a binary value that specifies if the position is horizontal or vertical."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumMoves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:23+00:00", "tests_total": 64, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minimumMoves(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumMoves", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1217, "task_id": "minimum-cost-to-move-chips-to-the-same-position", "difficulty": "Easy", "problem_description": "We have n chips, where the position of the i^th chip is position[i].\n\nWe need to move all the chips to the same position. In one step, we can change the position of the i^th chip from position[i] to:\n\n- position[i] + 2 or position[i] - 2 with cost = 0.\n- position[i] + 1 or position[i] - 1 with cost = 1.\n\nReturn the minimum cost needed to move all the chips to the same position.\n\nExample 1:\n\nInput: position = [1,2,3]\nOutput: 1\nExplanation: First step: Move the chip at position 3 to position 1 with cost = 0.\nSecond step: Move the chip at position 2 to position 1 with cost = 1.\nTotal cost is 1.\n\nExample 2:\n\nInput: position = [2,2,2,3,3]\nOutput: 2\nExplanation: We can move the two chips at position 3 to position 2. Each move has cost = 1. The total cost = 2.\n\nExample 3:\n\nInput: position = [1,1000000000]\nOutput: 1\n\nConstraints:\n\n- 1 <= position.length <= 100\n- 1 <= position[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(position = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(position = [1, 1000000000]) == 1\n assert candidate(position = [1, 2, 2, 2, 3, 3, 3]) == 3\n assert candidate(position = [5, 5, 5, 5, 5]) == 0\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(position = [1, 3, 5, 7, 9]) == 0\n assert candidate(position = [1, 1, 1, 1, 1]) == 0\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(position = [999999999, 999999998, 999999997, 999999996]) == 2\n assert candidate(position = [2, 4, 6, 8, 10]) == 0\n assert candidate(position = [1, 2, 2, 2, 3, 3, 3, 3]) == 3\n assert candidate(position = [1, 1, 1, 2, 2, 3]) == 2\n assert candidate(position = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(position = [2, 2, 2, 3, 3]) == 2\n assert candidate(position = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(position = [1, 3, 5, 7]) == 0\n assert candidate(position = [1, 2, 2, 3, 4, 5]) == 3\n assert candidate(position = [1000000000, 1000000000, 1000000000]) == 0\n assert candidate(position = [1]) == 0\n assert candidate(position = [1, 2, 2, 3, 3, 3, 4]) == 3\n assert candidate(position = [4, 6, 8, 10, 12]) == 0\n assert candidate(position = [2, 4, 6, 8]) == 0\n assert candidate(position = [10, 20, 30, 40, 50]) == 0\n assert candidate(position = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(position = [1, 2, 3]) == 1\n assert candidate(position = [1, 1, 2, 2, 3, 3, 3, 3]) == 2\n assert candidate(position = [100, 200, 300, 400, 500, 600]) == 0\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 1\n assert candidate(position = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 10\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15]) == 0\n assert candidate(position = [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]) == 0\n assert candidate(position = [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]) == 10\n assert candidate(position = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43]) == 0\n assert candidate(position = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(position = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005]) == 3\n assert candidate(position = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(position = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n assert candidate(position = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 5\n assert candidate(position = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 10\n assert candidate(position = [1, 1, 1, 1, 1, 1, 1, 1, 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]) == 24\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(position = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 12\n assert candidate(position = [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]) == 20\n assert candidate(position = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 12\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 7\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13]) == 0\n assert candidate(position = [1000000000, 999999998, 999999996, 999999994, 999999992]) == 0\n assert candidate(position = [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\n assert candidate(position = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 33\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(position = [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]) == 0\n assert candidate(position = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 17\n assert candidate(position = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 14\n assert candidate(position = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 11\n assert candidate(position = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 0\n assert candidate(position = [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(position = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 1\n assert candidate(position = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 9\n assert candidate(position = [1, 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(position = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 4\n assert candidate(position = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 10\n assert candidate(position = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(position = [2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(position = [1000000000, 999999998, 999999996, 999999994, 999999992, 999999990]) == 0\n assert candidate(position = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20]) == 0\n assert candidate(position = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]) == 6\n assert candidate(position = [1, 1, 1, 1, 1, 1, 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]) == 10\n assert candidate(position = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992]) == 4\n assert candidate(position = [1000000000, 999999998, 999999996, 999999994, 999999992, 999999990]) == 0\n assert candidate(position = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(position = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(position = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 7\n assert candidate(position = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(position = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(position = [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]) == 0\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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(position = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 8\n assert candidate(position = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(position = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 9\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 1\n assert candidate(position = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(position = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(position = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 7\n assert candidate(position = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009]) == 5\n assert candidate(position = [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]) == 16\n assert candidate(position = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 0\n assert candidate(position = [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, 5, 6]) == 16\n assert candidate(position = [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, 31, 31, 33, 33, 35, 35, 37, 37, 39, 39, 41, 41]) == 0\n assert candidate(position = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[2,2,2,3,3]", "[1,1000000000]"], "hints": ["The first move keeps the parity of the element as it is.", "The second move changes the parity of the element.", "Since the first move is free, if all the numbers have the same parity, the answer would be zero.", "Find the minimum cost to make all the numbers have the same parity."], "metadata": {"canonical_parameter_names": ["position"], "leetcode_dataset_entry_point": "Solution().minCostToMoveChips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:35+00:00", "tests_total": 105, "tests_dropped": 8, "flags": ["has_images"], "topic_tags": ["array", "math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minCostToMoveChips(self, position: list[int]) -> int:", "container": "Solution", "callable": "minCostToMoveChips", "parameters": [{"name": "position", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1218, "task_id": "longest-arithmetic-subsequence-of-given-difference", "difficulty": "Medium", "problem_description": "Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.\n\nA subsequence is a sequence that can be derived from arr by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: arr = [1,2,3,4], difference = 1\nOutput: 4\nExplanation: The longest arithmetic subsequence is [1,2,3,4].\n\nExample 2:\n\nInput: arr = [1,3,5,7], difference = 1\nOutput: 1\nExplanation: The longest arithmetic subsequence is any single element.\n\nExample 3:\n\nInput: arr = [1,5,7,8,5,3,4,2,1], difference = -2\nOutput: 4\nExplanation: The longest arithmetic subsequence is [7,5,3,1].\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- -10^4 <= arr[i], difference <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 0, -3, 4, -5, 0, -7, 1],difference = -3) == 3\n assert candidate(arr = [1, 2, 3, 4],difference = 1) == 4\n assert candidate(arr = [1, 3, 5, 7],difference = 1) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],difference = 0) == 5\n assert candidate(arr = [5, 4, 3, 2, 1],difference = -1) == 5\n assert candidate(arr = [1, 3, 5, 7, 9],difference = 2) == 5\n assert candidate(arr = [4, 12, 10, 0, -2, 7, -8, 9, -9, -12, -12, 8, 8],difference = 0) == 2\n assert candidate(arr = [1, 2, 3, 4, 5],difference = 2) == 3\n assert candidate(arr = [1, 5, 7, 8, 5, 3, 4, 2, 1],difference = -2) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],difference = 1) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],difference = -1) == 10\n assert candidate(arr = [4, 1, 1, 5, 2, 3, 4, 1],difference = 1) == 4\n assert candidate(arr = [1, 4, 7, 10],difference = 3) == 4\n assert candidate(arr = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44],difference = 3) == 15\n assert candidate(arr = [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],difference = -2) == 31\n assert candidate(arr = [20, 10, 30, 20, 40, 50, 60, 70, 80, 90, 100],difference = 10) == 9\n assert candidate(arr = [10, 8, 6, 4, 2, -2, -4, -6, -8, -10],difference = -2) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],difference = 2) == 11\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89],difference = 1) == 3\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],difference = 4) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16],difference = 2) == 8\n assert candidate(arr = [1000, -999, -998, -997, -996, -995, -994, -993, -992, -991],difference = 1) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],difference = 1) == 1\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],difference = 5) == 15\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],difference = 2) == 13\n assert candidate(arr = [100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50],difference = -2) == 26\n assert candidate(arr = [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],difference = 3) == 34\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8],difference = 2) == 4\n assert candidate(arr = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60],difference = 5) == 10\n assert candidate(arr = [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],difference = -2) == 41\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],difference = 1) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],difference = 2) == 20\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],difference = 2) == 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, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],difference = 1) == 40\n assert candidate(arr = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55],difference = 6) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],difference = 2) == 10\n assert candidate(arr = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],difference = 2) == 21\n assert candidate(arr = [30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, -3, -6, -9, -12, -15, -18, -21, -24, -27],difference = -3) == 20\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],difference = 1) == 8\n assert candidate(arr = [10, 7, 4, 3, 2, 1],difference = -3) == 4\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13],difference = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 6, 8, 10, 14, 18, 22, 26],difference = 2) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],difference = 100) == 10\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144],difference = 3) == 3\n assert candidate(arr = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55],difference = -5) == 10\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],difference = 4) == 10\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],difference = 1) == 4\n assert candidate(arr = [5, 3, 1, -1, -3, -5, -7, -9],difference = -2) == 8\n assert candidate(arr = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46],difference = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],difference = 1) == 15\n assert candidate(arr = [5, 6, 7, 10, 11, 12, 15, 16, 17, 20, 21, 22],difference = 1) == 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],difference = 1) == 50\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],difference = 10) == 15\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5],difference = 1) == 5\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63],difference = 6) == 11\n assert candidate(arr = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],difference = 1) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],difference = 1) == 20\n assert candidate(arr = [1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 18, 20],difference = 2) == 10\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],difference = 0) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70],difference = 10) == 7\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],difference = 3) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],difference = -1) == 10\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43],difference = 3) == 15\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],difference = -10) == 11\n assert candidate(arr = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32],difference = 3) == 10\n assert candidate(arr = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],difference = 3) == 10\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],difference = 2) == 2\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50],difference = 5) == 9\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25],difference = 4) == 7\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21],difference = 2) == 9\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],difference = 5) == 11\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],difference = 2) == 21\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],difference = -1) == 21\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13],difference = 2) == 7\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],difference = 5) == 10\n assert candidate(arr = [2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],difference = 2) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],difference = 10) == 11\n assert candidate(arr = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91],difference = 9) == 11\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],difference = 2) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],difference = 2) == 8\n assert candidate(arr = [10, 2, 5, 8, 4, 6, 1, 3, 7],difference = 3) == 3\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],difference = 2) == 25\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],difference = 10) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],difference = 4) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],difference = 2) == 15\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],difference = 13) == 3\n assert candidate(arr = [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],difference = -2) == 26\n assert candidate(arr = [10000, 9998, 9996, 9994, 9992, 9990, 9988, 9986, 9984, 9982],difference = -2) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],difference = 2) == 11\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],difference = 2) == 2\n assert candidate(arr = [1, 2, 3, 6, 7, 8, 10, 11],difference = 1) == 3\n assert candidate(arr = [1, 6, 11, 16, 21, 26, 31],difference = 5) == 7\n assert candidate(arr = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],difference = 11) == 10\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40],difference = 3) == 14\n assert candidate(arr = [100, 97, 94, 91, 88, 85, 82, 79, 76, 73, 70, 67, 64, 61, 58, 55, 52, 49, 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, -2, -5, -8, -11, -14, -17, -20, -23, -26, -29, -32, -35, -38, -41, -44, -47, -50],difference = -3) == 51\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],difference = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],difference = 1) == 15\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31],difference = 3) == 11\n assert candidate(arr = [3, 0, -3, -6, -9, -12, -15],difference = -3) == 7\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],difference = 0) == 20\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],difference = 4) == 13\n assert candidate(arr = [10, 4, 7, 2, 5, 8, 11, 14],difference = 3) == 5\n assert candidate(arr = [1, 2, 3, 8, 7, 6, 5, 4],difference = -1) == 5\n assert candidate(arr = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50],difference = -5) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],difference = 1) == 20\n assert candidate(arr = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14],difference = 1) == 14\n assert candidate(arr = [3, 0, -3, -6, -9, -12, -15, -18],difference = -3) == 8\n assert candidate(arr = [10, 7, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6],difference = -3) == 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],difference = 2) == 10\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],difference = 5) == 20\n assert candidate(arr = [3, 0, -3, -6, -9, -12, -15, -18, -21, -24],difference = -3) == 10\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],difference = 4) == 10\n assert candidate(arr = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41],difference = 3) == 13\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],difference = 0) == 10\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22],difference = 3) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],difference = 2) == 13\n assert candidate(arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, -12, -14, -16, -18],difference = -2) == 20\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10],difference = -10) == 12\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],difference = 2) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],difference = -1) == 20\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],difference = 1) == 10\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986],difference = -1) == 15\n assert candidate(arr = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993, -9992, -9991],difference = 1) == 10\n assert candidate(arr = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18],difference = 3) == 2\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],difference = 4) == 11\n assert candidate(arr = [100, -99, 198, -297, 396, -495, 594, -693, 792, -891, 990, -1089, 1188, -1287, 1386],difference = -198) == 7\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],difference = -10) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],difference = 10) == 10\n assert candidate(arr = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50],difference = -5) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],difference = 3) == 10\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],difference = 1) == 30\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],difference = 1) == 10\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65],difference = 5) == 13\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],difference = 1) == 25\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],difference = 1) == 3\n assert candidate(arr = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],difference = 1) == 2\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],difference = 1) == 2\n assert candidate(arr = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6],difference = 1) == 7\n assert candidate(arr = [50, 47, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, -1, -4, -7],difference = -3) == 20\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],difference = 4) == 20\n assert candidate(arr = [1, 2, 3, 5, 9, 17, 33, 65, 129, 257],difference = 1) == 3\n assert candidate(arr = [10, 5, 0, -5, -10, -15, -20, -25, -30],difference = -5) == 9\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],difference = 1) == 26\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],difference = 2) == 2\n assert candidate(arr = [200, 195, 190, 185, 180, 175, 170, 165, 160, 155, 150, 145, 140, 135, 130, 125, 120, 115, 110],difference = -5) == 19\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37],difference = 3) == 13\n assert candidate(arr = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],difference = -1) == 11\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],difference = -10) == 21\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],difference = 3) == 1\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],difference = 1) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],difference = 10) == 15\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],difference = 0) == 10\n assert candidate(arr = [4, 12, 10, 0, -2, 7, 15, 22, 29, 36, 43],difference = 7) == 5\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n1", "[1,3,5,7]\n1", "[1,5,7,8,5,3,4,2,1]\n-2"], "hints": ["Use dynamic programming.", "Let dp[i] be the maximum length of a subsequence of the given difference whose last element is i.", "dp[i] = 1 + dp[i-k]"], "metadata": {"canonical_parameter_names": ["arr", "difference"], "leetcode_dataset_entry_point": "Solution().longestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:37+00:00", "tests_total": 154, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def longestSubsequence(self, arr: list[int], difference: int) -> int:", "container": "Solution", "callable": "longestSubsequence", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "difference", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1219, "task_id": "path-with-maximum-gold", "difficulty": "Medium", "problem_description": "In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.\n\nReturn the maximum amount of gold you can collect under the conditions:\n\n- Every time you are located in a cell you will collect all the gold in that cell.\n- From your position, you can walk one step to the left, right, up, or down.\n- You can't visit the same cell more than once.\n- Never visit a cell with 0 gold.\n- You can start and stop collecting gold from any position in the grid that has some gold.\n\nExample 1:\n\nInput: grid = [[0,6,0],[5,8,7],[0,9,0]]\nOutput: 24\nExplanation:\n[[0,6,0],\n [5,8,7],\n [0,9,0]]\nPath to get the maximum gold, 9 -> 8 -> 7.\n\nExample 2:\n\nInput: grid = [[1,0,7],[2,0,6],[3,4,5],[0,3,0],[9,0,20]]\nOutput: 28\nExplanation:\n[[1,0,7],\n [2,0,6],\n [3,4,5],\n [0,3,0],\n [9,0,20]]\nPath to get the maximum gold, 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 15\n- 0 <= grid[i][j] <= 100\n- There are at most 25 cells containing gold.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 0, 7, 0], [2, 0, 6, 8], [0, 4, 5, 0], [3, 0, 3, 0], [9, 0, 20, 0]]) == 42\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 6], [7, 0, 0, 0], [0, 0, 0, 8]]) == 8\n assert candidate(grid = [[0, 6, 0], [5, 8, 7], [0, 9, 0]]) == 24\n assert candidate(grid = [[10, 0, 0], [0, 0, 0], [0, 0, 10]]) == 10\n assert candidate(grid = [[1, 3, 1, 5], [2, 2, 4, 1], [5, 0, 2, 3], [0, 6, 1, 2]]) == 37\n assert candidate(grid = [[1, 0, 7, 0], [2, 0, 6, 8], [0, 4, 5, 0], [9, 3, 0, 20]]) == 35\n assert candidate(grid = [[1, 0, 1], [0, 0, 0], [1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[10]]) == 10\n assert candidate(grid = [[1, 0, 7], [2, 0, 6], [3, 4, 5], [0, 3, 0], [9, 0, 20]]) == 28\n assert candidate(grid = [[0, 0], [0, 1]]) == 1\n assert candidate(grid = [[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]]) == 2\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 2, 0], [0, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 8]]) == 8\n assert candidate(grid = [[10, 33], [8, 3]]) == 54\n assert candidate(grid = [[0, 2, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0]]) == 2\n assert candidate(grid = [[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]]) == 120\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 0, 0, 0, 10], [10, 0, 50, 0, 10], [10, 0, 0, 0, 10], [10, 10, 10, 10, 10]]) == 160\n assert candidate(grid = [[8, 1, 0, 0, 0], [0, 0, 0, 2, 0], [0, 3, 4, 0, 0], [0, 0, 0, 5, 0], [0, 0, 0, 0, 6]]) == 9\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]]) == 250\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]]) == 100\n assert candidate(grid = [[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\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 = [[0, 0, 0, 0, 0], [0, 3, 6, 3, 0], [0, 6, 0, 6, 0], [0, 3, 6, 3, 0], [0, 0, 0, 0, 0]]) == 36\n assert candidate(grid = [[1, 0, 7, 0, 9], [2, 0, 6, 0, 8], [3, 4, 5, 0, 10], [0, 3, 0, 0, 11], [9, 0, 20, 0, 12]]) == 50\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 2, 0, 4, 0, 0], [0, 0, 6, 0, 8, 0], [0, 10, 0, 12, 0, 0], [0, 0, 14, 0, 16, 0], [0, 18, 0, 20, 0, 0]]) == 20\n assert candidate(grid = [[1, 0, 3, 0, 5], [0, 8, 0, 2, 0], [3, 0, 4, 0, 6], [0, 5, 0, 8, 0], [4, 0, 1, 0, 7]]) == 8\n assert candidate(grid = [[0, 0, 0, 0], [0, 100, 0, 0], [0, 0, 100, 0], [0, 0, 0, 0]]) == 100\n assert candidate(grid = [[0, 1, 0, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 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], [1, 1, 1, 1, 1, 1]]) == 22\n assert candidate(grid = [[1, 2, 3, 4, 5], [0, 0, 0, 0, 6], [7, 8, 9, 10, 11], [0, 0, 0, 0, 12], [13, 14, 15, 16, 17]]) == 132\n assert candidate(grid = [[0, 20, 0, 0], [0, 0, 0, 30], [40, 0, 50, 0], [0, 60, 0, 0]]) == 60\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, 3, 0, 4, 0], [2, 0, 5, 0, 6], [0, 7, 0, 8, 0], [9, 0, 10, 0, 11], [0, 12, 0, 13, 0]]) == 13\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 0], [0, 7, 8, 9, 10, 11, 12, 0], [0, 13, 14, 15, 16, 17, 18, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 171\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, 5]]) == 5\n assert candidate(grid = [[1, 0, 0, 0, 2], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [2, 0, 0, 0, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 136\n assert candidate(grid = [[1, 2, 0, 1, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 12\n assert candidate(grid = [[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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 10]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 0], [1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[5, 0, 10, 0, 15], [0, 20, 0, 25, 0], [30, 0, 35, 0, 40], [0, 45, 0, 50, 0], [55, 0, 60, 0, 65]]) == 65\n assert candidate(grid = [[3, 0, 1, 0, 3], [0, 1, 0, 1, 0], [1, 0, 2, 0, 1], [0, 1, 0, 1, 0], [3, 0, 1, 0, 3]]) == 3\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 78\n assert candidate(grid = [[10, 10, 10], [10, 0, 10], [10, 10, 10]]) == 80\n assert candidate(grid = [[0, 34, 0, 0, 12], [23, 0, 0, 11, 0], [0, 0, 22, 0, 0], [0, 10, 0, 0, 33], [11, 0, 0, 21, 0]]) == 34\n assert candidate(grid = [[1, 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, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]]) == 38\n assert candidate(grid = [[2, 0, 6, 0, 1, 0], [0, 3, 0, 5, 0, 8], [5, 0, 2, 0, 9, 0], [0, 7, 0, 1, 0, 4], [6, 0, 9, 0, 3, 0]]) == 9\n assert candidate(grid = [[5, 0, 2, 0, 5], [0, 1, 0, 1, 0], [2, 0, 3, 0, 2], [0, 1, 0, 1, 0], [5, 0, 2, 0, 5]]) == 5\n assert candidate(grid = [[30, 15, 15, 15, 30], [15, 0, 0, 0, 15], [15, 0, 0, 0, 15], [15, 0, 0, 0, 15], [30, 15, 15, 15, 30]]) == 300\n assert candidate(grid = [[100, 0, 100, 0, 100], [0, 0, 0, 0, 0], [100, 0, 100, 0, 100], [0, 0, 0, 0, 0], [100, 0, 100, 0, 100]]) == 100\n assert candidate(grid = [[10, 20, 30], [0, 0, 0], [40, 50, 60]]) == 150\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, 5, 4, 3, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 59\n assert candidate(grid = [[0, 3, 0, 4, 0], [2, 0, 2, 0, 1], [0, 6, 0, 7, 0], [3, 0, 4, 0, 2], [0, 5, 0, 6, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 20, 0, 0], [0, 19, 0, 18, 0], [0, 0, 17, 0, 0], [0, 0, 0, 0, 0]]) == 20\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]]) == 13\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 19\n assert candidate(grid = [[5, 0, 0, 0, 0, 5], [0, 4, 0, 0, 4, 0], [0, 0, 3, 3, 0, 0], [0, 0, 3, 3, 0, 0], [0, 4, 0, 0, 4, 0], [5, 0, 0, 0, 0, 5]]) == 12\n assert candidate(grid = [[1, 3, 1, 5], [2, 0, 0, 0], [5, 1, 1, 0], [4, 3, 2, 1]]) == 29\n assert candidate(grid = [[10, 10, 10, 10], [10, 0, 0, 10], [10, 0, 0, 10], [10, 10, 10, 10]]) == 120\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 = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 64\n assert candidate(grid = [[5, 0, 3, 0, 0], [0, 0, 0, 0, 0], [4, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(grid = [[1, 0, 0, 0, 5], [0, 2, 0, 4, 0], [0, 0, 3, 0, 0], [0, 6, 0, 7, 0], [8, 0, 0, 0, 9]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\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, 0, 3, 0, 5], [0, 8, 0, 10, 0], [11, 0, 13, 0, 15], [0, 16, 0, 18, 0], [19, 0, 21, 0, 23]]) == 23\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, 0, 1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 1, 0, 1, 0, 0, 0, 1], [1, 0, 0, 1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 30\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 0], [0, 2, 3, 4, 5, 0], [0, 3, 4, 5, 6, 0], [0, 4, 5, 6, 7, 0], [0, 0, 0, 0, 0, 0]]) == 64\n assert candidate(grid = [[8, 0, 0, 0, 0, 5, 0, 0, 0], [0, 1, 2, 3, 0, 0, 0, 4, 0], [0, 0, 3, 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]]) == 8\n assert candidate(grid = [[10, 20, 0, 0, 30], [0, 0, 50, 0, 0], [40, 0, 0, 0, 0], [0, 0, 60, 0, 0], [0, 70, 0, 80, 0]]) == 80\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]]) == 110\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 2, 0, 2, 0], [0, 0, 3, 0, 0], [0, 4, 0, 4, 0], [1, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 6, 4, 8], [2, 0, 0, 0, 0], [3, 0, 5, 1, 3], [0, 0, 0, 0, 0], [9, 0, 20, 0, 7]]) == 20\n assert candidate(grid = [[1, 3, 1, 5], [2, 0, 4, 0], [5, 3, 0, 2], [3, 2, 1, 1]]) == 26\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[5, 0, 0, 0, 5], [0, 5, 5, 5, 0], [0, 5, 0, 5, 0], [0, 5, 5, 5, 0], [5, 0, 0, 0, 5]]) == 40\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == 84\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [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], [1, 2, 3, 4, 5, 6, 7, 8, 9], [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], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 45\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 0, 6]]) == 6\n assert candidate(grid = [[30, 0, 40, 0, 50], [0, 20, 0, 30, 0], [40, 0, 50, 0, 60], [0, 30, 0, 40, 0], [50, 0, 60, 0, 70]]) == 70\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 100, 0, 100, 0], [0, 0, 0, 0, 0], [0, 100, 0, 100, 0], [0, 0, 0, 0, 0]]) == 100\n assert candidate(grid = [[0, 0, 0, 0], [0, 100, 100, 0], [0, 100, 100, 0], [0, 0, 0, 0]]) == 400\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]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 2, 0, 2, 0], [0, 0, 0, 0, 0], [0, 2, 0, 2, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 0], [0, 9, 8, 7, 6], [1, 2, 3, 4, 5]]) == 105\n assert candidate(grid = [[9, 0, 8, 0, 7], [0, 6, 0, 5, 0], [4, 0, 3, 0, 2], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[5, 1, 3, 1, 5], [1, 0, 2, 0, 1], [3, 0, 0, 0, 3], [1, 0, 2, 0, 1], [5, 1, 3, 1, 5]]) == 42\n assert candidate(grid = [[1, 0, 2, 0, 1], [0, 3, 0, 3, 0], [2, 0, 4, 0, 2], [0, 5, 0, 5, 0], [1, 0, 2, 0, 1]]) == 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, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 0, 0], [0, 0, 3, 0, 2, 0], [0, 2, 0, 2, 0, 0], [0, 0, 2, 0, 2, 0], [0, 0, 0, 0, 0, 0]]) == 3\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 = [[0, 2, 0, 8, 0], [4, 0, 0, 0, 6], [0, 3, 0, 1, 0], [0, 7, 0, 0, 9], [0, 0, 5, 0, 0]]) == 10\n assert candidate(grid = [[0, 30, 5, 0], [10, 0, 0, 10], [0, 20, 0, 0], [10, 0, 0, 0]]) == 35\n", "comparison": "exact"}, "public_tests": ["[[0,6,0],[5,8,7],[0,9,0]]", "[[1,0,7],[2,0,6],[3,4,5],[0,3,0],[9,0,20]]"], "hints": ["Use recursion to try all such paths and find the one with the maximum value."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().getMaximumGold", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:39+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "backtracking", "matrix"]}, "language": "python", "interface": {"raw_signature": "def getMaximumGold(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "getMaximumGold", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1220, "task_id": "count-vowels-permutation", "difficulty": "Hard", "problem_description": "Given an integer n, your task is to count how many strings of length n can be formed under the following rules:\n\n- Each character is a lower case vowel ('a', 'e', 'i', 'o', 'u')\n- Each vowel 'a' may only be followed by an 'e'.\n- Each vowel 'e' may only be followed by an 'a' or an 'i'.\n- Each vowel 'i' may not be followed by another 'i'.\n- Each vowel 'o' may only be followed by an 'i' or a 'u'.\n- Each vowel 'u' may only be followed by an 'a'.\n\nSince the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 1\nOutput: 5\nExplanation: All possible strings are: \"a\", \"e\", \"i\" , \"o\" and \"u\".\n\nExample 2:\n\nInput: n = 2\nOutput: 10\nExplanation: All possible strings are: \"ae\", \"ea\", \"ei\", \"ia\", \"ie\", \"io\", \"iu\", \"oi\", \"ou\" and \"ua\".\n\nExample 3:\n\nInput: n = 5\nOutput: 68\n\nConstraints:\n\n- 1 <= n <= 2 * 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1000) == 89945857\n assert candidate(n = 100) == 173981881\n assert candidate(n = 20000) == 759959057\n assert candidate(n = 200) == 670333618\n assert candidate(n = 10000) == 76428576\n assert candidate(n = 5000) == 598627501\n assert candidate(n = 2000) == 793084836\n assert candidate(n = 2) == 10\n assert candidate(n = 20) == 1151090\n assert candidate(n = 1) == 5\n assert candidate(n = 500) == 518032023\n assert candidate(n = 50) == 227130014\n assert candidate(n = 10) == 1739\n assert candidate(n = 5) == 68\n assert candidate(n = 15000) == 381635004\n assert candidate(n = 3) == 19\n assert candidate(n = 12345) == 480007966\n assert candidate(n = 4) == 35\n assert candidate(n = 75) == 467397509\n assert candidate(n = 150) == 965179800\n assert candidate(n = 6) == 129\n assert candidate(n = 19999) == 706457669\n assert candidate(n = 19000) == 70562691\n assert candidate(n = 18000) == 596349393\n assert candidate(n = 25) == 29599477\n", "comparison": "exact"}, "public_tests": ["1", "2"], "hints": ["Use dynamic programming.", "Let dp[i][j] be the number of strings of length i that ends with the j-th vowel.", "Deduce the recurrence from the given relations between vowels."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countVowelPermutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:41+00:00", "tests_total": 26, "tests_dropped": 1, "flags": [], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def countVowelPermutation(self, n: int) -> int:", "container": "Solution", "callable": "countVowelPermutation", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1221, "task_id": "split-a-string-in-balanced-strings", "difficulty": "Easy", "problem_description": "Balanced strings are those that have an equal quantity of 'L' and 'R' characters.\n\nGiven a balanced string s, split it into some number of substrings such that:\n\n- Each substring is balanced.\n\nReturn the maximum number of balanced strings you can obtain.\n\nExample 1:\n\nInput: s = \"RLRRLLRLRL\"\nOutput: 4\nExplanation: s can be split into \"RL\", \"RRLL\", \"RL\", \"RL\", each substring contains same number of 'L' and 'R'.\n\nExample 2:\n\nInput: s = \"RLRRRLLRLL\"\nOutput: 2\nExplanation: s can be split into \"RL\", \"RRRLLRLL\", each substring contains same number of 'L' and 'R'.\nNote that s cannot be split into \"RL\", \"RR\", \"RL\", \"LR\", \"LL\", because the 2^nd and 5^th substrings are not balanced.\n\nExample 3:\n\nInput: s = \"LLLLRRRR\"\nOutput: 1\nExplanation: s can be split into \"LLLLRRRR\".\n\nConstraints:\n\n- 2 <= s.length <= 1000\n- s[i] is either 'L' or 'R'.\n- s is a balanced string.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"RRLLRRLL\") == 2\n assert candidate(s = \"RLRRRLLRLL\") == 2\n assert candidate(s = \"RRRRLLLLRRRRLLLL\") == 2\n assert candidate(s = \"LRRLLRRL\") == 4\n assert candidate(s = \"LLLLRRRRLLRRRR\") == 2\n assert candidate(s = \"RLLLLRRR\") == 2\n assert candidate(s = \"RLLRRLRR\") == 3\n assert candidate(s = \"RLRRLLRLRL\") == 4\n assert candidate(s = \"RRLLRRLLRL\") == 3\n assert candidate(s = \"LLRRLLRRLL\") == 2\n assert candidate(s = \"RRLRRLRLRL\") == 0\n assert candidate(s = \"RRLLRRLLRR\") == 2\n assert candidate(s = \"RLRRLLRL\") == 3\n assert candidate(s = \"LRRLRLLRRL\") == 5\n assert candidate(s = \"RLRLRLRLRL\") == 5\n assert candidate(s = \"LLRRLLRR\") == 2\n assert candidate(s = \"RLRLRLRL\") == 4\n assert candidate(s = \"RRRRLLLL\") == 1\n assert candidate(s = \"RRLRLLRLRL\") == 3\n assert candidate(s = \"LLRRLLRRLR\") == 3\n assert candidate(s = \"LRLRLRLRLR\") == 5\n assert candidate(s = \"LLRRRLLL\") == 2\n assert candidate(s = \"LRLRLRLR\") == 4\n assert candidate(s = \"LLLLRRRR\") == 1\n assert candidate(s = \"RLRRLLRRLLRRRRLLLLRRLLRR\") == 5\n assert candidate(s = \"RRLLRRLLRRLLRRLL\") == 4\n assert candidate(s = \"LLLLLLLLRRRRRRRR\") == 1\n assert candidate(s = \"LLLLRRRLLLLRRRLLLLRRR\") == 0\n assert candidate(s = \"RRRLLLRRRLLLRRRLLL\") == 3\n assert candidate(s = \"LLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRR\") == 13\n assert candidate(s = \"LRLRLRLRLRRRRLLLLRRRRLLLL\") == 8\n assert candidate(s = \"RLLLLRRRRLLRLRRLRRLLRLRLRL\") == 10\n assert candidate(s = \"RLRLRLRLRLRLRLRLRL\") == 9\n assert candidate(s = \"RLRRLLRLRRLLRLRRLLRLRRLLRLRLRRLLRLRRLLRLRLRR\") == 15\n assert candidate(s = \"RLRLRLRLRLRLRLRL\") == 8\n assert candidate(s = \"RLLLLRRRRLLRRRRLLR\") == 4\n assert candidate(s = \"RLRRLLRLRRLLRLRLRRLLRLRL\") == 9\n assert candidate(s = \"LRRLRLRLRLRLRLRLRL\") == 9\n assert candidate(s = \"RRRRRRLLLLLLRRRRLL\") == 1\n assert candidate(s = \"LLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRR\") == 5\n assert candidate(s = \"RRLRRLRRLRRLRRLRRL\") == 0\n assert candidate(s = \"RLRRLLRLRRLLRLRLRRLLRLRLRRLLRLRLRRLLRLRL\") == 15\n assert candidate(s = \"RRRLLLLLRRRLLLLLRRRLLLLL\") == 3\n assert candidate(s = \"LRLRLRLRRRLLLLRRRLLLLRRRLRLR\") == 10\n assert candidate(s = \"LLRRLRRLRRLRRLRR\") == 3\n assert candidate(s = \"RLRLRLRLRLRLRLRLRLRL\") == 10\n assert candidate(s = \"RRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == 6\n assert candidate(s = \"RLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRR\") == 2\n assert candidate(s = \"RRLLRRLRLRRLRLRR\") == 1\n assert candidate(s = \"RLRLRLRLRRRRLLLL\") == 5\n assert candidate(s = \"LRLRLRLRLRLRLRLRLR\") == 9\n assert candidate(s = \"RLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLL\") == 21\n assert candidate(s = \"LLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRR\") == 3\n assert candidate(s = \"RLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRR\") == 10\n assert candidate(s = \"LRRRLLRRLRRRLLRRRLLR\") == 2\n assert candidate(s = \"RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL\") == 16\n assert candidate(s = \"LLLLRRRRRRRRLLLLRRRR\") == 2\n assert candidate(s = \"LLLLLLLLRRRRRRRRRRRRRRRR\") == 1\n assert candidate(s = \"LLRRRLLLLRRRRLLLLRRRR\") == 5\n assert candidate(s = \"LLRRLLRRLLLLRRRR\") == 3\n assert candidate(s = \"RLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRR\") == 16\n assert candidate(s = \"RRRRLLLLRRRRRRLLLLLLLLRRRRLLLLLLLLRRRRLLLL\") == 4\n assert candidate(s = \"RRRRLLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLL\") == 7\n assert candidate(s = \"LLLLLLRRRRRRLLLLLLRRRRRRLLLLLLRRRRRR\") == 3\n assert candidate(s = \"RRRRRRLLLLLLRRRRRRLLLLLLRRRRRRLLLLLL\") == 3\n assert candidate(s = \"LRRRRLLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLL\") == 7\n assert candidate(s = \"RLRRLLRLRLRLRRLLRLRLRRLLRLRL\") == 11\n assert candidate(s = \"LLLLRRRRLLLLRRRR\") == 2\n assert candidate(s = \"LLLLRRRRRLRRLLRRLLRRLLRRRRLLLLRRLLRRRRLLLLRRLLRR\") == 9\n assert candidate(s = \"RRRRRRLLLLLLLLRRRRRRLLLLLLLLRRRRRRLLLLLLLL\") == 5\n assert candidate(s = \"RRRRRRRRRRLLLLLLLLLLRRRRRRRRRRLLLLLLLLLL\") == 2\n assert candidate(s = \"LRRLRLRLRLRLRLRL\") == 8\n assert candidate(s = \"RRRLLRLLRRLRRLLRLLRR\") == 2\n assert candidate(s = \"RLRRLLRLRLRRLLRLRLRRLLRLRL\") == 10\n assert candidate(s = \"LLRRLLRRLLRRLLRRLLRRLLRR\") == 6\n assert candidate(s = \"LLLLRRRRLLLLRRRRLLLLRRRR\") == 3\n assert candidate(s = \"RRLLRRLLRRLLRRLLRRLL\") == 5\n assert candidate(s = \"RRRRLLLLRRRRLLLLRRRRLLLLRRRR\") == 3\n assert candidate(s = \"RLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLL\") == 3\n assert candidate(s = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR\") == 26\n assert candidate(s = \"RLRRLLRLRRLLRLRL\") == 6\n assert candidate(s = \"LRLRLRLRLRLRLRLR\") == 8\n assert candidate(s = \"RRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRRLL\") == 10\n assert candidate(s = \"RLLLLRRRRRLRRRLLLLLRRRRRLLLL\") == 5\n assert candidate(s = \"RRLLRRLLRRLLRRLLRRLLRRLL\") == 6\n assert candidate(s = \"RRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == 4\n assert candidate(s = \"LLLLLLLLLLLLRRRRRRRRRRRR\") == 1\n assert candidate(s = \"RRLLRLRLRRLLRLRL\") == 6\n assert candidate(s = \"RRRRRRRRLLLLLLLL\") == 1\n assert candidate(s = \"RLRRLLRLRLRLRRLLRLRRLLRLRL\") == 10\n assert candidate(s = \"LLRRLLRRLLRRLLRRLLRRLLRRLLRRLLRR\") == 8\n assert candidate(s = \"RLLLLLLLLLLLLRRRRRRRRRRRRR\") == 2\n assert candidate(s = \"LLLLRRRRRRRRLLLL\") == 2\n assert candidate(s = \"RRRLLLLRRRLLLLRRRLLLL\") == 5\n assert candidate(s = \"RLRRLLRLLRLRRLLRLR\") == 8\n assert candidate(s = \"RRRRLLLLRRRLLLLRRRRLLLLRRRLLLLRRRRLLLLRRRLLLLRRR\") == 11\n assert candidate(s = \"RLRRLLRLRLRRLLRLRL\") == 7\n assert candidate(s = \"RLRRLLRLRRLLRLRLRR\") == 6\n assert candidate(s = \"RRRRLLLLLLLLRRRRLLLL\") == 2\n assert candidate(s = \"RLRRRLRRRLRRRLRRRLRRRLRRRLRRRLRRRLRRRLRR\") == 1\n assert candidate(s = \"RRRRLLLLRRLLRRLLRRLLRRLL\") == 5\n assert candidate(s = \"RRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLL\") == 3\n assert candidate(s = \"LLRRLLRRLLRRLLRR\") == 4\n assert candidate(s = \"LRRRLLLRRLRRLLRR\") == 5\n assert candidate(s = \"LLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRR\") == 4\n assert candidate(s = \"RLRRLLRLRLRLRLRRLLRLRLRRLLRLRLRLRRLLRLRL\") == 16\n assert candidate(s = \"RLLLLRRRRLLRRLLRRLRRLRL\") == 7\n assert candidate(s = \"RRRRLLLLRRRRLLLLRRRRLLLL\") == 3\n assert candidate(s = \"RRLLLLRRLLLLRRLLLL\") == 2\n assert candidate(s = \"LRRLLRRLLRRLLRRLLRRLLRRLL\") == 12\n assert candidate(s = \"RLRRLLRLRRLLRLRRLLRLRRLL\") == 8\n assert candidate(s = \"LRRRRLLLLRRRRLLLL\") == 4\n assert candidate(s = \"RRRLLRLLRRRLLRLL\") == 2\n assert candidate(s = \"RLRLRLRLRLRRLLRRLLRLRLRLRL\") == 11\n assert candidate(s = \"LLRRLRRLRRLRRLRRLRRL\") == 3\n assert candidate(s = \"RRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLL\") == 2\n assert candidate(s = \"RLLLLLRRRRLLRRRLLLRLLLLLRRRRRRLLLLRRRLLRRRRLLRLLL\") == 8\n assert candidate(s = \"LLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRR\") == 1\n", "comparison": "exact"}, "public_tests": ["\"RLRRLLRLRL\"", "\"RLRRRLLRLL\"", "\"LLLLRRRR\""], "hints": ["Loop from left to right maintaining a balance variable when it gets an L increase it by one otherwise decrease it by one.", "Whenever the balance variable reaches zero then we increase the answer by one."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().balancedStringSplit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:43+00:00", "tests_total": 118, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def balancedStringSplit(self, s: str) -> int:", "container": "Solution", "callable": "balancedStringSplit", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1222, "task_id": "queens-that-can-attack-the-king", "difficulty": "Medium", "problem_description": "On a 0-indexed 8 x 8 chessboard, there can be multiple black queens and one white king.\n\nYou are given a 2D integer array queens where queens[i] = [xQueen_i, yQueen_i] represents the position of the i^th black queen on the chessboard. You are also given an integer array king of length 2 where king = [xKing, yKing] represents the position of the white king.\n\nReturn the coordinates of the black queens that can directly attack the king. You may return the answer in any order.\n\nExample 1:\n\nInput: queens = [[0,1],[1,0],[4,0],[0,4],[3,3],[2,4]], king = [0,0]\nOutput: [[0,1],[1,0],[3,3]]\nExplanation: The diagram above shows the three queens that can directly attack the king and the three queens that cannot attack the king (i.e., marked with red dashes).\n\nExample 2:\n\nInput: queens = [[0,0],[1,1],[2,2],[3,4],[3,5],[4,4],[4,5]], king = [3,3]\nOutput: [[2,2],[3,4],[4,4]]\nExplanation: The diagram above shows the three queens that can directly attack the king and the three queens that cannot attack the king (i.e., marked with red dashes).\n\nConstraints:\n\n- 1 <= queens.length < 64\n- queens[i].length == king.length == 2\n- 0 <= xQueen_i, yQueen_i, xKing, yKing < 8\n- All the given positions are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]], king=[4, 4]), [[3, 3], [5, 5]])\n assert answers_match(candidate(queens=[[6, 5], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [0, 5], [0, 0]], king=[3, 5]), [[2, 5], [4, 5]])\n assert answers_match(candidate(queens=[[0, 3], [6, 3], [3, 0], [3, 6]], king=[3, 3]), [[0, 3], [3, 0], [3, 6], [6, 3]])\n assert answers_match(candidate(queens=[[2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [7, 5], [0, 6], [0, 7]], king=[0, 0]), [[0, 6], [2, 0]])\n assert answers_match(candidate(queens=[[0, 1], [1, 0], [4, 0], [0, 4], [3, 3], [2, 4]], king=[0, 0]), [[0, 1], [1, 0], [3, 3]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[7, 7], [0, 7], [7, 0], [5, 5], [2, 2], [4, 4], [6, 6], [1, 1]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[5, 6], [7, 7], [2, 1], [0, 7], [1, 6], [5, 1], [3, 7], [0, 3], [4, 0], [1, 2], [6, 3], [5, 0], [0, 4], [2, 2], [1, 1], [6, 4]], king=[0, 0]), [[0, 3], [4, 0], [1, 1]])\n assert answers_match(candidate(queens=[[0, 7], [7, 0]], king=[3, 3]), [])\n assert answers_match(candidate(queens=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [0, 0]], king=[1, 0]), [[0, 0], [1, 1]])\n assert answers_match(candidate(queens=[[2, 5], [4, 1], [0, 7], [4, 2], [3, 0], [5, 3], [4, 5], [1, 4], [2, 3], [3, 4], [0, 5], [2, 7], [1, 2], [6, 3], [0, 6], [5, 0], [0, 1], [6, 4], [2, 0], [5, 2]], king=[3, 3]), [[2, 3], [0, 6], [3, 0], [3, 4], [4, 2], [5, 3]])\n assert answers_match(candidate(queens=[[0, 0], [7, 7], [0, 7], [7, 0]], king=[3, 3]), [[0, 0], [7, 7]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 4], [3, 5], [4, 4], [4, 5]], king=[3, 3]), [[2, 2], [3, 4], [4, 4]])\n assert answers_match(candidate(queens=[[2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]], king=[2, 4]), [[2, 3], [2, 5]])\n assert answers_match(candidate(queens=[[0, 3], [1, 4], [2, 5], [3, 6], [4, 7]], king=[3, 3]), [[0, 3], [3, 6]])\n assert answers_match(candidate(queens=[[4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [0, 0]], king=[4, 0]), [[0, 0], [4, 1]])\n assert answers_match(candidate(queens=[[7, 0], [6, 1], [5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7]], king=[3, 3]), [[3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7]], king=[0, 3]), [[0, 2], [0, 4]])\n assert answers_match(candidate(queens=[[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [0, 3], [7, 3], [3, 0], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[3, 0], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [0, 3], [1, 3], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 4], [1, 5], [2, 6], [3, 7], [4, 0], [5, 1], [6, 2], [7, 3], [0, 3], [1, 2], [2, 1], [3, 0], [4, 7], [5, 6], [6, 5], [7, 4]], king=[3, 3]), [[0, 3], [1, 5], [3, 0], [3, 7], [5, 1], [7, 3]])\n assert answers_match(candidate(queens=[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [1, 7], [2, 7], [3, 7]], king=[3, 3]), [[2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]], king=[3, 3]), [[2, 3], [3, 4]])\n assert answers_match(candidate(queens=[[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]], king=[3, 3]), [[1, 3], [2, 4], [3, 5], [6, 0]])\n assert answers_match(candidate(queens=[[7, 7], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]], king=[3, 3]), [[0, 0], [3, 0], [3, 7], [6, 0], [7, 7]])\n assert answers_match(candidate(queens=[[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4]], king=[3, 3]), [[2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 6], [6, 2], [6, 6], [3, 0], [3, 7], [4, 3], [7, 4]], king=[3, 3]), [[2, 2], [1, 5], [3, 0], [3, 7], [5, 1], [4, 3], [5, 5]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 6], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]], king=[3, 3]), [[2, 2], [2, 3], [2, 4], [3, 4], [6, 0], [4, 4]])\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0]], king=[3, 3]), [[2, 3], [2, 4], [3, 4], [4, 2]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [0, 2], [1, 1], [2, 0]], king=[3, 3]), [[1, 1], [2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [7, 0], [6, 1], [5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[1, 1], [1, 3], [2, 2], [3, 1], [3, 4], [4, 3], [5, 2], [6, 1], [6, 5], [7, 4]], king=[3, 3]), [[2, 2], [1, 3], [3, 1], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 0], [7, 7], [1, 1], [6, 6], [2, 2], [5, 5], [3, 3]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [5, 5]])\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [7, 0], [6, 1], [5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 7], [7, 6]], king=[3, 3]), [[2, 2], [2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6]], king=[3, 3]), [[2, 3], [3, 2]])\n assert answers_match(candidate(queens=[[7, 0], [6, 1], [5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7]], king=[7, 7]), [[0, 7], [7, 0]])\n assert answers_match(candidate(queens=[[7, 0], [6, 1], [5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6]], king=[3, 3]), [[2, 2], [3, 0], [3, 4], [6, 0], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 2], [1, 5], [2, 7], [3, 0], [4, 6], [5, 1], [6, 3], [7, 4]], king=[3, 3]), [[1, 5], [3, 0], [5, 1], [6, 3]])\n assert answers_match(candidate(queens=[[3, 2], [2, 1], [1, 0], [4, 2], [5, 2], [6, 2], [7, 2], [2, 3], [2, 4], [2, 5], [2, 6]], king=[2, 2]), [[2, 1], [2, 3], [3, 2]])\n assert answers_match(candidate(queens=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3], [6, 1], [6, 2], [6, 3]], king=[3, 3]), [[2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3]])\n assert answers_match(candidate(queens=[[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1]], king=[3, 3]), [[1, 3], [2, 4], [3, 5], [6, 0]])\n assert answers_match(candidate(queens=[[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 0], [1, 7], [2, 0], [2, 7], [3, 0], [3, 7], [4, 0], [4, 7], [5, 0], [5, 7], [6, 0], [6, 7], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]], king=[3, 3]), [[0, 0], [0, 3], [0, 6], [3, 0], [3, 7], [6, 0], [7, 3], [7, 7]])\n assert answers_match(candidate(queens=[[7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0]], king=[0, 0]), [[0, 1], [1, 0]])\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0]], king=[3, 3]), [[2, 2], [3, 0], [6, 0], [4, 4]])\n assert answers_match(candidate(queens=[[0, 1], [0, 5], [1, 0], [1, 7], [2, 2], [2, 6], [3, 3], [4, 2], [4, 4], [5, 1], [5, 5], [6, 0], [6, 7], [7, 3]], king=[3, 3]), [[2, 2], [4, 2], [7, 3], [4, 4]])\n assert answers_match(candidate(queens=[[1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1]], king=[0, 0]), [[4, 4]])\n assert answers_match(candidate(queens=[[1, 1], [1, 6], [6, 1], [6, 6], [3, 2], [4, 4], [5, 3]], king=[3, 3]), [[1, 1], [3, 2], [5, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7]], king=[3, 4]), [[0, 1], [0, 4], [0, 7], [3, 0], [7, 0]])\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2]], king=[3, 3]), [[2, 2], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0]], king=[3, 3]), [[2, 2], [3, 0], [6, 0], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [0, 7], [7, 0], [7, 7], [3, 3], [2, 2], [4, 4], [5, 5], [1, 6], [6, 1]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]], king=[3, 3]), [[2, 2], [0, 3], [0, 6], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [7, 7], [0, 7], [7, 0], [4, 4], [3, 3]], king=[3, 3]), [[0, 0], [4, 4]])\n assert answers_match(candidate(queens=[[1, 7], [7, 1], [2, 6], [6, 2], [3, 5], [5, 3], [4, 4], [0, 0], [7, 7], [0, 7], [7, 0]], king=[3, 3]), [[0, 0], [3, 5], [5, 3], [4, 4]])\n assert answers_match(candidate(queens=[[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6]], king=[7, 7]), [[6, 7], [7, 6]])\n assert answers_match(candidate(queens=[[0, 0], [7, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]], king=[3, 3]), [[0, 0], [3, 4], [4, 3], [7, 7]])\n assert answers_match(candidate(queens=[[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]], king=[7, 7]), [[0, 7], [7, 0]])\n assert answers_match(candidate(queens=[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1]], king=[3, 3]), [[0, 3], [0, 6], [3, 0], [3, 7], [6, 0], [7, 3]])\n assert answers_match(candidate(queens=[[0, 2], [1, 4], [2, 6], [3, 0], [3, 7], [4, 1], [4, 5], [5, 3], [5, 7], [6, 0], [6, 4], [7, 2]], king=[3, 3]), [[3, 0], [3, 7], [6, 0], [5, 3]])\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]], king=[0, 0]), [[1, 1]])\n assert answers_match(candidate(queens=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [0, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 1]], king=[3, 3]), [[2, 2], [3, 0], [3, 7], [6, 0], [4, 4]])\n assert answers_match(candidate(queens=[[0, 3], [2, 1], [4, 0], [5, 2], [6, 1], [7, 3], [1, 0], [1, 6], [3, 1], [3, 5], [5, 6], [6, 4]], king=[3, 3]), [[0, 3], [3, 1], [3, 5], [7, 3]])\n assert answers_match(candidate(queens=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]], king=[0, 0]), [[1, 1]])\n assert answers_match(candidate(queens=[[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0], [7, 1], [6, 2], [5, 3], [4, 4], [3, 5], [2, 6], [1, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]], king=[3, 3]), [[0, 3], [0, 6], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2]], king=[3, 3]), [[2, 2], [3, 2], [3, 7], [4, 2], [7, 7]])\n assert answers_match(candidate(queens=[[0, 3], [1, 3], [2, 3], [3, 2], [3, 3], [3, 4], [4, 3], [5, 3], [6, 3], [7, 3]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[1, 0], [1, 7], [2, 1], [2, 6], [3, 2], [3, 5], [4, 3], [4, 4], [5, 2], [5, 5], [6, 1], [6, 6], [7, 0], [7, 7]], king=[3, 3]), [[3, 2], [3, 5], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]], king=[3, 3]), [[2, 2], [2, 3], [3, 4], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [1, 2], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6]], king=[3, 3]), [[0, 0], [2, 3], [3, 2], [4, 4]])\n assert answers_match(candidate(queens=[[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1]], king=[3, 3]), [[3, 2], [3, 5], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 7], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [0, 7], [7, 0], [7, 7], [3, 3], [4, 4], [2, 2], [5, 5], [1, 1], [6, 6], [0, 3], [3, 0], [3, 6], [6, 3]], king=[3, 3]), [[2, 2], [0, 3], [3, 0], [3, 6], [6, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 0], [0, 4], [0, 7], [1, 1], [1, 3], [1, 5], [1, 7], [2, 2], [2, 4], [2, 6], [3, 0], [3, 2], [3, 6], [4, 1], [4, 3], [4, 5], [5, 0], [5, 2], [5, 4], [5, 7], [6, 1], [6, 3], [6, 5], [7, 0], [7, 3], [7, 7]], king=[3, 3]), [[2, 2], [1, 3], [2, 4], [3, 2], [3, 6], [4, 3], [7, 7]])\n assert answers_match(candidate(queens=[[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]], king=[3, 3]), [[2, 2], [5, 5]])\n assert answers_match(candidate(queens=[[1, 2], [2, 4], [3, 6], [4, 0], [5, 1], [6, 3], [7, 5]], king=[4, 4]), [[2, 4], [4, 0]])\n assert answers_match(candidate(queens=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, 7], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]], king=[3, 3]), [[2, 3], [2, 4], [3, 0], [3, 4], [4, 2], [6, 6]])\n assert answers_match(candidate(queens=[[1, 0], [0, 1], [2, 1], [1, 2], [0, 2], [2, 0], [3, 1], [2, 2], [1, 3], [0, 3], [3, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 4]], king=[3, 3]), [[2, 2], [2, 3], [3, 2]])\n assert answers_match(candidate(queens=[[0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [5, 7], [6, 6], [7, 5], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]], king=[3, 3]), [[2, 2], [1, 3], [2, 4], [3, 1], [3, 4], [4, 2], [4, 3], [6, 6]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [7, 0]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[0, 3], [1, 4], [2, 5], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2]], king=[3, 3]), [[0, 3], [3, 6], [6, 3]])\n assert answers_match(candidate(queens=[[0, 0], [7, 7], [0, 7], [7, 0], [3, 3], [2, 2], [4, 4], [5, 5]], king=[3, 3]), [[2, 2], [4, 4]])\n assert answers_match(candidate(queens=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0], [6, 1], [7, 2]], king=[3, 3]), [[2, 3], [3, 2], [3, 4]])\n assert answers_match(candidate(queens=[[0, 3], [1, 3], [2, 3], [3, 0], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [5, 3], [6, 3], [7, 3]], king=[3, 3]), [[2, 3], [3, 2], [3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[0, 0], [7, 7], [7, 0], [0, 7], [3, 3], [4, 4], [3, 0], [0, 3]], king=[3, 3]), [[0, 0], [0, 3], [3, 0], [4, 4]])\n assert answers_match(candidate(queens=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [0, 7], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [7, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0]], king=[3, 3]), [[1, 3], [2, 4], [3, 2], [3, 5], [4, 2], [4, 3]])\n assert answers_match(candidate(queens=[[0, 2], [1, 5], [2, 0], [3, 7], [4, 3], [5, 6], [6, 1], [7, 4]], king=[3, 3]), [[1, 5], [3, 7], [4, 3]])\n assert answers_match(candidate(queens=[[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]], king=[3, 3]), [[3, 4], [4, 3]])\n assert answers_match(candidate(queens=[[1, 1], [1, 6], [6, 1], [6, 6], [2, 2], [2, 5], [5, 2], [5, 5], [3, 4], [4, 3]], king=[3, 3]), [[2, 2], [3, 4], [4, 3], [5, 5]])\n assert answers_match(candidate(queens=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]], king=[3, 3]), [[2, 2], [3, 2], [4, 3], [4, 4]])\n assert answers_match(candidate(queens=[[0, 1], [0, 4], [0, 6], [1, 2], [1, 5], [1, 7], [2, 0], [2, 3], [2, 5], [2, 7], [3, 1], [3, 2], [3, 4], [3, 6], [4, 0], [4, 3], [4, 5], [4, 7], [5, 1], [5, 2], [5, 4], [5, 6], [6, 0], [6, 3], [6, 5], [6, 7], [7, 1], [7, 4]], king=[3, 3]), [[2, 3], [1, 5], [3, 2], [3, 4], [5, 1], [4, 3]])\n assert answers_match(candidate(queens=[[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]], king=[3, 3]), [[2, 3], [3, 4]])\n assert answers_match(candidate(queens=[[1, 2], [2, 4], [3, 6], [4, 0], [5, 1], [6, 3], [7, 5], [0, 6], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 1]], king=[3, 3]), [[2, 3], [2, 4], [3, 2], [3, 6], [5, 1], [6, 3]])\n assert answers_match(candidate(queens=[[0, 0], [0, 7], [7, 0], [7, 7], [1, 2], [1, 5], [6, 2], [6, 5], [2, 1], [2, 6], [5, 1], [5, 6], [3, 3]], king=[3, 3]), [[0, 0], [1, 5], [5, 1], [7, 7]])\n", "comparison": "unordered"}, "public_tests": ["[[0,1],[1,0],[4,0],[0,4],[3,3],[2,4]]\n[0,0]", "[[0,0],[1,1],[2,2],[3,4],[3,5],[4,4],[4,5]]\n[3,3]"], "hints": ["Check 8 directions around the King.", "Find the nearest queen in each direction."], "metadata": {"canonical_parameter_names": ["queens", "king"], "leetcode_dataset_entry_point": "Solution().queensAttacktheKing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:46+00:00", "tests_total": 102, "tests_dropped": 0, "flags": ["any_order", "figure_reference", "has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def queensAttacktheKing(self, queens: list[list[int]], king: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "queensAttacktheKing", "parameters": [{"name": "queens", "type": "list[list[int]]"}, {"name": "king", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1223, "task_id": "dice-roll-simulation", "difficulty": "Hard", "problem_description": "A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times.\n\nGiven an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained with exact n rolls. Since the answer may be too large, return it modulo 10^9 + 7.\n\nTwo sequences are considered different if at least one element differs from each other.\n\nExample 1:\n\nInput: n = 2, rollMax = [1,1,2,2,2,3]\nOutput: 34\nExplanation: There will be 2 rolls of die, if there are no constraints on the die, there are 6 * 6 = 36 possible combinations. In this case, looking at rollMax array, the numbers 1 and 2 appear at most once consecutively, therefore sequences (1,1) and (2,2) cannot occur, so the final answer is 36-2 = 34.\n\nExample 2:\n\nInput: n = 2, rollMax = [1,1,1,1,1,1]\nOutput: 30\n\nExample 3:\n\nInput: n = 3, rollMax = [1,1,1,2,2,3]\nOutput: 181\n\nConstraints:\n\n- 1 <= n <= 5000\n- rollMax.length == 6\n- 1 <= rollMax[i] <= 15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,rollMax = [2, 2, 2, 2, 2, 2]) == 7200\n assert candidate(n = 1,rollMax = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 1,rollMax = [15, 15, 15, 15, 15, 15]) == 6\n assert candidate(n = 10,rollMax = [2, 3, 4, 5, 6, 7]) == 58240426\n assert candidate(n = 2,rollMax = [1, 1, 2, 2, 2, 3]) == 34\n assert candidate(n = 2,rollMax = [1, 1, 1, 1, 1, 1]) == 30\n assert candidate(n = 5,rollMax = [1, 2, 3, 4, 5, 6]) == 6919\n assert candidate(n = 5,rollMax = [1, 1, 1, 1, 1, 1]) == 3750\n assert candidate(n = 4,rollMax = [1, 2, 3, 4, 5, 6]) == 1188\n assert candidate(n = 3,rollMax = [1, 1, 1, 2, 2, 3]) == 181\n assert candidate(n = 50,rollMax = [5, 5, 5, 5, 5, 5]) == 808684040\n assert candidate(n = 300,rollMax = [1, 1, 1, 15, 1, 15]) == 728503686\n assert candidate(n = 150,rollMax = [1, 2, 2, 3, 3, 4]) == 917820088\n assert candidate(n = 300,rollMax = [3, 3, 3, 3, 3, 3]) == 197968606\n assert candidate(n = 25,rollMax = [15, 14, 13, 12, 11, 10]) == 470351288\n assert candidate(n = 350,rollMax = [2, 3, 4, 5, 6, 7]) == 326686679\n assert candidate(n = 100,rollMax = [5, 5, 5, 5, 5, 5]) == 505697887\n assert candidate(n = 15,rollMax = [1, 1, 2, 2, 3, 3]) == 758892805\n assert candidate(n = 4,rollMax = [3, 2, 1, 2, 3, 4]) == 1176\n assert candidate(n = 150,rollMax = [5, 5, 5, 5, 5, 5]) == 488934088\n assert candidate(n = 10,rollMax = [1, 1, 1, 2, 3, 4]) == 27915907\n assert candidate(n = 50,rollMax = [2, 3, 4, 5, 6, 7]) == 197242731\n assert candidate(n = 10,rollMax = [2, 3, 1, 1, 4, 5]) == 36308544\n assert candidate(n = 50,rollMax = [3, 4, 5, 6, 7, 8]) == 753899520\n assert candidate(n = 400,rollMax = [1, 2, 1, 2, 1, 2]) == 987298539\n assert candidate(n = 200,rollMax = [2, 3, 4, 5, 6, 7]) == 221148447\n assert candidate(n = 50,rollMax = [1, 2, 1, 2, 1, 2]) == 825497499\n assert candidate(n = 50,rollMax = [1, 2, 3, 4, 5, 15]) == 992520282\n assert candidate(n = 200,rollMax = [2, 2, 2, 2, 2, 2]) == 818530237\n assert candidate(n = 10,rollMax = [1, 1, 1, 1, 1, 1]) == 11718750\n assert candidate(n = 100,rollMax = [10, 10, 10, 10, 10, 10]) == 568370197\n assert candidate(n = 30,rollMax = [1, 2, 1, 2, 1, 2]) == 679107530\n assert candidate(n = 100,rollMax = [1, 1, 2, 2, 3, 3]) == 12398650\n assert candidate(n = 100,rollMax = [1, 1, 1, 1, 1, 1]) == 776377743\n assert candidate(n = 400,rollMax = [15, 14, 13, 12, 11, 10]) == 379975553\n assert candidate(n = 20,rollMax = [5, 5, 5, 5, 5, 5]) == 703140572\n assert candidate(n = 100,rollMax = [1, 1, 2, 2, 3, 3]) == 12398650\n assert candidate(n = 20,rollMax = [2, 3, 4, 5, 6, 7]) == 412603689\n assert candidate(n = 400,rollMax = [4, 4, 4, 4, 4, 4]) == 418009264\n assert candidate(n = 150,rollMax = [7, 6, 5, 4, 3, 2]) == 3950632\n assert candidate(n = 40,rollMax = [3, 1, 2, 4, 1, 3]) == 255974937\n", "comparison": "exact"}, "public_tests": ["2\n[1,1,2,2,2,3]", "2\n[1,1,1,1,1,1]", "3\n[1,1,1,2,2,3]"], "hints": ["Think on Dynamic Programming.", "DP(pos, last) which means we are at the position pos having as last the last character seen."], "metadata": {"canonical_parameter_names": ["n", "rollMax"], "leetcode_dataset_entry_point": "Solution().dieSimulator", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:48+00:00", "tests_total": 41, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def dieSimulator(self, n: int, rollMax: list[int]) -> int:", "container": "Solution", "callable": "dieSimulator", "parameters": [{"name": "n", "type": "int"}, {"name": "rollMax", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1224, "task_id": "maximum-equal-frequency", "difficulty": "Hard", "problem_description": "Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so that every number that has appeared in it will have the same number of occurrences.\n\nIf after removing one element there are no remaining elements, it's still considered that every appeared number has the same number of ocurrences (0).\n\nExample 1:\n\nInput: nums = [2,2,1,1,5,3,3,5]\nOutput: 7\nExplanation: For the subarray [2,2,1,1,5,3,3] of length 7, if we remove nums[4] = 5, we will get [2,2,1,1,3,3], so that each number will appear exactly twice.\n\nExample 2:\n\nInput: nums = [1,1,1,2,2,2,3,3,3,4,4,4,5]\nOutput: 13\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 1, 1, 1, 2, 2, 3]) == 7\n assert candidate(nums = [1, 2, 2, 2, 1, 1]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 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]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]) == 11\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [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]) == 20\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 7\n assert candidate(nums = [10, 2, 8, 9, 3, 8, 1, 5, 2, 3, 7, 6]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 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]) == 19\n assert candidate(nums = [100000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1]) == 11\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5]) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 17\n assert candidate(nums = [2, 2, 1, 1, 5, 3, 3, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 11\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 = [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, 7, 7, 7, 7, 7, 7, 7, 7]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 20]) == 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9]) == 5\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6]) == 11\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, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 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]) == 30\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10]) == 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]) == 25\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 7\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]) == 28\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == 5\n assert candidate(nums = [1, 1, 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, 15, 15, 15]) == 46\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]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 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]) == 29\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, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\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, 8, 8, 8, 8, 8, 8, 8]) == 5\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8]) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9]) == 19\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, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 22\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]) == 39\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2]) == 21\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 45\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]) == 36\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 41\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\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]) == 31\n assert candidate(nums = [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]) == 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]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5]) == 9\n assert candidate(nums = [100000, 100000, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 11\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, 10]) == 31\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 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]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 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]) == 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, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 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, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 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]) == 21\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, 10, 10, 10, 10]) == 5\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]) == 5\n assert candidate(nums = [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]) == 28\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 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]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 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]) == 7\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]) == 21\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, 6, 6, 6, 6, 6, 6, 6, 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, 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]) == 59\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]) == 21\n assert candidate(nums = [1, 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, 5, 5, 5, 5, 5]) == 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]) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 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, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == 21\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == 7\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 6]) == 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, 11, 12, 13, 14, 15, 16]) == 21\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]) == 7\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 9\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]) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 17\n", "comparison": "exact"}, "public_tests": ["[2,2,1,1,5,3,3,5]", "[1,1,1,2,2,2,3,3,3,4,4,4,5]"], "hints": ["Keep track of the min and max frequencies.", "The number to be eliminated must have a frequency of 1, same as the others or the same +1."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxEqualFreq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:50+00:00", "tests_total": 104, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "python", "interface": {"raw_signature": "def maxEqualFreq(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxEqualFreq", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1227, "task_id": "airplane-seat-assignment-probability", "difficulty": "Medium", "problem_description": "n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of the passengers will:\n\n- Take their own seat if it is still available, and\n- Pick other seats randomly when they find their seat occupied\n\nReturn the probability that the n^th person gets his own seat.\n\nExample 1:\n\nInput: n = 1\nOutput: 1.00000\nExplanation: The first person can only get the first seat.\n\nExample 2:\n\nInput: n = 2\nOutput: 0.50000\nExplanation: The second person has a probability of 0.5 to get the second seat (when first person gets the first seat).\n\nConstraints:\n\n- 1 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=3), 0.5)\n assert answers_match(candidate(n=100000), 0.5)\n assert answers_match(candidate(n=100), 0.5)\n assert answers_match(candidate(n=10000), 0.5)\n assert answers_match(candidate(n=2), 0.5)\n assert answers_match(candidate(n=1), 1)\n assert answers_match(candidate(n=1000), 0.5)\n assert answers_match(candidate(n=10), 0.5)\n assert answers_match(candidate(n=99999), 0.5)\n assert answers_match(candidate(n=2000), 0.5)\n assert answers_match(candidate(n=50000), 0.5)\n assert answers_match(candidate(n=50), 0.5)\n assert answers_match(candidate(n=5), 0.5)\n assert answers_match(candidate(n=10001), 0.5)\n assert answers_match(candidate(n=4), 0.5)\n assert answers_match(candidate(n=1001), 0.5)\n assert answers_match(candidate(n=101), 0.5)\n assert answers_match(candidate(n=20000), 0.5)\n assert answers_match(candidate(n=5000), 0.5)\n assert answers_match(candidate(n=20), 0.5)\n assert answers_match(candidate(n=9999), 0.5)\n assert answers_match(candidate(n=50001), 0.5)\n assert answers_match(candidate(n=2500), 0.5)\n assert answers_match(candidate(n=200), 0.5)\n assert answers_match(candidate(n=99998), 0.5)\n assert answers_match(candidate(n=500), 0.5)\n", "comparison": "float"}, "public_tests": ["1", "2"], "hints": ["Let f(n) denote the probability of the n-th person getting correct seat in n-person case, then: f(1) = 1 (base case, trivial) f(2) = 1/2 (also trivial)", "Try to calculate f(3), f(4), and f(5) using the base cases. What is the value of them? f(i) for i >= 2 will also be 1/2.", "Try to proof why f(i) = 1/2 for i >= 2."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().nthPersonGetsNthSeat", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:52+00:00", "tests_total": 32, "tests_dropped": 6, "flags": ["decimal_answer"], "topic_tags": ["math", "dynamic-programming", "brainteaser", "probability-and-statistics"]}, "language": "python", "interface": {"raw_signature": "def nthPersonGetsNthSeat(self, n: int) -> float:", "container": "Solution", "callable": "nthPersonGetsNthSeat", "parameters": [{"name": "n", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1232, "task_id": "check-if-it-is-a-straight-line", "difficulty": "Easy", "problem_description": "You are given an integer array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.\n\nExample 1:\n\nInput: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]\nOutput: true\n\nExample 2:\n\nInput: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]\nOutput: false\n\nConstraints:\n\n- 2 <= coordinates.length <= 1000\n- coordinates[i].length == 2\n- -10^4 <= coordinates[i][0], coordinates[i][1] <= 10^4\n- coordinates contains no duplicate point.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3]]) == True\n assert candidate(coordinates = [[-10000, -10000], [0, 0], [10000, 10000]]) == True\n assert candidate(coordinates = [[-4, -3], [1, 0], [3, -1], [0, -1], [-5, 2]]) == False\n assert candidate(coordinates = [[0, 0], [5, 5], [10, 10], [15, 15]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 4]]) == False\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 5]]) == False\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 4], [4, 5], [5, 6], [7, 7]]) == False\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3]]) == True\n assert candidate(coordinates = [[1, 2], [2, 1], [3, 0], [4, -1], [5, -2]]) == True\n assert candidate(coordinates = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [2, 3]]) == False\n assert candidate(coordinates = [[-4, -3], [-1, 1], [2, 5], [5, 9]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == True\n assert candidate(coordinates = [[-1, -1], [0, 0], [1, 1], [2, 2]]) == True\n assert candidate(coordinates = [[0, 1], [1, 3], [-1, -1], [2, 5]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 6]]) == False\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 5]]) == False\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 0], [2, 1], [3, 0]]) == False\n assert candidate(coordinates = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]]) == True\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == True\n assert candidate(coordinates = [[10, 5], [15, 10], [20, 15], [25, 20]]) == True\n assert candidate(coordinates = [[10000, 10000], [5000, 5000], [0, 0]]) == True\n assert candidate(coordinates = [[2, 4], [2, 5], [2, 6]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == True\n assert candidate(coordinates = [[5, -10], [10, -5], [15, 0], [20, 5], [25, 10]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6]]) == True\n assert candidate(coordinates = [[-10, 5], [-5, 10], [0, 15], [5, 20], [10, 25], [15, 30], [20, 35], [25, 40]]) == True\n assert candidate(coordinates = [[-2, -4], [-1, -2], [0, 0], [1, 2], [2, 4]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == True\n assert candidate(coordinates = [[1000, 2000], [2000, 4000], [3000, 6000], [4000, 8000], [5000, 10000]]) == True\n assert candidate(coordinates = [[10, 20], [20, 40], [30, 60], [40, 80], [50, 100], [60, 120]]) == True\n assert candidate(coordinates = [[1, 2], [2, 3], [4, 5], [5, 6], [7, 8], [8, 9], [10, 11]]) == True\n assert candidate(coordinates = [[-5, -20], [0, -10], [5, 0], [10, 10], [15, 20]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 8]]) == False\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10]]) == True\n assert candidate(coordinates = [[-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5], [15, -10]]) == True\n assert candidate(coordinates = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14], [16, 16]]) == True\n assert candidate(coordinates = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11]]) == True\n assert candidate(coordinates = [[-2, 3], [-1, 4], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == True\n assert candidate(coordinates = [[10000, 10000], [5000, 5000], [0, 0], [-5000, -5000], [-10000, -10000]]) == True\n assert candidate(coordinates = [[-20, -30], [-10, -15], [0, 0], [10, 15], [20, 30]]) == True\n assert candidate(coordinates = [[-5, 5], [-10, 10], [-15, 15], [-20, 20], [-25, 25], [-30, 30]]) == True\n assert candidate(coordinates = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30]]) == True\n assert candidate(coordinates = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]) == True\n assert candidate(coordinates = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35]]) == True\n assert candidate(coordinates = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[-2, 1], [-1, 3], [0, 5], [1, 7], [2, 9], [3, 11]]) == True\n assert candidate(coordinates = [[-4, -2], [-2, 0], [0, 2], [2, 4], [4, 6]]) == True\n assert candidate(coordinates = [[-100, 100], [-50, 150], [0, 200], [50, 250], [100, 300]]) == True\n assert candidate(coordinates = [[-2, 2], [0, 0], [2, -2], [4, -4], [6, -6]]) == True\n assert candidate(coordinates = [[-1, -2], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8]]) == True\n assert candidate(coordinates = [[-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5]]) == True\n assert candidate(coordinates = [[5, 0], [5, 1], [5, 2], [5, 3], [5, 4]]) == True\n assert candidate(coordinates = [[0, -10], [0, -5], [0, 0], [0, 5], [0, 10], [0, 15]]) == True\n assert candidate(coordinates = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000]]) == True\n assert candidate(coordinates = [[0, 1], [1, 3], [2, 5], [3, 7], [4, 9]]) == True\n assert candidate(coordinates = [[-3, 7], [-2, 5], [-1, 3], [0, 1], [1, -1], [2, -3]]) == True\n assert candidate(coordinates = [[-1, -2], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8], [11, 10]]) == True\n assert candidate(coordinates = [[-5, -5], [0, -2.5], [5, 0], [10, 2.5], [15, 5]]) == True\n assert candidate(coordinates = [[-500, 500], [-250, 750], [0, 1000], [250, 1250], [500, 1500]]) == True\n assert candidate(coordinates = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == True\n assert candidate(coordinates = [[-10, 0], [-5, 0], [0, 0], [5, 0], [10, 0], [15, 0]]) == True\n assert candidate(coordinates = [[-2, -1], [0, 0], [2, 1], [4, 2], [6, 3], [8, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == True\n assert candidate(coordinates = [[-2, -3], [-1, -1], [0, 1], [1, 3], [2, 5], [3, 7]]) == True\n assert candidate(coordinates = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[-100, 200], [-200, 400], [-300, 600], [-400, 800], [-500, 1000]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30]]) == True\n assert candidate(coordinates = [[-5, -10], [-4, -8], [-3, -6], [-2, -4], [-1, -2], [0, 0]]) == True\n assert candidate(coordinates = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15], [20, 20]]) == True\n assert candidate(coordinates = [[-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100]]) == True\n assert candidate(coordinates = [[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0]]) == True\n assert candidate(coordinates = [[-100, -100], [-50, -50], [0, 0], [50, 50], [100, 100]]) == True\n assert candidate(coordinates = [[-5, 5], [0, 10], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35]]) == True\n assert candidate(coordinates = [[100, -200], [200, -400], [300, -600], [400, -800], [500, -1000]]) == True\n assert candidate(coordinates = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10]]) == True\n assert candidate(coordinates = [[100, 100], [200, 200], [300, 300], [400, 401], [500, 500]]) == False\n assert candidate(coordinates = [[-100, 100], [100, -100], [0, 0]]) == True\n assert candidate(coordinates = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15]]) == True\n assert candidate(coordinates = [[-3, 3], [-6, 6], [-9, 9], [-12, 12], [-15, 15]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]]) == False\n assert candidate(coordinates = [[-10, -20], [0, 0], [10, 20], [20, 40], [30, 60]]) == True\n assert candidate(coordinates = [[1, 1], [3, 5], [5, 9], [7, 13], [9, 17]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]) == True\n assert candidate(coordinates = [[-1, -5], [0, -2], [1, 1], [2, 4], [3, 7], [4, 10]]) == True\n assert candidate(coordinates = [[0, 1000], [1000, 1000], [2000, 1000], [3000, 1000], [4000, 1000]]) == True\n assert candidate(coordinates = [[-2, -3], [-1, -1], [0, 1], [1, 3], [2, 5]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64]]) == True\n assert candidate(coordinates = [[-100, -200], [-200, -400], [-300, -600], [-400, -800], [-500, -1000]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]]) == True\n assert candidate(coordinates = [[1, 2], [4, 6], [7, 10], [10, 14], [13, 18], [16, 22], [19, 26]]) == True\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == True\n assert candidate(coordinates = [[-3, -6], [1, -2], [5, 2], [7, 3]]) == False\n assert candidate(coordinates = [[-100, 0], [0, 0], [100, 0], [200, 0], [300, 0]]) == True\n assert candidate(coordinates = [[-1000, 2000], [0, 0], [1000, -2000]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30], [20, 40]]) == True\n assert candidate(coordinates = [[-10, 0], [0, 5], [10, 10], [20, 15], [30, 20], [40, 25], [50, 30], [60, 35]]) == True\n assert candidate(coordinates = [[-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]) == True\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]]) == True\n assert candidate(coordinates = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]) == True\n assert candidate(coordinates = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == True\n assert candidate(coordinates = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == True\n assert candidate(coordinates = [[0, 1], [1, 2], [2, 3], [3, 5], [4, 6], [5, 8]]) == False\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 15]]) == False\n assert candidate(coordinates = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80]]) == True\n assert candidate(coordinates = [[-1, -1], [1, 1], [3, 3], [5, 5], [7, 7], [9, 9]]) == True\n assert candidate(coordinates = [[-1000, 0], [-500, 0], [0, 0], [500, 0], [1000, 0]]) == True\n assert candidate(coordinates = [[-10000, 10000], [-5000, 10000], [0, 10000], [5000, 10000], [10000, 10000]]) == True\n assert candidate(coordinates = [[5, 3], [10, 6], [15, 9], [20, 12], [25, 15]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 3], [5, 5]]) == False\n assert candidate(coordinates = [[-2, 4], [-1, 2], [0, 0], [1, -2], [2, -4]]) == True\n assert candidate(coordinates = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == True\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]", "[[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]"], "hints": ["If there're only 2 points, return true.", "Check if all other points lie on the line defined by the first 2 points.", "Use cross product to check collinearity."], "metadata": {"canonical_parameter_names": ["coordinates"], "leetcode_dataset_entry_point": "Solution().checkStraightLine", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:03+00:00", "tests_total": 125, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def checkStraightLine(self, coordinates: list[list[int]]) -> bool:", "container": "Solution", "callable": "checkStraightLine", "parameters": [{"name": "coordinates", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1233, "task_id": "remove-sub-folders-from-the-filesystem", "difficulty": "Medium", "problem_description": "Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order.\n\nIf a folder[i] is located within another folder[j], it is called a sub-folder of it. A sub-folder of folder[j] must start with folder[j], followed by a \"/\". For example, \"/a/b\" is a sub-folder of \"/a\", but \"/b\" is not a sub-folder of \"/a/b/c\".\n\nThe format of a path is one or more concatenated strings of the form: '/' followed by one or more lowercase English letters.\n\n- For example, \"/leetcode\" and \"/leetcode/problems\" are valid paths while an empty string and \"/\" are not.\n\nExample 1:\n\nInput: folder = [\"/a\",\"/a/b\",\"/c/d\",\"/c/d/e\",\"/c/f\"]\nOutput: [\"/a\",\"/c/d\",\"/c/f\"]\nExplanation: Folders \"/a/b\" is a subfolder of \"/a\" and \"/c/d/e\" is inside of folder \"/c/d\" in our filesystem.\n\nExample 2:\n\nInput: folder = [\"/a\",\"/a/b/c\",\"/a/b/d\"]\nOutput: [\"/a\"]\nExplanation: Folders \"/a/b/c\" and \"/a/b/d\" will be removed because they are subfolders of \"/a\".\n\nExample 3:\n\nInput: folder = [\"/a/b/c\",\"/a/b/ca\",\"/a/b/d\"]\nOutput: [\"/a/b/c\",\"/a/b/ca\",\"/a/b/d\"]\n\nConstraints:\n\n- 1 <= folder.length <= 4 * 10^4\n- 2 <= folder[i].length <= 100\n- folder[i] contains only lowercase letters and '/'.\n- folder[i] always starts with the character '/'.\n- Each folder name is unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(folder=['/a', '/a/b', '/c/d', '/c/d/e', '/c/f']), ['/a', '/c/d', '/c/f'])\n assert answers_match(candidate(folder=['/a', '/a/b/c', '/a/b/d']), ['/a'])\n assert answers_match(candidate(folder=['/m', '/m/n/o', '/m/n', '/p/q', '/p/q/r/s', '/p/q/t']), ['/m', '/p/q'])\n assert answers_match(candidate(folder=['/one', '/one/two', '/three', '/three/four', '/three/four/five']), ['/one', '/three'])\n assert answers_match(candidate(folder=['/a/b/c', '/a/b/ca', '/a/b/d']), ['/a/b/c', '/a/b/ca', '/a/b/d'])\n assert answers_match(candidate(folder=['/x', '/x/y/z', '/x/y', '/z/a', '/z/a/b']), ['/x', '/z/a'])\n assert answers_match(candidate(folder=['/x', '/x/y', '/x/y/z', '/x/y/za', '/w']), ['/w', '/x'])\n assert answers_match(candidate(folder=['/a', '/a/b/c', '/a/b/d']), ['/a'])\n assert answers_match(candidate(folder=['/x', '/x/y/z', '/x/y', '/z', '/z/w']), ['/x', '/z'])\n assert answers_match(candidate(folder=['/x', '/x/y/z', '/x/y', '/w']), ['/w', '/x'])\n assert answers_match(candidate(folder=['/a/b/c', '/a/b/ca', '/a/b/d']), ['/a/b/c', '/a/b/ca', '/a/b/d'])\n assert answers_match(candidate(folder=['/one/two/three', '/one/two/three/four', '/one', '/two/three']), ['/one', '/two/three'])\n assert answers_match(candidate(folder=['/m/n', '/m/no', '/m/no/p', '/m/no/qr', '/m/ns']), ['/m/n', '/m/no', '/m/ns'])\n assert answers_match(candidate(folder=['/a', '/a/b', '/c/d', '/c/d/e', '/c/f']), ['/a', '/c/d', '/c/f'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/z/alpha', '/x/y/z/beta', '/x/y/z/gamma/delta', '/x/y/z/gamma/epsilon']), ['/x/y/z'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y', '/x/y/z/a', '/x/y/z/b/c', '/w/x/y/z', '/w/x/y']), ['/w/x/y', '/x/y'])\n assert answers_match(candidate(folder=['/root/user/documents', '/root/user/documents/reports', '/root/user/images', '/root/user/images/profile']), ['/root/user/documents', '/root/user/images'])\n assert answers_match(candidate(folder=['/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', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n', '/a/b/c/d/e/f/g/h/i/j/k/l/m', '/a/b/c/d/e/f/g/h/i/j/k/l', '/a/b/c/d/e/f/g/h/i/j/k', '/a/b/c/d/e/f/g/h/i/j', '/a/b/c/d/e/f/g/h/i', '/a/b/c/d/e/f/g/h', '/a/b/c/d/e/f/g', '/a/b/c/d/e/f', '/a/b/c/d/e', '/a/b/c/d', '/a/b/c', '/a/b', '/a']), ['/a'])\n assert answers_match(candidate(folder=['/library/books', '/library/books/fiction', '/library/books/fiction/scifi', '/library/books/fiction/scifi/fantasy', '/library/books/fiction/romance', '/library/books/nonfiction', '/library/books/nonfiction/biography', '/library/books/nonfiction/history']), ['/library/books'])\n assert answers_match(candidate(folder=['/m/n/o/p/q/r/s/t/u/v', '/m/n/o/p/q/r/s/t/u/v/w/x/y/z', '/m/n/o/p/q/r/s/t/u', '/m/n/o/p', '/m/n/o/p/q']), ['/m/n/o/p'])\n assert answers_match(candidate(folder=['/books/science', '/books/science/physics', '/books/science/chemistry', '/books/science/biology', '/books/history', '/books/history/europe', '/books/history/asia']), ['/books/history', '/books/science'])\n assert answers_match(candidate(folder=['/alpha/beta/gamma/delta/epsilon/phi/chi', '/alpha/beta/gamma/delta/epsilon/phi/chi/psi', '/alpha/beta/gamma/delta/epsilon/phi/chi/psi/omega', '/alpha/beta/gamma/delta/epsilon/phi/theta']), ['/alpha/beta/gamma/delta/epsilon/phi/chi', '/alpha/beta/gamma/delta/epsilon/phi/theta'])\n assert answers_match(candidate(folder=['/root/user/documents', '/root/user/documents/projects', '/root/user/downloads', '/root/user/downloads/archive', '/root/user/downloads/archive/old']), ['/root/user/documents', '/root/user/downloads'])\n assert answers_match(candidate(folder=['/deep/nested/folder/structure/here', '/deep/nested/folder/structure/here/is', '/deep/nested/folder/structure/here/is/a', '/deep/nested/folder/structure/here/is/a/test', '/deep/nested/folder/structure/here/is/a/test/file']), ['/deep/nested/folder/structure/here'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/z/w', '/x/y/z/w/x', '/x/y/z/w/x/y', '/x/y/z/w/x/y/z', '/x/y/z/w/x/y/z/a']), ['/x/y/z'])\n assert answers_match(candidate(folder=['/abc/def/ghi/jkl', '/abc/def/ghi/jkl/mno', '/abc/def/ghi/jkl/mno/pqr', '/abc/def/ghi/jkl/mno/pqr/stu', '/abc/def/ghi/jkl/mno/pqr/vwx', '/abc/def/ghi/jkl/mno/pqr/vwx/yz']), ['/abc/def/ghi/jkl'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/z/w', '/x/y/zx', '/x/y/z/xy']), ['/x/y/z', '/x/y/zx'])\n assert answers_match(candidate(folder=['/root/project/src/main/java/com/example', '/root/project/src', '/root/project/tests/unit', '/root/project']), ['/root/project'])\n assert answers_match(candidate(folder=['/alpha/beta/gamma/delta', '/alpha/beta/gamma/delta/epsilon', '/alpha/beta/gamma/delta/epsilon/zeta', '/alpha/beta/gamma/delta/eta', '/alpha/beta/gamma/delta/eta/theta', '/alpha/beta/gamma/delta/eta/theta/iota']), ['/alpha/beta/gamma/delta'])\n assert answers_match(candidate(folder=['/alpha/bravo/charlie/delta', '/alpha/bravo/charlie/delta/echo', '/alpha/bravo/charlie/delta/echo/foxtrot', '/alpha/bravo/charlie/delta/echo/foxtrot/golf']), ['/alpha/bravo/charlie/delta'])\n assert answers_match(candidate(folder=['/root/a/b/c/d/e/f/g/h/i', '/root/a/b/c/d/e/f/g', '/root/a/b/c/d/e', '/root/a/b/c']), ['/root/a/b/c'])\n assert answers_match(candidate(folder=['/one/two/three/four/five/six/seven', '/one/two/three/four/five/six/seven/eight', '/one/two/three/four/five/six/seven/eight/nine', '/one/two/three/four/five/six/seven/eight/ten']), ['/one/two/three/four/five/six/seven'])\n assert answers_match(candidate(folder=['/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', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w']), ['/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w'])\n assert answers_match(candidate(folder=['/a/b/c/d/e', '/a/b/c/d', '/a/b/c/d/f', '/a/b/c/d/f/g', '/a/b/c/d/f/h']), ['/a/b/c/d'])\n assert answers_match(candidate(folder=['/base/a', '/base/a/b', '/base/a/b/c', '/base/a/b/d', '/base/a/b/e/f', '/base/a/b/e/g', '/base/a/b/h/i/j/k', '/base/a/b/h/i/l', '/base/a/b/h/i/m/n/o/p']), ['/base/a'])\n assert answers_match(candidate(folder=['/zoo/animals/mammals/carnivores/lions', '/zoo/animals/mammals/carnivores/tigers', '/zoo/animals/mammals/herbivores/elephants', '/zoo/animals/mammals/herbivores/giraffes', '/zoo/animals/birds/flying/eagles', '/zoo/animals/birds/flying/penguins', '/zoo/animals/birds/nonflying/ostriches', '/zoo/animals/birds/nonflying/emus']), ['/zoo/animals/birds/flying/eagles', '/zoo/animals/birds/flying/penguins', '/zoo/animals/birds/nonflying/emus', '/zoo/animals/birds/nonflying/ostriches', '/zoo/animals/mammals/carnivores/lions', '/zoo/animals/mammals/carnivores/tigers', '/zoo/animals/mammals/herbivores/elephants', '/zoo/animals/mammals/herbivores/giraffes'])\n assert answers_match(candidate(folder=['/root/a', '/root/a/b', '/root/a/b/c', '/root/a/b/d', '/root/a/b/e/f', '/root/a/b/e/g', '/root/a/b/e', '/root/a/b/e/g/h']), ['/root/a'])\n assert answers_match(candidate(folder=['/a/b/c/d', '/a/b/c/d/e', '/a/b/c/d/f', '/a/b/c/d/g', '/a/b/c/d/h/i']), ['/a/b/c/d'])\n assert answers_match(candidate(folder=['/projects/alpha/beta/gamma/delta/epsilon/zeta', '/projects/alpha/beta/gamma/delta/epsilon/eta', '/projects/alpha/beta/gamma/delta', '/projects/alpha/beta/gamma', '/projects/alpha/beta']), ['/projects/alpha/beta'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y', '/x/y/z/w', '/x/y/v', '/x/y/z/v', '/x/y/v/w', '/x/u/v']), ['/x/u/v', '/x/y'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/za', '/x/ya', '/x/yb', '/x/yc/zc', '/x/yc/zb']), ['/x/y/z', '/x/y/za', '/x/ya', '/x/yb', '/x/yc/zb', '/x/yc/zc'])\n assert answers_match(candidate(folder=['/a/b/c/d', '/a/b/c', '/a/b', '/a', '/a/b/c/d/e', '/a/b/c/f', '/a/g', '/a/g/h', '/a/g/i/j', '/a/g/i/j/k']), ['/a'])\n assert answers_match(candidate(folder=['/projects/webapp/client', '/projects/webapp/client/src', '/projects/webapp/client/src/components', '/projects/webapp/server', '/projects/webapp/server/routes', '/projects/webapp/server/models']), ['/projects/webapp/client', '/projects/webapp/server'])\n assert answers_match(candidate(folder=['/project/src/main/java/com/example', '/project/src/main/java/com/example/model', '/project/src/main/java/com/example/service', '/project/src/test/java/com/example/service', '/project/src/test/resources', '/project/src/main/resources']), ['/project/src/main/java/com/example', '/project/src/main/resources', '/project/src/test/java/com/example/service', '/project/src/test/resources'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/za', '/x/y', '/x/y/z/zzz', '/x/y/z/zza']), ['/x/y'])\n assert answers_match(candidate(folder=['/code/base', '/code/base/core', '/code/base/core/utils', '/code/base/core/utils/a', '/code/base/core/utils/b', '/code/base/core/models', '/code/base/core/models/user', '/code/base/core/models/group']), ['/code/base'])\n assert answers_match(candidate(folder=['/a/b', '/a/b/c', '/a/b/c/d', '/a/b/c/d/e', '/a/b/c/d/e/f', '/a/b/c/d/e/f/g', '/a/b/c/d/e/f/g/h', '/a/b/c/d/e/f/g/h/i', '/a/b/c/d/e/f/g/h/i/j', '/a/b/c/d/e/f/g/h/i/j/k', '/a/b/c/d/e/f/g/h/i/j/k/l', '/a/b/c/d/e/f/g/h/i/j/k/l/m', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q']), ['/a/b'])\n assert answers_match(candidate(folder=['/m/n/o/p/q/r', '/m/n/o/p/q/r/s', '/m/n/o/p/q/r/s/t', '/m/n/o/p/q/r/u', '/m/n/o/p/v', '/m/n/o/p/v/w', '/m/n/o/p/v/w/x']), ['/m/n/o/p/q/r', '/m/n/o/p/v'])\n assert answers_match(candidate(folder=['/mnt/external/storage', '/mnt/external/storage/backup', '/mnt/external/storage/photos', '/mnt/external/storage/photos/vacation', '/mnt/external/storage/photos/wedding', '/mnt/external/storage/videos', '/mnt/external/storage/videos/home', '/mnt/external/storage/videos/travel']), ['/mnt/external/storage'])\n assert answers_match(candidate(folder=['/user/home', '/user/home/settings', '/user/home/settings/preferences', '/user/home/settings/notifications', '/user/home/documents', '/user/home/documents/work', '/user/home/documents/personal']), ['/user/home'])\n assert answers_match(candidate(folder=['/p/q/r', '/p/q/r/s', '/p/q/r/s/t', '/p/q/r/s/u', '/p/q/v', '/p/q/v/w', '/p/q/v/w/x', '/p/q/v/w/y']), ['/p/q/r', '/p/q/v'])\n assert answers_match(candidate(folder=['/project/src', '/project/src/components', '/project/src/components/button', '/project/src/components/input', '/project/src/utils', '/project/src/utils/helpers', '/project/src/utils/api', '/project/src/assets', '/project/src/assets/images', '/project/src/assets/fonts', '/project/src/assets/icons']), ['/project/src'])\n assert answers_match(candidate(folder=['/a/b/c/d/e/f', '/a/b/c/d', '/a/b/c', '/a/b', '/a', '/z/y/x', '/z/y', '/z']), ['/a', '/z'])\n", "comparison": "unordered"}, "public_tests": ["[\"/a\",\"/a/b\",\"/c/d\",\"/c/d/e\",\"/c/f\"]", "[\"/a\",\"/a/b/c\",\"/a/b/d\"]", "[\"/a/b/c\",\"/a/b/ca\",\"/a/b/d\"]"], "hints": ["Sort the folders lexicographically.", "Insert the current element in an array and then loop until we get rid of all of their subfolders, repeat this until no element is left."], "metadata": {"canonical_parameter_names": ["folder"], "leetcode_dataset_entry_point": "Solution().removeSubfolders", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:06+00:00", "tests_total": 97, "tests_dropped": 44, "flags": ["any_order"], "topic_tags": ["array", "string", "depth-first-search", "trie"]}, "language": "python", "interface": {"raw_signature": "def removeSubfolders(self, folder: list[str]) -> list[str]:", "container": "Solution", "callable": "removeSubfolders", "parameters": [{"name": "folder", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1234, "task_id": "replace-the-substring-for-balanced-string", "difficulty": "Medium", "problem_description": "You are given a string s of length n containing only four kinds of characters: 'Q', 'W', 'E', and 'R'.\n\nA string is said to be balanced if each of its characters appears n / 4 times where n is the length of the string.\n\nReturn the minimum length of the substring that can be replaced with any other string of the same length to make s balanced. If s is already balanced, return 0.\n\nExample 1:\n\nInput: s = \"QWER\"\nOutput: 0\nExplanation: s is already balanced.\n\nExample 2:\n\nInput: s = \"QQWE\"\nOutput: 1\nExplanation: We need to replace a 'Q' to 'R', so that \"RQWE\" (or \"QRWE\") is balanced.\n\nExample 3:\n\nInput: s = \"QQQW\"\nOutput: 2\nExplanation: We can replace the first \"QQ\" to \"ER\".\n\nConstraints:\n\n- n == s.length\n- 4 <= n <= 10^5\n- n is a multiple of 4.\n- s contains only 'Q', 'W', 'E', and 'R'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"QQQQQQQQWWWWEEEEEEEERRRRRRRR\") == 14\n assert candidate(s = \"QQQQWWER\") == 2\n assert candidate(s = \"QQQQWWWWEEEERRRR\") == 0\n assert candidate(s = \"QQWWRRER\") == 1\n assert candidate(s = \"QQQQWWWEERRR\") == 1\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEERRRRRRRR\") == 0\n assert candidate(s = \"QQQWEEERRRQQQWEEERRR\") == 5\n assert candidate(s = \"QWERQWERQWERQWER\") == 0\n assert candidate(s = \"QQQWEEEERRRQ\") == 3\n assert candidate(s = \"QQWE\") == 1\n assert candidate(s = \"QQQW\") == 2\n assert candidate(s = \"QWER\") == 0\n assert candidate(s = \"QQQQEEEERRRR\") == 6\n assert candidate(s = \"WQWRQQQW\") == 3\n assert candidate(s = \"QQQQWEEEWWRR\") == 1\n assert candidate(s = \"QWQWQWQW\") == 4\n assert candidate(s = \"QQQQEEEEWWWWRRRR\") == 0\n assert candidate(s = \"QQQQWEEEERRR\") == 3\n assert candidate(s = \"QQQQWWEERRRRQQQQ\") == 4\n assert candidate(s = \"QQQWEEEERRRR\") == 2\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 42\n assert candidate(s = \"QQWWEERRQQWWEERRQQWWEERR\") == 0\n assert candidate(s = \"QQQQQWEEEEERRRRR\") == 8\n assert candidate(s = \"WWWWWWWWQQQQEEEERRRR\") == 3\n assert candidate(s = \"QWQWQWQWQWQWQWQWQWQWQWQWQWQWQWQW\") == 16\n assert candidate(s = \"EEEEWWRRQQQQEEEEWWRRQQQQ\") == 4\n assert candidate(s = \"QQQQWWWWEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRR\") == 14\n assert candidate(s = \"EEEEEEEEWWWWWWWWRRRRRRRRQQQQQQQQ\") == 0\n assert candidate(s = \"QWQWQWQWQWQWQWQW\") == 8\n assert candidate(s = \"QQQQQQQQWWWWWWWWWEEEEEEEEEEEEEEEEERRRRRRRRRRRRRR\") == 7\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEERRRRRRRRRRRRRRRRRRRR\") == 9\n assert candidate(s = \"QQQWWWWWWWWEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRR\") == 11\n assert candidate(s = \"WQQQWEWQERWREWER\") == 1\n assert candidate(s = \"QWQWQWQWQQQQQQQQEEEEWWRRQQQQ\") == 10\n assert candidate(s = \"QQQQQQQQWEEEEEEEEEERRRRRRRRR\") == 14\n assert candidate(s = \"QQQQQQWWEEEERRRR\") == 2\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 102\n assert candidate(s = \"QQQQWWEEREEE\") == 5\n assert candidate(s = \"QQWWEERRQQWWEERR\") == 0\n assert candidate(s = \"QQQQWWWWEEEERRRRQQQQWWWWEEEE\") == 6\n assert candidate(s = \"QQQWEEEERRRRQQQWEEEERRRR\") == 4\n assert candidate(s = \"QQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERR\") == 16\n assert candidate(s = \"QQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRR\") == 24\n assert candidate(s = \"QQQQQQQQEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRR\") == 14\n assert candidate(s = \"WQQQWQQQWQQQWQQQEEEEWWRRQQQQ\") == 11\n assert candidate(s = \"QQQWEEEEWWRRQQQQEEEEWWRR\") == 3\n assert candidate(s = \"QWQWQWQWQWQWQQQQWWRRQQQQ\") == 12\n assert candidate(s = \"QQQQQQWWWWWWEEEEEEEEEERRRRRRRRRRRRRR\") == 6\n assert candidate(s = \"QWQQQQQQQQQWEWEWEWRR\") == 5\n assert candidate(s = \"QQQWWEERQQRRQWRE\") == 2\n assert candidate(s = \"QQQQEEEEWWRR\") == 2\n assert candidate(s = \"QQQQQQQQQQQQQQQQEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 30\n assert candidate(s = \"QQQQQQQQQQQQQQQQEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 28\n assert candidate(s = \"QQQQWWEERRRRQQQQWWEERRRR\") == 4\n assert candidate(s = \"QQQQWWEERRRRQQQQWWEERRRRQQQQWWEERRRR\") == 6\n assert candidate(s = \"QQQQWEEEEEERRRRR\") == 3\n assert candidate(s = \"QQQQQQQQWWWWWWWWWWWWWWWWWWEEEEEERRRR\") == 9\n assert candidate(s = \"QQQWEEEEEERRRRQQ\") == 4\n assert candidate(s = \"RRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEE\") == 0\n assert candidate(s = \"QQWWEERRRRWWWWRRRRQQQWEEERRRRWWWWRRRRQQQWEEERRRRWWWWRRRR\") == 21\n assert candidate(s = \"QQWWEERRRRWWWWRRRRWWWWRRRRWWWWRRRRQQWWEERRRRWWWWRRRR\") == 19\n assert candidate(s = \"WWWWQQQQEEEERRRRWWWWQQQQEEEERRRR\") == 0\n assert candidate(s = \"QQQQQQQQWWEERRRR\") == 4\n", "comparison": "exact"}, "public_tests": ["\"QWER\"", "\"QQWE\"", "\"QQQW\""], "hints": ["Use 2-pointers algorithm to make sure all amount of characters outside the 2 pointers are smaller or equal to n/4.", "That means you need to count the amount of each letter and make sure the amount is enough."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().balancedString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:08+00:00", "tests_total": 158, "tests_dropped": 95, "flags": [], "topic_tags": ["string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def balancedString(self, s: str) -> int:", "container": "Solution", "callable": "balancedString", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1235, "task_id": "maximum-profit-in-job-scheduling", "difficulty": "Hard", "problem_description": "We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].\n\nYou're given the startTime, endTime and profit arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range.\n\nIf you choose a job that ends at time X you will be able to start another job that starts at time X.\n\nExample 1:\n\nInput: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]\nOutput: 120\nExplanation: The subset chosen is the first and fourth job.\nTime range [1-3]+[3-6] , we get profit of 120 = 50 + 70.\n\nExample 2:\n\nInput: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]\nOutput: 150\nExplanation: The subset chosen is the first, fourth and fifth job.\nProfit obtained 150 = 20 + 70 + 60.\n\nExample 3:\n\nInput: startTime = [1,1,1], endTime = [2,3,4], profit = [5,6,4]\nOutput: 6\n\nConstraints:\n\n- 1 <= startTime.length == endTime.length == profit.length <= 5 * 10^4\n- 1 <= startTime[i] < endTime[i] <= 10^9\n- 1 <= profit[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startTime = [1, 10, 4, 3, 8, 9],endTime = [2, 11, 5, 7, 9, 10],profit = [3, 1, 5, 6, 4, 3]) == 17\n assert candidate(startTime = [1, 3, 5, 6, 7],endTime = [3, 5, 9, 8, 9],profit = [50, 20, 60, 40, 30]) == 130\n assert candidate(startTime = [1, 10, 100, 1000],endTime = [2, 20, 200, 2000],profit = [5, 50, 500, 5000]) == 5555\n assert candidate(startTime = [1, 3, 6, 8],endTime = [2, 5, 10, 12],profit = [50, 20, 100, 80]) == 170\n assert candidate(startTime = [3, 1, 1, 2],endTime = [4, 2, 4, 3],profit = [50, 10, 40, 70]) == 130\n assert candidate(startTime = [3, 5, 10],endTime = [15, 18, 19],profit = [20, 20, 100]) == 100\n assert candidate(startTime = [1],endTime = [2],profit = [5]) == 5\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(startTime = [1, 3, 6, 8, 12, 14],endTime = [4, 5, 10, 11, 14, 15],profit = [5, 6, 8, 3, 10, 4]) == 28\n assert candidate(startTime = [1, 2, 3, 4, 5, 6],endTime = [2, 3, 4, 5, 6, 7],profit = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(startTime = [1, 1, 1],endTime = [2, 3, 4],profit = [5, 6, 4]) == 6\n assert candidate(startTime = [1, 2, 3, 3],endTime = [3, 4, 5, 6],profit = [50, 10, 40, 70]) == 120\n assert candidate(startTime = [1, 2, 3, 4, 6],endTime = [3, 5, 10, 6, 9],profit = [20, 20, 100, 70, 60]) == 150\n assert candidate(startTime = [5, 8, 4, 1, 1],endTime = [6, 10, 7, 8, 2],profit = [100, 500, 100, 200, 300]) == 900\n assert candidate(startTime = [1, 3, 6, 8],endTime = [5, 7, 10, 12],profit = [50, 20, 100, 200]) == 250\n assert candidate(startTime = [2, 5, 8, 11],endTime = [5, 7, 10, 14],profit = [20, 30, 40, 50]) == 140\n assert candidate(startTime = [5, 10, 15, 20, 25],endTime = [10, 15, 20, 25, 30],profit = [100, 150, 200, 250, 300]) == 1000\n assert candidate(startTime = [100, 200, 300],endTime = [200, 300, 400],profit = [1000, 2000, 3000]) == 6000\n assert candidate(startTime = [1, 2, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37],endTime = [5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34, 37, 38, 41, 42],profit = [100, 200, 150, 300, 100, 500, 400, 300, 600, 700, 800, 600, 400, 300, 200, 100, 900, 800, 700, 600]) == 3400\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1000\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [2, 3, 4, 5, 6, 7],profit = [100, 200, 300, 400, 500, 600]) == 600\n assert candidate(startTime = [1, 2, 3, 5, 6, 8, 10, 12, 14, 16],endTime = [5, 4, 6, 9, 8, 11, 13, 15, 17, 19],profit = [5, 3, 7, 9, 8, 6, 4, 2, 1, 10]) == 33\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 325\n assert candidate(startTime = [1, 1, 2, 2, 3, 4, 5, 5, 6, 7],endTime = [3, 4, 4, 5, 6, 7, 7, 8, 9, 10],profit = [50, 40, 30, 20, 60, 10, 20, 100, 5, 45]) == 155\n assert candidate(startTime = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],endTime = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 2100\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(startTime = [1, 5, 8, 11, 13, 16, 19, 22, 25, 28],endTime = [4, 9, 12, 15, 17, 20, 23, 26, 29, 32],profit = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 370\n assert candidate(startTime = [3, 7, 10, 12, 13, 14, 15, 16, 18, 20],endTime = [5, 8, 13, 14, 15, 17, 20, 21, 22, 23],profit = [5, 8, 13, 14, 15, 17, 20, 21, 22, 23]) == 84\n assert candidate(startTime = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],endTime = [5, 14, 24, 34, 44, 54, 64, 74, 84, 94, 104, 114, 124, 134, 144],profit = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 1800\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],profit = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1000\n assert candidate(startTime = [1, 2, 3, 5, 8, 11, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],endTime = [4, 6, 9, 13, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 6900\n assert candidate(startTime = [1, 5, 10, 15, 20, 25, 30],endTime = [4, 9, 14, 19, 24, 29, 34],profit = [100, 200, 300, 400, 500, 600, 700]) == 2800\n assert candidate(startTime = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],endTime = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 360\n assert candidate(startTime = [1, 3, 6, 8, 12, 15, 18, 20, 25, 30],endTime = [5, 7, 10, 14, 16, 19, 22, 24, 30, 35],profit = [50, 20, 70, 10, 120, 30, 50, 25, 80, 60]) == 430\n assert candidate(startTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],endTime = [2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8],profit = [10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 25, 25, 25, 25]) == 70\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 3000\n assert candidate(startTime = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16],endTime = [2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 19, 21, 22, 23, 24],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 42\n assert candidate(startTime = [3, 5, 8, 10, 11, 12, 15, 18, 20, 22],endTime = [4, 9, 11, 13, 14, 17, 19, 23, 24, 25],profit = [20, 30, 5, 10, 50, 40, 70, 60, 10, 20]) == 190\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],endTime = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],profit = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 720\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],profit = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10]) == 600\n assert candidate(startTime = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],endTime = [6, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48],profit = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220]) == 730\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(startTime = [1, 3, 6, 8, 10, 13, 16, 18, 20, 23],endTime = [4, 7, 10, 12, 14, 17, 20, 22, 24, 27],profit = [500, 400, 300, 200, 100, 50, 75, 125, 175, 225]) == 1250\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 260\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],profit = [20, 15, 10, 5, 40, 35, 30, 25, 20, 15, 10, 5, 40, 35, 30]) == 335\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 1360\n assert candidate(startTime = [1, 2, 5, 6, 8, 12, 15, 18, 20, 25],endTime = [5, 5, 10, 10, 13, 17, 20, 22, 28, 30],profit = [50, 20, 70, 10, 30, 60, 5, 40, 90, 25]) == 270\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [5, 4, 8, 10, 9, 11, 13, 14, 16, 17, 18, 19, 20, 21, 22],profit = [100, 200, 150, 300, 250, 200, 400, 350, 300, 250, 200, 150, 100, 50, 100]) == 750\n assert candidate(startTime = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],endTime = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800],profit = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(startTime = [1, 5, 8, 10, 13, 16, 18, 20, 22, 25, 27, 29],endTime = [4, 9, 11, 12, 15, 17, 19, 21, 24, 26, 28, 30],profit = [100, 150, 100, 50, 200, 100, 150, 50, 100, 200, 50, 150]) == 1300\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 8, 6, 10, 12, 14, 18, 20, 22, 24],profit = [10, 30, 20, 40, 50, 70, 60, 80, 90, 100]) == 250\n assert candidate(startTime = [1, 3, 4, 5, 6, 8, 9],endTime = [2, 5, 7, 7, 9, 10, 11],profit = [10, 20, 40, 10, 30, 50, 20]) == 100\n assert candidate(startTime = [3, 5, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81],endTime = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],profit = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 3200\n assert candidate(startTime = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16],endTime = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],profit = [20, 25, 20, 30, 35, 40, 35, 45, 50, 55, 50, 60, 65, 70, 65, 75, 80, 85, 90, 95]) == 275\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 100\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],profit = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 250\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, 23],profit = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 110\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 50\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],profit = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 3850\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 100\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(startTime = [1, 5, 7, 8, 9, 10, 12, 15, 16, 19],endTime = [5, 8, 9, 10, 12, 15, 16, 20, 21, 25],profit = [100, 80, 40, 60, 70, 50, 30, 90, 20, 150]) == 440\n assert candidate(startTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],endTime = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1010\n assert candidate(startTime = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],profit = [20, 40, 30, 60, 50, 80, 70, 100, 90, 120, 110, 140, 130, 160, 150, 180, 170, 200, 190, 220, 210, 240, 230]) == 750\n assert candidate(startTime = [1, 2, 2, 4, 6, 7, 9, 10],endTime = [3, 3, 5, 8, 7, 10, 12, 15],profit = [50, 20, 30, 40, 60, 70, 80, 90]) == 270\n assert candidate(startTime = [3, 12, 8, 4, 9, 15, 18, 20, 25, 30],endTime = [7, 16, 13, 5, 11, 20, 22, 23, 32, 31],profit = [100, 150, 90, 60, 120, 200, 80, 40, 180, 160]) == 640\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],profit = [1, 2, 3, 4, 5, 6, 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(startTime = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18],endTime = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 300\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [500, 300, 700, 100, 400, 800, 200, 600, 900, 1000]) == 5500\n assert candidate(startTime = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],profit = [10, 50, 20, 60, 30, 70, 40, 80, 50, 90, 60]) == 560\n assert candidate(startTime = [1, 2, 3, 5, 8, 13, 21],endTime = [5, 4, 6, 8, 10, 15, 25],profit = [20, 20, 10, 40, 20, 30, 50]) == 160\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],profit = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 6050\n assert candidate(startTime = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],endTime = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(startTime = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],endTime = [2, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 21000\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(startTime = [3, 15, 5, 10, 20, 25],endTime = [10, 20, 10, 15, 25, 30],profit = [50, 70, 30, 60, 100, 40]) == 320\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 100\n assert candidate(startTime = [1, 2, 3, 5, 7, 9, 10, 12, 15, 18, 20],endTime = [5, 6, 8, 10, 12, 14, 17, 20, 22, 25, 27],profit = [100, 50, 70, 60, 80, 90, 120, 150, 200, 180, 220]) == 550\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],profit = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 2750\n assert candidate(startTime = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],endTime = [9, 14, 19, 24, 29, 34, 39, 44, 49, 54],profit = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550]) == 3250\n", "comparison": "exact"}, "public_tests": ["[1,2,3,3]\n[3,4,5,6]\n[50,10,40,70]", "[1,2,3,4,6]\n[3,5,10,6,9]\n[20,20,100,70,60]", "[1,1,1]\n[2,3,4]\n[5,6,4]"], "hints": ["Think on DP.", "Sort the elements by starting time, then define the dp[i] as the maximum profit taking elements from the suffix starting at i.", "Use binarySearch (lower_bound/upper_bound on C++) to get the next index for the DP transition."], "metadata": {"canonical_parameter_names": ["startTime", "endTime", "profit"], "leetcode_dataset_entry_point": "Solution().jobScheduling", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:10+00:00", "tests_total": 92, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def jobScheduling(self, startTime: list[int], endTime: list[int], profit: list[int]) -> int:", "container": "Solution", "callable": "jobScheduling", "parameters": [{"name": "startTime", "type": "list[int]"}, {"name": "endTime", "type": "list[int]"}, {"name": "profit", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1238, "task_id": "circular-permutation-in-binary-representation", "difficulty": "Medium", "problem_description": "Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that :\n\n- p[0] = start\n- p[i] and p[i+1] differ by only one bit in their binary representation.\n- p[0] and p[2^n -1] must also differ by only one bit in their binary representation.\n\nExample 1:\n\nInput: n = 2, start = 3\nOutput: [3,2,0,1]\nExplanation: The binary representation of the permutation is (11,10,00,01).\nAll the adjacent element differ by one bit. Another valid permutation is [3,1,0,2]\n\nExample 2:\n\nInput: n = 3, start = 2\nOutput: [2,6,7,5,4,0,1,3]\nExplanation: The binary representation of the permutation is (010,110,111,101,100,000,001,011).\n\nConstraints:\n\n- 1 <= n <= 16\n- 0 <= start < 2 ^ n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,start = 0) == [0, 1]\n assert candidate(n = 12,start = 2048) == [2048, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046, 2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024, 3072, 3073, 3075, 3074, 3078, 3079, 3077, 3076, 3084, 3085, 3087, 3086, 3082, 3083, 3081, 3080, 3096, 3097, 3099, 3098, 3102, 3103, 3101, 3100, 3092, 3093, 3095, 3094, 3090, 3091, 3089, 3088, 3120, 3121, 3123, 3122, 3126, 3127, 3125, 3124, 3132, 3133, 3135, 3134, 3130, 3131, 3129, 3128, 3112, 3113, 3115, 3114, 3118, 3119, 3117, 3116, 3108, 3109, 3111, 3110, 3106, 3107, 3105, 3104, 3168, 3169, 3171, 3170, 3174, 3175, 3173, 3172, 3180, 3181, 3183, 3182, 3178, 3179, 3177, 3176, 3192, 3193, 3195, 3194, 3198, 3199, 3197, 3196, 3188, 3189, 3191, 3190, 3186, 3187, 3185, 3184, 3152, 3153, 3155, 3154, 3158, 3159, 3157, 3156, 3164, 3165, 3167, 3166, 3162, 3163, 3161, 3160, 3144, 3145, 3147, 3146, 3150, 3151, 3149, 3148, 3140, 3141, 3143, 3142, 3138, 3139, 3137, 3136, 3264, 3265, 3267, 3266, 3270, 3271, 3269, 3268, 3276, 3277, 3279, 3278, 3274, 3275, 3273, 3272, 3288, 3289, 3291, 3290, 3294, 3295, 3293, 3292, 3284, 3285, 3287, 3286, 3282, 3283, 3281, 3280, 3312, 3313, 3315, 3314, 3318, 3319, 3317, 3316, 3324, 3325, 3327, 3326, 3322, 3323, 3321, 3320, 3304, 3305, 3307, 3306, 3310, 3311, 3309, 3308, 3300, 3301, 3303, 3302, 3298, 3299, 3297, 3296, 3232, 3233, 3235, 3234, 3238, 3239, 3237, 3236, 3244, 3245, 3247, 3246, 3242, 3243, 3241, 3240, 3256, 3257, 3259, 3258, 3262, 3263, 3261, 3260, 3252, 3253, 3255, 3254, 3250, 3251, 3249, 3248, 3216, 3217, 3219, 3218, 3222, 3223, 3221, 3220, 3228, 3229, 3231, 3230, 3226, 3227, 3225, 3224, 3208, 3209, 3211, 3210, 3214, 3215, 3213, 3212, 3204, 3205, 3207, 3206, 3202, 3203, 3201, 3200, 3456, 3457, 3459, 3458, 3462, 3463, 3461, 3460, 3468, 3469, 3471, 3470, 3466, 3467, 3465, 3464, 3480, 3481, 3483, 3482, 3486, 3487, 3485, 3484, 3476, 3477, 3479, 3478, 3474, 3475, 3473, 3472, 3504, 3505, 3507, 3506, 3510, 3511, 3509, 3508, 3516, 3517, 3519, 3518, 3514, 3515, 3513, 3512, 3496, 3497, 3499, 3498, 3502, 3503, 3501, 3500, 3492, 3493, 3495, 3494, 3490, 3491, 3489, 3488, 3552, 3553, 3555, 3554, 3558, 3559, 3557, 3556, 3564, 3565, 3567, 3566, 3562, 3563, 3561, 3560, 3576, 3577, 3579, 3578, 3582, 3583, 3581, 3580, 3572, 3573, 3575, 3574, 3570, 3571, 3569, 3568, 3536, 3537, 3539, 3538, 3542, 3543, 3541, 3540, 3548, 3549, 3551, 3550, 3546, 3547, 3545, 3544, 3528, 3529, 3531, 3530, 3534, 3535, 3533, 3532, 3524, 3525, 3527, 3526, 3522, 3523, 3521, 3520, 3392, 3393, 3395, 3394, 3398, 3399, 3397, 3396, 3404, 3405, 3407, 3406, 3402, 3403, 3401, 3400, 3416, 3417, 3419, 3418, 3422, 3423, 3421, 3420, 3412, 3413, 3415, 3414, 3410, 3411, 3409, 3408, 3440, 3441, 3443, 3442, 3446, 3447, 3445, 3444, 3452, 3453, 3455, 3454, 3450, 3451, 3449, 3448, 3432, 3433, 3435, 3434, 3438, 3439, 3437, 3436, 3428, 3429, 3431, 3430, 3426, 3427, 3425, 3424, 3360, 3361, 3363, 3362, 3366, 3367, 3365, 3364, 3372, 3373, 3375, 3374, 3370, 3371, 3369, 3368, 3384, 3385, 3387, 3386, 3390, 3391, 3389, 3388, 3380, 3381, 3383, 3382, 3378, 3379, 3377, 3376, 3344, 3345, 3347, 3346, 3350, 3351, 3349, 3348, 3356, 3357, 3359, 3358, 3354, 3355, 3353, 3352, 3336, 3337, 3339, 3338, 3342, 3343, 3341, 3340, 3332, 3333, 3335, 3334, 3330, 3331, 3329, 3328, 3840, 3841, 3843, 3842, 3846, 3847, 3845, 3844, 3852, 3853, 3855, 3854, 3850, 3851, 3849, 3848, 3864, 3865, 3867, 3866, 3870, 3871, 3869, 3868, 3860, 3861, 3863, 3862, 3858, 3859, 3857, 3856, 3888, 3889, 3891, 3890, 3894, 3895, 3893, 3892, 3900, 3901, 3903, 3902, 3898, 3899, 3897, 3896, 3880, 3881, 3883, 3882, 3886, 3887, 3885, 3884, 3876, 3877, 3879, 3878, 3874, 3875, 3873, 3872, 3936, 3937, 3939, 3938, 3942, 3943, 3941, 3940, 3948, 3949, 3951, 3950, 3946, 3947, 3945, 3944, 3960, 3961, 3963, 3962, 3966, 3967, 3965, 3964, 3956, 3957, 3959, 3958, 3954, 3955, 3953, 3952, 3920, 3921, 3923, 3922, 3926, 3927, 3925, 3924, 3932, 3933, 3935, 3934, 3930, 3931, 3929, 3928, 3912, 3913, 3915, 3914, 3918, 3919, 3917, 3916, 3908, 3909, 3911, 3910, 3906, 3907, 3905, 3904, 4032, 4033, 4035, 4034, 4038, 4039, 4037, 4036, 4044, 4045, 4047, 4046, 4042, 4043, 4041, 4040, 4056, 4057, 4059, 4058, 4062, 4063, 4061, 4060, 4052, 4053, 4055, 4054, 4050, 4051, 4049, 4048, 4080, 4081, 4083, 4082, 4086, 4087, 4085, 4084, 4092, 4093, 4095, 4094, 4090, 4091, 4089, 4088, 4072, 4073, 4075, 4074, 4078, 4079, 4077, 4076, 4068, 4069, 4071, 4070, 4066, 4067, 4065, 4064, 4000, 4001, 4003, 4002, 4006, 4007, 4005, 4004, 4012, 4013, 4015, 4014, 4010, 4011, 4009, 4008, 4024, 4025, 4027, 4026, 4030, 4031, 4029, 4028, 4020, 4021, 4023, 4022, 4018, 4019, 4017, 4016, 3984, 3985, 3987, 3986, 3990, 3991, 3989, 3988, 3996, 3997, 3999, 3998, 3994, 3995, 3993, 3992, 3976, 3977, 3979, 3978, 3982, 3983, 3981, 3980, 3972, 3973, 3975, 3974, 3970, 3971, 3969, 3968, 3712, 3713, 3715, 3714, 3718, 3719, 3717, 3716, 3724, 3725, 3727, 3726, 3722, 3723, 3721, 3720, 3736, 3737, 3739, 3738, 3742, 3743, 3741, 3740, 3732, 3733, 3735, 3734, 3730, 3731, 3729, 3728, 3760, 3761, 3763, 3762, 3766, 3767, 3765, 3764, 3772, 3773, 3775, 3774, 3770, 3771, 3769, 3768, 3752, 3753, 3755, 3754, 3758, 3759, 3757, 3756, 3748, 3749, 3751, 3750, 3746, 3747, 3745, 3744, 3808, 3809, 3811, 3810, 3814, 3815, 3813, 3812, 3820, 3821, 3823, 3822, 3818, 3819, 3817, 3816, 3832, 3833, 3835, 3834, 3838, 3839, 3837, 3836, 3828, 3829, 3831, 3830, 3826, 3827, 3825, 3824, 3792, 3793, 3795, 3794, 3798, 3799, 3797, 3796, 3804, 3805, 3807, 3806, 3802, 3803, 3801, 3800, 3784, 3785, 3787, 3786, 3790, 3791, 3789, 3788, 3780, 3781, 3783, 3782, 3778, 3779, 3777, 3776, 3648, 3649, 3651, 3650, 3654, 3655, 3653, 3652, 3660, 3661, 3663, 3662, 3658, 3659, 3657, 3656, 3672, 3673, 3675, 3674, 3678, 3679, 3677, 3676, 3668, 3669, 3671, 3670, 3666, 3667, 3665, 3664, 3696, 3697, 3699, 3698, 3702, 3703, 3701, 3700, 3708, 3709, 3711, 3710, 3706, 3707, 3705, 3704, 3688, 3689, 3691, 3690, 3694, 3695, 3693, 3692, 3684, 3685, 3687, 3686, 3682, 3683, 3681, 3680, 3616, 3617, 3619, 3618, 3622, 3623, 3621, 3620, 3628, 3629, 3631, 3630, 3626, 3627, 3625, 3624, 3640, 3641, 3643, 3642, 3646, 3647, 3645, 3644, 3636, 3637, 3639, 3638, 3634, 3635, 3633, 3632, 3600, 3601, 3603, 3602, 3606, 3607, 3605, 3604, 3612, 3613, 3615, 3614, 3610, 3611, 3609, 3608, 3592, 3593, 3595, 3594, 3598, 3599, 3597, 3596, 3588, 3589, 3591, 3590, 3586, 3587, 3585, 3584, 2560, 2561, 2563, 2562, 2566, 2567, 2565, 2564, 2572, 2573, 2575, 2574, 2570, 2571, 2569, 2568, 2584, 2585, 2587, 2586, 2590, 2591, 2589, 2588, 2580, 2581, 2583, 2582, 2578, 2579, 2577, 2576, 2608, 2609, 2611, 2610, 2614, 2615, 2613, 2612, 2620, 2621, 2623, 2622, 2618, 2619, 2617, 2616, 2600, 2601, 2603, 2602, 2606, 2607, 2605, 2604, 2596, 2597, 2599, 2598, 2594, 2595, 2593, 2592, 2656, 2657, 2659, 2658, 2662, 2663, 2661, 2660, 2668, 2669, 2671, 2670, 2666, 2667, 2665, 2664, 2680, 2681, 2683, 2682, 2686, 2687, 2685, 2684, 2676, 2677, 2679, 2678, 2674, 2675, 2673, 2672, 2640, 2641, 2643, 2642, 2646, 2647, 2645, 2644, 2652, 2653, 2655, 2654, 2650, 2651, 2649, 2648, 2632, 2633, 2635, 2634, 2638, 2639, 2637, 2636, 2628, 2629, 2631, 2630, 2626, 2627, 2625, 2624, 2752, 2753, 2755, 2754, 2758, 2759, 2757, 2756, 2764, 2765, 2767, 2766, 2762, 2763, 2761, 2760, 2776, 2777, 2779, 2778, 2782, 2783, 2781, 2780, 2772, 2773, 2775, 2774, 2770, 2771, 2769, 2768, 2800, 2801, 2803, 2802, 2806, 2807, 2805, 2804, 2812, 2813, 2815, 2814, 2810, 2811, 2809, 2808, 2792, 2793, 2795, 2794, 2798, 2799, 2797, 2796, 2788, 2789, 2791, 2790, 2786, 2787, 2785, 2784, 2720, 2721, 2723, 2722, 2726, 2727, 2725, 2724, 2732, 2733, 2735, 2734, 2730, 2731, 2729, 2728, 2744, 2745, 2747, 2746, 2750, 2751, 2749, 2748, 2740, 2741, 2743, 2742, 2738, 2739, 2737, 2736, 2704, 2705, 2707, 2706, 2710, 2711, 2709, 2708, 2716, 2717, 2719, 2718, 2714, 2715, 2713, 2712, 2696, 2697, 2699, 2698, 2702, 2703, 2701, 2700, 2692, 2693, 2695, 2694, 2690, 2691, 2689, 2688, 2944, 2945, 2947, 2946, 2950, 2951, 2949, 2948, 2956, 2957, 2959, 2958, 2954, 2955, 2953, 2952, 2968, 2969, 2971, 2970, 2974, 2975, 2973, 2972, 2964, 2965, 2967, 2966, 2962, 2963, 2961, 2960, 2992, 2993, 2995, 2994, 2998, 2999, 2997, 2996, 3004, 3005, 3007, 3006, 3002, 3003, 3001, 3000, 2984, 2985, 2987, 2986, 2990, 2991, 2989, 2988, 2980, 2981, 2983, 2982, 2978, 2979, 2977, 2976, 3040, 3041, 3043, 3042, 3046, 3047, 3045, 3044, 3052, 3053, 3055, 3054, 3050, 3051, 3049, 3048, 3064, 3065, 3067, 3066, 3070, 3071, 3069, 3068, 3060, 3061, 3063, 3062, 3058, 3059, 3057, 3056, 3024, 3025, 3027, 3026, 3030, 3031, 3029, 3028, 3036, 3037, 3039, 3038, 3034, 3035, 3033, 3032, 3016, 3017, 3019, 3018, 3022, 3023, 3021, 3020, 3012, 3013, 3015, 3014, 3010, 3011, 3009, 3008, 2880, 2881, 2883, 2882, 2886, 2887, 2885, 2884, 2892, 2893, 2895, 2894, 2890, 2891, 2889, 2888, 2904, 2905, 2907, 2906, 2910, 2911, 2909, 2908, 2900, 2901, 2903, 2902, 2898, 2899, 2897, 2896, 2928, 2929, 2931, 2930, 2934, 2935, 2933, 2932, 2940, 2941, 2943, 2942, 2938, 2939, 2937, 2936, 2920, 2921, 2923, 2922, 2926, 2927, 2925, 2924, 2916, 2917, 2919, 2918, 2914, 2915, 2913, 2912, 2848, 2849, 2851, 2850, 2854, 2855, 2853, 2852, 2860, 2861, 2863, 2862, 2858, 2859, 2857, 2856, 2872, 2873, 2875, 2874, 2878, 2879, 2877, 2876, 2868, 2869, 2871, 2870, 2866, 2867, 2865, 2864, 2832, 2833, 2835, 2834, 2838, 2839, 2837, 2836, 2844, 2845, 2847, 2846, 2842, 2843, 2841, 2840, 2824, 2825, 2827, 2826, 2830, 2831, 2829, 2828, 2820, 2821, 2823, 2822, 2818, 2819, 2817, 2816, 2304, 2305, 2307, 2306, 2310, 2311, 2309, 2308, 2316, 2317, 2319, 2318, 2314, 2315, 2313, 2312, 2328, 2329, 2331, 2330, 2334, 2335, 2333, 2332, 2324, 2325, 2327, 2326, 2322, 2323, 2321, 2320, 2352, 2353, 2355, 2354, 2358, 2359, 2357, 2356, 2364, 2365, 2367, 2366, 2362, 2363, 2361, 2360, 2344, 2345, 2347, 2346, 2350, 2351, 2349, 2348, 2340, 2341, 2343, 2342, 2338, 2339, 2337, 2336, 2400, 2401, 2403, 2402, 2406, 2407, 2405, 2404, 2412, 2413, 2415, 2414, 2410, 2411, 2409, 2408, 2424, 2425, 2427, 2426, 2430, 2431, 2429, 2428, 2420, 2421, 2423, 2422, 2418, 2419, 2417, 2416, 2384, 2385, 2387, 2386, 2390, 2391, 2389, 2388, 2396, 2397, 2399, 2398, 2394, 2395, 2393, 2392, 2376, 2377, 2379, 2378, 2382, 2383, 2381, 2380, 2372, 2373, 2375, 2374, 2370, 2371, 2369, 2368, 2496, 2497, 2499, 2498, 2502, 2503, 2501, 2500, 2508, 2509, 2511, 2510, 2506, 2507, 2505, 2504, 2520, 2521, 2523, 2522, 2526, 2527, 2525, 2524, 2516, 2517, 2519, 2518, 2514, 2515, 2513, 2512, 2544, 2545, 2547, 2546, 2550, 2551, 2549, 2548, 2556, 2557, 2559, 2558, 2554, 2555, 2553, 2552, 2536, 2537, 2539, 2538, 2542, 2543, 2541, 2540, 2532, 2533, 2535, 2534, 2530, 2531, 2529, 2528, 2464, 2465, 2467, 2466, 2470, 2471, 2469, 2468, 2476, 2477, 2479, 2478, 2474, 2475, 2473, 2472, 2488, 2489, 2491, 2490, 2494, 2495, 2493, 2492, 2484, 2485, 2487, 2486, 2482, 2483, 2481, 2480, 2448, 2449, 2451, 2450, 2454, 2455, 2453, 2452, 2460, 2461, 2463, 2462, 2458, 2459, 2457, 2456, 2440, 2441, 2443, 2442, 2446, 2447, 2445, 2444, 2436, 2437, 2439, 2438, 2434, 2435, 2433, 2432, 2176, 2177, 2179, 2178, 2182, 2183, 2181, 2180, 2188, 2189, 2191, 2190, 2186, 2187, 2185, 2184, 2200, 2201, 2203, 2202, 2206, 2207, 2205, 2204, 2196, 2197, 2199, 2198, 2194, 2195, 2193, 2192, 2224, 2225, 2227, 2226, 2230, 2231, 2229, 2228, 2236, 2237, 2239, 2238, 2234, 2235, 2233, 2232, 2216, 2217, 2219, 2218, 2222, 2223, 2221, 2220, 2212, 2213, 2215, 2214, 2210, 2211, 2209, 2208, 2272, 2273, 2275, 2274, 2278, 2279, 2277, 2276, 2284, 2285, 2287, 2286, 2282, 2283, 2281, 2280, 2296, 2297, 2299, 2298, 2302, 2303, 2301, 2300, 2292, 2293, 2295, 2294, 2290, 2291, 2289, 2288, 2256, 2257, 2259, 2258, 2262, 2263, 2261, 2260, 2268, 2269, 2271, 2270, 2266, 2267, 2265, 2264, 2248, 2249, 2251, 2250, 2254, 2255, 2253, 2252, 2244, 2245, 2247, 2246, 2242, 2243, 2241, 2240, 2112, 2113, 2115, 2114, 2118, 2119, 2117, 2116, 2124, 2125, 2127, 2126, 2122, 2123, 2121, 2120, 2136, 2137, 2139, 2138, 2142, 2143, 2141, 2140, 2132, 2133, 2135, 2134, 2130, 2131, 2129, 2128, 2160, 2161, 2163, 2162, 2166, 2167, 2165, 2164, 2172, 2173, 2175, 2174, 2170, 2171, 2169, 2168, 2152, 2153, 2155, 2154, 2158, 2159, 2157, 2156, 2148, 2149, 2151, 2150, 2146, 2147, 2145, 2144, 2080, 2081, 2083, 2082, 2086, 2087, 2085, 2084, 2092, 2093, 2095, 2094, 2090, 2091, 2089, 2088, 2104, 2105, 2107, 2106, 2110, 2111, 2109, 2108, 2100, 2101, 2103, 2102, 2098, 2099, 2097, 2096, 2064, 2065, 2067, 2066, 2070, 2071, 2069, 2068, 2076, 2077, 2079, 2078, 2074, 2075, 2073, 2072, 2056, 2057, 2059, 2058, 2062, 2063, 2061, 2060, 2052, 2053, 2055, 2054, 2050, 2051, 2049]\n assert candidate(n = 8,start = 128) == [128, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129]\n assert candidate(n = 5,start = 15) == [15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13]\n assert candidate(n = 11,start = 1023) == [1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046, 2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021]\n assert candidate(n = 4,start = 0) == [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8]\n assert candidate(n = 6,start = 20) == [20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28]\n assert candidate(n = 4,start = 5) == [5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 0, 1, 3, 2, 6, 7]\n assert candidate(n = 3,start = 2) == [2, 6, 7, 5, 4, 0, 1, 3]\n assert candidate(n = 2,start = 3) == [3, 2, 0, 1]\n assert candidate(n = 5,start = 10) == [10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14]\n assert candidate(n = 7,start = 42) == [42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43]\n assert candidate(n = 10,start = 510) == [510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506]\n assert candidate(n = 9,start = 255) == [255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253]\n assert candidate(n = 12,start = 2047) == [2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024, 3072, 3073, 3075, 3074, 3078, 3079, 3077, 3076, 3084, 3085, 3087, 3086, 3082, 3083, 3081, 3080, 3096, 3097, 3099, 3098, 3102, 3103, 3101, 3100, 3092, 3093, 3095, 3094, 3090, 3091, 3089, 3088, 3120, 3121, 3123, 3122, 3126, 3127, 3125, 3124, 3132, 3133, 3135, 3134, 3130, 3131, 3129, 3128, 3112, 3113, 3115, 3114, 3118, 3119, 3117, 3116, 3108, 3109, 3111, 3110, 3106, 3107, 3105, 3104, 3168, 3169, 3171, 3170, 3174, 3175, 3173, 3172, 3180, 3181, 3183, 3182, 3178, 3179, 3177, 3176, 3192, 3193, 3195, 3194, 3198, 3199, 3197, 3196, 3188, 3189, 3191, 3190, 3186, 3187, 3185, 3184, 3152, 3153, 3155, 3154, 3158, 3159, 3157, 3156, 3164, 3165, 3167, 3166, 3162, 3163, 3161, 3160, 3144, 3145, 3147, 3146, 3150, 3151, 3149, 3148, 3140, 3141, 3143, 3142, 3138, 3139, 3137, 3136, 3264, 3265, 3267, 3266, 3270, 3271, 3269, 3268, 3276, 3277, 3279, 3278, 3274, 3275, 3273, 3272, 3288, 3289, 3291, 3290, 3294, 3295, 3293, 3292, 3284, 3285, 3287, 3286, 3282, 3283, 3281, 3280, 3312, 3313, 3315, 3314, 3318, 3319, 3317, 3316, 3324, 3325, 3327, 3326, 3322, 3323, 3321, 3320, 3304, 3305, 3307, 3306, 3310, 3311, 3309, 3308, 3300, 3301, 3303, 3302, 3298, 3299, 3297, 3296, 3232, 3233, 3235, 3234, 3238, 3239, 3237, 3236, 3244, 3245, 3247, 3246, 3242, 3243, 3241, 3240, 3256, 3257, 3259, 3258, 3262, 3263, 3261, 3260, 3252, 3253, 3255, 3254, 3250, 3251, 3249, 3248, 3216, 3217, 3219, 3218, 3222, 3223, 3221, 3220, 3228, 3229, 3231, 3230, 3226, 3227, 3225, 3224, 3208, 3209, 3211, 3210, 3214, 3215, 3213, 3212, 3204, 3205, 3207, 3206, 3202, 3203, 3201, 3200, 3456, 3457, 3459, 3458, 3462, 3463, 3461, 3460, 3468, 3469, 3471, 3470, 3466, 3467, 3465, 3464, 3480, 3481, 3483, 3482, 3486, 3487, 3485, 3484, 3476, 3477, 3479, 3478, 3474, 3475, 3473, 3472, 3504, 3505, 3507, 3506, 3510, 3511, 3509, 3508, 3516, 3517, 3519, 3518, 3514, 3515, 3513, 3512, 3496, 3497, 3499, 3498, 3502, 3503, 3501, 3500, 3492, 3493, 3495, 3494, 3490, 3491, 3489, 3488, 3552, 3553, 3555, 3554, 3558, 3559, 3557, 3556, 3564, 3565, 3567, 3566, 3562, 3563, 3561, 3560, 3576, 3577, 3579, 3578, 3582, 3583, 3581, 3580, 3572, 3573, 3575, 3574, 3570, 3571, 3569, 3568, 3536, 3537, 3539, 3538, 3542, 3543, 3541, 3540, 3548, 3549, 3551, 3550, 3546, 3547, 3545, 3544, 3528, 3529, 3531, 3530, 3534, 3535, 3533, 3532, 3524, 3525, 3527, 3526, 3522, 3523, 3521, 3520, 3392, 3393, 3395, 3394, 3398, 3399, 3397, 3396, 3404, 3405, 3407, 3406, 3402, 3403, 3401, 3400, 3416, 3417, 3419, 3418, 3422, 3423, 3421, 3420, 3412, 3413, 3415, 3414, 3410, 3411, 3409, 3408, 3440, 3441, 3443, 3442, 3446, 3447, 3445, 3444, 3452, 3453, 3455, 3454, 3450, 3451, 3449, 3448, 3432, 3433, 3435, 3434, 3438, 3439, 3437, 3436, 3428, 3429, 3431, 3430, 3426, 3427, 3425, 3424, 3360, 3361, 3363, 3362, 3366, 3367, 3365, 3364, 3372, 3373, 3375, 3374, 3370, 3371, 3369, 3368, 3384, 3385, 3387, 3386, 3390, 3391, 3389, 3388, 3380, 3381, 3383, 3382, 3378, 3379, 3377, 3376, 3344, 3345, 3347, 3346, 3350, 3351, 3349, 3348, 3356, 3357, 3359, 3358, 3354, 3355, 3353, 3352, 3336, 3337, 3339, 3338, 3342, 3343, 3341, 3340, 3332, 3333, 3335, 3334, 3330, 3331, 3329, 3328, 3840, 3841, 3843, 3842, 3846, 3847, 3845, 3844, 3852, 3853, 3855, 3854, 3850, 3851, 3849, 3848, 3864, 3865, 3867, 3866, 3870, 3871, 3869, 3868, 3860, 3861, 3863, 3862, 3858, 3859, 3857, 3856, 3888, 3889, 3891, 3890, 3894, 3895, 3893, 3892, 3900, 3901, 3903, 3902, 3898, 3899, 3897, 3896, 3880, 3881, 3883, 3882, 3886, 3887, 3885, 3884, 3876, 3877, 3879, 3878, 3874, 3875, 3873, 3872, 3936, 3937, 3939, 3938, 3942, 3943, 3941, 3940, 3948, 3949, 3951, 3950, 3946, 3947, 3945, 3944, 3960, 3961, 3963, 3962, 3966, 3967, 3965, 3964, 3956, 3957, 3959, 3958, 3954, 3955, 3953, 3952, 3920, 3921, 3923, 3922, 3926, 3927, 3925, 3924, 3932, 3933, 3935, 3934, 3930, 3931, 3929, 3928, 3912, 3913, 3915, 3914, 3918, 3919, 3917, 3916, 3908, 3909, 3911, 3910, 3906, 3907, 3905, 3904, 4032, 4033, 4035, 4034, 4038, 4039, 4037, 4036, 4044, 4045, 4047, 4046, 4042, 4043, 4041, 4040, 4056, 4057, 4059, 4058, 4062, 4063, 4061, 4060, 4052, 4053, 4055, 4054, 4050, 4051, 4049, 4048, 4080, 4081, 4083, 4082, 4086, 4087, 4085, 4084, 4092, 4093, 4095, 4094, 4090, 4091, 4089, 4088, 4072, 4073, 4075, 4074, 4078, 4079, 4077, 4076, 4068, 4069, 4071, 4070, 4066, 4067, 4065, 4064, 4000, 4001, 4003, 4002, 4006, 4007, 4005, 4004, 4012, 4013, 4015, 4014, 4010, 4011, 4009, 4008, 4024, 4025, 4027, 4026, 4030, 4031, 4029, 4028, 4020, 4021, 4023, 4022, 4018, 4019, 4017, 4016, 3984, 3985, 3987, 3986, 3990, 3991, 3989, 3988, 3996, 3997, 3999, 3998, 3994, 3995, 3993, 3992, 3976, 3977, 3979, 3978, 3982, 3983, 3981, 3980, 3972, 3973, 3975, 3974, 3970, 3971, 3969, 3968, 3712, 3713, 3715, 3714, 3718, 3719, 3717, 3716, 3724, 3725, 3727, 3726, 3722, 3723, 3721, 3720, 3736, 3737, 3739, 3738, 3742, 3743, 3741, 3740, 3732, 3733, 3735, 3734, 3730, 3731, 3729, 3728, 3760, 3761, 3763, 3762, 3766, 3767, 3765, 3764, 3772, 3773, 3775, 3774, 3770, 3771, 3769, 3768, 3752, 3753, 3755, 3754, 3758, 3759, 3757, 3756, 3748, 3749, 3751, 3750, 3746, 3747, 3745, 3744, 3808, 3809, 3811, 3810, 3814, 3815, 3813, 3812, 3820, 3821, 3823, 3822, 3818, 3819, 3817, 3816, 3832, 3833, 3835, 3834, 3838, 3839, 3837, 3836, 3828, 3829, 3831, 3830, 3826, 3827, 3825, 3824, 3792, 3793, 3795, 3794, 3798, 3799, 3797, 3796, 3804, 3805, 3807, 3806, 3802, 3803, 3801, 3800, 3784, 3785, 3787, 3786, 3790, 3791, 3789, 3788, 3780, 3781, 3783, 3782, 3778, 3779, 3777, 3776, 3648, 3649, 3651, 3650, 3654, 3655, 3653, 3652, 3660, 3661, 3663, 3662, 3658, 3659, 3657, 3656, 3672, 3673, 3675, 3674, 3678, 3679, 3677, 3676, 3668, 3669, 3671, 3670, 3666, 3667, 3665, 3664, 3696, 3697, 3699, 3698, 3702, 3703, 3701, 3700, 3708, 3709, 3711, 3710, 3706, 3707, 3705, 3704, 3688, 3689, 3691, 3690, 3694, 3695, 3693, 3692, 3684, 3685, 3687, 3686, 3682, 3683, 3681, 3680, 3616, 3617, 3619, 3618, 3622, 3623, 3621, 3620, 3628, 3629, 3631, 3630, 3626, 3627, 3625, 3624, 3640, 3641, 3643, 3642, 3646, 3647, 3645, 3644, 3636, 3637, 3639, 3638, 3634, 3635, 3633, 3632, 3600, 3601, 3603, 3602, 3606, 3607, 3605, 3604, 3612, 3613, 3615, 3614, 3610, 3611, 3609, 3608, 3592, 3593, 3595, 3594, 3598, 3599, 3597, 3596, 3588, 3589, 3591, 3590, 3586, 3587, 3585, 3584, 2560, 2561, 2563, 2562, 2566, 2567, 2565, 2564, 2572, 2573, 2575, 2574, 2570, 2571, 2569, 2568, 2584, 2585, 2587, 2586, 2590, 2591, 2589, 2588, 2580, 2581, 2583, 2582, 2578, 2579, 2577, 2576, 2608, 2609, 2611, 2610, 2614, 2615, 2613, 2612, 2620, 2621, 2623, 2622, 2618, 2619, 2617, 2616, 2600, 2601, 2603, 2602, 2606, 2607, 2605, 2604, 2596, 2597, 2599, 2598, 2594, 2595, 2593, 2592, 2656, 2657, 2659, 2658, 2662, 2663, 2661, 2660, 2668, 2669, 2671, 2670, 2666, 2667, 2665, 2664, 2680, 2681, 2683, 2682, 2686, 2687, 2685, 2684, 2676, 2677, 2679, 2678, 2674, 2675, 2673, 2672, 2640, 2641, 2643, 2642, 2646, 2647, 2645, 2644, 2652, 2653, 2655, 2654, 2650, 2651, 2649, 2648, 2632, 2633, 2635, 2634, 2638, 2639, 2637, 2636, 2628, 2629, 2631, 2630, 2626, 2627, 2625, 2624, 2752, 2753, 2755, 2754, 2758, 2759, 2757, 2756, 2764, 2765, 2767, 2766, 2762, 2763, 2761, 2760, 2776, 2777, 2779, 2778, 2782, 2783, 2781, 2780, 2772, 2773, 2775, 2774, 2770, 2771, 2769, 2768, 2800, 2801, 2803, 2802, 2806, 2807, 2805, 2804, 2812, 2813, 2815, 2814, 2810, 2811, 2809, 2808, 2792, 2793, 2795, 2794, 2798, 2799, 2797, 2796, 2788, 2789, 2791, 2790, 2786, 2787, 2785, 2784, 2720, 2721, 2723, 2722, 2726, 2727, 2725, 2724, 2732, 2733, 2735, 2734, 2730, 2731, 2729, 2728, 2744, 2745, 2747, 2746, 2750, 2751, 2749, 2748, 2740, 2741, 2743, 2742, 2738, 2739, 2737, 2736, 2704, 2705, 2707, 2706, 2710, 2711, 2709, 2708, 2716, 2717, 2719, 2718, 2714, 2715, 2713, 2712, 2696, 2697, 2699, 2698, 2702, 2703, 2701, 2700, 2692, 2693, 2695, 2694, 2690, 2691, 2689, 2688, 2944, 2945, 2947, 2946, 2950, 2951, 2949, 2948, 2956, 2957, 2959, 2958, 2954, 2955, 2953, 2952, 2968, 2969, 2971, 2970, 2974, 2975, 2973, 2972, 2964, 2965, 2967, 2966, 2962, 2963, 2961, 2960, 2992, 2993, 2995, 2994, 2998, 2999, 2997, 2996, 3004, 3005, 3007, 3006, 3002, 3003, 3001, 3000, 2984, 2985, 2987, 2986, 2990, 2991, 2989, 2988, 2980, 2981, 2983, 2982, 2978, 2979, 2977, 2976, 3040, 3041, 3043, 3042, 3046, 3047, 3045, 3044, 3052, 3053, 3055, 3054, 3050, 3051, 3049, 3048, 3064, 3065, 3067, 3066, 3070, 3071, 3069, 3068, 3060, 3061, 3063, 3062, 3058, 3059, 3057, 3056, 3024, 3025, 3027, 3026, 3030, 3031, 3029, 3028, 3036, 3037, 3039, 3038, 3034, 3035, 3033, 3032, 3016, 3017, 3019, 3018, 3022, 3023, 3021, 3020, 3012, 3013, 3015, 3014, 3010, 3011, 3009, 3008, 2880, 2881, 2883, 2882, 2886, 2887, 2885, 2884, 2892, 2893, 2895, 2894, 2890, 2891, 2889, 2888, 2904, 2905, 2907, 2906, 2910, 2911, 2909, 2908, 2900, 2901, 2903, 2902, 2898, 2899, 2897, 2896, 2928, 2929, 2931, 2930, 2934, 2935, 2933, 2932, 2940, 2941, 2943, 2942, 2938, 2939, 2937, 2936, 2920, 2921, 2923, 2922, 2926, 2927, 2925, 2924, 2916, 2917, 2919, 2918, 2914, 2915, 2913, 2912, 2848, 2849, 2851, 2850, 2854, 2855, 2853, 2852, 2860, 2861, 2863, 2862, 2858, 2859, 2857, 2856, 2872, 2873, 2875, 2874, 2878, 2879, 2877, 2876, 2868, 2869, 2871, 2870, 2866, 2867, 2865, 2864, 2832, 2833, 2835, 2834, 2838, 2839, 2837, 2836, 2844, 2845, 2847, 2846, 2842, 2843, 2841, 2840, 2824, 2825, 2827, 2826, 2830, 2831, 2829, 2828, 2820, 2821, 2823, 2822, 2818, 2819, 2817, 2816, 2304, 2305, 2307, 2306, 2310, 2311, 2309, 2308, 2316, 2317, 2319, 2318, 2314, 2315, 2313, 2312, 2328, 2329, 2331, 2330, 2334, 2335, 2333, 2332, 2324, 2325, 2327, 2326, 2322, 2323, 2321, 2320, 2352, 2353, 2355, 2354, 2358, 2359, 2357, 2356, 2364, 2365, 2367, 2366, 2362, 2363, 2361, 2360, 2344, 2345, 2347, 2346, 2350, 2351, 2349, 2348, 2340, 2341, 2343, 2342, 2338, 2339, 2337, 2336, 2400, 2401, 2403, 2402, 2406, 2407, 2405, 2404, 2412, 2413, 2415, 2414, 2410, 2411, 2409, 2408, 2424, 2425, 2427, 2426, 2430, 2431, 2429, 2428, 2420, 2421, 2423, 2422, 2418, 2419, 2417, 2416, 2384, 2385, 2387, 2386, 2390, 2391, 2389, 2388, 2396, 2397, 2399, 2398, 2394, 2395, 2393, 2392, 2376, 2377, 2379, 2378, 2382, 2383, 2381, 2380, 2372, 2373, 2375, 2374, 2370, 2371, 2369, 2368, 2496, 2497, 2499, 2498, 2502, 2503, 2501, 2500, 2508, 2509, 2511, 2510, 2506, 2507, 2505, 2504, 2520, 2521, 2523, 2522, 2526, 2527, 2525, 2524, 2516, 2517, 2519, 2518, 2514, 2515, 2513, 2512, 2544, 2545, 2547, 2546, 2550, 2551, 2549, 2548, 2556, 2557, 2559, 2558, 2554, 2555, 2553, 2552, 2536, 2537, 2539, 2538, 2542, 2543, 2541, 2540, 2532, 2533, 2535, 2534, 2530, 2531, 2529, 2528, 2464, 2465, 2467, 2466, 2470, 2471, 2469, 2468, 2476, 2477, 2479, 2478, 2474, 2475, 2473, 2472, 2488, 2489, 2491, 2490, 2494, 2495, 2493, 2492, 2484, 2485, 2487, 2486, 2482, 2483, 2481, 2480, 2448, 2449, 2451, 2450, 2454, 2455, 2453, 2452, 2460, 2461, 2463, 2462, 2458, 2459, 2457, 2456, 2440, 2441, 2443, 2442, 2446, 2447, 2445, 2444, 2436, 2437, 2439, 2438, 2434, 2435, 2433, 2432, 2176, 2177, 2179, 2178, 2182, 2183, 2181, 2180, 2188, 2189, 2191, 2190, 2186, 2187, 2185, 2184, 2200, 2201, 2203, 2202, 2206, 2207, 2205, 2204, 2196, 2197, 2199, 2198, 2194, 2195, 2193, 2192, 2224, 2225, 2227, 2226, 2230, 2231, 2229, 2228, 2236, 2237, 2239, 2238, 2234, 2235, 2233, 2232, 2216, 2217, 2219, 2218, 2222, 2223, 2221, 2220, 2212, 2213, 2215, 2214, 2210, 2211, 2209, 2208, 2272, 2273, 2275, 2274, 2278, 2279, 2277, 2276, 2284, 2285, 2287, 2286, 2282, 2283, 2281, 2280, 2296, 2297, 2299, 2298, 2302, 2303, 2301, 2300, 2292, 2293, 2295, 2294, 2290, 2291, 2289, 2288, 2256, 2257, 2259, 2258, 2262, 2263, 2261, 2260, 2268, 2269, 2271, 2270, 2266, 2267, 2265, 2264, 2248, 2249, 2251, 2250, 2254, 2255, 2253, 2252, 2244, 2245, 2247, 2246, 2242, 2243, 2241, 2240, 2112, 2113, 2115, 2114, 2118, 2119, 2117, 2116, 2124, 2125, 2127, 2126, 2122, 2123, 2121, 2120, 2136, 2137, 2139, 2138, 2142, 2143, 2141, 2140, 2132, 2133, 2135, 2134, 2130, 2131, 2129, 2128, 2160, 2161, 2163, 2162, 2166, 2167, 2165, 2164, 2172, 2173, 2175, 2174, 2170, 2171, 2169, 2168, 2152, 2153, 2155, 2154, 2158, 2159, 2157, 2156, 2148, 2149, 2151, 2150, 2146, 2147, 2145, 2144, 2080, 2081, 2083, 2082, 2086, 2087, 2085, 2084, 2092, 2093, 2095, 2094, 2090, 2091, 2089, 2088, 2104, 2105, 2107, 2106, 2110, 2111, 2109, 2108, 2100, 2101, 2103, 2102, 2098, 2099, 2097, 2096, 2064, 2065, 2067, 2066, 2070, 2071, 2069, 2068, 2076, 2077, 2079, 2078, 2074, 2075, 2073, 2072, 2056, 2057, 2059, 2058, 2062, 2063, 2061, 2060, 2052, 2053, 2055, 2054, 2050, 2051, 2049, 2048, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046]\n assert candidate(n = 10,start = 511) == [511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510]\n assert candidate(n = 7,start = 64) == [64, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65]\n assert candidate(n = 6,start = 32) == [32, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33]\n assert candidate(n = 3,start = 7) == [7, 5, 4, 0, 1, 3, 2, 6]\n assert candidate(n = 5,start = 16) == [16, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17]\n assert candidate(n = 8,start = 255) == [255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253]\n assert candidate(n = 7,start = 56) == [56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57]\n assert candidate(n = 7,start = 48) == [48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16]\n assert candidate(n = 9,start = 127) == [127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126]\n assert candidate(n = 9,start = 256) == [256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257]\n assert candidate(n = 8,start = 15) == [15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13]\n assert candidate(n = 11,start = 2047) == [2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046]\n assert candidate(n = 9,start = 511) == [511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510]\n assert candidate(n = 8,start = 3) == [3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 0, 1]\n assert candidate(n = 5,start = 7) == [7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 0, 1, 3, 2, 6]\n assert candidate(n = 8,start = 7) == [7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 0, 1, 3, 2, 6]\n assert candidate(n = 8,start = 31) == [31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30]\n assert candidate(n = 10,start = 7) == [7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6]\n assert candidate(n = 6,start = 31) == [31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30]\n assert candidate(n = 2,start = 2) == [2, 0, 1, 3]\n assert candidate(n = 10,start = 63) == [63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61]\n assert candidate(n = 10,start = 31) == [31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30]\n assert candidate(n = 12,start = 4095) == [4095, 4094, 4090, 4091, 4089, 4088, 4072, 4073, 4075, 4074, 4078, 4079, 4077, 4076, 4068, 4069, 4071, 4070, 4066, 4067, 4065, 4064, 4000, 4001, 4003, 4002, 4006, 4007, 4005, 4004, 4012, 4013, 4015, 4014, 4010, 4011, 4009, 4008, 4024, 4025, 4027, 4026, 4030, 4031, 4029, 4028, 4020, 4021, 4023, 4022, 4018, 4019, 4017, 4016, 3984, 3985, 3987, 3986, 3990, 3991, 3989, 3988, 3996, 3997, 3999, 3998, 3994, 3995, 3993, 3992, 3976, 3977, 3979, 3978, 3982, 3983, 3981, 3980, 3972, 3973, 3975, 3974, 3970, 3971, 3969, 3968, 3712, 3713, 3715, 3714, 3718, 3719, 3717, 3716, 3724, 3725, 3727, 3726, 3722, 3723, 3721, 3720, 3736, 3737, 3739, 3738, 3742, 3743, 3741, 3740, 3732, 3733, 3735, 3734, 3730, 3731, 3729, 3728, 3760, 3761, 3763, 3762, 3766, 3767, 3765, 3764, 3772, 3773, 3775, 3774, 3770, 3771, 3769, 3768, 3752, 3753, 3755, 3754, 3758, 3759, 3757, 3756, 3748, 3749, 3751, 3750, 3746, 3747, 3745, 3744, 3808, 3809, 3811, 3810, 3814, 3815, 3813, 3812, 3820, 3821, 3823, 3822, 3818, 3819, 3817, 3816, 3832, 3833, 3835, 3834, 3838, 3839, 3837, 3836, 3828, 3829, 3831, 3830, 3826, 3827, 3825, 3824, 3792, 3793, 3795, 3794, 3798, 3799, 3797, 3796, 3804, 3805, 3807, 3806, 3802, 3803, 3801, 3800, 3784, 3785, 3787, 3786, 3790, 3791, 3789, 3788, 3780, 3781, 3783, 3782, 3778, 3779, 3777, 3776, 3648, 3649, 3651, 3650, 3654, 3655, 3653, 3652, 3660, 3661, 3663, 3662, 3658, 3659, 3657, 3656, 3672, 3673, 3675, 3674, 3678, 3679, 3677, 3676, 3668, 3669, 3671, 3670, 3666, 3667, 3665, 3664, 3696, 3697, 3699, 3698, 3702, 3703, 3701, 3700, 3708, 3709, 3711, 3710, 3706, 3707, 3705, 3704, 3688, 3689, 3691, 3690, 3694, 3695, 3693, 3692, 3684, 3685, 3687, 3686, 3682, 3683, 3681, 3680, 3616, 3617, 3619, 3618, 3622, 3623, 3621, 3620, 3628, 3629, 3631, 3630, 3626, 3627, 3625, 3624, 3640, 3641, 3643, 3642, 3646, 3647, 3645, 3644, 3636, 3637, 3639, 3638, 3634, 3635, 3633, 3632, 3600, 3601, 3603, 3602, 3606, 3607, 3605, 3604, 3612, 3613, 3615, 3614, 3610, 3611, 3609, 3608, 3592, 3593, 3595, 3594, 3598, 3599, 3597, 3596, 3588, 3589, 3591, 3590, 3586, 3587, 3585, 3584, 2560, 2561, 2563, 2562, 2566, 2567, 2565, 2564, 2572, 2573, 2575, 2574, 2570, 2571, 2569, 2568, 2584, 2585, 2587, 2586, 2590, 2591, 2589, 2588, 2580, 2581, 2583, 2582, 2578, 2579, 2577, 2576, 2608, 2609, 2611, 2610, 2614, 2615, 2613, 2612, 2620, 2621, 2623, 2622, 2618, 2619, 2617, 2616, 2600, 2601, 2603, 2602, 2606, 2607, 2605, 2604, 2596, 2597, 2599, 2598, 2594, 2595, 2593, 2592, 2656, 2657, 2659, 2658, 2662, 2663, 2661, 2660, 2668, 2669, 2671, 2670, 2666, 2667, 2665, 2664, 2680, 2681, 2683, 2682, 2686, 2687, 2685, 2684, 2676, 2677, 2679, 2678, 2674, 2675, 2673, 2672, 2640, 2641, 2643, 2642, 2646, 2647, 2645, 2644, 2652, 2653, 2655, 2654, 2650, 2651, 2649, 2648, 2632, 2633, 2635, 2634, 2638, 2639, 2637, 2636, 2628, 2629, 2631, 2630, 2626, 2627, 2625, 2624, 2752, 2753, 2755, 2754, 2758, 2759, 2757, 2756, 2764, 2765, 2767, 2766, 2762, 2763, 2761, 2760, 2776, 2777, 2779, 2778, 2782, 2783, 2781, 2780, 2772, 2773, 2775, 2774, 2770, 2771, 2769, 2768, 2800, 2801, 2803, 2802, 2806, 2807, 2805, 2804, 2812, 2813, 2815, 2814, 2810, 2811, 2809, 2808, 2792, 2793, 2795, 2794, 2798, 2799, 2797, 2796, 2788, 2789, 2791, 2790, 2786, 2787, 2785, 2784, 2720, 2721, 2723, 2722, 2726, 2727, 2725, 2724, 2732, 2733, 2735, 2734, 2730, 2731, 2729, 2728, 2744, 2745, 2747, 2746, 2750, 2751, 2749, 2748, 2740, 2741, 2743, 2742, 2738, 2739, 2737, 2736, 2704, 2705, 2707, 2706, 2710, 2711, 2709, 2708, 2716, 2717, 2719, 2718, 2714, 2715, 2713, 2712, 2696, 2697, 2699, 2698, 2702, 2703, 2701, 2700, 2692, 2693, 2695, 2694, 2690, 2691, 2689, 2688, 2944, 2945, 2947, 2946, 2950, 2951, 2949, 2948, 2956, 2957, 2959, 2958, 2954, 2955, 2953, 2952, 2968, 2969, 2971, 2970, 2974, 2975, 2973, 2972, 2964, 2965, 2967, 2966, 2962, 2963, 2961, 2960, 2992, 2993, 2995, 2994, 2998, 2999, 2997, 2996, 3004, 3005, 3007, 3006, 3002, 3003, 3001, 3000, 2984, 2985, 2987, 2986, 2990, 2991, 2989, 2988, 2980, 2981, 2983, 2982, 2978, 2979, 2977, 2976, 3040, 3041, 3043, 3042, 3046, 3047, 3045, 3044, 3052, 3053, 3055, 3054, 3050, 3051, 3049, 3048, 3064, 3065, 3067, 3066, 3070, 3071, 3069, 3068, 3060, 3061, 3063, 3062, 3058, 3059, 3057, 3056, 3024, 3025, 3027, 3026, 3030, 3031, 3029, 3028, 3036, 3037, 3039, 3038, 3034, 3035, 3033, 3032, 3016, 3017, 3019, 3018, 3022, 3023, 3021, 3020, 3012, 3013, 3015, 3014, 3010, 3011, 3009, 3008, 2880, 2881, 2883, 2882, 2886, 2887, 2885, 2884, 2892, 2893, 2895, 2894, 2890, 2891, 2889, 2888, 2904, 2905, 2907, 2906, 2910, 2911, 2909, 2908, 2900, 2901, 2903, 2902, 2898, 2899, 2897, 2896, 2928, 2929, 2931, 2930, 2934, 2935, 2933, 2932, 2940, 2941, 2943, 2942, 2938, 2939, 2937, 2936, 2920, 2921, 2923, 2922, 2926, 2927, 2925, 2924, 2916, 2917, 2919, 2918, 2914, 2915, 2913, 2912, 2848, 2849, 2851, 2850, 2854, 2855, 2853, 2852, 2860, 2861, 2863, 2862, 2858, 2859, 2857, 2856, 2872, 2873, 2875, 2874, 2878, 2879, 2877, 2876, 2868, 2869, 2871, 2870, 2866, 2867, 2865, 2864, 2832, 2833, 2835, 2834, 2838, 2839, 2837, 2836, 2844, 2845, 2847, 2846, 2842, 2843, 2841, 2840, 2824, 2825, 2827, 2826, 2830, 2831, 2829, 2828, 2820, 2821, 2823, 2822, 2818, 2819, 2817, 2816, 2304, 2305, 2307, 2306, 2310, 2311, 2309, 2308, 2316, 2317, 2319, 2318, 2314, 2315, 2313, 2312, 2328, 2329, 2331, 2330, 2334, 2335, 2333, 2332, 2324, 2325, 2327, 2326, 2322, 2323, 2321, 2320, 2352, 2353, 2355, 2354, 2358, 2359, 2357, 2356, 2364, 2365, 2367, 2366, 2362, 2363, 2361, 2360, 2344, 2345, 2347, 2346, 2350, 2351, 2349, 2348, 2340, 2341, 2343, 2342, 2338, 2339, 2337, 2336, 2400, 2401, 2403, 2402, 2406, 2407, 2405, 2404, 2412, 2413, 2415, 2414, 2410, 2411, 2409, 2408, 2424, 2425, 2427, 2426, 2430, 2431, 2429, 2428, 2420, 2421, 2423, 2422, 2418, 2419, 2417, 2416, 2384, 2385, 2387, 2386, 2390, 2391, 2389, 2388, 2396, 2397, 2399, 2398, 2394, 2395, 2393, 2392, 2376, 2377, 2379, 2378, 2382, 2383, 2381, 2380, 2372, 2373, 2375, 2374, 2370, 2371, 2369, 2368, 2496, 2497, 2499, 2498, 2502, 2503, 2501, 2500, 2508, 2509, 2511, 2510, 2506, 2507, 2505, 2504, 2520, 2521, 2523, 2522, 2526, 2527, 2525, 2524, 2516, 2517, 2519, 2518, 2514, 2515, 2513, 2512, 2544, 2545, 2547, 2546, 2550, 2551, 2549, 2548, 2556, 2557, 2559, 2558, 2554, 2555, 2553, 2552, 2536, 2537, 2539, 2538, 2542, 2543, 2541, 2540, 2532, 2533, 2535, 2534, 2530, 2531, 2529, 2528, 2464, 2465, 2467, 2466, 2470, 2471, 2469, 2468, 2476, 2477, 2479, 2478, 2474, 2475, 2473, 2472, 2488, 2489, 2491, 2490, 2494, 2495, 2493, 2492, 2484, 2485, 2487, 2486, 2482, 2483, 2481, 2480, 2448, 2449, 2451, 2450, 2454, 2455, 2453, 2452, 2460, 2461, 2463, 2462, 2458, 2459, 2457, 2456, 2440, 2441, 2443, 2442, 2446, 2447, 2445, 2444, 2436, 2437, 2439, 2438, 2434, 2435, 2433, 2432, 2176, 2177, 2179, 2178, 2182, 2183, 2181, 2180, 2188, 2189, 2191, 2190, 2186, 2187, 2185, 2184, 2200, 2201, 2203, 2202, 2206, 2207, 2205, 2204, 2196, 2197, 2199, 2198, 2194, 2195, 2193, 2192, 2224, 2225, 2227, 2226, 2230, 2231, 2229, 2228, 2236, 2237, 2239, 2238, 2234, 2235, 2233, 2232, 2216, 2217, 2219, 2218, 2222, 2223, 2221, 2220, 2212, 2213, 2215, 2214, 2210, 2211, 2209, 2208, 2272, 2273, 2275, 2274, 2278, 2279, 2277, 2276, 2284, 2285, 2287, 2286, 2282, 2283, 2281, 2280, 2296, 2297, 2299, 2298, 2302, 2303, 2301, 2300, 2292, 2293, 2295, 2294, 2290, 2291, 2289, 2288, 2256, 2257, 2259, 2258, 2262, 2263, 2261, 2260, 2268, 2269, 2271, 2270, 2266, 2267, 2265, 2264, 2248, 2249, 2251, 2250, 2254, 2255, 2253, 2252, 2244, 2245, 2247, 2246, 2242, 2243, 2241, 2240, 2112, 2113, 2115, 2114, 2118, 2119, 2117, 2116, 2124, 2125, 2127, 2126, 2122, 2123, 2121, 2120, 2136, 2137, 2139, 2138, 2142, 2143, 2141, 2140, 2132, 2133, 2135, 2134, 2130, 2131, 2129, 2128, 2160, 2161, 2163, 2162, 2166, 2167, 2165, 2164, 2172, 2173, 2175, 2174, 2170, 2171, 2169, 2168, 2152, 2153, 2155, 2154, 2158, 2159, 2157, 2156, 2148, 2149, 2151, 2150, 2146, 2147, 2145, 2144, 2080, 2081, 2083, 2082, 2086, 2087, 2085, 2084, 2092, 2093, 2095, 2094, 2090, 2091, 2089, 2088, 2104, 2105, 2107, 2106, 2110, 2111, 2109, 2108, 2100, 2101, 2103, 2102, 2098, 2099, 2097, 2096, 2064, 2065, 2067, 2066, 2070, 2071, 2069, 2068, 2076, 2077, 2079, 2078, 2074, 2075, 2073, 2072, 2056, 2057, 2059, 2058, 2062, 2063, 2061, 2060, 2052, 2053, 2055, 2054, 2050, 2051, 2049, 2048, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046, 2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024, 3072, 3073, 3075, 3074, 3078, 3079, 3077, 3076, 3084, 3085, 3087, 3086, 3082, 3083, 3081, 3080, 3096, 3097, 3099, 3098, 3102, 3103, 3101, 3100, 3092, 3093, 3095, 3094, 3090, 3091, 3089, 3088, 3120, 3121, 3123, 3122, 3126, 3127, 3125, 3124, 3132, 3133, 3135, 3134, 3130, 3131, 3129, 3128, 3112, 3113, 3115, 3114, 3118, 3119, 3117, 3116, 3108, 3109, 3111, 3110, 3106, 3107, 3105, 3104, 3168, 3169, 3171, 3170, 3174, 3175, 3173, 3172, 3180, 3181, 3183, 3182, 3178, 3179, 3177, 3176, 3192, 3193, 3195, 3194, 3198, 3199, 3197, 3196, 3188, 3189, 3191, 3190, 3186, 3187, 3185, 3184, 3152, 3153, 3155, 3154, 3158, 3159, 3157, 3156, 3164, 3165, 3167, 3166, 3162, 3163, 3161, 3160, 3144, 3145, 3147, 3146, 3150, 3151, 3149, 3148, 3140, 3141, 3143, 3142, 3138, 3139, 3137, 3136, 3264, 3265, 3267, 3266, 3270, 3271, 3269, 3268, 3276, 3277, 3279, 3278, 3274, 3275, 3273, 3272, 3288, 3289, 3291, 3290, 3294, 3295, 3293, 3292, 3284, 3285, 3287, 3286, 3282, 3283, 3281, 3280, 3312, 3313, 3315, 3314, 3318, 3319, 3317, 3316, 3324, 3325, 3327, 3326, 3322, 3323, 3321, 3320, 3304, 3305, 3307, 3306, 3310, 3311, 3309, 3308, 3300, 3301, 3303, 3302, 3298, 3299, 3297, 3296, 3232, 3233, 3235, 3234, 3238, 3239, 3237, 3236, 3244, 3245, 3247, 3246, 3242, 3243, 3241, 3240, 3256, 3257, 3259, 3258, 3262, 3263, 3261, 3260, 3252, 3253, 3255, 3254, 3250, 3251, 3249, 3248, 3216, 3217, 3219, 3218, 3222, 3223, 3221, 3220, 3228, 3229, 3231, 3230, 3226, 3227, 3225, 3224, 3208, 3209, 3211, 3210, 3214, 3215, 3213, 3212, 3204, 3205, 3207, 3206, 3202, 3203, 3201, 3200, 3456, 3457, 3459, 3458, 3462, 3463, 3461, 3460, 3468, 3469, 3471, 3470, 3466, 3467, 3465, 3464, 3480, 3481, 3483, 3482, 3486, 3487, 3485, 3484, 3476, 3477, 3479, 3478, 3474, 3475, 3473, 3472, 3504, 3505, 3507, 3506, 3510, 3511, 3509, 3508, 3516, 3517, 3519, 3518, 3514, 3515, 3513, 3512, 3496, 3497, 3499, 3498, 3502, 3503, 3501, 3500, 3492, 3493, 3495, 3494, 3490, 3491, 3489, 3488, 3552, 3553, 3555, 3554, 3558, 3559, 3557, 3556, 3564, 3565, 3567, 3566, 3562, 3563, 3561, 3560, 3576, 3577, 3579, 3578, 3582, 3583, 3581, 3580, 3572, 3573, 3575, 3574, 3570, 3571, 3569, 3568, 3536, 3537, 3539, 3538, 3542, 3543, 3541, 3540, 3548, 3549, 3551, 3550, 3546, 3547, 3545, 3544, 3528, 3529, 3531, 3530, 3534, 3535, 3533, 3532, 3524, 3525, 3527, 3526, 3522, 3523, 3521, 3520, 3392, 3393, 3395, 3394, 3398, 3399, 3397, 3396, 3404, 3405, 3407, 3406, 3402, 3403, 3401, 3400, 3416, 3417, 3419, 3418, 3422, 3423, 3421, 3420, 3412, 3413, 3415, 3414, 3410, 3411, 3409, 3408, 3440, 3441, 3443, 3442, 3446, 3447, 3445, 3444, 3452, 3453, 3455, 3454, 3450, 3451, 3449, 3448, 3432, 3433, 3435, 3434, 3438, 3439, 3437, 3436, 3428, 3429, 3431, 3430, 3426, 3427, 3425, 3424, 3360, 3361, 3363, 3362, 3366, 3367, 3365, 3364, 3372, 3373, 3375, 3374, 3370, 3371, 3369, 3368, 3384, 3385, 3387, 3386, 3390, 3391, 3389, 3388, 3380, 3381, 3383, 3382, 3378, 3379, 3377, 3376, 3344, 3345, 3347, 3346, 3350, 3351, 3349, 3348, 3356, 3357, 3359, 3358, 3354, 3355, 3353, 3352, 3336, 3337, 3339, 3338, 3342, 3343, 3341, 3340, 3332, 3333, 3335, 3334, 3330, 3331, 3329, 3328, 3840, 3841, 3843, 3842, 3846, 3847, 3845, 3844, 3852, 3853, 3855, 3854, 3850, 3851, 3849, 3848, 3864, 3865, 3867, 3866, 3870, 3871, 3869, 3868, 3860, 3861, 3863, 3862, 3858, 3859, 3857, 3856, 3888, 3889, 3891, 3890, 3894, 3895, 3893, 3892, 3900, 3901, 3903, 3902, 3898, 3899, 3897, 3896, 3880, 3881, 3883, 3882, 3886, 3887, 3885, 3884, 3876, 3877, 3879, 3878, 3874, 3875, 3873, 3872, 3936, 3937, 3939, 3938, 3942, 3943, 3941, 3940, 3948, 3949, 3951, 3950, 3946, 3947, 3945, 3944, 3960, 3961, 3963, 3962, 3966, 3967, 3965, 3964, 3956, 3957, 3959, 3958, 3954, 3955, 3953, 3952, 3920, 3921, 3923, 3922, 3926, 3927, 3925, 3924, 3932, 3933, 3935, 3934, 3930, 3931, 3929, 3928, 3912, 3913, 3915, 3914, 3918, 3919, 3917, 3916, 3908, 3909, 3911, 3910, 3906, 3907, 3905, 3904, 4032, 4033, 4035, 4034, 4038, 4039, 4037, 4036, 4044, 4045, 4047, 4046, 4042, 4043, 4041, 4040, 4056, 4057, 4059, 4058, 4062, 4063, 4061, 4060, 4052, 4053, 4055, 4054, 4050, 4051, 4049, 4048, 4080, 4081, 4083, 4082, 4086, 4087, 4085, 4084, 4092, 4093]\n assert candidate(n = 9,start = 123) == [123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121]\n assert candidate(n = 7,start = 1) == [1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 0]\n assert candidate(n = 9,start = 500) == [500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508]\n assert candidate(n = 10,start = 15) == [15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13]\n assert candidate(n = 1,start = 1) == [1, 0]\n assert candidate(n = 6,start = 24) == [24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8]\n assert candidate(n = 11,start = 1024) == [1024, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046, 2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025]\n assert candidate(n = 4,start = 15) == [15, 14, 10, 11, 9, 8, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13]\n assert candidate(n = 10,start = 1023) == [1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021]\n assert candidate(n = 5,start = 31) == [31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30]\n assert candidate(n = 10,start = 255) == [255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253]\n assert candidate(n = 9,start = 63) == [63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61]\n assert candidate(n = 7,start = 127) == [127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126]\n assert candidate(n = 10,start = 512) == [512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513]\n assert candidate(n = 6,start = 63) == [63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61]\n assert candidate(n = 10,start = 127) == [127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126]\n assert candidate(n = 6,start = 12) == [12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 0, 1, 3, 2, 6, 7, 5, 4]\n", "comparison": "exact"}, "public_tests": ["2\n3", "3\n2"], "hints": ["Use gray code to generate a n-bit sequence.", "Rotate the sequence such that its first element is start."], "metadata": {"canonical_parameter_names": ["n", "start"], "leetcode_dataset_entry_point": "Solution().circularPermutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:13+00:00", "tests_total": 55, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "backtracking", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def circularPermutation(self, n: int, start: int) -> List[int]:", "container": "Solution", "callable": "circularPermutation", "parameters": [{"name": "n", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1239, "task_id": "maximum-length-of-a-concatenated-string-with-unique-characters", "difficulty": "Medium", "problem_description": "You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters.\n\nReturn the maximum possible length of s.\n\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: arr = [\"un\",\"iq\",\"ue\"]\nOutput: 4\nExplanation: All the valid concatenations are:\n- \"\"\n- \"un\"\n- \"iq\"\n- \"ue\"\n- \"uniq\" (\"un\" + \"iq\")\n- \"ique\" (\"iq\" + \"ue\")\nMaximum length is 4.\n\nExample 2:\n\nInput: arr = [\"cha\",\"r\",\"act\",\"ers\"]\nOutput: 6\nExplanation: Possible longest valid concatenations are \"chaers\" (\"cha\" + \"ers\") and \"acters\" (\"act\" + \"ers\").\n\nExample 3:\n\nInput: arr = [\"abcdefghijklmnopqrstuvwxyz\"]\nOutput: 26\nExplanation: The only string in arr has all 26 characters.\n\nConstraints:\n\n- 1 <= arr.length <= 16\n- 1 <= arr[i].length <= 26\n- arr[i] contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = ['abcd', 'abef', 'cdgh', 'cdef']) == 8\n assert candidate(arr = ['un', 'iq', 'ue']) == 4\n assert candidate(arr = ['abcdefghijklmnopqrstuvwxyz']) == 26\n assert candidate(arr = ['unique', 'strings', 'with', 'no', 'common', 'characters']) == 6\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']) == 16\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz']) == 26\n assert candidate(arr = ['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz']) == 26\n assert candidate(arr = ['zzzz', 'zzyy', 'xxzz', 'xxyy', 'abcd']) == 4\n assert candidate(arr = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj']) == 0\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 26\n assert candidate(arr = ['xyy', 'zmk']) == 3\n assert candidate(arr = ['a', 'ab', 'abc', 'abcd', 'abcde']) == 5\n assert candidate(arr = ['abc', 'de', 'fgh', 'ij', 'klm', 'nop', 'qrs', 'tuv', 'wxy', 'z']) == 26\n assert candidate(arr = ['a', 'b', 'c']) == 3\n assert candidate(arr = ['abcd', 'aabbccdd', 'abcde', 'mnopqr', 'stuvwx', 'yz']) == 19\n assert candidate(arr = ['aabbcc', 'ddeeff', 'gghhiijj']) == 0\n assert candidate(arr = ['cha', 'r', 'act', 'ers']) == 6\n assert candidate(arr = ['aabbcc', 'ddeeff', 'gghhii', 'jklmno', 'pqqrst', 'uvwxyz']) == 12\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz', 'abcd', 'efgh']) == 24\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 26\n assert candidate(arr = ['xyzz', 'abxy', 'mnop', 'qrst', 'uvwz', 'mnop', 'qrst', 'uvwz', 'mnop', 'qrst', 'uvwz', 'mnop', 'qrst', 'uvwz', 'mnop', 'qrst']) == 16\n assert candidate(arr = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp']) == 0\n assert candidate(arr = ['unique', 'strings', 'with', 'distinct', 'chars', 'in', 'each', 'subsequence']) == 7\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz', 'mnop', 'qrst', 'uvwxy']) == 25\n assert candidate(arr = ['xyz', 'uvw', 'tuv', 'stu', 'rst', 'qrs', 'pqr', 'opq', 'nop', 'mno', 'lmn', 'klm', 'jkl', 'ikl', 'ihg', 'fgh']) == 18\n assert candidate(arr = ['aabb', 'ccdd', 'eeff', 'gghh', 'iijj', 'kklm', 'nopq', 'rstu', 'vwxy', 'zz']) == 12\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxyza', 'bcdefg', 'hijklm', 'nopqrs', 'tuvwxy', 'zabcde']) == 24\n assert candidate(arr = ['abcdexyz', 'mnop', 'qrstuvw', 'zabcd', 'ef', 'ghijkl', 'mnopqr', 'stuv', 'wxyz', 'abcdefghij', 'klmnopqr', 'stuvwxyz']) == 26\n assert candidate(arr = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'abcdefgh', 'ijklmnop', 'qrstuvwxyz']) == 26\n assert candidate(arr = ['abcd', 'defg', 'hijk', 'lmno', 'pqrs', 'tuvw', 'xyza']) == 24\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'a', 'b', 'c', 'd']) == 26\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cded', 'efgi', 'hjkl', 'mnop', 'qrst', 'uvwz', 'abcd']) == 24\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz', 'abcdefghijklmnopqrstuvwxyz', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz']) == 26\n assert candidate(arr = ['abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi']) == 9\n assert candidate(arr = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd', 'efghi', 'jklmn', 'opqrs', 'tuvwx', 'yzabc', 'defgh']) == 25\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == 24\n assert candidate(arr = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghij', 'klmnopqr', 'stuvwxyz']) == 26\n assert candidate(arr = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'fffff']) == 0\n assert candidate(arr = ['zyxwvutsrqpomnlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'mnopqrstuvwxyza', 'bcdefghijklmnopqr', 'stuvwxyzabcde']) == 26\n assert candidate(arr = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'ffffff', 'ggggg']) == 0\n assert candidate(arr = ['abcd', 'def', 'ghij', 'klmno', 'pqrst', 'uvwxy', 'z']) == 24\n assert candidate(arr = ['abcd', 'efgh', 'abcd', 'efgh', 'ijkl', 'mnop', 'ijkl', 'mnop', 'qrst', 'uvwx', 'qrst', 'uvwx', 'yz', 'yz', 'abcd']) == 26\n assert candidate(arr = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh']) == 0\n assert candidate(arr = ['abcd', 'abef', 'acgh', 'adei', 'afjk', 'aglm', 'ahno', 'aipq', 'arst', 'auvw', 'axyz']) == 4\n assert candidate(arr = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'abcdefgh', 'ijklmnop', 'qrstuvwxyz']) == 26\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == 26\n assert candidate(arr = ['abcdefgh', 'yzabcd', 'efghij', 'mnopqr', 'stuvwx', 'qrstuv', 'wxyzab']) == 24\n assert candidate(arr = ['long', 'strings', 'with', 'repeated', 'characters', 'are', 'not', 'allowed', 'in', 'this', 'problem']) == 11\n assert candidate(arr = ['zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyz']) == 26\n assert candidate(arr = ['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz']) == 26\n assert candidate(arr = ['abcd', 'ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz']) == 26\n assert candidate(arr = ['abcdefgh', 'ijklmnop', 'qrstuvwxyz', 'abcdefgh', 'ijklmnop', 'qrstuvwxyz']) == 26\n assert candidate(arr = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd', 'efghi', 'jklmn', 'opqrs', 'tuvwx', 'yzabc']) == 25\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxyzab', 'cdefgh', 'ijklmn', 'opqrst']) == 24\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd']) == 26\n assert candidate(arr = ['xyz', 'abcdef', 'ghijklm', 'nopqr', 'stuv', 'wxyz', 'mnop', 'qrstuv', 'xyzuvw', 'abcdefg']) == 26\n assert candidate(arr = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll', 'mmmm', 'nnnn', 'oooo', 'pppp']) == 0\n assert candidate(arr = ['aabbcc', 'ddeeff', 'gghhii', 'jkkllm', 'nnoopq', 'rrsstt', 'uuvvww', 'xxyyzz']) == 0\n assert candidate(arr = ['abcdefghijklmnop', 'qrstuvwxyz', 'abcdefghijkl', 'mnopqrstuv', 'wxyzabcdef', 'ghijklmnop', 'qrstuvwxy', 'zabcdefghij']) == 26\n assert candidate(arr = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh']) == 0\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == 24\n assert candidate(arr = ['zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz']) == 26\n assert candidate(arr = ['unique', 'chars', 'only', 'here', 'subseq', 'concat', 'maximum', 'length', 'string', 'concatenation']) == 9\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmno', 'pqrstu', 'vwxyz']) == 24\n assert candidate(arr = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yzabcdef', 'ghijklmn', 'opqrstuv', 'wxyzab', 'cdefghij', 'klmnopqr', 'stuvwxy']) == 24\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv']) == 24\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab']) == 26\n assert candidate(arr = ['unique', 'chars', 'only', 'here', 'are', 'some', 'strings', 'with', 'various', 'lengths']) == 11\n", "comparison": "exact"}, "public_tests": ["[\"un\",\"iq\",\"ue\"]", "[\"cha\",\"r\",\"act\",\"ers\"]", "[\"abcdefghijklmnopqrstuvwxyz\"]"], "hints": ["You can try all combinations and keep mask of characters you have.", "You can use DP."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().maxLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:15+00:00", "tests_total": 87, "tests_dropped": 19, "flags": [], "topic_tags": ["array", "string", "backtracking", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def maxLength(self, arr: list[str]) -> int:", "container": "Solution", "callable": "maxLength", "parameters": [{"name": "arr", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1240, "task_id": "tiling-a-rectangle-with-the-fewest-squares", "difficulty": "Hard", "problem_description": "Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.\n\nExample 1:\n\nInput: n = 2, m = 3\nOutput: 3\nExplanation: 3 squares are necessary to cover the rectangle.\n2 (squares of 1x1)\n1 (square of 2x2)\n\nExample 2:\n\nInput: n = 5, m = 8\nOutput: 5\n\nExample 3:\n\nInput: n = 11, m = 13\nOutput: 6\n\nConstraints:\n\n- 1 <= n, m <= 13\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8,m = 8) == 1\n assert candidate(n = 1,m = 1) == 1\n assert candidate(n = 7,m = 7) == 1\n assert candidate(n = 9,m = 10) == 6\n assert candidate(n = 7,m = 8) == 7\n assert candidate(n = 6,m = 7) == 5\n assert candidate(n = 6,m = 10) == 4\n assert candidate(n = 8,m = 9) == 7\n assert candidate(n = 3,m = 3) == 1\n assert candidate(n = 4,m = 10) == 4\n assert candidate(n = 11,m = 13) == 6\n assert candidate(n = 5,m = 8) == 5\n assert candidate(n = 12,m = 13) == 7\n assert candidate(n = 4,m = 6) == 3\n assert candidate(n = 10,m = 11) == 6\n assert candidate(n = 9,m = 12) == 4\n assert candidate(n = 9,m = 11) == 7\n assert candidate(n = 13,m = 13) == 1\n assert candidate(n = 3,m = 5) == 4\n assert candidate(n = 2,m = 3) == 3\n assert candidate(n = 10,m = 10) == 1\n assert candidate(n = 6,m = 6) == 1\n assert candidate(n = 7,m = 12) == 6\n assert candidate(n = 3,m = 11) == 6\n assert candidate(n = 11,m = 10) == 6\n assert candidate(n = 13,m = 5) == 6\n assert candidate(n = 12,m = 7) == 6\n assert candidate(n = 13,m = 7) == 6\n assert candidate(n = 5,m = 11) == 6\n assert candidate(n = 5,m = 12) == 6\n assert candidate(n = 7,m = 13) == 6\n assert candidate(n = 9,m = 9) == 1\n assert candidate(n = 3,m = 7) == 5\n assert candidate(n = 6,m = 11) == 6\n assert candidate(n = 2,m = 13) == 8\n assert candidate(n = 6,m = 13) == 6\n assert candidate(n = 6,m = 9) == 3\n assert candidate(n = 4,m = 9) == 6\n assert candidate(n = 8,m = 12) == 3\n assert candidate(n = 4,m = 11) == 6\n assert candidate(n = 13,m = 12) == 7\n assert candidate(n = 10,m = 5) == 2\n assert candidate(n = 4,m = 7) == 5\n assert candidate(n = 7,m = 10) == 6\n assert candidate(n = 12,m = 5) == 6\n assert candidate(n = 9,m = 7) == 6\n assert candidate(n = 10,m = 12) == 5\n assert candidate(n = 8,m = 13) == 6\n assert candidate(n = 12,m = 11) == 7\n assert candidate(n = 8,m = 10) == 5\n assert candidate(n = 3,m = 10) == 6\n assert candidate(n = 11,m = 9) == 7\n assert candidate(n = 8,m = 11) == 6\n assert candidate(n = 13,m = 6) == 6\n assert candidate(n = 5,m = 9) == 6\n assert candidate(n = 4,m = 13) == 7\n assert candidate(n = 12,m = 10) == 5\n", "comparison": "exact"}, "public_tests": ["2\n3", "5\n8", "11\n13"], "hints": ["Can you use backtracking to solve this problem ?.", "Suppose you've placed a bunch of squares. Where is the natural spot to place the next square ?.", "The maximum number of squares to be placed will be ≤ max(n,m)."], "metadata": {"canonical_parameter_names": ["n", "m"], "leetcode_dataset_entry_point": "Solution().tilingRectangle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:17+00:00", "tests_total": 66, "tests_dropped": 9, "flags": ["has_images"], "topic_tags": ["backtracking"]}, "language": "python", "interface": {"raw_signature": "def tilingRectangle(self, n: int, m: int) -> int:", "container": "Solution", "callable": "tilingRectangle", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1247, "task_id": "minimum-swaps-to-make-strings-equal", "difficulty": "Medium", "problem_description": "You are given two strings s1 and s2 of equal length consisting of letters \"x\" and \"y\" only. Your task is to make these two strings equal to each other. You can swap any two characters that belong to different strings, which means: swap s1[i] and s2[j].\n\nReturn the minimum number of swaps required to make s1 and s2 equal, or return -1 if it is impossible to do so.\n\nExample 1:\n\nInput: s1 = \"xx\", s2 = \"yy\"\nOutput: 1\nExplanation: Swap s1[0] and s2[1], s1 = \"yx\", s2 = \"yx\".\n\nExample 2:\n\nInput: s1 = \"xy\", s2 = \"yx\"\nOutput: 2\nExplanation: Swap s1[0] and s2[0], s1 = \"yy\", s2 = \"xx\".\nSwap s1[0] and s2[1], s1 = \"xy\", s2 = \"xy\".\nNote that you cannot swap s1[0] and s1[1] to make s1 equal to \"yx\", cause we can only swap chars in different strings.\n\nExample 3:\n\nInput: s1 = \"xx\", s2 = \"xy\"\nOutput: -1\n\nConstraints:\n\n- 1 <= s1.length, s2.length <= 1000\n- s1.length == s2.length\n- s1, s2 only contain 'x' or 'y'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"xyyy\",s2 = \"yxxx\") == 3\n assert candidate(s1 = \"xx\",s2 = \"yy\") == 1\n assert candidate(s1 = \"xxyy\",s2 = \"xyxy\") == 2\n assert candidate(s1 = \"xxyyxyxyxx\",s2 = \"xyyxyxxxyx\") == 4\n assert candidate(s1 = \"xxxyyy\",s2 = \"yyyxxx\") == 4\n assert candidate(s1 = \"xyyx\",s2 = \"xxyy\") == 2\n assert candidate(s1 = \"yx\",s2 = \"xy\") == 2\n assert candidate(s1 = \"xxxx\",s2 = \"yyyy\") == 2\n assert candidate(s1 = \"yxyy\",s2 = \"xyyx\") == -1\n assert candidate(s1 = \"xx\",s2 = \"xy\") == -1\n assert candidate(s1 = \"yy\",s2 = \"xx\") == 1\n assert candidate(s1 = \"xyyx\",s2 = \"xyyx\") == 0\n assert candidate(s1 = \"yyyy\",s2 = \"xxxx\") == 2\n assert candidate(s1 = \"xyxy\",s2 = \"yxyx\") == 2\n assert candidate(s1 = \"xyxx\",s2 = \"xyyx\") == -1\n assert candidate(s1 = \"xxyx\",s2 = \"xyxy\") == -1\n assert candidate(s1 = \"xy\",s2 = \"yx\") == 2\n assert candidate(s1 = \"xyxyxy\",s2 = \"yxyxyx\") == 4\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyx\") == 14\n assert candidate(s1 = \"xyxxxyxxyy\",s2 = \"yxyyxyyxxy\") == 3\n assert candidate(s1 = \"xyyyxy\",s2 = \"yxyxyx\") == -1\n assert candidate(s1 = \"xxyyxx\",s2 = \"yyxxxy\") == -1\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\") == 16\n assert candidate(s1 = \"xyxyyx\",s2 = \"yxyxyx\") == 2\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyxyx\") == 14\n assert candidate(s1 = \"xyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyx\") == 6\n assert candidate(s1 = \"xxxyyyxx\",s2 = \"yyxxxyyy\") == 3\n assert candidate(s1 = \"xyyxxyyyxy\",s2 = \"yxyyxxyxyx\") == -1\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\") == 20\n assert candidate(s1 = \"yxyxyxyxyx\",s2 = \"xyxyxyxyxy\") == 6\n assert candidate(s1 = \"xyyxxyyxxy\",s2 = \"yxyxyxyxyx\") == 4\n assert candidate(s1 = \"xxxyyyy\",s2 = \"yyyxxxx\") == -1\n assert candidate(s1 = \"xyyxxyyx\",s2 = \"yxyxyxyx\") == 2\n assert candidate(s1 = \"xxyyyy\",s2 = \"yyxxyx\") == -1\n assert candidate(s1 = \"xxxxxyyyyy\",s2 = \"yyyyyyxxxx\") == -1\n assert candidate(s1 = \"xxyxyxyy\",s2 = \"yyxyxyyx\") == -1\n assert candidate(s1 = \"xyxyxxxy\",s2 = \"yyxxyxyx\") == -1\n assert candidate(s1 = \"xxyxxyxyxy\",s2 = \"yxyxyxyxyy\") == 3\n assert candidate(s1 = \"xxxyyyxy\",s2 = \"yyxxyxxy\") == 2\n assert candidate(s1 = \"xyyx\",s2 = \"yxyx\") == 2\n assert candidate(s1 = \"xxyyxyyx\",s2 = \"yyxyxxxy\") == 4\n assert candidate(s1 = \"xxyxxy\",s2 = \"yyxyyx\") == 3\n assert candidate(s1 = \"xyyxxyxyxy\",s2 = \"yxyxyxyxyy\") == -1\n assert candidate(s1 = \"xyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyx\") == 8\n assert candidate(s1 = \"xxyyxy\",s2 = \"yyxyxx\") == 2\n assert candidate(s1 = \"xyxyxy\",s2 = \"yxyxyy\") == -1\n assert candidate(s1 = \"xyxxyyxy\",s2 = \"yxyyyxyx\") == -1\n assert candidate(s1 = \"xxyxyxyxyx\",s2 = \"yxyxyxyxyx\") == -1\n assert candidate(s1 = \"xxyyxyxyx\",s2 = \"yyxyxyxyx\") == -1\n assert candidate(s1 = \"yxyxyxyxyx\",s2 = \"xyxyxyxyyx\") == 4\n assert candidate(s1 = \"xyxxyxxyxy\",s2 = \"yxyxyxyxyx\") == -1\n assert candidate(s1 = \"xyxyxyyxyx\",s2 = \"xyxyxyxyxy\") == 2\n assert candidate(s1 = \"xxxxxy\",s2 = \"yyyxxx\") == 3\n assert candidate(s1 = \"xxyyxxxyyy\",s2 = \"yyxxyyxyxx\") == 4\n assert candidate(s1 = \"xxxxxx\",s2 = \"yyyyyy\") == 3\n assert candidate(s1 = \"xyxyxyxyxy\",s2 = \"yxyxyxyxyx\") == 6\n assert candidate(s1 = \"xxxxxyyyy\",s2 = \"yyyyxxxyx\") == -1\n assert candidate(s1 = \"xxyx\",s2 = \"xyyx\") == -1\n assert candidate(s1 = \"xxxxxxxx\",s2 = \"yyyyyyyy\") == 4\n assert candidate(s1 = \"xxxxxxxxxx\",s2 = \"yyyyyyyyyy\") == 5\n assert candidate(s1 = \"xyxxyxxyx\",s2 = \"yxyxyxyyx\") == 3\n assert candidate(s1 = \"xyxxyy\",s2 = \"yxyxyx\") == 2\n assert candidate(s1 = \"xxyxyxyx\",s2 = \"yxyxyxyy\") == 1\n assert candidate(s1 = \"xyxyxxxyyx\",s2 = \"yxyxyxxyxy\") == -1\n assert candidate(s1 = \"xxyyxxyyxx\",s2 = \"yyxyxxyyxy\") == 3\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyx\") == 10\n assert candidate(s1 = \"xyxyxyxy\",s2 = \"yxyxyxyx\") == 4\n assert candidate(s1 = \"xxyy\",s2 = \"yyxx\") == 2\n assert candidate(s1 = \"xxyxyxyxyxyxyxyxyx\",s2 = \"xyxyxyxyxyxyxyxyyx\") == -1\n assert candidate(s1 = \"xxyyxyxyxyxyxy\",s2 = \"yyxyxyxyxyxyyx\") == -1\n assert candidate(s1 = \"xyxyy\",s2 = \"yxyyx\") == 2\n assert candidate(s1 = \"xyyxxyyxxyyx\",s2 = \"yxyxyxyxyxyy\") == -1\n assert candidate(s1 = \"xxyxyxyx\",s2 = \"xyxyxyyx\") == -1\n assert candidate(s1 = \"xxxxxyyy\",s2 = \"yyyyxxxx\") == -1\n assert candidate(s1 = \"xyxyxyxyyy\",s2 = \"yxyxyxyxxx\") == 5\n assert candidate(s1 = \"yyxyyyxxxyyy\",s2 = \"xyxxyyxyxxyx\") == -1\n assert candidate(s1 = \"yxyxyxyx\",s2 = \"xyxyxyxy\") == 4\n assert candidate(s1 = \"xyxxyxyxyx\",s2 = \"xyxyxyxyyx\") == -1\n assert candidate(s1 = \"xyxxyxyx\",s2 = \"yxxyxyyx\") == -1\n assert candidate(s1 = \"xxxxxxyy\",s2 = \"yyxxxxyx\") == -1\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyx\") == 12\n assert candidate(s1 = \"xxyyxyyx\",s2 = \"yyxyxyyx\") == -1\n assert candidate(s1 = \"xxxyyyxyyx\",s2 = \"yyxyyxyxxy\") == -1\n assert candidate(s1 = \"xxyxxyxyxy\",s2 = \"yxyxyxyxyx\") == -1\n assert candidate(s1 = \"xyxxyxxyxxyxyy\",s2 = \"yxyxyxyxyxyyxy\") == 5\n assert candidate(s1 = \"xxyxyxx\",s2 = \"yyxyxyy\") == -1\n assert candidate(s1 = \"xxyxyxyxyx\",s2 = \"xyxyxyxyyx\") == -1\n assert candidate(s1 = \"xyxyxyyy\",s2 = \"yxyxyxxx\") == 5\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\") == 18\n assert candidate(s1 = \"xxyxyxyxyx\",s2 = \"xyxxyxyxyx\") == 2\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\") == 18\n assert candidate(s1 = \"xyyxxyxyxy\",s2 = \"yxyxyxyxyx\") == 4\n assert candidate(s1 = \"xxyxyx\",s2 = \"yyxyxy\") == 3\n assert candidate(s1 = \"xxyyyy\",s2 = \"yyyxxx\") == -1\n assert candidate(s1 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\") == 20\n assert candidate(s1 = \"xyxxyxyx\",s2 = \"xyxyxyyx\") == -1\n assert candidate(s1 = \"xyxyxyxyxy\",s2 = \"yxyxyxyxyy\") == -1\n assert candidate(s1 = \"xyxxyxxyx\",s2 = \"yxyxyxyxy\") == 3\n assert candidate(s1 = \"xyxxyxyxyxyxyxyxyxyxyxyxyxyx\",s2 = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == -1\n assert candidate(s1 = \"xxyxyxyxyy\",s2 = \"yyxyxyxyyx\") == -1\n assert candidate(s1 = \"xyxyxyxyxyxyxyxy\",s2 = \"yxyxyxyxyxyxyxyx\") == 8\n assert candidate(s1 = \"xyxxxy\",s2 = \"yxyyxy\") == 3\n assert candidate(s1 = \"xxyxyyxy\",s2 = \"yyxyxyyx\") == -1\n", "comparison": "exact"}, "public_tests": ["\"xx\"\n\"yy\"", "\"xy\"\n\"yx\"", "\"xx\"\n\"xy\""], "hints": ["First, ignore all the already matched positions, they don't affect the answer at all. For the unmatched positions, there are three basic cases (already given in the examples):", "(\"xx\", \"yy\") => 1 swap, (\"xy\", \"yx\") => 2 swaps", "So the strategy is, apply case 1 as much as possible, then apply case 2 if the last two unmatched are in this case, or fall into impossible if only one pair of unmatched left. This can be done via a simple math."], "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().minimumSwap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:28+00:00", "tests_total": 103, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minimumSwap(self, s1: str, s2: str) -> int:", "container": "Solution", "callable": "minimumSwap", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1248, "task_id": "count-number-of-nice-subarrays", "difficulty": "Medium", "problem_description": "Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.\n\nReturn the number of nice sub-arrays.\n\nExample 1:\n\nInput: nums = [1,1,2,1,1], k = 3\nOutput: 2\nExplanation: The only sub-arrays with 3 odd numbers are [1,1,2,1] and [1,2,1,1].\n\nExample 2:\n\nInput: nums = [2,4,6], k = 1\nOutput: 0\nExplanation: There are no odd numbers in the array.\n\nExample 3:\n\nInput: nums = [2,2,2,1,2,2,1,2,2,2], k = 2\nOutput: 16\n\nConstraints:\n\n- 1 <= nums.length <= 50000\n- 1 <= nums[i] <= 10^5\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 2\n assert candidate(nums = [2],k = 1) == 0\n assert candidate(nums = [2, 4, 6],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 1\n assert candidate(nums = [2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(nums = [2, 2, 2, 1, 2, 2, 1, 2, 2, 2],k = 2) == 16\n assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 4\n assert candidate(nums = [1, 1, 2, 1, 1],k = 3) == 2\n assert candidate(nums = [10, 15, 20, 25, 30],k = 1) == 8\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 44\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 15) == 16\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 1) == 0\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34],k = 5) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 81\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == 13\n assert candidate(nums = [2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2],k = 4) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 54\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 2\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 2) == 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 = 5) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1],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 = 10) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 3) == 18\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],k = 5) == 42\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],k = 3) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 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, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 36\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 = 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],k = 1) == 20\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 4) == 6\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100],k = 5) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 3) == 9\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2],k = 4) == 57\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9],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 = 15) == 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],k = 10) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 16\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9],k = 5) == 11\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, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 640\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 13\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],k = 2) == 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],k = 6) == 18\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],k = 3) == 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) == 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],k = 3) == 22\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) == 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],k = 5) == 22\n assert candidate(nums = [1, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 3) == 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 = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 22\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) == 25\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],k = 3) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 6\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7) == 9\n", "comparison": "exact"}, "public_tests": ["[1,1,2,1,1]\n3", "[2,4,6]\n1", "[2,2,2,1,2,2,1,2,2,2]\n2"], "hints": ["After replacing each even by zero and every odd by one can we use prefix sum to find answer ?", "Can we use two pointers to count number of sub-arrays ?", "Can we store the indices of odd numbers and for each k indices count the number of sub-arrays that contains them ?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().numberOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:30+00:00", "tests_total": 68, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "hash-table", "math", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numberOfSubarrays(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "numberOfSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1249, "task_id": "minimum-remove-to-make-valid-parentheses", "difficulty": "Medium", "problem_description": "Given a string s of '(' , ')' and lowercase English characters.\n\nYour task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string.\n\nFormally, a parentheses string is valid if and only if:\n\n- It is the empty string, contains only lowercase characters, or\n- It can be written as AB (A concatenated with B), where A and B are valid strings, or\n- It can be written as (A), where A is a valid string.\n\nExample 1:\n\nInput: s = \"lee(t(c)o)de)\"\nOutput: \"lee(t(c)o)de\"\nExplanation: \"lee(t(co)de)\" , \"lee(t(c)ode)\" would also be accepted.\n\nExample 2:\n\nInput: s = \"a)b(c)d\"\nOutput: \"ab(c)d\"\n\nExample 3:\n\nInput: s = \"))((\"\nOutput: \"\"\nExplanation: An empty string is also valid.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is either '(' , ')', or lowercase English letter.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(a(b)c)d(e(fg)h\") == \"(a(b)c)de(fg)h\"\n assert candidate(s = \"()\") == \"()\"\n assert candidate(s = \"))(()\") == \"()\"\n assert candidate(s = \"ab(c(d)e)f(g(h)i)j(kl)\") == \"ab(c(d)e)f(g(h)i)j(kl)\"\n assert candidate(s = \"a)b(c)d\") == \"ab(c)d\"\n assert candidate(s = \"()()\") == \"()()\"\n assert candidate(s = \"(a(b)c)d(e(f)g)h(i)\") == \"(a(b)c)d(e(f)g)h(i)\"\n assert candidate(s = \"))(())\") == \"(())\"\n assert candidate(s = \"(a(b)c)d(e(f)g)h\") == \"(a(b)c)d(e(f)g)h\"\n assert candidate(s = \"lee(t(c)o)de)\") == \"lee(t(c)o)de\"\n assert candidate(s = \"a(b)c)d(e(fg)h)i(j(k(l)m)n)o(pq(r)s)t(uv(w)x)y(z)\") == \"a(b)cd(e(fg)h)i(j(k(l)m)n)o(pq(r)s)t(uv(w)x)y(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)st(u)v(w(x)y)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)st(u)v(w(x)y)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(uv(w)x)y(z))))\") == \"a((b)c)d(e(f)g)h(i(j(k(l)m)n)o(p(q(r)s)t(uv(w)x)y(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)st(u)v(w)xy(z)\"\n assert candidate(s = \"a(b(c)d(e(f)g(h)i)j)k\") == \"a(b(c)d(e(f)g(h)i)j)k\"\n assert candidate(s = \"(())((()())())(()(()))(()(()())())(()(()))(()(()())())\") == \"(())((()())())(()(()))(()(()())())(()(()))(()(()())())\"\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)))\"\n assert candidate(s = \"(a(b(c(d(e(f(g(h)i)j)k)l)m)n)o(p)\") == \"a(b(c(d(e(f(g(h)i)j)k)l)m)n)o(p)\"\n assert candidate(s = \"(x(y(z)))a(b(c)d(e(f)g)h)i)j)k\") == \"(x(y(z)))a(b(c)d(e(f)g)h)ijk\"\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)\"\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)nopqrstuvwxyz\"\n assert candidate(s = \"((((((((((a))))))))))\") == \"((((((((((a))))))))))\"\n assert candidate(s = \"a(b(c)d(e(f)g)h)i(j(k(l)m)n)o\") == \"a(b(c)d(e(f)g)h)i(j(k(l)m)n)o\"\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)op(q(r)s)t(u(v(w)x)y(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)op(q(r)s)t(u(v(w)x)y(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)\") == \"abcde(f(g(h)i(j(k(l)m)n)o(p)q(r)s)t(u)v(w)x(y)z)\"\n assert candidate(s = \"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)mnopqrstuvwxyz\"\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)mnopqrstuvwxyz\"\n assert candidate(s = \"((abc)(def))ghi(jkl(mno)pqr)stu(vwx(yz)\") == \"((abc)(def))ghi(jkl(mno)pqr)stuvwx(yz)\"\n assert candidate(s = \"((a(b)c)d)e(f(g(h)i)j)k(lmno)p(q(rst)uvw)x(y(z))\") == \"((a(b)c)d)e(f(g(h)i)j)k(lmno)p(q(rst)uvw)x(y(z))\"\n assert candidate(s = \"((((((((a))))))))\") == \"((((((((a))))))))\"\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))\"\n assert candidate(s = \"(())((())())(((())))\") == \"(())((())())(((())))\"\n assert candidate(s = \"a((((((((((b))))))))))\") == \"a((((((((((b))))))))))\"\n assert candidate(s = \"((((a)bb)ccc)d)eeee(f)ggg(h)iii\") == \"((((a)bb)ccc)d)eeee(f)ggg(h)iii\"\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\"\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)cd(e(f(g)h)i(j(k(l)m)n)o(p)q(r)s)t(u)v(w)x(y)z\"\n assert candidate(s = \"abc(def(ghi)jkl)mno(pqr)stu(vwxyz)\") == \"abc(def(ghi)jkl)mno(pqr)stu(vwxyz)\"\n assert candidate(s = \"((a(b)c)d(e(f)g)h(i)j)k(l(m)n)o(p)q(r)s)t\") == \"((a(b)c)d(e(f)g)h(i)j)k(l(m)n)o(p)q(r)st\"\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)st(u)v(w(x)y)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)st(u)v(w)x(y)z\"\n assert candidate(s = \"(abc(def(ghi(jkl(mnopqr(stu(vwx(yz)))))))\") == \"abc(def(ghi(jkl(mnopqr(stu(vwx(yz)))))))\"\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\"\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)\"\n assert candidate(s = \"((((((((((((((((((((((()))))))))))))))))))))))))\") == \"((((((((((((((((((((((()))))))))))))))))))))))\"\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)hi(j(k(l)m)n)o(p)q(r)st(u)v(w(x)y)z\"\n assert candidate(s = \"((((((((((a))))))))))b\") == \"((((((((((a))))))))))b\"\n assert candidate(s = \"()()()((()))(())(((()))(()(()))(())(()))\") == \"()()()((()))(())(((()))(()(()))(())(()))\"\n assert candidate(s = \"((((((((((()))))))))))\") == \"((((((((((()))))))))))\"\n assert candidate(s = \"(((abc)def)ghijklmnopqrst)uv(wxyz)\") == \"(((abc)def)ghijklmnopqrst)uv(wxyz)\"\n assert candidate(s = \"abc)def(ghi)jkl(mno)pqr(stu)vwx(yz\") == \"abcdef(ghi)jkl(mno)pqr(stu)vwxyz\"\n assert candidate(s = \"((a)(b)(c)(d))\") == \"((a)(b)(c)(d))\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz(abcdefghijklmnopqrstuvwxyz)\") == \"abcdefghijklmnopqrstuvwxyz(abcdefghijklmnopqrstuvwxyz)\"\n assert candidate(s = \"((((((((((((((((((((()))))))))))))))))))))))))))))()\") == \"((((((((((((((((((((()))))))))))))))))))))()\"\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)\"\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))\"\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\"\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)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)u)v)w)x)yz\"\n assert candidate(s = \"((((((a(b)c)d))))))\") == \"((((((a(b)c)d)))))\"\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))))\") == \"ab(c)d(e(f(g(h)i(j(k(l)m)n)o(p)q(r)s)t(u)v(w)x(y(z))))\"\n assert candidate(s = \"((((((((((((((((((((((()\") == \"()\"\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)cd(e(f)g(h)i(j(k(l)m)n)o(p)q(r)s)t(u)v(w)x(y)z\"\n assert candidate(s = \"(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(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)st(u)v(w(x)y)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(abc)\") == \"a(b(c)d(e(f(g(h)i)j)k)l)mnopqrstuvwxyz(abc)\"\n assert candidate(s = \"((a(b)c)d(e(f)g)h)i(j(k(l)m)n)o(p)\") == \"((a(b)c)d(e(f)g)h)i(j(k(l)m)n)o(p)\"\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)nopqrstuvwxyz\"\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)\"\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)abc(def)\") == \"(a(b(c)d(e(f(g(h)i)j)k)l)m)nopqrstuvwxyzabc(def)\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz)abcdefghijklmnopqrstuvwxyz(\") == \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\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)\"\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)\"\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)st(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(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)abc\") == \"(a(b(c)d(e(f(g(h)i)j)k)l)m)nopqrstuvwxyzabc\"\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))))\") == \"ab(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", "comparison": "exact"}, "public_tests": ["\"lee(t(c)o)de)\"", "\"a)b(c)d\"", "\"))((\""], "hints": ["Each prefix of a balanced parentheses has a number of open parentheses greater or equal than closed parentheses, similar idea with each suffix.", "Check the array from left to right, remove characters that do not meet the property mentioned above, same idea in backward way."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minRemoveToMakeValid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:33+00:00", "tests_total": 77, "tests_dropped": 1, "flags": ["multiple_answers"], "topic_tags": ["string", "stack"]}, "language": "python", "interface": {"raw_signature": "def minRemoveToMakeValid(self, s: str) -> str:", "container": "Solution", "callable": "minRemoveToMakeValid", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1250, "task_id": "check-if-it-is-a-good-array", "difficulty": "Hard", "problem_description": "Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the array by any possible subset and multiplicand.\n\nReturn True if the array is good otherwise return False.\n\nExample 1:\n\nInput: nums = [12,5,7,23]\nOutput: true\nExplanation: Pick numbers 5 and 7.\n5*3 + 7*(-2) = 1\n\nExample 2:\n\nInput: nums = [29,6,10]\nOutput: true\nExplanation: Pick numbers 29, 6 and 10.\n29*1 + 6*(-3) + 10*(-1) = 1\n\nExample 3:\n\nInput: nums = [3,6]\nOutput: false\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 13, 19]) == True\n assert candidate(nums = [100, 200, 300, 400]) == False\n assert candidate(nums = [7, 13, 19, 29]) == True\n assert candidate(nums = [29, 6, 10]) == True\n assert candidate(nums = [7, 14, 21, 35]) == False\n assert candidate(nums = [2, 4, 6, 8, 10]) == False\n assert candidate(nums = [7, 14, 21, 28]) == False\n assert candidate(nums = [2, 3, 5]) == True\n assert candidate(nums = [1]) == True\n assert candidate(nums = [1000000000]) == False\n assert candidate(nums = [11, 22, 33, 44]) == False\n assert candidate(nums = [3, 6]) == False\n assert candidate(nums = [12, 5, 7, 23]) == True\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == False\n assert candidate(nums = [100, 200, 300]) == False\n assert candidate(nums = [5, 5, 5, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [3, 5, 7, 11, 13]) == True\n assert candidate(nums = [17, 19, 23, 29]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == False\n assert candidate(nums = [8, 12, 16, 20]) == False\n assert candidate(nums = [7, 14, 21, 28, 35]) == False\n assert candidate(nums = [5, 10, 15]) == False\n assert candidate(nums = [5, 10, 15, 20, 25]) == False\n assert candidate(nums = [11, 22, 33, 44, 55]) == False\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [11, 13, 17, 19]) == True\n assert candidate(nums = [5]) == False\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1]) == True\n assert candidate(nums = [123456789, 987654321, 246813579, 864204864]) == False\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == False\n assert candidate(nums = [97, 101, 103, 107, 109, 113, 127, 131, 137, 139]) == True\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == False\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(nums = [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]) == True\n assert candidate(nums = [13195, 26390, 39585, 52780, 65975, 79170, 92365, 105560, 118755, 131950]) == False\n assert candidate(nums = [13, 17, 19, 23, 29]) == True\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139]) == True\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444]) == False\n assert candidate(nums = [4, 9, 25, 49, 121, 169, 289, 361]) == True\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == False\n assert candidate(nums = [9973, 9967, 9959, 9949, 9941, 9931, 9929, 9923, 9919, 9907]) == True\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42]) == False\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(nums = [13, 17, 19, 23, 29]) == True\n assert candidate(nums = [131, 137, 139, 149, 151, 157, 163, 167, 173, 179]) == True\n assert candidate(nums = [8, 14, 21, 35, 56]) == True\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == False\n assert candidate(nums = [17, 23, 19, 5, 3, 2]) == True\n assert candidate(nums = [7, 21, 35, 56, 112, 140]) == False\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == False\n assert candidate(nums = [13, 17, 19, 23, 29, 31]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == False\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333]) == False\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == False\n assert candidate(nums = [41, 43, 47, 53, 59, 61, 67, 71, 73, 79]) == True\n assert candidate(nums = [101, 103, 107, 109, 113]) == True\n assert candidate(nums = [42, 105, 210, 35]) == False\n assert candidate(nums = [49, 77, 91, 119, 133, 161, 187, 203, 221, 247, 259, 287, 301, 329, 343, 371, 399, 413, 437, 469, 497, 511, 539, 553, 581]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == 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]) == True\n assert candidate(nums = [3, 5, 8, 11, 19]) == True\n assert candidate(nums = [555, 1110, 1665, 2220, 2775]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [999999999, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == True\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == False\n assert candidate(nums = [15, 21, 35, 525, 630]) == True\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == False\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\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]) == False\n assert candidate(nums = [17, 23, 41, 59]) == True\n assert candidate(nums = [1000000000, 999999999, 1, 2]) == True\n assert candidate(nums = [8, 12, 18, 24, 30, 36, 42, 48, 54]) == False\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == False\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == False\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == True\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == False\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == False\n assert candidate(nums = [123, 456, 789, 101, 137]) == True\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == False\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(nums = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == True\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == False\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == True\n assert candidate(nums = [13, 17, 19, 23, 29, 31]) == True\n assert candidate(nums = [41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [35, 105, 175, 245, 315]) == False\n assert candidate(nums = [97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == True\n assert candidate(nums = [17, 29, 41, 53, 67, 83]) == True\n assert candidate(nums = [3, 9, 27, 81, 243]) == False\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960, 1020, 1080, 1140, 1200]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001]) == True\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == False\n assert candidate(nums = [31, 37, 41, 43, 47, 53, 59]) == True\n assert candidate(nums = [123456789, 987654321, 234567891, 345678912]) == False\n assert candidate(nums = [37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127]) == True\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555]) == False\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561]) == False\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009]) == True\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]) == True\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020]) == True\n assert candidate(nums = [41, 43, 47, 53, 59, 61]) == True\n assert candidate(nums = [101, 202, 303, 404, 505]) == 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]) == True\n assert candidate(nums = [89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == False\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(nums = [333333333, 666666667, 333333333, 666666667, 333333333, 666666667, 333333333, 666666667, 333333333, 666666667]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [97, 1, 101, 1, 103, 1, 107, 1, 109, 1]) == True\n assert candidate(nums = [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == True\n assert candidate(nums = [71, 113, 151, 199, 239, 283, 317, 359, 401, 443]) == True\n assert candidate(nums = [17, 31, 41, 43, 59, 61]) == True\n assert candidate(nums = [101, 103, 107, 109, 113]) == True\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == False\n assert candidate(nums = [15, 21, 25, 35, 45]) == True\n assert candidate(nums = [100, 101, 102, 103, 104]) == True\n assert candidate(nums = [3, 5, 7, 11, 13, 17]) == True\n", "comparison": "exact"}, "public_tests": ["[12,5,7,23]", "[29,6,10]", "[3,6]"], "hints": ["Eq. ax+by=1 has solution x, y if gcd(a,b) = 1.", "Can you generalize the formula?. Check Bézout's lemma."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().isGoodArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:35+00:00", "tests_total": 138, "tests_dropped": 10, "flags": [], "topic_tags": ["array", "math", "number-theory", "bezouts-lemma", "euclidean-algorithm", "greatest-common-divisor", "extended-euclidean-algorithm"]}, "language": "python", "interface": {"raw_signature": "def isGoodArray(self, nums: list[int]) -> bool:", "container": "Solution", "callable": "isGoodArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1252, "task_id": "cells-with-odd-values-in-a-matrix", "difficulty": "Easy", "problem_description": "There is an m x n matrix that is initialized to all 0's. There is also a 2D array indices where each indices[i] = [r_i, c_i] represents a 0-indexed location to perform some increment operations on the matrix.\n\nFor each location indices[i], do both of the following:\n\n1. Increment all the cells on row r_i.\n2. Increment all the cells on column c_i.\n\nGiven m, n, and indices, return the number of odd-valued cells in the matrix after applying the increment to all locations in indices.\n\nExample 1:\n\nInput: m = 2, n = 3, indices = [[0,1],[1,1]]\nOutput: 6\nExplanation: Initial matrix = [[0,0,0],[0,0,0]].\nAfter applying first increment it becomes [[1,2,1],[0,1,0]].\nThe final matrix is [[1,3,1],[1,3,1]], which contains 6 odd numbers.\n\nExample 2:\n\nInput: m = 2, n = 2, indices = [[1,1],[0,0]]\nOutput: 0\nExplanation: Final matrix = [[2,2],[2,2]]. There are no odd numbers in the final matrix.\n\nConstraints:\n\n- 1 <= m, n <= 50\n- 1 <= indices.length <= 100\n- 0 <= r_i < m\n- 0 <= c_i < n\n\nFollow up: Could you solve this in O(n + m + indices.length) time with only O(n + m) extra space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 2,n = 3,indices = [[0, 1], [1, 1]]) == 6\n assert candidate(m = 50,n = 50,indices = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 368\n assert candidate(m = 4,n = 5,indices = [[0, 1], [0, 1], [1, 2], [2, 3], [3, 4]]) == 9\n assert candidate(m = 1,n = 1,indices = [[0, 0]]) == 0\n assert candidate(m = 5,n = 4,indices = [[0, 0], [0, 0], [0, 0]]) == 7\n assert candidate(m = 4,n = 5,indices = [[0, 1], [2, 3], [1, 4]]) == 9\n assert candidate(m = 3,n = 4,indices = [[0, 0], [1, 2], [2, 3]]) == 3\n assert candidate(m = 5,n = 5,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(m = 3,n = 4,indices = [[0, 1], [1, 2], [2, 3]]) == 3\n assert candidate(m = 3,n = 3,indices = [[0, 0], [1, 1], [2, 2]]) == 0\n assert candidate(m = 3,n = 4,indices = [[0, 0], [1, 1], [2, 2], [0, 3]]) == 4\n assert candidate(m = 2,n = 2,indices = [[1, 1], [0, 0]]) == 0\n assert candidate(m = 5,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]) == 20\n assert candidate(m = 4,n = 5,indices = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(m = 5,n = 5,indices = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 0\n assert candidate(m = 3,n = 3,indices = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == 0\n assert candidate(m = 8,n = 8,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [7, 0], [0, 3], [3, 0]]) == 24\n assert candidate(m = 7,n = 3,indices = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2]]) == 0\n assert candidate(m = 10,n = 10,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(m = 4,n = 5,indices = [[0, 1], [0, 2], [2, 3], [3, 4], [1, 0]]) == 5\n assert candidate(m = 10,n = 1,indices = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 10\n assert candidate(m = 10,n = 10,indices = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(m = 5,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(m = 5,n = 3,indices = [[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]]) == 0\n assert candidate(m = 4,n = 6,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 5], [1, 4], [2, 3], [3, 2], [0, 1], [1, 0]]) == 12\n assert candidate(m = 8,n = 4,indices = [[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, 0], [4, 1], [4, 2], [4, 3], [5, 0], [5, 1], [5, 2], [5, 3], [6, 0], [6, 1], [6, 2], [6, 3], [7, 0], [7, 1], [7, 2], [7, 3]]) == 0\n assert candidate(m = 5,n = 5,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4], [4, 0]]) == 12\n assert candidate(m = 5,n = 1,indices = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]) == 0\n assert candidate(m = 6,n = 6,indices = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]) == 0\n assert candidate(m = 5,n = 5,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 0\n assert candidate(m = 7,n = 2,indices = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1]]) == 14\n assert candidate(m = 10,n = 10,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 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], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9]]) == 0\n assert candidate(m = 10,n = 10,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == 0\n assert candidate(m = 5,n = 4,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1]]) == 4\n assert candidate(m = 1,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]) == 0\n assert candidate(m = 10,n = 10,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [9, 0]]) == 32\n assert candidate(m = 7,n = 3,indices = [[0, 0], [1, 1], [2, 2], [0, 2], [1, 0], [2, 1]]) == 0\n assert candidate(m = 7,n = 8,indices = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7]]) == 38\n assert candidate(m = 3,n = 7,indices = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [0, 3], [0, 4], [0, 5], [0, 6]]) == 0\n assert candidate(m = 15,n = 15,indices = [[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]]) == 0\n assert candidate(m = 6,n = 6,indices = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [0, 5], [1, 4], [2, 1], [3, 0], [4, 3], [5, 2]]) == 0\n assert candidate(m = 10,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4]]) == 35\n assert candidate(m = 4,n = 5,indices = [[0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [0, 4], [1, 3], [2, 2], [3, 1]]) == 5\n assert candidate(m = 9,n = 7,indices = [[0, 0], [0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 0], [4, 1], [5, 2], [6, 3], [7, 4], [8, 5]]) == 54\n assert candidate(m = 5,n = 3,indices = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2]]) == 0\n assert candidate(m = 4,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [2, 0], [3, 0]]) == 4\n assert candidate(m = 10,n = 10,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 100\n assert candidate(m = 7,n = 7,indices = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0]]) == 0\n assert candidate(m = 5,n = 6,indices = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 5\n assert candidate(m = 8,n = 8,indices = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]]) == 0\n assert candidate(m = 2,n = 7,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == 14\n assert candidate(m = 1,n = 10,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 10\n assert candidate(m = 4,n = 3,indices = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]]) == 12\n assert candidate(m = 4,n = 4,indices = [[0, 0], [0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3]]) == 0\n assert candidate(m = 3,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4]]) == 0\n assert candidate(m = 6,n = 4,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]]) == 24\n assert candidate(m = 50,n = 50,indices = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [2, 0]]) == 192\n assert candidate(m = 6,n = 7,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 6], [1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [0, 0]]) == 11\n assert candidate(m = 30,n = 20,indices = [[0, 0], [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], [6, 18], [6, 19]]) == 480\n assert candidate(m = 4,n = 6,indices = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 2], [3, 3], [0, 3], [1, 4], [2, 5]]) == 12\n assert candidate(m = 6,n = 6,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 5], [5, 0], [0, 4], [4, 0], [0, 3], [3, 0], [0, 2], [2, 0], [0, 1], [1, 0]]) == 0\n assert candidate(m = 10,n = 10,indices = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 0\n assert candidate(m = 7,n = 8,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1]]) == 14\n assert candidate(m = 3,n = 3,indices = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [0, 0], [1, 1], [2, 2]]) == 0\n assert candidate(m = 4,n = 6,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 0\n assert candidate(m = 8,n = 5,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 0], [6, 1], [7, 2]]) == 24\n assert candidate(m = 7,n = 7,indices = [[0, 1], [0, 3], [1, 0], [1, 2], [1, 4], [1, 6], [2, 1], [2, 3], [2, 5], [3, 0], [3, 2], [3, 4], [3, 6], [4, 1], [4, 3], [4, 5], [5, 0], [5, 2], [5, 4], [5, 6], [6, 1], [6, 3], [6, 5]]) == 26\n assert candidate(m = 3,n = 3,indices = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 2], [2, 0]]) == 0\n assert candidate(m = 4,n = 6,indices = [[0, 1], [0, 1], [0, 1], [3, 5], [3, 5]]) == 8\n assert candidate(m = 6,n = 5,indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4]]) == 30\n assert candidate(m = 5,n = 6,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1]]) == 10\n assert candidate(m = 6,n = 4,indices = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [0, 0], [0, 2], [0, 3]]) == 8\n assert candidate(m = 3,n = 3,indices = [[0, 0], [0, 0], [1, 1], [1, 1], [2, 2], [2, 2]]) == 0\n assert candidate(m = 6,n = 6,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 5], [5, 0], [3, 2], [2, 3]]) == 16\n assert candidate(m = 8,n = 8,indices = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]]) == 0\n", "comparison": "exact"}, "public_tests": ["2\n3\n[[0,1],[1,1]]", "2\n2\n[[1,1],[0,0]]"], "hints": ["Simulation : With small constraints, it is possible to apply changes to each row and column and count odd cells after applying it.", "You can accumulate the number you should add to each row and column and then you can count the number of odd cells."], "metadata": {"canonical_parameter_names": ["m", "n", "indices"], "leetcode_dataset_entry_point": "Solution().oddCells", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:38+00:00", "tests_total": 75, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def oddCells(self, m: int, n: int, indices: list[list[int]]) -> int:", "container": "Solution", "callable": "oddCells", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "indices", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1253, "task_id": "reconstruct-a-2-row-binary-matrix", "difficulty": "Medium", "problem_description": "Given the following details of a matrix with n columns and 2 rows :\n\n- The matrix is a binary matrix, which means each element in the matrix can be 0 or 1.\n- The sum of elements of the 0-th(upper) row is given as upper.\n- The sum of elements of the 1-st(lower) row is given as lower.\n- The sum of elements in the i-th column(0-indexed) is colsum[i], where colsum is given as an integer array with length n.\n\nYour task is to reconstruct the matrix with upper, lower and colsum.\n\nReturn it as a 2-D integer array.\n\nIf there are more than one valid solution, any of them will be accepted.\n\nIf no valid solution exists, return an empty 2-D array.\n\nExample 1:\n\nInput: upper = 2, lower = 1, colsum = [1,1,1]\nOutput: [[1,1,0],[0,0,1]]\nExplanation: [[1,0,1],[0,1,0]], and [[0,1,1],[1,0,0]] are also correct answers.\n\nExample 2:\n\nInput: upper = 2, lower = 3, colsum = [2,2,1,1]\nOutput: []\n\nExample 3:\n\nInput: upper = 5, lower = 5, colsum = [2,1,2,0,1,0,1,2,0,1]\nOutput: [[1,1,1,0,1,0,0,1,0,0],[1,0,1,0,0,0,1,1,0,1]]\n\nConstraints:\n\n- 1 <= colsum.length <= 10^5\n- 0 <= upper, lower <= colsum.length\n- 0 <= colsum[i] <= 2\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(upper = 2,lower = 3,colsum = [2, 2, 1, 1]) == []\n assert candidate(upper = 1,lower = 1,colsum = [1, 0, 1]) == [[0, 0, 1], [1, 0, 0]]\n assert candidate(upper = 4,lower = 2,colsum = [2, 1, 1, 0, 0]) == []\n assert candidate(upper = 3,lower = 3,colsum = [2, 0, 2, 0, 2]) == [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]\n assert candidate(upper = 0,lower = 0,colsum = [0, 0, 0, 0]) == [[0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(upper = 5,lower = 5,colsum = [2, 1, 2, 0, 1, 0, 1, 2, 0, 1]) == [[1, 0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 0, 0]]\n assert candidate(upper = 2,lower = 1,colsum = [1, 1, 1]) == [[1, 0, 1], [0, 1, 0]]\n assert candidate(upper = 10,lower = 10,colsum = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 0,lower = 0,colsum = [0, 0, 0, 0, 0]) == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(upper = 5,lower = 5,colsum = [2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 15,lower = 5,colsum = [2, 1, 2, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(upper = 3,lower = 2,colsum = [2, 1, 1, 0, 1]) == [[1, 1, 0, 0, 1], [1, 0, 1, 0, 0]]\n assert candidate(upper = 3,lower = 3,colsum = [1, 1, 1, 1, 1, 1]) == [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]\n assert candidate(upper = 6,lower = 4,colsum = [2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(upper = 5,lower = 5,colsum = [2, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == []\n assert candidate(upper = 6,lower = 4,colsum = [2, 2, 1, 1, 0, 0, 1]) == []\n assert candidate(upper = 10,lower = 6,colsum = [2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0]) == []\n assert candidate(upper = 7,lower = 5,colsum = [1, 2, 1, 2, 1, 1, 1]) == []\n assert candidate(upper = 5,lower = 5,colsum = [2, 1, 2, 0, 1, 0, 1, 2, 0, 1]) == [[1, 0, 1, 0, 1, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 0, 0]]\n assert candidate(upper = 5,lower = 5,colsum = [0, 1, 2, 0, 0, 1, 2, 1, 0]) == []\n assert candidate(upper = 8,lower = 2,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 3,lower = 1,colsum = [1, 2, 1, 1, 0]) == []\n assert candidate(upper = 3,lower = 2,colsum = [1, 1, 1, 1, 0]) == []\n assert candidate(upper = 1,lower = 1,colsum = [2]) == [[1], [1]]\n assert candidate(upper = 3,lower = 6,colsum = [2, 2, 1, 1, 1, 2, 1]) == []\n assert candidate(upper = 5,lower = 5,colsum = [2, 1, 0, 1, 0, 2, 1, 0]) == []\n assert candidate(upper = 2,lower = 2,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 1,lower = 2,colsum = [1, 1, 0, 0, 1]) == [[0, 0, 0, 0, 1], [1, 1, 0, 0, 0]]\n assert candidate(upper = 4,lower = 4,colsum = [2, 0, 1, 1, 2, 1, 1, 0]) == [[1, 0, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1, 0, 0]]\n assert candidate(upper = 1,lower = 1,colsum = [2, 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]]\n assert candidate(upper = 2,lower = 2,colsum = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]\n assert candidate(upper = 3,lower = 3,colsum = [2, 0, 1, 1, 2]) == [[1, 0, 0, 1, 1], [1, 0, 1, 0, 1]]\n assert candidate(upper = 5,lower = 5,colsum = [1, 2, 0, 2, 1, 0, 1]) == []\n assert candidate(upper = 8,lower = 8,colsum = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == []\n assert candidate(upper = 4,lower = 4,colsum = [2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]) == []\n assert candidate(upper = 6,lower = 6,colsum = [2, 1, 0, 2, 1, 0, 1, 1, 0, 0, 2, 1]) == []\n assert candidate(upper = 7,lower = 3,colsum = [1, 0, 1, 2, 1, 0, 1, 1, 0]) == []\n assert candidate(upper = 3,lower = 3,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 3,lower = 2,colsum = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(upper = 5,lower = 5,colsum = [0, 1, 2, 1, 1, 0, 2, 0]) == []\n assert candidate(upper = 3,lower = 4,colsum = [1, 2, 1, 1, 0, 1]) == []\n assert candidate(upper = 6,lower = 4,colsum = [2, 1, 1, 1, 1, 2, 0, 1, 1, 0]) == [[1, 1, 1, 0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1, 0, 0]]\n assert candidate(upper = 7,lower = 3,colsum = [1, 2, 1, 1, 1, 0, 0, 2]) == []\n assert candidate(upper = 10,lower = 10,colsum = [2, 2, 2, 2, 2, 0, 0, 0, 0, 0]) == []\n assert candidate(upper = 5,lower = 3,colsum = [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]) == []\n assert candidate(upper = 5,lower = 5,colsum = [0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(upper = 9,lower = 9,colsum = [2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == []\n assert candidate(upper = 8,lower = 6,colsum = [2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]) == []\n assert candidate(upper = 8,lower = 7,colsum = [2, 2, 2, 0, 1, 1, 0, 1]) == []\n assert candidate(upper = 10,lower = 10,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 2]) == []\n assert candidate(upper = 5,lower = 4,colsum = [2, 1, 1, 1, 0, 1]) == []\n assert candidate(upper = 8,lower = 4,colsum = [2, 2, 2, 2, 0, 0, 0, 0]) == []\n assert candidate(upper = 4,lower = 5,colsum = [1, 1, 1, 1, 2, 1, 0, 1]) == []\n assert candidate(upper = 5,lower = 3,colsum = [1, 1, 1, 2, 1, 2, 0, 0]) == [[1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0]]\n assert candidate(upper = 10,lower = 5,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == []\n assert candidate(upper = 7,lower = 3,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[1, 1, 1, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0, 1, 0, 1, 0]]\n assert candidate(upper = 3,lower = 3,colsum = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [[0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]]\n assert candidate(upper = 10,lower = 10,colsum = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 8,lower = 8,colsum = [1, 2, 2, 1, 2, 1, 1, 2]) == []\n assert candidate(upper = 1,lower = 1,colsum = [0, 0, 0, 0, 0, 2]) == [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1]]\n assert candidate(upper = 0,lower = 0,colsum = [0, 0, 0, 0, 0]) == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(upper = 3,lower = 4,colsum = [2, 1, 2, 0, 1]) == []\n assert candidate(upper = 10,lower = 10,colsum = [2, 1, 2, 1, 0, 0, 0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0, 1, 1, 0]) == []\n assert candidate(upper = 7,lower = 3,colsum = [1, 2, 1, 1, 0, 2, 1, 0]) == []\n assert candidate(upper = 7,lower = 8,colsum = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(upper = 7,lower = 5,colsum = [1, 2, 2, 1, 1, 0, 0, 0, 1, 1]) == []\n assert candidate(upper = 3,lower = 3,colsum = [1, 1, 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(upper = 5,lower = 5,colsum = [2, 0, 2, 0, 1, 1]) == []\n assert candidate(upper = 7,lower = 3,colsum = [2, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 1]) == []\n assert candidate(upper = 10,lower = 5,colsum = [2, 2, 2, 1, 1, 1, 1, 1, 1, 0]) == []\n assert candidate(upper = 6,lower = 6,colsum = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == []\n assert candidate(upper = 4,lower = 4,colsum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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", "comparison": "exact"}, "public_tests": ["2\n1\n[1,1,1]", "2\n3\n[2,2,1,1]", "5\n5\n[2,1,2,0,1,0,1,2,0,1]"], "hints": ["You cannot do anything about colsum[i] = 2 case or colsum[i] = 0 case. Then you put colsum[i] = 1 case to the upper row until upper has reached. Then put the rest into lower row.", "Fill 0 and 2 first, then fill 1 in the upper row or lower row in turn but be careful about exhausting permitted 1s in each row."], "metadata": {"canonical_parameter_names": ["upper", "lower", "colsum"], "leetcode_dataset_entry_point": "Solution().reconstructMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:40+00:00", "tests_total": 72, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "matrix"]}, "language": "python", "interface": {"raw_signature": "def reconstructMatrix(self, upper: int, lower: int, colsum: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "reconstructMatrix", "parameters": [{"name": "upper", "type": "int"}, {"name": "lower", "type": "int"}, {"name": "colsum", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1254, "task_id": "number-of-closed-islands", "difficulty": "Medium", "problem_description": "Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directionally connected group of 0s and a closed island is an island totally (all left, top, right, bottom) surrounded by 1s.\n\nReturn the number of closed islands.\n\nExample 1:\n\nInput: grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]]\nOutput: 2\nExplanation:\nIslands in gray are closed because they are completely surrounded by water (group of 1s).\n\nExample 2:\n\nInput: grid = [[0,0,1,0,0],[0,1,0,1,0],[0,1,1,1,0]]\nOutput: 1\n\nExample 3:\n\nInput: grid = [[1,1,1,1,1,1,1],\n [1,0,0,0,0,0,1],\n [1,0,1,1,1,0,1],\n [1,0,1,0,1,0,1],\n [1,0,1,1,1,0,1],\n [1,0,0,0,0,0,1],\n [1,1,1,1,1,1,1]]\nOutput: 2\n\nConstraints:\n\n- 1 <= grid.length, grid[0].length <= 100\n- 0 <= grid[i][j] <=1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\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]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1, 1, 0], [1, 0, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]]) == 0\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, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 1, 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]]) == 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, 0, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\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, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 0, 1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0], [1, 0, 1, 1, 1, 1, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 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, 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, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1, 1], [0, 0, 1, 0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 1, 0], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1, 1]]) == 3\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, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 0, 1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 1, 1, 1, 0, 1]]) == 0\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, 1, 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]]) == 2\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 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]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 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, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]]) == 0\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, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\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, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 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]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1, 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, 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]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1]]) == 0\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, 0, 1, 0, 1, 1, 1, 0, 1, 0, 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, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 3\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, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 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]]) == 2\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 1, 0]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 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]]) == 3\n assert candidate(grid = [[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, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 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, 0, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 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, 1, 1, 1]]) == 3\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]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 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, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 1, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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\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, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[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, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1], [1, 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]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 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, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 1, 0, 1, 0, 1, 1, 1, 1], [1, 1, 1, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\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, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 31\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, 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, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 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], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 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, 1], [1, 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(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, 0, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 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, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 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], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]]", "[[0,0,1,0,0],[0,1,0,1,0],[0,1,1,1,0]]", "[[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]]"], "hints": ["Exclude connected group of 0s on the corners because they are not closed island.", "Return number of connected component of 0s on the grid."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().closedIsland", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:43+00:00", "tests_total": 63, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def closedIsland(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "closedIsland", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1255, "task_id": "maximum-score-words-formed-by-letters", "difficulty": "Hard", "problem_description": "Given a list of words, list of single letters (might be repeating) and score of every character.\n\nReturn the maximum score of any valid set of words formed by using the given letters (words[i] cannot be used two or more times).\n\nIt is not necessary to use all characters in letters and each letter can only be used once. Score of letters 'a', 'b', 'c', ... ,'z' is given by score[0], score[1], ... , score[25] respectively.\n\nExample 1:\n\nInput: words = [\"dog\",\"cat\",\"dad\",\"good\"], letters = [\"a\",\"a\",\"c\",\"d\",\"d\",\"d\",\"g\",\"o\",\"o\"], score = [1,0,9,5,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0]\nOutput: 23\nExplanation:\nScore a=1, c=9, d=5, g=3, o=2\nGiven letters, we can form the words \"dad\" (5+1+5) and \"good\" (3+2+2+5) with a score of 23.\nWords \"dad\" and \"dog\" only get a score of 21.\n\nExample 2:\n\nInput: words = [\"xxxz\",\"ax\",\"bx\",\"cx\"], letters = [\"z\",\"a\",\"b\",\"c\",\"x\",\"x\",\"x\"], score = [4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,10]\nOutput: 27\nExplanation:\nScore a=4, b=4, c=4, x=5, z=10\nGiven letters, we can form the words \"ax\" (4+5), \"bx\" (4+5) and \"cx\" (4+5) with a score of 27.\nWord \"xxxz\" only get a score of 25.\n\nExample 3:\n\nInput: words = [\"leetcode\"], letters = [\"l\",\"e\",\"t\",\"c\",\"o\",\"d\"], score = [0,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0]\nOutput: 0\nExplanation:\nLetter \"e\" can only be used once.\n\nConstraints:\n\n- 1 <= words.length <= 14\n- 1 <= words[i].length <= 15\n- 1 <= letters.length <= 100\n- letters[i].length == 1\n- score.length == 26\n- 0 <= score[i] <= 10\n- words[i], letters[i] contains only lower case English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['xxxz', 'ax', 'bx', 'cx'],letters = ['z', 'a', 'b', 'c', 'x', 'x', 'x'],score = [4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10]) == 27\n assert candidate(words = ['leetcode'],letters = ['l', 'e', 't', 'c', 'o', 'd'],score = [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(words = ['dog', 'cat', 'dad', 'good'],letters = ['a', 'a', 'c', 'd', 'd', 'd', 'g', 'o', 'o'],score = [1, 0, 9, 5, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 23\n assert candidate(words = ['quartz', 'pearl', 'opal'],letters = ['q', 'u', 'a', 'r', 't', 'z', 'p', 'e', 'a', 'r', 'l', 'o', 'p', 'a', 'l'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 38\n assert candidate(words = ['programming', 'code', 'python', 'challenge'],letters = ['a', 'c', 'd', 'e', 'e', 'g', 'h', 'i', 'l', 'l', 'm', 'n', 'n', 'n', 'o', 'o', 'p', 'p', 'r', 'r', 'r', 's', 't', 'u', 'y', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 24\n assert candidate(words = ['university', 'college', 'school'],letters = ['u', 'n', 'i', 'v', 'e', 'r', 's', 'i', 't', 'y', 'c', 'o', 'l', 'l', 'e', 'g', 'e', 's', 'c', 'h', 'o', 'o', 'l'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 38\n assert candidate(words = ['zebra', 'elephant', 'giraffe', 'hippo'],letters = ['a', 'e', 'e', 'f', 'g', 'h', 'i', 'i', 'l', 'n', 'o', 'p', 'p', 'r', 'r', 's', 't', 'u', 'z', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 13\n assert candidate(words = ['optimization', 'performance', 'scalability', 'expert', 'knowledge', 'skill'],letters = ['o', 'p', 't', 'i', 'm', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'p', 'e', 'r', 'f', 'o', 'r', 'm', 'a', 'n', 'c', 'e', 's', 'c', 'a', 'l', 'a', 'b', 'i', 'l', 'i', 't', 'y', 'e', 'x', 'p', 'e', 'r', 't', 'k', 'n', 'o', 'w', 'l', 'e', 'd', 'g', 'e', 's', 'k', 'i', 'l', 'l'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 4, 8, 8, 10]) == 118\n assert candidate(words = ['onomatopoeia', 'palindrome', 'multifarious'],letters = ['o', 'n', 'o', 'm', 'a', 't', 'o', 'p', 'o', 'e', 'i', 'a', 'p', 'a', 'l', 'i', 'n', 'd', 'r', 'o', 'm', 'e', 'm', 'u', 'l', 't', 'i', 'f', 'a', 'r', 'i', 'o', 'u', 's'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 56\n assert candidate(words = ['optimization', 'performance', 'efficiency'],letters = ['o', 'p', 't', 'i', 'm', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'p', 'e', 'r', 'f', 'o', 'r', 'm', 'a', 'n', 'c', 'e', 'e', 'f', 'f', 'i', 'c', 'i', 'e', 'n', 'c', 'y'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 66\n assert candidate(words = ['mississippi', 'alabama', 'tennessee'],letters = ['m', 'i', 's', 's', 'i', 's', 's', 'i', 'p', 'p', 'i', 'a', 'l', 'a', 'b', 'a', 'm', 'a', 't', 'e', 'n', 'n', 'e', 's', 's', 'e'],score = [3, 1, 9, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 5, 5, 0, 2, 3, 9]) == 88\n assert candidate(words = ['algorithm', 'datastructure', 'machinelearning'],letters = ['a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm', 'd', 'a', 't', 'a', 's', 't', 'r', 'u', 'c', 't', 'u', 'r', 'e', 'm', 'a', 'c', 'h', 'i', 'n', 'e', 'l', 'e', 'a', 'r', 'n', 'i', 'n', 'g'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 65\n assert candidate(words = ['amazing', 'zebra', 'apple'],letters = ['a', 'm', 'a', 'z', 'i', 'n', 'g', 'z', 'e', 'b', 'r', 'a', 'a', 'p', 'p', 'l'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 38\n assert candidate(words = ['syzygy', 'zygote', 'zygomycete'],letters = ['s', 'y', 'z', 'y', 'g', 'y', 'z', 'y', 'g', 'o', 't', 'e', 'z', 'y', 'g', 'o', 'm', 'y', 'c', 'e', 't', 'e'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 56\n assert candidate(words = ['zebra', 'monkey', 'giraffe'],letters = ['z', 'e', 'r', 'b', 'a', 'o', 'n', 'k', 'm', 'y', 'g', 'i', 'r', 'a', 'f', 'f', 'e'],score = [1, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0]) == 12\n assert candidate(words = ['algorithm', 'data', 'structure', 'software'],letters = ['a', 'a', 'a', 'c', 'd', 'd', 'e', 'g', 'h', 'i', 'i', 'l', 'm', 'n', 'o', 'o', 'o', 'r', 's', 's', 's', 't', 'u', 'w', 'y'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 15\n assert candidate(words = ['abacaxi', 'kiwi', 'pineapple'],letters = ['a', 'b', 'a', 'c', 'a', 'x', 'i', 'k', 'i', 'w', 'i', 'p', 'i', 'n', 'e', 'a', 'p', 'p', 'l', 'e'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 41\n assert candidate(words = ['kitten', 'puppy', 'dog', 'cat'],letters = ['a', 'c', 'd', 'd', 'd', 'g', 'k', 'n', 'o', 'p', 'p', 'p', 'p', 'p', 't', 'u', 'y', 'y'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 24\n assert candidate(words = ['hello', 'world', 'python', 'java'],letters = ['h', 'e', 'l', 'l', 'o', 'w', 'r', 'd', 'p', 'y', 't', 'h', 'o', 'n', 'j', 'a', 'v'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 26\n assert candidate(words = ['algorithm', 'data', 'structure'],letters = ['a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm', 'd', 'a', 't', 'a', 's', 't', 'r', 'u', 'c', 't', 'u', 'r', 'e'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 4, 8, 8, 10]) == 33\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],letters = ['a', 'a', 'b', 'b', 'c', 'd', 'e', 'e', 'e', 'h', 'i', 'l', 'n', 'n', 'p', 'r', 't', 'u'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 5\n assert candidate(words = ['zebra', 'elephant', 'giraffe'],letters = ['z', 'e', 'b', 'r', 'a', 'e', 'l', 'p', 'h', 'a', 'n', 't', 'g', 'i', 'r', 'a', 'f', 'f', 'e'],score = [5, 1, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 36\n assert candidate(words = ['xylophone', 'guitar', 'piano', 'drums'],letters = ['a', 'd', 'e', 'g', 'h', 'i', 'l', 'm', 'n', 'n', 'n', 'o', 'o', 'p', 'p', 'r', 's', 't', 'u', 'u', 'x', 'y', 'y', 'y', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 32\n assert candidate(words = ['complexity', 'theory', 'graph', 'tree'],letters = ['a', 'b', 'c', 'c', 'd', 'd', 'e', 'e', 'f', 'g', 'g', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'n', 'n', 'o', 'o', 'o', 'o', 'p', 'q', 'r', 'r', 's', 's', 't', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 5]) == 19\n assert candidate(words = ['expert', 'knowledge', 'skill'],letters = ['e', 'x', 'p', 'e', 'r', 't', 'k', 'n', 'o', 'w', 'l', 'e', 'd', 'g', 'e', 's', 'k', 'i', 'l', 'l'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 4, 8, 8, 10]) == 45\n assert candidate(words = ['programming', 'contest', 'challenge'],letters = ['p', 'r', 'o', 'g', 'a', 'm', 'm', 'i', 'n', 'g', 'c', 'o', 'n', 't', 'e', 's', 't', 'c', 'h', 'a', 'l', 'l', 'e', 'n', 'g', 'e'],score = [3, 5, 1, 3, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10, 8, 7, 5, 4, 4, 3, 7, 2, 9, 4]) == 60\n assert candidate(words = ['fantastic', 'extraordinary', 'amazing'],letters = ['f', 'a', 'n', 't', 'a', 's', 't', 'i', 'c', 'e', 'x', 't', 'r', 'o', 'd', 'i', 'n', 'a', 'r', 'y', 'a', 'm', 'a', 'z', 'i', 'n', 'g'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 39\n assert candidate(words = ['complex', 'challenging', 'problems', 'solutions'],letters = ['c', 'o', 'm', 'p', 'l', 'e', 'x', 'c', 'h', 'a', 'l', 'l', 'e', 'n', 'g', 'i', 'n', 'g', 'p', 'r', 'o', 'b', 'l', 'e', 'm', 's', 'o', 'l', 'u', 't', 'i', 'o', 'n', 's'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 54\n assert candidate(words = ['fantastic', 'breathtaking', 'transformation', 'unbelievable'],letters = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'c', 'd', 'd', 'e', 'e', 'e', 'e', 'f', 'g', 'h', 'i', 'i', 'i', 'k', 'l', 'm', 'n', 'n', 'n', 'o', 'o', 'o', 'o', 'p', 'r', 'r', 's', 't', 't', 't', 'u', 'u', 'v', 'w', 'x', 'y', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 25\n assert candidate(words = ['python', 'java', 'csharp', 'javascript'],letters = ['a', 'a', 'a', 'b', 'c', 'c', 'd', 'd', 'e', 'e', 'f', 'g', 'g', 'h', 'i', 'i', 'j', 'j', 'k', 'k', 'l', 'm', 'n', 'n', 'o', 'o', 'p', 'p', 'q', 'q', 'r', 's', 't', 't', 'u', 'u', 'v', 'w', 'x', 'y', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 5]) == 38\n assert candidate(words = ['optimization', 'algorithm', 'data', 'structure'],letters = ['a', 'a', 'a', 'b', 'c', 'c', 'd', 'd', 'e', 'e', 'g', 'h', 'i', 'i', 'l', 'm', 'n', 'o', 'o', 'p', 'p', 'r', 's', 't', 't', 'u', 'v', 'x', 'y', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 5]) == 20\n assert candidate(words = ['zebra', 'xylophone', 'quartz', 'jigsaw'],letters = ['a', 'a', 'e', 'g', 'h', 'i', 'j', 'j', 'k', 'l', 'o', 'o', 'p', 'q', 'r', 's', 't', 'u', 'w', 'x', 'y', 'z', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 41\n assert candidate(words = ['wizard', 'oracle', 'sorcerer'],letters = ['w', 'i', 'z', 'a', 'r', 'd', 'o', 'r', 'a', 'c', 'l', 'e', 's', 'o', 'r', 'c', 'e', 'r', 'e'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 10]) == 27\n assert candidate(words = ['programming', 'code', 'hackathon', 'python'],letters = ['p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g', 'c', 'o', 'd', 'e', 'h', 'a', 'c', 'k', 'a', 't', 'h', 'o', 'n', 'p', 'y', 't', 'h', 'o', 'n'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 67\n assert candidate(words = ['orange', 'grape', 'apple', 'banana'],letters = ['a', 'a', 'a', 'b', 'e', 'g', 'n', 'n', 'n', 'o', 'p', 'r', 'r', 'r', 's', 't', 'u', 'u', 'u', 'u', 'u'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 8\n assert candidate(words = ['abracadabra', 'alakazam', 'sorcery', 'spellbound'],letters = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'c', 'd', 'e', 'e', 'e', 'i', 'l', 'l', 'l', 'm', 'o', 'o', 'o', 'p', 'r', 'r', 'r', 's', 's', 't', 'u', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 18\n assert candidate(words = ['abcdefghij', 'klmnopqrstu', 'vwxyz'],letters = ['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'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 74\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'mnopqrstuv'],letters = ['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'],score = [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]) == 110\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],letters = ['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'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 90\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],letters = ['a', 'a', 'a', 'b', 'c', 'd', 'e', 'e', 'e', 'e', 'n', 'n', 'r', 't', 'y'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 5]) == 14\n assert candidate(words = ['quantum', 'computing', 'artificial', 'intelligence'],letters = ['q', 'u', 'a', 'n', 't', 'u', 'm', 'c', 'o', 'm', 'p', 'u', 't', 'i', 'n', 'g', 'a', 'r', 't', 'i', 'f', 'i', 'c', 'i', 'a', 'l', 'i', 'n', 't', 'e', 'l', 'l', 'i', 'g', 'e', 'n', 'c', 'e'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 79\n assert candidate(words = ['programming', 'challenge', 'solution'],letters = ['p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g', 'c', 'h', 'a', 'l', 'l', 'e', 'n', 'g', 'e', 's', 'o', 'l', 'u', 't', 'i', 'o', 'n'],score = [1, 1, 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(words = ['apple', 'banana', 'cherry', 'date'],letters = ['a', 'b', 'c', 'd', 'e', 'e', 'e', 'g', 'h', 'i', 'n', 'n', 'p', 'p', 'r', 't', 'u'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 5\n assert candidate(words = ['apple', 'banana', 'grape', 'orange'],letters = ['a', 'a', 'p', 'l', 'e', 'b', 'a', 'n', 'a', 'n', 'a', 'g', 'r', 'a', 'p', 'e', 'o', 'r', 'a', 'n', 'g', 'e'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 24\n assert candidate(words = ['apple', 'banana', 'cherry'],letters = ['a', 'p', 'p', 'l', 'e', 'b', 'a', 'n', 'a', 'n', 'a', 'c', 'h', 'e', 'r', 'r', 'y'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 34\n assert candidate(words = ['programming', 'is', 'fun', 'and', 'educational'],letters = ['a', 'a', 'a', 'b', 'c', 'd', 'e', 'e', 'e', 'e', 'f', 'g', 'h', 'i', 'i', 'i', 'j', 'k', 'l', 'm', 'n', 'n', 'n', 'o', 'o', 'p', 'p', 'p', 'p', 'r', 'r', 's', 't', 'u', 'u', 'v', 'w', 'x', 'y', 'z'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 5]) == 30\n assert candidate(words = ['optimization', 'performance', 'scalability'],letters = ['o', 'p', 't', 'i', 'm', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'p', 'e', 'r', 'f', 'o', 'r', 'm', 'a', 'n', 'c', 'e', 's', 'c', 'a', 'l', 'a', 'b', 'i', 'l', 'i', 't', 'y'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 4, 8, 8, 10]) == 73\n assert candidate(words = ['zebra', 'giraffe', 'hippo'],letters = ['z', 'e', 'b', 'r', 'a', 'g', 'i', 'r', 'a', 'f', 'f', 'e', 'h', 'i', 'p', 'p', 'o'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 2, 4, 2, 4, 1, 2]) == 34\n assert candidate(words = ['apple', 'banana', 'cherry'],letters = ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'c', 'h', 'e', 'r', 'r', 'y', 'n'],score = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]) == 14\n assert candidate(words = ['programming', 'python', 'java', 'code'],letters = ['p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g', 'p', 'y', 't', 'h', 'o', 'n', 'j', 'a', 'v', 'a', 'c', 'o', 'd', 'e'],score = [3, 1, 3, 7, 2, 2, 4, 6, 5, 3, 5, 1, 3, 7, 2, 1, 4, 6, 5, 3, 5, 1, 3, 7, 2, 1]) == 89\n assert candidate(words = ['algorithm', 'data', 'structure', 'code'],letters = ['a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm', 'd', 'a', 't', 'a', 's', 't', 'r', 'u', 'c', 't', 'u', 'r', 'e', 'c', 'o', 'd', 'e'],score = [1, 3, 2, 2, 1, 2, 3, 5, 1, 1, 1, 1, 2, 1, 1, 1, 2, 4, 2, 4, 1, 6, 2, 5, 3, 5]) == 59\n", "comparison": "exact"}, "public_tests": ["[\"dog\",\"cat\",\"dad\",\"good\"]\n[\"a\",\"a\",\"c\",\"d\",\"d\",\"d\",\"g\",\"o\",\"o\"]\n[1,0,9,5,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0]", "[\"xxxz\",\"ax\",\"bx\",\"cx\"]\n[\"z\",\"a\",\"b\",\"c\",\"x\",\"x\",\"x\"]\n[4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,10]", "[\"leetcode\"]\n[\"l\",\"e\",\"t\",\"c\",\"o\",\"d\"]\n[0,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0]"], "hints": ["Note that words.length is small. This means you can iterate over every subset of words (2^N)."], "metadata": {"canonical_parameter_names": ["words", "letters", "score"], "leetcode_dataset_entry_point": "Solution().maxScoreWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:45+00:00", "tests_total": 76, "tests_dropped": 25, "flags": [], "topic_tags": ["array", "hash-table", "string", "dynamic-programming", "backtracking", "bit-manipulation", "counting", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def maxScoreWords(self, words: list[str], letters: list[str], score: list[int]) -> int:", "container": "Solution", "callable": "maxScoreWords", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "letters", "type": "list[str]"}, {"name": "score", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1260, "task_id": "shift-2d-grid", "difficulty": "Easy", "problem_description": "Given a 2D grid of size m x n and an integer k. You need to shift the grid k times.\n\nIn one shift operation:\n\n- Element at grid[i][j] moves to grid[i][j + 1].\n- Element at grid[i][n - 1] moves to grid[i + 1][0].\n- Element at grid[m - 1][n - 1] moves to grid[0][0].\n\nReturn the 2D grid after applying shift operation k times.\n\nExample 1:\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]], k = 1\nOutput: [[9,1,2],[3,4,5],[6,7,8]]\n\nExample 2:\n\nInput: grid = [[3,8,1,9],[19,7,2,5],[4,6,11,10],[12,0,21,13]], k = 4\nOutput: [[12,0,21,13],[3,8,1,9],[19,7,2,5],[4,6,11,10]]\n\nExample 3:\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]], k = 9\nOutput: [[1,2,3],[4,5,6],[7,8,9]]\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m <= 50\n- 1 <= n <= 50\n- -1000 <= grid[i][j] <= 1000\n- 0 <= k <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[3, 8, 1, 9], [19, 7, 2, 5], [4, 6, 11, 10], [12, 0, 21, 13]],k = 4) == [[12, 0, 21, 13], [3, 8, 1, 9], [19, 7, 2, 5], [4, 6, 11, 10]]\n assert candidate(grid = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],k = 2) == [[-8, -9, -1], [-2, -3, -4], [-5, -6, -7]]\n assert candidate(grid = [[1000, -1000], [1000, -1000]],k = 1) == [[-1000, 1000], [-1000, 1000]]\n assert candidate(grid = [[1]],k = 0) == [[1]]\n assert candidate(grid = [[1]],k = 100) == [[1]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 9) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(grid = [[1, 2], [3, 4]],k = 50) == [[3, 4], [1, 2]]\n assert candidate(grid = [[1, 2], [3, 4]],k = 2) == [[3, 4], [1, 2]]\n assert candidate(grid = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],k = 15) == [[-4, -5, -6], [-7, -8, -9], [-1, -2, -3]]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60]],k = 2) == [[50, 60, 10], [20, 30, 40]]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 1) == [[9, 1, 2], [3, 4, 5], [6, 7, 8]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],k = 10) == [[3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 1, 2]]\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 100) == [[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, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],k = 10) == [[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]]\n assert candidate(grid = [[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]],k = 11) == [[9, 10, 11, 12, 13, 14, 15, 16, 17], [18, 19, 9, 8, 7, 6, 5, 4, 3], [2, 1, 2, 3, 4, 5, 6, 7, 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]],k = 15) == [[15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n assert candidate(grid = [[-1, -1, 0, 1, 1], [-2, -2, 0, 2, 2], [-3, -3, 0, 3, 3], [-4, -4, 0, 4, 4], [-5, -5, 0, 5, 5]],k = 3) == [[0, 5, 5, -1, -1], [0, 1, 1, -2, -2], [0, 2, 2, -3, -3], [0, 3, 3, -4, -4], [0, 4, 4, -5, -5]]\n assert candidate(grid = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90], [-100, -110, -120]],k = 7) == [[-60, -70, -80], [-90, -100, -110], [-120, -10, -20], [-30, -40, -50]]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]],k = 7) == [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]\n assert candidate(grid = [[5, 1, 9, 11], [2, 4, 8, 10], [13, 3, 6, 7], [15, 14, 12, 16]],k = 23) == [[3, 6, 7, 15], [14, 12, 16, 5], [1, 9, 11, 2], [4, 8, 10, 13]]\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 = 25) == [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]]\n assert candidate(grid = [[-1000, -900, -800], [-700, -600, -500], [-400, -300, -200], [-100, 0, 100], [200, 300, 400], [500, 600, 700]],k = 30) == [[-400, -300, -200], [-100, 0, 100], [200, 300, 400], [500, 600, 700], [-1000, -900, -800], [-700, -600, -500]]\n assert candidate(grid = [[-1000, 1000, -500, 500], [200, -200, 300, -300], [400, -400, 500, -500]],k = 100) == [[400, -400, 500, -500], [-1000, 1000, -500, 500], [200, -200, 300, -300]]\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 = 20) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(grid = [[-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]],k = 25) == [[-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]]\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]],k = 18) == [[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]]\n assert candidate(grid = [[1000, -1000, 1000], [-1000, 1000, -1000], [1000, -1000, 1000]],k = 63) == [[1000, -1000, 1000], [-1000, 1000, -1000], [1000, -1000, 1000]]\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 = 30) == [[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]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 15) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 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]],k = 50) == [[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, 6], [7, 8], [9, 10]],k = 15) == [[6, 7], [8, 9], [10, 1], [2, 3], [4, 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]],k = 25) == [[6, 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]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 13) == [[8, 9], [10, 1], [2, 3], [4, 5], [6, 7]]\n assert candidate(grid = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11], [20, 19, 18, 17, 16]],k = 35) == [[10, 9, 8, 7, 6], [15, 14, 13, 12, 11], [20, 19, 18, 17, 16], [5, 4, 3, 2, 1]]\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 = 15) == [[80, 85, 90, 95, 100, 105, 110, 115, 120, 125], [130, 135, 140, 145, 150, 5, 10, 15, 20, 25], [30, 35, 40, 45, 50, 55, 60, 65, 70, 75]]\n assert candidate(grid = [[45, 67, 89], [12, 34, 56], [78, 90, 23]],k = 25) == [[89, 12, 34], [56, 78, 90], [23, 45, 67]]\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) == [[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]]\n assert candidate(grid = [[-5, -10, -15], [-20, -25, -30], [-35, -40, -45], [-50, -55, -60]],k = 15) == [[-50, -55, -60], [-5, -10, -15], [-20, -25, -30], [-35, -40, -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], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 7) == [[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]]\n assert candidate(grid = [[100, -100, 200, -200], [300, -300, 400, -400], [500, -500, 600, -600]],k = 25) == [[-600, 100, -100, 200], [-200, 300, -300, 400], [-400, 500, -500, 600]]\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 = 100) == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(grid = [[-1, 0, 1], [-1, 0, 1], [-1, 0, 1], [-1, 0, 1], [-1, 0, 1]],k = 12) == [[-1, 0, 1], [-1, 0, 1], [-1, 0, 1], [-1, 0, 1], [-1, 0, 1]]\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180]],k = 10) == [[90, 100, 110, 120, 130, 140], [150, 160, 170, 180, 10, 20], [30, 40, 50, 60, 70, 80]]\n assert candidate(grid = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]],k = 15) == [[5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [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, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 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(grid = [[42]],k = 0) == [[42]]\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]],k = 23) == [[2, 1, 0, 1, 3, 5, 7, 9, 11, 13], [15, 17, 19, 19, 17, 15, 13, 11, 9, 7], [5, 3, 1, 0, 1, 2, 3, 4, 5, 6], [7, 8, 9, 9, 8, 7, 6, 5, 4, 3]]\n assert candidate(grid = [[1000, 0, -1000, 500], [500, 1000, 0, -500], [-500, -1000, 500, 0], [0, 500, -500, 1000]],k = 65) == [[1000, 1000, 0, -1000], [500, 500, 1000, 0], [-500, -500, -1000, 500], [0, 0, 500, -500]]\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200]],k = 7) == [[140, 150, 160, 170, 180], [190, 200, 10, 20, 30], [40, 50, 60, 70, 80], [90, 100, 110, 120, 130]]\n assert candidate(grid = [[-1000, 1000, -500, 500], [0, -999, 999, 0], [250, -250, 750, -750]],k = 100) == [[250, -250, 750, -750], [-1000, 1000, -500, 500], [0, -999, 999, 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]],k = 8) == [[13, 14], [15, 16], [17, 18], [19, 20], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]\n assert candidate(grid = [[1000, -1000, 1000], [-1000, 1000, -1000], [1000, -1000, 1000]],k = 50) == [[1000, -1000, 1000], [-1000, 1000, 1000], [-1000, 1000, -1000]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 1) == [[10, 1], [2, 3], [4, 5], [6, 7], [8, 9]]\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]],k = 15) == [[15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26], [27, 28, 29, 0, 1, 2], [3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14]]\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]],k = 33) == [[8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7]]\n assert candidate(grid = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19]],k = 25) == [[15, 16, 17, 18], [19, 0, 1, 2], [3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 3) == [[8, 9], [10, 1], [2, 3], [4, 5], [6, 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]],k = 24) == [[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(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]],k = 25) == [[5, 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(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 = 25) == [[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]]\n assert candidate(grid = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000]],k = 81) == [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000]]\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 100) == [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 100) == [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(grid = [[-10, -20, -30, -40], [-50, -60, -70, -80], [-90, -100, -110, -120], [-130, -140, -150, -160]],k = 100) == [[-130, -140, -150, -160], [-10, -20, -30, -40], [-50, -60, -70, -80], [-90, -100, -110, -120]]\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]],k = 19) == [[12, 13, 14], [15, 16, 17], [18, 19, 20], [21, 22, 23], [24, 25, 26], [27, 28, 29], [30, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]\n assert candidate(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]],k = 17) == [[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]]\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]],k = 20) == [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 10) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(grid = [[5, 1, 4, 2, 8], [0, 3, 9, 7, 6], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]],k = 13) == [[12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 5, 1], [4, 2, 8, 0, 3], [9, 7, 6, 10, 11]]\n assert candidate(grid = [[5, -5, 15, -15, 25, -25], [35, -35, 45, -45, 55, -55], [65, -65, 75, -75, 85, -85]],k = 20) == [[85, -85, 5, -5, 15, -15], [25, -25, 35, -35, 45, -45], [55, -55, 65, -65, 75, -75]]\n assert candidate(grid = [[-1, 2, -3, 4, -5, 6], [7, -8, 9, -10, 11, -12], [13, -14, 15, -16, 17, -18]],k = 100) == [[9, -10, 11, -12, 13, -14], [15, -16, 17, -18, -1, 2], [-3, 4, -5, 6, 7, -8]]\n assert candidate(grid = [[999, 999, 999], [999, 999, 999], [999, 999, 999], [999, 999, 999], [999, 999, 999]],k = 50) == [[999, 999, 999], [999, 999, 999], [999, 999, 999], [999, 999, 999], [999, 999, 999]]\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 = 19) == [[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, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]],k = 100) == [[-1, -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(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200]],k = 3) == [[180, 190, 200, 10, 20], [30, 40, 50, 60, 70], [80, 90, 100, 110, 120], [130, 140, 150, 160, 170]]\n assert candidate(grid = [[5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34]],k = 30) == [[5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34]]\n assert candidate(grid = [[-1000, 1000], [-1000, 1000], [-1000, 1000], [-1000, 1000], [-1000, 1000]],k = 50) == [[-1000, 1000], [-1000, 1000], [-1000, 1000], [-1000, 1000], [-1000, 1000]]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 15) == [[20, 30, 40, 50], [60, 70, 80, 90], [100, 110, 120, 130], [140, 150, 160, 10]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 7) == [[4, 5], [6, 7], [8, 9], [10, 1], [2, 3]]\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 3) == [[8], [9], [10], [1], [2], [3], [4], [5], [6], [7]]\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[4,5,6],[7,8,9]]\n1", "[[3,8,1,9],[19,7,2,5],[4,6,11,10],[12,0,21,13]]\n4", "[[1,2,3],[4,5,6],[7,8,9]]\n9"], "hints": ["Simulate step by step. move grid[i][j] to grid[i][j+1]. handle last column of the grid.", "Put the matrix row by row to a vector. take k % vector.length and move last k of the vector to the beginning. put the vector to the matrix back the same way."], "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().shiftGrid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:56+00:00", "tests_total": 84, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def shiftGrid(self, grid: list[list[int]], k: int) -> list[list[int]]:", "container": "Solution", "callable": "shiftGrid", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1262, "task_id": "greatest-sum-divisible-by-three", "difficulty": "Medium", "problem_description": "Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three.\n\nExample 1:\n\nInput: nums = [3,6,5,1,8]\nOutput: 18\nExplanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3).\n\nExample 2:\n\nInput: nums = [4]\nOutput: 0\nExplanation: Since 4 is not divisible by 3, do not pick any number.\n\nExample 3:\n\nInput: nums = [1,2,3,4,4]\nOutput: 12\nExplanation: Pick numbers 1, 3, 4 and 4 their sum is 12 (maximum sum divisible by 3).\n\nConstraints:\n\n- 1 <= nums.length <= 4 * 10^4\n- 1 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 18\n assert candidate(nums = [2, 3, 5, 7, 11]) == 21\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 30\n assert candidate(nums = [4]) == 0\n assert candidate(nums = [10000, 10000, 10000, 10000]) == 30000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20]) == 75\n assert candidate(nums = [1, 4, 7, 10, 13, 16]) == 51\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13]) == 42\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == 18\n assert candidate(nums = [1, 2, 4, 5, 7, 10]) == 27\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 11]) == 36\n assert candidate(nums = [9, 9, 9, 9, 9, 9]) == 54\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums = [1, 2, 3, 4, 4]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(nums = [2, 6, 2, 2, 7, 10]) == 27\n assert candidate(nums = [3, 6, 5, 1, 8]) == 18\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19]) == 69\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3]) == 21\n assert candidate(nums = [1, 2, 3]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 18\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 11, 13, 17, 19, 23, 29]) == 138\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums = [3, 9, 12, 18, 21, 24, 27, 30]) == 144\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == 1815\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1050\n assert candidate(nums = [8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50]) == 435\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5400\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, 77, 80, 83, 86, 89, 92, 95, 98, 101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, 176, 179, 182, 185, 188, 191, 194, 197, 200]) == 6765\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [1, 2, 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]) == 1686\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 390\n assert candidate(nums = [13, 19, 3, 11, 27, 5, 23, 29, 31, 37, 41, 43, 47]) == 324\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41]) == 294\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 1260\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]) == 930\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 270\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 321\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 2109\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 11, 13, 17, 19, 23, 29, 31]) == 168\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == 228\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]) == 603\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 60000\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89]) == 705\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 165\n assert candidate(nums = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63]) == 687\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 390\n assert candidate(nums = [1234, 4567, 7890, 3456, 6789, 2345, 5678, 8901, 123, 456]) == 41439\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 270\n assert candidate(nums = [8, 10, 5, 7, 6, 9, 3, 12, 15, 18, 21, 24, 27, 30, 33]) == 228\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 525\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 108\n assert candidate(nums = [13, 16, 19, 22, 25, 28, 31, 34, 37, 40]) == 252\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38]) == 258\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 240\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 = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 189810\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57]) == 435\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 = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40]) == 282\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 90000\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 378\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]) == 585\n assert candidate(nums = [3, 9, 27, 81, 243, 729]) == 1092\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 = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 1680\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 840\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981]) == 189828\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 99954\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 630\n assert candidate(nums = [9, 12, 3, 15, 6, 3, 18, 21, 24, 27]) == 138\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 39\n assert candidate(nums = [123, 456, 789, 1011, 1213, 1415, 1617, 1819, 2021, 2223, 2425]) == 13899\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 360\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 105\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]) == 1053\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]) == 585\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]) == 450\n assert candidate(nums = [3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 174\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 149880\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 420\n assert candidate(nums = [3, 1, 2, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1059\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 108\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 600\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, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43]) == 330\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]) == 975\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 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 840\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]) == 1395\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 705\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]) == 1395\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 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]) == 399\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6]) == 42\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == 246\n assert candidate(nums = [3, 9, 12, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 339\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 30\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 8, 9]) == 63\n assert candidate(nums = [104, 101, 102, 103, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1455\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 180\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == 144\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 153\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 36\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6]) == 81\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 75000\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495]) == 3960\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(nums = [1, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 156\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 99945\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 75\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 8, 9, 10]) == 111\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == 180\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 147\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5400\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 11, 13, 17, 19, 23, 29]) == 138\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]) == 480\n", "comparison": "exact"}, "public_tests": ["[3,6,5,1,8]", "[4]", "[1,2,3,4,4]"], "hints": ["Represent the state as DP[pos][mod]: maximum possible sum starting in the position \"pos\" in the array where the current sum modulo 3 is equal to mod."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSumDivThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:58+00:00", "tests_total": 139, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "dynamic-programming", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxSumDivThree(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxSumDivThree", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1263, "task_id": "minimum-moves-to-move-a-box-to-their-target-location", "difficulty": "Hard", "problem_description": "A storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations.\n\nThe game is represented by an m x n grid of characters grid where each element is a wall, floor, or box.\n\nYour task is to move the box 'B' to the target position 'T' under the following rules:\n\n- The character 'S' represents the player. The player can move up, down, left, right in grid if it is a floor (empty cell).\n- The character '.' represents the floor which means a free cell to walk.\n- The character '#' represents the wall which means an obstacle (impossible to walk there).\n- There is only one box 'B' and one target cell 'T' in the grid.\n- The box can be moved to an adjacent free cell by standing next to the box and then moving in the direction of the box. This is a push.\n- The player cannot walk through the box.\n\nReturn the minimum number of pushes to move the box to the target. If there is no way to reach the target, return -1.\n\nExample 1:\n\nInput: grid = [[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"],\n [\"#\",\"T\",\"#\",\"#\",\"#\",\"#\"],\n [\"#\",\".\",\".\",\"B\",\".\",\"#\"],\n [\"#\",\".\",\"#\",\"#\",\".\",\"#\"],\n [\"#\",\".\",\".\",\".\",\"S\",\"#\"],\n [\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"]]\nOutput: 3\nExplanation: We return only the number of times the box is pushed.\n\nExample 2:\n\nInput: grid = [[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"],\n [\"#\",\"T\",\"#\",\"#\",\"#\",\"#\"],\n [\"#\",\".\",\".\",\"B\",\".\",\"#\"],\n [\"#\",\"#\",\"#\",\"#\",\".\",\"#\"],\n [\"#\",\".\",\".\",\".\",\"S\",\"#\"],\n [\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"]]\nOutput: -1\n\nExample 3:\n\nInput: grid = [[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"],\n [\"#\",\"T\",\".\",\".\",\"#\",\"#\"],\n [\"#\",\".\",\"#\",\"B\",\".\",\"#\"],\n [\"#\",\".\",\".\",\".\",\".\",\"#\"],\n [\"#\",\".\",\".\",\".\",\"S\",\"#\"],\n [\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"]]\nOutput: 5\nExplanation: push the box down, left, left, up and up.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 20\n- grid contains only characters '.', '#', 'S', 'T', or 'B'.\n- There is only one character 'S', 'B', and 'T' in the grid.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '.', '#', '#', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '#', '#'], ['#', '.', '#', 'B', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '#', '#', '#', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', 'B', '.', '.', '#'], ['#', '#', '#', '#', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '.', '#', '#', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '#', '#'], ['#', '.', '.', 'B', '#', '#'], ['#', '.', '#', '.', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '#', '#'], ['#', '.', '#', 'B', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '.', '#', 'S', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', '.', '.', 'B', '#'], ['#', '.', '#', '#', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', 'S', '.', '.', '.', '.', '#'], ['#', '#', '.', '.', '.', 'T', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '#', '#', '.', '#'], ['#', '.', '.', 'S', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '#'], ['#', '.', '#', 'B', '.', '#'], ['#', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '.', '.', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', 'B', '.', '.', '#'], ['#', 'S', '.', '.', '#', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'B', '.', '#'], ['#', '.', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', 'S', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', 'T', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', 'T', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '#'], ['#', '.', 'S', '.', '.', '.', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '#', '.', 'B', '.', '#'], ['#', '.', '.', '#', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '.', '.', '#'], ['#', '.', '#', 'B', '#', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'T', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'B', '.', '#'], ['#', '.', '#', '#', '.', '#', '.', '#'], ['#', '.', '.', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '#', '#', 'B', '.', '#'], ['#', '.', '.', '.', '.', 'S'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', 'S', '#'], ['#', '.', '.', '.', '#', '#', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', '.', '.', 'T', '#', '#'], ['#', '.', '#', '#', '#', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '.', 'S', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', 'B', '#', '.', '#'], ['#', '.', '#', '.', '#', '.', '#'], ['#', '.', '.', '.', '.', 'T', '#'], ['#', 'S', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '.', '#', '.', '#'], ['#', '.', 'B', '.', 'T', '.', '#'], ['#', '.', '.', 'S', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '#', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '.', '#', '.', '#'], ['#', '.', '.', '.', '.', 'T', '#'], ['#', 'S', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '#', '.', '.', '.', '#', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '.', 'T', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'S', 'T', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '.', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', 'B', '.', '.', '#'], ['#', 'S', '#', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '#', 'B', '#', '.', '.', '#'], ['#', '.', '.', 'S', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '#', '#', '.', '.', '#'], ['#', '.', '.', 'S', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '#', '#', '#', '#', '.', '#'], ['#', '.', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '#', 'B', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '.', '#'], ['#', '.', '.', '#', '#', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '.', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 7\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', 'T', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', 'B', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '#', 'B', '.', '#'], ['#', '.', '.', '.', '.', '.', 'T', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '.', 'T', '#'], ['#', '.', '#', '#', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '#', '#', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', 'S', '.', '.', '#'], ['#', '.', '.', '#', '.', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '#'], ['#', '.', '#', 'B', '.', '.', '#'], ['#', '.', '.', 'T', 'S', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '#', '#', '#', '#', '#'], ['#', '#', '.', '.', '.', '.', 'T', '#'], ['#', '.', '.', 'B', '.', '#', '.', '#'], ['#', '.', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', 'T', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', 'B', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', 'T', '#'], ['#', '.', '#', '.', '.', '#'], ['#', '.', '.', '.', 'B', '#'], ['#', '.', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#', '#']]) == 7\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', 'T', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '.', '#'], ['#', '.', '.', '#', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '#', '.', '.', '.', '.', '#', '#'], ['#', '.', '.', 'B', '.', '.', '.', '#'], ['#', '.', '#', '.', 'T', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '#', '.', '#'], ['#', '.', '#', '#', 'S', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 6\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '#', '.', '#'], ['#', '.', '#', 'B', 'T', '#', '.', '#'], ['#', '.', '.', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '#', '#', '#'], ['#', '.', '.', '.', '#', '#'], ['#', '#', '#', 'B', '.', '#'], ['#', '.', '.', '.', '.', 'S'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', 'B', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '.', '.', 'T', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '#', 'B', '#', '.', '.', '#'], ['#', '.', '.', '.', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', '#', 'T']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', 'B', '.', '.', '.', '#'], ['#', '.', '.', '#', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '.', '.', '#'], ['#', '.', '.', '.', 'B', '#'], ['#', '.', '.', '#', '.', '#'], ['#', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '#'], ['#', '.', '.', '#', '.', '#'], ['#', '.', '.', 'B', '.', '#'], ['#', '#', '.', '.', '.', '#'], ['#', 'S', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '#'], ['#', '.', '.', '#', '.', '#'], ['#', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', 'T', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '.', 'B', '.', '.', '.', '#'], ['#', 'S', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '#', '.', '.', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '.', '#'], ['#', 'S', '.', '.', '#', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 5\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'S', '#'], ['#', 'B', '.', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#'], ['#', 'S', '.', 'B', '#'], ['#', '.', '.', '.', '#'], ['#', '.', '.', 'T', '#'], ['#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', 'B', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'T', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', 'S', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 4\n assert candidate(grid = [['#', '#', '#', '#', '#'], ['#', 'S', '.', '.', '#'], ['#', '.', '#', '.', '#'], ['#', '.', '.', 'B', '#'], ['#', 'T', '.', '.', '#'], ['#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '.', '#'], ['#', '.', 'S', '.', '.', '.', '#'], ['#', '.', '.', '.', 'T', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 2\n assert candidate(grid = [['#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', 'T', '#'], ['#', '.', 'B', '.', '.', '#'], ['#', '.', '#', '.', '.', '#'], ['#', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', 'T', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '.', '.', '#', '.', '.', '#'], ['#', '.', 'S', '#', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == 3\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', 'B', '.', '#'], ['#', '.', '.', '.', '#', '.', '#'], ['#', '.', 'S', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', 'T', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '#', '.', '#'], ['#', '.', '#', 'B', '.', '.', '#'], ['#', '.', '#', '.', '.', 'S', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', 'T', '.', '.', '#'], ['#', '.', '#', '#', '#', '.', '#'], ['#', '.', '.', 'B', '.', '.', '#'], ['#', '#', '#', '#', '#', '.', '#'], ['#', '.', '.', '.', 'S', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]) == -1\n assert candidate(grid = [['#', '#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '.', '.', '.', '#'], ['#', '.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', 'B', '.', '.', '#'], ['#', '.', '#', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', 'S', '#'], ['#', '.', '.', '.', '.', '.', 'T', '#'], ['#', '#', '#', '#', '#', '#', '#', '#']]) == 5\n", "comparison": "exact"}, "public_tests": ["[[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"],[\"#\",\"T\",\"#\",\"#\",\"#\",\"#\"],[\"#\",\".\",\".\",\"B\",\".\",\"#\"],[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],[\"#\",\".\",\".\",\".\",\"S\",\"#\"],[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"]]", "[[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"],[\"#\",\"T\",\"#\",\"#\",\"#\",\"#\"],[\"#\",\".\",\".\",\"B\",\".\",\"#\"],[\"#\",\"#\",\"#\",\"#\",\".\",\"#\"],[\"#\",\".\",\".\",\".\",\"S\",\"#\"],[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"]]", "[[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"],[\"#\",\"T\",\".\",\".\",\"#\",\"#\"],[\"#\",\".\",\"#\",\"B\",\".\",\"#\"],[\"#\",\".\",\".\",\".\",\".\",\"#\"],[\"#\",\".\",\".\",\".\",\"S\",\"#\"],[\"#\",\"#\",\"#\",\"#\",\"#\",\"#\"]]"], "hints": ["We represent the search state as (player_row, player_col, box_row, box_col).", "You need to count only the number of pushes. Then inside of your BFS check if the box could be pushed (in any direction) given the current position of the player."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minPushBox", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:00+00:00", "tests_total": 82, "tests_dropped": 10, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "heap-priority-queue", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minPushBox(self, grid: list[list[str]]) -> int:", "container": "Solution", "callable": "minPushBox", "parameters": [{"name": "grid", "type": "list[list[str]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1266, "task_id": "minimum-time-visiting-all-points", "difficulty": "Easy", "problem_description": "On a 2D plane, there are n points with integer coordinates points[i] = [x_i, y_i]. Return the minimum time in seconds to visit all the points in the order given by points.\n\nYou can move according to these rules:\n\n- In 1 second, you can either:\n - move vertically by one unit,\n - move horizontally by one unit, or\n - move diagonally sqrt(2) units (in other words, move one unit vertically then one unit horizontally in 1 second).\n- You have to visit the points in the same order as they appear in the array.\n- You are allowed to pass through points that appear later in the order, but these do not count as visits.\n\nExample 1:\n\nInput: points = [[1,1],[3,4],[-1,0]]\nOutput: 7\nExplanation: One optimal path is [1,1] -> [2,2] -> [3,3] -> [3,4] -> [2,3] -> [1,2] -> [0,1] -> [-1,0]\nTime from [1,1] to [3,4] = 3 seconds\nTime from [3,4] to [-1,0] = 4 seconds\nTotal time = 7 seconds\n\nExample 2:\n\nInput: points = [[3,2],[-2,2]]\nOutput: 5\n\nConstraints:\n\n- points.length == n\n- 1 <= n <= 100\n- points[i].length == 2\n- -1000 <= points[i][0], points[i][1] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [1, 1], [0, 0], [1, 1]]) == 3\n assert candidate(points = [[5, 5], [5, 5], [5, 5], [5, 5]]) == 0\n assert candidate(points = [[-5, -5], [-4, -4], [-3, -3], [-2, -2]]) == 3\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3]]) == 3\n assert candidate(points = [[-1000, -1000], [1000, 1000], [-1000, 1000], [1000, -1000]]) == 6000\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 3\n assert candidate(points = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 4\n assert candidate(points = [[3, 2], [-2, 2]]) == 5\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 6\n assert candidate(points = [[-1, -1], [1, 1], [-1, -1], [1, 1]]) == 6\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1]]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(points = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]) == 4\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4]]) == 3\n assert candidate(points = [[1, 1], [3, 4], [-1, 0]]) == 7\n assert candidate(points = [[-1000, -1000], [1000, 1000]]) == 2000\n assert candidate(points = [[1, 1], [2, 2], [2, 1], [1, 2], [0, 0]]) == 5\n assert candidate(points = [[0, 0], [5, 5], [10, 10]]) == 10\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0]]) == 3\n assert candidate(points = [[0, 0], [1000, 1000]]) == 1000\n assert candidate(points = [[10, 10], [0, 0], [5, 5]]) == 15\n assert candidate(points = [[-1, -1], [1, 1], [-2, -2], [2, 2]]) == 9\n assert candidate(points = [[10, 10], [5, 5], [0, 0], [-5, -5], [-10, -10]]) == 20\n assert candidate(points = [[1000, 1000], [-1000, -1000], [1000, -1000], [-1000, 1000]]) == 6000\n assert candidate(points = [[1000, 1000], [-1000, -1000], [0, 0]]) == 3000\n assert candidate(points = [[-1000, 0], [1000, 0], [0, -1000], [0, 1000]]) == 5000\n assert candidate(points = [[999, 999], [1000, 1000], [999, 1000], [1000, 999], [999, 999], [0, 0], [-1, -1], [-1000, -1000]]) == 2003\n assert candidate(points = [[-500, 500], [500, -500], [-500, -500], [500, 500], [-1, 1], [1, -1]]) == 3503\n assert candidate(points = [[-100, -100], [-90, -90], [-80, -80], [-70, -70], [-60, -60], [-50, -50], [-40, -40]]) == 60\n assert candidate(points = [[-1, -1], [1, 1], [-1, 1], [1, -1], [-2, -2], [2, 2], [-2, 2], [2, -2]]) == 21\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 18\n assert candidate(points = [[0, 0], [1, 0], [1, 1], [0, 1], [0, 2], [1, 2], [1, 3], [0, 3], [0, 4], [1, 4], [1, 5], [0, 5], [0, 6], [1, 6], [1, 7], [0, 7], [0, 8], [1, 8], [1, 9], [0, 9]]) == 19\n assert candidate(points = [[5, 5], [5, 15], [15, 15], [15, 5], [5, 5], [10, 10], [15, 5], [5, 15]]) == 60\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 9\n assert candidate(points = [[-2, -2], [-2, 2], [2, 2], [2, -2], [-2, -2], [1, 1], [0, 0], [-1, -1]]) == 21\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800]]) == 600\n assert candidate(points = [[5, 5], [1, 1], [-3, -3], [-5, -5], [0, 0], [5, 5], [10, 10], [5, 5]]) == 30\n assert candidate(points = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0], [2, 0], [0, 2], [2, 2], [0, 0], [2, 2]]) == 18\n assert candidate(points = [[-10, 10], [0, 0], [10, -10], [0, 0], [-10, 10], [0, 0], [10, -10]]) == 60\n assert candidate(points = [[10, 10], [10, 11], [11, 11], [12, 12], [12, 13], [13, 13], [13, 14], [14, 14]]) == 7\n assert candidate(points = [[-999, -999], [-998, -998], [-997, -997], [-996, -996], [-995, -995], [-994, -994], [-993, -993]]) == 6\n assert candidate(points = [[0, 0], [1000, 0], [0, 1000], [1000, 1000], [500, 500], [0, 0], [1000, 0], [0, 1000]]) == 6000\n assert candidate(points = [[0, 0], [1, 1], [2, 0], [1, -1], [0, 0], [-1, -1], [-2, 0], [-1, 1]]) == 7\n assert candidate(points = [[-1000, -1000], [-999, -999], [-998, -998], [-997, -997], [-996, -996], [-995, -995], [-994, -994], [-993, -993]]) == 7\n assert candidate(points = [[100, 0], [0, 100], [100, 100], [0, 0], [50, 50], [50, 0], [0, 50]]) == 450\n assert candidate(points = [[0, 1], [1, 0], [0, -1], [-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0], [0, 0]]) == 8\n assert candidate(points = [[-100, -100], [-99, -101], [-98, -102], [-97, -103], [-96, -104], [-95, -105], [-94, -106]]) == 6\n assert candidate(points = [[100, 100], [200, 150], [300, 200], [350, 250], [400, 300], [500, 350], [600, 400]]) == 500\n assert candidate(points = [[100, 200], [200, 300], [300, 200], [200, 100], [100, 200], [200, 300], [300, 400], [400, 300]]) == 700\n assert candidate(points = [[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]]) == 14\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]]) == 20\n assert candidate(points = [[-900, 0], [-800, -100], [-700, -200], [-600, -300], [-500, -400], [-400, -500], [-300, -600], [-200, -700], [-100, -800], [0, -900]]) == 900\n assert candidate(points = [[10, 10], [20, 20], [15, 25], [25, 15], [30, 30], [40, 40], [35, 35], [45, 45]]) == 65\n assert candidate(points = [[0, 0], [999, 999], [1, 1], [998, 998], [2, 2], [997, 997], [3, 3], [996, 996], [4, 4]]) == 7964\n assert candidate(points = [[0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]) == 18\n assert candidate(points = [[5, 5], [5, 15], [15, 15], [15, 5], [5, 5], [5, 25], [25, 25], [25, 5], [5, 5]]) == 120\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [2, 0], [0, 2], [3, 0], [0, 3], [4, 0], [0, 4], [5, 0], [0, 5]]) == 30\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5], [35, 5], [40, 5], [45, 5], [50, 5]]) == 45\n assert candidate(points = [[1, 2], [2, 5], [5, 4], [7, 8], [10, 10], [5, 5], [3, 3], [2, 2], [1, 1]]) == 22\n assert candidate(points = [[-500, 500], [500, -500], [-500, -500], [500, 500], [0, 0], [-1000, 1000], [1000, -1000]]) == 6500\n assert candidate(points = [[0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 10\n assert candidate(points = [[1, 1], [1000, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 2005\n assert candidate(points = [[100, 100], [200, 200], [300, 100], [200, 0], [100, 100]]) == 400\n assert candidate(points = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0], [100, 0]]) == 100\n assert candidate(points = [[1000, 0], [0, 1000], [1000, 1000], [0, 0], [500, 500], [250, 250], [750, 750]]) == 4250\n assert candidate(points = [[-100, -100], [-50, -100], [0, -100], [50, -100], [100, -100], [100, -50], [100, 0], [100, 50], [100, 100], [50, 100], [0, 100], [-50, 100], [-100, 100], [-100, 50], [-100, 0], [-100, -50]]) == 750\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [2, 2], [1, 1], [0, 0], [-1, -1]]) == 8\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [0, 0], [-1, -1], [1, 1], [0, 0], [-1, -1], [1, 1]]) == 10\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 14\n assert candidate(points = [[-100, 100], [100, -100], [-100, -100], [100, 100], [-100, 100]]) == 800\n assert candidate(points = [[0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 16\n assert candidate(points = [[-10, 10], [20, -20], [30, 30], [-40, -40], [50, 50], [0, 0], [-50, -50]]) == 340\n assert candidate(points = [[-1, -2], [-3, -4], [-5, -6], [-7, -8], [-9, -10], [-11, -12], [-13, -14], [-15, -16], [-17, -18]]) == 16\n assert candidate(points = [[-999, 999], [0, 0], [999, -999], [0, 0], [-999, 999]]) == 3996\n assert candidate(points = [[-100, 0], [0, -100], [100, 0], [0, 100], [0, 0], [-100, 0], [0, -100], [100, 0], [0, 100]]) == 800\n assert candidate(points = [[-500, -500], [500, 500], [-500, 500], [500, -500], [-500, -500], [0, 0], [500, 500], [0, 0]]) == 5500\n assert candidate(points = [[-100, -100], [0, 0], [100, 100], [0, 0], [-100, -100]]) == 400\n assert candidate(points = [[0, 0], [0, 500], [500, 0], [1000, 500], [500, 1000], [0, 500], [500, 0]]) == 3000\n assert candidate(points = [[10, 10], [5, 5], [0, 0], [-5, -5], [-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]]) == 40\n assert candidate(points = [[-1, 0], [0, -1], [1, 0], [0, 1], [-1, 0]]) == 4\n assert candidate(points = [[-1000, 0], [0, 1000], [1000, 0], [0, -1000], [-1000, -1000]]) == 4000\n assert candidate(points = [[0, 0], [1, 0], [2, 1], [2, 2], [3, 3], [3, 4], [4, 4]]) == 6\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 18\n assert candidate(points = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0], [0, -1], [-1, -1], [-1, 0], [0, 0]]) == 8\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]]) == 800\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == 10\n assert candidate(points = [[0, 0], [1, 1], [2, 0], [1, 0], [0, 1], [0, 2], [1, 1]]) == 6\n assert candidate(points = [[-300, -300], [-200, -200], [-100, -100], [0, 0], [100, 100], [200, 200], [300, 300]]) == 600\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 18\n assert candidate(points = [[100, 0], [90, 10], [80, 20], [70, 30], [60, 40], [50, 50], [40, 60], [30, 70], [20, 80], [10, 90], [0, 100]]) == 100\n assert candidate(points = [[-999, 999], [999, -999], [-999, -999], [999, 999], [0, 0], [-100, 100], [100, -100]]) == 7293\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]) == 10\n assert candidate(points = [[0, 0], [100, 0], [100, 100], [0, 100], [0, 0], [100, 100], [100, 0], [0, 0]]) == 700\n assert candidate(points = [[500, 500], [0, 0], [500, 0], [0, 500], [500, 500], [250, 250], [750, 750], [250, 750], [750, 250]]) == 3750\n assert candidate(points = [[100, 0], [50, 50], [0, 100], [-50, 50], [-100, 0], [-50, -50], [0, -100], [50, -50]]) == 350\n assert candidate(points = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000]]) == 3000\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]) == 9\n assert candidate(points = [[-10, -10], [10, 10], [-5, 5], [5, -5], [0, 0], [-5, -5], [5, 5], [-10, -10], [10, 10]]) == 100\n assert candidate(points = [[-500, -500], [-400, -400], [-300, -300], [-200, -200], [-100, -100], [0, 0], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500]]) == 1000\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [0, 0]]) == 900\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18]]) == 18\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 9\n assert candidate(points = [[-300, -400], [400, 300], [-200, 100], [200, -200], [0, 0]]) == 1900\n assert candidate(points = [[500, 500], [450, 550], [400, 600], [350, 650], [300, 700], [250, 750], [200, 800]]) == 300\n assert candidate(points = [[0, 0], [100, 100], [200, 0], [300, 100], [400, 0], [500, 100], [600, 0], [700, 100], [800, 0], [900, 100]]) == 900\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(points = [[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [-6, 6], [-7, 7], [-8, 8], [-9, 9]]) == 8\n assert candidate(points = [[-500, 0], [0, 500], [500, 0], [0, -500], [-500, 0], [0, 0], [500, 500], [-500, -500]]) == 4000\n assert candidate(points = [[1, 1], [10, 10], [1, 10], [10, 1], [1, 1], [10, 10], [1, 10], [10, 1], [1, 1]]) == 72\n assert candidate(points = [[-1, -2], [-3, -4], [-5, -6], [-7, -8], [-9, -10], [-11, -12], [-13, -14], [-15, -16], [-17, -18], [-19, -20]]) == 18\n assert candidate(points = [[0, 0], [1000, 0], [0, 1000], [1000, 1000], [500, 500], [0, 0]]) == 4000\n assert candidate(points = [[-1, 2], [3, -4], [5, 6], [-7, 8], [9, -10], [-11, 12], [13, -14], [-15, 16], [0, 0]]) == 140\n assert candidate(points = [[0, 0], [1, 1], [2, 0], [3, 1], [4, 0], [5, 1], [6, 0], [7, 1], [8, 0], [9, 1]]) == 9\n assert candidate(points = [[-1, 1], [1, -1], [-2, 2], [2, -2], [-3, 3], [3, -3], [-4, 4], [4, -4], [-5, 5], [5, -5]]) == 54\n assert candidate(points = [[-100, -100], [-90, -90], [-80, -80], [-70, -70], [-60, -60], [-50, -50], [-40, -40], [-30, -30], [-20, -20], [-10, -10]]) == 90\n assert candidate(points = [[-500, 500], [0, 0], [500, -500], [0, 0], [-500, 500], [0, 0], [500, -500], [0, 0]]) == 3500\n assert candidate(points = [[0, 0], [1000, 1000], [-1000, -1000], [500, 500], [-500, -500], [1, -1], [0, 0]]) == 6002\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 6], [7, 5], [8, 7], [9, 8], [10, 10]]) == 15\n assert candidate(points = [[-1000, 1000], [1000, 0], [0, 1000], [1000, -1000], [0, 0]]) == 6000\n", "comparison": "exact"}, "public_tests": ["[[1,1],[3,4],[-1,0]]", "[[3,2],[-2,2]]"], "hints": ["To walk from point A to point B there will be an optimal strategy to walk ?", "Advance in diagonal as possible then after that go in straight line.", "Repeat the process until visiting all the points."], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minTimeToVisitAllPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:03+00:00", "tests_total": 120, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def minTimeToVisitAllPoints(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "minTimeToVisitAllPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1267, "task_id": "count-servers-that-communicate", "difficulty": "Medium", "problem_description": "You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.\nReturn the number of servers that communicate with any other server.\n\nExample 1:\n\nInput: grid = [[1,0],[0,1]]\nOutput: 0\nExplanation: No servers can communicate with others.\n\nExample 2:\n\nInput: grid = [[1,0],[1,1]]\nOutput: 3\nExplanation: All three servers can communicate with at least one other server.\n\nExample 3:\n\nInput: grid = [[1,1,0,0],[0,0,1,0],[0,0,1,0],[0,0,0,1]]\nOutput: 4\nExplanation: The two servers in the first row can communicate with each other. The two servers in the third column can communicate with each other. The server at right bottom corner can't communicate with any other server.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m <= 250\n- 1 <= n <= 250\n- grid[i][j] == 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 0], [0, 0, 0, 0], [1, 1, 1, 0], [0, 0, 0, 0]]) == 6\n assert candidate(grid = [[1, 0], [1, 1]]) == 3\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 13\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 1], [0, 0, 0], [1, 0, 1]]) == 4\n assert candidate(grid = [[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, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 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, 1, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\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\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\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, 1]]) == 0\n assert candidate(grid = [[0, 0, 0], [0, 0, 1], [1, 0, 0], [0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]]) == 8\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 1, 0, 0], [1, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 8\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, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0]]) == 0\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, 1, 0], [1, 0, 0], [0, 0, 1]]) == 3\n assert candidate(grid = [[1, 1, 0], [1, 0, 1], [0, 1, 1]]) == 6\n assert candidate(grid = [[1, 0], [0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0], [0, 0, 0], [0, 0, 1]]) == 2\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, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0], [0, 1, 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\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1], [1, 1], [1, 1]]) == 6\n assert candidate(grid = [[1, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 1]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[1,0],[0,1]]", "[[1,0],[1,1]]", "[[1,1,0,0],[0,0,1,0],[0,0,1,0],[0,0,0,1]]"], "hints": ["Store number of computer in each row and column.", "Count all servers that are not isolated."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countServers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:05+00:00", "tests_total": 50, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix", "counting"]}, "language": "python", "interface": {"raw_signature": "def countServers(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "countServers", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1268, "task_id": "search-suggestions-system", "difficulty": "Medium", "problem_description": "You are given an array of strings products and a string searchWord.\n\nDesign a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.\n\nReturn a list of lists of the suggested products after each character of searchWord is typed.\n\nExample 1:\n\nInput: products = [\"mobile\",\"mouse\",\"moneypot\",\"monitor\",\"mousepad\"], searchWord = \"mouse\"\nOutput: [[\"mobile\",\"moneypot\",\"monitor\"],[\"mobile\",\"moneypot\",\"monitor\"],[\"mouse\",\"mousepad\"],[\"mouse\",\"mousepad\"],[\"mouse\",\"mousepad\"]]\nExplanation: products sorted lexicographically = [\"mobile\",\"moneypot\",\"monitor\",\"mouse\",\"mousepad\"].\nAfter typing m and mo all products match and we show user [\"mobile\",\"moneypot\",\"monitor\"].\nAfter typing mou, mous and mouse the system suggests [\"mouse\",\"mousepad\"].\n\nExample 2:\n\nInput: products = [\"havana\"], searchWord = \"havana\"\nOutput: [[\"havana\"],[\"havana\"],[\"havana\"],[\"havana\"],[\"havana\"],[\"havana\"]]\nExplanation: The only word \"havana\" will be always suggested while typing the search word.\n\nConstraints:\n\n- 1 <= products.length <= 1000\n- 1 <= products[i].length <= 3000\n- 1 <= sum(products[i].length) <= 2 * 10^4\n- All the strings of products are unique.\n- products[i] consists of lowercase English letters.\n- 1 <= searchWord.length <= 1000\n- searchWord consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(products = ['keyboard', 'keypad', 'keys', 'kick'],searchWord = \"key\") == [['keyboard', 'keypad', 'keys'], ['keyboard', 'keypad', 'keys'], ['keyboard', 'keypad', 'keys']]\n assert candidate(products = ['keyboard', 'keypad', 'mousepad'],searchWord = \"key\") == [['keyboard', 'keypad'], ['keyboard', 'keypad'], ['keyboard', 'keypad']]\n assert candidate(products = ['apple', 'banana', 'grape', 'orange'],searchWord = \"or\") == [['orange'], ['orange']]\n assert candidate(products = ['aaa', 'aaab', 'aaac', 'aab'],searchWord = \"aa\") == [['aaa', 'aaab', 'aaac'], ['aaa', 'aaab', 'aaac']]\n assert candidate(products = ['charger', 'cable', 'case'],searchWord = \"ca\") == [['cable', 'case', 'charger'], ['cable', 'case']]\n assert candidate(products = ['bag', 'bags', 'banner', 'box', 'car'],searchWord = \"ba\") == [['bag', 'bags', 'banner'], ['bag', 'bags', 'banner']]\n assert candidate(products = ['aaa', 'aab', 'aac', 'aad', 'aae'],searchWord = \"aa\") == [['aaa', 'aab', 'aac'], ['aaa', 'aab', 'aac']]\n assert candidate(products = ['aaa', 'aab', 'aac', 'aad'],searchWord = \"aa\") == [['aaa', 'aab', 'aac'], ['aaa', 'aab', 'aac']]\n assert candidate(products = ['apple', 'apples', 'application'],searchWord = \"app\") == [['apple', 'apples', 'application'], ['apple', 'apples', 'application'], ['apple', 'apples', 'application']]\n assert candidate(products = ['apple', 'banana', 'grape', 'orange'],searchWord = \"ba\") == [['banana'], ['banana']]\n assert candidate(products = ['havana'],searchWord = \"havana\") == [['havana'], ['havana'], ['havana'], ['havana'], ['havana'], ['havana']]\n assert candidate(products = ['keyboard', 'keypad', 'kiosk'],searchWord = \"key\") == [['keyboard', 'keypad', 'kiosk'], ['keyboard', 'keypad'], ['keyboard', 'keypad']]\n assert candidate(products = ['apple', 'banana', 'grape', 'orange', 'peach'],searchWord = \"app\") == [['apple'], ['apple'], ['apple']]\n assert candidate(products = ['apple', 'apricot', 'banana', 'bat', 'berry'],searchWord = \"ba\") == [['banana', 'bat', 'berry'], ['banana', 'bat']]\n assert candidate(products = ['keyboard', 'keypad', 'keyboardpad'],searchWord = \"key\") == [['keyboard', 'keyboardpad', 'keypad'], ['keyboard', 'keyboardpad', 'keypad'], ['keyboard', 'keyboardpad', 'keypad']]\n assert candidate(products = ['mobile', 'mouse', 'moneypot', 'monitor', 'mousepad'],searchWord = \"mouse\") == [['mobile', 'moneypot', 'monitor'], ['mobile', 'moneypot', 'monitor'], ['mouse', 'mousepad'], ['mouse', 'mousepad'], ['mouse', 'mousepad']]\n assert candidate(products = ['aardvark', 'aardwolf', 'albatross', 'alligator', 'alpaca', 'antelope', 'anteater'],searchWord = \"aa\") == [['aardvark', 'aardwolf', 'albatross'], ['aardvark', 'aardwolf']]\n assert candidate(products = ['xylophone', 'xylography', 'xylem', 'xenon', 'xerox', 'xerophyte', 'xenodochial'],searchWord = \"xero\") == [['xenodochial', 'xenon', 'xerophyte'], ['xenodochial', 'xenon', 'xerophyte'], ['xerophyte', 'xerox'], ['xerophyte', 'xerox']]\n assert candidate(products = ['jacket', 'jaguar', 'jar', 'jasmine', 'jeep'],searchWord = \"ja\") == [['jacket', 'jaguar', 'jar'], ['jacket', 'jaguar', 'jar']]\n assert candidate(products = ['ant', 'anteater', 'antelope', 'antenna', 'antique', 'antfarm', 'antler'],searchWord = \"ant\") == [['ant', 'anteater', 'antelope'], ['ant', 'anteater', 'antelope'], ['ant', 'anteater', 'antelope']]\n assert candidate(products = ['television', 'telescope', 'temperature', 'tennis', 'tense'],searchWord = \"te\") == [['telescope', 'television', 'temperature'], ['telescope', 'television', 'temperature']]\n assert candidate(products = ['apple', 'apricot', 'banana', 'bat', 'berry', 'blackberry', 'blueberry'],searchWord = \"b\") == [['banana', 'bat', 'berry']]\n assert candidate(products = ['grape', 'grapefruit', 'grapevine', 'graph', 'grapejuice'],searchWord = \"gr\") == [['grape', 'grapefruit', 'grapejuice'], ['grape', 'grapefruit', 'grapejuice']]\n assert candidate(products = ['dog', 'dolphin', 'dome', 'domestic', 'domino'],searchWord = \"dom\") == [['dog', 'dolphin', 'dome'], ['dog', 'dolphin', 'dome'], ['dome', 'domestic', 'domino']]\n assert candidate(products = ['magnifier', 'magnificent', 'magnet', 'magnolia', 'magnitude'],searchWord = \"magn\") == [['magnet', 'magnificent', 'magnifier'], ['magnet', 'magnificent', 'magnifier'], ['magnet', 'magnificent', 'magnifier'], ['magnet', 'magnificent', 'magnifier']]\n assert candidate(products = ['apple', 'application', 'appliance', 'appropriate', 'appetizer'],searchWord = \"appl\") == [['appetizer', 'apple', 'appliance'], ['appetizer', 'apple', 'appliance'], ['appetizer', 'apple', 'appliance'], ['apple', 'appliance', 'application']]\n assert candidate(products = ['grape', 'grapefruit', 'grapejuice', 'graphite', 'grapevine', 'grapefruitjuice'],searchWord = \"grape\") == [['grape', 'grapefruit', 'grapefruitjuice'], ['grape', 'grapefruit', 'grapefruitjuice'], ['grape', 'grapefruit', 'grapefruitjuice'], ['grape', 'grapefruit', 'grapefruitjuice'], ['grape', 'grapefruit', 'grapefruitjuice']]\n assert candidate(products = ['hamburger', 'hammock', 'hammer', 'hammerhead', 'handheld'],searchWord = \"ham\") == [['hamburger', 'hammer', 'hammerhead'], ['hamburger', 'hammer', 'hammerhead'], ['hamburger', 'hammer', 'hammerhead']]\n assert candidate(products = ['watermelon', 'water', 'wave', 'wonder', 'wonderland'],searchWord = \"wat\") == [['water', 'watermelon', 'wave'], ['water', 'watermelon', 'wave'], ['water', 'watermelon']]\n assert candidate(products = ['amazon', 'amazing', 'ambassador', 'ambient', 'amplifier'],searchWord = \"ambi\") == [['amazing', 'amazon', 'ambassador'], ['amazing', 'amazon', 'ambassador'], ['ambassador', 'ambient'], ['ambient']]\n assert candidate(products = ['car', 'card', 'cardboard', 'cargo', 'cartoon'],searchWord = \"car\") == [['car', 'card', 'cardboard'], ['car', 'card', 'cardboard'], ['car', 'card', 'cardboard']]\n assert candidate(products = ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm'],searchWord = \"abc\") == [['abcd', 'abce', 'abcf'], ['abcd', 'abce', 'abcf'], ['abcd', 'abce', 'abcf']]\n assert candidate(products = ['zebra', 'zinc', 'zoo', 'zesty', 'zoning', 'zest', 'zookeeper'],searchWord = \"ze\") == [['zebra', 'zest', 'zesty'], ['zebra', 'zest', 'zesty']]\n assert candidate(products = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij'],searchWord = \"abcdefghijk\") == [['a', 'ab', 'abc'], ['ab', 'abc', 'abcd'], ['abc', 'abcd', 'abcde'], ['abcd', 'abcde', 'abcdef'], ['abcde', 'abcdef', 'abcdefg'], ['abcdef', 'abcdefg', 'abcdefgh'], ['abcdefg', 'abcdefgh', 'abcdefghi'], ['abcdefgh', 'abcdefghi', 'abcdefghij'], ['abcdefghi', 'abcdefghij'], ['abcdefghij'], []]\n assert candidate(products = ['apple', 'apricot', 'banana', 'bat', 'berry', 'blueberry', 'blackberry'],searchWord = \"ba\") == [['banana', 'bat', 'berry'], ['banana', 'bat']]\n assert candidate(products = ['zebra', 'zebrafish', 'zebrafly', 'zebratail', 'zebralight', 'zebrashoe', 'zebragram', 'zebratic', 'zebrastriped'],searchWord = \"zebra\") == [['zebra', 'zebrafish', 'zebrafly'], ['zebra', 'zebrafish', 'zebrafly'], ['zebra', 'zebrafish', 'zebrafly'], ['zebra', 'zebrafish', 'zebrafly'], ['zebra', 'zebrafish', 'zebrafly']]\n assert candidate(products = ['orange', 'oregano', 'organ', 'organize', 'organism'],searchWord = \"org\") == [['orange', 'oregano', 'organ'], ['orange', 'oregano', 'organ'], ['organ', 'organism', 'organize']]\n assert candidate(products = ['xenon', 'xerox', 'xenophobe', 'xenial', 'xenolith', 'xenoliths', 'xenonarc', 'xenonarcosis', 'xenolithologist'],searchWord = \"xen\") == [['xenial', 'xenolith', 'xenolithologist'], ['xenial', 'xenolith', 'xenolithologist'], ['xenial', 'xenolith', 'xenolithologist']]\n assert candidate(products = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aab', 'aac', 'aad', 'aaf', 'aag'],searchWord = \"aa\") == [['a', 'aa', 'aaa'], ['aa', 'aaa', 'aaaa']]\n assert candidate(products = ['laptop', 'laptopbag', 'laser', 'lateral', 'latitude'],searchWord = \"lap\") == [['laptop', 'laptopbag', 'laser'], ['laptop', 'laptopbag', 'laser'], ['laptop', 'laptopbag']]\n assert candidate(products = ['cherry', 'cranberry', 'cantaloupe', 'carrot', 'corn', 'cucumber'],searchWord = \"car\") == [['cantaloupe', 'carrot', 'cherry'], ['cantaloupe', 'carrot'], ['carrot']]\n assert candidate(products = ['aardvark', 'aardwolf', 'albatross', 'albino', 'alligator', 'alpaca', 'almighty'],searchWord = \"al\") == [['aardvark', 'aardwolf', 'albatross'], ['albatross', 'albino', 'alligator']]\n assert candidate(products = ['navigate', 'navigation', 'navigator', 'navy', 'navel'],searchWord = \"nav\") == [['navel', 'navigate', 'navigation'], ['navel', 'navigate', 'navigation'], ['navel', 'navigate', 'navigation']]\n assert candidate(products = ['electronics', 'electric', 'elephant', 'elbow', 'eleven'],searchWord = \"ele\") == [['elbow', 'electric', 'electronics'], ['elbow', 'electric', 'electronics'], ['electric', 'electronics', 'elephant']]\n assert candidate(products = ['apple', 'apricot', 'banana', 'bat', 'berry', 'blackberry', 'blueberry', 'bluebird', 'bluetooth'],searchWord = \"bl\") == [['banana', 'bat', 'berry'], ['blackberry', 'blueberry', 'bluebird']]\n assert candidate(products = ['applepie', 'applesauce', 'appleskin', 'apple', 'applejack'],searchWord = \"appl\") == [['apple', 'applejack', 'applepie'], ['apple', 'applejack', 'applepie'], ['apple', 'applejack', 'applepie'], ['apple', 'applejack', 'applepie']]\n assert candidate(products = ['queen', 'queens', 'queenship', 'queer', 'queue'],searchWord = \"quee\") == [['queen', 'queens', 'queenship'], ['queen', 'queens', 'queenship'], ['queen', 'queens', 'queenship'], ['queen', 'queens', 'queenship']]\n assert candidate(products = ['apple', 'apricot', 'avocado', 'banana', 'bat', 'berry', 'blackberry', 'blueberry', 'cherry', 'cantaloupe', 'cranberry'],searchWord = \"ap\") == [['apple', 'apricot', 'avocado'], ['apple', 'apricot']]\n assert candidate(products = ['applepie', 'applesauce', 'apple', 'appletart', 'apples', 'apricot'],searchWord = \"apple\") == [['apple', 'applepie', 'apples'], ['apple', 'applepie', 'apples'], ['apple', 'applepie', 'apples'], ['apple', 'applepie', 'apples'], ['apple', 'applepie', 'apples']]\n assert candidate(products = ['guitar', 'guitarcase', 'guitarhero', 'guitarpick', 'guitarstand', 'guitartuner', 'guitarstring'],searchWord = \"gu\") == [['guitar', 'guitarcase', 'guitarhero'], ['guitar', 'guitarcase', 'guitarhero']]\n assert candidate(products = ['ocean', 'ocelot', 'octopus', 'octagon', 'octagonal'],searchWord = \"oct\") == [['ocean', 'ocelot', 'octagon'], ['ocean', 'ocelot', 'octagon'], ['octagon', 'octagonal', 'octopus']]\n assert candidate(products = ['chocolate', 'chips', 'chipmunk', 'cheese', 'cherry', 'chili'],searchWord = \"ch\") == [['cheese', 'cherry', 'chili'], ['cheese', 'cherry', 'chili']]\n assert candidate(products = ['abcd', 'abce', 'abcf', 'abcg', 'abch'],searchWord = \"abc\") == [['abcd', 'abce', 'abcf'], ['abcd', 'abce', 'abcf'], ['abcd', 'abce', 'abcf']]\n assert candidate(products = ['zebra', 'zulu', 'zymurgy', 'zestful', 'zestfully', 'zestless', 'zippy', 'zoo', 'zoology', 'zucchini'],searchWord = \"zoo\") == [['zebra', 'zestful', 'zestfully'], ['zoo', 'zoology'], ['zoo', 'zoology']]\n assert candidate(products = ['fishing', 'fishtank', 'fish', 'fishmonger', 'fisherman', 'fishhook', 'fishnet'],searchWord = \"fish\") == [['fish', 'fisherman', 'fishhook'], ['fish', 'fisherman', 'fishhook'], ['fish', 'fisherman', 'fishhook'], ['fish', 'fisherman', 'fishhook']]\n assert candidate(products = ['banana', 'band', 'bangalore', 'bank', 'banner'],searchWord = \"ban\") == [['banana', 'band', 'bangalore'], ['banana', 'band', 'bangalore'], ['banana', 'band', 'bangalore']]\n assert candidate(products = ['paint', 'painter', 'painting', 'paintball', 'paintbrush'],searchWord = \"pain\") == [['paint', 'paintball', 'paintbrush'], ['paint', 'paintball', 'paintbrush'], ['paint', 'paintball', 'paintbrush'], ['paint', 'paintball', 'paintbrush']]\n assert candidate(products = ['flower', 'flour', 'flow', 'flourish', 'flourmill'],searchWord = \"flow\") == [['flour', 'flourish', 'flourmill'], ['flour', 'flourish', 'flourmill'], ['flour', 'flourish', 'flourmill'], ['flow', 'flower']]\n assert candidate(products = ['car', 'card', 'care', 'careful', 'careless'],searchWord = \"ca\") == [['car', 'card', 'care'], ['car', 'card', 'care']]\n assert candidate(products = ['football', 'footwear', 'footbridge', 'footnote', 'footrest', 'footlocker', 'footrace', 'footlight'],searchWord = \"foot\") == [['football', 'footbridge', 'footlight'], ['football', 'footbridge', 'footlight'], ['football', 'footbridge', 'footlight'], ['football', 'footbridge', 'footlight']]\n assert candidate(products = ['strawberry', 'straw', 'stratosphere', 'stranger', 'strategy'],searchWord = \"stra\") == [['stranger', 'strategy', 'stratosphere'], ['stranger', 'strategy', 'stratosphere'], ['stranger', 'strategy', 'stratosphere'], ['stranger', 'strategy', 'stratosphere']]\n assert candidate(products = ['apple', 'apricot', 'banana', 'bat', 'berry', 'blackberry', 'blueberry'],searchWord = \"ba\") == [['banana', 'bat', 'berry'], ['banana', 'bat']]\n assert candidate(products = ['watermelon', 'water', 'waterfall', 'watershed', 'watercolor'],searchWord = \"water\") == [['water', 'watercolor', 'waterfall'], ['water', 'watercolor', 'waterfall'], ['water', 'watercolor', 'waterfall'], ['water', 'watercolor', 'waterfall'], ['water', 'watercolor', 'waterfall']]\n assert candidate(products = ['computer', 'computational', 'compute', 'computing', 'computerized'],searchWord = \"compute\") == [['computational', 'compute', 'computer'], ['computational', 'compute', 'computer'], ['computational', 'compute', 'computer'], ['computational', 'compute', 'computer'], ['computational', 'compute', 'computer'], ['computational', 'compute', 'computer'], ['compute', 'computer', 'computerized']]\n assert candidate(products = ['strawberry', 'straw', 'strange', 'strategy', 'stranger'],searchWord = \"stra\") == [['strange', 'stranger', 'strategy'], ['strange', 'stranger', 'strategy'], ['strange', 'stranger', 'strategy'], ['strange', 'stranger', 'strategy']]\n assert candidate(products = ['elephant', 'elephantine', 'elegant', 'elevate', 'elementary'],searchWord = \"ele\") == [['elegant', 'elementary', 'elephant'], ['elegant', 'elementary', 'elephant'], ['elegant', 'elementary', 'elephant']]\n assert candidate(products = ['orange', 'ornament', 'organ', 'orchid', 'orchard', 'organize'],searchWord = \"or\") == [['orange', 'orchard', 'orchid'], ['orange', 'orchard', 'orchid']]\n assert candidate(products = ['aaab', 'aaac', 'aaad', 'aaae', 'aaaf', 'aaag', 'aaah', 'aaai', 'aaaj', 'aaak', 'aaal', 'aaam', 'aaan', 'aaao', 'aaap', 'aaaq', 'aaar', 'aaas', 'aaat', 'aaau', 'aaav', 'aaaw', 'aaax', 'aaay', 'aaaz'],searchWord = \"aaa\") == [['aaab', 'aaac', 'aaad'], ['aaab', 'aaac', 'aaad'], ['aaab', 'aaac', 'aaad']]\n assert candidate(products = ['internet', 'interact', 'interest', 'interior', 'interfere'],searchWord = \"inte\") == [['interact', 'interest', 'interfere'], ['interact', 'interest', 'interfere'], ['interact', 'interest', 'interfere'], ['interact', 'interest', 'interfere']]\n assert candidate(products = ['computer', 'compute', 'computation', 'compositor', 'composite', 'compress', 'compression', 'compressor', 'compressed'],searchWord = \"compre\") == [['composite', 'compositor', 'compress'], ['composite', 'compositor', 'compress'], ['composite', 'compositor', 'compress'], ['composite', 'compositor', 'compress'], ['compress', 'compressed', 'compression'], ['compress', 'compressed', 'compression']]\n assert candidate(products = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango', 'nectarine', 'orange', 'papaya', 'quince', 'raspberry', 'strawberry', 'tangerine', 'ugli', 'vanilla', 'watermelon', 'xigua', 'yellow', 'zucchini'],searchWord = \"a\") == [['apple']]\n assert candidate(products = ['radio', 'radiance', 'radiant', 'radioactive', 'radioactivity'],searchWord = \"radi\") == [['radiance', 'radiant', 'radio'], ['radiance', 'radiant', 'radio'], ['radiance', 'radiant', 'radio'], ['radiance', 'radiant', 'radio']]\n assert candidate(products = ['keyboard', 'keychain', 'keyhole', 'keylogger', 'keynote'],searchWord = \"key\") == [['keyboard', 'keychain', 'keyhole'], ['keyboard', 'keychain', 'keyhole'], ['keyboard', 'keychain', 'keyhole']]\n assert candidate(products = ['starship', 'stars', 'start', 'star', 'startrek', 'starfish'],searchWord = \"star\") == [['star', 'starfish', 'stars'], ['star', 'starfish', 'stars'], ['star', 'starfish', 'stars'], ['star', 'starfish', 'stars']]\n assert candidate(products = ['dog', 'dove', 'donkey', 'dragon', 'drone', 'drill', 'door'],searchWord = \"dr\") == [['dog', 'donkey', 'door'], ['dragon', 'drill', 'drone']]\n assert candidate(products = ['guitar', 'guitarist', 'guilt', 'guilty', 'gully'],searchWord = \"guil\") == [['guilt', 'guilty', 'guitar'], ['guilt', 'guilty', 'guitar'], ['guilt', 'guilty', 'guitar'], ['guilt', 'guilty']]\n assert candidate(products = ['algorithm', 'algebra', 'alabama', 'alaska', 'alligator'],searchWord = \"al\") == [['alabama', 'alaska', 'algebra'], ['alabama', 'alaska', 'algebra']]\n assert candidate(products = ['abcd', 'abce', 'abcf', 'abcg', 'abch', 'abci', 'abcj', 'abck', 'abcl', 'abcm', 'abcn'],searchWord = \"abcd\") == [['abcd', 'abce', 'abcf'], ['abcd', 'abce', 'abcf'], ['abcd', 'abce', 'abcf'], ['abcd']]\n assert candidate(products = ['zebra', 'zeal', 'zero', 'zone', 'zoo', 'zap', 'zest'],searchWord = \"ze\") == [['zap', 'zeal', 'zebra'], ['zeal', 'zebra', 'zero']]\n assert candidate(products = ['zebra', 'zoo', 'zoom', 'zoning', 'zone', 'zany', 'zap', 'zest', 'zigzag', 'zither'],searchWord = \"z\") == [['zany', 'zap', 'zebra']]\n assert candidate(products = ['piano', 'piccolo', 'pipe', 'pipeorgan', 'pitchfork'],searchWord = \"pi\") == [['piano', 'piccolo', 'pipe'], ['piano', 'piccolo', 'pipe']]\n assert candidate(products = ['umbrella', 'underwear', 'universe', 'unique', 'unit', 'unity', 'university', 'unicycle', 'unicorn', 'unzip'],searchWord = \"uni\") == [['umbrella', 'underwear', 'unicorn'], ['underwear', 'unicorn', 'unicycle'], ['unicorn', 'unicycle', 'unique']]\n assert candidate(products = ['banana', 'bandanna', 'bandage', 'band', 'bandwidth'],searchWord = \"band\") == [['banana', 'band', 'bandage'], ['banana', 'band', 'bandage'], ['banana', 'band', 'bandage'], ['band', 'bandage', 'bandanna']]\n", "comparison": "exact"}, "public_tests": ["[\"mobile\",\"mouse\",\"moneypot\",\"monitor\",\"mousepad\"]\n\"mouse\"", "[\"havana\"]\n\"havana\""], "hints": ["Brute force is a good choice because length of the string is ≤ 1000.", "Binary search the answer.", "Use Trie data structure to store the best three matching. Traverse the Trie."], "metadata": {"canonical_parameter_names": ["products", "searchWord"], "leetcode_dataset_entry_point": "Solution().suggestedProducts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:07+00:00", "tests_total": 109, "tests_dropped": 26, "flags": [], "topic_tags": ["array", "string", "binary-search", "trie", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def suggestedProducts(self, products: list[str], searchWord: str) -> list[list[str]]:", "container": "Solution", "callable": "suggestedProducts", "parameters": [{"name": "products", "type": "list[str]"}, {"name": "searchWord", "type": "str"}], "return_type": "list[list[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1269, "task_id": "number-of-ways-to-stay-in-the-same-place-after-some-steps", "difficulty": "Hard", "problem_description": "You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time).\n\nGiven two integers steps and arrLen, return the number of ways such that your pointer is still at index 0 after exactly steps steps. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: steps = 3, arrLen = 2\nOutput: 4\nExplanation: There are 4 differents ways to stay at index 0 after 3 steps.\nRight, Left, Stay\nStay, Right, Left\nRight, Stay, Left\nStay, Stay, Stay\n\nExample 2:\n\nInput: steps = 2, arrLen = 4\nOutput: 2\nExplanation: There are 2 differents ways to stay at index 0 after 2 steps\nRight, Left\nStay, Stay\n\nExample 3:\n\nInput: steps = 4, arrLen = 2\nOutput: 8\n\nConstraints:\n\n- 1 <= steps <= 500\n- 1 <= arrLen <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(steps = 5,arrLen = 3) == 21\n assert candidate(steps = 10,arrLen = 5) == 2187\n assert candidate(steps = 5,arrLen = 5) == 21\n assert candidate(steps = 2,arrLen = 4) == 2\n assert candidate(steps = 3,arrLen = 2) == 4\n assert candidate(steps = 10,arrLen = 1) == 1\n assert candidate(steps = 10,arrLen = 3) == 1682\n assert candidate(steps = 1,arrLen = 3) == 1\n assert candidate(steps = 4,arrLen = 2) == 8\n assert candidate(steps = 350,arrLen = 150) == 426619980\n assert candidate(steps = 20,arrLen = 10) == 50852018\n assert candidate(steps = 100,arrLen = 1000000) == 345787718\n assert candidate(steps = 200,arrLen = 10) == 27369014\n assert candidate(steps = 300,arrLen = 500) == 337584699\n assert candidate(steps = 200,arrLen = 1000) == 404113244\n assert candidate(steps = 250,arrLen = 100000) == 266783101\n assert candidate(steps = 250,arrLen = 250) == 266783101\n assert candidate(steps = 1,arrLen = 5) == 1\n assert candidate(steps = 200,arrLen = 50) == 228436718\n assert candidate(steps = 400,arrLen = 150) == 792402924\n assert candidate(steps = 100,arrLen = 5) == 361798919\n assert candidate(steps = 300,arrLen = 300) == 337584699\n assert candidate(steps = 150,arrLen = 100) == 924870032\n assert candidate(steps = 300,arrLen = 1) == 1\n assert candidate(steps = 400,arrLen = 10000) == 990505357\n assert candidate(steps = 100,arrLen = 20) == 227326058\n assert candidate(steps = 400,arrLen = 500) == 990505357\n assert candidate(steps = 400,arrLen = 20) == 378873335\n assert candidate(steps = 450,arrLen = 1000) == 679622497\n assert candidate(steps = 100,arrLen = 250) == 345787718\n assert candidate(steps = 7,arrLen = 7) == 127\n assert candidate(steps = 300,arrLen = 10) == 202608062\n assert candidate(steps = 100,arrLen = 500) == 345787718\n assert candidate(steps = 250,arrLen = 2) == 771819109\n assert candidate(steps = 200,arrLen = 300) == 404113244\n assert candidate(steps = 450,arrLen = 900) == 679622497\n assert candidate(steps = 150,arrLen = 50) == 700273839\n assert candidate(steps = 400,arrLen = 1) == 1\n assert candidate(steps = 50,arrLen = 5) == 316310597\n assert candidate(steps = 200,arrLen = 5) == 143744346\n assert candidate(steps = 30,arrLen = 5) == 559846999\n assert candidate(steps = 300,arrLen = 1000) == 337584699\n assert candidate(steps = 150,arrLen = 200) == 924870032\n assert candidate(steps = 20,arrLen = 5) == 44991659\n assert candidate(steps = 100,arrLen = 1000) == 345787718\n assert candidate(steps = 300,arrLen = 100) == 266213554\n assert candidate(steps = 350,arrLen = 350) == 47176184\n assert candidate(steps = 125,arrLen = 75) == 534594928\n assert candidate(steps = 150,arrLen = 10) == 809029961\n assert candidate(steps = 450,arrLen = 250) == 679622497\n assert candidate(steps = 250,arrLen = 1000) == 266783101\n assert candidate(steps = 150,arrLen = 1) == 1\n assert candidate(steps = 400,arrLen = 200) == 990505356\n assert candidate(steps = 120,arrLen = 300) == 991528385\n assert candidate(steps = 200,arrLen = 500000) == 404113244\n assert candidate(steps = 450,arrLen = 500) == 679622497\n assert candidate(steps = 180,arrLen = 10) == 513914322\n assert candidate(steps = 3,arrLen = 10) == 4\n assert candidate(steps = 100,arrLen = 10) == 836991026\n assert candidate(steps = 250,arrLen = 100) == 694490842\n assert candidate(steps = 250,arrLen = 5000) == 266783101\n assert candidate(steps = 250,arrLen = 10) == 321394621\n assert candidate(steps = 50,arrLen = 10) == 48059843\n assert candidate(steps = 250,arrLen = 50) == 739582172\n assert candidate(steps = 400,arrLen = 2) == 99483769\n", "comparison": "exact"}, "public_tests": ["3\n2", "2\n4", "4\n2"], "hints": ["Try with Dynamic programming, dp(pos,steps): number of ways to back pos = 0 using exactly \"steps\" moves.", "Notice that the computational complexity does not depend of \"arrlen\"."], "metadata": {"canonical_parameter_names": ["steps", "arrLen"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:09+00:00", "tests_total": 65, "tests_dropped": 0, "flags": [], "topic_tags": ["dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numWays(self, steps: int, arrLen: int) -> int:", "container": "Solution", "callable": "numWays", "parameters": [{"name": "steps", "type": "int"}, {"name": "arrLen", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1275, "task_id": "find-winner-on-a-tic-tac-toe-game", "difficulty": "Easy", "problem_description": "Tic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are:\n\n- Players take turns placing characters into empty squares ' '.\n- The first player A always places 'X' characters, while the second player B always places 'O' characters.\n- 'X' and 'O' characters are always placed into empty squares, never on filled ones.\n- The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.\n- The game also ends if all squares are non-empty.\n- No more moves can be played if the game is over.\n\nGiven a 2D integer array moves where moves[i] = [row_i, col_i] indicates that the i^th move will be played on grid[row_i][col_i]. return the winner of the game if it exists (A or B). In case the game ends in a draw return \"Draw\". If there are still movements to play return \"Pending\".\n\nYou can assume that moves is valid (i.e., it follows the rules of Tic-Tac-Toe), the grid is initially empty, and A will play first.\n\nExample 1:\n\nInput: moves = [[0,0],[2,0],[1,1],[2,1],[2,2]]\nOutput: \"A\"\nExplanation: A wins, they always play first.\n\nExample 2:\n\nInput: moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]]\nOutput: \"B\"\nExplanation: B wins.\n\nExample 3:\n\nInput: moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]]\nOutput: \"Draw\"\nExplanation: The game ends in a draw since there are no moves to make.\n\nConstraints:\n\n- 1 <= moves.length <= 9\n- moves[i].length == 2\n- 0 <= row_i, col_i <= 2\n- There are no repeated elements on moves.\n- moves follow the rules of tic tac toe.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [1, 0], [1, 2], [2, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [2, 0], [1, 1], [2, 1], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 2], [1, 1], [2, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 2], [0, 1], [1, 0], [2, 0], [2, 1], [1, 2]]) == \"Draw\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 0], [1, 0], [1, 2], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [0, 1], [0, 2], [1, 0], [2, 0]]) == \"B\"\n assert candidate(moves = [[0, 0], [0, 1], [0, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 0], [1, 0], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 2], [1, 0], [2, 0]]) == \"B\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 2], [2, 0], [1, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 1], [2, 0], [2, 1], [0, 2], [1, 0], [1, 2], [0, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [2, 0], [0, 1], [1, 1], [0, 2], [2, 1], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [0, 1], [0, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 2], [2, 0], [0, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 0], [1, 0], [1, 2], [2, 1], [0, 1], [0, 2], [2, 2]]) == \"Draw\"\n assert candidate(moves = [[0, 0], [2, 0], [1, 1], [2, 1], [1, 2], [0, 1], [0, 2], [1, 0], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 0], [0, 1], [1, 0], [2, 1], [0, 2], [1, 2], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [0, 1], [0, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [2, 0], [1, 1], [2, 1], [0, 1], [0, 0], [1, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 1], [0, 1], [2, 1], [0, 2], [2, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [0, 1], [0, 0], [1, 2], [2, 0], [2, 2], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[1, 0], [0, 0], [1, 1], [0, 1], [2, 0], [0, 2], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [2, 0], [1, 1], [1, 0], [0, 0], [2, 2], [2, 1], [0, 1], [1, 2]]) == \"Draw\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 2], [0, 0], [1, 0], [1, 2], [2, 2], [2, 1], [0, 1]]) == \"Draw\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 1], [0, 2], [1, 2], [2, 1], [0, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [0, 2], [1, 0], [1, 2], [2, 0]]) == \"Pending\"\n assert candidate(moves = [[2, 1], [0, 0], [1, 1], [1, 0], [2, 0], [1, 2], [2, 2], [0, 1], [0, 2]]) == \"A\"\n assert candidate(moves = [[1, 0], [2, 0], [0, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 0], [1, 0], [2, 1], [2, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [1, 0], [0, 2], [2, 0], [2, 1], [1, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 1], [0, 2], [2, 0], [1, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [2, 2], [0, 1], [1, 1], [2, 0], [0, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [2, 0], [0, 0], [2, 2], [1, 0], [2, 1]]) == \"A\"\n assert candidate(moves = [[0, 1], [2, 0], [1, 1], [0, 0], [2, 2], [1, 2], [0, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [2, 0], [2, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [0, 1], [1, 1], [0, 2], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 0], [2, 0], [1, 1], [1, 2], [2, 2], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [0, 1], [0, 0], [1, 0], [2, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 1], [1, 1], [0, 0], [0, 1], [0, 2], [2, 0], [2, 2], [1, 0], [1, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 0], [2, 0], [1, 1], [0, 1], [2, 1], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [0, 1], [0, 2], [1, 0], [2, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 0], [2, 1], [0, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 2], [0, 0], [0, 2], [2, 0], [1, 1], [1, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 0], [1, 0], [2, 2], [0, 2], [2, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [2, 0], [1, 1], [1, 0], [0, 2], [2, 1], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 2], [0, 0], [1, 0], [0, 1], [1, 1], [0, 2]]) == \"B\"\n assert candidate(moves = [[0, 0], [2, 0], [1, 0], [0, 1], [2, 1], [0, 2], [1, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [2, 2], [1, 0], [0, 1], [0, 0], [2, 0]]) == \"Pending\"\n assert candidate(moves = [[1, 1], [2, 0], [0, 2], [1, 0], [0, 0], [1, 2], [2, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[1, 1], [2, 0], [1, 0], [0, 0], [1, 2], [2, 1], [0, 1]]) == \"A\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 0], [0, 2], [2, 2], [1, 2], [1, 0]]) == \"A\"\n assert candidate(moves = [[0, 1], [1, 1], [2, 1], [0, 0], [1, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [1, 0], [0, 1], [1, 2], [0, 2], [2, 0], [2, 1], [2, 2]]) == \"A\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 2], [0, 0], [2, 2], [1, 2], [1, 0]]) == \"Pending\"\n assert candidate(moves = [[2, 0], [1, 0], [0, 0], [2, 1], [1, 1], [0, 1], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 1], [1, 0], [2, 1], [0, 2], [2, 0], [1, 2], [0, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 0], [2, 0], [0, 1], [0, 2], [1, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 1], [2, 0], [1, 0], [2, 1], [1, 1], [0, 2], [2, 2], [0, 0]]) == \"Pending\"\n assert candidate(moves = [[1, 1], [2, 2], [0, 0], [1, 0], [2, 0], [0, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 2], [0, 2], [1, 1], [2, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[1, 0], [0, 1], [2, 0], [1, 2], [0, 2], [2, 1], [1, 1]]) == \"A\"\n assert candidate(moves = [[0, 1], [1, 1], [2, 1], [0, 0], [0, 2], [2, 0], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 1], [0, 2], [1, 2], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 1], [0, 0], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [2, 2], [0, 1], [1, 1], [2, 0], [1, 0], [0, 2], [2, 1], [1, 2]]) == \"A\"\n assert candidate(moves = [[2, 1], [1, 1], [0, 0], [0, 1], [2, 0], [0, 2], [1, 0], [2, 2], [1, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [2, 1], [1, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 0], [0, 1], [1, 1], [0, 2], [2, 2], [2, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 2], [0, 0], [1, 1], [2, 1], [2, 0], [0, 1], [1, 0], [1, 2], [0, 2]]) == \"A\"\n assert candidate(moves = [[1, 0], [0, 0], [2, 0], [1, 1], [2, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [2, 0], [1, 1], [1, 0], [2, 1], [0, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [0, 2], [2, 2], [1, 0], [1, 2], [2, 0], [2, 1], [0, 1], [1, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [0, 1], [1, 1], [1, 0], [2, 2]]) == \"A\"\n assert candidate(moves = [[1, 1], [0, 0], [0, 1], [0, 2], [1, 2], [2, 0], [1, 0]]) == \"A\"\n assert candidate(moves = [[1, 1], [0, 0], [2, 0], [1, 0], [2, 2], [0, 1], [0, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 0], [0, 2], [1, 2], [2, 1]]) == \"B\"\n assert candidate(moves = [[0, 0], [1, 1], [1, 0], [0, 1], [0, 2], [2, 0], [2, 2], [1, 2], [2, 1]]) == \"Draw\"\n assert candidate(moves = [[2, 0], [0, 1], [1, 1], [0, 0], [2, 2], [1, 2], [2, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]) == \"B\"\n assert candidate(moves = [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 0], [2, 2]]) == \"A\"\n assert candidate(moves = [[2, 2], [0, 2], [2, 1], [0, 1], [2, 0], [0, 0], [1, 0], [1, 1]]) == \"B\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 0], [1, 0], [2, 1], [0, 1]]) == \"Pending\"\n assert candidate(moves = [[1, 0], [0, 0], [1, 1], [1, 2], [0, 1], [2, 1], [0, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[2, 2], [0, 0], [1, 1], [0, 1], [0, 2], [2, 1], [2, 0]]) == \"A\"\n assert candidate(moves = [[2, 2], [1, 1], [0, 0], [1, 2], [0, 1], [2, 1], [0, 2]]) == \"A\"\n assert candidate(moves = [[2, 0], [1, 1], [0, 2], [1, 0], [0, 0], [2, 2], [2, 1], [1, 2]]) == \"B\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 1], [0, 1], [0, 2], [2, 0], [2, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 1], [2, 2], [1, 1], [0, 2], [1, 2], [2, 0], [1, 0]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 1], [2, 1], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 1], [1, 2], [2, 0], [1, 0], [0, 2]]) == \"B\"\n assert candidate(moves = [[0, 2], [1, 1], [0, 1], [0, 0], [2, 0], [2, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [1, 1], [0, 1], [1, 2], [0, 2], [1, 0], [2, 0], [2, 2], [2, 1]]) == \"A\"\n assert candidate(moves = [[1, 1], [0, 0], [2, 0], [1, 0], [2, 2], [0, 1], [2, 1]]) == \"A\"\n assert candidate(moves = [[0, 1], [1, 1], [2, 1], [0, 0], [0, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [2, 0], [0, 1], [1, 2], [2, 1]]) == \"B\"\n assert candidate(moves = [[2, 0], [1, 0], [1, 1], [0, 2], [1, 2], [2, 1], [0, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [0, 2], [1, 1], [2, 2], [1, 0], [2, 0]]) == \"Pending\"\n assert candidate(moves = [[2, 0], [0, 0], [1, 1], [0, 1], [2, 1], [0, 2]]) == \"B\"\n assert candidate(moves = [[1, 1], [0, 0], [2, 2], [1, 0], [2, 1], [0, 2], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[0, 0], [2, 0], [0, 1], [2, 1], [0, 2], [1, 1], [2, 2], [1, 0], [1, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 0], [1, 0], [1, 2], [0, 2], [2, 1], [2, 2]]) == \"Pending\"\n assert candidate(moves = [[2, 2], [1, 1], [1, 0], [0, 0], [0, 2], [2, 0], [1, 2]]) == \"A\"\n assert candidate(moves = [[0, 0], [2, 2], [1, 0], [1, 1], [0, 1], [2, 0], [1, 2]]) == \"Pending\"\n assert candidate(moves = [[1, 1], [0, 0], [0, 1], [2, 2], [2, 0], [2, 1], [1, 0]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [0, 1], [0, 0], [2, 0], [1, 0], [2, 2], [1, 2], [2, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [2, 0], [1, 1], [0, 1], [2, 2], [1, 0], [2, 1]]) == \"A\"\n assert candidate(moves = [[0, 0], [1, 1], [2, 2], [0, 2], [1, 0], [2, 0], [0, 1]]) == \"Pending\"\n assert candidate(moves = [[0, 2], [1, 1], [0, 1], [1, 0], [2, 0], [0, 0]]) == \"Pending\"\n", "comparison": "exact"}, "public_tests": ["[[0,0],[2,0],[1,1],[2,1],[2,2]]", "[[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]]", "[[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]]"], "hints": ["It's straightforward to check if A or B won or not, check for each row/column/diag if all the three are the same.", "Then if no one wins, the game is a draw iff the board is full, i.e. moves.length = 9 otherwise is pending."], "metadata": {"canonical_parameter_names": ["moves"], "leetcode_dataset_entry_point": "Solution().tictactoe", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:18+00:00", "tests_total": 114, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "matrix", "simulation"]}, "language": "python", "interface": {"raw_signature": "def tictactoe(self, moves: list[list[int]]) -> str:", "container": "Solution", "callable": "tictactoe", "parameters": [{"name": "moves", "type": "list[list[int]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1276, "task_id": "number-of-burgers-with-no-waste-of-ingredients", "difficulty": "Medium", "problem_description": "Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows:\n\n- Jumbo Burger: 4 tomato slices and 1 cheese slice.\n- Small Burger: 2 Tomato slices and 1 cheese slice.\n\nReturn [total_jumbo, total_small] so that the number of remaining tomatoSlices equal to 0 and the number of remaining cheeseSlices equal to 0. If it is not possible to make the remaining tomatoSlices and cheeseSlices equal to 0 return [].\n\nExample 1:\n\nInput: tomatoSlices = 16, cheeseSlices = 7\nOutput: [1,6]\nExplantion: To make one jumbo burger and 6 small burgers we need 4*1 + 2*6 = 16 tomato and 1 + 6 = 7 cheese.\nThere will be no remaining ingredients.\n\nExample 2:\n\nInput: tomatoSlices = 17, cheeseSlices = 4\nOutput: []\nExplantion: There will be no way to use all ingredients to make small and jumbo burgers.\n\nExample 3:\n\nInput: tomatoSlices = 4, cheeseSlices = 17\nOutput: []\nExplantion: Making 1 jumbo burger there will be 16 cheese remaining and making 2 small burgers there will be 15 cheese remaining.\n\nConstraints:\n\n- 0 <= tomatoSlices, cheeseSlices <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tomatoSlices = 10000000,cheeseSlices = 5000000) == [0, 5000000]\n assert candidate(tomatoSlices = 16,cheeseSlices = 7) == [1, 6]\n assert candidate(tomatoSlices = 14,cheeseSlices = 5) == [2, 3]\n assert candidate(tomatoSlices = 8,cheeseSlices = 2) == [2, 0]\n assert candidate(tomatoSlices = 20,cheeseSlices = 5) == [5, 0]\n assert candidate(tomatoSlices = 0,cheeseSlices = 0) == [0, 0]\n assert candidate(tomatoSlices = 10,cheeseSlices = 3) == [2, 1]\n assert candidate(tomatoSlices = 4,cheeseSlices = 17) == []\n assert candidate(tomatoSlices = 8,cheeseSlices = 4) == [0, 4]\n assert candidate(tomatoSlices = 2,cheeseSlices = 1) == [0, 1]\n assert candidate(tomatoSlices = 6,cheeseSlices = 3) == [0, 3]\n assert candidate(tomatoSlices = 10000000,cheeseSlices = 2500000) == [2500000, 0]\n assert candidate(tomatoSlices = 17,cheeseSlices = 4) == []\n assert candidate(tomatoSlices = 10,cheeseSlices = 5) == [0, 5]\n assert candidate(tomatoSlices = 22,cheeseSlices = 5) == []\n assert candidate(tomatoSlices = 22,cheeseSlices = 6) == [5, 1]\n assert candidate(tomatoSlices = 1000,cheeseSlices = 250) == [250, 0]\n assert candidate(tomatoSlices = 1,cheeseSlices = 1) == []\n assert candidate(tomatoSlices = 12,cheeseSlices = 3) == [3, 0]\n assert candidate(tomatoSlices = 42,cheeseSlices = 14) == [7, 7]\n assert candidate(tomatoSlices = 28,cheeseSlices = 7) == [7, 0]\n assert candidate(tomatoSlices = 5000000,cheeseSlices = 2000000) == [500000, 1500000]\n assert candidate(tomatoSlices = 30,cheeseSlices = 8) == [7, 1]\n assert candidate(tomatoSlices = 22,cheeseSlices = 11) == [0, 11]\n assert candidate(tomatoSlices = 15,cheeseSlices = 5) == []\n assert candidate(tomatoSlices = 7,cheeseSlices = 2) == []\n assert candidate(tomatoSlices = 88,cheeseSlices = 22) == [22, 0]\n assert candidate(tomatoSlices = 7,cheeseSlices = 3) == []\n assert candidate(tomatoSlices = 18,cheeseSlices = 5) == [4, 1]\n assert candidate(tomatoSlices = 18,cheeseSlices = 8) == [1, 7]\n assert candidate(tomatoSlices = 40,cheeseSlices = 10) == [10, 0]\n assert candidate(tomatoSlices = 9,cheeseSlices = 3) == []\n assert candidate(tomatoSlices = 12,cheeseSlices = 5) == [1, 4]\n assert candidate(tomatoSlices = 5,cheeseSlices = 3) == []\n assert candidate(tomatoSlices = 22,cheeseSlices = 9) == [2, 7]\n assert candidate(tomatoSlices = 50,cheeseSlices = 12) == []\n assert candidate(tomatoSlices = 32,cheeseSlices = 8) == [8, 0]\n assert candidate(tomatoSlices = 100,cheeseSlices = 30) == [20, 10]\n assert candidate(tomatoSlices = 24,cheeseSlices = 6) == [6, 0]\n assert candidate(tomatoSlices = 32,cheeseSlices = 10) == [6, 4]\n assert candidate(tomatoSlices = 14,cheeseSlices = 7) == [0, 7]\n assert candidate(tomatoSlices = 7,cheeseSlices = 4) == []\n assert candidate(tomatoSlices = 80,cheeseSlices = 15) == []\n assert candidate(tomatoSlices = 34,cheeseSlices = 8) == []\n assert candidate(tomatoSlices = 20,cheeseSlices = 8) == [2, 6]\n assert candidate(tomatoSlices = 28,cheeseSlices = 6) == []\n assert candidate(tomatoSlices = 14,cheeseSlices = 4) == [3, 1]\n assert candidate(tomatoSlices = 16,cheeseSlices = 10) == []\n assert candidate(tomatoSlices = 123456,cheeseSlices = 65432) == []\n assert candidate(tomatoSlices = 50,cheeseSlices = 15) == [10, 5]\n assert candidate(tomatoSlices = 34,cheeseSlices = 9) == [8, 1]\n assert candidate(tomatoSlices = 10,cheeseSlices = 2) == []\n assert candidate(tomatoSlices = 12,cheeseSlices = 6) == [0, 6]\n assert candidate(tomatoSlices = 8,cheeseSlices = 3) == [1, 2]\n assert candidate(tomatoSlices = 34,cheeseSlices = 11) == [6, 5]\n assert candidate(tomatoSlices = 25,cheeseSlices = 8) == []\n assert candidate(tomatoSlices = 18,cheeseSlices = 6) == [3, 3]\n assert candidate(tomatoSlices = 5000000,cheeseSlices = 1250000) == [1250000, 0]\n assert candidate(tomatoSlices = 14,cheeseSlices = 3) == []\n assert candidate(tomatoSlices = 9999998,cheeseSlices = 4999999) == [0, 4999999]\n assert candidate(tomatoSlices = 22,cheeseSlices = 7) == [4, 3]\n assert candidate(tomatoSlices = 28,cheeseSlices = 10) == [4, 6]\n assert candidate(tomatoSlices = 30,cheeseSlices = 10) == [5, 5]\n assert candidate(tomatoSlices = 4,cheeseSlices = 0) == []\n assert candidate(tomatoSlices = 12,cheeseSlices = 4) == [2, 2]\n assert candidate(tomatoSlices = 10,cheeseSlices = 4) == [1, 3]\n assert candidate(tomatoSlices = 100,cheeseSlices = 25) == [25, 0]\n assert candidate(tomatoSlices = 44,cheeseSlices = 11) == [11, 0]\n assert candidate(tomatoSlices = 34,cheeseSlices = 13) == [4, 9]\n", "comparison": "exact"}, "public_tests": ["16\n7", "17\n4", "4\n17"], "hints": ["Can we have an answer if the number of tomatoes is odd ?", "If we have answer will be there multiple answers or just one answer ?", "Let us define number of jumbo burgers as X and number of small burgers as Y We have to find an x and y in this equation", "1. 4X + 2Y = tomato", "2. X + Y = cheese"], "metadata": {"canonical_parameter_names": ["tomatoSlices", "cheeseSlices"], "leetcode_dataset_entry_point": "Solution().numOfBurgers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:21+00:00", "tests_total": 73, "tests_dropped": 4, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def numOfBurgers(self, tomatoSlices: int, cheeseSlices: int) -> list[int]:", "container": "Solution", "callable": "numOfBurgers", "parameters": [{"name": "tomatoSlices", "type": "int"}, {"name": "cheeseSlices", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1277, "task_id": "count-square-submatrices-with-all-ones", "difficulty": "Medium", "problem_description": "Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.\n\nExample 1:\n\nInput: matrix =\n[\n [0,1,1,1],\n [1,1,1,1],\n [0,1,1,1]\n]\nOutput: 15\nExplanation:\nThere are 10 squares of side 1.\nThere are 4 squares of side 2.\nThere is 1 square of side 3.\nTotal number of squares = 10 + 4 + 1 = 15.\n\nExample 2:\n\nInput: matrix =\n[\n [1,0,1],\n [1,1,0],\n [1,1,0]\n]\nOutput: 7\nExplanation:\nThere are 6 squares of side 1.\nThere is 1 square of side 2.\nTotal number of squares = 6 + 1 = 7.\n\nConstraints:\n\n- 1 <= arr.length <= 300\n- 1 <= arr[0].length <= 300\n- 0 <= arr[i][j] <= 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 24\n assert candidate(matrix = [[1]]) == 1\n assert candidate(matrix = [[0]]) == 0\n assert candidate(matrix = [[0, 1, 1, 1], [1, 1, 1, 1], [0, 1, 1, 1]]) == 15\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 0, 1], [1, 1, 0], [1, 1, 0]]) == 7\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 14\n assert candidate(matrix = [[1, 1], [1, 1]]) == 5\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1]]) == 42\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 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(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 140\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 40\n assert candidate(matrix = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 25\n assert candidate(matrix = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0]]) == 34\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]]) == 15\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 43\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1]]) == 24\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 91\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]]) == 13\n assert candidate(matrix = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 8\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 12\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], [0, 1, 0, 1, 0, 1]]) == 18\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 55\n assert candidate(matrix = [[1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 0, 1, 1]]) == 30\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 38\n assert candidate(matrix = [[1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 26\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 204\n assert candidate(matrix = [[1, 1, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 0, 0], [1, 0, 0, 1, 0, 1]]) == 36\n assert candidate(matrix = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1]]) == 29\n assert candidate(matrix = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1]]) == 48\n assert candidate(matrix = [[1, 1, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 0, 1]]) == 30\n assert candidate(matrix = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 30\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(matrix = [[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]]) == 14\n assert candidate(matrix = [[1, 1, 1, 1, 0], [1, 1, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0]]) == 15\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 30\n assert candidate(matrix = [[1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0]]) == 43\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 25\n assert candidate(matrix = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == 11\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 10\n assert candidate(matrix = [[1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0]]) == 32\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, 0, 1, 0, 1]]) == 25\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 70\n assert candidate(matrix = [[1, 1, 0, 1, 1], [1, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1]]) == 16\n assert candidate(matrix = [[0, 1, 0, 1], [1, 1, 1, 1], [0, 1, 0, 1], [1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 5\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 40\n assert candidate(matrix = [[1, 1, 0, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1]]) == 30\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1]]) == 32\n assert candidate(matrix = [[1, 1, 0, 1], [1, 1, 0, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == 11\n assert candidate(matrix = [[0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 1, 0, 1]]) == 32\n assert candidate(matrix = [[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]]) == 14\n assert candidate(matrix = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == 10\n assert candidate(matrix = [[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]]) == 8\n assert candidate(matrix = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0]]) == 27\n assert candidate(matrix = [[0, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1]]) == 29\n assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1]]) == 51\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 0, 0, 1, 1]]) == 17\n assert candidate(matrix = [[0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1]]) == 26\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 21\n assert candidate(matrix = [[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(matrix = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 22\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 18\n assert candidate(matrix = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]]) == 17\n assert candidate(matrix = [[1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0]]) == 43\n", "comparison": "exact"}, "public_tests": ["[[0,1,1,1],[1,1,1,1],[0,1,1,1]]", "[[1,0,1],[1,1,0],[1,1,0]]"], "hints": ["Create an additive table that counts the sum of elements of submatrix with the superior corner at (0,0).", "Loop over all subsquares in O(n^3) and check if the sum make the whole array to be ones, if it checks then add 1 to the answer."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().countSquares", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:23+00:00", "tests_total": 67, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def countSquares(self, matrix: list[list[int]]) -> int:", "container": "Solution", "callable": "countSquares", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1278, "task_id": "palindrome-partitioning-iii", "difficulty": "Hard", "problem_description": "You are given a string s containing lowercase letters and an integer k. You need to :\n\n- First, change some characters of s to other lowercase English letters.\n- Then divide s into k non-empty disjoint substrings such that each substring is a palindrome.\n\nReturn the minimal number of characters that you need to change to divide the string.\n\nExample 1:\n\nInput: s = \"abc\", k = 2\nOutput: 1\nExplanation: You can split the string into \"ab\" and \"c\", and change 1 character in \"ab\" to make it palindrome.\n\nExample 2:\n\nInput: s = \"aabbc\", k = 3\nOutput: 0\nExplanation: You can split the string into \"aa\", \"bb\" and \"c\", all of them are palindrome.\n\nExample 3:\n\nInput: s = \"leetcode\", k = 8\nOutput: 0\n\nConstraints:\n\n- 1 <= k <= s.length <= 100.\n- s only contains lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",k = 2) == 1\n assert candidate(s = \"abababa\",k = 4) == 1\n assert candidate(s = \"aaaa\",k = 2) == 0\n assert candidate(s = \"leetcode\",k = 8) == 0\n assert candidate(s = \"abcd\",k = 2) == 1\n assert candidate(s = \"racecar\",k = 5) == 0\n assert candidate(s = \"nnn\",k = 1) == 0\n assert candidate(s = \"abac\",k = 3) == 1\n assert candidate(s = \"racecar\",k = 1) == 0\n assert candidate(s = \"aabbc\",k = 3) == 0\n assert candidate(s = \"abacdfgdcaba\",k = 3) == 1\n assert candidate(s = \"palindrome\",k = 2) == 4\n assert candidate(s = \"aaaabbbbcccc\",k = 3) == 0\n assert candidate(s = \"aabbccdd\",k = 4) == 0\n assert candidate(s = \"zzzzzzzzzz\",k = 1) == 0\n assert candidate(s = \"palindrome\",k = 4) == 3\n assert candidate(s = \"mississippi\",k = 4) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 13) == 14\n assert candidate(s = \"banana\",k = 2) == 0\n assert candidate(s = \"abcdefg\",k = 7) == 0\n assert candidate(s = \"aabbaabbaabbaabb\",k = 4) == 0\n assert candidate(s = \"ababababab\",k = 5) == 1\n assert candidate(s = \"abcdefg\",k = 4) == 2\n assert candidate(s = \"aabbccddeeff\",k = 6) == 0\n assert candidate(s = \"abcdcbaabcdcba\",k = 4) == 0\n assert candidate(s = \"xyxyxyxyxy\",k = 5) == 1\n assert candidate(s = \"mamamamamama\",k = 5) == 1\n assert candidate(s = \"zxyxzyxzyxzyx\",k = 4) == 2\n assert candidate(s = \"aababababa\",k = 5) == 0\n assert candidate(s = \"xyxyxyxyxyxyxyxyxy\",k = 9) == 1\n assert candidate(s = \"zazapapa\",k = 3) == 1\n assert candidate(s = \"xyxyxyxyx\",k = 5) == 0\n assert candidate(s = \"abababab\",k = 5) == 1\n assert candidate(s = \"abcde\",k = 3) == 1\n assert candidate(s = \"mnopqrstu\",k = 5) == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 50) == 0\n assert candidate(s = \"abcdedcba\",k = 3) == 0\n assert candidate(s = \"abcbcaabc\",k = 3) == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 0\n assert candidate(s = \"abcdefgabcdefg\",k = 2) == 6\n assert candidate(s = \"aaaaaaaaaaa\",k = 2) == 0\n assert candidate(s = \"aabbaa\",k = 3) == 0\n assert candidate(s = \"racecar\",k = 3) == 0\n assert candidate(s = \"abcdefghijk\",k = 3) == 4\n assert candidate(s = \"aabbccddeeffgghh\",k = 8) == 0\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyx\",k = 5) == 4\n assert candidate(s = \"levelmadammadam\",k = 4) == 0\n assert candidate(s = \"abcdefghij\",k = 5) == 3\n assert candidate(s = \"abcdabcdabcd\",k = 3) == 3\n assert candidate(s = \"noonnoonnoon\",k = 6) == 0\n assert candidate(s = \"aaaaaaaaaa\",k = 5) == 0\n assert candidate(s = \"banana\",k = 3) == 1\n assert candidate(s = \"noonnoonnoon\",k = 4) == 0\n assert candidate(s = \"racecar\",k = 2) == 3\n assert candidate(s = \"abacdefghijklmnopqrstuvwxyz\",k = 26) == 1\n assert candidate(s = \"xyzyxzyzxzyx\",k = 6) == 0\n assert candidate(s = \"abcbabc\",k = 3) == 0\n assert candidate(s = \"aabbaa\",k = 2) == 1\n assert candidate(s = \"aaaaabbbbb\",k = 2) == 0\n assert candidate(s = \"abccba\",k = 1) == 0\n assert candidate(s = \"abcbabcba\",k = 4) == 1\n assert candidate(s = \"abcdefghi\",k = 3) == 3\n assert candidate(s = \"abcdefgh\",k = 8) == 0\n assert candidate(s = \"abcdefghi\",k = 9) == 0\n assert candidate(s = \"xyzyzyzyzyzyz\",k = 3) == 0\n assert candidate(s = \"abcdefg\",k = 3) == 2\n assert candidate(s = \"aabaaa\",k = 2) == 0\n assert candidate(s = \"abcdefg\",k = 1) == 3\n assert candidate(s = \"ababab\",k = 2) == 0\n assert candidate(s = \"abcdabc\",k = 3) == 1\n assert candidate(s = \"xyzxyzxyz\",k = 3) == 2\n assert candidate(s = \"abccccba\",k = 2) == 2\n assert candidate(s = \"mississippi\",k = 3) == 1\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == 0\n assert candidate(s = \"abababababababababab\",k = 10) == 0\n assert candidate(s = \"ababababa\",k = 5) == 0\n assert candidate(s = \"abacabadabacaba\",k = 7) == 0\n assert candidate(s = \"abccccba\",k = 3) == 0\n assert candidate(s = \"abcdefghi\",k = 5) == 2\n assert candidate(s = \"abacaxaba\",k = 4) == 1\n assert candidate(s = \"aababbaab\",k = 4) == 0\n assert candidate(s = \"aaaaabbbbbcccccddddd\",k = 10) == 0\n assert candidate(s = \"racecarannakayak\",k = 4) == 1\n assert candidate(s = \"abbaabba\",k = 4) == 0\n assert candidate(s = \"abacaxabac\",k = 5) == 1\n assert candidate(s = \"zzzzzzzzz\",k = 5) == 0\n assert candidate(s = \"aaaaabbbbb\",k = 5) == 0\n assert candidate(s = \"abcdabcdabcd\",k = 4) == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 26) == 0\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n2", "\"aabbc\"\n3", "\"leetcode\"\n8"], "hints": ["For each substring calculate the minimum number of steps to make it palindrome and store it in a table.", "Create a dp(pos, cnt) which means the minimum number of characters changed for the suffix of s starting on pos splitting the suffix on cnt chunks."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().palindromePartition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:25+00:00", "tests_total": 89, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def palindromePartition(self, s: str, k: int) -> int:", "container": "Solution", "callable": "palindromePartition", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1281, "task_id": "subtract-the-product-and-sum-of-digits-of-an-integer", "difficulty": "Easy", "problem_description": "Given an integer number n, return the difference between the product of its digits and the sum of its digits.\n\nExample 1:\n\nInput: n = 234\nOutput: 15\nExplanation:\nProduct of digits = 2 * 3 * 4 = 24\nSum of digits = 2 + 3 + 4 = 9\nResult = 24 - 9 = 15\n\nExample 2:\n\nInput: n = 4421\nOutput: 21\nExplanation:\nProduct of digits = 4 * 4 * 2 * 1 = 32\nSum of digits = 4 + 4 + 2 + 1 = 11\nResult = 32 - 11 = 21\n\nConstraints:\n\n- 1 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 99999) == 59004\n assert candidate(n = 11111) == -4\n assert candidate(n = 789) == 480\n assert candidate(n = 1111) == -3\n assert candidate(n = 234) == 15\n assert candidate(n = 12345) == 105\n assert candidate(n = 456) == 105\n assert candidate(n = 10000) == -1\n assert candidate(n = 9999) == 6525\n assert candidate(n = 100) == -1\n assert candidate(n = 105) == -6\n assert candidate(n = 1000) == -1\n assert candidate(n = 4421) == 21\n assert candidate(n = 4321) == 14\n assert candidate(n = 123) == 0\n assert candidate(n = 33333) == 228\n assert candidate(n = 55555) == 3100\n assert candidate(n = 10987) == -25\n assert candidate(n = 77777) == 16772\n assert candidate(n = 67890) == -30\n assert candidate(n = 86420) == -20\n assert candidate(n = 56789) == 15085\n assert candidate(n = 24680) == -20\n assert candidate(n = 59382) == 2133\n assert candidate(n = 80808) == -24\n assert candidate(n = 50400) == -9\n assert candidate(n = 44444) == 1004\n assert candidate(n = 59876) == 15085\n assert candidate(n = 100000) == -1\n assert candidate(n = 10401) == -6\n assert candidate(n = 10101) == -3\n assert candidate(n = 29999) == 13084\n assert candidate(n = 22222) == 22\n assert candidate(n = 13579) == 920\n assert candidate(n = 90909) == -27\n assert candidate(n = 98765) == 15085\n assert candidate(n = 43210) == -10\n assert candidate(n = 95135) == 652\n assert candidate(n = 91123) == 38\n assert candidate(n = 10010) == -2\n assert candidate(n = 54321) == 105\n assert candidate(n = 76543) == 2495\n", "comparison": "exact"}, "public_tests": ["234", "4421"], "hints": ["How to compute all digits of the number ?", "Use modulus operator (%) to compute the last digit.", "Generalise modulus operator idea to compute all digits."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().subtractProductAndSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:27+00:00", "tests_total": 55, "tests_dropped": 13, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def subtractProductAndSum(self, n: int) -> int:", "container": "Solution", "callable": "subtractProductAndSum", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1282, "task_id": "group-the-people-given-the-group-size-they-belong-to", "difficulty": "Medium", "problem_description": "There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1.\n\nYou are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1] = 3, then person 1 must be in a group of size 3.\n\nReturn a list of groups such that each person i is in a group of size groupSizes[i].\n\nEach person should appear in exactly one group, and every person must be in a group. If there are multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.\n\nExample 1:\n\nInput: groupSizes = [3,3,3,3,3,1,3]\nOutput: [[5],[0,1,2],[3,4,6]]\nExplanation:\nThe first group is [5]. The size is 1, and groupSizes[5] = 1.\nThe second group is [0,1,2]. The size is 3, and groupSizes[0] = groupSizes[1] = groupSizes[2] = 3.\nThe third group is [3,4,6]. The size is 3, and groupSizes[3] = groupSizes[4] = groupSizes[6] = 3.\nOther possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]].\n\nExample 2:\n\nInput: groupSizes = [2,1,3,3,3,2]\nOutput: [[1],[0,5],[2,3,4]]\n\nConstraints:\n\n- groupSizes.length == n\n- 1 <= n <= 500\n- 1 <= groupSizes[i] <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(groupSizes = [1, 2, 2, 1, 1]) == [[0], [3], [4], [1, 2]]\n assert candidate(groupSizes = [1, 1, 1, 1, 1, 1]) == [[0], [1], [2], [3], [4], [5]]\n assert candidate(groupSizes = [1, 2, 2, 1]) == [[0], [3], [1, 2]]\n assert candidate(groupSizes = [2, 2, 2, 2, 2, 2]) == [[0, 1], [2, 3], [4, 5]]\n assert candidate(groupSizes = [2, 2, 3, 3, 3, 4, 4, 4, 4]) == [[0, 1], [2, 3, 4], [5, 6, 7, 8]]\n assert candidate(groupSizes = [2, 2, 3, 3, 3]) == [[0, 1], [2, 3, 4]]\n assert candidate(groupSizes = [2, 2, 3, 3, 3, 3, 3, 3]) == [[0, 1], [2, 3, 4], [5, 6, 7]]\n assert candidate(groupSizes = [2, 2, 1, 1]) == [[0, 1], [2], [3]]\n assert candidate(groupSizes = [2, 1, 3, 3, 3, 2]) == [[0, 5], [1], [2, 3, 4]]\n assert candidate(groupSizes = [1, 1, 1, 1, 1]) == [[0], [1], [2], [3], [4]]\n assert candidate(groupSizes = [3, 3, 3, 3, 3, 1, 3]) == [[0, 1, 2], [3, 4, 6], [5]]\n assert candidate(groupSizes = [1, 2, 3, 4, 5]) == [[0], [1], [2], [3], [4]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5]) == [[0, 1, 2, 3, 4]]\n assert candidate(groupSizes = [4, 4, 4, 4]) == [[0, 1, 2, 3]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3]) == [[0, 1, 2, 3, 4], [5], [6], [7], [8], [9], [10, 11], [12, 13, 14]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [[0, 1, 2, 3, 4], [5], [6], [7], [8], [9]]\n assert candidate(groupSizes = [4, 4, 4, 4, 4, 4, 4, 4]) == [[0, 1, 2, 3], [4, 5, 6, 7]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 4, 4, 4, 3, 3, 2, 2, 1]) == [[0, 1, 2, 3, 4], [5, 6, 7], [8, 9], [10, 11], [12]]\n assert candidate(groupSizes = [7, 2, 2, 7, 7, 2, 2, 2, 7, 7, 7, 7, 7]) == [[0, 3, 4, 8, 9, 10, 11], [12], [1, 2], [5, 6], [7]]\n assert candidate(groupSizes = [3, 3, 3, 3, 3, 2, 2]) == [[0, 1, 2], [3, 4], [5, 6]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == [[0, 1, 2, 3, 4], [5], [6], [7], [8], [9], [10, 11], [12, 13], [14]]\n assert candidate(groupSizes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]\n assert candidate(groupSizes = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42, 43]]\n assert candidate(groupSizes = [2, 3, 3, 2, 3, 3, 1]) == [[0, 3], [1, 2, 4], [5], [6]]\n assert candidate(groupSizes = [3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4]) == [[0, 1, 2], [3], [4, 5], [6], [7], [8], [9], [10], [11, 12, 13, 14]]\n assert candidate(groupSizes = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13]]\n assert candidate(groupSizes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10], [11], [12], [13], [14]]\n assert candidate(groupSizes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19]]\n assert candidate(groupSizes = [2, 3, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [[0, 2], [3], [1, 4, 5], [6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21]]\n assert candidate(groupSizes = [2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2]) == [[0, 3], [4, 7], [8, 11], [1, 2, 5], [6, 9, 10]]\n assert candidate(groupSizes = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [[0], [1, 2], [3, 4, 5], [6, 7, 8, 9]]\n assert candidate(groupSizes = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [[0, 2], [4, 6], [8, 10], [12, 14], [1, 3, 5], [7, 9, 11], [13, 15]]\n assert candidate(groupSizes = [1, 2, 3, 2, 1, 3, 4, 3, 4, 2, 1, 4, 3, 2, 1, 3, 4, 3, 2, 1, 4]) == [[0], [4], [10], [14], [19], [1, 3], [9, 13], [18], [2, 5, 7], [12, 15, 17], [6, 8, 11, 16], [20]]\n assert candidate(groupSizes = [2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6]) == [[0, 5], [10], [1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 9, 14]]\n assert candidate(groupSizes = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == [[0, 1], [2, 3, 4], [5], [6, 7, 8, 9]]\n assert candidate(groupSizes = [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, 1, 1, 1, 1, 1, 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]]\n assert candidate(groupSizes = [3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1]) == [[0, 1, 2], [3], [4, 5], [6], [7], [8], [9], [10]]\n assert candidate(groupSizes = [7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]) == [[0, 1, 2, 3, 4, 5, 6], [7], [8], [9], [10], [11], [12], [13], [14, 15], [16]]\n assert candidate(groupSizes = [2, 3, 2, 3, 3, 2, 3]) == [[0, 2], [5], [1, 3, 4], [6]]\n assert candidate(groupSizes = [7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1]) == [[0, 1, 2, 3, 4, 5, 6], [7], [8], [9], [10], [11], [12], [13]]\n assert candidate(groupSizes = [3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[0, 1, 2], [3, 4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19]]\n assert candidate(groupSizes = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [[0], [1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14]]\n assert candidate(groupSizes = [4, 3, 3, 4, 2, 2, 4, 3, 3, 4, 2, 2, 4, 3, 3, 4, 2, 2]) == [[0, 3, 6, 9], [12, 15], [1, 2, 7], [8, 13, 14], [4, 5], [10, 11], [16, 17]]\n assert candidate(groupSizes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14]]\n assert candidate(groupSizes = [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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [[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]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15], [16], [17], [18], [19]]\n assert candidate(groupSizes = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == [[0], [10], [1, 9], [2, 8], [3, 7], [4, 6], [5]]\n assert candidate(groupSizes = [4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == [[0, 1, 2, 3], [4, 5, 6], [7, 8], [9]]\n assert candidate(groupSizes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]\n assert candidate(groupSizes = [4, 4, 4, 4, 4, 4, 4, 4]) == [[0, 1, 2, 3], [4, 5, 6, 7]]\n assert candidate(groupSizes = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [[0, 5, 10, 15], [1, 6, 11, 16], [2, 7, 12], [17], [3, 8], [13, 18], [4], [9], [14], [19]]\n assert candidate(groupSizes = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [[0, 1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21, 22, 23]]\n assert candidate(groupSizes = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == [[0, 1, 2], [3, 4], [5, 6], [7, 8], [9], [10], [11], [12]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 5, 5, 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, 1, 2, 3, 4], [5, 6, 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(groupSizes = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [[0, 2], [4, 6], [8, 10], [1, 3, 5], [7, 9, 11]]\n assert candidate(groupSizes = [6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11, 12], [13, 14]]\n assert candidate(groupSizes = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == [[0], [10], [1, 9], [2, 8], [3, 7], [4, 6], [5]]\n assert candidate(groupSizes = [3, 3, 3, 3, 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]) == [[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]]\n assert candidate(groupSizes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]\n assert candidate(groupSizes = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1]) == [[0, 1, 2], [3, 4], [5, 6], [7, 8], [9], [10], [11]]\n assert candidate(groupSizes = [4, 4, 4, 4, 2, 2, 2, 2]) == [[0, 1, 2, 3], [4, 5], [6, 7]]\n assert candidate(groupSizes = [4, 4, 4, 4, 4, 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, 1, 1, 1, 1, 1, 1, 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]]\n assert candidate(groupSizes = [2, 3, 2, 3, 3, 2, 2, 3, 2]) == [[0, 2], [5, 6], [8], [1, 3, 4], [7]]\n assert candidate(groupSizes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 3, 3, 3, 2, 2]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17], [18, 19]]\n assert candidate(groupSizes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 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]) == [[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]]\n assert candidate(groupSizes = [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], [10, 11], [12, 13], [14, 15]]\n assert candidate(groupSizes = [2, 3, 4, 5, 6, 7, 8, 9, 10, 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]) == [[0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [18], [19], [20], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [31], [32], [33]]\n assert candidate(groupSizes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]\n assert candidate(groupSizes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]\n assert candidate(groupSizes = [3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 2]) == [[0, 1, 2], [7, 8, 9], [10], [3, 4], [5, 6], [11]]\n assert candidate(groupSizes = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [[0, 2, 4, 6, 8], [1], [3], [5], [7], [9]]\n assert candidate(groupSizes = [8, 1, 8, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 1]) == [[0, 2, 3, 4, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 22, 23, 24, 25], [1], [5], [21], [26]]\n assert candidate(groupSizes = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 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]]\n assert candidate(groupSizes = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == [[0], [1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]\n assert candidate(groupSizes = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]\n assert candidate(groupSizes = [5, 1, 5, 5, 5, 1, 5, 5, 5, 5, 1]) == [[0, 2, 3, 4, 6], [7, 8, 9], [1], [5], [10]]\n assert candidate(groupSizes = [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]) == [[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]]\n assert candidate(groupSizes = [6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1]) == [[0, 1, 2, 3, 4, 5], [6], [7], [8], [9], [10], [11]]\n assert candidate(groupSizes = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14]]\n assert candidate(groupSizes = [3, 3, 3, 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]) == [[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]]\n assert candidate(groupSizes = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [[0], [5], [1, 6], [2, 7], [3, 8], [4, 9]]\n assert candidate(groupSizes = [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [[0], [1, 2], [3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16]]\n assert candidate(groupSizes = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11]]\n", "comparison": "exact"}, "public_tests": ["[3,3,3,3,3,1,3]", "[2,1,3,3,3,2]"], "hints": ["Put people's IDs with same groupSize into buckets, then split each bucket into groups.", "Greedy fill until you need a new group."], "metadata": {"canonical_parameter_names": ["groupSizes"], "leetcode_dataset_entry_point": "Solution().groupThePeople", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:29+00:00", "tests_total": 83, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "greedy"]}, "language": "python", "interface": {"raw_signature": "def groupThePeople(self, groupSizes: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "groupThePeople", "parameters": [{"name": "groupSizes", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1283, "task_id": "find-the-smallest-divisor-given-a-threshold", "difficulty": "Medium", "problem_description": "Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.\n\nEach result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).\n\nThe test cases are generated so that there will be an answer.\n\nExample 1:\n\nInput: nums = [1,2,5,9], threshold = 6\nOutput: 5\nExplanation: We can get a sum to 17 (1+2+5+9) if the divisor is 1.\nIf the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the sum will be 5 (1+1+1+2).\n\nExample 2:\n\nInput: nums = [44,22,33,11,1], threshold = 5\nOutput: 44\n\nConstraints:\n\n- 1 <= nums.length <= 5 * 10^4\n- 1 <= nums[i] <= 10^6\n- nums.length <= threshold <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],threshold = 15) == 10\n assert candidate(nums = [44, 22, 33, 11, 1],threshold = 5) == 44\n assert candidate(nums = [1, 1, 1, 1, 1],threshold = 5) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],threshold = 100) == 2\n assert candidate(nums = [1, 2, 5, 9],threshold = 6) == 5\n assert candidate(nums = [1000000],threshold = 1000000) == 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 = 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],threshold = 50) == 7\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],threshold = 20) == 7\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000],threshold = 1000000) == 3\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],threshold = 1000) == 17\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],threshold = 18) == 9\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],threshold = 1000000) == 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],threshold = 100) == 4\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],threshold = 500000) == 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],threshold = 1000000) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],threshold = 100) == 58\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 20) == 3\n assert candidate(nums = [500, 400, 300, 200, 100],threshold = 50) == 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, 21, 22, 23, 24, 25],threshold = 50) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],threshold = 50) == 25\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250],threshold = 1000000) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 30) == 2\n assert candidate(nums = [800, 800, 800, 800, 800, 800, 800, 800, 800, 800],threshold = 10) == 800\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],threshold = 50) == 16\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],threshold = 200000) == 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],threshold = 100) == 24\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],threshold = 30) == 5\n assert candidate(nums = [123456, 654321, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888],threshold = 1000000) == 5\n assert candidate(nums = [123456, 654321, 111111, 222222, 333333, 444444, 555555],threshold = 1000000) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],threshold = 300) == 41\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],threshold = 1000000) == 5\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],threshold = 20) == 834\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) == 20\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],threshold = 50000) == 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],threshold = 20) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 10) == 10\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],threshold = 50) == 1200\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890],threshold = 500000) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 25) == 3\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],threshold = 25) == 100\n assert candidate(nums = [500000, 400000, 300000, 200000, 100000],threshold = 1000000) == 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],threshold = 75) == 16\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],threshold = 10000) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],threshold = 210101) == 6\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],threshold = 111111) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],threshold = 25) == 267\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 18) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],threshold = 75) == 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],threshold = 100) == 3\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],threshold = 20) == 1000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],threshold = 50) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],threshold = 12) == 8\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999],threshold = 1000) == 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],threshold = 1000) == 22\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],threshold = 20) == 10\n", "comparison": "exact"}, "public_tests": ["[1,2,5,9]\n6", "[44,22,33,11,1]\n5"], "hints": ["Examine every possible number for solution. Choose the largest of them.", "Use binary search to reduce the time complexity."], "metadata": {"canonical_parameter_names": ["nums", "threshold"], "leetcode_dataset_entry_point": "Solution().smallestDivisor", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:32+00:00", "tests_total": 81, "tests_dropped": 25, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def smallestDivisor(self, nums: list[int], threshold: int) -> int:", "container": "Solution", "callable": "smallestDivisor", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1284, "task_id": "minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix", "difficulty": "Hard", "problem_description": "Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share one edge.\n\nReturn the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.\n\nA binary matrix is a matrix with all cells equal to 0 or 1 only.\n\nA zero matrix is a matrix with all cells equal to 0.\n\nExample 1:\n\nInput: mat = [[0,0],[0,1]]\nOutput: 3\nExplanation: One possible solution is to flip (1, 0) then (0, 1) and finally (1, 1) as shown.\n\nExample 2:\n\nInput: mat = [[0]]\nOutput: 0\nExplanation: Given matrix is a zero matrix. We do not need to change it.\n\nExample 3:\n\nInput: mat = [[1,0,0],[1,0,0]]\nOutput: -1\nExplanation: Given matrix cannot be a zero matrix.\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n <= 3\n- mat[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[0, 0], [0, 1]]) == 3\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 5\n assert candidate(mat = [[1, 1], [1, 1]]) == 4\n assert candidate(mat = [[0]]) == 0\n assert candidate(mat = [[1, 1, 0], [0, 0, 0], [0, 0, 1]]) == 6\n assert candidate(mat = [[0, 1, 0], [1, 0, 1], [0, 1, 0]]) == 4\n assert candidate(mat = [[1, 0, 0], [1, 0, 0]]) == -1\n assert candidate(mat = [[0, 1, 1], [1, 1, 0], [1, 0, 1]]) == 8\n assert candidate(mat = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 9\n assert candidate(mat = [[1, 1, 1], [0, 1, 0], [1, 1, 1]]) == 3\n assert candidate(mat = [[0, 1, 0], [1, 1, 1], [0, 1, 0]]) == 1\n assert candidate(mat = [[0, 1, 1], [1, 0, 1], [1, 1, 0]]) == 2\n assert candidate(mat = [[1, 1, 0], [1, 0, 1], [0, 1, 1]]) == 2\n assert candidate(mat = [[1, 1, 1], [1, 1, 0], [1, 0, 1]]) == 5\n assert candidate(mat = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 8\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 3\n assert candidate(mat = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 5\n assert candidate(mat = [[1, 1, 0], [1, 1, 0], [0, 0, 0]]) == 6\n assert candidate(mat = [[1, 1, 1], [0, 0, 0], [1, 1, 1]]) == 2\n assert candidate(mat = [[0, 0, 1], [0, 1, 0], [1, 0, 0]]) == 3\n", "comparison": "exact"}, "public_tests": ["[[0,0],[0,1]]", "[[0]]", "[[1,0,0],[1,0,0]]"], "hints": ["Flipping same index two times is like not flipping it at all. Each index can be flipped one time. Try all possible combinations. O(2^(n*m))."], "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:34+00:00", "tests_total": 53, "tests_dropped": 33, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "bit-manipulation", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minFlips(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1287, "task_id": "element-appearing-more-than-25-in-sorted-array", "difficulty": "Easy", "problem_description": "Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.\n\nExample 1:\n\nInput: arr = [1,2,2,6,6,6,6,7,10]\nOutput: 6\n\nExample 2:\n\nInput: arr = [1,1]\nOutput: 1\n\nConstraints:\n\n- 1 <= arr.length <= 10^4\n- 0 <= arr[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 4, 5, 6]) == 2\n assert candidate(arr = [1, 1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 9, 10]) == 8\n assert candidate(arr = [1, 2, 3, 4, 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 9, 10, 11, 12]) == 8\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr = [1, 2, 3, 3, 3, 3, 4, 5, 6, 7]) == 3\n assert candidate(arr = [0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(arr = [7, 7, 7, 7, 8, 9, 10]) == 7\n assert candidate(arr = [3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 3\n assert candidate(arr = [1, 2, 2, 6, 6, 6, 6, 7, 10]) == 6\n assert candidate(arr = [3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\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\n assert candidate(arr = [3, 3, 3, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 4, 4, 4, 4]) == 2\n assert candidate(arr = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 3, 3, 4, 5]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr = [5, 5, 5, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [10, 10, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 10\n assert candidate(arr = [3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 11, 12, 13, 14]) == 10\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 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\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 2, 2, 2, 3, 3, 3, 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, 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 candidate(arr = [0, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5]) == 2\n assert candidate(arr = [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\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [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]) == 1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 25\n assert candidate(arr = [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, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 5\n assert candidate(arr = [10, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 50\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\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\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 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, 4, 5, 5, 5, 5]) == 2\n assert candidate(arr = [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, 5, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [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]) == 0\n assert candidate(arr = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 10, 11, 12]) == 9\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, 1, 1, 2, 3, 4, 5]) == 1\n assert candidate(arr = [10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 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]) == 20\n assert candidate(arr = [1, 1, 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, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 10\n assert candidate(arr = [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]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 2\n assert candidate(arr = [1, 2, 2, 2, 2, 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\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr = [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, 3, 3, 3, 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, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10]) == 3\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, 2, 3, 4]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [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]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 100\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 6\n assert candidate(arr = [1, 1, 1, 1, 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, 5]) == 4\n assert candidate(arr = [1, 1, 1, 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [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, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 3\n assert candidate(arr = [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\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, 2, 2, 2, 2, 3]) == 1\n assert candidate(arr = [0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 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, 5, 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(arr = [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 3\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, 2, 3, 4, 5]) == 1\n assert candidate(arr = [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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [1, 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, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n", "comparison": "exact"}, "public_tests": ["[1,2,2,6,6,6,6,7,10]", "[1,1]"], "hints": ["Divide the array in four parts [1 - 25%] [25 - 50 %] [50 - 75 %] [75% - 100%]", "The answer should be in one of the ends of the intervals.", "In order to check which is element is the answer we can count the frequency with binarySearch."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findSpecialInteger", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:36+00:00", "tests_total": 83, "tests_dropped": 0, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def findSpecialInteger(self, arr: list[int]) -> int:", "container": "Solution", "callable": "findSpecialInteger", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1288, "task_id": "remove-covered-intervals", "difficulty": "Medium", "problem_description": "Given an array intervals where intervals[i] = [l_i, r_i] represent the interval [l_i, r_i), remove all intervals that are covered by another interval in the list.\n\nThe interval [a, b) is covered by the interval [c, d) if and only if c <= a and b <= d.\n\nReturn the number of remaining intervals.\n\nExample 1:\n\nInput: intervals = [[1,4],[3,6],[2,8]]\nOutput: 2\nExplanation: Interval [3,6] is covered by [2,8], therefore it is removed.\n\nExample 2:\n\nInput: intervals = [[1,4],[2,3]]\nOutput: 1\n\nConstraints:\n\n- 1 <= intervals.length <= 1000\n- intervals[i].length == 2\n- 0 <= l_i < r_i <= 10^5\n- All the given intervals are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(intervals = [[1, 100], [2, 50], [3, 75]]) == 1\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5]]) == 3\n assert candidate(intervals = [[1, 4], [3, 6], [2, 8]]) == 2\n assert candidate(intervals = [[1, 2], [1, 4], [3, 4]]) == 1\n assert candidate(intervals = [[1, 4], [2, 3]]) == 1\n assert candidate(intervals = [[0, 10], [5, 12]]) == 2\n assert candidate(intervals = [[1, 100], [50, 51], [51, 101]]) == 2\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4]]) == 3\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4]]) == 1\n assert candidate(intervals = [[0, 10], [5, 15], [15, 20]]) == 3\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(intervals = [[1, 5], [2, 5], [3, 5]]) == 1\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 1\n assert candidate(intervals = [[1, 2]]) == 1\n assert candidate(intervals = [[1, 5], [2, 3], [4, 6], [5, 7], [6, 8]]) == 4\n assert candidate(intervals = [[3, 10], [5, 7], [7, 9], [8, 10], [2, 3]]) == 2\n assert candidate(intervals = [[1, 10], [2, 5], [3, 7], [4, 8], [5, 9]]) == 1\n assert candidate(intervals = [[1, 100], [1, 50], [1, 25], [1, 125]]) == 1\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 7\n assert candidate(intervals = [[2, 5], [3, 7], [5, 10], [1, 15]]) == 1\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [10, 60]]) == 1\n assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25]]) == 5\n assert candidate(intervals = [[1, 5], [2, 3], [4, 9], [5, 7], [6, 8]]) == 2\n assert candidate(intervals = [[1, 500], [50, 1000], [100, 1500], [150, 2000], [200, 2500]]) == 5\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 7\n assert candidate(intervals = [[1, 20], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997]]) == 1\n assert candidate(intervals = [[5, 10], [10, 20], [15, 25], [20, 30], [25, 35]]) == 5\n assert candidate(intervals = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [1, 11]]) == 1\n assert candidate(intervals = [[1, 10], [2, 5], [3, 7], [8, 9], [5, 6]]) == 1\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == 1\n assert candidate(intervals = [[1, 10], [2, 5], [3, 7], [5, 9], [6, 8]]) == 1\n assert candidate(intervals = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n assert candidate(intervals = [[10, 20], [15, 25], [5, 30], [20, 30], [25, 35]]) == 2\n assert candidate(intervals = [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 7\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 6\n assert candidate(intervals = [[1, 100], [50, 150], [10, 50], [20, 30], [70, 100]]) == 2\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13]]) == 9\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 8\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 5\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 10\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]]) == 6\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [15, 45]]) == 4\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 8\n assert candidate(intervals = [[1, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == 1\n assert candidate(intervals = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]]) == 1\n assert candidate(intervals = [[1, 100], [5, 95], [10, 90], [15, 85], [20, 80], [25, 75], [30, 70], [35, 65], [40, 60], [45, 55]]) == 1\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]]) == 5\n assert candidate(intervals = [[1, 4], [2, 5], [3, 9], [4, 8], [5, 7]]) == 3\n assert candidate(intervals = [[1, 10], [5, 15], [10, 20], [0, 30]]) == 1\n assert candidate(intervals = [[5, 10], [6, 15], [10, 15], [15, 20], [16, 20]]) == 3\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]]) == 5\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [10, 50], [15, 45], [25, 35]]) == 1\n assert candidate(intervals = [[1, 4], [2, 8], [3, 12], [4, 16], [5, 20], [6, 24], [7, 28]]) == 7\n assert candidate(intervals = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]]) == 5\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 1\n assert candidate(intervals = [[1, 4], [1, 5], [1, 6], [1, 7]]) == 1\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35]]) == 6\n assert candidate(intervals = [[10, 20], [15, 25], [5, 30], [25, 35], [30, 40]]) == 3\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [5, 45]]) == 1\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [5, 20], [10, 16]]) == 1\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 5\n assert candidate(intervals = [[1, 4], [2, 3], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 6\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 9\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [200, 300], [250, 350]]) == 5\n assert candidate(intervals = [[1, 20], [2, 3], [3, 19], [19, 20], [15, 18]]) == 1\n assert candidate(intervals = [[1, 10], [2, 5], [5, 7], [6, 9], [8, 10]]) == 1\n assert candidate(intervals = [[1, 10], [2, 5], [3, 7], [6, 9], [4, 8]]) == 1\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [5, 35]]) == 1\n assert candidate(intervals = [[0, 5], [5, 10], [10, 15], [15, 20], [0, 20], [1, 19], [2, 18], [3, 17]]) == 1\n assert candidate(intervals = [[1, 5], [2, 3], [4, 6], [3, 7], [8, 10], [9, 11], [10, 12]]) == 5\n assert candidate(intervals = [[5, 10], [4, 9], [3, 8], [2, 7], [1, 6]]) == 5\n assert candidate(intervals = [[5, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70]]) == 7\n assert candidate(intervals = [[10, 20], [20, 30], [25, 40], [35, 50], [45, 60]]) == 5\n assert candidate(intervals = [[1, 20], [10, 20], [15, 20], [5, 25], [1, 30], [25, 35], [30, 40]]) == 3\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [5, 15], [10, 30], [15, 35], [20, 40]]) == 4\n assert candidate(intervals = [[0, 1000], [1, 999], [2, 998], [3, 997], [4, 996]]) == 1\n assert candidate(intervals = [[1, 1000], [50, 550], [100, 900], [200, 800], [300, 700], [400, 600], [500, 550], [600, 650], [700, 750]]) == 1\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]]) == 9\n assert candidate(intervals = [[100, 200], [150, 250], [50, 150], [200, 300]]) == 4\n assert candidate(intervals = [[1, 10], [2, 5], [3, 7], [4, 9], [5, 6]]) == 1\n assert candidate(intervals = [[100, 200], [100, 200], [150, 250], [50, 150], [200, 300]]) == 4\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70]]) == 7\n assert candidate(intervals = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == 7\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [5, 25]]) == 1\n assert candidate(intervals = [[1, 4], [1, 6], [1, 8], [1, 10], [1, 12]]) == 1\n assert candidate(intervals = [[1, 4], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 7\n assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]]) == 8\n assert candidate(intervals = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [1, 2], [2, 3], [3, 4]]) == 1\n assert candidate(intervals = [[1, 3], [2, 5], [4, 7], [6, 9], [8, 10]]) == 5\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == 12\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 5\n assert candidate(intervals = [[1, 10], [1, 5], [1, 3], [1, 2], [2, 10], [2, 5], [2, 3], [3, 10], [3, 5], [4, 10]]) == 1\n assert candidate(intervals = [[0, 10], [5, 15], [10, 20], [15, 25]]) == 4\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 8\n assert candidate(intervals = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996]]) == 1\n assert candidate(intervals = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [1, 11]]) == 1\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]]) == 5\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40]]) == 5\n assert candidate(intervals = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [1, 25]]) == 1\n assert candidate(intervals = [[1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]]) == 1\n assert candidate(intervals = [[1, 10], [2, 5], [3, 7], [8, 15], [5, 12]]) == 3\n assert candidate(intervals = [[5, 10], [1, 3], [4, 5], [8, 11], [10, 15]]) == 5\n assert candidate(intervals = [[1, 100], [5, 50], [10, 90], [20, 80], [30, 70], [40, 60]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[52141,92589],[52991,93486],[46321,59199],[51955,78788],[18533,23127]]", "[[14041,32641],[24914,51477],[4983,81235],[62018,77987],[31523,32192],[74196,96194],[16126,52652],[59901,67707],[36502,51366],[56437,86744]]"], "hints": ["How to check if an interval is covered by another?", "Compare each interval to all others and check if it is covered by any interval."], "metadata": {"canonical_parameter_names": ["intervals"], "leetcode_dataset_entry_point": "Solution().removeCoveredIntervals", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:38+00:00", "tests_total": 111, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def removeCoveredIntervals(self, intervals: list[list[int]]) -> int:", "container": "Solution", "callable": "removeCoveredIntervals", "parameters": [{"name": "intervals", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1289, "task_id": "minimum-falling-path-sum-ii", "difficulty": "Hard", "problem_description": "Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.\n\nA falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements chosen in adjacent rows are in the same column.\n\nExample 1:\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: 13\nExplanation:\nThe possible falling paths are:\n[1,5,9], [1,5,7], [1,6,7], [1,6,8],\n[2,4,8], [2,4,9], [2,6,7], [2,6,8],\n[3,4,8], [3,4,9], [3,5,7], [3,5,9]\nThe falling path with the smallest sum is [1,5,7], so the answer is 13.\n\nExample 2:\n\nInput: grid = [[7]]\nOutput: 7\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 1 <= n <= 200\n- -99 <= grid[i][j] <= 99\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[3, 1, 1], [1, 2, 3], [2, 3, 4]]) == 5\n assert candidate(grid = [[10, 20, 30], [30, 20, 10], [10, 10, 10]]) == 30\n assert candidate(grid = [[7]]) == 7\n assert candidate(grid = [[3, 1, 1], [1, 7, 6], [2, 7, 7]]) == 9\n assert candidate(grid = [[-99, -98, -97], [-96, -95, -94], [-93, -92, -91]]) == -287\n assert candidate(grid = [[1, 2], [3, 4]]) == 5\n assert candidate(grid = [[0, 1, 2, 3], [3, 2, 1, 0], [0, 3, 2, 1], [1, 0, 3, 2]]) == 0\n assert candidate(grid = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == -17\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, 0, 1, 0]]) == 12\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 13\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[5, 3], [2, 1]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [25, 24, 23, 22, 21]]) == 56\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50], [-5, -15, -25, -35, -45], [-6, -12, -18, -24, -30], [-7, -14, -21, -28, -35]]) == -149\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 30\n assert candidate(grid = [[-10, -20, -30], [-30, -10, -20], [-20, -30, -10]]) == -90\n assert candidate(grid = [[9, 3, 2, 4, 1], [5, 6, 7, 8, 9], [1, 2, 3, 4, 5], [4, 3, 2, 1, 0], [5, 6, 7, 8, 9]]) == 13\n assert candidate(grid = [[10, 50, 20, 30], [40, 10, 60, 70], [80, 90, 10, 40], [50, 20, 30, 60]]) == 50\n assert candidate(grid = [[5, 3, 8, 1], [2, 7, 1, 6], [9, 2, 5, 3], [4, 8, 2, 9]]) == 6\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 20, 40], [40, 20, 10, 50, 30], [30, 50, 40, 10, 20]]) == 50\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 0], [0, 6, 5, 4, 3, 2, 1], [1, 0, 6, 5, 4, 3, 2], [2, 1, 0, 6, 5, 4, 3], [3, 2, 1, 0, 6, 5, 4], [4, 3, 2, 1, 0, 6, 5]]) == 0\n assert candidate(grid = [[-1, -2, -3], [-3, -4, -5], [-5, -6, -7]]) == -14\n assert candidate(grid = [[-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, 3, -4, 5], [5, 4, -3, 2, -1], [-2, -3, 4, -5, 1]]) == -21\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, -1, 1], [-1, 0, 1], [1, 0, -1]]) == -3\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, 1, -2, 2, -3]]) == -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]]) == 57\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], [3, 6, 9, 12, 15, 1, 4, 7, 10, 13], [13, 10, 7, 4, 1, 16, 13, 10, 7, 4], [4, 7, 10, 13, 16, 19, 22, 25, 28, 31], [31, 28, 25, 22, 19, 32, 35, 38, 41, 44]]) == 31\n assert candidate(grid = [[10, -7, 10, -7, 10], [5, 4, -1, 6, -7], [1, 0, -2, -5, -3], [2, 6, -1, 8, -1], [0, -2, -1, 1, 2]]) == -22\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]]) == 25\n assert candidate(grid = [[-50, -60, -70, -80, -90], [-90, -50, -60, -70, -80], [-80, -90, -50, -60, -70], [-70, -80, -90, -50, -60], [-60, -70, -80, -90, -50]]) == -450\n assert candidate(grid = [[-10, -6, -3, 0, 2], [-5, -2, 1, 2, 4], [6, 2, 0, -1, -3], [5, 2, 5, -2, 1], [8, -3, -2, 2, 2]]) == -20\n assert candidate(grid = [[-1, 2, -3, 4], [4, -3, 2, -1], [-2, 1, -4, 3], [3, -4, 1, -2]]) == -14\n assert candidate(grid = [[1, 3, 1, 2], [1, 2, 2, 4], [5, 3, 5, 3], [6, 4, 6, 5]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 9\n assert candidate(grid = [[-1, -2, -3], [-3, -2, -1], [-2, -1, -3]]) == -9\n assert candidate(grid = [[5, 3, 8, 6, 2], [9, 4, 1, 7, 3], [2, 6, 4, 8, 5], [7, 1, 9, 3, 6], [3, 7, 2, 5, 8]]) == 8\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]]) == -50\n assert candidate(grid = [[99, -99, 45, -45], [-45, 45, -99, 99], [0, 0, 0, 0], [-1, 1, -2, 2]]) == -200\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [15, 25, 35, 45, 55], [55, 45, 35, 25, 15], [12, 22, 32, 42, 52]]) == 62\n assert candidate(grid = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [1, 3, 5, 7, 9]]) == 13\n assert candidate(grid = [[-10, -5, -8, -6], [-1, -3, -7, -4], [-3, -7, -2, -5], [-9, -4, -6, -6]]) == -33\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]]) == 6\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 30, 20, 40], [40, 20, 30, 10]]) == 40\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]]) == 6\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [1, 5, 4, 3, 2], [3, 2, 1, 5, 4]]) == 6\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 9\n assert candidate(grid = [[-10, 15, -20, 25], [5, -5, 0, 10], [30, -35, 40, -45], [50, -55, 60, -65]]) == -125\n assert candidate(grid = [[-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6], [-4, -5, -6, -7]]) == -20\n assert candidate(grid = [[-10, -50, 20, -30], [15, 10, -45, 5], [25, -20, 5, -5], [30, 20, 0, 10]]) == -115\n assert candidate(grid = [[50, 20, 30, 40], [10, 60, 70, 80], [90, 10, 40, 20], [50, 80, 60, 30]]) == 70\n assert candidate(grid = [[7, 2, 9, 3, 1], [2, 8, 3, 9, 2], [1, 5, 4, 6, 8], [6, 9, 2, 5, 3], [4, 7, 1, 6, 8]]) == 9\n assert candidate(grid = [[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]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, 0, -1, -2, -3], [0, 1, -1, -2, -3], [2, -1, 1, -2, -3], [-1, 2, -2, 1, -3], [-2, -3, 3, 1, 0]]) == -13\n assert candidate(grid = [[50, 50, 50], [50, 50, 50], [50, 50, 50]]) == 150\n assert candidate(grid = [[1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1], [1, -1, 1, -1]]) == -4\n assert candidate(grid = [[-99, 99, -98, 98], [-97, 97, -96, 96], [-95, 95, -94, 94], [-93, 93, -92, 92]]) == -382\n assert candidate(grid = [[-1, 3, 2, 2, 0], [-2, 0, -1, -1, -1], [0, -3, -2, -1, 1], [1, -1, 1, -2, -2], [1, 2, 0, -1, -1]]) == -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, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 0\n assert candidate(grid = [[-99, 0, 99], [-99, 0, 99], [-99, 0, 99]]) == -198\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[4,5,6],[7,8,9]]", "[[7]]"], "hints": ["Use dynamic programming.", "Let dp[i][j] be the answer for the first i rows such that column j is chosen from row i.", "Use the concept of cumulative array to optimize the complexity of the solution."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minFallingPathSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:40+00:00", "tests_total": 83, "tests_dropped": 21, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minFallingPathSum(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minFallingPathSum", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1291, "task_id": "sequential-digits", "difficulty": "Medium", "problem_description": "An integer has sequential digits if and only if each digit in the number is one more than the previous digit.\n\nReturn a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.\n\nExample 1:\n\nInput: low = 100, high = 300\nOutput: [123,234]\n\nExample 2:\n\nInput: low = 1000, high = 13000\nOutput: [1234,2345,3456,4567,5678,6789,12345]\n\nConstraints:\n\n- 10 <= low <= high <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 567,high = 6789) == [567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789]\n assert candidate(low = 500,high = 700) == [567, 678]\n assert candidate(low = 10,high = 100) == [12, 23, 34, 45, 56, 67, 78, 89]\n assert candidate(low = 123456789,high = 123456789) == [123456789]\n assert candidate(low = 11,high = 22) == [12]\n assert candidate(low = 111,high = 999) == [123, 234, 345, 456, 567, 678, 789]\n assert candidate(low = 50,high = 500) == [56, 67, 78, 89, 123, 234, 345, 456]\n assert candidate(low = 789,high = 98765) == [789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 123,high = 456) == [123, 234, 345, 456]\n assert candidate(low = 9876,high = 98765) == [12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 1234,high = 5678) == [1234, 2345, 3456, 4567, 5678]\n assert candidate(low = 100,high = 300) == [123, 234]\n assert candidate(low = 1000,high = 13000) == [1234, 2345, 3456, 4567, 5678, 6789, 12345]\n assert candidate(low = 100000,high = 999999) == [123456, 234567, 345678, 456789]\n assert candidate(low = 234567,high = 345678) == [234567, 345678]\n assert candidate(low = 123,high = 987654321) == [123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 1111,high = 2222) == [1234]\n assert candidate(low = 99999999,high = 1000000000) == [123456789]\n assert candidate(low = 80000,high = 85000) == []\n assert candidate(low = 234,high = 345678) == [234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678]\n assert candidate(low = 50000,high = 90000) == [56789]\n assert candidate(low = 50000,high = 80000) == [56789]\n assert candidate(low = 56,high = 789) == [56, 67, 78, 89, 123, 234, 345, 456, 567, 678, 789]\n assert candidate(low = 100000,high = 200000) == [123456]\n assert candidate(low = 111,high = 123456789) == [123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 987,high = 9876) == [1234, 2345, 3456, 4567, 5678, 6789]\n assert candidate(low = 4567,high = 87654) == [4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 1234567,high = 7654321) == [1234567, 2345678, 3456789]\n assert candidate(low = 111,high = 222) == [123]\n assert candidate(low = 789,high = 789) == [789]\n assert candidate(low = 2345678,high = 3456789) == [2345678, 3456789]\n assert candidate(low = 111,high = 999999) == [123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789]\n assert candidate(low = 12345678,high = 23456789) == [12345678, 23456789]\n assert candidate(low = 1111,high = 4444) == [1234, 2345, 3456]\n assert candidate(low = 2000,high = 40000) == [2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567]\n assert candidate(low = 12345678,high = 87654321) == [12345678, 23456789]\n assert candidate(low = 4321,high = 987654321) == [4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 12,high = 89) == [12, 23, 34, 45, 56, 67, 78, 89]\n assert candidate(low = 99,high = 100) == []\n assert candidate(low = 34567,high = 987654321) == [34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 10000,high = 99999) == [12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 1234567,high = 3456789) == [1234567, 2345678, 3456789]\n assert candidate(low = 300000,high = 500000) == [345678, 456789]\n assert candidate(low = 4567,high = 8901) == [4567, 5678, 6789]\n assert candidate(low = 150,high = 10000) == [234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789]\n assert candidate(low = 10,high = 98) == [12, 23, 34, 45, 56, 67, 78, 89]\n assert candidate(low = 3456,high = 87654) == [3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 1111,high = 22222) == [1234, 2345, 3456, 4567, 5678, 6789, 12345]\n assert candidate(low = 111111,high = 222222) == [123456]\n assert candidate(low = 56789,high = 98765) == [56789]\n assert candidate(low = 88888888,high = 99999999) == []\n assert candidate(low = 123456,high = 678910) == [123456, 234567, 345678, 456789]\n assert candidate(low = 12345,high = 67890) == [12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 111,high = 987654321) == [123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 1234,high = 23456789) == [1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789]\n assert candidate(low = 4000,high = 5000) == [4567]\n assert candidate(low = 890,high = 123456789) == [1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 120,high = 123) == [123]\n assert candidate(low = 1111111,high = 7777777) == [1234567, 2345678, 3456789]\n assert candidate(low = 56789,high = 67890) == [56789]\n assert candidate(low = 98765,high = 987654321) == [123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 9876,high = 1000000) == [12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789]\n assert candidate(low = 23456,high = 67890) == [23456, 34567, 45678, 56789]\n assert candidate(low = 3456789,high = 4567890) == [3456789]\n assert candidate(low = 123456,high = 123456789) == [123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 123456,high = 789012) == [123456, 234567, 345678, 456789]\n assert candidate(low = 4000000,high = 6000000) == []\n assert candidate(low = 10,high = 999999999) == [12, 23, 34, 45, 56, 67, 78, 89, 123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 987654,high = 987654321) == [1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 56789,high = 654321) == [56789, 123456, 234567, 345678, 456789]\n assert candidate(low = 300000,high = 350000) == [345678]\n assert candidate(low = 10000000,high = 99999999) == [12345678, 23456789]\n assert candidate(low = 23456,high = 345678) == [23456, 34567, 45678, 56789, 123456, 234567, 345678]\n assert candidate(low = 12,high = 123456789) == [12, 23, 34, 45, 56, 67, 78, 89, 123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 1000000,high = 1500000) == [1234567]\n assert candidate(low = 234,high = 456789) == [234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789]\n assert candidate(low = 10000,high = 20000) == [12345]\n assert candidate(low = 250,high = 950) == [345, 456, 567, 678, 789]\n assert candidate(low = 1234,high = 56789) == [1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789]\n assert candidate(low = 890,high = 987654321) == [1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789, 12345678, 23456789, 123456789]\n assert candidate(low = 50,high = 200) == [56, 67, 78, 89, 123]\n assert candidate(low = 222,high = 55555) == [234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678]\n assert candidate(low = 900,high = 1000) == []\n assert candidate(low = 345,high = 3456789) == [345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567, 2345678, 3456789]\n assert candidate(low = 9876543,high = 987654321) == [12345678, 23456789, 123456789]\n", "comparison": "exact"}, "public_tests": ["100\n300", "1000\n13000"], "hints": ["Generate all numbers with sequential digits and check if they are in the given range.", "Fix the starting digit then do a recursion that tries to append all valid digits."], "metadata": {"canonical_parameter_names": ["low", "high"], "leetcode_dataset_entry_point": "Solution().sequentialDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:45+00:00", "tests_total": 88, "tests_dropped": 3, "flags": [], "topic_tags": ["enumeration"]}, "language": "python", "interface": {"raw_signature": "def sequentialDigits(self, low: int, high: int) -> list[int]:", "container": "Solution", "callable": "sequentialDigits", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1292, "task_id": "maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold", "difficulty": "Medium", "problem_description": "Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.\n\nExample 1:\n\nInput: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4\nOutput: 2\nExplanation: The maximum side length of square with sum less than or equal to 4 is 2 as shown.\n\nExample 2:\n\nInput: 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]], threshold = 1\nOutput: 0\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n <= 300\n- 0 <= mat[i][j] <= 10^4\n- 0 <= threshold <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],threshold = 10) == 3\n assert candidate(mat = [[1, 1, 3, 2, 4, 3, 2], [1, 1, 3, 2, 4, 3, 2], [1, 1, 3, 2, 4, 3, 2]],threshold = 4) == 2\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]],threshold = 1) == 0\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],threshold = 100) == 1\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],threshold = 15) == 2\n assert candidate(mat = [[100, 200, 300], [200, 300, 400], [300, 400, 500]],threshold = 600) == 1\n assert candidate(mat = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],threshold = 2500) == 2\n assert candidate(mat = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600]],threshold = 2500) == 2\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], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],threshold = 50) == 3\n assert candidate(mat = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]],threshold = 20) == 2\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]],threshold = 30) == 3\n assert candidate(mat = [[5, 2, 4, 1, 3, 6, 8, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 2, 4, 1, 3, 6, 8, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 2, 4, 1, 3, 6, 8, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 2, 4, 1, 3, 6, 8, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 2, 4, 1, 3, 6, 8, 7, 9]],threshold = 30) == 3\n assert candidate(mat = [[5, 10, 15, 20, 25, 30], [30, 25, 20, 15, 10, 5], [5, 10, 15, 20, 25, 30], [30, 25, 20, 15, 10, 5], [5, 10, 15, 20, 25, 30], [30, 25, 20, 15, 10, 5]],threshold = 100) == 2\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8], [8, 6, 4, 2, 0, 1, 3, 5, 7], [2, 4, 6, 8, 0, 9, 7, 5, 3]],threshold = 30) == 3\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],threshold = 250) == 2\n assert candidate(mat = [[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]],threshold = 20) == 2\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 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 = 20) == 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]],threshold = 30) == 2\n assert candidate(mat = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]],threshold = 10) == 1\n assert candidate(mat = [[100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100]],threshold = 500) == 2\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, 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]],threshold = 2) == 2\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]],threshold = 40) == 3\n assert candidate(mat = [[2, 3, 5], [3, 8, 13], [5, 13, 21]],threshold = 20) == 2\n assert candidate(mat = [[100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100]],threshold = 250) == 1\n assert candidate(mat = [[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, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],threshold = 15) == 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, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]],threshold = 30) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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 = 25) == 5\n assert candidate(mat = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]],threshold = 50) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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 = 15) == 3\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],threshold = 18) == 2\n assert candidate(mat = [[10, 11, 12], [13, 14, 15], [16, 17, 18]],threshold = 39) == 1\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]],threshold = 1) == 5\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],threshold = 100) == 3\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, 46, 47, 48, 49, 50]],threshold = 100) == 2\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, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],threshold = 1) == 1\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]],threshold = 20) == 2\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 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 = 25) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],threshold = 20) == 4\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]],threshold = 40) == 2\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 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 = 20) == 2\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]],threshold = 10) == 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]],threshold = 1) == 5\n assert candidate(mat = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]],threshold = 81) == 3\n assert candidate(mat = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],threshold = 1000) == 1\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 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 = 25) == 2\n assert candidate(mat = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]],threshold = 50) == 2\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]],threshold = 14) == 3\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 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 = 100) == 4\n assert candidate(mat = [[1, 3, 1, 5, 6, 2], [2, 4, 6, 8, 7, 3], [5, 7, 8, 9, 10, 1], [6, 8, 9, 10, 11, 2], [7, 9, 10, 11, 12, 3]],threshold = 20) == 2\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]],threshold = 10) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 20) == 4\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]],threshold = 15) == 2\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],threshold = 20) == 2\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]],threshold = 1) == 5\n assert candidate(mat = [[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, 3, 3, 3, 3, 2, 1, 0], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 4, 3, 2, 0], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [0, 1, 2, 3, 3, 3, 3, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],threshold = 20) == 4\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]],threshold = 10) == 2\n assert candidate(mat = [[5, 9, 6, 8, 7], [4, 6, 4, 4, 3], [8, 5, 3, 3, 1], [7, 8, 4, 6, 2], [1, 1, 2, 7, 3]],threshold = 15) == 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]],threshold = 5) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [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 = 16) == 4\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]],threshold = 25) == 2\n assert candidate(mat = [[9, 5, 6, 7, 8], [8, 7, 6, 5, 9], [7, 6, 5, 4, 8], [6, 5, 4, 3, 7], [5, 4, 3, 2, 6]],threshold = 30) == 2\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, 0, 1]],threshold = 3) == 2\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], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]],threshold = 50) == 3\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46], [12, 22, 32, 42, 52]],threshold = 150) == 3\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, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],threshold = 2) == 2\n assert candidate(mat = [[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]],threshold = 100) == 4\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17], [17, 15, 13, 11, 9, 7, 5, 3, 1], [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, 2, 3, 4, 5, 6, 7, 8, 9]],threshold = 50) == 3\n assert candidate(mat = [[9, 1, 2], [1, 9, 1], [2, 1, 9]],threshold = 15) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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 = 150) == 12\n assert candidate(mat = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3]],threshold = 30) == 2\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],threshold = 5) == 2\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],threshold = 5) == 1\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], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]],threshold = 100) == 4\n assert candidate(mat = [[9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9]],threshold = 81) == 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]],threshold = 1) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],threshold = 15) == 1\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]],threshold = 25) == 3\n assert candidate(mat = [[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 = 25) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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 = 50) == 7\n assert candidate(mat = [[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]],threshold = 500) == 2\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]],threshold = 3) == 1\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]],threshold = 1) == 5\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 15) == 3\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 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 = 25) == 2\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],threshold = 15) == 3\n", "comparison": "exact"}, "public_tests": ["[[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]]\n4", "[[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]]\n1"], "hints": ["Store prefix sum of all grids in another 2D array.", "Try all possible solutions and if you cannot find one return 0.", "If x is a valid answer then any y < x is also valid answer. Use binary search to find answer."], "metadata": {"canonical_parameter_names": ["mat", "threshold"], "leetcode_dataset_entry_point": "Solution().maxSideLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:47+00:00", "tests_total": 85, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxSideLength(self, mat: list[list[int]], threshold: int) -> int:", "container": "Solution", "callable": "maxSideLength", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1293, "task_id": "shortest-path-in-a-grid-with-obstacles-elimination", "difficulty": "Hard", "problem_description": "You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step.\n\nReturn the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.\n\nExample 1:\n\nInput: grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]], k = 1\nOutput: 6\nExplanation:\nThe shortest path without eliminating any obstacle is 10.\nThe shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).\n\nExample 2:\n\nInput: grid = [[0,1,1],[1,1,1],[1,0,0]], k = 1\nOutput: -1\nExplanation: We need to eliminate at least two obstacles to find such a walk.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 40\n- 1 <= k <= m * n\n- grid[i][j] is either 0 or 1.\n- grid[0][0] == grid[m - 1][n - 1] == 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0]],k = 2) == 9\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0], [0, 1, 1, 0]],k = 2) == 6\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 1) == 4\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]],k = 2) == 8\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]],k = 1) == 7\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0]],k = 1) == 6\n assert candidate(grid = [[0, 0], [1, 0]],k = 1) == 2\n assert candidate(grid = [[0, 1, 1], [1, 1, 1], [1, 0, 0]],k = 1) == -1\n assert candidate(grid = [[0, 0, 0], [1, 1, 0], [0, 0, 0], [0, 1, 1], [0, 0, 0]],k = 1) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],k = 1) == 7\n assert candidate(grid = [[0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0]],k = 2) == -1\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 1, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0, 1, 0, 0]],k = 4) == 12\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 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, 0, 0, 0, 0, 0, 0]],k = 6) == 16\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == 13\n assert candidate(grid = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1], [0, 1, 0, 0, 0, 0]],k = 4) == 9\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]],k = 2) == 10\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, 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]],k = 3) == 15\n assert candidate(grid = [[0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],k = 3) == 8\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]],k = 3) == 10\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == 18\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],k = 5) == 12\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 15) == 18\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, 1, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == 15\n assert candidate(grid = [[0, 1, 1, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == 13\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]],k = 6) == 15\n assert candidate(grid = [[0, 0, 1, 1, 0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 1, 1, 0, 0]],k = 8) == 13\n assert candidate(grid = [[0, 1, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]],k = 3) == 13\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]],k = 3) == 12\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]],k = 7) == 17\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, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == 13\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0], [1, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == 13\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 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]],k = 4) == 13\n assert candidate(grid = [[0, 0, 1, 1, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == 18\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]],k = 5) == 16\n assert candidate(grid = [[0, 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], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 8) == 17\n assert candidate(grid = [[0, 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], [0, 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], [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]],k = 8) == 17\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 8) == 15\n assert candidate(grid = [[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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == 15\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, 1, 0, 1, 0, 1, 0, 0], [0, 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, 0]],k = 6) == 14\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 1, 1, 1, 0], [0, 0, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],k = 2) == 8\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0]],k = 3) == 10\n assert candidate(grid = [[0, 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, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 6) == 15\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, 0]],k = 8) == 17\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 0, 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, 0, 0, 0, 0, 0, 0]],k = 4) == 14\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, 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]],k = 5) == 13\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, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == 13\n assert candidate(grid = [[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, 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]],k = 8) == 17\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 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]],k = 8) == 20\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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == 21\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 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, 0, 0]],k = 5) == 14\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]],k = 8) == 18\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0]],k = 4) == 13\n assert candidate(grid = [[0, 1, 1, 1, 0, 1, 1, 1, 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, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0]],k = 5) == 16\n assert candidate(grid = [[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], [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, 0, 0]],k = 10) == 14\n assert candidate(grid = [[0, 1, 1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 1, 0, 0]],k = 4) == 13\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 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], [1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == 15\n assert candidate(grid = [[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]],k = 2) == 12\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 1, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0]],k = 5) == 15\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == 15\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]],k = 2) == 9\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 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, 0, 0]],k = 6) == 14\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],k = 4) == 12\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]],k = 2) == 8\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, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == 18\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 0, 0, 0], [1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == 12\n assert candidate(grid = [[0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == 12\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, 0, 0], [0, 1, 0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 15) == 23\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],k = 4) == 11\n", "comparison": "exact"}, "public_tests": ["[[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]]\n1", "[[0,1,1],[1,1,1],[1,0,0]]\n1"], "hints": ["Use BFS.", "BFS on (x,y,r) x,y is coordinate, r is remain number of obstacles you can remove."], "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().shortestPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:50+00:00", "tests_total": 75, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def shortestPath(self, grid: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "shortestPath", "parameters": [{"name": "grid", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1295, "task_id": "find-numbers-with-even-number-of-digits", "difficulty": "Easy", "problem_description": "Given an array nums of integers, return how many of them contain an even number of digits.\n\nExample 1:\n\nInput: nums = [12,345,2,6,7896]\nOutput: 2\nExplanation:\n12 contains 2 digits (even number of digits).\n345 contains 3 digits (odd number of digits).\n2 contains 1 digit (odd number of digits).\n6 contains 1 digit (odd number of digits).\n7896 contains 4 digits (even number of digits).\nTherefore only 12 and 7896 contain an even number of digits.\n\nExample 2:\n\nInput: nums = [555,901,482,1771]\nOutput: 1\nExplanation:\nOnly 1771 contains an even number of digits.\n\nConstraints:\n\n- 1 <= nums.length <= 500\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 100, 1000, 10000, 100000]) == 3\n assert candidate(nums = [10, 100, 1000, 10000]) == 2\n assert candidate(nums = [10, 22, 333, 4444, 55555]) == 3\n assert candidate(nums = [100000, 10000, 1000, 100, 10]) == 3\n assert candidate(nums = [555, 901, 482, 1771]) == 1\n assert candidate(nums = [12, 345, 2, 6, 7896]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9]) == 0\n assert candidate(nums = [1, 22, 333, 4444, 55555]) == 2\n assert candidate(nums = [9, 99, 999, 9999, 99999]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000]) == 0\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1000]) == 1\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == 9\n assert candidate(nums = [54321, 12345, 67890, 98765, 43210, 11111, 22222, 33333]) == 0\n assert candidate(nums = [1234, 5678, 9101, 1122, 3344, 5566, 7788, 8899]) == 8\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 9999, 8888, 7777, 6666, 5555]) == 5\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 1\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 60006, 70007, 80008, 90009]) == 0\n assert candidate(nums = [100000, 20000, 300, 40, 5]) == 2\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 9\n assert candidate(nums = [100000, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111]) == 1\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 9\n assert candidate(nums = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090]) == 9\n assert candidate(nums = [98765, 4321, 8642, 13579, 24680]) == 2\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 3\n assert candidate(nums = [1234, 5678, 1122, 3344, 5566, 7788, 9900, 1100, 2200, 3300, 4400, 5500, 6600, 7700, 8800, 9900]) == 16\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 9\n", "comparison": "exact"}, "public_tests": ["[12,345,2,6,7896]", "[555,901,482,1771]"], "hints": ["How to compute the number of digits of a number ?", "Divide the number by 10 again and again to get the number of digits."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:52+00:00", "tests_total": 110, "tests_dropped": 82, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def findNumbers(self, nums: list[int]) -> int:", "container": "Solution", "callable": "findNumbers", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1296, "task_id": "divide-array-in-sets-of-k-consecutive-numbers", "difficulty": "Medium", "problem_description": "Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.\n\nReturn true if it is possible. Otherwise, return false.\n\nExample 1:\n\nInput: nums = [1,2,3,3,4,4,5,6], k = 4\nOutput: true\nExplanation: Array can be divided into [1,2,3,4] and [3,4,5,6].\n\nExample 2:\n\nInput: nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3\nOutput: true\nExplanation: Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].\n\nExample 3:\n\nInput: nums = [1,2,3,4], k = 3\nOutput: false\nExplanation: Each array should be divided in subarrays of size 3.\n\nConstraints:\n\n- 1 <= k <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n\nNote: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 6],k = 4) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == True\n assert candidate(nums = [1, 2, 3, 4],k = 3) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3],k = 3) == True\n assert candidate(nums = [3, 2, 1, 2, 3, 4, 3, 4, 5, 9, 10, 11],k = 3) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == True\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, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 6) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 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],k = 10) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 31],k = 5) == False\n assert candidate(nums = [5, 6, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14],k = 4) == False\n assert candidate(nums = [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, 20, 20],k = 4) == 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],k = 5) == 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],k = 3) == False\n assert candidate(nums = [1, 2, 3, 3, 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 = 5) == False\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 10) == False\n assert candidate(nums = [1, 3, 2, 2, 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 = 4) == False\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],k = 5) == False\n assert candidate(nums = [1, 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],k = 4) == False\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7],k = 4) == False\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],k = 4) == False\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 4) == False\n assert candidate(nums = [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 = 4) == 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],k = 3) == False\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 = 5) == 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],k = 7) == 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],k = 15) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8],k = 6) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 2) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 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],k = 3) == True\n assert candidate(nums = [5, 8, 9, 10, 11, 5, 8, 9, 10, 11, 5, 8, 9, 10, 11, 5, 8, 9, 10, 11],k = 5) == 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],k = 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],k = 7) == False\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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 = 5) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 5) == 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, 130, 130, 140, 140, 150, 150, 160, 160, 170, 170, 180, 180, 190, 190, 200, 200],k = 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 10) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == False\n assert candidate(nums = [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 4) == 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],k = 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],k = 5) == 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],k = 4) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12],k = 5) == False\n assert candidate(nums = [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 = 5) == False\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 = 5) == 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, 12, 12, 12],k = 3) == 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],k = 5) == True\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10],k = 5) == False\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],k = 5) == False\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, 10, 10, 10, 11, 11, 11, 12, 12, 12],k = 6) == False\n assert candidate(nums = [5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16],k = 4) == 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],k = 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],k = 10) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 5) == False\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],k = 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],k = 5) == True\n assert candidate(nums = [5, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12],k = 4) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 5) == 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, 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],k = 5) == 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 5) == False\n assert candidate(nums = [1, 2, 3, 3, 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 = 6) == 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3],k = 2) == 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],k = 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, 9, 9, 9, 10, 10, 10],k = 3) == False\n assert candidate(nums = [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],k = 4) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 3) == False\n assert candidate(nums = [3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14],k = 3) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25],k = 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 5) == True\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 3) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17],k = 2) == 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],k = 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],k = 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 5) == True\n assert candidate(nums = [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],k = 3) == 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],k = 2) == True\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 = 5) == False\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 = 4) == 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],k = 3) == False\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],k = 5) == False\n", "comparison": "exact"}, "public_tests": ["[1,2,3,3,4,4,5,6]\n4", "[3,2,1,2,3,4,3,4,5,9,10,11]\n3", "[3,3,2,2,1,1]\n3"], "hints": ["If the smallest number in the possible-to-split array is V, then numbers V+1, V+2, ... V+k-1 must contain there as well.", "You can iteratively find k sets and remove them from array until it becomes empty.", "Failure to do so would mean that array is unsplittable."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().isPossibleDivide", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:54+00:00", "tests_total": 90, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def isPossibleDivide(self, nums: list[int], k: int) -> bool:", "container": "Solution", "callable": "isPossibleDivide", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1297, "task_id": "maximum-number-of-occurrences-of-a-substring", "difficulty": "Medium", "problem_description": "Given a string s, return the maximum number of occurrences of any substring under the following rules:\n\n- The number of unique characters in the substring must be less than or equal to maxLetters.\n- The substring size must be between minSize and maxSize inclusive.\n\nExample 1:\n\nInput: s = \"aababcaab\", maxLetters = 2, minSize = 3, maxSize = 4\nOutput: 2\nExplanation: Substring \"aab\" has 2 occurrences in the original string.\nIt satisfies the conditions, 2 unique letters and size 3 (between minSize and maxSize).\n\nExample 2:\n\nInput: s = \"aaaa\", maxLetters = 1, minSize = 3, maxSize = 3\nOutput: 2\nExplanation: Substring \"aaa\" occur 2 times in the string. It can overlap.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- 1 <= maxLetters <= 26\n- 1 <= minSize <= maxSize <= min(26, s.length)\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaa\",maxLetters = 1,minSize = 3,maxSize = 3) == 2\n assert candidate(s = \"abacabadabacaba\",maxLetters = 3,minSize = 3,maxSize = 5) == 4\n assert candidate(s = \"xyzxyzxyz\",maxLetters = 3,minSize = 3,maxSize = 3) == 3\n assert candidate(s = \"abacaba\",maxLetters = 2,minSize = 2,maxSize = 5) == 2\n assert candidate(s = \"aabcabcabc\",maxLetters = 2,minSize = 2,maxSize = 3) == 3\n assert candidate(s = \"xyzxyz\",maxLetters = 3,minSize = 2,maxSize = 4) == 2\n assert candidate(s = \"abcde\",maxLetters = 3,minSize = 2,maxSize = 3) == 1\n assert candidate(s = \"xyzxyzxyz\",maxLetters = 3,minSize = 1,maxSize = 2) == 3\n assert candidate(s = \"abcde\",maxLetters = 3,minSize = 2,maxSize = 4) == 1\n assert candidate(s = \"abcde\",maxLetters = 5,minSize = 1,maxSize = 5) == 1\n assert candidate(s = \"abacabadabacaba\",maxLetters = 2,minSize = 2,maxSize = 3) == 4\n assert candidate(s = \"abacabadaba\",maxLetters = 2,minSize = 2,maxSize = 3) == 3\n assert candidate(s = \"aababcaab\",maxLetters = 2,minSize = 3,maxSize = 4) == 2\n assert candidate(s = \"abcabcabc\",maxLetters = 3,minSize = 3,maxSize = 9) == 3\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\",maxLetters = 5,minSize = 10,maxSize = 15) == 0\n assert candidate(s = \"thisisjustatest\",maxLetters = 4,minSize = 4,maxSize = 5) == 1\n assert candidate(s = \"abababababababababababab\",maxLetters = 2,minSize = 2,maxSize = 4) == 12\n assert candidate(s = \"abcdefabcdefabcdef\",maxLetters = 3,minSize = 5,maxSize = 6) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 15,minSize = 7,maxSize = 14) == 1\n assert candidate(s = \"zzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 7) == 8\n assert candidate(s = \"abcdefabcdefabcdef\",maxLetters = 3,minSize = 3,maxSize = 3) == 3\n assert candidate(s = \"abcabcabcabc\",maxLetters = 3,minSize = 3,maxSize = 9) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 3,minSize = 3,maxSize = 5) == 1\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\",maxLetters = 3,minSize = 4,maxSize = 8) == 17\n assert candidate(s = \"xyzxyzxyzxyz\",maxLetters = 2,minSize = 1,maxSize = 3) == 4\n assert candidate(s = \"abcabcabcabcabcabc\",maxLetters = 3,minSize = 3,maxSize = 6) == 6\n assert candidate(s = \"aabbccddeeffgg\",maxLetters = 3,minSize = 2,maxSize = 4) == 1\n assert candidate(s = \"xyxyxyxyxyxyxy\",maxLetters = 2,minSize = 3,maxSize = 6) == 6\n assert candidate(s = \"mnopmnopmnop\",maxLetters = 4,minSize = 5,maxSize = 7) == 2\n assert candidate(s = \"abababababababab\",maxLetters = 2,minSize = 3,maxSize = 6) == 7\n assert candidate(s = \"abcdefghij\",maxLetters = 5,minSize = 3,maxSize = 4) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",maxLetters = 10,minSize = 5,maxSize = 10) == 1\n assert candidate(s = \"abcdabcdabcd\",maxLetters = 4,minSize = 4,maxSize = 4) == 3\n assert candidate(s = \"mississippiissi\",maxLetters = 3,minSize = 2,maxSize = 5) == 3\n assert candidate(s = \"abcdefgabcdefg\",maxLetters = 2,minSize = 4,maxSize = 5) == 0\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",maxLetters = 10,minSize = 10,maxSize = 20) == 1\n assert candidate(s = \"aabbccddeeaabbccddeeaabb\",maxLetters = 3,minSize = 4,maxSize = 5) == 3\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv\",maxLetters = 10,minSize = 10,maxSize = 15) == 9\n assert candidate(s = \"abacabadabacabadabacabadabacaba\",maxLetters = 3,minSize = 5,maxSize = 7) == 4\n assert candidate(s = \"abacabadabacaba\",maxLetters = 2,minSize = 4,maxSize = 4) == 0\n assert candidate(s = \"abacabadabacabadabacaba\",maxLetters = 3,minSize = 3,maxSize = 7) == 6\n assert candidate(s = \"abcabcabcabc\",maxLetters = 1,minSize = 1,maxSize = 1) == 4\n assert candidate(s = \"abcabcabcabc\",maxLetters = 3,minSize = 2,maxSize = 5) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 26,minSize = 1,maxSize = 10) == 2\n assert candidate(s = \"pqrstuvwpqrstu\",maxLetters = 7,minSize = 5,maxSize = 8) == 2\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",maxLetters = 4,minSize = 8,maxSize = 12) == 13\n assert candidate(s = \"abcdefabcdefabcdef\",maxLetters = 6,minSize = 6,maxSize = 6) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",maxLetters = 4,minSize = 4,maxSize = 8) == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",maxLetters = 5,minSize = 5,maxSize = 10) == 1\n assert candidate(s = \"abcabcabcabc\",maxLetters = 3,minSize = 2,maxSize = 4) == 4\n assert candidate(s = \"abracadabraabracadabra\",maxLetters = 4,minSize = 5,maxSize = 7) == 2\n assert candidate(s = \"mnopqr\",maxLetters = 6,minSize = 1,maxSize = 6) == 1\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\",maxLetters = 2,minSize = 3,maxSize = 4) == 18\n assert candidate(s = \"xyzyzyzyzyz\",maxLetters = 2,minSize = 3,maxSize = 4) == 4\n assert candidate(s = \"abcabcabcabc\",maxLetters = 3,minSize = 4,maxSize = 6) == 3\n assert candidate(s = \"zzzzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 10) == 10\n assert candidate(s = \"ababababababab\",maxLetters = 2,minSize = 4,maxSize = 6) == 6\n assert candidate(s = \"xyzxyzxyz\",maxLetters = 3,minSize = 2,maxSize = 5) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",maxLetters = 4,minSize = 4,maxSize = 8) == 29\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeff\",maxLetters = 3,minSize = 6,maxSize = 12) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",maxLetters = 26,minSize = 1,maxSize = 26) == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 26,minSize = 15,maxSize = 20) == 1\n assert candidate(s = \"xyxzyxzyxzyxzyxzyxzyxz\",maxLetters = 3,minSize = 3,maxSize = 4) == 7\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 10,minSize = 10,maxSize = 20) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 10) == 16\n assert candidate(s = \"abcdabcdabcd\",maxLetters = 4,minSize = 3,maxSize = 3) == 3\n assert candidate(s = \"bananaananabanananaanananana\",maxLetters = 3,minSize = 3,maxSize = 6) == 11\n assert candidate(s = \"thisisaverylongstringthatwilltestthelimits\",maxLetters = 10,minSize = 5,maxSize = 15) == 1\n assert candidate(s = \"xyzxyzxyzxyz\",maxLetters = 3,minSize = 4,maxSize = 6) == 3\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",maxLetters = 5,minSize = 10,maxSize = 15) == 0\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababab\",maxLetters = 2,minSize = 4,maxSize = 8) == 34\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 26,minSize = 1,maxSize = 26) == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",maxLetters = 3,minSize = 3,maxSize = 6) == 31\n assert candidate(s = \"abcdefabcdefabcdef\",maxLetters = 6,minSize = 6,maxSize = 12) == 3\n assert candidate(s = \"tuvwxyzuvwxy\",maxLetters = 10,minSize = 4,maxSize = 7) == 2\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\",maxLetters = 4,minSize = 4,maxSize = 8) == 8\n assert candidate(s = \"mnopqrsmnopqr\",maxLetters = 7,minSize = 5,maxSize = 8) == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",maxLetters = 3,minSize = 3,maxSize = 6) == 10\n assert candidate(s = \"xxyxxxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\",maxLetters = 2,minSize = 5,maxSize = 10) == 13\n assert candidate(s = \"aabbccddeeff\",maxLetters = 3,minSize = 3,maxSize = 5) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 10) == 54\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmn\",maxLetters = 10,minSize = 5,maxSize = 15) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",maxLetters = 4,minSize = 6,maxSize = 8) == 7\n assert candidate(s = \"abcdefabcdefabcdef\",maxLetters = 6,minSize = 3,maxSize = 6) == 3\n assert candidate(s = \"mississippiississippiississi\",maxLetters = 4,minSize = 5,maxSize = 8) == 3\n assert candidate(s = \"abcdefabcdef\",maxLetters = 6,minSize = 3,maxSize = 6) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 10) == 20\n assert candidate(s = \"abracadabraabracadabra\",maxLetters = 5,minSize = 5,maxSize = 10) == 2\n assert candidate(s = \"xyxxyxyxyx\",maxLetters = 2,minSize = 1,maxSize = 3) == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",maxLetters = 10,minSize = 5,maxSize = 8) == 1\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababab\",maxLetters = 2,minSize = 2,maxSize = 4) == 35\n assert candidate(s = \"ababababababababababababababab\",maxLetters = 2,minSize = 4,maxSize = 8) == 14\n assert candidate(s = \"abababababab\",maxLetters = 2,minSize = 2,maxSize = 3) == 6\n assert candidate(s = \"llllllllllllll\",maxLetters = 1,minSize = 6,maxSize = 8) == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",maxLetters = 1,minSize = 10,maxSize = 20) == 21\n assert candidate(s = \"xyzxyzxyz\",maxLetters = 3,minSize = 3,maxSize = 6) == 3\n assert candidate(s = \"ababababababababababababababab\",maxLetters = 2,minSize = 2,maxSize = 2) == 15\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\",maxLetters = 4,minSize = 5,maxSize = 10) == 8\n assert candidate(s = \"abababababababababab\",maxLetters = 2,minSize = 4,maxSize = 6) == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",maxLetters = 1,minSize = 10,maxSize = 15) == 11\n assert candidate(s = \"abcabcabcabc\",maxLetters = 3,minSize = 3,maxSize = 4) == 4\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",maxLetters = 10,minSize = 5,maxSize = 10) == 1\n assert candidate(s = \"abababababababab\",maxLetters = 2,minSize = 2,maxSize = 4) == 8\n assert candidate(s = \"pqrspqrspqrspqrs\",maxLetters = 4,minSize = 5,maxSize = 8) == 3\n assert candidate(s = \"abcabcabcabc\",maxLetters = 3,minSize = 1,maxSize = 10) == 4\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",maxLetters = 10,minSize = 5,maxSize = 10) == 2\n assert candidate(s = \"aabbccddeeff\",maxLetters = 3,minSize = 4,maxSize = 6) == 1\n assert candidate(s = \"aaabbbcccdddeee\",maxLetters = 2,minSize = 2,maxSize = 3) == 2\n assert candidate(s = \"abcabcabcabcabcabc\",maxLetters = 3,minSize = 2,maxSize = 4) == 6\n assert candidate(s = \"aabbccddeeff\",maxLetters = 3,minSize = 2,maxSize = 6) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 10) == 22\n assert candidate(s = \"zzzzzzzzzzzz\",maxLetters = 1,minSize = 5,maxSize = 6) == 8\n assert candidate(s = \"abababababababababababababab\",maxLetters = 2,minSize = 3,maxSize = 5) == 13\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",maxLetters = 5,minSize = 10,maxSize = 15) == 0\n", "comparison": "exact"}, "public_tests": ["\"aababcaab\"\n2\n3\n4", "\"aaaa\"\n1\n3\n3"], "hints": ["Check out the constraints, (maxSize <=26).", "This means you can explore all substrings in O(n * 26).", "Find the Maximum Number of Occurrences of a Substring with bruteforce."], "metadata": {"canonical_parameter_names": ["s", "maxLetters", "minSize", "maxSize"], "leetcode_dataset_entry_point": "Solution().maxFreq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:56+00:00", "tests_total": 117, "tests_dropped": 3, "flags": [], "topic_tags": ["hash-table", "string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int:", "container": "Solution", "callable": "maxFreq", "parameters": [{"name": "s", "type": "str"}, {"name": "maxLetters", "type": "int"}, {"name": "minSize", "type": "int"}, {"name": "maxSize", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1298, "task_id": "maximum-candies-you-can-get-from-boxes", "difficulty": "Hard", "problem_description": "You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:\n\n- status[i] is 1 if the i^th box is open and 0 if the i^th box is closed,\n- candies[i] is the number of candies in the i^th box,\n- keys[i] is a list of the labels of the boxes you can open after opening the i^th box.\n- containedBoxes[i] is a list of the boxes you found inside the i^th box.\n\nYou are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.\n\nReturn the maximum number of candies you can get following the rules above.\n\nExample 1:\n\nInput: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0]\nOutput: 16\nExplanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2.\nBox 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.\nIn box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.\nTotal number of candies collected = 7 + 4 + 5 = 16 candy.\n\nExample 2:\n\nInput: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0]\nOutput: 6\nExplanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys.\nThe total number of candies will be 6.\n\nConstraints:\n\n- n == status.length == candies.length == keys.length == containedBoxes.length\n- 1 <= n <= 1000\n- status[i] is either 0 or 1.\n- 1 <= candies[i] <= 1000\n- 0 <= keys[i].length <= n\n- 0 <= keys[i][j] < n\n- All values of keys[i] are unique.\n- 0 <= containedBoxes[i].length <= n\n- 0 <= containedBoxes[i][j] < n\n- All values of containedBoxes[i] are unique.\n- Each box is contained in one box at most.\n- 0 <= initialBoxes.length <= n\n- 0 <= initialBoxes[i] < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(status = [0, 0, 0],candies = [100, 200, 300],keys = [[1, 2], [0, 2], [0, 1]],containedBoxes = [[1, 2], [0, 2], [0, 1]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0],candies = [10, 20, 30],keys = [[1], [2], []],containedBoxes = [[], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 1, 0, 0, 1],candies = [5, 15, 25, 35, 45],keys = [[2, 3], [], [4], [], []],containedBoxes = [[1, 2], [3], [], [], []],initialBoxes = [0]) == 80\n assert candidate(status = [1, 1, 0, 0],candies = [10, 20, 30, 40],keys = [[], [], [2], [3]],containedBoxes = [[2, 3], [], [], []],initialBoxes = [0, 1]) == 30\n assert candidate(status = [1, 1, 0, 0],candies = [10, 20, 30, 40],keys = [[2], [3], [], []],containedBoxes = [[], [], [1, 3], []],initialBoxes = [0, 1]) == 30\n assert candidate(status = [1, 0, 1, 0, 1],candies = [3, 5, 2, 7, 6],keys = [[2], [1, 4], [0], [], [3]],containedBoxes = [[4], [3], [], [1], [2]],initialBoxes = [0]) == 11\n assert candidate(status = [0, 0, 1, 1],candies = [10, 20, 30, 40],keys = [[1, 3], [0], [], []],containedBoxes = [[2], [3], [], []],initialBoxes = [2]) == 30\n assert candidate(status = [0, 0, 1, 1],candies = [10, 20, 30, 40],keys = [[1, 2], [0], [3], []],containedBoxes = [[2, 3], [1], [], []],initialBoxes = [2]) == 30\n assert candidate(status = [1, 1, 1],candies = [5, 10, 15],keys = [[], [2], []],containedBoxes = [[1], [], []],initialBoxes = [0]) == 15\n assert candidate(status = [1, 0, 0, 0, 0, 0],candies = [1, 1, 1, 1, 1, 1],keys = [[1, 2, 3, 4, 5], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5], [], [], [], [], []],initialBoxes = [0]) == 6\n assert candidate(status = [0, 0, 0, 0],candies = [100, 200, 300, 400],keys = [[1, 2], [2, 3], [3], []],containedBoxes = [[1, 2, 3], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 0],candies = [100, 200, 300],keys = [[1], [], [2]],containedBoxes = [[2], [], []],initialBoxes = [0]) == 100\n assert candidate(status = [0, 0, 1, 1],candies = [2, 3, 5, 7],keys = [[1, 2], [2, 3], [], []],containedBoxes = [[2, 3], [3], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 1, 0],candies = [7, 5, 4, 100],keys = [[], [], [1], []],containedBoxes = [[1, 2], [3], [], []],initialBoxes = [0]) == 16\n assert candidate(status = [1, 1, 1],candies = [5, 5, 5],keys = [[], [2], [1]],containedBoxes = [[1, 2], [0, 2], [0, 1]],initialBoxes = [0]) == 15\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70],keys = [[3, 5], [0, 2], [4], [], [6], [], []],containedBoxes = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1], [0, 2]],initialBoxes = [0]) == 260\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0],candies = [10, 20, 30, 40, 50, 60, 70],keys = [[1, 3, 5], [2, 4, 6], [3, 4], [0, 5, 6], [0, 2, 4], [0, 3, 5], [2, 4, 6]],containedBoxes = [[1, 2, 3], [4, 5, 6], [0, 3, 5], [2, 4, 6], [0, 1, 5], [2, 3, 4], [0, 1, 4]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keys = [[1, 2], [3, 4], [5, 6], [7, 8], [9], [], [], [], [], []],containedBoxes = [[3, 4, 5], [6, 7, 8], [9], [], [], [0, 1, 2], [3, 4, 5], [6, 7, 8], [9], [0, 1, 2]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60],keys = [[1, 2], [0], [3], [4], [5], []],containedBoxes = [[2, 3], [0, 3], [1, 4], [2, 5], [3], []],initialBoxes = [1]) == 210\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90],keys = [[1, 3, 5, 7, 8], [2, 4, 6], [0, 3, 6, 8], [1, 4, 7], [0, 2, 7, 8], [1, 3, 6], [0, 2, 5, 8], [1, 3, 4, 8], [0, 1, 2, 3, 4, 5, 6, 7]],containedBoxes = [[1, 3, 5, 7, 8], [2, 4, 6], [0, 3, 6, 8], [1, 4, 7], [0, 2, 7, 8], [1, 3, 6], [0, 2, 5, 8], [1, 3, 4, 8], [0, 1, 2, 3, 4, 5, 6, 7]],initialBoxes = [0]) == 450\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keys = [[1, 3, 5, 7], [2, 4, 6, 8], [], [], [], [], [], [], [], []],containedBoxes = [[1, 3, 5, 7], [2, 4, 6, 8], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0],candies = [50, 100, 150, 200, 250, 300, 350],keys = [[2, 3], [1, 3], [0, 2, 4], [0, 1, 2, 5], [0, 3, 5, 6], [1, 4, 6], [1, 3, 4]],containedBoxes = [[1, 2, 3], [0, 2, 4], [0, 1, 5], [0, 1, 2, 5], [0, 3, 5, 6], [1, 4, 6], [1, 3, 4]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70],keys = [[1, 2, 3], [3, 4], [4, 5, 6], [5, 6], [], [], []],containedBoxes = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70, 80],keys = [[1, 3, 5, 7], [2, 4, 6], [0, 3, 6], [1, 4, 7], [0, 2, 7], [1, 3, 6], [0, 2, 5], [1, 3, 4]],containedBoxes = [[1, 3, 5, 7], [2, 4, 6], [0, 3, 6], [1, 4, 7], [0, 2, 7], [1, 3, 6], [0, 2, 5], [1, 3, 4]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],keys = [[1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8]],containedBoxes = [[1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8], [1, 3, 5, 7], [2, 4, 6, 8]],initialBoxes = [0, 2, 4, 6, 8]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 1, 1, 1, 1, 1, 1, 1, 1],keys = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [], []],containedBoxes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],keys = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 660\n assert candidate(status = [1, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8],keys = [[1, 2], [3, 4], [5, 6], [], [7], [], [], []],containedBoxes = [[1, 2], [3, 4], [5, 6], [], [7], [], [], []],initialBoxes = [0]) == 36\n assert candidate(status = [1, 0, 0, 0, 1, 0],candies = [150, 120, 300, 180, 90, 210],keys = [[1, 4], [2], [3], [4], [], [3]],containedBoxes = [[2], [3], [4], [5], [], []],initialBoxes = [0]) == 150\n assert candidate(status = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 66\n assert candidate(status = [1, 0, 1, 0, 1, 0],candies = [10, 20, 30, 40, 50, 60],keys = [[2, 3], [1, 4], [0, 5], [0, 4], [3, 5], []],containedBoxes = [[2, 5], [4], [], [1], [5], [0]],initialBoxes = [0]) == 100\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70],keys = [[1, 3], [2, 4], [5], [], [6], [], []],containedBoxes = [[3, 4], [0, 1, 5], [2, 6], [], [], [], []],initialBoxes = [0]) == 100\n assert candidate(status = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1],candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],keys = [[3, 5, 7, 9], [0, 2, 4, 6, 8], [], [], [], [], [], [], [], []],containedBoxes = [[1, 3, 5, 7, 9], [2, 4, 6, 8], [3, 5, 7, 9], [4, 6, 8], [5, 7, 9], [6, 8], [7, 9], [8, 9], [9], []],initialBoxes = [0]) == 3600\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70, 80],keys = [[1, 4], [2, 5], [3, 6], [0, 7], [6, 3], [0, 7], [1, 4], [2, 5]],containedBoxes = [[2, 5], [4, 6], [7, 0], [3, 1], [6, 5], [0, 2], [5, 4], [7, 1]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 1, 0, 1, 0, 0, 0, 1],candies = [15, 25, 35, 5, 10, 15, 20, 25, 30, 40],keys = [[1, 3], [5], [], [6], [], [], [0], [7], [8], []],containedBoxes = [[1, 2, 3, 4], [5, 6], [7, 8], [], [5, 6], [0, 1, 2], [3, 4], [5, 6], [7, 8], []],initialBoxes = [3, 9]) == 45\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],keys = [[1, 3, 5, 7, 9], [2, 4, 6, 8], [], [], [], [], [], [], [], []],containedBoxes = [[1, 3, 5, 7, 9], [2, 4, 6, 8], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 275\n assert candidate(status = [1, 1, 0, 1, 0, 0],candies = [10, 20, 30, 40, 50, 60],keys = [[1, 2], [4], [3, 5], [], [5], []],containedBoxes = [[2, 3], [3], [4], [], [5], []],initialBoxes = [0]) == 80\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],keys = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10], [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], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]],containedBoxes = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10], [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], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90],keys = [[1, 2], [3, 4], [5, 6], [7, 8], [], [], [], [], []],containedBoxes = [[1, 2], [3, 4], [5, 6], [7, 8], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11], [], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11], [], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 0, 1, 0, 0, 0, 1],candies = [100, 200, 300, 400, 500, 600, 700, 800],keys = [[1, 3, 7], [2, 5], [4, 6], [], [], [], [], []],containedBoxes = [[2, 5, 6], [3, 4, 7], [1, 5, 7], [0, 4, 6], [], [], [], [0, 2]],initialBoxes = [0, 3]) == 500\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0],candies = [5, 10, 15, 20, 25, 30, 35],keys = [[1, 2, 3, 4, 5, 6], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 0, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70],keys = [[2, 3], [4], [], [], [], [6], [1]],containedBoxes = [[1, 2, 3], [], [4, 5], [], [], [], []],initialBoxes = [0]) == 130\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9], [], [5, 6, 7, 8, 9], [6, 7, 8, 9], [7, 8, 9], [8, 9], [9], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8, 9], [], [6, 7, 8, 9], [7, 8, 9], [8, 9], [9], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 1, 0, 0, 1, 0],candies = [10, 50, 20, 60, 30, 40, 70],keys = [[3], [1, 4], [5], [], [0], [], [2]],containedBoxes = [[2, 4], [5], [], [6], [], [0, 2], []],initialBoxes = [0]) == 30\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keys = [[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], [8, 9], [9], []],containedBoxes = [[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], [8, 9], [9], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keys = [[], [], [], [], [], [], [], [], [], [0, 1, 2, 3, 4, 5, 6, 7, 8]],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [0, 1, 2, 3, 4, 5, 6, 7, 8]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80],keys = [[1, 3, 5], [2, 4, 6], [3, 4], [0, 5, 6], [0, 2, 4], [0, 3, 5], [2, 4, 6], [1, 2, 3]],containedBoxes = [[1, 2, 3], [4, 5, 6], [0, 3, 5], [2, 4, 6], [0, 1, 5], [2, 3, 4], [0, 1, 4], [0, 1, 2, 3, 4, 5, 6]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 1, 0, 0, 0, 1, 0],candies = [1, 2, 3, 4, 5, 6, 7],keys = [[1, 2, 3, 4, 5, 6], [], [4, 5], [5, 6], [1, 3, 5], [], [2, 4]],containedBoxes = [[1, 2, 3, 4, 5, 6], [], [3, 4], [3, 5], [1, 3, 5], [], [2, 4]],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 1, 0, 0, 1],candies = [10, 20, 30, 40, 50, 60],keys = [[3, 4], [1], [2], [0], [5], []],containedBoxes = [[1, 2], [3], [4], [5], [], []],initialBoxes = [0]) == 90\n assert candidate(status = [1, 1, 1, 1, 1, 1, 1, 1],candies = [100, 200, 300, 400, 500, 600, 700, 800],keys = [[], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7], [], [], [], [], [], [], []],initialBoxes = [0]) == 3600\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keys = [[1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [], [], [], [], [], [], [], []],containedBoxes = [[1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [], [], [], [], [], [], [], []],initialBoxes = [1, 3, 5, 7, 9]) == 55\n assert candidate(status = [1, 0, 1, 0, 0, 1],candies = [50, 20, 10, 80, 60, 90],keys = [[3, 4], [2, 5], [], [], [], [1]],containedBoxes = [[1, 2], [3, 5], [], [], [2], []],initialBoxes = [0]) == 60\n assert candidate(status = [1, 0, 0, 1, 0, 1],candies = [100, 200, 300, 400, 500, 600],keys = [[2, 4], [], [1], [5], [], [0]],containedBoxes = [[3, 4, 5], [], [], [], [], [2]],initialBoxes = [0]) == 1900\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keys = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [9], []],initialBoxes = [9]) == 100\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1],candies = [5, 10, 15, 20, 25, 30, 35, 40],keys = [[1, 3, 5, 7], [], [3, 5, 7], [], [3, 5, 7], [], [3, 5, 7], []],containedBoxes = [[1, 3, 5, 7], [], [1, 3, 5, 7], [], [1, 3, 5, 7], [], [1, 3, 5, 7], []],initialBoxes = [0, 1]) == 10\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8],keys = [[1], [2], [3], [4], [5], [6], [7], []],containedBoxes = [[1], [2], [3], [4], [5], [6], [7], []],initialBoxes = [0]) == 0\n assert candidate(status = [0, 0, 1, 0, 0, 0, 1],candies = [220, 130, 50, 110, 80, 70, 60],keys = [[1, 2], [3, 4], [5, 6], [], [], [], [1]],containedBoxes = [[3, 4], [5], [6], [], [], [], [0]],initialBoxes = [2]) == 110\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80],keys = [[1], [3], [5], [7], [], [], [], []],containedBoxes = [[1, 3, 5, 7], [], [], [], [], [], [], []],initialBoxes = [0, 2, 4, 6]) == 360\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0],candies = [1, 3, 5, 7, 9, 11, 13, 15],keys = [[2, 4, 6], [1, 3, 5], [], [], [], [], [], []],containedBoxes = [[1, 3, 5], [2, 4, 6], [], [], [], [], [], []],initialBoxes = [0]) == 1\n assert candidate(status = [1, 1, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60],keys = [[1, 2, 3, 4, 5], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5], [], [], [], [], []],initialBoxes = [0]) == 210\n assert candidate(status = [1, 1, 0, 0, 0, 0, 0, 0],candies = [50, 30, 40, 20, 10, 70, 60, 80],keys = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7], [], []],containedBoxes = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7], [], [], []],initialBoxes = [0, 1]) == 360\n assert candidate(status = [0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60],keys = [[2, 3], [0, 5], [3, 4], [0, 5], [1, 2], [4]],containedBoxes = [[3, 4], [1, 5], [0, 4], [0, 1], [1, 3], [0]],initialBoxes = [3]) == 0\n assert candidate(status = [1, 1, 0, 0, 0, 1, 0],candies = [5, 15, 25, 35, 45, 55, 65],keys = [[3], [4], [], [6], [2], [], [0]],containedBoxes = [[2, 3, 4], [1, 5], [], [], [], [], []],initialBoxes = [0, 1]) == 180\n assert candidate(status = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 5500\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0, 0],candies = [1, 2, 3, 4, 5, 6, 7, 8, 9],keys = [[1, 3, 5], [2, 4, 6], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 7], [1, 5, 8], [0, 2, 6], [2, 3, 5]],containedBoxes = [[1, 3, 5], [2, 4, 6], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 7], [1, 5, 8], [0, 2, 6], [2, 3, 5]],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1],candies = [100, 200, 300, 400, 500, 600, 700],keys = [[1], [2], [3], [4], [5], [6], []],containedBoxes = [[1, 3, 5], [2, 4, 6], [3, 5, 6], [4, 5, 6], [5, 6], [6], []],initialBoxes = [0]) == 2800\n assert candidate(status = [1, 1, 1, 1, 1],candies = [10, 20, 30, 40, 50],keys = [[], [3, 4], [4], [], []],containedBoxes = [[1, 2, 3], [2, 3, 4], [3, 4], [], []],initialBoxes = [0]) == 150\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],candies = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],keys = [[1, 2], [3, 4], [5, 6], [7, 8], [9], [0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],containedBoxes = [[4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [6, 7, 8, 9], [7, 8, 9], [8, 9], [9, 0, 1], [0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]],initialBoxes = [0]) == 500\n assert candidate(status = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0],candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [1], [], [], []],containedBoxes = [[2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [0], [], [], []],initialBoxes = [0, 6]) == 265\n assert candidate(status = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],candies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],keys = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],containedBoxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [], [], [], [], [], [], [], [], []],initialBoxes = [0]) == 100\n assert candidate(status = [1, 0, 1, 0, 1, 0],candies = [5, 10, 15, 20, 25, 30],keys = [[2], [1, 3], [4], [0, 5], [], []],containedBoxes = [[2, 3], [1, 4], [0, 5], [], [], [2]],initialBoxes = [0]) == 20\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70],keys = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6], []],containedBoxes = [[1, 2, 3, 4, 5, 6], [], [], [], [], [], []],initialBoxes = [0]) == 0\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],keys = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [], [0, 1], [2, 3], [4, 5], [6, 7], [8, 9], []],containedBoxes = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [], [0, 1], [2, 3], [4, 5], [6, 7], [8, 9], []],initialBoxes = [0, 2, 4, 6, 8]) == 275\n assert candidate(status = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],candies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],keys = [[1, 2], [3, 4], [5, 6], [7, 8], [9], [0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],containedBoxes = [[3, 4, 5], [6, 7, 8], [9], [0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 1], [2, 3]],initialBoxes = [0]) == 2500\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],keys = [[2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7]],containedBoxes = [[4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9], [6, 7, 8, 9], [7, 8, 9], [8, 9], [9, 0, 1], [0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]],initialBoxes = [0]) == 0\n assert candidate(status = [0, 1, 0, 1, 0, 1, 0, 1],candies = [10, 20, 30, 40, 50, 60, 70, 80],keys = [[2], [3], [4], [5], [6], [7], [], [1]],containedBoxes = [[1, 3, 5, 7], [2, 4, 6], [3, 5, 7], [4, 6], [5, 7], [6, 7], [], []],initialBoxes = [0, 1]) == 20\n assert candidate(status = [0, 0, 0, 0, 0, 0, 0, 0],candies = [10, 20, 30, 40, 50, 60, 70, 80],keys = [[1, 2], [3, 4], [5, 6], [7], [6], [5], [4], [3]],containedBoxes = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1], [0, 2]],initialBoxes = [0]) == 0\n", "comparison": "exact"}, "public_tests": ["[1,0,1,0]\n[7,5,4,100]\n[[],[],[1],[]]\n[[1,2],[3],[],[]]\n[0]", "[1,0,0,0,0,0]\n[1,1,1,1,1,1]\n[[1,2,3,4,5],[],[],[],[],[]]\n[[1,2,3,4,5],[],[],[],[],[]]\n[0]"], "hints": ["Use Breadth First Search (BFS) to traverse all possible boxes you can open. Only push to the queue the boxes the you have with their keys."], "metadata": {"canonical_parameter_names": ["status", "candies", "keys", "containedBoxes", "initialBoxes"], "leetcode_dataset_entry_point": "Solution().maxCandies", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:15:59+00:00", "tests_total": 83, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def maxCandies(self, status: list[int], candies: list[int], keys: list[list[int]], containedBoxes: list[list[int]], initialBoxes: list[int]) -> int:", "container": "Solution", "callable": "maxCandies", "parameters": [{"name": "status", "type": "list[int]"}, {"name": "candies", "type": "list[int]"}, {"name": "keys", "type": "list[list[int]]"}, {"name": "containedBoxes", "type": "list[list[int]]"}, {"name": "initialBoxes", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1299, "task_id": "replace-elements-with-greatest-element-on-right-side", "difficulty": "Easy", "problem_description": "Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1.\n\nAfter doing so, return the array.\n\nExample 1:\n\nInput: arr = [17,18,5,4,6,1]\nOutput: [18,6,6,6,1,-1]\nExplanation:\n- index 0 --> the greatest element to the right of index 0 is index 1 (18).\n- index 1 --> the greatest element to the right of index 1 is index 4 (6).\n- index 2 --> the greatest element to the right of index 2 is index 4 (6).\n- index 3 --> the greatest element to the right of index 3 is index 4 (6).\n- index 4 --> the greatest element to the right of index 4 is index 5 (1).\n- index 5 --> there are no elements to the right of index 5, so we put -1.\n\nExample 2:\n\nInput: arr = [400]\nOutput: [-1]\nExplanation: There are no elements to the right of index 0.\n\nConstraints:\n\n- 1 <= arr.length <= 10^4\n- 1 <= arr[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [5, 4, 3, 2, 1]) == [4, 3, 2, 1, -1]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [5, 5, 5, 5, -1]\n assert candidate(arr = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, -1]\n assert candidate(arr = [1, 2]) == [2, -1]\n assert candidate(arr = [1, 2, 3]) == [3, 3, -1]\n assert candidate(arr = [17, 18, 5, 4, 6, 1]) == [18, 6, 6, 6, 1, -1]\n assert candidate(arr = [1]) == [-1]\n assert candidate(arr = [10, 20, 30, 40, 50]) == [50, 50, 50, 50, -1]\n assert candidate(arr = [50, 40, 30, 20, 10]) == [40, 30, 20, 10, -1]\n assert candidate(arr = [99999, 99998, 99997, 99996, 99995]) == [99998, 99997, 99996, 99995, -1]\n assert candidate(arr = [2, 1]) == [1, -1]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [400]) == [-1]\n assert candidate(arr = [3, 3, 3, 3, 3]) == [3, 3, 3, 3, -1]\n assert candidate(arr = [100000, 100000, 100000]) == [100000, 100000, -1]\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [3, 3, 3, 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(arr = [100000, 99999, 99998, 99997, 99996, 99995]) == [99999, 99998, 99997, 99996, 99995, -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]) == [39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, -1]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995]) == [99999, 99998, 99997, 99996, 99995, -1]\n assert candidate(arr = [1, 2, 3, 2, 1, 3, 2, 1]) == [3, 3, 3, 3, 3, 2, 1, -1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [10, 9, 9, 8, 8, 7, 7, 6, 6, -1]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -1]\n assert candidate(arr = [1, 10, 100, 1000, 10000]) == [10000, 10000, 10000, 10000, -1]\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -1]\n assert candidate(arr = [100000]) == [-1]\n assert candidate(arr = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, -1]\n assert candidate(arr = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == [50, 50, 50, 50, 50, 50, 50, 50, 5, -1]\n assert candidate(arr = [9, 4, 3, 9, 1, 8, 5, 2]) == [9, 9, 9, 8, 8, 5, 2, -1]\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 4, 3, 2, 1, -1]\n assert candidate(arr = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 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, 4, -1]\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, -1]\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [100000, 100000, 100000, 100000, 100000]) == [100000, 100000, 100000, 100000, -1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, -1]\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, -1]\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [10, 9, 9, 8, 8, 7, 7, 6, 6, -1]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994]) == [99999, 99998, 99997, 99996, 99995, 99994, -1]\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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(arr = [1, 3, 2, 4, 5, 7, 6, 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]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, -1]\n assert candidate(arr = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, -1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, -1]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [9, 9, 9, 9, 9, 6, 6, 5, 5, 5, -1]\n assert candidate(arr = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(arr = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, -1]\n assert candidate(arr = [5, 5, 5, 5, 5, 9, 5, 5, 5, 5]) == [9, 9, 9, 9, 9, 5, 5, 5, 5, -1]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -1]\n assert candidate(arr = [100, 90, 90, 80, 80, 70, 60, 50, 40, 30, 20, 10]) == [90, 90, 80, 80, 70, 60, 50, 40, 30, 20, 10, -1]\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]\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, -1]\n assert candidate(arr = [3, 2, 2, 3, 1, 1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [90, 80, 70, 60, 50, 40, 30, 20, 10, -1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, -1]\n assert candidate(arr = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [45, 40, 35, 30, 25, 20, 15, 10, 5, -1]\n assert candidate(arr = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, -1]\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, -1]\n assert candidate(arr = [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, -1]\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(arr = [1, 3, 2, 4, 5, 3, 4, 2, 3, 1]) == [5, 5, 5, 5, 4, 4, 3, 3, 1, -1]\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20]) == [20, 20, 20, 20, 20, 20, 20, -1]\n assert candidate(arr = [9, 4, 3, 9, 2, 5, 6, 7, 8, 1]) == [9, 9, 9, 8, 8, 8, 8, 8, 1, -1]\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [10, 100, 1000, 10000, 100000, 99999, 9999, 999, 99, 9]) == [100000, 100000, 100000, 100000, 99999, 9999, 999, 99, 9, -1]\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, -1]\n assert candidate(arr = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 1, -1]\n assert candidate(arr = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1, -1]\n assert candidate(arr = [3, 5, 1, 8, 9, 1, 4, 2, 10, 7]) == [10, 10, 10, 10, 10, 10, 10, 10, 7, -1]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, -1]\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, -1]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -1]\n assert candidate(arr = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, -1]\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60]) == [60, 60, 60, 60, 60, 60, 60, 60, 60, -1]\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == [100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996, 99996, -1]\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 7, 9, 8, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2]) == [3, 3, 3, 3, 3, 3, 3, 3, 2, -1]\n assert candidate(arr = [9, 4, 3, 2, 7, 8, 5, 6]) == [8, 8, 8, 8, 8, 6, 6, -1]\n assert candidate(arr = [9, 4, 3, 7, 2, 8, 6]) == [8, 8, 8, 8, 8, 6, -1]\n assert candidate(arr = [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, -1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1]\n assert candidate(arr = [2, 2, 2, 3, 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, -1]\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -1]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8]) == [8, 8, 8, 8, 8, 8, 8, -1]\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10]) == [10, 10, 10, 10, 10, 10, -1]\n assert candidate(arr = [100000, 100000, 100000, 100000]) == [100000, 100000, 100000, -1]\n", "comparison": "exact"}, "public_tests": ["[17,18,5,4,6,1]", "[400]"], "hints": ["Loop through the array starting from the end.", "Keep the maximum value seen so far."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().replaceElements", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:01+00:00", "tests_total": 104, "tests_dropped": 4, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def replaceElements(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "replaceElements", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1300, "task_id": "sum-of-mutated-array-closest-to-target", "difficulty": "Medium", "problem_description": "Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.\n\nIn case of a tie, return the minimum such integer.\n\nNotice that the answer is not neccesarilly a number from arr.\n\nExample 1:\n\nInput: arr = [4,9,3], target = 10\nOutput: 3\nExplanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer.\n\nExample 2:\n\nInput: arr = [2,3,5], target = 10\nOutput: 5\n\nExample 3:\n\nInput: arr = [60864,25176,27249,21296,20204], target = 56803\nOutput: 11361\n\nConstraints:\n\n- 1 <= arr.length <= 10^4\n- 1 <= arr[i], target <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],target = 11) == 3\n assert candidate(arr = [5, 5, 5, 5, 5],target = 17) == 3\n assert candidate(arr = [10, 20, 30, 40, 50],target = 100) == 23\n assert candidate(arr = [2, 3, 5],target = 10) == 5\n assert candidate(arr = [9, 9, 9, 9, 9],target = 40) == 8\n assert candidate(arr = [10000, 10000, 10000],target = 10000) == 3333\n assert candidate(arr = [99999, 99999, 99999, 99999],target = 100000) == 25000\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 7\n assert candidate(arr = [60864, 25176, 27249, 21296, 20204],target = 56803) == 11361\n assert candidate(arr = [100000, 100000, 100000],target = 100000) == 33333\n assert candidate(arr = [5, 5, 5, 5, 5],target = 20) == 4\n assert candidate(arr = [10, 20, 30],target = 25) == 8\n assert candidate(arr = [1, 1, 1, 1, 1],target = 3) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],target = 15) == 5\n assert candidate(arr = [4, 9, 3],target = 10) == 3\n assert candidate(arr = [1, 1, 1, 1, 1],target = 5) == 1\n assert candidate(arr = [10000, 20000, 30000, 40000, 50000],target = 100000) == 23333\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],target = 95000) == 9500\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 100) == 7\n assert candidate(arr = [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(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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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) == 0\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],target = 30000) == 3429\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5],target = 20) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 100) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 4500) == 600\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 100) == 9\n assert candidate(arr = [50000, 25000, 75000, 12500, 100000],target = 100000) == 21875\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 150) == 13\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 50) == 1\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 500) == 95\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],target = 45000) == 4500\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 200) == 16\n assert candidate(arr = [23, 1, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164],target = 900) == 76\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],target = 100000) == 10000\n assert candidate(arr = [23, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90],target = 1500) == 48\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 40) == 5\n assert candidate(arr = [10, 20, 30, 40, 50],target = 120) == 30\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 50) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 550) == 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],target = 100) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 20) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 150) == 10\n assert candidate(arr = [5, 15, 25, 35, 45, 55],target = 150) == 35\n assert candidate(arr = [1, 10, 100, 1000, 10000],target = 12345) == 10000\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 4500) == 600\n assert candidate(arr = [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(arr = [100, 150, 200, 250, 300],target = 800) == 183\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 30) == 3\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],target = 150) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 75) == 10\n assert candidate(arr = [1, 100000, 2, 99999, 3, 99998],target = 100000) == 33331\n assert candidate(arr = [1, 3, 5, 7, 9],target = 25) == 9\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],target = 10000) == 567\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 250) == 27\n assert candidate(arr = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],target = 200) == 23\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 300) == 37\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 1000) == 92\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 1500) == 95\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],target = 1000) == 50\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 7500) == 600\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 200) == 12\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],target = 8000) == 800\n assert candidate(arr = [50, 50, 50, 50, 50, 50],target = 200) == 33\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1000) == 1\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000],target = 10000) == 2333\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 450) == 45\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 20) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 3\n assert candidate(arr = [10, 20, 30, 40, 50],target = 150) == 50\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == 6\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 733\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 225) == 30\n assert candidate(arr = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],target = 550) == 59\n assert candidate(arr = [50, 40, 30, 20, 10],target = 150) == 50\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == 6\n assert candidate(arr = [1, 10, 100, 1000, 10000],target = 11111) == 10000\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 50) == 3\n assert candidate(arr = [100, 200, 300, 400, 500],target = 1400) == 400\n assert candidate(arr = [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(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == 10\n assert candidate(arr = [1, 100, 1000, 10000, 100000],target = 12345) == 5622\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 1000) == 92\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 3000) == 343\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 200) == 20\n assert candidate(arr = [1, 2, 3, 4, 5],target = 15) == 5\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],target = 55000) == 10000\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == 2\n assert candidate(arr = [5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000],target = 80000) == 9000\n assert candidate(arr = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996],target = 50000) == 9997\n assert candidate(arr = [50000, 40000, 30000, 20000, 10000],target = 100000) == 23333\n assert candidate(arr = [100, 200, 300, 400, 500],target = 1000) == 233\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 25) == 3\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 100) == 19\n", "comparison": "exact"}, "public_tests": ["[4,9,3]\n10", "[2,3,5]\n10", "[60864,25176,27249,21296,20204]\n56803"], "hints": ["If you draw a graph with the value on one axis and the absolute difference between the target and the array sum, what will you get?", "That graph is uni-modal.", "Use ternary search on that graph to find the best value."], "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().findBestValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:03+00:00", "tests_total": 113, "tests_dropped": 18, "flags": [], "topic_tags": ["array", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def findBestValue(self, arr: list[int], target: int) -> int:", "container": "Solution", "callable": "findBestValue", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1301, "task_id": "number-of-paths-with-max-score", "difficulty": "Hard", "problem_description": "You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'.\n\nYou need to reach the top left square marked with the character 'E'. The rest of the squares are labeled either with a numeric character 1, 2, ..., 9 or with an obstacle 'X'. In one move you can go up, left or up-left (diagonally) only if there is no obstacle there.\n\nReturn a list of two integers: the first integer is the maximum sum of numeric characters you can collect, and the second is the number of such paths that you can take to get that maximum sum, taken modulo 10^9 + 7.\n\nIn case there is no path, return [0, 0].\n\nExample 1:\n\nInput: board = [\"E23\",\"2X2\",\"12S\"]\nOutput: [7,1]\n\nExample 2:\n\nInput: board = [\"E12\",\"1X1\",\"21S\"]\nOutput: [4,2]\n\nExample 3:\n\nInput: board = [\"E11\",\"XXX\",\"11S\"]\nOutput: [0,0]\n\nConstraints:\n\n- 2 <= board.length == board[i].length <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = ['E11', 'XXX', '11S']) == [0, 0]\n assert candidate(board = ['EX', 'XS']) == [0, 1]\n assert candidate(board = ['E111', '1X11', '1111', '111S']) == [5, 8]\n assert candidate(board = ['E22', '222', '22S']) == [6, 6]\n assert candidate(board = ['E1X', 'X1X', 'X1S']) == [3, 1]\n assert candidate(board = ['EX', '1S']) == [1, 1]\n assert candidate(board = ['E23', '2X2', '12S']) == [7, 1]\n assert candidate(board = ['E111', '1111', '11X1', '111S']) == [5, 8]\n assert candidate(board = ['E12', '1X1', '21S']) == [4, 2]\n assert candidate(board = ['E1X', '1X1', 'S11']) == [3, 2]\n assert candidate(board = ['E1', '1S']) == [1, 2]\n assert candidate(board = ['E121', '2121', '1212', '1S11']) == [9, 6]\n assert candidate(board = ['E12X4', '56789', 'X1234', '5678X', '9XS12']) == [40, 1]\n assert candidate(board = ['E1234', '56X89', '4X321', '12X56', '789XS']) == [30, 1]\n assert candidate(board = ['E1234567', '23456789', '3456789X', '456789XS', '56789XSX', '6789XSXX', '789XSXXX', '89XSXXXX']) == [0, 0]\n assert candidate(board = ['E1234', '56789', 'X123X', '45678', '9XS12']) == [46, 1]\n assert candidate(board = ['E1X1', '1X1X', '1X1X', '1X1S']) == [4, 1]\n assert candidate(board = ['E2222', '22222', '22X22', '22222', '2222S']) == [14, 34]\n assert candidate(board = ['E11111111', '1X1X1X1X1', '111X111X1', '1X1X1X1X1', '111X111X1', '1X1X1X1X1', '111X111X1', '1X1X1X1X1', '11111111S']) == [15, 11]\n assert candidate(board = ['E9876', '9X8X7', '6X5X4', '3X2X1', '4321S']) == [42, 1]\n assert candidate(board = ['E999', '9X99', '99X9', '999S']) == [45, 4]\n assert candidate(board = ['E12X4', '56789', 'X1234', '56789', 'S1234']) == [52, 1]\n assert candidate(board = ['E111', '1X11', '11X1', '111S']) == [5, 4]\n assert candidate(board = ['E222', '2X22', '2X22', '2X2S']) == [10, 4]\n assert candidate(board = ['E12345', '6X7X89', '1X2X3X', '4X5X6X', '7X8X9X', '12345S']) == [41, 1]\n assert candidate(board = ['E1234', '1X1X1', '21212', '31313', '4141S']) == [16, 2]\n assert candidate(board = ['E1234', '56X78', '9X0X1', '23456', '7XS9E']) == [37, 1]\n assert candidate(board = ['E2222', '2X2X2', '2X2X2', '2X2X2', '2222S']) == [14, 3]\n assert candidate(board = ['E12X45', '1X2X3X', '4X5X6X', '7X8X9X', '1X2X3X', '45678S']) == [43, 1]\n assert candidate(board = ['E1111', '1X1X1', '111X1', '1X1X1', '1111S']) == [7, 4]\n assert candidate(board = ['E12121', '1X1X11', '212121', '1X1X11', '212121', '11111S']) == [13, 12]\n assert candidate(board = ['E12345', '6789XS', '54321X', '98765X', '43210X', '32109S']) == [55, 1]\n assert candidate(board = ['E22222', '2X2X22', '222X22', '2X2X22', '222X22', '22222S']) == [18, 11]\n assert candidate(board = ['E11111', '1X1X11', '1X1X11', '1X1X11', '1X1X11', '11111S']) == [9, 8]\n assert candidate(board = ['E12345', '67X9X1', '234567', '89XS12', '345678', '456789']) == [64, 10]\n assert candidate(board = ['E1234', '56X78', '9X123', '45678', '89XS1']) == [45, 1]\n assert candidate(board = ['E234', '1X12', '21XS', '3456']) == [21, 1]\n assert candidate(board = ['E1111', '1X1X1', '1X1X1', '1X1X1', '1111S']) == [7, 3]\n assert candidate(board = ['E11111', '111111', '111X11', '111111', '111111', '11111S']) == [9, 152]\n assert candidate(board = ['E1111111', '1X1X1X11', '111X1111', '1X1X1X11', '111X1111', '1X1X1X11', '111X1111', '1111111S']) == [13, 28]\n assert candidate(board = ['E123456789', '987654321X', '123456789X', 'X987654321', '123456789X', 'X987654321', '123456789X', 'X987654321', '123456789X', 'XS12345678']) == [121, 72]\n assert candidate(board = ['E12345', '67X890', '123X45', '678X90', '123X45', '6789XS']) == [45, 1]\n assert candidate(board = ['E12345', '1X2X3X', '4X5X6X', '7X8X9X', '1X2X3X', '45678S']) == [43, 1]\n assert candidate(board = ['E1111', '11111', '11X11', '11111', '1111S']) == [7, 34]\n assert candidate(board = ['E11X1', '1X1X1', '1X1X1', '1X1X1', '111XS']) == [0, 0]\n assert candidate(board = ['E111111', '1X1X1X1', '111X111', '1X1X1X1', '111X111', '1X1X1X1', '111111S']) == [11, 8]\n assert candidate(board = ['E111111', '1X1X1X1', '111X1X1', '1X1X1X1', '111X1X1', '1X1X1X1', '111111S']) == [11, 6]\n assert candidate(board = ['E11X1', '1X1X1', '1X1X1', '1X1X1', '11X1S']) == [6, 1]\n assert candidate(board = ['E123', '21X1', '1X1X', '321S']) == [9, 1]\n assert candidate(board = ['E11111', '1X1X11', '111X11', '1X1X11', '111X11', '11111S']) == [9, 11]\n assert candidate(board = ['E1111', '1X1X1', '11111', '1X1X1', '1111S']) == [7, 6]\n assert candidate(board = ['E1X11', '11X11', '111X1', '1111X', '1111S']) == [7, 19]\n assert candidate(board = ['E11111', '1X1X11', '111111', '1X1X1X', '111111', '11XS11']) == [10, 12]\n assert candidate(board = ['E1111111', '1X1X1X11', '11111111', '1X1X1X11', '11111111', '1X1X1X11', '11111111', '11XS1111']) == [14, 90]\n assert candidate(board = ['E12345', '1X2X3X', '4X5X6X', '7X8X9X', '1X2X3X', '4567XS']) == [31, 1]\n assert candidate(board = ['E1212121', '1X1X1X11', '21212121', '1X1X1X11', '21212121', '1X1X1X11', '21212121', '1111111S']) == [19, 40]\n assert candidate(board = ['E1234', '4321X', '1234X', '4321X', '1234S']) == [21, 8]\n assert candidate(board = ['E2222', '2X2X2', '222X2', '2X2X2', '2222S']) == [14, 4]\n assert candidate(board = ['E11111', '1X1X1X', '1X1X1X', '1X1X1X', '1X1X1X', '11111S']) == [9, 3]\n assert candidate(board = ['E1111', '11111', '11111', '11111', '1111S']) == [7, 70]\n assert candidate(board = ['E12X12', '234567', '89XS12', '345678', '456789', '56789S']) == [58, 15]\n assert candidate(board = ['E12345', '678X91', '234567', '89X123', '456789', '9XS123']) == [63, 2]\n assert candidate(board = ['E12X45', '6789X1', '234567', '89X123', '45678X', '9XS123']) == [56, 4]\n assert candidate(board = ['E123456789', '987654X789', '87654321X9', '7654321X89', '654321X789', '54321X6789', '4321X56789', '321X456789', '21X3456789', '1XS2345678']) == [125, 1]\n assert candidate(board = ['E1111', '11X11', '1X1X1', '11X11', '1111S']) == [7, 4]\n assert candidate(board = ['E12345', '67X89X', '123XS1', '456789', 'X98765', '4321XS']) == [55, 2]\n assert candidate(board = ['E1234', '1X1X1', '23X32', '1X1X1', '4321S']) == [14, 2]\n", "comparison": "exact"}, "public_tests": ["[\"E3283\",\"47715\",\"31479\",\"X1X32\",\"721XS\"]", "[\"E8X84\",\"98635\",\"24233\",\"X64X3\",\"281XS\"]", "[\"E3231\",\"3X588\",\"X2715\",\"94342\",\"6X82S\"]"], "hints": ["Use dynamic programming to find the path with the max score.", "Use another dynamic programming array to count the number of paths with max score."], "metadata": {"canonical_parameter_names": ["board"], "leetcode_dataset_entry_point": "Solution().pathsWithMaxScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:05+00:00", "tests_total": 95, "tests_dropped": 28, "flags": [], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def pathsWithMaxScore(self, board: list[str]) -> list[int]:", "container": "Solution", "callable": "pathsWithMaxScore", "parameters": [{"name": "board", "type": "list[str]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1304, "task_id": "find-n-unique-integers-sum-up-to-zero", "difficulty": "Easy", "problem_description": "Given an integer n, return any array containing n unique integers such that they add up to 0.\n\nExample 1:\n\nInput: n = 5\nOutput: [-7,-1,1,3,4]\nExplanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].\n\nExample 2:\n\nInput: n = 3\nOutput: [-1,0,1]\n\nExample 3:\n\nInput: n = 1\nOutput: [0]\n\nConstraints:\n\n- 1 <= n <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [1, -1, 0]\n assert candidate(n = 100) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50]\n assert candidate(n = 2) == [1, -1]\n assert candidate(n = 1) == [0]\n assert candidate(n = 1000) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499, 500, -500]\n assert candidate(n = 10) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(n = 5) == [1, -1, 2, -2, 0]\n assert candidate(n = 601) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 0]\n assert candidate(n = 105) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 666) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333]\n assert candidate(n = 995) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 0]\n assert candidate(n = 50) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25]\n assert candidate(n = 300) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150]\n assert candidate(n = 123) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 333) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 0]\n assert candidate(n = 550) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275]\n assert candidate(n = 4) == [1, -1, 2, -2]\n assert candidate(n = 600) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300]\n assert candidate(n = 64) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32]\n assert candidate(n = 16) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n assert candidate(n = 450) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225]\n assert candidate(n = 99) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 17) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 0]\n assert candidate(n = 501) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 0]\n assert candidate(n = 23) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 0]\n assert candidate(n = 51) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 80) == [1, -1, 2, -2, 3, -3, 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]\n assert candidate(n = 128) == [1, -1, 2, -2, 3, -3, 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]\n assert candidate(n = 101) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 8) == [1, -1, 2, -2, 3, -3, 4, -4]\n assert candidate(n = 250) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125]\n assert candidate(n = 999) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499, 0]\n assert candidate(n = 75) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 32) == [1, -1, 2, -2, 3, -3, 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 = 997) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 0]\n assert candidate(n = 256) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128]\n assert candidate(n = 20) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(n = 201) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 0]\n assert candidate(n = 889) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 0]\n assert candidate(n = 19) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 0]\n assert candidate(n = 667) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 0]\n assert candidate(n = 513) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 0]\n assert candidate(n = 13) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 0]\n assert candidate(n = 150) == [1, -1, 2, -2, 3, -3, 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]\n assert candidate(n = 800) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400]\n assert candidate(n = 11) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 0]\n assert candidate(n = 876) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438]\n assert candidate(n = 200) == [1, -1, 2, -2, 3, -3, 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]\n assert candidate(n = 400) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200]\n assert candidate(n = 512) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256]\n assert candidate(n = 9) == [1, -1, 2, -2, 3, -3, 4, -4, 0]\n assert candidate(n = 6) == [1, -1, 2, -2, 3, -3]\n assert candidate(n = 750) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375]\n assert candidate(n = 120) == [1, -1, 2, -2, 3, -3, 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]\n assert candidate(n = 499) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 0]\n assert candidate(n = 199) == [1, -1, 2, -2, 3, -3, 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, 0]\n assert candidate(n = 500) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250]\n assert candidate(n = 998) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499]\n assert candidate(n = 7) == [1, -1, 2, -2, 3, -3, 0]\n assert candidate(n = 25) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 0]\n", "comparison": "exact"}, "public_tests": ["5", "3", "1"], "hints": ["Return an array where the values are symmetric. (+x , -x).", "If n is odd, append value 0 in your returned array."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().sumZero", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:10+00:00", "tests_total": 60, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math"]}, "language": "python", "interface": {"raw_signature": "def sumZero(self, n: int) -> list[int]:", "container": "Solution", "callable": "sumZero", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1306, "task_id": "jump-game-iii", "difficulty": "Medium", "problem_description": "Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach any index with value 0.\n\nNotice that you can not jump outside of the array at any time.\n\nExample 1:\n\nInput: arr = [4,2,3,0,3,1,2], start = 5\nOutput: true\nExplanation:\nAll possible ways to reach at index 3 with value 0 are:\nindex 5 -> index 4 -> index 1 -> index 3\nindex 5 -> index 6 -> index 4 -> index 1 -> index 3\n\nExample 2:\n\nInput: arr = [4,2,3,0,3,1,2], start = 0\nOutput: true\nExplanation:\nOne possible way to reach at index 3 with value 0 is:\nindex 0 -> index 4 -> index 1 -> index 3\n\nExample 3:\n\nInput: arr = [3,0,2,1,2], start = 2\nOutput: false\nExplanation: There is no way to reach at index 1 with value 0.\n\nConstraints:\n\n- 1 <= arr.length <= 5 * 10^4\n- 0 <= arr[i] < arr.length\n- 0 <= start < arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 0, 5, 0, 5, 0],start = 1) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0],start = 0) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2],start = 0) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 4) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 5) == True\n assert candidate(arr = [3, 0, 2, 1, 2],start = 2) == False\n assert candidate(arr = [0, 1, 0, 1, 0],start = 3) == True\n assert candidate(arr = [0, 1, 1, 0, 1, 1],start = 4) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 2, 3, 4, 0],start = 0) == False\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0],start = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 0) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 2) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5],start = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 0],start = 4) == True\n assert candidate(arr = [2, 3, 1, 1, 4],start = 3) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1],start = 0) == False\n assert candidate(arr = [0, 1],start = 1) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0) == False\n assert candidate(arr = [1, 2, 3, 4, 0],start = 2) == False\n assert candidate(arr = [2, 3, 0, 1, 4],start = 2) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 1) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],start = 6) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 15) == True\n assert candidate(arr = [2, 0, 1, 1, 3, 0, 2, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 18) == True\n assert candidate(arr = [1, 3, 0, 0, 2, 4, 2, 0, 1, 3],start = 5) == True\n assert candidate(arr = [5, 0, 2, 0, 3, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0],start = 1) == True\n assert candidate(arr = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0],start = 1) == True\n assert candidate(arr = [3, 5, 2, 1, 0, 0, 1, 2, 3],start = 5) == True\n assert candidate(arr = [5, 1, 4, 1, 2, 3, 0, 1],start = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5],start = 6) == True\n assert candidate(arr = [5, 2, 1, 4, 0, 0, 0, 3, 1, 2, 1],start = 0) == True\n assert candidate(arr = [4, 0, 1, 0, 2, 3, 0, 1],start = 2) == True\n assert candidate(arr = [0, 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, 1, 0, 1, 0, 1, 0],start = 15) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 10) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0, 0, 0, 0, 5],start = 9) == True\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],start = 10) == True\n assert candidate(arr = [3, 2, 1, 0, 4, 2, 0, 3, 0, 1],start = 0) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0],start = 19) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0],start = 0) == True\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, 0],start = 24) == True\n assert candidate(arr = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 0) == True\n assert candidate(arr = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],start = 10) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3],start = 15) == False\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 20) == True\n assert candidate(arr = [3, 4, 1, 2, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2],start = 19) == True\n assert candidate(arr = [4, 2, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 13) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],start = 0) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],start = 5) == False\n assert candidate(arr = [4, 0, 5, 0, 3, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5],start = 1) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 19) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2, 3, 0, 1],start = 8) == True\n assert candidate(arr = [3, 4, 2, 3, 0, 1, 2, 0, 1, 3],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 14) == True\n assert candidate(arr = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0],start = 0) == False\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],start = 6) == True\n assert candidate(arr = [5, 3, 0, 0, 2, 0, 1, 0, 0, 3, 0],start = 2) == True\n assert candidate(arr = [1, 3, 0, 0, 2, 3, 4, 0, 0, 5, 4, 3],start = 1) == True\n assert candidate(arr = [4, 0, 5, 3, 0, 1, 2, 0, 3, 1],start = 5) == True\n assert candidate(arr = [4, 1, 3, 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, 0],start = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0],start = 19) == True\n assert candidate(arr = [2, 3, 0, 1, 4, 5, 6, 0, 2, 1],start = 3) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 19) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],start = 9) == True\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],start = 39) == False\n assert candidate(arr = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 9) == True\n assert candidate(arr = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0],start = 8) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 5) == True\n assert candidate(arr = [2, 0, 2, 0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 0, 2, 0],start = 14) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 10) == True\n assert candidate(arr = [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, 0],start = 34) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 13) == True\n assert candidate(arr = [5, 0, 1, 2, 3, 0, 1, 0, 2, 3, 0],start = 5) == True\n assert candidate(arr = [4, 2, 3, 1, 0, 2, 3, 4, 5, 0],start = 2) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 14) == True\n assert candidate(arr = [2, 3, 4, 5, 0, 0, 5, 4, 3, 2],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],start = 0) == True\n assert candidate(arr = [10, 8, 5, 0, 12, 10, 7, 3, 8, 4, 2, 9, 0, 6, 1],start = 5) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 20) == True\n assert candidate(arr = [5, 1, 3, 2, 4, 0, 6],start = 2) == True\n assert candidate(arr = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0],start = 1) == True\n assert candidate(arr = [3, 0, 2, 5, 0, 1, 2, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],start = 1) == True\n assert candidate(arr = [2, 1, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0],start = 2) == True\n assert candidate(arr = [2, 3, 1, 1, 2, 4, 2, 0, 1, 3, 1, 2, 3, 4, 0],start = 6) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0],start = 14) == True\n assert candidate(arr = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],start = 10) == True\n assert candidate(arr = [2, 3, 1, 1, 4, 2, 3, 1, 1, 4],start = 5) == False\n assert candidate(arr = [2, 4, 3, 2, 0, 1, 2, 3, 4, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 21) == True\n assert candidate(arr = [0, 3, 0, 5, 0, 0, 3, 1, 0, 2],start = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4],start = 8) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 4) == True\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 0, 1, 2, 3],start = 8) == True\n assert candidate(arr = [0, 3, 2, 1, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0],start = 10) == True\n assert candidate(arr = [1, 0, 3, 4, 0, 5, 2, 0, 0, 3, 2],start = 4) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 10) == True\n", "comparison": "exact"}, "public_tests": ["[4,2,3,0,3,1,2]\n5", "[4,2,3,0,3,1,2]\n0", "[3,0,2,1,2]\n2"], "hints": ["Think of BFS to solve the problem.", "When you reach a position with a value = 0 then return true."], "metadata": {"canonical_parameter_names": ["arr", "start"], "leetcode_dataset_entry_point": "Solution().canReach", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:14+00:00", "tests_total": 111, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "depth-first-search", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def canReach(self, arr: list[int], start: int) -> bool:", "container": "Solution", "callable": "canReach", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "start", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1307, "task_id": "verbal-arithmetic-puzzle", "difficulty": "Hard", "problem_description": "Given an equation, represented by words on the left side and the result on the right side.\n\nYou need to check if the equation is solvable under the following rules:\n\n- Each character is decoded as one digit (0 - 9).\n- No two characters can map to the same digit.\n- Each words[i] and result are decoded as one number without leading zeros.\n- Sum of numbers on the left side (words) will equal to the number on the right side (result).\n\nReturn true if the equation is solvable, otherwise return false.\n\nExample 1:\n\nInput: words = [\"SEND\",\"MORE\"], result = \"MONEY\"\nOutput: true\nExplanation: Map 'S'-> 9, 'E'->5, 'N'->6, 'D'->7, 'M'->1, 'O'->0, 'R'->8, 'Y'->'2'\nSuch that: \"SEND\" + \"MORE\" = \"MONEY\" , 9567 + 1085 = 10652\n\nExample 2:\n\nInput: words = [\"SIX\",\"SEVEN\",\"SEVEN\"], result = \"TWENTY\"\nOutput: true\nExplanation: Map 'S'-> 6, 'I'->5, 'X'->0, 'E'->8, 'V'->7, 'N'->2, 'T'->1, 'W'->'3', 'Y'->4\nSuch that: \"SIX\" + \"SEVEN\" + \"SEVEN\" = \"TWENTY\" , 650 + 68782 + 68782 = 138214\n\nExample 3:\n\nInput: words = [\"LEET\",\"CODE\"], result = \"POINT\"\nOutput: false\nExplanation: There is no possible mapping to satisfy the equation, so we return false.\nNote that two different characters cannot map to the same digit.\n\nConstraints:\n\n- 2 <= words.length <= 5\n- 1 <= words[i].length, result.length <= 7\n- words[i], result contain only uppercase English letters.\n- The number of different characters used in the expression is at most 10.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['SEND', 'MORE'],result = \"MONEY\") == True\n assert candidate(words = ['A', 'A', 'A', 'A'],result = \"AA\") == False\n assert candidate(words = ['LEET', 'CODE'],result = \"POINT\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HIALL\") == False\n assert candidate(words = ['AA', 'BB'],result = \"CC\") == True\n assert candidate(words = ['SIX', 'SEVEN', 'SEVEN'],result = \"TWENTY\") == True\n assert candidate(words = ['CAT', 'DOG'],result = \"BIRD\") == True\n assert candidate(words = ['ABA', 'B'],result = \"ABC\") == True\n assert candidate(words = ['A', 'B'],result = \"C\") == True\n assert candidate(words = ['ABC', 'BCD'],result = \"DEE\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PEACE\") == True\n assert candidate(words = ['CASTLE', 'KNIGHT'],result = \"BATTLE\") == False\n assert candidate(words = ['MAX', 'MIN'],result = \"SUM\") == True\n assert candidate(words = ['BAT', 'BALL', 'BASE'],result = \"TABLE\") == False\n assert candidate(words = ['FAST', 'CAR'],result = \"RACING\") == False\n assert candidate(words = ['HEAL', 'HURT'],result = \"BALANCE\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PYTHON\") == False\n assert candidate(words = ['SAINT', 'SEER'],result = \"VISION\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"GALAXY\") == False\n assert candidate(words = ['SNOW', 'ICE'],result = \"COLD\") == True\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HAPPY\") == False\n assert candidate(words = ['A', 'BB', 'CCC', 'DDDD'],result = \"E\") == False\n assert candidate(words = ['KNIGHT', 'KNIGHT'],result = \"WARLORD\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SIX\") == False\n assert candidate(words = ['TRUE', 'FALSE'],result = \"PARADOX\") == False\n assert candidate(words = ['STAR', 'SHIP'],result = \"GALAXY\") == False\n assert candidate(words = ['TEN', 'TEN', 'TEN'],result = \"THIRTY\") == False\n assert candidate(words = ['HOUSE', 'DOG'],result = \"FAMILY\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"GRAPE\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR', 'FIVE'],result = \"SUMUP\") == False\n assert candidate(words = ['FOUR', 'FIVE', 'SIX'],result = \"FIFTEEN\") == False\n assert candidate(words = ['UP', 'DOWN'],result = \"ZERO\") == True\n assert candidate(words = ['SUN', 'MOON'],result = \"STAR\") == True\n assert candidate(words = ['BIG', 'DOG'],result = \"ANIMAL\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PLANETS\") == False\n assert candidate(words = ['ABACAXI', 'MANGO', 'KIWI'],result = \"FRUITS\") == False\n assert candidate(words = ['CAT', 'DOG', 'MOUSE'],result = \"PIG\") == False\n assert candidate(words = ['BIRD', 'FLY', 'HIGH'],result = \"FLIGHT\") == False\n assert candidate(words = ['ALICE', 'BOB'],result = \"GAME\") == False\n assert candidate(words = ['RIGHT', 'WRONG'],result = \"FALSE\") == False\n assert candidate(words = ['CAT', 'DOG', 'MOUSE'],result = \"CLAW\") == False\n assert candidate(words = ['PYTHON', 'ROCKS'],result = \"PROGRAM\") == False\n assert candidate(words = ['FLY', 'FLY', 'HIGH'],result = \"SKYLINE\") == False\n assert candidate(words = ['SEND', 'MORE', 'MONEY'],result = \"TWICE\") == False\n assert candidate(words = ['UNO', 'DOS', 'TRES'],result = \"SEIS\") == True\n assert candidate(words = ['WIZARD', 'WAND'],result = \"MAGIC\") == False\n assert candidate(words = ['LUCK', 'IN', 'THE', 'DRAW'],result = \"SUCCESS\") == False\n assert candidate(words = ['SUN', 'MOON', 'STARS'],result = \"SKYLINE\") == False\n assert candidate(words = ['BLACK', 'WHITE', 'GRAY'],result = \"COLORS\") == False\n assert candidate(words = ['ALICE', 'BOB', 'CHARLIE'],result = \"FICTION\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SUM\") == False\n assert candidate(words = ['MAGIC', 'WAND'],result = \"WIZARD\") == False\n assert candidate(words = ['JAVA', 'PYTHON'],result = \"SCRIPT\") == False\n assert candidate(words = ['FALCON', 'HAWK'],result = \"BIRD\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"GRAPES\") == False\n assert candidate(words = ['ZERO', 'ONE'],result = \"SUM\") == False\n assert candidate(words = ['EARTH', 'WATER'],result = \"PLANET\") == False\n assert candidate(words = ['APPLE', 'BANANA', 'CHERRY'],result = \"FRUIT\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR'],result = \"TEN\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR'],result = \"SUM\") == False\n assert candidate(words = ['MATH', 'IS', 'FUN'],result = \"JOKES\") == False\n assert candidate(words = ['DOG', 'CAT'],result = \"ANIMAL\") == False\n assert candidate(words = ['GREEN', 'BLUE', 'YELLOW'],result = \"COLORS\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"FIVE\") == False\n assert candidate(words = ['MAT', 'ADD', 'SUB'],result = \"SUM\") == False\n assert candidate(words = ['WITCH', 'WAND'],result = \"MAGIC\") == True\n assert candidate(words = ['HAPPY', 'JOY'],result = \"BLISS\") == True\n assert candidate(words = ['STAR', 'PLANET', 'GALAXY'],result = \"COSMOS\") == False\n assert candidate(words = ['FAST', 'SLOW'],result = \"BALANCE\") == False\n assert candidate(words = ['LEFT', 'RIGHT'],result = \"EQUAL\") == False\n assert candidate(words = ['COOL', 'DRINK'],result = \"REFRESH\") == False\n assert candidate(words = ['MAGICAL', 'REALM'],result = \"MYSTERY\") == False\n assert candidate(words = ['LEARN', 'PYTHON'],result = \"CODEING\") == False\n assert candidate(words = ['CAR', 'BIKE'],result = \"VEHICLE\") == False\n assert candidate(words = ['HEART', 'SOUL'],result = \"LOVE\") == False\n assert candidate(words = ['MATH', 'IS', 'FUN'],result = \"GAMES\") == False\n assert candidate(words = ['PARIS', 'BERLIN'],result = \"ROME\") == False\n assert candidate(words = ['SUN', 'MOON'],result = \"AURA\") == True\n assert candidate(words = ['MATH', 'SCI', 'ENG'],result = \"STUDY\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"SKY\") == False\n assert candidate(words = ['ALPHA', 'BETA', 'GAMMA'],result = \"DELTA\") == True\n assert candidate(words = ['PYTHON', 'JAVA'],result = \"SCRIPT\") == False\n assert candidate(words = ['TEN', 'TWO'],result = \"TWELVE\") == False\n assert candidate(words = ['FAST', 'RUN', 'JUMP'],result = \"ATHLETE\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"CHERRY\") == True\n assert candidate(words = ['ALCHEMY', 'ENCHANT'],result = \"MAGICAL\") == False\n assert candidate(words = ['PYTHON', 'JAVA'],result = \"SCRIPT\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HALLO\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE'],result = \"SIX\") == False\n assert candidate(words = ['ABCDE', 'FGHIJ'],result = \"KLMNO\") == False\n assert candidate(words = ['SKY', 'TREE'],result = \"FOREST\") == False\n assert candidate(words = ['PI', 'E'],result = \"CIRCLE\") == False\n assert candidate(words = ['FOUR', 'FIVE', 'SIX'],result = \"FIFTEEN\") == False\n assert candidate(words = ['RED', 'BLUE'],result = \"COLOR\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"PLANET\") == False\n assert candidate(words = ['HAPPY', 'JOY'],result = \"HARMONY\") == False\n assert candidate(words = ['SPY', 'SPY'],result = \"QUIZ\") == True\n assert candidate(words = ['APPLE', 'BANANA'],result = \"FRUIT\") == False\n assert candidate(words = ['HAPPY', 'SAD'],result = \"JOY\") == False\n assert candidate(words = ['CRYPT', 'GRAPH', 'DRY'],result = \"DRYRUN\") == False\n assert candidate(words = ['GENIE', 'BOTTLE'],result = \"WISHES\") == False\n assert candidate(words = ['RED', 'BLUE'],result = \"GREEN\") == False\n assert candidate(words = ['BIRD', 'FLY'],result = \"SKY\") == False\n assert candidate(words = ['MYTH', 'HERO'],result = \"LEGEND\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SUM\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPP'],result = \"PROGRAM\") == False\n assert candidate(words = ['TREE', 'FOREST'],result = \"GREEN\") == False\n", "comparison": "exact"}, "public_tests": ["[\"SEND\",\"MORE\"]\n\"MONEY\"", "[\"SIX\",\"SEVEN\",\"SEVEN\"]\n\"TWENTY\"", "[\"LEET\",\"CODE\"]\n\"POINT\""], "hints": ["Use Backtracking and pruning to solve this problem.", "If you set the values of some digits (from right to left), the other digits will be constrained."], "metadata": {"canonical_parameter_names": ["words", "result"], "leetcode_dataset_entry_point": "Solution().isSolvable", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:16+00:00", "tests_total": 148, "tests_dropped": 41, "flags": [], "topic_tags": ["array", "math", "string", "backtracking"]}, "language": "python", "interface": {"raw_signature": "def isSolvable(self, words: list[str], result: str) -> bool:", "container": "Solution", "callable": "isSolvable", "parameters": [{"name": "words", "type": "list[str]"}, {"name": "result", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1309, "task_id": "decrypt-string-from-alphabet-to-integer-mapping", "difficulty": "Easy", "problem_description": "You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:\n\n- Characters ('a' to 'i') are represented by ('1' to '9') respectively.\n- Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.\n\nReturn the string formed after mapping.\n\nThe test cases are generated so that a unique mapping will always exist.\n\nExample 1:\n\nInput: s = \"10#11#12\"\nOutput: \"jkab\"\nExplanation: \"j\" -> \"10#\" , \"k\" -> \"11#\" , \"a\" -> \"1\" , \"b\" -> \"2\".\n\nExample 2:\n\nInput: s = \"1326#\"\nOutput: \"acz\"\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s consists of digits and the '#' letter.\n- s will be a valid string such that mapping is always possible.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"11#11#11#11#11#11#11#11#11#11#\") == \"kkkkkkkkkk\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"26#25#24#23#22#21#\") == \"zyxwvu\"\n assert candidate(s = \"1326#\") == \"acz\"\n assert candidate(s = \"25#24#23#22#21#20#19#18#17#16#15#14#13#\") == \"yxwvutsrqponm\"\n assert candidate(s = \"11#12#13#14#15#16#17#18#19#\") == \"klmnopqrs\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jklmnopqrstuvwxyz\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26\") == \"abcdefghijklmnopqrstuvwxybf\"\n assert candidate(s = \"10#11#12\") == \"jkab\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#\") == \"jt~ˆ’œ¦°º\"\n assert candidate(s = \"10#11#12#13#14#15#\") == \"jklmno\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321#\") == \"jklmnopqrstuvwxyzihgfedcu\"\n assert candidate(s = \"20#21#22#23#24#25#26#\") == \"tuvwxyz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjj\"\n assert candidate(s = \"26#25#24#23#22#21#20#19#18#17#16#15#14#13#12#11#10#\") == \"zyxwvutsrqponmlkj\"\n assert candidate(s = \"25#26#\") == \"yz\"\n assert candidate(s = \"123456789\") == \"abcdefghi\"\n assert candidate(s = \"11#22#33#44#55#66#77#88#99#\") == \"kvŒ—¢­¸Ã\"\n assert candidate(s = \"25#26#10#10#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"yzjjjklmnopqrstuvwxyz\"\n assert candidate(s = \"52525252525252525252525252525252525252525252525252525252525252525252525252525#\") == \"ebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebey\"\n assert candidate(s = \"26#25#24#23#22#21#20#19#18#17#16#15#14#13#12#11#10#987654321\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#11#21#31#41#51#61#71#81#91#26#\") == \"jt~ˆ’œ¦°ºku‰“§±»z\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#98765432112345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"abcdefghijklmnopqrstuvwxyzihgfedcbaabcdefghijklmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"lmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26\") == \"ijklmnopqrstuvwxybf\"\n assert candidate(s = \"12345678910#20#30#40#50#60#70#80#90#11#21#31#41#51#61#71#81#91#26#\") == \"abcdefghijt~ˆ’œ¦°ºku‰“§±»z\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"ijklmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"26#10#26#10#26#10#26#10#26#10#26#10#26#10#26#10#\") == \"zjzjzjzjzjzjzjzj\"\n assert candidate(s = \"10#20#30#11#21#31#12#22#32#13#23#33#14#24#34#15#25#35#16#26#36#\") == \"jt~kulv€mwnx‚oyƒpz„\"\n assert candidate(s = \"91#82#73#64#55#46#37#28#19#10#11#12#13#14#15#16#17#18#\") == \"»²© —Ž\u0085|sjklmnopqr\"\n assert candidate(s = \"12#14#16#18#20#22#24#26#11#13#15#17#19#21#23#25#\") == \"lnprtvxzkmoqsuwy\"\n assert candidate(s = \"11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#\") == \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\"\n assert candidate(s = \"25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#\") == \"yzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\"\n assert candidate(s = \"11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"klmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999999999999#10#\") == \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiÃj\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jklmnopqrstuvwxyzjklmnopqrstuvwxyz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjjj\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"ijklmnopqrstuvwxyz\"\n assert candidate(s = \"10#20#30#11#21#31#12#22#32#13#23#14#24#15#25#16#26\") == \"jt~kulv€mwnxoypbf\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jt~ˆ’œ¦°ºjklmnopqrstuvwxyz\"\n assert candidate(s = \"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#\") == \"jjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjj\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\"\n", "comparison": "exact"}, "public_tests": ["\"10#11#12\"", "\"1326#\""], "hints": ["Scan from right to left, in each step of the scanning check whether there is a trailing \"#\" 2 indexes away."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().freqAlphabets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:19+00:00", "tests_total": 43, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def freqAlphabets(self, s: str) -> str:", "container": "Solution", "callable": "freqAlphabets", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1310, "task_id": "xor-queries-of-a-subarray", "difficulty": "Medium", "problem_description": "You are given an array arr of positive integers. You are also given the array queries where queries[i] = [left_i,right_i].\n\nFor each query i compute the XOR of elements from left_i to right_i (that is, arr[left_i] XOR arr[left_i + 1] XOR ... XOR arr[right_i] ).\n\nReturn an array answer where answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]\nOutput: [2,7,14,8]\nExplanation:\nThe binary representation of the elements in the array are:\n1 = 0001\n3 = 0011\n4 = 0100\n8 = 1000\nThe XOR values for queries are:\n[0,1] = 1 xor 3 = 2\n[1,2] = 3 xor 4 = 7\n[0,3] = 1 xor 3 xor 4 xor 8 = 14\n[3,3] = 8\n\nExample 2:\n\nInput: arr = [4,8,2,10], queries = [[2,3],[1,3],[0,0],[0,3]]\nOutput: [8,0,4,4]\n\nConstraints:\n\n- 1 <= arr.length, queries.length <= 3 * 10^4\n- 1 <= arr[i] <= 10^9\n- queries[i].length == 2\n- 0 <= left_i <= right_i < arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [4, 8, 2, 10],queries = [[2, 3], [1, 3], [0, 0], [0, 3]]) == [8, 0, 4, 4]\n assert candidate(arr = [10, 5, 2, 3, 15],queries = [[0, 4], [1, 2], [2, 3], [0, 1], [3, 4]]) == [1, 7, 1, 15, 12]\n assert candidate(arr = [5, 2, 3, 9],queries = [[0, 0], [1, 3], [0, 2], [2, 3]]) == [5, 8, 4, 10]\n assert candidate(arr = [7, 11, 15, 22, 29],queries = [[0, 2], [1, 3], [0, 4], [4, 4]]) == [3, 18, 8, 29]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 2], [1, 3], [0, 1], [2, 2]]) == [0, 7, 4, 4]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [11, 0, 11, 0, 3]\n assert candidate(arr = [15, 10, 5, 3],queries = [[0, 3], [1, 1], [0, 0], [2, 3]]) == [3, 10, 15, 6]\n assert candidate(arr = [5, 2, 4, 6, 1],queries = [[0, 2], [1, 4], [0, 4], [3, 3]]) == [3, 1, 4, 6]\n assert candidate(arr = [7, 11, 13, 8],queries = [[0, 2], [1, 3], [2, 3], [0, 1]]) == [1, 14, 5, 12]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 0], [1, 1], [0, 1], [0, 3]]) == [5, 1, 4, 2]\n assert candidate(arr = [15, 14, 13, 12, 11],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [15, 14, 13, 12, 11]\n assert candidate(arr = [1, 1, 1, 1],queries = [[0, 1], [1, 2], [0, 3], [3, 3]]) == [0, 0, 0, 1]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 1], [2, 3], [0, 2], [1, 2]]) == [4, 6, 0, 5]\n assert candidate(arr = [1, 3, 4, 8],queries = [[0, 1], [1, 2], [0, 3], [3, 3]]) == [2, 7, 14, 8]\n assert candidate(arr = [3, 6, 9, 12, 15],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [3, 6, 9, 12, 15]\n assert candidate(arr = [7, 11, 15],queries = [[0, 2], [0, 0], [1, 1], [2, 2]]) == [3, 7, 11, 15]\n assert candidate(arr = [2, 6, 1, 8, 3, 9, 4],queries = [[0, 6], [2, 5], [1, 3], [4, 6], [0, 2]]) == [3, 3, 15, 14, 5]\n assert candidate(arr = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 4]]) == [503538687, 587645496, 362994761, 847757604, 111254601, 996193791, 161737801, 518034651, 195148873, 1025255708]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [[0, 10], [1, 8], [2, 9], [0, 3], [6, 8], [5, 7], [0, 1], [9, 10]]) == [2047, 510, 1020, 15, 448, 224, 3, 1536]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 10], [1, 5], [3, 7], [0, 6], [6, 10], [2, 9]]) == [2047, 992, 248, 2032, 31, 510]\n assert candidate(arr = [8, 13, 21, 34, 55, 89, 144, 233],queries = [[0, 7], [1, 5], [3, 6], [4, 7], [0, 6]]) == [37, 84, 220, 23, 204]\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [0, 4], [1, 3], [0, 3], [1, 2], [0, 2], [1, 1], [0, 1], [0, 0]]) == [0, 254, 124, 56, 16, 1, 252, 120, 48, 3, 248, 112, 7, 240, 15, 224, 31, 192, 63, 128, 127, 255]\n assert candidate(arr = [3, 6, 8, 12, 15, 9, 7, 11],queries = [[0, 7], [2, 5], [1, 6], [4, 6], [0, 3], [3, 7]]) == [11, 2, 3, 1, 1, 6]\n assert candidate(arr = [987654321, 876543219, 765432198, 654321987, 543219876, 432198765, 321987654, 219876543, 198765432, 98765432, 87654321],queries = [[0, 9], [1, 5], [3, 7], [0, 6], [6, 9], [2, 8]]) == [768397751, 117666047, 8926579, 787233800, 269601273, 651120525]\n assert candidate(arr = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],queries = [[0, 19], [1, 18], [3, 17], [4, 16], [6, 15]]) == [0, 23, 27, 13, 1]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],queries = [[0, 20], [2, 7], [5, 9], [0, 10], [10, 20], [4, 15]]) == [2097151, 252, 992, 2047, 2096128, 65520]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 975318642, 864213579, 753186429, 642135798, 531864297, 421357986],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [1049048706, 106058268, 737300943, 847988034, 1066314123, 438303364]\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],queries = [[0, 12], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [0, 4], [6, 8], [0, 7], [8, 10], [0, 1], [11, 12]]) == [129, 366, 613, 600, 432, 648, 521, 563, 843, 949, 435, 127]\n assert candidate(arr = [13, 7, 18, 5, 12, 6, 9, 4, 8, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7]]) == [24, 31, 16, 6, 10, 18, 23]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [682, 340, 168, 80, 32, 683, 343, 175, 95, 63, 31, 15, 7, 3, 1]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1023, 510, 252, 120, 48]\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707],queries = [[0, 9], [2, 7], [1, 8], [4, 5], [0, 3]]) == [982, 760, 366, 485, 707]\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 1], [1, 2], [2, 3], [3, 4]]) == [26, 55, 31, 51, 17, 5, 21, 19, 1, 6, 2, 12]\n assert candidate(arr = [987654321, 987654322, 987654323, 987654324, 987654325, 987654326, 987654327, 987654328, 987654329, 987654330],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [11, 0, 11, 0, 3]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 9], [1, 2], [6, 7], [8, 9]]) == [682, 340, 168, 80, 32, 640, 21, 256, 8, 2]\n assert candidate(arr = [9, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [6, 10, 16, 14, 5, 17]\n assert candidate(arr = [13, 29, 17, 23, 19, 31, 2, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 6], [7, 14]]) == [20, 4, 14, 12, 10, 20, 0, 24, 12]\n assert candidate(arr = [21, 33, 47, 59, 71, 83, 97, 101, 103, 107, 109, 113, 127],queries = [[0, 12], [2, 7], [5, 9], [0, 8], [9, 12], [4, 11]]) == [95, 4, 91, 87, 8, 0]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [0, 0], [10, 10], [0, 5], [5, 10]]) == [2047, 1022, 508, 248, 112, 32, 1024, 1, 2016, 63]\n assert candidate(arr = [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]]) == [20, 1, 16, 1, 20, 1, 8, 1, 4, 1]\n assert candidate(arr = [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]]) == [0, 14, 2, 12, 4, 10, 6, 8]\n assert candidate(arr = [2, 6, 3, 9, 11, 12, 5],queries = [[0, 6], [1, 4], [2, 3], [4, 5], [0, 5]]) == [12, 7, 10, 7, 9]\n assert candidate(arr = [6, 2, 8, 4, 10, 12, 14, 16, 18, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [22, 4, 20, 12, 6]\n assert candidate(arr = [13, 19, 31, 14, 20, 27, 25, 22, 23, 29, 30, 18, 21, 16, 26, 15, 24, 17, 28, 11, 3, 10, 5, 6, 7, 8, 9, 4, 12, 1],queries = [[0, 29], [5, 24], [10, 22], [15, 28], [20, 26], [25, 27], [0, 28], [1, 27], [2, 26], [3, 25], [4, 24], [5, 23], [6, 22], [7, 21], [8, 20], [9, 19], [10, 18], [11, 17], [12, 16], [13, 15], [0, 27], [1, 26], [2, 25], [3, 24], [4, 23], [5, 22], [6, 21], [7, 20], [8, 19], [9, 18], [10, 17], [11, 16], [12, 15], [0, 26], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [0, 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], [0, 24], [1, 23], [2, 22], [3, 21], [4, 20], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15], [10, 14], [11, 13], [12, 12]]) == [2, 17, 14, 21, 12, 5, 3, 2, 21, 3, 5, 22, 11, 23, 11, 31, 9, 11, 8, 5, 15, 6, 28, 11, 2, 16, 14, 29, 8, 20, 21, 26, 16, 11, 15, 20, 12, 4, 21, 4, 30, 3, 8, 4, 2, 31, 2, 7, 19, 10, 1, 31, 7, 21, 31, 25, 28, 13, 5, 10, 0, 21, 15, 11, 28, 12, 9, 14, 1, 19, 23, 21]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [5, 9]]) == [524095, 241270, 30061, 201228, 30433, 130751, 292406]\n assert candidate(arr = [2, 6, 12, 8, 3, 10],queries = [[0, 5], [1, 3], [2, 4], [0, 2], [4, 5]]) == [9, 2, 7, 8, 9]\n assert candidate(arr = [3, 8, 15, 2, 7, 9, 6, 11, 5, 10],queries = [[0, 9], [2, 5], [4, 7], [0, 4], [6, 9], [1, 8]]) == [10, 3, 3, 1, 2, 3]\n assert candidate(arr = [2, 6, 8, 10, 12, 14, 16, 18],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7]]) == [6, 22, 0, 6, 6, 0]\n assert candidate(arr = [5, 12, 25, 50, 100, 200, 400, 800, 1600, 3200],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [2302, 1147, 567, 270, 172, 2232, 70, 1264]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981],queries = [[0, 19], [2, 7], [5, 9], [0, 6], [6, 19], [2, 15]]) == [1004, 7, 999999991, 1000000001, 23, 15]\n assert candidate(arr = [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], [0, 0], [14, 14]]) == [0, 14, 2, 12, 4, 10, 6, 8, 1, 15]\n assert candidate(arr = [6, 9, 4, 7, 3, 8, 10, 12],queries = [[0, 7], [2, 5], [1, 4], [3, 6], [0, 3], [4, 7]]) == [1, 8, 9, 6, 12, 13]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7]]) == [29918, 200913, 130828, 232367, 100446, 130176]\n assert candidate(arr = [31, 15, 7, 3, 1],queries = [[0, 4], [1, 3], [2, 2], [3, 3], [0, 3], [1, 2]]) == [21, 11, 7, 3, 20, 8]\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [0, 17], [1, 16], [2, 15], [3, 14], [4, 13], [5, 12], [6, 11], [7, 10], [8, 9], [0, 16], [1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [0, 12], [1, 11], [2, 10], [3, 9], [4, 8], [5, 7], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [0, 4], [1, 3], [0, 3], [1, 2], [0, 2], [1, 1], [0, 1], [0, 0]]) == [8388600, 4194288, 2097120, 1048512, 524160, 261888, 130560, 64512, 30720, 12288, 4194296, 2097136, 1048544, 524224, 262016, 130816, 65024, 31744, 14336, 2097144, 1048560, 524256, 262080, 130944, 65280, 32256, 15360, 6144, 1048568, 524272, 262112, 131008, 65408, 32512, 15872, 7168, 524280, 262128, 131040, 65472, 32640, 16128, 7680, 3072, 262136, 131056, 65504, 32704, 16256, 7936, 3584, 131064, 65520, 32736, 16320, 8064, 3840, 1536, 65528, 32752, 16352, 8128, 3968, 1792, 32760, 16368, 8160, 4032, 1920, 768, 16376, 8176, 4064, 1984, 896, 8184, 4080, 2016, 960, 384, 4088, 2032, 992, 448, 2040, 1008, 480, 1016, 496, 224, 504, 240, 248, 112, 120, 48, 56, 16, 24, 8]\n assert candidate(arr = [97, 43, 27, 58, 103, 82, 75, 34, 69, 20, 15, 88, 47, 62, 91],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == [123, 65, 84, 96, 2, 106, 44, 34, 69, 20, 15, 88, 47, 62]\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],queries = [[0, 9], [1, 6], [2, 7], [3, 8], [4, 9], [0, 5], [5, 8], [0, 1], [8, 9]]) == [67, 9, 83, 25, 103, 63, 16, 27, 11]\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7], [0, 5], [2, 7], [1, 4], [0, 1], [6, 7], [0, 0], [7, 7]]) == [170, 84, 40, 16, 160, 10, 168, 42, 80, 128, 2, 255, 1]\n assert candidate(arr = [17, 23, 5, 31, 4, 6, 7, 9],queries = [[0, 7], [2, 5], [3, 6], [1, 4], [0, 0], [7, 7]]) == [16, 24, 26, 9, 17, 9]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111213141, 191817161, 151413121, 121110987, 765432109, 890123456],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [541748032, 304059029, 90073865, 176057750, 231612316]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [0, 14, 2, 12, 4, 10, 6]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [524095, 241270, 30061, 201228, 30433, 292406, 231689, 151730]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5],queries = [[0, 14], [5, 10], [2, 12], [0, 7], [8, 14]]) == [4, 14, 5, 15, 11]\n assert candidate(arr = [31, 28, 30, 29, 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],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], [0, 15], [15, 29]]) == [1, 28, 3, 25, 1, 28, 1, 16, 1, 28, 1, 24, 1, 28, 1, 0, 17]\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [2, 3]]) == [2040, 1008, 480, 192, 1016, 496, 224, 504, 240, 96]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [11, 0, 0, 7, 10, 2]\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],queries = [[0, 14], [1, 12], [3, 11], [4, 10], [6, 9]]) == [16, 0, 28, 20, 12]\n assert candidate(arr = [17, 23, 31, 47, 59, 67, 71, 83, 97, 101],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [94, 42, 92, 16, 120, 83, 13, 117]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 4], [5, 8]]) == [511, 254, 124, 56, 16, 31, 480]\n assert candidate(arr = [25, 35, 45, 55, 65, 75, 85, 95, 105],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [0, 4], [5, 8]]) == [73, 57, 69, 61, 97, 40]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 9], [1, 2], [6, 7], [8, 9]]) == [1015, 0, 7, 0, 7, 1020, 999999991, 1, 3, 15]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],queries = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 0], [15, 15]]) == [16, 1, 12, 1, 8, 1, 12, 1, 1, 16]\n assert candidate(arr = [234, 567, 890, 1234, 5678, 9012, 3456, 7890, 12345, 67890, 112233, 445566, 778899, 101112, 212223, 313233, 414243, 515253, 616263, 717273],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [650028, 203295, 687983, 893088, 783953, 993262, 800805, 900957, 410396, 48987]\n assert candidate(arr = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144],queries = [[0, 9], [1, 5], [3, 7], [0, 6], [6, 9], [2, 8]]) == [268173312, 130023424, 32505856, 266338304, 3932160, 66584576]\n", "comparison": "exact"}, "public_tests": ["[1,3,4,8]\n[[0,1],[1,2],[0,3],[3,3]]", "[4,8,2,10]\n[[2,3],[1,3],[0,0],[0,3]]"], "hints": ["What is the result of x ^ y ^ x ?", "Compute the prefix sum for XOR.", "Process the queries with the prefix sum values."], "metadata": {"canonical_parameter_names": ["arr", "queries"], "leetcode_dataset_entry_point": "Solution().xorQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:21+00:00", "tests_total": 77, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def xorQueries(self, arr: list[int], queries: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "xorQueries", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1311, "task_id": "get-watched-videos-by-your-friends", "difficulty": "Medium", "problem_description": "There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.\n\nLevel 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest.\n\nExample 1:\n\nInput: watchedVideos = [[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1\nOutput: [\"B\",\"C\"]\nExplanation:\nYou have id = 0 (green color in the figure) and your friends are (yellow color in the figure):\nPerson with id = 1 -> watchedVideos = [\"C\"]\nPerson with id = 2 -> watchedVideos = [\"B\",\"C\"]\nThe frequencies of watchedVideos by your friends are:\nB -> 1\nC -> 2\n\nExample 2:\n\nInput: watchedVideos = [[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2\nOutput: [\"D\"]\nExplanation:\nYou have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).\n\nConstraints:\n\n- n == watchedVideos.length == friends.length\n- 2 <= n <= 100\n- 1 <= watchedVideos[i].length <= 100\n- 1 <= watchedVideos[i][j].length <= 8\n- 0 <= friends[i].length < n\n- 0 <= friends[i][j] < n\n- 0 <= id < n\n- 1 <= level < n\n- if friends[i] contains j, then friends[j] contains i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(watchedVideos = [['Action', 'Comedy'], ['Action'], ['Comedy', 'Drama'], ['Drama']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 3,level = 1) == ['Action', 'Comedy', 'Drama']\n assert candidate(watchedVideos = [['X', 'Y'], ['Y', 'Z'], ['Z', 'X'], ['X', 'Y', 'Z']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['Z', 'X', 'Y']\n assert candidate(watchedVideos = [['X', 'Y'], ['Z'], ['X', 'Z'], ['W']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['W', 'X', 'Y']\n assert candidate(watchedVideos = [['A', 'B'], ['C'], ['B', 'C'], ['D']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 0,level = 1) == ['B', 'C']\n assert candidate(watchedVideos = [['M', 'N'], ['N'], ['M', 'N'], ['O']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 1) == ['M', 'N', 'O']\n assert candidate(watchedVideos = [['Movie1', 'Movie2'], ['Movie3'], ['Movie2', 'Movie3'], ['Movie4']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie3']\n assert candidate(watchedVideos = [['Movie1', 'Movie2'], ['Movie2', 'Movie3'], ['Movie3', 'Movie4'], ['Movie4', 'Movie5']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie2', 'Movie3']\n assert candidate(watchedVideos = [['P', 'Q'], ['R'], ['P', 'R'], ['S']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 3,level = 1) == ['P', 'R']\n assert candidate(watchedVideos = [['X', 'Y'], ['Y', 'Z'], ['X', 'Z'], ['W']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['W', 'X', 'Y']\n assert candidate(watchedVideos = [['Movie1'], ['Movie2'], ['Movie3'], ['Movie4']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie2']\n assert candidate(watchedVideos = [['A', 'B'], ['C'], ['B', 'C'], ['D']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 0,level = 2) == ['D']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'Comedy'], ['Comedy', 'Drama'], ['Drama', 'Thriller'], ['Action', 'Thriller']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1]],id = 0,level = 2) == ['Action', 'Comedy', 'Drama', 'Thriller']\n assert candidate(watchedVideos = [['Romance', 'Horror'], ['Romance', 'Drama'], ['Horror', 'Drama'], ['Romance'], ['Horror', 'Drama', 'Romance']],friends = [[1, 2, 3], [0, 4], [0, 3], [0, 2, 4], [1, 3]],id = 2,level = 1) == ['Horror', 'Romance']\n assert candidate(watchedVideos = [['Thriller'], ['Horror', 'Thriller'], ['Horror'], ['Comedy', 'Horror'], ['Comedy', 'Drama'], ['Drama', 'Thriller']],friends = [[1, 2, 3], [0, 2, 4], [0, 1, 4, 5], [0, 4, 5], [1, 2, 3, 5], [2, 3, 4]],id = 3,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'Romance'], ['Romance', 'Action'], ['Action', 'Comedy'], ['Comedy', 'Thriller']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1]],id = 0,level = 2) == ['Action', 'Comedy', 'Romance', 'Thriller']\n assert candidate(watchedVideos = [['Horror', 'Thriller'], ['Horror'], ['Thriller'], ['Horror', 'Thriller'], ['Horror'], ['Thriller', 'Comedy']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 5], [2], [3]],id = 0,level = 2) == ['Thriller', 'Horror']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Comedy'], ['Comedy', 'Thriller'], ['Thriller', 'SciFi']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 0,level = 2) == ['Comedy', 'SciFi', 'Thriller']\n assert candidate(watchedVideos = [['Romance', 'Drama'], ['Drama', 'Thriller'], ['Thriller', 'Horror'], ['Horror', 'Comedy'], ['Comedy', 'Romance'], ['Romance', 'Thriller']],friends = [[1, 2], [0, 3, 5], [0, 4], [1, 4], [2, 3], [1]],id = 3,level = 1) == ['Comedy', 'Drama', 'Romance', 'Thriller']\n assert candidate(watchedVideos = [['Anime', 'Cartoon'], ['Drama', 'Horror'], ['Cartoon'], ['Sci-Fi', 'Drama'], ['Horror', 'Anime']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 0,level = 2) == ['Anime', 'Drama', 'Horror', 'Sci-Fi']\n assert candidate(watchedVideos = [['Sci-Fi', 'Horror'], ['Romance'], ['Sci-Fi', 'Drama'], ['Romance', 'Sci-Fi'], ['Horror', 'Drama'], ['Comedy'], ['Drama'], ['Romance']],friends = [[1, 2, 3], [0, 4, 5], [0, 3, 6], [0, 2, 4, 7], [1, 3, 5, 7], [1, 4, 6], [2, 5], [3, 4, 7]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror'], ['Horror', 'Thriller'], ['Action', 'Drama'], ['Action'], ['Drama', 'Thriller'], ['Drama'], ['Thriller', 'Horror'], ['Drama', 'Horror'], ['Drama', 'Action']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8], [1, 0, 3, 4, 5, 6, 7, 8, 9], [1, 0, 2, 4, 5, 6, 7, 8, 9], [1, 2, 3, 0, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9], [1, 2, 3, 4, 5, 0, 7, 8, 9], [1, 2, 3, 4, 5, 6, 0, 8, 9], [1, 2, 3, 4, 5, 6, 7, 0, 9], [1, 2, 3, 4, 5, 6, 7, 8, 0]],id = 4,level = 4) == []\n assert candidate(watchedVideos = [['Fantasy', 'Comedy'], ['Fantasy'], ['Fantasy', 'Comedy'], ['Drama'], ['Fantasy', 'Drama'], ['Comedy', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2, 5], [2], [3]],id = 3,level = 2) == ['Comedy', 'Drama', 'Fantasy']\n assert candidate(watchedVideos = [['Drama'], ['Drama', 'Drama'], ['Thriller'], ['Thriller', 'Thriller', 'Drama'], ['Thriller', 'Drama']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 4], [2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Action', 'Drama'], ['Comedy', 'Romance'], ['Action', 'Comedy'], ['Romance'], ['Action', 'Romance'], ['Drama', 'Comedy']],friends = [[1, 2, 3], [0, 4], [0, 5], [0, 5], [1, 5], [2, 3, 4]],id = 0,level = 2) == ['Action', 'Comedy', 'Drama', 'Romance']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Comedy', 'Action'], ['Drama', 'Comedy'], ['Horror', 'Thriller'], ['Action', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1, 2]],id = 0,level = 2) == ['Action', 'Drama', 'Horror', 'Thriller']\n assert candidate(watchedVideos = [['Comedy'], ['Comedy', 'Horror'], ['Horror', 'Drama'], ['Comedy', 'Drama', 'Thriller'], ['Drama', 'Thriller'], ['Drama', 'Thriller', 'Horror'], ['Horror', 'Drama', 'Comedy'], ['Horror', 'Drama', 'Comedy', 'Thriller']],friends = [[1, 3, 4], [0, 2, 5], [1, 4], [0, 5, 7], [0, 2, 6], [1, 3, 6], [4, 7], [3, 6]],id = 5,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Romance'], ['Action'], ['Romance', 'Drama'], ['Drama', 'Thriller'], ['Action', 'Thriller'], ['Action', 'Romance']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 5], [3, 4]],id = 1,level = 3) == ['Action', 'Thriller']\n assert candidate(watchedVideos = [['Action'], ['Action', 'Comedy'], ['Comedy'], ['Drama', 'Action'], ['Drama'], ['Action', 'Drama'], ['Action', 'Comedy'], ['Comedy', 'Drama']],friends = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 5, 6], [0, 1, 6, 7], [1, 6], [2, 7], [2, 3, 4, 7], [3, 5, 6]],id = 4,level = 2) == ['Action', 'Comedy', 'Drama']\n assert candidate(watchedVideos = [['Comedy'], ['Action'], ['Romance'], ['Action', 'Romance'], ['Comedy', 'Romance'], ['Comedy', 'Action']],friends = [[1, 2, 3, 4], [0, 4, 5], [0, 5, 3], [0, 2, 5], [0, 1, 3], [1, 2, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Thriller'], ['Horror'], ['Sci-Fi'], ['Thriller', 'Horror'], ['Sci-Fi', 'Thriller'], ['Horror', 'Sci-Fi']],friends = [[1, 2], [0, 3, 4], [0, 5], [1, 5], [1, 5], [2, 3, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Horror'], ['Horror', 'Thriller'], ['Thriller'], ['Horror', 'Thriller', 'Comedy'], ['Comedy', 'Action'], ['Action', 'Comedy'], ['Action', 'Comedy'], ['Comedy', 'Thriller'], ['Thriller', 'Horror']],friends = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 5, 6], [0, 1, 6, 7], [1, 6], [2, 7], [2, 3, 4, 7], [3, 5, 6], [3, 7]],id = 5,level = 3) == ['Action', 'Comedy']\n assert candidate(watchedVideos = [['Romance'], ['Romance', 'Comedy'], ['Romance'], ['Comedy'], ['Romance', 'Action'], ['Action', 'Drama'], ['Drama', 'Action'], ['Drama'], ['Comedy', 'Romance'], ['Romance', 'Drama']],friends = [[1, 2, 3, 4], [0, 5, 6, 7, 8, 9], [0, 9, 8], [0, 5, 7], [0, 5, 8, 9], [1, 3, 4, 6, 9], [1, 5, 9], [1, 3, 9], [2, 4, 9], [2, 3, 4, 5, 6, 7]],id = 5,level = 3) == []\n", "comparison": "exact"}, "public_tests": ["[[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]]\n[[1,2],[0,3],[0,3],[1,2]]\n0\n1", "[[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]]\n[[1,2],[0,3],[0,3],[1,2]]\n0\n2"], "hints": ["Do BFS to find the kth level friends.", "Then collect movies saw by kth level friends and sort them accordingly."], "metadata": {"canonical_parameter_names": ["watchedVideos", "friends", "id", "level"], "leetcode_dataset_entry_point": "Solution().watchedVideosByFriends", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:23+00:00", "tests_total": 67, "tests_dropped": 35, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "breadth-first-search", "graph", "sorting"]}, "language": "python", "interface": {"raw_signature": "def watchedVideosByFriends(self, watchedVideos: list[list[str]], friends: list[list[int]], id: int, level: int) -> list[str]:", "container": "Solution", "callable": "watchedVideosByFriends", "parameters": [{"name": "watchedVideos", "type": "list[list[str]]"}, {"name": "friends", "type": "list[list[int]]"}, {"name": "id", "type": "int"}, {"name": "level", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1312, "task_id": "minimum-insertion-steps-to-make-a-string-palindrome", "difficulty": "Hard", "problem_description": "Given a string s. In one step you can insert any character at any index of the string.\n\nReturn the minimum number of steps to make s palindrome.\n\nA Palindrome String is one that reads the same backward as well as forward.\n\nExample 1:\n\nInput: s = \"zzazz\"\nOutput: 0\nExplanation: The string \"zzazz\" is already palindrome we do not need any insertions.\n\nExample 2:\n\nInput: s = \"mbadm\"\nOutput: 2\nExplanation: String can be \"mbdadbm\" or \"mdbabdm\".\n\nExample 3:\n\nInput: s = \"leetcode\"\nOutput: 5\nExplanation: Inserting 5 characters the string becomes \"leetcodocteel\".\n\nConstraints:\n\n- 1 <= s.length <= 500\n- s consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"race\") == 3\n assert candidate(s = \"noon\") == 0\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"abcdef\") == 5\n assert candidate(s = \"zzazz\") == 0\n assert candidate(s = \"google\") == 2\n assert candidate(s = \"mbadm\") == 2\n assert candidate(s = \"abcd\") == 3\n assert candidate(s = \"algorithm\") == 8\n assert candidate(s = \"leetcode\") == 5\n assert candidate(s = \"aabb\") == 2\n assert candidate(s = \"abacabadabacabadabacaba\") == 0\n assert candidate(s = \"noonappa\") == 4\n assert candidate(s = \"wasitacaroracatisawwasitacaroracatisaw\") == 0\n assert candidate(s = \"amanaplanacanalpanamanaplanacanalpanama\") == 0\n assert candidate(s = \"aaaabaaaa\") == 0\n assert candidate(s = \"aabaa\") == 0\n assert candidate(s = \"abcde\") == 4\n assert candidate(s = \"abcdabcdabcd\") == 7\n assert candidate(s = \"racecarrace\") == 3\n assert candidate(s = \"rotorlevel\") == 5\n assert candidate(s = \"flzxrpfr\") == 5\n assert candidate(s = \"geeksforgeeks\") == 8\n assert candidate(s = \"abcdefghijklijklkjihgfedcba\") == 2\n assert candidate(s = \"aaaaabbbbb\") == 5\n assert candidate(s = \"flasflasflas\") == 7\n assert candidate(s = \"abcdefghikjlmnopqrstuvwxyzzyxwvutnmlkjihgfedcba\") == 7\n assert candidate(s = \"noonnoonnoonnoon\") == 0\n assert candidate(s = \"mississippimississippi\") == 6\n assert candidate(s = \"jglkhflhfl\") == 5\n assert candidate(s = \"abca\") == 1\n assert candidate(s = \"verylongstringthatneedsmanyinsertionstopalindrome\") == 27\n assert candidate(s = \"bananaananabanana\") == 2\n assert candidate(s = \"abcdxyzzyxwvutrdcba\") == 5\n assert candidate(s = \"abcdxyzzyxdcba\") == 0\n assert candidate(s = \"qzihxknhzvqt\") == 5\n assert candidate(s = \"triplepletriple\") == 10\n assert candidate(s = \"xyxzzxyxyxyxyxyx\") == 3\n assert candidate(s = \"abcdbca\") == 2\n assert candidate(s = \"kayak\") == 0\n assert candidate(s = \"flrif\") == 2\n assert candidate(s = \"abcdefghijjiuhgfedcba\") == 1\n assert candidate(s = \"aabaaabaabaaa\") == 2\n assert candidate(s = \"pqrstuabutsrqp\") == 1\n assert candidate(s = \"xyxz\") == 1\n assert candidate(s = \"abcda\") == 2\n assert candidate(s = \"ababababababab\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abababababa\") == 0\n assert candidate(s = \"deeee\") == 1\n assert candidate(s = \"abcbabc\") == 2\n assert candidate(s = \"abcdefedcbafedcba\") == 4\n assert candidate(s = \"randomstring\") == 9\n assert candidate(s = \"thisisaverylongstringthatneedsmuchinsertionstobecomeapalindrome\") == 42\n assert candidate(s = \"abbaabbaba\") == 2\n assert candidate(s = \"wasitacaroracatisaw\") == 0\n assert candidate(s = \"trinitrotoluene\") == 8\n assert candidate(s = \"xyxxyxyxyxyx\") == 1\n assert candidate(s = \"aibohphobia\") == 0\n assert candidate(s = \"abcdefedcba\") == 0\n assert candidate(s = \"level\") == 0\n assert candidate(s = \"aabbccdd\") == 6\n assert candidate(s = \"stats\") == 0\n assert candidate(s = \"levellevellevel\") == 0\n assert candidate(s = \"fdlhdlf\") == 2\n assert candidate(s = \"abccbaabc\") == 3\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"abacaxabaycabacaxaba\") == 5\n assert candidate(s = \"radar\") == 0\n assert candidate(s = \"xyxzxy\") == 1\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"pwwkew\") == 3\n assert candidate(s = \"redivider\") == 0\n assert candidate(s = \"abcdabcd\") == 5\n assert candidate(s = \"banana\") == 1\n assert candidate(s = \"noonnoonnoonnoonnoon\") == 0\n assert candidate(s = \"anana\") == 0\n assert candidate(s = \"noonabbada\") == 6\n assert candidate(s = \"agbdba\") == 1\n assert candidate(s = \"ananana\") == 0\n assert candidate(s = \"detartrated\") == 0\n assert candidate(s = \"abcdedcbaabcdedcba\") == 0\n assert candidate(s = \"hellohello\") == 5\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"aabbccddeeff\") == 10\n assert candidate(s = \"xyxzxyxyyzz\") == 4\n assert candidate(s = \"madamimadam\") == 0\n assert candidate(s = \"abcdefghikjlmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"bbbbabc\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"cabbbbb\") == 2\n assert candidate(s = \"amanaplanacanalpanama\") == 0\n assert candidate(s = \"aebcbda\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"abcdefg\") == 6\n assert candidate(s = \"zyelkx\") == 5\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 0\n assert candidate(s = \"abbbbac\") == 1\n assert candidate(s = \"abcbbbb\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"noonoonnoon\") == 1\n assert candidate(s = \"repaper\") == 0\n assert candidate(s = \"xyzxyz\") == 3\n assert candidate(s = \"abcdedcba\") == 0\n assert candidate(s = \"mamad\") == 2\n assert candidate(s = \"noonhighnoon\") == 1\n assert candidate(s = \"abacdfgdcaba\") == 1\n assert candidate(s = \"abcabc\") == 3\n assert candidate(s = \"rotor\") == 0\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"racecar\") == 0\n assert candidate(s = \"racecarrracecar\") == 0\n assert candidate(s = \"madamimadamimadam\") == 0\n assert candidate(s = \"aabbccddeeefff\") == 11\n assert candidate(s = \"xyzyxyzyx\") == 0\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"flamingo\") == 7\n assert candidate(s = \"zxcvbnmasdfghjkloiuytrewq\") == 24\n assert candidate(s = \"amcelkpal\") == 6\n assert candidate(s = \"abbababa\") == 1\n assert candidate(s = \"aaabaaaa\") == 1\n assert candidate(s = \"abcdabcda\") == 4\n", "comparison": "exact"}, "public_tests": ["\"zzazz\"", "\"mbadm\"", "\"leetcode\""], "hints": ["Is dynamic programming suitable for this problem ?", "If we know the longest palindromic sub-sequence is x and the length of the string is n then, what is the answer to this problem? It is n - x as we need n - x insertions to make the remaining characters also palindrome."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minInsertions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:26+00:00", "tests_total": 123, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minInsertions(self, s: str) -> int:", "container": "Solution", "callable": "minInsertions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1313, "task_id": "decompress-run-length-encoded-list", "difficulty": "Easy", "problem_description": "We are given a list nums of integers representing a list compressed with run-length encoding.\n\nConsider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0). For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.\n\nReturn the decompressed list.\n\nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [2,4,4,4]\nExplanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].\nThe second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].\nAt the end the concatenation [2] + [4,4,4] is [2,4,4,4].\n\nExample 2:\n\nInput: nums = [1,1,2,3]\nOutput: [1,3,3]\n\nConstraints:\n\n- 2 <= nums.length <= 100\n- nums.length % 2 == 0\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 2, 8, 3, 7]) == [9, 8, 8, 7, 7, 7]\n assert candidate(nums = [3, 1, 2, 2]) == [1, 1, 1, 2, 2]\n assert candidate(nums = [2, 5, 3, 1]) == [5, 5, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4]) == [2, 4, 4, 4]\n assert candidate(nums = [2, 5, 3, 7]) == [5, 5, 7, 7, 7]\n assert candidate(nums = [2, 5, 3, 6]) == [5, 5, 6, 6, 6]\n assert candidate(nums = [10, 1, 5, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(nums = [4, 6, 2, 7]) == [6, 6, 6, 6, 7, 7]\n assert candidate(nums = [5, 10, 3, 20]) == [10, 10, 10, 10, 10, 20, 20, 20]\n assert candidate(nums = [4, 8, 1, 6]) == [8, 8, 8, 8, 6]\n assert candidate(nums = [1, 1, 2, 3]) == [1, 3, 3]\n assert candidate(nums = [1, 9, 3, 8, 2, 4]) == [9, 8, 8, 8, 4, 4]\n assert candidate(nums = [4, 7, 1, 2]) == [7, 7, 7, 7, 2]\n assert candidate(nums = [1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1, 2, 1, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [2, 5, 4, 1]) == [5, 5, 1, 1, 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, 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 candidate(nums = [99, 99, 1, 1]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1]\n assert candidate(nums = [7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 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, 11, 89, 12, 88, 13, 87, 14, 86, 15, 85, 16, 84, 17, 83, 18, 82, 19, 81, 20, 80]) == [99, 98, 98, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96]\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == [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, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]\n assert candidate(nums = [30, 10, 20, 20, 10, 30, 5, 5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5, 5, 5, 5, 5]\n assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == [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, 9, 9, 9, 9]\n assert candidate(nums = [2, 3, 3, 2, 2, 3, 3, 2]) == [3, 3, 2, 2, 2, 3, 3, 2, 2, 2]\n assert candidate(nums = [5, 5, 10, 10, 15, 15]) == [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, 15, 15, 15, 15, 15]\n assert candidate(nums = [10, 5, 6, 3, 2, 8, 9, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6]) == [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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [2, 50, 3, 40, 4, 30, 5, 20, 6, 10]) == [50, 50, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [3, 3, 7, 7, 7, 7, 7, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 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, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]\n assert candidate(nums = [7, 1, 3, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 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 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 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, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 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, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2, 18, 2, 20, 2, 22, 2, 24, 2, 26, 2, 28, 2, 30]) == [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]\n assert candidate(nums = [10, 5, 3, 6, 7, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, 2, 2, 2, 2, 2]\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]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == [2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99, 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]\n assert candidate(nums = [10, 5, 3, 3, 7, 2]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == [1, 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]\n assert candidate(nums = [5, 10, 4, 20, 3, 30, 2, 40, 1, 50]) == [10, 10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 40, 40, 50]\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 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]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 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, 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]\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, 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]\n assert candidate(nums = [8, 1, 7, 2, 6, 3, 5, 4, 4, 5, 3, 6, 2, 7, 1, 8]) == [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8]\n assert candidate(nums = [7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6]) == [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]\n assert candidate(nums = [99, 1, 1, 99]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99]\n assert candidate(nums = [33, 3, 33, 3, 33, 3, 33, 3, 33, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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 = [50, 1, 50, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20]) == [3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 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, 100, 2, 99, 3, 98, 4, 97]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [25, 9, 15, 3, 5, 8]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 8, 8, 8, 8, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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 = [10, 5, 3, 2, 7, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9]\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, 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 = [10, 5, 3, 1, 7, 2, 6, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 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, 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, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [5, 10, 3, 20, 7, 30]) == [10, 10, 10, 10, 10, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30]\n assert candidate(nums = [5, 5, 3, 3, 2, 2, 1, 1]) == [5, 5, 5, 5, 5, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6]) == [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, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]\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, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [2, 1, 3, 2, 2, 3, 4, 4, 10, 5, 20, 6]) == [1, 1, 2, 2, 2, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [10, 5, 6, 3, 2, 9, 1, 8]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 9, 9, 8]\n assert candidate(nums = [33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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 = [25, 1, 25, 2, 25, 3, 25, 4, 25, 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, 2, 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, 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, 5, 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 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5]) == [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]\n assert candidate(nums = [7, 1, 6, 2, 5, 3, 4, 4, 3, 5]) == [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]\n assert candidate(nums = [100, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(nums = [20, 1, 15, 2, 10, 3, 5, 4, 3, 5]) == [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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 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, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == [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, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 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, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [5, 10, 3, 20, 1, 30]) == [10, 10, 10, 10, 10, 20, 20, 20, 30]\n assert candidate(nums = [20, 30, 10, 40, 5, 50, 2, 60]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60]\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [3, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93]\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = [10, 5, 8, 15, 6, 25]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 25, 25, 25, 25, 25, 25]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [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 = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\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, 4, 4, 6, 6, 6, 6, 6, 6, 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, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 4, 4, 4, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 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, 25, 25, 25, 25, 25, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 1, 1]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[1,1,2,3]"], "hints": ["Decompress the given array by repeating nums[2*i+1] a number of times equal to nums[2*i]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().decompressRLElist", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:28+00:00", "tests_total": 86, "tests_dropped": 0, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def decompressRLElist(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "decompressRLElist", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1314, "task_id": "matrix-block-sum", "difficulty": "Medium", "problem_description": "Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:\n\n- i - k <= r <= i + k,\n- j - k <= c <= j + k, and\n- (r, c) is a valid position in the matrix.\n\nExample 1:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1\nOutput: [[12,21,16],[27,45,33],[24,39,28]]\n\nExample 2:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2\nOutput: [[45,45,45],[45,45,45],[45,45,45]]\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n, k <= 100\n- 1 <= mat[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 2) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[1, 2], [3, 4]],k = 1) == [[10, 10], [10, 10]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 1) == [[4, 6, 4], [6, 9, 6], [4, 6, 4]]\n assert candidate(mat = [[5]],k = 1) == [[5]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 1) == [[12, 21, 16], [27, 45, 33], [24, 39, 28]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 5) == [[9, 9, 9], [9, 9, 9], [9, 9, 9]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [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) == [[80, 100, 120, 120, 100, 80], [100, 125, 150, 150, 125, 100], [120, 150, 180, 180, 150, 120], [120, 150, 180, 180, 150, 120], [100, 125, 150, 150, 125, 100], [80, 100, 120, 120, 100, 80]]\n assert candidate(mat = [[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, 19, 18, 17, 16, 15, 14, 13, 12]],k = 2) == [[69, 94, 120, 125, 130, 135, 140, 114, 87], [126, 168, 210, 210, 210, 210, 210, 168, 126], [126, 168, 210, 210, 210, 210, 210, 168, 126], [102, 138, 175, 180, 185, 190, 195, 158, 120]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 1) == [[4, 6, 4], [6, 9, 6], [6, 9, 6], [6, 9, 6], [4, 6, 4]]\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 = 2) == [[63, 90, 120, 102, 81], [114, 160, 210, 176, 138], [180, 250, 325, 270, 210], [174, 240, 310, 256, 198], [153, 210, 270, 222, 171]]\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 3) == [[680, 680, 680, 680], [680, 680, 680, 680], [680, 680, 680, 680], [680, 680, 680, 680]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]],k = 2) == [[60, 92, 130, 116, 96], [102, 152, 210, 184, 150], [102, 152, 210, 184, 150], [93, 136, 185, 160, 129]]\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 3) == [[64, 64, 64, 64], [64, 64, 64, 64], [64, 64, 64, 64], [64, 64, 64, 64]]\n assert candidate(mat = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [[4, 4], [6, 6], [6, 6], [6, 6], [6, 6], [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, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 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) == [[16, 20, 24, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 30, 25, 20], [24, 30, 36, 42, 42, 42, 36, 30, 24], [28, 35, 42, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 42, 35, 28], [24, 30, 36, 42, 42, 42, 36, 30, 24], [20, 25, 30, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 2) == [[9, 12, 12, 9], [12, 16, 16, 12], [15, 20, 20, 15], [12, 16, 16, 12], [9, 12, 12, 9]]\n assert candidate(mat = [[2, 1, 3, 4], [1, 2, 2, 1], [3, 3, 2, 4], [4, 1, 5, 4]],k = 1) == [[6, 11, 13, 10], [12, 19, 22, 16], [14, 23, 24, 18], [11, 18, 19, 15]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 3) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [63, 99, 69], [48, 75, 52]]\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 = 2) == [[63, 90, 120, 102, 81], [114, 160, 210, 176, 138], [180, 250, 325, 270, 210], [174, 240, 310, 256, 198], [153, 210, 270, 222, 171]]\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 = 1) == [[16, 27, 33, 39, 28], [39, 63, 72, 81, 57], [69, 108, 117, 126, 87], [99, 153, 162, 171, 117], [76, 117, 123, 129, 88]]\n assert candidate(mat = [[5, 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 = 1) == [[20, 30, 30, 30, 20], [30, 45, 45, 45, 30], [30, 45, 45, 45, 30], [30, 45, 45, 45, 30], [20, 30, 30, 30, 20]]\n assert candidate(mat = [[1, 3, 1], [1, 5, 1], [4, 2, 4]],k = 2) == [[22, 22, 22], [22, 22, 22], [22, 22, 22]]\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]],k = 1) == [[26, 42, 48, 54, 60, 66, 72, 78, 84, 58], [69, 108, 117, 126, 135, 144, 153, 162, 171, 117], [66, 102, 108, 114, 120, 126, 132, 138, 144, 98]]\n assert candidate(mat = [[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) == [[126, 180, 240, 204, 162], [228, 320, 420, 352, 276], [360, 500, 650, 540, 420], [348, 480, 620, 512, 396], [306, 420, 540, 444, 342]]\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, 75, 74, 73, 72, 71]],k = 2) == [[837, 1110, 1380, 1365, 1086, 810], [1080, 1432, 1780, 1760, 1400, 1044], [1305, 1730, 2150, 2125, 1690, 1260], [1008, 1336, 1660, 1640, 1304, 972], [729, 966, 1200, 1185, 942, 702]]\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 2) == [[27, 42, 42, 36], [42, 64, 64, 54], [42, 64, 64, 54], [36, 54, 54, 45]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [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 = 1) == [[20, 30, 30, 30, 30, 20], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [20, 30, 30, 30, 30, 20]]\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]],k = 2) == [[81, 114, 150, 165, 180, 150, 117], [150, 208, 270, 290, 310, 256, 198], [240, 330, 425, 450, 475, 390, 300], [234, 320, 410, 430, 450, 368, 282], [207, 282, 360, 375, 390, 318, 243]]\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]],k = 3) == [[280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376]]\n assert candidate(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]],k = 2) == [[81, 102, 120, 90, 63], [138, 176, 210, 160, 114], [210, 270, 325, 250, 180], [198, 256, 310, 240, 174], [171, 222, 270, 210, 153]]\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 = 3) == [[160, 210, 210, 210, 176], [160, 210, 210, 210, 176], [160, 210, 210, 210, 176], [160, 210, 210, 210, 176]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 3) == [[16, 16, 16, 16], [16, 16, 16, 16], [16, 16, 16, 16], [16, 16, 16, 16]]\n assert candidate(mat = [[9, 2, 3, 4, 6], [7, 1, 8, 5, 3], [6, 5, 4, 7, 9], [2, 3, 1, 4, 5], [8, 6, 7, 2, 3]],k = 1) == [[19, 30, 23, 29, 18], [30, 45, 39, 49, 34], [24, 37, 38, 46, 33], [30, 42, 39, 42, 30], [19, 27, 23, 22, 14]]\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],k = 2) == [[270, 390, 390, 315], [270, 390, 390, 315], [270, 390, 390, 315]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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) == [[16, 20, 24, 28, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [24, 30, 36, 42, 42, 42, 42, 36, 30, 24], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [24, 30, 36, 42, 42, 42, 42, 36, 30, 24], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[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 = 1) == [[48, 81, 99, 117, 84], [117, 189, 216, 243, 171], [207, 324, 351, 378, 261], [297, 459, 486, 513, 351], [228, 351, 369, 387, 264]]\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 = 2) == [[72, 102, 135, 150, 126, 99], [132, 184, 240, 260, 216, 168], [132, 184, 240, 260, 216, 168], [126, 174, 225, 240, 198, 153]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 28, 24, 20, 16]]\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]],k = 2) == [[9, 12, 15, 12, 9], [12, 16, 20, 16, 12], [15, 20, 25, 20, 15], [12, 16, 20, 16, 12], [9, 12, 15, 12, 9]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]],k = 1) == [[8, 15, 21, 27, 33, 24], [15, 27, 36, 45, 54, 39], [21, 36, 45, 54, 63, 45], [27, 45, 54, 63, 72, 51], [33, 54, 63, 72, 81, 57], [24, 39, 45, 51, 57, 40]]\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]],k = 3) == [[88, 130, 130, 130, 120], [120, 175, 175, 175, 160], [120, 175, 175, 175, 160], [120, 175, 175, 175, 160], [104, 150, 150, 150, 136]]\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]],k = 3) == [[16, 20, 20, 20, 16], [20, 25, 25, 25, 20], [20, 25, 25, 25, 20], [20, 25, 25, 25, 20], [16, 20, 20, 20, 16]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],k = 1) == [[10, 10], [21, 21], [33, 33], [45, 45], [57, 57], [42, 42]]\n assert candidate(mat = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],k = 2) == [[99, 144, 144, 117], [180, 256, 256, 204], [180, 256, 256, 204], [171, 240, 240, 189]]\n assert candidate(mat = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],k = 1) == [[24, 42, 54, 40], [60, 99, 117, 84], [108, 171, 189, 132], [88, 138, 150, 104]]\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 3) == [[136, 136, 136, 136], [136, 136, 136, 136], [136, 136, 136, 136], [136, 136, 136, 136]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [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 = 1) == [[20, 30, 30, 30, 30, 20], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [20, 30, 30, 30, 30, 20]]\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],k = 2) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\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 = 1) == [[16, 27, 33, 39, 28], [39, 63, 72, 81, 57], [69, 108, 117, 126, 87], [56, 87, 93, 99, 68]]\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, 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 = 4) == [[575, 705, 840, 980, 1125, 1170, 1060, 945, 825, 700], [840, 1026, 1218, 1416, 1620, 1674, 1512, 1344, 1170, 990], [1155, 1407, 1666, 1932, 2205, 2268, 2044, 1813, 1575, 1330], [1520, 1848, 2184, 2528, 2880, 2952, 2656, 2352, 2040, 1720], [1935, 2349, 2772, 3204, 3645, 3726, 3348, 2961, 2565, 2160], [2385, 2889, 3402, 3924, 4455, 4536, 4068, 3591, 3105, 2610], [2320, 2808, 3304, 3808, 4320, 4392, 3936, 3472, 3000, 2520], [2205, 2667, 3136, 3612, 4095, 4158, 3724, 3283, 2835, 2380], [2040, 2466, 2898, 3336, 3780, 3834, 3432, 3024, 2610, 2190], [1825, 2205, 2590, 2980, 3375, 3420, 3060, 2695, 2325, 1950]]\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40]],k = 2) == [[126, 180, 240, 204, 162], [228, 320, 420, 352, 276], [228, 320, 420, 352, 276], [216, 300, 390, 324, 252]]\n assert candidate(mat = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]],k = 2) == [[27, 36, 36, 27], [36, 48, 48, 36], [36, 48, 48, 36], [27, 36, 36, 27]]\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]],k = 2) == [[9, 12, 15, 12, 9], [12, 16, 20, 16, 12], [15, 20, 25, 20, 15], [12, 16, 20, 16, 12], [9, 12, 15, 12, 9]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 2) == [[45, 45, 45], [78, 78, 78], [120, 120, 120], [165, 165, 165], [150, 150, 150], [126, 126, 126]]\n assert candidate(mat = [[2, 1, 3], [1, 1, 1], [3, 2, 1]],k = 2) == [[15, 15, 15], [15, 15, 15], [15, 15, 15]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [36, 57, 40]]\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]],k = 1) == [[18, 30, 36, 42, 48, 34], [45, 72, 81, 90, 99, 69], [81, 126, 135, 144, 153, 105], [117, 180, 189, 198, 207, 141], [90, 138, 144, 150, 156, 106]]\n assert candidate(mat = [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 12, 13], [14, 15, 16]],k = 2) == [[54, 54, 54], [90, 90, 90], [135, 135, 135], [126, 126, 126], [108, 108, 108]]\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]],k = 1) == [[4, 6, 6, 6, 4], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [4, 6, 6, 6, 4]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [63, 99, 69], [81, 126, 87], [60, 93, 64]]\n assert candidate(mat = [[2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37]],k = 2) == [[81, 114, 150, 165, 138, 108], [144, 200, 260, 280, 232, 180], [225, 310, 400, 425, 350, 270], [315, 430, 550, 575, 470, 360], [288, 392, 500, 520, 424, 324], [243, 330, 420, 435, 354, 270]]\n assert candidate(mat = [[5, 5, 5, 5, 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 = 2) == [[45, 60, 75, 75, 75, 60, 45], [60, 80, 100, 100, 100, 80, 60], [60, 80, 100, 100, 100, 80, 60], [45, 60, 75, 75, 75, 60, 45]]\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[4,5,6],[7,8,9]]\n1", "[[1,2,3],[4,5,6],[7,8,9]]\n2"], "hints": ["How to calculate the required sum for a cell (i,j) fast ?", "Use the concept of cumulative sum array.", "Create a cumulative sum matrix where dp[i][j] is the sum of all cells in the rectangle from (0,0) to (i,j), use inclusion-exclusion idea."], "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().matrixBlockSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:30+00:00", "tests_total": 88, "tests_dropped": 25, "flags": [], "topic_tags": ["array", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def matrixBlockSum(self, mat: list[list[int]], k: int) -> list[list[int]]:", "container": "Solution", "callable": "matrixBlockSum", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1316, "task_id": "distinct-echo-substrings", "difficulty": "Hard", "problem_description": "Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).\n\nExample 1:\n\nInput: text = \"abcabcabc\"\nOutput: 3\nExplanation: The 3 substrings are \"abcabc\", \"bcabca\" and \"cabcab\".\n\nExample 2:\n\nInput: text = \"leetcodeleetcode\"\nOutput: 2\nExplanation: The 2 substrings are \"ee\" and \"leetcodeleetcode\".\n\nConstraints:\n\n- 1 <= text.length <= 2000\n- text has only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"ababab\") == 2\n assert candidate(text = \"abcabcabc\") == 3\n assert candidate(text = \"aaaa\") == 2\n assert candidate(text = \"ab\") == 0\n assert candidate(text = \"abbbabbb\") == 2\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(text = \"abcd\") == 0\n assert candidate(text = \"abacaba\") == 0\n assert candidate(text = \"abc\") == 0\n assert candidate(text = \"leetcodeleetcode\") == 2\n assert candidate(text = \"banana\") == 2\n assert candidate(text = \"xyzxyzxyzxyz\") == 4\n assert candidate(text = \"abcdefg\") == 0\n assert candidate(text = \"racecar racecar\") == 0\n assert candidate(text = \"a\") == 0\n assert candidate(text = \"abababab\") == 3\n assert candidate(text = \"aabbccddeeff\") == 6\n assert candidate(text = \"mississippi\") == 4\n assert candidate(text = \"ababababab\") == 4\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxyxy\") == 11\n assert candidate(text = \"abacaxiabacaxiabacaxi\") == 7\n assert candidate(text = \"abcabcabcabcabcabcabc\") == 9\n assert candidate(text = \"abcdeabcdeabcdeabcde\") == 6\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 33\n assert candidate(text = \"repeatedrepeatedrepeatedrepeated\") == 9\n assert candidate(text = \"tattattattattattat\") == 8\n assert candidate(text = \"aaaaabaaaabaaaa\") == 7\n assert candidate(text = \"racecaracecaracecar\") == 6\n assert candidate(text = \"abcababcababcab\") == 6\n assert candidate(text = \"aabbccddeeffaabbccddeeff\") == 7\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxy\") == 10\n assert candidate(text = \"abacabaabacaba\") == 3\n assert candidate(text = \"leetcodeleetcodeleetcodeleetcode\") == 10\n assert candidate(text = \"thisisaverylongstringthatrepeatstitselfthisisaverylongstringthatrepeatstitself\") == 2\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 26\n assert candidate(text = \"aaaabaaaab\") == 3\n assert candidate(text = \"abcabcabcabcabcabc\") == 7\n assert candidate(text = \"aaaaaaa\") == 3\n assert candidate(text = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(text = \"abababababab\") == 5\n assert candidate(text = \"aaaaabcabcabcabcabc\") == 8\n assert candidate(text = \"qwertyqwertyqwerty\") == 6\n assert candidate(text = \"aabbccddeeffaabbccddeeffaabbccddeeff\") == 18\n assert candidate(text = \"xyzxyzxyzxyzxyzxyz\") == 7\n assert candidate(text = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 27\n assert candidate(text = \"abababababababababababababababababababababababababababababababababab\") == 33\n assert candidate(text = \"leetcodeisgoodandleetcodeisgood\") == 2\n assert candidate(text = \"supercalifragilisticexpialidocioussupercalifragilisticexpialidocious\") == 2\n assert candidate(text = \"abacabacabacabac\") == 5\n assert candidate(text = \"patternpatternpatternpattern\") == 9\n assert candidate(text = \"mississippimississippi\") == 5\n assert candidate(text = \"abcdabcdabcdabcd\") == 5\n assert candidate(text = \"zxcvbnmlkjhgfdsazxcvbnmlkjhgfdsa\") == 1\n assert candidate(text = \"abcdefgabcdefgabcdefg\") == 7\n assert candidate(text = \"abracadabraabracadabra\") == 3\n assert candidate(text = \"hellohellohellohellohello\") == 11\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzz\") == 10\n assert candidate(text = \"zzzzzzzzzzzzzzzz\") == 8\n assert candidate(text = \"abababa\") == 2\n assert candidate(text = \"ababababababab\") == 6\n assert candidate(text = \"aaaaaaaaaa\") == 5\n assert candidate(text = \"abcdabcdeabcd\") == 1\n assert candidate(text = \"racecar\") == 0\n assert candidate(text = \"abcdefghabcdefgh\") == 1\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 32\n assert candidate(text = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 10\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(text = \"abcabcabcabc\") == 4\n assert candidate(text = \"abcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(text = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 0\n assert candidate(text = \"aaaaa\") == 2\n assert candidate(text = \"abracadabrabracadabra\") == 4\n assert candidate(text = \"aaaaaa\") == 3\n assert candidate(text = \"abacabadabacabadabacaba\") == 8\n assert candidate(text = \"aaaaabbbbbaaaaabbbbb\") == 5\n assert candidate(text = \"noonnoonnoonnoon\") == 7\n assert candidate(text = \"abacabadabacaba\") == 0\n assert candidate(text = \"xyxyxyxyxyxyxyxy\") == 7\n assert candidate(text = \"abracadabraabracadabraabracadabraabracadabraabracadabraabracadabra\") == 25\n assert candidate(text = \"abcabcabcabcabc\") == 6\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 43\n assert candidate(text = \"abababababababab\") == 7\n assert candidate(text = \"aaaaaaaaaabaaaaaaaaaa\") == 5\n assert candidate(text = \"aaaabbbbcccc\") == 6\n assert candidate(text = \"noonnoonnoonnoonnoon\") == 10\n assert candidate(text = \"abcxyzabcxyzabcxyz\") == 6\n assert candidate(text = \"abcabca\") == 2\n assert candidate(text = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 52\n assert candidate(text = \"uniqueuniqueuniqueunique\") == 7\n assert candidate(text = \"racecaracecar\") == 2\n assert candidate(text = \"abcdefabcdefabcdef\") == 6\n assert candidate(text = \"bananabananaananabanana\") == 7\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 32\n assert candidate(text = \"bananaabanana\") == 3\n assert candidate(text = \"aaaabbbbccccddddeeeeffff\") == 12\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 27\n assert candidate(text = \"hellohellohellohellohellohellohellohellohellohello\") == 22\n", "comparison": "exact"}, "public_tests": ["\"abcabcabc\"", "\"leetcodeleetcode\""], "hints": ["Given a substring of the text, how to check if it can be written as the concatenation of a string with itself ?", "We can do that in linear time, a faster way is to use hashing.", "Try all substrings and use hashing to check them."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().distinctEchoSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:35+00:00", "tests_total": 98, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "trie", "rolling-hash", "suffix-array", "hash-function", "suffix-automaton", "suffix-tree"]}, "language": "python", "interface": {"raw_signature": "def distinctEchoSubstrings(self, text: str) -> int:", "container": "Solution", "callable": "distinctEchoSubstrings", "parameters": [{"name": "text", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1317, "task_id": "convert-integer-to-the-sum-of-two-no-zero-integers", "difficulty": "Easy", "problem_description": "No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.\n\nGiven an integer n, return a list of two integers [a, b] where:\n\n- a and b are No-Zero integers.\n- a + b = n\n\nThe test cases are generated so that there is at least one valid solution. If there are many valid solutions, you can return any of them.\n\nExample 1:\n\nInput: n = 2\nOutput: [1,1]\nExplanation: Let a = 1 and b = 1.\nBoth a and b are no-zero integers, and a + b = 2 = n.\n\nExample 2:\n\nInput: n = 11\nOutput: [2,9]\nExplanation: Let a = 2 and b = 9.\nBoth a and b are no-zero integers, and a + b = 11 = n.\nNote that there are other valid answers as [8, 3] that can be accepted.\n\nConstraints:\n\n- 2 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == [2, 99]\n assert candidate(n = 1010) == [11, 999]\n assert candidate(n = 11) == [2, 9]\n assert candidate(n = 104) == [5, 99]\n assert candidate(n = 1001) == [2, 999]\n assert candidate(n = 2) == [1, 1]\n assert candidate(n = 9999) == [1, 9998]\n assert candidate(n = 100) == [1, 99]\n assert candidate(n = 210) == [11, 199]\n assert candidate(n = 9801) == [2, 9799]\n assert candidate(n = 2345) == [1, 2344]\n assert candidate(n = 2100) == [111, 1989]\n assert candidate(n = 1111) == [112, 999]\n assert candidate(n = 8888) == [1, 8887]\n assert candidate(n = 1000) == [1, 999]\n assert candidate(n = 43) == [1, 42]\n assert candidate(n = 1357) == [1, 1356]\n assert candidate(n = 6789) == [1, 6788]\n assert candidate(n = 6005) == [6, 5999]\n assert candidate(n = 8181) == [2, 8179]\n assert candidate(n = 2468) == [1, 2467]\n assert candidate(n = 2048) == [49, 1999]\n assert candidate(n = 999) == [1, 998]\n assert candidate(n = 3030) == [31, 2999]\n assert candidate(n = 9012) == [13, 8999]\n assert candidate(n = 9090) == [91, 8999]\n assert candidate(n = 65) == [1, 64]\n assert candidate(n = 21) == [2, 19]\n assert candidate(n = 432) == [1, 431]\n assert candidate(n = 543) == [1, 542]\n assert candidate(n = 87) == [1, 86]\n assert candidate(n = 98) == [1, 97]\n assert candidate(n = 2023) == [24, 1999]\n assert candidate(n = 9998) == [1, 9997]\n assert candidate(n = 7007) == [8, 6999]\n assert candidate(n = 7070) == [71, 6999]\n assert candidate(n = 6543) == [1, 6542]\n assert candidate(n = 7777) == [1, 7776]\n assert candidate(n = 8080) == [81, 7999]\n assert candidate(n = 4999) == [1, 4998]\n assert candidate(n = 9876) == [1, 9875]\n assert candidate(n = 987) == [1, 986]\n assert candidate(n = 8901) == [2, 8899]\n assert candidate(n = 5678) == [1, 5677]\n assert candidate(n = 4004) == [5, 3999]\n assert candidate(n = 2000) == [1, 1999]\n assert candidate(n = 4567) == [1, 4566]\n assert candidate(n = 6006) == [7, 5999]\n assert candidate(n = 8008) == [9, 7999]\n assert candidate(n = 6666) == [1, 6665]\n assert candidate(n = 76) == [1, 75]\n assert candidate(n = 4680) == [1, 4679]\n assert candidate(n = 765) == [1, 764]\n assert candidate(n = 2020) == [21, 1999]\n assert candidate(n = 3050) == [51, 2999]\n assert candidate(n = 32) == [1, 31]\n assert candidate(n = 1023) == [24, 999]\n assert candidate(n = 7890) == [1, 7889]\n assert candidate(n = 7654) == [1, 7653]\n assert candidate(n = 876) == [1, 875]\n assert candidate(n = 7006) == [7, 6999]\n assert candidate(n = 5050) == [51, 4999]\n assert candidate(n = 5002) == [3, 4999]\n assert candidate(n = 9997) == [1, 9996]\n assert candidate(n = 3003) == [4, 2999]\n assert candidate(n = 8765) == [1, 8764]\n assert candidate(n = 321) == [2, 319]\n assert candidate(n = 3333) == [1, 3332]\n assert candidate(n = 3456) == [1, 3455]\n assert candidate(n = 1098) == [99, 999]\n assert candidate(n = 10000) == [1, 9999]\n assert candidate(n = 5432) == [1, 5431]\n assert candidate(n = 2109) == [111, 1998]\n assert candidate(n = 54) == [1, 53]\n assert candidate(n = 654) == [1, 653]\n assert candidate(n = 8642) == [1, 8641]\n assert candidate(n = 5555) == [1, 5554]\n assert candidate(n = 3210) == [11, 3199]\n assert candidate(n = 9009) == [11, 8998]\n assert candidate(n = 6060) == [61, 5999]\n assert candidate(n = 5005) == [6, 4999]\n assert candidate(n = 4444) == [1, 4443]\n assert candidate(n = 4321) == [2, 4319]\n assert candidate(n = 2222) == [1, 2221]\n assert candidate(n = 6234) == [1, 6233]\n assert candidate(n = 109) == [11, 98]\n assert candidate(n = 4040) == [41, 3999]\n assert candidate(n = 1234) == [1, 1233]\n assert candidate(n = 7272) == [1, 7271]\n", "comparison": "exact"}, "public_tests": ["19", "139"], "hints": ["Loop through all elements from 1 to n.", "Choose A = i and B = n - i then check if A and B are both No-Zero integers."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().getNoZeroIntegers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:37+00:00", "tests_total": 115, "tests_dropped": 26, "flags": ["multiple_answers"], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def getNoZeroIntegers(self, n: int) -> list[int]:", "container": "Solution", "callable": "getNoZeroIntegers", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1318, "task_id": "minimum-flips-to-make-a-or-b-equal-to-c", "difficulty": "Medium", "problem_description": "Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).\nFlip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.\n\nExample 1:\n\nInput: a = 2, b = 6, c = 5\nOutput: 3\nExplanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)\n\nExample 2:\n\nInput: a = 4, b = 2, c = 7\nOutput: 1\n\nExample 3:\n\nInput: a = 1, b = 2, c = 3\nOutput: 0\n\nConstraints:\n\n- 1 <= a <= 10^9\n- 1 <= b <= 10^9\n- 1 <= c <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 10,b = 15,c = 25) == 4\n assert candidate(a = 2,b = 6,c = 5) == 3\n assert candidate(a = 1,b = 2,c = 3) == 0\n assert candidate(a = 8,b = 3,c = 11) == 0\n assert candidate(a = 4,b = 2,c = 7) == 1\n assert candidate(a = 1000000000,b = 1000000000,c = 1) == 27\n assert candidate(a = 123,b = 456,c = 789) == 9\n assert candidate(a = 8388607,b = 16777215,c = 16777215) == 0\n assert candidate(a = 65535,b = 65535,c = 65535) == 0\n assert candidate(a = 987654321,b = 123456789,c = 864197532) == 20\n assert candidate(a = 123456789,b = 987654321,c = 135792468) == 25\n assert candidate(a = 1048575,b = 2097151,c = 3145727) == 2\n assert candidate(a = 255,b = 128,c = 254) == 1\n assert candidate(a = 16777215,b = 33554431,c = 67108863) == 1\n assert candidate(a = 1023,b = 511,c = 1535) == 2\n assert candidate(a = 1023,b = 2047,c = 3071) == 2\n assert candidate(a = 255,b = 128,c = 383) == 3\n assert candidate(a = 987654,b = 321456,c = 654321) == 9\n assert candidate(a = 987654321,b = 348712387,c = 1) == 30\n assert candidate(a = 777,b = 888,c = 999) == 6\n assert candidate(a = 123456789,b = 987654321,c = 999999999) == 10\n assert candidate(a = 134217728,b = 67108864,c = 201326592) == 0\n assert candidate(a = 15,b = 30,c = 45) == 4\n assert candidate(a = 1023,b = 512,c = 1024) == 12\n assert candidate(a = 123456789,b = 987654321,c = 1000000000) == 16\n assert candidate(a = 123456789,b = 987654321,c = 987654321) == 7\n assert candidate(a = 134217727,b = 67108863,c = 201326592) == 53\n assert candidate(a = 32,b = 16,c = 48) == 0\n assert candidate(a = 14,b = 28,c = 42) == 4\n assert candidate(a = 8,b = 3,c = 15) == 1\n assert candidate(a = 999,b = 888,c = 777) == 8\n assert candidate(a = 1000000,b = 999999,c = 1000001) == 5\n assert candidate(a = 8,b = 16,c = 24) == 0\n assert candidate(a = 1048575,b = 524287,c = 1572863) == 2\n assert candidate(a = 1000000000,b = 999999999,c = 1000000000) == 9\n assert candidate(a = 1023,b = 512,c = 768) == 8\n assert candidate(a = 134217727,b = 268435455,c = 335544319) == 4\n assert candidate(a = 897,b = 564,c = 231) == 6\n assert candidate(a = 511,b = 255,c = 127) == 3\n assert candidate(a = 134217727,b = 268435455,c = 536870911) == 1\n assert candidate(a = 1023,b = 511,c = 255) == 3\n assert candidate(a = 536870911,b = 268435455,c = 805306367) == 2\n assert candidate(a = 255,b = 511,c = 1023) == 1\n assert candidate(a = 255,b = 128,c = 191) == 1\n assert candidate(a = 1000000000,b = 1000000000,c = 500000000) == 21\n assert candidate(a = 65535,b = 131071,c = 262143) == 1\n assert candidate(a = 500,b = 600,c = 700) == 3\n assert candidate(a = 65535,b = 32768,c = 98304) == 16\n assert candidate(a = 255,b = 128,c = 64) == 8\n assert candidate(a = 16777215,b = 255,c = 16777470) == 19\n assert candidate(a = 100000000,b = 200000000,c = 300000000) == 10\n assert candidate(a = 5349,b = 7281,c = 12630) == 11\n assert candidate(a = 123456789,b = 987654321,c = 101110101) == 20\n assert candidate(a = 29,b = 15,c = 31) == 0\n assert candidate(a = 7,b = 14,c = 21) == 4\n assert candidate(a = 3,b = 12,c = 15) == 0\n assert candidate(a = 1048576,b = 2097152,c = 3145727) == 21\n assert candidate(a = 25,b = 50,c = 75) == 4\n assert candidate(a = 500000000,b = 500000000,c = 1000000000) == 21\n assert candidate(a = 31,b = 15,c = 7) == 3\n assert candidate(a = 1048575,b = 1048576,c = 2097151) == 0\n assert candidate(a = 536870911,b = 268435455,c = 703687440) == 32\n assert candidate(a = 348712387,b = 987654321,c = 1000000000) == 18\n assert candidate(a = 170,b = 85,c = 255) == 0\n assert candidate(a = 987654,b = 321456,c = 1309110) == 8\n assert candidate(a = 1023,b = 512,c = 1535) == 3\n assert candidate(a = 999999,b = 888888,c = 777777) == 8\n assert candidate(a = 1048575,b = 524287,c = 262143) == 3\n assert candidate(a = 65535,b = 65535,c = 131071) == 1\n assert candidate(a = 89,b = 67,c = 45) == 6\n assert candidate(a = 1,b = 1023,c = 1023) == 0\n assert candidate(a = 65535,b = 32767,c = 98303) == 2\n assert candidate(a = 1,b = 1000000000,c = 1000000000) == 1\n assert candidate(a = 8,b = 3,c = 10) == 1\n assert candidate(a = 789,b = 456,c = 1245) == 4\n", "comparison": "exact"}, "public_tests": ["2\n6\n5", "4\n2\n7", "1\n2\n3"], "hints": ["Check the bits one by one whether they need to be flipped."], "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:39+00:00", "tests_total": 92, "tests_dropped": 17, "flags": ["has_images"], "topic_tags": ["bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def minFlips(self, a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1319, "task_id": "number-of-operations-to-make-network-connected", "difficulty": "Medium", "problem_description": "There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [a_i, b_i] represents a connection between computers a_i and b_i. Any computer can reach any other computer directly or indirectly through the network.\n\nYou are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.\n\nReturn the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.\n\nExample 1:\n\nInput: n = 4, connections = [[0,1],[0,2],[1,2]]\nOutput: 1\nExplanation: Remove cable between computer 1 and 2 and place between computers 1 and 3.\n\nExample 2:\n\nInput: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]\nOutput: 2\n\nExample 3:\n\nInput: n = 6, connections = [[0,1],[0,2],[0,3],[1,2]]\nOutput: -1\nExplanation: There are not enough cables.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- 1 <= connections.length <= min(n * (n - 1) / 2, 10^5)\n- connections[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- There are no repeated connections.\n- No two computers are connected by more than one cable.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [3, 4]]) == -1\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, 3], [1, 2]]) == -1\n assert candidate(n = 5,connections = [[0, 1], [2, 3]]) == -1\n assert candidate(n = 3,connections = [[0, 1], [1, 2]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]) == 3\n assert candidate(n = 5,connections = [[0, 1], [0, 2], [3, 4]]) == -1\n assert candidate(n = 2,connections = [[0, 1]]) == 0\n assert candidate(n = 4,connections = [[0, 1], [0, 2], [1, 2]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == -1\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3]]) == 2\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14]]) == -1\n assert candidate(n = 20,connections = [[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 = 12,connections = [[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,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6], [0, 6], [1, 7], [2, 8], [3, 9], [4, 0]]) == 0\n assert candidate(n = 15,connections = [[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]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]]) == 0\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [13, 0], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(n = 10,connections = [[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 = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]]) == 1\n assert candidate(n = 20,connections = [[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]]) == 4\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 10]]) == 2\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11]]) == 3\n assert candidate(n = 13,connections = [[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\n assert candidate(n = 100,connections = [[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]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14]]) == 4\n assert candidate(n = 12,connections = [[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, 5], [5, 10], [10, 3], [3, 8], [8, 1]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 1\n assert candidate(n = 30,connections = [[0, 1], [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, 25], [24, 26], [25, 27], [26, 28], [27, 29], [0, 29]]) == 0\n assert candidate(n = 30,connections = [[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 = 12,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == -1\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [3, 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 = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == -1\n assert candidate(n = 20,connections = [[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(n = 10,connections = [[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]]) == 2\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 3], [2, 5], [4, 7], [6, 8]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(n = 15,connections = [[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]]) == 0\n assert candidate(n = 11,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [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]]) == 0\n assert candidate(n = 25,connections = [[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], [6, 22], [7, 23], [8, 24]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [6, 7]]) == -1\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 2], [1, 3]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 16,connections = [[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, 7], [7, 14], [14, 6], [6, 13], [13, 5], [5, 12], [12, 4], [4, 11], [11, 3], [3, 10], [10, 2], [2, 9], [9, 1], [1, 8]]) == 0\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [2, 5]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]) == 1\n assert candidate(n = 10,connections = [[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]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,connections = [[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\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [3, 4], [4, 5]]) == -1\n assert candidate(n = 10,connections = [[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 = 15,connections = [[0, 1], [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, 14]]) == 0\n assert candidate(n = 30,connections = [[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]]) == -1\n assert candidate(n = 20,connections = [[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\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [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]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [5, 1]]) == 0\n assert candidate(n = 20,connections = [[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, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 16,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == -1\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [0, 8], [1, 7], [2, 5], [3, 6]]) == 0\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8]]) == -1\n assert candidate(n = 15,connections = [[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 = 15,connections = [[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 = 25,connections = [[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,connections = [[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, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [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], [0, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15], [14, 17], [16, 19]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 0\n", "comparison": "exact"}, "public_tests": ["4\n[[0,1],[0,2],[1,2]]", "6\n[[0,1],[0,2],[0,3],[1,2],[1,3]]", "6\n[[0,1],[0,2],[0,3],[1,2]]"], "hints": ["As long as there are at least (n - 1) connections, there is definitely a way to connect all computers.", "Use DFS to determine the number of isolated computer clusters."], "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().makeConnected", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:41+00:00", "tests_total": 89, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def makeConnected(self, n: int, connections: list[list[int]]) -> int:", "container": "Solution", "callable": "makeConnected", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1320, "task_id": "minimum-distance-to-type-a-word-using-two-fingers", "difficulty": "Hard", "problem_description": "You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.\n\n- For example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at coordinate (4, 1).\n\nGiven the string word, return the minimum total distance to type such string using only two fingers.\n\nThe distance between coordinates (x_1, y_1) and (x_2, y_2) is |x_1 - x_2| + |y_1 - y_2|.\n\nNote that the initial positions of your two fingers are considered free so do not count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.\n\nExample 1:\n\nInput: word = \"CAKE\"\nOutput: 3\nExplanation: Using two fingers, one optimal way to type \"CAKE\" is:\nFinger 1 on letter 'C' -> cost = 0\nFinger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2\nFinger 2 on letter 'K' -> cost = 0\nFinger 2 on letter 'E' -> cost = Distance from letter 'K' to letter 'E' = 1\nTotal distance = 3\n\nExample 2:\n\nInput: word = \"HAPPY\"\nOutput: 6\nExplanation: Using two fingers, one optimal way to type \"HAPPY\" is:\nFinger 1 on letter 'H' -> cost = 0\nFinger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2\nFinger 2 on letter 'P' -> cost = 0\nFinger 2 on letter 'P' -> cost = Distance from letter 'P' to letter 'P' = 0\nFinger 1 on letter 'Y' -> cost = Distance from letter 'A' to letter 'Y' = 4\nTotal distance = 6\n\nConstraints:\n\n- 2 <= word.length <= 300\n- word consists of uppercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"QWERTYUIOPASDFGHJKLZXCVBNM\") == 52\n assert candidate(word = \"ZZZZZ\") == 0\n assert candidate(word = \"CAKE\") == 3\n assert candidate(word = \"RHYTHM\") == 9\n assert candidate(word = \"FINGER\") == 8\n assert candidate(word = \"ALPHABET\") == 12\n assert candidate(word = \"ABCD\") == 2\n assert candidate(word = \"QWERTYUIOPASDFGHJKLMZXCVBNM\") == 54\n assert candidate(word = \"NEW\") == 3\n assert candidate(word = \"HAPPY\") == 6\n assert candidate(word = \"ABCMN\") == 3\n assert candidate(word = \"LONGEST\") == 8\n assert candidate(word = \"MISSISSIPPI\") == 5\n assert candidate(word = \"YEAR\") == 7\n assert candidate(word = \"ZXY\") == 1\n assert candidate(word = \"OPTIMIZATION\") == 17\n assert candidate(word = \"YYYYYY\") == 0\n assert candidate(word = \"ACB\") == 1\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 36\n assert candidate(word = \"MOUSE\") == 5\n assert candidate(word = \"ZZZZ\") == 0\n assert candidate(word = \"AA\") == 0\n assert candidate(word = \"TRANSFER\") == 15\n assert candidate(word = \"ABCDEFGHIJKLMNOP\") == 18\n assert candidate(word = \"PYTHON\") == 6\n assert candidate(word = \"QRSTUVWXYZ\") == 12\n assert candidate(word = \"KEYBOARD\") == 15\n assert candidate(word = \"ABAB\") == 0\n assert candidate(word = \"ABCDEFG\") == 5\n assert candidate(word = \"DISTANCE\") == 11\n assert candidate(word = \"ALGORITHMS\") == 14\n assert candidate(word = \"CAPABILITY\") == 13\n assert candidate(word = \"HASHMAP\") == 9\n assert candidate(word = \"LONGWORDLONGWORDLONGWORDLONGWORDLONGWORDLONGWORDLONGWORD\") == 122\n assert candidate(word = \"SPECIAL\") == 12\n assert candidate(word = \"DEPLOYMENT\") == 14\n assert candidate(word = \"VOLCANOES\") == 15\n assert candidate(word = \"VICTORY\") == 10\n assert candidate(word = \"BACKSPACENOTPOSSIBLE\") == 35\n assert candidate(word = \"PROSPERING\") == 18\n assert candidate(word = \"METHOD\") == 7\n assert candidate(word = \"ROBUST\") == 7\n assert candidate(word = \"PLANNING\") == 11\n assert candidate(word = \"JOY\") == 2\n assert candidate(word = \"DEPTHFIRSTSEARCH\") == 29\n assert candidate(word = \"CONCEPT\") == 7\n assert candidate(word = \"INTEGRATION\") == 19\n assert candidate(word = \"PLENTY\") == 7\n assert candidate(word = \"COORDINATION\") == 18\n assert candidate(word = \"ACCOMPLISHED\") == 18\n assert candidate(word = \"RUBY\") == 7\n assert candidate(word = \"SERVER\") == 10\n assert candidate(word = \"PYTHONIC\") == 8\n assert candidate(word = \"PRODUCT\") == 8\n assert candidate(word = \"JUST\") == 3\n assert candidate(word = \"RESEARCH\") == 13\n assert candidate(word = \"PYTHONCODING\") == 15\n assert candidate(word = \"INITIATION\") == 9\n assert candidate(word = \"OBJECTORIENTED\") == 22\n assert candidate(word = \"REQUIREMENT\") == 15\n assert candidate(word = \"BANANA\") == 1\n assert candidate(word = \"FINANCE\") == 10\n assert candidate(word = \"HELLOFROMTHEOTHERSIDE\") == 35\n assert candidate(word = \"DEDICATED\") == 10\n assert candidate(word = \"SUPERLONGWORD\") == 23\n assert candidate(word = \"ACCOMPLISHMENT\") == 20\n assert candidate(word = \"PROGRAMMER\") == 13\n assert candidate(word = \"SPECIALCHARACTERS\") == 32\n assert candidate(word = \"NETWORK\") == 10\n assert candidate(word = \"AWESOME\") == 11\n assert candidate(word = \"PROGRESS\") == 9\n assert candidate(word = \"WIN\") == 2\n assert candidate(word = \"OBJECTIVE\") == 15\n assert candidate(word = \"FLOURISH\") == 10\n assert candidate(word = \"PROSPEROUS\") == 16\n assert candidate(word = \"EXPERIMENT\") == 14\n assert candidate(word = \"FINGERBOARD\") == 20\n assert candidate(word = \"PATIENCE\") == 13\n assert candidate(word = \"ADJUSTMENT\") == 13\n assert candidate(word = \"EXCEL\") == 6\n assert candidate(word = \"SUPERCALIFRAGILISTICEXPIALIDOCIOUS\") == 59\n assert candidate(word = \"FRANK\") == 7\n assert candidate(word = \"SOFTWARE\") == 18\n assert candidate(word = \"TWOPOINTERS\") == 15\n assert candidate(word = \"ANALYSIS\") == 13\n assert candidate(word = \"RESOLUTION\") == 15\n assert candidate(word = \"LONGWORDFORTESTING\") == 32\n assert candidate(word = \"INTERACTION\") == 18\n assert candidate(word = \"UNOBTRUDES\") == 17\n assert candidate(word = \"FINGERMOVEMENT\") == 20\n assert candidate(word = \"PEACE\") == 5\n assert candidate(word = \"DEPONIBLE\") == 11\n assert candidate(word = \"ASTARSEARCH\") == 22\n assert candidate(word = \"ANGULAR\") == 10\n assert candidate(word = \"SERVICE\") == 12\n assert candidate(word = \"PROSPERITY\") == 19\n assert candidate(word = \"RECOGNITION\") == 13\n assert candidate(word = \"KINDNESS\") == 7\n assert candidate(word = \"PYTHONPYTHONPYTHON\") == 26\n assert candidate(word = \"PARTNER\") == 12\n assert candidate(word = \"IDEAL\") == 5\n assert candidate(word = \"PRODUCTIVE\") == 14\n assert candidate(word = \"HARMONY\") == 10\n assert candidate(word = \"MYSQL\") == 5\n assert candidate(word = \"PYTHONISFUN\") == 17\n assert candidate(word = \"UNIVERSAL\") == 16\n assert candidate(word = \"KEYBOARDLAYOUT\") == 29\n assert candidate(word = \"SAFE\") == 4\n assert candidate(word = \"TYPESCRIPT\") == 20\n assert candidate(word = \"TREE\") == 3\n assert candidate(word = \"FINGERFINGER\") == 20\n assert candidate(word = \"AAAAA\") == 0\n assert candidate(word = \"GENTLE\") == 7\n assert candidate(word = \"ETHICAL\") == 8\n assert candidate(word = \"BACKTRACKING\") == 21\n assert candidate(word = \"AFFLUENT\") == 11\n assert candidate(word = \"TIMECOMPLEXITY\") == 27\n assert candidate(word = \"HUMBLE\") == 11\n assert candidate(word = \"API\") == 2\n assert candidate(word = \"OVERCOME\") == 14\n assert candidate(word = \"DOBRE\") == 8\n assert candidate(word = \"PRACTICE\") == 13\n assert candidate(word = \"PLAIN\") == 8\n assert candidate(word = \"ACHIEVEMENT\") == 14\n assert candidate(word = \"COMPUTERSCIENCE\") == 28\n assert candidate(word = \"SUCCESSFUL\") == 9\n assert candidate(word = \"GOAL\") == 5\n assert candidate(word = \"CHANGE\") == 9\n assert candidate(word = \"FULFILLMENT\") == 12\n assert candidate(word = \"PRINCIPLE\") == 13\n assert candidate(word = \"CODER\") == 5\n assert candidate(word = \"ALLOCATION\") == 13\n assert candidate(word = \"DIJKSTRAS\") == 14\n assert candidate(word = \"INTERPRETATION\") == 22\n assert candidate(word = \"INTEGRITY\") == 16\n assert candidate(word = \"HACK\") == 4\n assert candidate(word = \"QWJRTYUPASDFGZXCVB\") == 43\n assert candidate(word = \"SUPERLATIVE\") == 23\n assert candidate(word = \"PERSISTENT\") == 16\n assert candidate(word = \"MULTIPLEFINGERS\") == 24\n assert candidate(word = \"OPERATION\") == 16\n assert candidate(word = \"DELIVERY\") == 14\n assert candidate(word = \"DETERMINATION\") == 20\n assert candidate(word = \"DATASTRUCTURE\") == 24\n assert candidate(word = \"CALCULATION\") == 19\n assert candidate(word = \"OPULANCE\") == 15\n assert candidate(word = \"TOP\") == 1\n assert candidate(word = \"SIMULATION\") == 19\n assert candidate(word = \"ATTENTIVE\") == 12\n assert candidate(word = \"PROFILING\") == 9\n assert candidate(word = \"EFFICIENT\") == 7\n assert candidate(word = \"MEMORYMANAGEMENT\") == 26\n assert candidate(word = \"STRATEGY\") == 18\n assert candidate(word = \"THRIVE\") == 9\n assert candidate(word = \"ENERGETIC\") == 15\n assert candidate(word = \"THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG\") == 73\n assert candidate(word = \"CUSTOMIZATION\") == 20\n assert candidate(word = \"OPTIMIZE\") == 11\n assert candidate(word = \"ELITE\") == 6\n assert candidate(word = \"PROGRAMMINGISFUN\") == 24\n assert candidate(word = \"COMMITTED\") == 9\n assert candidate(word = \"EFFECTIVE\") == 10\n assert candidate(word = \"REPORT\") == 6\n assert candidate(word = \"SPACESAVING\") == 22\n assert candidate(word = \"INTERFACE\") == 15\n assert candidate(word = \"NEURALNETWORKS\") == 29\n assert candidate(word = \"CORRECT\") == 9\n assert candidate(word = \"KNIGHTMARCH\") == 17\n assert candidate(word = \"SIMPLE\") == 8\n assert candidate(word = \"TECHNOLOGY\") == 16\n assert candidate(word = \"QUEUE\") == 2\n assert candidate(word = \"ABACAXABABACAB\") == 15\n assert candidate(word = \"PROGRAMMING\") == 14\n assert candidate(word = \"SEARCH\") == 10\n assert candidate(word = \"MULTIPLEWORDSHEREANDTHERE\") == 49\n assert candidate(word = \"LOAD\") == 7\n assert candidate(word = \"CONFIDENT\") == 11\n assert candidate(word = \"HTML\") == 4\n assert candidate(word = \"SECURE\") == 10\n assert candidate(word = \"MECHANISM\") == 13\n assert candidate(word = \"WEALTHY\") == 15\n assert candidate(word = \"FLAWLESS\") == 12\n assert candidate(word = \"MORAL\") == 6\n assert candidate(word = \"RESPONSIBLE\") == 19\n assert candidate(word = \"DEVOTED\") == 6\n assert candidate(word = \"PASSIONATE\") == 15\n assert candidate(word = \"RANDOMKEYPAD\") == 24\n assert candidate(word = \"BACKSPACENEEDED\") == 20\n assert candidate(word = \"JAVA\") == 2\n assert candidate(word = \"CHALLENGE\") == 11\n assert candidate(word = \"PRESENTATION\") == 17\n assert candidate(word = \"BOOMING\") == 7\n assert candidate(word = \"HELLOWORLD\") == 13\n assert candidate(word = \"EQUITABLE\") == 16\n assert candidate(word = \"GREATEST\") == 10\n assert candidate(word = \"DATASTRUCTURES\") == 26\n assert candidate(word = \"EXCELLENCE\") == 14\n assert candidate(word = \"PRECISE\") == 10\n assert candidate(word = \"OBTAINED\") == 11\n assert candidate(word = \"EXECUTION\") == 9\n assert candidate(word = \"DELICATE\") == 11\n assert candidate(word = \"KRUSKALSMST\") == 16\n assert candidate(word = \"AAABBBCCCDDD\") == 2\n assert candidate(word = \"BEST\") == 4\n assert candidate(word = \"ABCDEFGHIJABCDEFGHIJ\") == 24\n assert candidate(word = \"EXEMPLARY\") == 19\n assert candidate(word = \"PRIMSMST\") == 9\n assert candidate(word = \"MANAGER\") == 10\n assert candidate(word = \"RELATIONSHIP\") == 19\n assert candidate(word = \"COMMUNICATION\") == 15\n assert candidate(word = \"FINGERPRINT\") == 17\n assert candidate(word = \"RECOMMENDATION\") == 18\n assert candidate(word = \"MULTITHREADING\") == 24\n assert candidate(word = \"MEETING\") == 8\n assert candidate(word = \"TRIUMPHANT\") == 17\n assert candidate(word = \"PRIDE\") == 5\n assert candidate(word = \"STRETCH\") == 8\n assert candidate(word = \"FINGERLATERALMOVEMENT\") == 38\n assert candidate(word = \"CLIENT\") == 6\n assert candidate(word = \"BOOM\") == 2\n assert candidate(word = \"AFFLUENCE\") == 13\n assert candidate(word = \"CONSECUTIVE\") == 16\n assert candidate(word = \"GREAT\") == 8\n assert candidate(word = \"MARKET\") == 9\n assert candidate(word = \"GENUINE\") == 8\n assert candidate(word = \"BIGDATAANALYSIS\") == 24\n assert candidate(word = \"CONVINCED\") == 10\n assert candidate(word = \"UNIT\") == 3\n assert candidate(word = \"CONFIGURATION\") == 25\n assert candidate(word = \"PLAN\") == 6\n assert candidate(word = \"ADAPTABLE\") == 13\n assert candidate(word = \"TEAMWORK\") == 15\n assert candidate(word = \"AAAAAAAAA\") == 0\n assert candidate(word = \"ACHIEVE\") == 8\n assert candidate(word = \"UTILIZATION\") == 17\n assert candidate(word = \"THRIVING\") == 10\n assert candidate(word = \"PERFORMANCE\") == 20\n assert candidate(word = \"MODEST\") == 6\n assert candidate(word = \"DEVELOPMENT\") == 13\n assert candidate(word = \"ACHIEVED\") == 9\n assert candidate(word = \"BREADTHFIRSTSEARCH\") == 35\n assert candidate(word = \"ASSURED\") == 9\n assert candidate(word = \"TRIUMPH\") == 12\n assert candidate(word = \"ENTHUSIASTIC\") == 17\n assert candidate(word = \"BUSINESS\") == 11\n assert candidate(word = \"PHP\") == 0\n assert candidate(word = \"EARNED\") == 10\n assert candidate(word = \"BBBBC\") == 0\n assert candidate(word = \"LONGKEYSEQUENCE\") == 20\n assert candidate(word = \"RIGHT\") == 5\n assert candidate(word = \"PERFECTION\") == 14\n assert candidate(word = \"PRINCIPLED\") == 14\n assert candidate(word = \"DEBUGGINGISSLOW\") == 23\n assert candidate(word = \"GUARANTEED\") == 13\n assert candidate(word = \"PROSPER\") == 11\n assert candidate(word = \"SYNCHRONIZATION\") == 25\n assert candidate(word = \"ACCOUNTABLE\") == 14\n assert candidate(word = \"VIVACIOUS\") == 10\n assert candidate(word = \"ACCURATE\") == 14\n assert candidate(word = \"INITIALIZE\") == 17\n assert candidate(word = \"ABUNDANCE\") == 12\n assert candidate(word = \"EXACT\") == 10\n assert candidate(word = \"PREMIERE\") == 12\n assert candidate(word = \"PNEUMONULA\") == 19\n assert candidate(word = \"SYNTAXERRORHANDLING\") == 36\n assert candidate(word = \"PYTHONANDJAVA\") == 15\n assert candidate(word = \"PROBLEM\") == 10\n assert candidate(word = \"DECIDED\") == 4\n assert candidate(word = \"INFORMATION\") == 18\n assert candidate(word = \"CODINGCHALLENGES\") == 23\n assert candidate(word = \"TRANSACTION\") == 16\n assert candidate(word = \"CONTESTSAREFUN\") == 24\n assert candidate(word = \"DYNAMIC\") == 11\n assert candidate(word = \"PATTERN\") == 11\n assert candidate(word = \"CONCURRENT\") == 12\n assert candidate(word = \"TEST\") == 2\n assert candidate(word = \"SUPERIOR\") == 10\n assert candidate(word = \"LOVEPYTHON\") == 17\n assert candidate(word = \"COLLABORATION\") == 22\n assert candidate(word = \"MINIMALIZATION\") == 20\n assert candidate(word = \"MACHINELEARNING\") == 28\n assert candidate(word = \"PLETHORA\") == 16\n assert candidate(word = \"MEMORIZATION\") == 21\n assert candidate(word = \"PROTECTED\") == 11\n assert candidate(word = \"JAVASCRIPT\") == 19\n assert candidate(word = \"EXCEPTIONAL\") == 20\n assert candidate(word = \"FLOURISHING\") == 15\n assert candidate(word = \"COORDINATOR\") == 17\n assert candidate(word = \"VARIABLESANDTYPES\") == 33\n assert candidate(word = \"TEAM\") == 6\n assert candidate(word = \"TRAVELINGSALESMANPROBLEM\") == 51\n assert candidate(word = \"VUE\") == 1\n assert candidate(word = \"DIRECT\") == 10\n assert candidate(word = \"AVOIDDISTANCE\") == 17\n assert candidate(word = \"PREMIUM\") == 10\n assert candidate(word = \"FLEXIBLE\") == 12\n assert candidate(word = \"CPLUSPLUS\") == 15\n assert candidate(word = \"BUG\") == 2\n assert candidate(word = \"COOLCODE\") == 8\n assert candidate(word = \"CONGRATULATIONS\") == 25\n assert candidate(word = \"MONGODB\") == 8\n assert candidate(word = \"NETWORKFLOW\") == 16\n assert candidate(word = \"SIMULATEDANNEALING\") == 34\n assert candidate(word = \"STRONG\") == 6\n assert candidate(word = \"POSTGRESQL\") == 17\n assert candidate(word = \"TARGET\") == 11\n assert candidate(word = \"PROJECT\") == 10\n assert candidate(word = \"ARTIFICIALINTELLIGENCE\") == 37\n assert candidate(word = \"DATABASE\") == 10\n assert candidate(word = \"RECURSION\") == 13\n assert candidate(word = \"REACT\") == 9\n assert candidate(word = \"FRAMEWORK\") == 16\n assert candidate(word = \"OPTIMAL\") == 10\n assert candidate(word = \"REACHED\") == 8\n assert candidate(word = \"EXCELLENT\") == 12\n assert candidate(word = \"KANGAROO\") == 11\n assert candidate(word = \"GENETICALGORITHM\") == 24\n assert candidate(word = \"STRESS\") == 5\n assert candidate(word = \"PYTHONPROGRAMMING\") == 23\n assert candidate(word = \"GRAPH\") == 5\n assert candidate(word = \"MIGHTY\") == 6\n assert candidate(word = \"HONEST\") == 6\n assert candidate(word = \"ACCELERATION\") == 18\n assert candidate(word = \"XYLOPHONE\") == 15\n assert candidate(word = \"LUXURY\") == 6\n assert candidate(word = \"LOYAL\") == 8\n assert candidate(word = \"DIVIDEANDCONQUER\") == 25\n assert candidate(word = \"IDENTIFICATION\") == 19\n assert candidate(word = \"HONORABLE\") == 11\n assert candidate(word = \"TYPINGISAWAYTORELAX\") == 37\n assert candidate(word = \"ENGINEERING\") == 15\n assert candidate(word = \"TYPINGWITHTWOFINGERS\") == 39\n assert candidate(word = \"COMPANY\") == 10\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 84\n assert candidate(word = \"ARRAY\") == 4\n assert candidate(word = \"CSS\") == 0\n assert candidate(word = \"CYBER\") == 7\n assert candidate(word = \"ENGINEER\") == 9\n assert candidate(word = \"FUTURE\") == 7\n assert candidate(word = \"APPLICATION\") == 14\n assert candidate(word = \"STACK\") == 6\n assert candidate(word = \"VICTORIOUS\") == 13\n assert candidate(word = \"IMPLEMENTATION\") == 18\n assert candidate(word = \"HELLOUNIVERSE\") == 23\n assert candidate(word = \"PROCESS\") == 9\n assert candidate(word = \"FUNCTION\") == 9\n assert candidate(word = \"CAREER\") == 6\n assert candidate(word = \"INITIATIVE\") == 12\n assert candidate(word = \"RESULT\") == 8\n assert candidate(word = \"EMPATHY\") == 12\n assert candidate(word = \"ABILITY\") == 8\n assert candidate(word = \"SUPPLIER\") == 10\n assert candidate(word = \"INTERVENTION\") == 20\n assert candidate(word = \"ATTAINED\") == 8\n assert candidate(word = \"ALGORITHM\") == 13\n assert candidate(word = \"LEADER\") == 7\n assert candidate(word = \"SOFTWAREENGINEERING\") == 36\n assert candidate(word = \"SUPERABUNDANCE\") == 26\n assert candidate(word = \"TENACIOUS\") == 11\n assert candidate(word = \"FAIR\") == 5\n assert candidate(word = \"HELLOWORLDHELLOWORLD\") == 29\n assert candidate(word = \"REFACTOR\") == 14\n assert candidate(word = \"SATISFACTION\") == 20\n assert candidate(word = \"ALGORITHMSANDDATA\") == 26\n assert candidate(word = \"PROLIFIC\") == 5\n assert candidate(word = \"GRAPHALGORITHMS\") == 24\n assert candidate(word = \"CAREFUL\") == 12\n assert candidate(word = \"ECONOMY\") == 7\n assert candidate(word = \"OUTSTANDING\") == 12\n assert candidate(word = \"GREEDYALGORITHM\") == 27\n assert candidate(word = \"VIP\") == 1\n assert candidate(word = \"BAAABBBCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWWXXXXYYYYZZZZZ\") == 36\n assert candidate(word = \"COMPASSION\") == 12\n assert candidate(word = \"ARCHITECTURE\") == 20\n assert candidate(word = \"BELLMANFORD\") == 17\n assert candidate(word = \"WORKFLOW\") == 10\n assert candidate(word = \"NODEJS\") == 7\n assert candidate(word = \"RESILIENT\") == 14\n assert candidate(word = \"ZYXWVUTSRQPONMLKJIHGFEDCBA\") == 36\n assert candidate(word = \"HAPPINESS\") == 12\n assert candidate(word = \"RELIABLE\") == 10\n assert candidate(word = \"POWERFUL\") == 11\n assert candidate(word = \"PERFECT\") == 10\n assert candidate(word = \"TRUSTWORTHY\") == 18\n assert candidate(word = \"TRANSPARENT\") == 23\n assert candidate(word = \"MINIMIZE\") == 8\n assert candidate(word = \"COMPLEXITY\") == 20\n assert candidate(word = \"TENDER\") == 6\n assert candidate(word = \"ACCEPTANCE\") == 13\n assert candidate(word = \"FLASK\") == 5\n assert candidate(word = \"KNOWLEDGE\") == 13\n assert candidate(word = \"RICH\") == 3\n assert candidate(word = \"ENVIRONMENT\") == 17\n assert candidate(word = \"GAINED\") == 7\n assert candidate(word = \"DISCOVER\") == 13\n assert candidate(word = \"DOUBTFREE\") == 13\n assert candidate(word = \"LUXURIOUS\") == 9\n assert candidate(word = \"SECURITY\") == 14\n assert candidate(word = \"INDUSTRY\") == 13\n assert candidate(word = \"MOVEMENTOFKEYS\") == 19\n assert candidate(word = \"DJANGO\") == 6\n assert candidate(word = \"FUNCTIONCALLSARE\") == 28\n assert candidate(word = \"CONSCIENTIOUS\") == 16\n assert candidate(word = \"HELLOORLD\") == 9\n assert candidate(word = \"REVISION\") == 11\n assert candidate(word = \"INNOVATION\") == 12\n assert candidate(word = \"EXCLUSIVE\") == 18\n assert candidate(word = \"SURE\") == 5\n assert candidate(word = \"TRUST\") == 4\n assert candidate(word = \"DYNAMICPROGRAMMING\") == 31\n assert candidate(word = \"LEARN\") == 8\n assert candidate(word = \"SUCCESS\") == 5\n assert candidate(word = \"AAAAAAAAAABBBBBBBBBBCCCCCCCCCC\") == 1\n assert candidate(word = \"EVOLUTION\") == 11\n assert candidate(word = \"SOLUTION\") == 10\n assert candidate(word = \"OPPORTUNITY\") == 14\n assert candidate(word = \"ABUNDANT\") == 9\n assert candidate(word = \"FAILURE\") == 10\n assert candidate(word = \"REVOLUTION\") == 14\n assert candidate(word = \"SEQUENCE\") == 11\n assert candidate(word = \"FINGERFINGERFINGER\") == 32\n assert candidate(word = \"LINKEDLIST\") == 14\n assert candidate(word = \"EXPERIENCE\") == 14\n assert candidate(word = \"OPEN\") == 3\n assert candidate(word = \"LOVE\") == 4\n assert candidate(word = \"CONCLUSION\") == 14\n assert candidate(word = \"SKILL\") == 5\n assert candidate(word = \"EVALUATION\") == 19\n assert candidate(word = \"FINGERTYPINGISFUN\") == 32\n assert candidate(word = \"MAGNIFICENT\") == 13\n assert candidate(word = \"LEETCODE\") == 8\n assert candidate(word = \"CUSTOMER\") == 12\n assert candidate(word = \"STRIGHT\") == 8\n assert candidate(word = \"SPACECOMPLEXITY\") == 28\n assert candidate(word = \"DEPENDABLE\") == 13\n assert candidate(word = \"DEVELOPER\") == 10\n assert candidate(word = \"EXPRESS\") == 11\n assert candidate(word = \"KEYPADTYPING\") == 24\n assert candidate(word = \"PROFESSION\") == 12\n assert candidate(word = \"REPOSITION\") == 11\n assert candidate(word = \"KNAPSACKPROBLEM\") == 28\n assert candidate(word = \"DESIGN\") == 8\n assert candidate(word = \"DEBUG\") == 6\n assert candidate(word = \"TRACING\") == 11\n assert candidate(word = \"STURDY\") == 9\n assert candidate(word = \"WEALTH\") == 11\n assert candidate(word = \"TRANSFORMATION\") == 29\n assert candidate(word = \"EFFORT\") == 5\n assert candidate(word = \"EXERCISE\") == 11\n", "comparison": "exact"}, "public_tests": ["\"CAKE\"", "\"HAPPY\""], "hints": ["Use dynamic programming.", "dp[i][j][k]: smallest movements when you have one finger on i-th char and the other one on j-th char already having written k first characters from word."], "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minimumDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:44+00:00", "tests_total": 450, "tests_dropped": 1, "flags": ["figure_reference", "has_images"], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minimumDistance(self, word: str) -> int:", "container": "Solution", "callable": "minimumDistance", "parameters": [{"name": "word", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1324, "task_id": "print-words-vertically", "difficulty": "Medium", "problem_description": "Given a string s. Return all the words vertically in the same order in which they appear in s.\nWords are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).\nEach word would be put on only one column and that in one column there will be only one word.\n\nExample 1:\n\nInput: s = \"HOW ARE YOU\"\nOutput: [\"HAY\",\"ORO\",\"WEU\"]\nExplanation: Each word is printed vertically.\n \"HAY\"\n \"ORO\"\n \"WEU\"\n\nExample 2:\n\nInput: s = \"TO BE OR NOT TO BE\"\nOutput: [\"TBONTB\",\"OEROOE\",\" T\"]\nExplanation: Trailing spaces is not allowed.\n\"TBONTB\"\n\"OEROOE\"\n\" T\"\n\nExample 3:\n\nInput: s = \"CONTEST IS COMING\"\nOutput: [\"CIC\",\"OSO\",\"N M\",\"T I\",\"E N\",\"S G\",\"T\"]\n\nConstraints:\n\n- 1 <= s.length <= 200\n- s contains only upper case English letters.\n- It's guaranteed that there is only one space between 2 words.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"AB CD\") == ['AC', 'BD']\n assert candidate(s = \"A B C D\") == ['ABCD']\n assert candidate(s = \"A B C D E\") == ['ABCDE']\n assert candidate(s = \"SINGLEWORD\") == ['S', 'I', 'N', 'G', 'L', 'E', 'W', 'O', 'R', 'D']\n assert candidate(s = \"A B C\") == ['ABC']\n assert candidate(s = \"PYTHON\") == ['P', 'Y', 'T', 'H', 'O', 'N']\n assert candidate(s = \"HELLO WORLD\") == ['HW', 'EO', 'LR', 'LL', 'OD']\n assert candidate(s = \"ABCD EF GHIJK\") == ['AEG', 'BFH', 'C I', 'D J', ' K']\n assert candidate(s = \"PROGRAMMING IS FUN\") == ['PIF', 'RSU', 'O N', 'G', 'R', 'A', 'M', 'M', 'I', 'N', 'G']\n assert candidate(s = \"MAKE AMERICA GREAT AGAIN\") == ['MAGA', 'AMRG', 'KEEA', 'ERAI', ' ITN', ' C', ' A']\n assert candidate(s = \"SPACE BETWEEN\") == ['SB', 'PE', 'AT', 'CW', 'EE', ' E', ' N']\n assert candidate(s = \"UPPER CASE ONLY\") == ['UCO', 'PAN', 'PSL', 'EEY', 'R']\n assert candidate(s = \"HOW ARE YOU\") == ['HAY', 'ORO', 'WEU']\n assert candidate(s = \"PYTHON CODING CHALLENGE\") == ['PCC', 'YOH', 'TDA', 'HIL', 'ONL', 'NGE', ' N', ' G', ' E']\n assert candidate(s = \"JUMP HIGH\") == ['JH', 'UI', 'MG', 'PH']\n assert candidate(s = \"A\") == ['A']\n assert candidate(s = \"ALIGNED TEXT VERTICALLY\") == ['ATV', 'LEE', 'IXR', 'GTT', 'N I', 'E C', 'D A', ' L', ' L', ' Y']\n assert candidate(s = \"KEEP IT SIMPLE\") == ['KIS', 'ETI', 'E M', 'P P', ' L', ' E']\n assert candidate(s = \"HELLO HELLO HELLO\") == ['HHH', 'EEE', 'LLL', 'LLL', 'OOO']\n assert candidate(s = \"TO BE OR NOT TO BE\") == ['TBONTB', 'OEROOE', ' T']\n assert candidate(s = \"CONTEST IS COMING\") == ['CIC', 'OSO', 'N M', 'T I', 'E N', 'S G', 'T']\n assert candidate(s = \"SAME LENGTH\") == ['SL', 'AE', 'MN', 'EG', ' T', ' H']\n assert candidate(s = \"PYTHON IS FUN\") == ['PIF', 'YSU', 'T N', 'H', 'O', 'N']\n assert candidate(s = \"MULTIPLE SPACES BETWEEN WORDS\") == ['MSBW', 'UPEO', 'LATR', 'TCWD', 'IEES', 'PSE', 'L N', 'E']\n assert candidate(s = \"VERTICAL PRINTING TEST\") == ['VPT', 'ERE', 'RIS', 'TNT', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"VERTICALALIGNMENT WITH SPACES\") == ['VWS', 'EIP', 'RTA', 'THC', 'I E', 'C S', 'A', 'L', 'A', 'L', 'I', 'G', 'N', 'M', 'E', 'N', 'T']\n assert candidate(s = \"VERYLONGWORDSTOCHALLENGEIMPLEMENTATION\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'T', 'O', 'C', 'H', 'A', 'L', 'L', 'E', 'N', 'G', 'E', 'I', 'M', 'P', 'L', 'E', 'M', 'E', 'N', 'T', 'A', 'T', 'I', 'O', 'N']\n assert candidate(s = \"SHORT LONGER LONGEST\") == ['SLL', 'HOO', 'ONN', 'RGG', 'TEE', ' RS', ' T']\n assert candidate(s = \"UNIVERSITY OF WATERLOO\") == ['UOW', 'NFA', 'I T', 'V E', 'E R', 'R L', 'S O', 'I O', 'T', 'Y']\n assert candidate(s = \"VERTICAL ALIGNMENT TEST\") == ['VAT', 'ELE', 'RIS', 'TGT', 'IN', 'CM', 'AE', 'LN', ' T']\n assert candidate(s = \"COMPACT AND READABLE CODE\") == ['CARC', 'ONEO', 'MDAD', 'P DE', 'A A', 'C B', 'T L', ' E']\n assert candidate(s = \"MIXED CASE words\") == ['MCw', 'IAo', 'XSr', 'EEd', 'D s']\n assert candidate(s = \"LONGESTWORDHERE SHORT MEDIUM\") == ['LSM', 'OHE', 'NOD', 'GRI', 'ETU', 'S M', 'T', 'W', 'O', 'R', 'D', 'H', 'E', 'R', 'E']\n assert candidate(s = \"SMALL BIGGEST WORD\") == ['SBW', 'MIO', 'AGR', 'LGD', 'LE', ' S', ' T']\n assert candidate(s = \"HELLO WORLD THIS IS A TEST\") == ['HWTIAT', 'EOHS E', 'LRI S', 'LLS T', 'OD']\n assert candidate(s = \"MIXED LENGTH WORDS HERE\") == ['MLWH', 'IEOE', 'XNRR', 'EGDE', 'DTS', ' H']\n assert candidate(s = \"COMPUTER SCIENCE DEPARTMENT\") == ['CSD', 'OCE', 'MIP', 'PEA', 'UNR', 'TCT', 'EEM', 'R E', ' N', ' T']\n assert candidate(s = \"VERYLONGWORDSTO TEST THE SYSTEM\") == ['VTTS', 'EEHY', 'RSES', 'YT T', 'L E', 'O M', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'T', 'O']\n assert candidate(s = \"SAMEWORDSAMEWORD\") == ['S', 'A', 'M', 'E', 'W', 'O', 'R', 'D', 'S', 'A', 'M', 'E', 'W', 'O', 'R', 'D']\n assert candidate(s = \"SMALL WORDS\") == ['SW', 'MO', 'AR', 'LD', 'LS']\n assert candidate(s = \"VERTICAL PRINTING IS FUN\") == ['VPIF', 'ERSU', 'RI N', 'TN', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"ALGORITHMS DATA STRUCTURES\") == ['ADS', 'LAT', 'GTR', 'OAU', 'R C', 'I T', 'T U', 'H R', 'M E', 'S S']\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']\n assert candidate(s = \"EFFICIENT AND POWERFUL\") == ['EAP', 'FNO', 'FDW', 'I E', 'C R', 'I F', 'E U', 'N L', 'T']\n assert candidate(s = \"AVERYLONGWORD THATFITSSNICELY INTOTHECOLUMN\") == ['ATI', 'VHN', 'EAT', 'RTO', 'YFT', 'LIH', 'OTE', 'NSC', 'GSO', 'WNL', 'OIU', 'RCM', 'DEN', ' L', ' Y']\n assert candidate(s = \"MIXEDCASEANDUPPERCASE\") == ['M', 'I', 'X', 'E', 'D', 'C', 'A', 'S', 'E', 'A', 'N', 'D', 'U', 'P', 'P', 'E', 'R', 'C', 'A', 'S', 'E']\n assert candidate(s = \"MIXEDCASE mixedcase\") == ['Mm', 'Ii', 'Xx', 'Ee', 'Dd', 'Cc', 'Aa', 'Ss', 'Ee']\n assert candidate(s = \"MIXED CASE Words AND NUMBERS 123\") == ['MCWAN1', 'IAoNU2', 'XSrDM3', 'EEd B', 'D s E', ' R', ' S']\n assert candidate(s = \"SPACES ARE IGNORED BETWEEN WORDS\") == ['SAIBW', 'PRGEO', 'AENTR', 'C OWD', 'E RES', 'S EE', ' DN']\n assert candidate(s = \"PYTHONPROGRAMMING\") == ['P', 'Y', 'T', 'H', 'O', 'N', 'P', 'R', 'O', 'G', 'R', 'A', 'M', 'M', 'I', 'N', 'G']\n assert candidate(s = \"CHECK FOR SPACES IN BETWEEN\") == ['CFSIB', 'HOPNE', 'ERA T', 'C C W', 'K E E', ' S E', ' N']\n assert candidate(s = \"DATA SCIENCE AND MACHINE LEARNING\") == ['DSAML', 'ACNAE', 'TIDCA', 'AE HR', ' N IN', ' C NI', ' E EN', ' G']\n assert candidate(s = \"LEADING AND TRAILING SPACES\") == ['LATS', 'ENRP', 'ADAA', 'D IC', 'I LE', 'N IS', 'G N', ' G']\n assert candidate(s = \"VERYLONGWORDSHOULDTESTTHEFUNCTION\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'H', 'O', 'U', 'L', 'D', 'T', 'E', 'S', 'T', 'T', 'H', 'E', 'F', 'U', 'N', 'C', 'T', 'I', 'O', 'N']\n assert candidate(s = \"MULTILINE VERTICAL OUTPUT\") == ['MVO', 'UEU', 'LRT', 'TTP', 'IIU', 'LCT', 'IA', 'NL', 'E']\n assert candidate(s = \"LONGESTWORD IN A SENTENCE\") == ['LIAS', 'ON E', 'N N', 'G T', 'E E', 'S N', 'T C', 'W E', 'O', 'R', 'D']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN\") == ['OTTFFSSENT', 'NWHOIIEIIE', 'EORUVXVGNN', ' ERE EHE', ' E NT']\n assert candidate(s = \"ALIGNED COLUMN OUTPUT PRINTING\") == ['ACOP', 'LOUR', 'ILTI', 'GUPN', 'NMUT', 'ENTI', 'D N', ' G']\n assert candidate(s = \"ANOTHEREXAMPLEFOR TESTING\") == ['AT', 'NE', 'OS', 'TT', 'HI', 'EN', 'RG', 'E', 'X', 'A', 'M', 'P', 'L', 'E', 'F', 'O', 'R']\n assert candidate(s = \"SHORT LONGEST SHORTEST\") == ['SLS', 'HOH', 'ONO', 'RGR', 'TET', ' SE', ' TS', ' T']\n assert candidate(s = \"SAMEWORD SAMEWORD SAMEWORD\") == ['SSS', 'AAA', 'MMM', 'EEE', 'WWW', 'OOO', 'RRR', 'DDD']\n assert candidate(s = \"ALIGNED ROWS\") == ['AR', 'LO', 'IW', 'GS', 'N', 'E', 'D']\n assert candidate(s = \"JUSTIFIED TEXT\") == ['JT', 'UE', 'SX', 'TT', 'I', 'F', 'I', 'E', 'D']\n assert candidate(s = \"SHORTEST LONGEST WORD\") == ['SLW', 'HOO', 'ONR', 'RGD', 'TE', 'ES', 'ST', 'T']\n assert candidate(s = \"ENDING SPACES ARE NOT ALLOWED \") == ['ESANA', 'NPROL', 'DAETL', 'IC O', 'NE W', 'GS E', ' D']\n assert candidate(s = \"S P A C E S E P A R A T E D\") == ['SPACESEPARATED']\n assert candidate(s = \"VERYLONGWORDTHATREQUIRESPROPERVERTICALALIGNMENT\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'T', 'H', 'A', 'T', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'S', 'P', 'R', 'O', 'P', 'E', 'R', 'V', 'E', 'R', 'T', 'I', 'C', 'A', 'L', 'A', 'L', 'I', 'G', 'N', 'M', 'E', 'N', 'T']\n assert candidate(s = \"MIX SOME VERY LONG WORDS IN THIS STRING\") == ['MSVLWITS', 'IOEOONHT', 'XMRNR IR', ' EYGD SI', ' S N', ' G']\n assert candidate(s = \"MULTILINE TEXT PRINTING\") == ['MTP', 'UER', 'LXI', 'TTN', 'I T', 'L I', 'I N', 'N G', 'E']\n assert candidate(s = \"VERY LONG WORDS IN THIS SENTENCE\") == ['VLWITS', 'EOONHE', 'RNR IN', 'YGD ST', ' S E', ' N', ' C', ' E']\n assert candidate(s = \"LEADING SPACES ARE IGNORED\") == ['LSAI', 'EPRG', 'AAEN', 'DC O', 'IE R', 'NS E', 'G D']\n assert candidate(s = \"VERTICAL PRINTING TEST CASE\") == ['VPTC', 'EREA', 'RISS', 'TNTE', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"REALLYLONGWORD THATS EVENLONGER\") == ['RTE', 'EHV', 'AAE', 'LTN', 'LSL', 'Y O', 'L N', 'O G', 'N E', 'G R', 'W', 'O', 'R', 'D']\n assert candidate(s = \"SIXTEENCHARACTERLIMITHERE\") == ['S', 'I', 'X', 'T', 'E', 'E', 'N', 'C', 'H', 'A', 'R', 'A', 'C', 'T', 'E', 'R', 'L', 'I', 'M', 'I', 'T', 'H', 'E', 'R', 'E']\n assert candidate(s = \"HIGH LEVEL LANGUAGE\") == ['HLL', 'IEA', 'GVN', 'HEG', ' LU', ' A', ' G', ' E']\n assert candidate(s = \"SAMELENGTH WORDS\") == ['SW', 'AO', 'MR', 'ED', 'LS', 'E', 'N', 'G', 'T', 'H']\n assert candidate(s = \"ONECHAR PER WORD A B C D E\") == ['OPWABCDE', 'NEO', 'ERR', 'C D', 'H', 'A', 'R']\n assert candidate(s = \"VARYING WORD LENGTHS\") == ['VWL', 'AOE', 'RRN', 'YDG', 'I T', 'N H', 'G S']\n assert candidate(s = \"PYTHON IS AWESOME\") == ['PIA', 'YSW', 'T E', 'H S', 'O O', 'N M', ' E']\n assert candidate(s = \"SHOULD HANDLE LARGE WORDS CORRECTLY\") == ['SHLWC', 'HAAOO', 'ONRRR', 'UDGDR', 'LLESE', 'DE C', ' T', ' L', ' Y']\n assert candidate(s = \"ONEVERYLONGWORDHERE\") == ['O', 'N', 'E', 'V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'H', 'E', 'R', 'E']\n assert candidate(s = \"HELLO WORLD FROM ALIBABA CLOUD\") == ['HWFAC', 'EORLL', 'LROIO', 'LLMBU', 'OD AD', ' B', ' A']\n assert candidate(s = \"DIFFERENT LENGTH WORDS\") == ['DLW', 'IEO', 'FNR', 'FGD', 'ETS', 'RH', 'E', 'N', 'T']\n assert candidate(s = \"UPPERCASE WORDS ONLY\") == ['UWO', 'PON', 'PRL', 'EDY', 'RS', 'C', 'A', 'S', 'E']\n assert candidate(s = \"THIS IS A LONG STRING FOR TESTING\") == ['TIALSFT', 'HS OTOE', 'I NRRS', 'S GI T', ' N I', ' G N', ' G']\n assert candidate(s = \"LEADING AND TRAILING SPACES ARE NOT ALLOWED\") == ['LATSANA', 'ENRPROL', 'ADAAETL', 'D IC O', 'I LE W', 'N IS E', 'G N D', ' G']\n assert candidate(s = \"SPECIAL CASES LIKE EMPTY STRING\") == ['SCLES', 'PAIMT', 'ESKPR', 'CEETI', 'IS YN', 'A G', 'L']\n assert candidate(s = \"UNIVERSAL ACCEPTANCE OF PYTHON\") == ['UAOP', 'NCFY', 'IC T', 'VE H', 'EP O', 'RT N', 'SA', 'AN', 'LC', ' E']\n assert candidate(s = \"HELLO WORLD FROM THE OTHER SIDE\") == ['HWFTOS', 'EORHTI', 'LROEHD', 'LLM EE', 'OD R']\n assert candidate(s = \"TESTING WITH SPECIAL CHARACTERS !@#\") == ['TWSC!', 'EIPH@', 'STEA#', 'THCR', 'I IA', 'N AC', 'G LT', ' E', ' R', ' S']\n assert candidate(s = \"MULTILINE STRING WITH MULTIPLE LINES\") == ['MSWML', 'UTIUI', 'LRTLN', 'TIHTE', 'IN IS', 'LG P', 'I L', 'N E', 'E']\n assert candidate(s = \"SHORTEST WORD\") == ['SW', 'HO', 'OR', 'RD', 'T', 'E', 'S', 'T']\n assert candidate(s = \"TEST WITH MANY WORDS AND DIFFERENT LENGTHS\") == ['TWMWADL', 'EIAONIE', 'STNRDFN', 'THYD FG', ' S ET', ' RH', ' ES', ' N', ' T']\n assert candidate(s = \"EXTREMELYLONGWORD SOMETIMES ARE NECESSARY\") == ['ESAN', 'XORE', 'TMEC', 'RE E', 'ET S', 'MI S', 'EM A', 'LE R', 'YS Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D']\n assert candidate(s = \"EQUAL LENGTH WORDS HERE\") == ['ELWH', 'QEOE', 'UNRR', 'AGDE', 'LTS', ' H']\n assert candidate(s = \"HELLO WORLD THIS IS A VERTICALLY PRINTED TEXT\") == ['HWTIAVPT', 'EOHS ERE', 'LRI RIX', 'LLS TNT', 'OD IT', ' CE', ' AD', ' L', ' L', ' Y']\n assert candidate(s = \"SINGLE\") == ['S', 'I', 'N', 'G', 'L', 'E']\n assert candidate(s = \"PYTHONCODE JAVA CODE CSHARP\") == ['PJCC', 'YAOS', 'TVDH', 'HAEA', 'O R', 'N P', 'C', 'O', 'D', 'E']\n assert candidate(s = \"WITH MANY DIFFERENT LENGTHS\") == ['WMDL', 'IAIE', 'TNFN', 'HYFG', ' ET', ' RH', ' ES', ' N', ' T']\n assert candidate(s = \"DIFFERENT LENGTHS\") == ['DL', 'IE', 'FN', 'FG', 'ET', 'RH', 'ES', 'N', 'T']\n assert candidate(s = \"PYTHON PROGRAMMING\") == ['PP', 'YR', 'TO', 'HG', 'OR', 'NA', ' M', ' M', ' I', ' N', ' G']\n assert candidate(s = \"ALMOSTDONE\") == ['A', 'L', 'M', 'O', 'S', 'T', 'D', 'O', 'N', 'E']\n assert candidate(s = \"VARYING LENGTHS IN THIS STRING\") == ['VLITS', 'AENHT', 'RN IR', 'YG SI', 'IT N', 'NH G', 'GS']\n assert candidate(s = \"AVERYLONGWORDWITHNOSPACE\") == ['A', 'V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'W', 'I', 'T', 'H', 'N', 'O', 'S', 'P', 'A', 'C', 'E']\n assert candidate(s = \"PROGRAMMING CHALLENGES ARE FUN\") == ['PCAF', 'RHRU', 'OAEN', 'GL', 'RL', 'AE', 'MN', 'MG', 'IE', 'NS', 'G']\n assert candidate(s = \"TESTING EDGE CASES HERE\") == ['TECH', 'EDAE', 'SGSR', 'TEEE', 'I S', 'N', 'G']\n assert candidate(s = \"DIFFERENT SPACING TEST\") == ['DST', 'IPE', 'FAS', 'FCT', 'EI', 'RN', 'EG', 'N', 'T']\n assert candidate(s = \"MIXED SPACES AND VARYING LENGTHS\") == ['MSAVL', 'IPNAE', 'XADRN', 'EC YG', 'DE IT', ' S NH', ' GS']\n assert candidate(s = \"SPARSEMATRIX AND DENSEMATRIX\") == ['SAD', 'PNE', 'ADN', 'R S', 'S E', 'E M', 'M A', 'A T', 'T R', 'R I', 'I X', 'X']\n assert candidate(s = \"ALIGNED COLUMN OUTPUT\") == ['ACO', 'LOU', 'ILT', 'GUP', 'NMU', 'ENT', 'D']\n assert candidate(s = \"UPPERCASE LOWERCASE MIXEDCASE\") == ['ULM', 'POI', 'PWX', 'EEE', 'RRD', 'CCC', 'AAA', 'SSS', 'EEE']\n assert candidate(s = \"REALLYLONGWORD AND SHORT\") == ['RAS', 'ENH', 'ADO', 'L R', 'L T', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D']\n assert candidate(s = \"ONE\") == ['O', 'N', 'E']\n assert candidate(s = \"PYTHONJAVAJS CPLUSPLUS RUBY\") == ['PCR', 'YPU', 'TLB', 'HUY', 'OS', 'NP', 'JL', 'AU', 'VS', 'A', 'J', 'S']\n assert candidate(s = \"MULTILINE STRINGS ARE NOT ALLOWED\") == ['MSANA', 'UTROL', 'LRETL', 'TI O', 'IN W', 'LG E', 'IS D', 'N', 'E']\n assert candidate(s = \"VERTICAL PRINTING\") == ['VP', 'ER', 'RI', 'TN', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"VERTICAL PRINTING OF STRINGS\") == ['VPOS', 'ERFT', 'RI R', 'TN I', 'IT N', 'CI G', 'AN S', 'LG']\n assert candidate(s = \"TRAILING SPACES ARE NOT ALLOWED \") == ['TSANA', 'RPROL', 'AAETL', 'IC O', 'LE W', 'IS E', 'N D', 'G']\n assert candidate(s = \"MULTILINE VERTICAL PRINT\") == ['MVP', 'UER', 'LRI', 'TTN', 'IIT', 'LC', 'IA', 'NL', 'E']\n assert candidate(s = \"SINGLELETTERS ABC DEF GHI\") == ['SADG', 'IBEH', 'NCFI', 'G', 'L', 'E', 'L', 'E', 'T', 'T', 'E', 'R', 'S']\n assert candidate(s = \"SMALL LARGER LARGEST\") == ['SLL', 'MAA', 'ARR', 'LGG', 'LEE', ' RS', ' T']\n assert candidate(s = \"SAME LENGTH WORDS\") == ['SLW', 'AEO', 'MNR', 'EGD', ' TS', ' H']\n assert candidate(s = \"ALIGNS WORDS CORRECTLY\") == ['AWC', 'LOO', 'IRR', 'GDR', 'NSE', 'S C', ' T', ' L', ' Y']\n assert candidate(s = \"MIXED CASE STRING\") == ['MCS', 'IAT', 'XSR', 'EEI', 'D N', ' G']\n assert candidate(s = \"UPPERCASE LOWERCASE MIXED\") == ['ULM', 'POI', 'PWX', 'EEE', 'RRD', 'CC', 'AA', 'SS', 'EE']\n assert candidate(s = \"VERIFYING THE CORRECTNESS OF THE IMPLEMENTATION\") == ['VTCOTI', 'EHOFHM', 'RER EP', 'I R L', 'F E E', 'Y C M', 'I T E', 'N N N', 'G E T', ' S A', ' S T', ' I', ' O', ' N']\n assert candidate(s = \"HELLO WORLD HELLO WORLD\") == ['HWHW', 'EOEO', 'LRLR', 'LLLL', 'ODOD']\n assert candidate(s = \"PYTHON IS A GREAT LANGUAGE\") == ['PIAGL', 'YS RA', 'T EN', 'H AG', 'O TU', 'N A', ' G', ' E']\n assert candidate(s = \"MIXEDCASE Words ARE Allowed\") == ['MWAA', 'IoRl', 'XrEl', 'Ed o', 'Ds w', 'C e', 'A d', 'S', 'E']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX\") == ['OTTFFS', 'NWHOII', 'EORUVX', ' ERE', ' E']\n assert candidate(s = \"SPECIAL !@#$%^&*() CHARACTERS ARE NOT ALLOWED BUT UPPER CASE ONLY\") == ['S!CANABUCO', 'P@HROLUPAN', 'E#AETLTPSL', 'C$R O EEY', 'I%A W R', 'A^C E', 'L&T D', ' *E', ' (R', ' )S']\n assert candidate(s = \"MIXED CASE WITH VARYING LENGTHS\") == ['MCWVL', 'IAIAE', 'XSTRN', 'EEHYG', 'D IT', ' NH', ' GS']\n assert candidate(s = \"HELLO WORLD FROM PYTHON\") == ['HWFP', 'EORY', 'LROT', 'LLMH', 'OD O', ' N']\n assert candidate(s = \"LONGESTWORDINASENTENCEISHERE\") == ['L', 'O', 'N', 'G', 'E', 'S', 'T', 'W', 'O', 'R', 'D', 'I', 'N', 'A', 'S', 'E', 'N', 'T', 'E', 'N', 'C', 'E', 'I', 'S', 'H', 'E', 'R', 'E']\n assert candidate(s = \"EQUAL LENGTH WORDS\") == ['ELW', 'QEO', 'UNR', 'AGD', 'LTS', ' H']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX SEVEN\") == ['OTTFFSS', 'NWHOIIE', 'EORUVXV', ' ERE E', ' E N']\n assert candidate(s = \"MIXED LENGTHS SHORTEST LONGEST MIDDLE\") == ['MLSLM', 'IEHOI', 'XNOND', 'EGRGD', 'DTTEL', ' HESE', ' SST', ' T']\n assert candidate(s = \"PYTHON PROGRAMMING LANGUAGE\") == ['PPL', 'YRA', 'TON', 'HGG', 'ORU', 'NAA', ' MG', ' ME', ' I', ' N', ' G']\n assert candidate(s = \"LONGESTWORDFORTESTING VARYING LENGTHS TESTING\") == ['LVLT', 'OAEE', 'NRNS', 'GYGT', 'EITI', 'SNHN', 'TGSG', 'W', 'O', 'R', 'D', 'F', 'O', 'R', 'T', 'E', 'S', 'T', 'I', 'N', 'G']\n assert candidate(s = \"DIFFERENT LENGTH WORDS HERE\") == ['DLWH', 'IEOE', 'FNRR', 'FGDE', 'ETS', 'RH', 'E', 'N', 'T']\n", "comparison": "exact"}, "public_tests": ["\"HOW ARE YOU\"", "\"TO BE OR NOT TO BE\"", "\"CONTEST IS COMING\""], "hints": ["Use the maximum length of words to determine the length of the returned answer. However, don't forget to remove trailing spaces."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().printVertically", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:46+00:00", "tests_total": 140, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "simulation"]}, "language": "python", "interface": {"raw_signature": "def printVertically(self, s: str) -> List[str]:", "container": "Solution", "callable": "printVertically", "parameters": [{"name": "s", "type": "str"}], "return_type": "List[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1326, "task_id": "minimum-number-of-taps-to-open-to-water-a-garden", "difficulty": "Hard", "problem_description": "There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e., the length of the garden is n).\n\nThere are n + 1 taps located at points [0, 1, ..., n] in the garden.\n\nGiven an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-th tap can water the area [i - ranges[i], i + ranges[i]] if it was open.\n\nReturn the minimum number of taps that should be open to water the whole garden, If the garden cannot be watered return -1.\n\nExample 1:\n\nInput: n = 5, ranges = [3,4,1,1,0,0]\nOutput: 1\nExplanation: The tap at point 0 can cover the interval [-3,3]\nThe tap at point 1 can cover the interval [-3,5]\nThe tap at point 2 can cover the interval [1,3]\nThe tap at point 3 can cover the interval [2,4]\nThe tap at point 4 can cover the interval [4,4]\nThe tap at point 5 can cover the interval [5,5]\nOpening Only the second tap will water the whole garden [0,5]\n\nExample 2:\n\nInput: n = 3, ranges = [0,0,0,0]\nOutput: -1\nExplanation: Even if you activate all the four taps you cannot water the whole garden.\n\nConstraints:\n\n- 1 <= n <= 10^4\n- ranges.length == n + 1\n- 0 <= ranges[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 5,ranges = [3, 4, 1, 1, 0, 0]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 0, 0, 4]) == 2\n assert candidate(n = 3,ranges = [0, 0, 0, 0]) == -1\n assert candidate(n = 2,ranges = [1, 0, 1]) == 2\n assert candidate(n = 6,ranges = [1, 2, 3, 4, 5, 6, 7]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 1, 0, 1]) == -1\n assert candidate(n = 7,ranges = [1, 2, 1, 0, 2, 1, 0, 1]) == 3\n assert candidate(n = 6,ranges = [1, 2, 1, 0, 2, 1, 0]) == 2\n assert candidate(n = 1,ranges = [1, 1]) == 1\n assert candidate(n = 6,ranges = [1, 2, 2, 1, 0, 1, 0]) == 2\n assert candidate(n = 20,ranges = [0, 2, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 0, 1, 0, 1, 0]) == 8\n assert candidate(n = 7,ranges = [1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(n = 12,ranges = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2]) == 6\n assert candidate(n = 20,ranges = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(n = 20,ranges = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [4, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(n = 10,ranges = [2, 3, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(n = 20,ranges = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) == -1\n assert candidate(n = 15,ranges = [3, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0]) == -1\n assert candidate(n = 14,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 7,ranges = [3, 2, 2, 3, 2, 2, 1, 1]) == 2\n assert candidate(n = 10,ranges = [2, 3, 0, 2, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 14,ranges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]) == 1\n assert candidate(n = 7,ranges = [0, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(n = 12,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 12,ranges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(n = 15,ranges = [1, 2, 2, 3, 1, 2, 3, 0, 1, 2, 1, 0, 1, 2, 1, 0]) == 4\n assert candidate(n = 9,ranges = [0, 0, 2, 0, 0, 0, 2, 0, 0, 2]) == 3\n assert candidate(n = 11,ranges = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 5\n assert candidate(n = 12,ranges = [4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == -1\n assert candidate(n = 12,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 9,ranges = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 10,ranges = [2, 2, 0, 2, 2, 0, 1, 0, 1, 2, 0]) == 4\n assert candidate(n = 12,ranges = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(n = 10,ranges = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 9,ranges = [0, 0, 1, 0, 0, 0, 0, 0, 1, 1]) == -1\n assert candidate(n = 25,ranges = [0, 0, 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(n = 8,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(n = 15,ranges = [3, 1, 4, 2, 1, 0, 1, 0, 0, 2, 3, 0, 1, 0, 1, 0]) == 4\n assert candidate(n = 8,ranges = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 1\n assert candidate(n = 13,ranges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(n = 12,ranges = [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == -1\n assert candidate(n = 20,ranges = [3, 1, 0, 0, 0, 0, 0, 2, 2, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0]) == -1\n assert candidate(n = 7,ranges = [3, 2, 1, 0, 0, 0, 2, 1]) == -1\n assert candidate(n = 7,ranges = [3, 0, 1, 2, 0, 1, 0, 1]) == 4\n assert candidate(n = 12,ranges = [0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(n = 8,ranges = [0, 1, 0, 0, 0, 2, 1, 0, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 1, 1, 0, 2, 1, 0, 0, 2, 3, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 9,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(n = 12,ranges = [2, 3, 0, 1, 0, 3, 0, 1, 0, 0, 1, 0, 1]) == -1\n assert candidate(n = 10,ranges = [3, 1, 2, 1, 3, 2, 1, 1, 2, 3, 1]) == 3\n assert candidate(n = 12,ranges = [0, 0, 3, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 25,ranges = [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]) == -1\n assert candidate(n = 20,ranges = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]) == 2\n assert candidate(n = 11,ranges = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n assert candidate(n = 8,ranges = [3, 0, 2, 1, 1, 0, 2, 1, 1]) == 2\n assert candidate(n = 10,ranges = [2, 3, 1, 1, 0, 2, 1, 0, 1, 2, 1]) == 3\n assert candidate(n = 18,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 10,ranges = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1]) == 2\n assert candidate(n = 8,ranges = [0, 0, 2, 0, 0, 0, 2, 1, 1]) == 2\n assert candidate(n = 18,ranges = [5, 0, 3, 0, 0, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 4]) == 6\n assert candidate(n = 14,ranges = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0]) == -1\n assert candidate(n = 10,ranges = [2, 3, 1, 4, 0, 1, 2, 0, 3, 1, 2]) == 2\n assert candidate(n = 11,ranges = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 8,ranges = [1, 0, 1, 1, 0, 0, 0, 1, 1]) == -1\n assert candidate(n = 10,ranges = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(n = 13,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 9,ranges = [4, 0, 0, 0, 4, 0, 0, 0, 4, 0]) == 2\n assert candidate(n = 10,ranges = [2, 3, 1, 4, 0, 0, 2, 0, 1, 0, 1]) == 3\n assert candidate(n = 15,ranges = [3, 0, 1, 1, 0, 0, 0, 1, 2, 1, 0, 1, 1, 0, 0, 3]) == -1\n assert candidate(n = 14,ranges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1]) == 1\n assert candidate(n = 9,ranges = [0, 2, 1, 3, 1, 2, 0, 1, 0, 2]) == 3\n assert candidate(n = 14,ranges = [3, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(n = 20,ranges = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) == -1\n assert candidate(n = 7,ranges = [3, 2, 0, 0, 1, 0, 1, 1]) == 3\n assert candidate(n = 12,ranges = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(n = 12,ranges = [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 20,ranges = [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(n = 25,ranges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(n = 20,ranges = [4, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(n = 10,ranges = [2, 3, 1, 0, 0, 1, 2, 1, 0, 2, 0]) == 3\n assert candidate(n = 20,ranges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n", "comparison": "exact"}, "public_tests": ["5\n[3,4,1,1,0,0]", "3\n[0,0,0,0]"], "hints": ["Create intervals of the area covered by each tap, sort intervals by the left end.", "We need to cover the interval [0, n]. we can start with the first interval and out of all intervals that intersect with it we choose the one that covers the farthest point to the right.", "What if there is a gap between intervals that is not covered ? we should stop and return -1 as there is some interval that cannot be covered."], "metadata": {"canonical_parameter_names": ["n", "ranges"], "leetcode_dataset_entry_point": "Solution().minTaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:50+00:00", "tests_total": 93, "tests_dropped": 9, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minTaps(self, n: int, ranges: list[int]) -> int:", "container": "Solution", "callable": "minTaps", "parameters": [{"name": "n", "type": "int"}, {"name": "ranges", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1328, "task_id": "break-a-palindrome", "difficulty": "Medium", "problem_description": "Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.\n\nReturn the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string.\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, a has a character strictly smaller than the corresponding character in b. For example, \"abcc\" is lexicographically smaller than \"abcd\" because the first position they differ is at the fourth character, and 'c' is smaller than 'd'.\n\nExample 1:\n\nInput: palindrome = \"abccba\"\nOutput: \"aaccba\"\nExplanation: There are many ways to make \"abccba\" not a palindrome, such as \"zbccba\", \"aaccba\", and \"abacba\".\nOf all the ways, \"aaccba\" is the lexicographically smallest.\n\nExample 2:\n\nInput: palindrome = \"a\"\nOutput: \"\"\nExplanation: There is no way to replace a single character to make \"a\" not a palindrome, so return an empty string.\n\nConstraints:\n\n- 1 <= palindrome.length <= 1000\n- palindrome consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(palindrome = \"refer\") == \"aefer\"\n assert candidate(palindrome = \"abba\") == \"aaba\"\n assert candidate(palindrome = \"rotor\") == \"aotor\"\n assert candidate(palindrome = \"aa\") == \"ab\"\n assert candidate(palindrome = \"aba\") == \"abb\"\n assert candidate(palindrome = \"a\") == \"\"\n assert candidate(palindrome = \"madam\") == \"aadam\"\n assert candidate(palindrome = \"abccba\") == \"aaccba\"\n assert candidate(palindrome = \"racecar\") == \"aacecar\"\n assert candidate(palindrome = \"moom\") == \"aoom\"\n assert candidate(palindrome = \"aabaa\") == \"aabab\"\n assert candidate(palindrome = \"zzz\") == \"azz\"\n assert candidate(palindrome = \"xyx\") == \"ayx\"\n assert candidate(palindrome = \"level\") == \"aevel\"\n assert candidate(palindrome = \"aaaaa\") == \"aaaab\"\n assert candidate(palindrome = \"abcdedcba\") == \"aacdedcba\"\n assert candidate(palindrome = \"abcba\") == \"aacba\"\n assert candidate(palindrome = \"bcb\") == \"acb\"\n assert candidate(palindrome = \"noon\") == \"aoon\"\n assert candidate(palindrome = \"mamad\") == \"aamad\"\n assert candidate(palindrome = \"deified\") == \"aeified\"\n assert candidate(palindrome = \"z\") == \"\"\n assert candidate(palindrome = \"aabaaa\") == \"aaaaaa\"\n assert candidate(palindrome = \"toot\") == \"aoot\"\n assert candidate(palindrome = \"babababab\") == \"aabababab\"\n assert candidate(palindrome = \"peep\") == \"aeep\"\n assert candidate(palindrome = \"ppppppppp\") == \"apppppppp\"\n assert candidate(palindrome = \"aabbaa\") == \"aaabaa\"\n assert candidate(palindrome = \"abcdefghihgfedcba\") == \"aacdefghihgfedcba\"\n assert candidate(palindrome = \"zzzzzzzz\") == \"azzzzzzz\"\n assert candidate(palindrome = \"bbaab\") == \"abaab\"\n assert candidate(palindrome = \"redder\") == \"aedder\"\n assert candidate(palindrome = \"abcdefghgfedcba\") == \"aacdefghgfedcba\"\n assert candidate(palindrome = \"abcdefghijklmnoponmlkjihgfedcbaedcbafghijklmnop\") == \"aacdefghijklmnoponmlkjihgfedcbaedcbafghijklmnop\"\n assert candidate(palindrome = \"abacaba\") == \"aaacaba\"\n assert candidate(palindrome = \"aabbccddeeffgggggeeeddccbbaa\") == \"aaabccddeeffgggggeeeddccbbaa\"\n assert candidate(palindrome = \"xyzzyx\") == \"ayzzyx\"\n assert candidate(palindrome = \"kayakkayak\") == \"aayakkayak\"\n assert candidate(palindrome = \"repaper\") == \"aepaper\"\n assert candidate(palindrome = \"aaaaaaaa\") == \"aaaaaaab\"\n assert candidate(palindrome = \"ivicc\") == \"avicc\"\n assert candidate(palindrome = \"abaacaaba\") == \"aaaacaaba\"\n assert candidate(palindrome = \"racecarxracecar\") == \"aacecarxracecar\"\n assert candidate(palindrome = \"abacdfgdcaba\") == \"aaacdfgdcaba\"\n assert candidate(palindrome = \"nnnnnnnnna\") == \"annnnnnnna\"\n assert candidate(palindrome = \"aaaaaaaaa\") == \"aaaaaaaab\"\n assert candidate(palindrome = \"abcdddcba\") == \"aacdddcba\"\n assert candidate(palindrome = \"aabbccddeeffgggeeeddccbbaa\") == \"aaabccddeeffgggeeeddccbbaa\"\n assert candidate(palindrome = \"stats\") == \"atats\"\n assert candidate(palindrome = \"aacaaca\") == \"aaaaaca\"\n assert candidate(palindrome = \"reviver\") == \"aeviver\"\n assert candidate(palindrome = \"aabbccddeedccbaa\") == \"aaabccddeedccbaa\"\n assert candidate(palindrome = \"amanaplanacanalpanama\") == \"aaanaplanacanalpanama\"\n assert candidate(palindrome = \"xyzyx\") == \"ayzyx\"\n assert candidate(palindrome = \"ababababab\") == \"aaabababab\"\n assert candidate(palindrome = \"zzzzzzzzz\") == \"azzzzzzzz\"\n assert candidate(palindrome = \"abaababa\") == \"aaaababa\"\n assert candidate(palindrome = \"aaaaaaaaaa\") == \"aaaaaaaaab\"\n assert candidate(palindrome = \"aabbccddeedccbbaa\") == \"aaabccddeedccbbaa\"\n assert candidate(palindrome = \"noonnoon\") == \"aoonnoon\"\n assert candidate(palindrome = \"aabbccddeeffgggeeddccbbaa\") == \"aaabccddeeffgggeeddccbbaa\"\n assert candidate(palindrome = \"reviled\") == \"aeviled\"\n assert candidate(palindrome = \"aabbbaa\") == \"aaabbaa\"\n assert candidate(palindrome = \"aabbccddeeffggfeeddccbbaa\") == \"aaabccddeeffggfeeddccbbaa\"\n assert candidate(palindrome = \"rotator\") == \"aotator\"\n assert candidate(palindrome = \"abccbaa\") == \"aaccbaa\"\n assert candidate(palindrome = \"bbbbb\") == \"abbbb\"\n assert candidate(palindrome = \"aaa\") == \"aab\"\n assert candidate(palindrome = \"aabbccddeccbaa\") == \"aaabccddeccbaa\"\n assert candidate(palindrome = \"ababababa\") == \"aaabababa\"\n assert candidate(palindrome = \"aabbccddeeffgggggggeeeddccbbaa\") == \"aaabccddeeffgggggggeeeddccbbaa\"\n assert candidate(palindrome = \"aaaabaaa\") == \"aaaabaab\"\n assert candidate(palindrome = \"fedcbafedcba\") == \"aedcbafedcba\"\n assert candidate(palindrome = \"abcbaba\") == \"aacbaba\"\n assert candidate(palindrome = \"aaabaaa\") == \"aaabaab\"\n assert candidate(palindrome = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == \"ayxwvutsrqponmlkjihgfedcbaedcba\"\n assert candidate(palindrome = \"sees\") == \"aees\"\n assert candidate(palindrome = \"aabbccddeeffggggggfeeddccbbaa\") == \"aaabccddeeffggggggfeeddccbbaa\"\n assert candidate(palindrome = \"aaaaaaa\") == \"aaaaaab\"\n assert candidate(palindrome = \"bbcb\") == \"abcb\"\n assert candidate(palindrome = \"zyxwvutsrqponmlkjihgfedcbaedcbafghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"ayxwvutsrqponmlkjihgfedcbaedcbafghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(palindrome = \"civic\") == \"aivic\"\n assert candidate(palindrome = \"zzzzzzz\") == \"azzzzzz\"\n assert candidate(palindrome = \"babababababababababababababababababa\") == \"aabababababababababababababababababa\"\n assert candidate(palindrome = \"repaid\") == \"aepaid\"\n assert candidate(palindrome = \"rotorrotor\") == \"aotorrotor\"\n assert candidate(palindrome = \"abcdeedcba\") == \"aacdeedcba\"\n assert candidate(palindrome = \"reeve\") == \"aeeve\"\n assert candidate(palindrome = \"abcddddcba\") == \"aacddddcba\"\n assert candidate(palindrome = \"kayak\") == \"aayak\"\n assert candidate(palindrome = \"reviler\") == \"aeviler\"\n assert candidate(palindrome = \"abcdefedcba\") == \"aacdefedcba\"\n assert candidate(palindrome = \"rotavator\") == \"aotavator\"\n assert candidate(palindrome = \"madamimadam\") == \"aadamimadam\"\n assert candidate(palindrome = \"redivider\") == \"aedivider\"\n assert candidate(palindrome = \"abacabadaba\") == \"aaacabadaba\"\n assert candidate(palindrome = \"abcddcba\") == \"aacddcba\"\n assert candidate(palindrome = \"aaaabaaaa\") == \"aaaabaaab\"\n assert candidate(palindrome = \"leveler\") == \"aeveler\"\n assert candidate(palindrome = \"abababa\") == \"aaababa\"\n assert candidate(palindrome = \"abecba\") == \"aaecba\"\n assert candidate(palindrome = \"zaz\") == \"aaz\"\n assert candidate(palindrome = \"aabbccbaa\") == \"aaabccbaa\"\n assert candidate(palindrome = \"abcdcba\") == \"aacdcba\"\n assert candidate(palindrome = \"aabbccddeeffggggfeeddccbbaa\") == \"aaabccddeeffggggfeeddccbbaa\"\n assert candidate(palindrome = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\") == \"acbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\"\n assert candidate(palindrome = \"anana\") == \"aaana\"\n assert candidate(palindrome = \"bababababa\") == \"aababababa\"\n assert candidate(palindrome = \"zzzzz\") == \"azzzz\"\n assert candidate(palindrome = \"abcaaba\") == \"aacaaba\"\n assert candidate(palindrome = \"bob\") == \"aob\"\n assert candidate(palindrome = \"abaabaaabaabaa\") == \"aaaabaaabaabaa\"\n assert candidate(palindrome = \"deed\") == \"aeed\"\n assert candidate(palindrome = \"detartrated\") == \"aetartrated\"\n assert candidate(palindrome = \"civiccivic\") == \"aiviccivic\"\n assert candidate(palindrome = \"zzzz\") == \"azzz\"\n assert candidate(palindrome = \"repel\") == \"aepel\"\n assert candidate(palindrome = \"deedeed\") == \"aeedeed\"\n", "comparison": "exact"}, "public_tests": ["\"abccba\"", "\"a\""], "hints": ["How to detect if there is impossible to perform the replacement? Only when the length = 1.", "Change the first non 'a' character to 'a'.", "What if the string has only 'a'?", "Change the last character to 'b'."], "metadata": {"canonical_parameter_names": ["palindrome"], "leetcode_dataset_entry_point": "Solution().breakPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:52+00:00", "tests_total": 118, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def breakPalindrome(self, palindrome: str) -> str:", "container": "Solution", "callable": "breakPalindrome", "parameters": [{"name": "palindrome", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1329, "task_id": "sort-the-matrix-diagonally", "difficulty": "Medium", "problem_description": "A 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 reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2].\n\nGiven an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix.\n\nExample 1:\n\nInput: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]\nOutput: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]\n\nExample 2:\n\nInput: mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]\nOutput: [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[22,27,31,36,50,66],[84,28,75,33,55,68]]\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n <= 100\n- 1 <= mat[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1]]) == [[1]]\n assert candidate(mat = [[37, 47, 1, 44], [20, 3, 2, 90], [96, 50, 4, 24]]) == [[3, 2, 1, 44], [20, 4, 24, 90], [96, 50, 37, 47]]\n assert candidate(mat = [[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(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]]\n assert candidate(mat = [[30, 29, 28, 27, 26, 25], [24, 23, 22, 21, 20, 19], [18, 17, 16, 15, 14, 13], [12, 11, 10, 9, 8, 7], [6, 5, 4, 3, 2, 1]]) == [[2, 1, 7, 13, 19, 25], [3, 9, 8, 14, 20, 26], [4, 10, 16, 15, 21, 27], [5, 11, 17, 23, 22, 28], [6, 12, 18, 24, 30, 29]]\n assert candidate(mat = [[30, 29, 19, 53, 22], [47, 27, 45, 54, 30], [28, 42, 23, 45, 52], [40, 11, 52, 33, 46], [15, 50, 46, 32, 48]]) == [[23, 29, 19, 30, 22], [32, 27, 45, 52, 53], [11, 42, 30, 45, 54], [40, 28, 47, 33, 46], [15, 50, 46, 52, 48]]\n assert candidate(mat = [[11, 25, 66, 1, 69, 7], [23, 55, 17, 45, 15, 52], [75, 31, 36, 44, 58, 8], [22, 27, 33, 25, 68, 4], [84, 28, 14, 11, 5, 50]]) == [[5, 17, 4, 1, 52, 7], [11, 11, 25, 45, 8, 69], [14, 23, 25, 44, 58, 15], [22, 27, 31, 36, 50, 66], [84, 28, 75, 33, 55, 68]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [[1, 4, 7], [2, 5, 8], [3, 6, 9]]\n assert candidate(mat = [[3, 3, 1, 1], [2, 2, 1, 2], [1, 1, 1, 2]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(mat = [[100, 99, 98], [97, 96, 95], [94, 93, 92]]) == [[92, 95, 98], [93, 96, 99], [94, 97, 100]]\n assert candidate(mat = [[10, 9, 8, 7], [6, 5, 4, 3], [2, 1, 1, 1]]) == [[1, 1, 3, 7], [1, 5, 4, 8], [2, 6, 10, 9]]\n assert candidate(mat = [[37, 71], [58, 62]]) == [[37, 71], [58, 62]]\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, 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(mat = [[1, 10, 3, 7, 5], [6, 2, 8, 4, 1], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]) == [[1, 8, 3, 1, 5], [6, 2, 10, 4, 7], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]\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, 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]]) == [[1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92], [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [4, 14, 24, 34, 44, 54, 64, 74, 84, 94], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [6, 16, 26, 36, 46, 56, 66, 76, 86, 96], [7, 17, 27, 37, 47, 57, 67, 77, 87, 97], [8, 18, 28, 38, 48, 58, 68, 78, 88, 98], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]\n assert candidate(mat = [[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]]) == [[75, 80, 85, 90, 95], [76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99]]\n assert candidate(mat = [[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(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, 2, 4, 6, 8, 10, 12, 14], [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15], [3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 1], [4, 6, 8, 10, 12, 14, 1, 2, 3, 5, 7, 9, 11, 13, 15], [5, 7, 9, 11, 13, 15, 2, 3, 4, 6, 8, 10, 12, 14, 1], [6, 8, 10, 12, 14, 1, 2, 3, 4, 5, 7, 9, 11, 13, 15]]) == [[1, 1, 2, 2, 1, 3, 2, 4, 1, 5, 1, 3, 2, 1, 15], [2, 2, 2, 3, 3, 4, 6, 5, 7, 6, 8, 4, 12, 13, 14], [1, 3, 3, 3, 4, 4, 5, 6, 7, 7, 6, 10, 10, 12, 14], [2, 1, 6, 5, 4, 5, 6, 5, 7, 8, 8, 9, 11, 11, 15], [3, 5, 4, 9, 8, 7, 9, 7, 8, 9, 8, 10, 9, 14, 13], [4, 6, 8, 7, 12, 11, 10, 12, 11, 9, 10, 9, 11, 12, 15], [5, 7, 9, 11, 10, 15, 14, 13, 12, 11, 10, 11, 12, 14, 13], [6, 8, 10, 12, 14, 13, 15, 14, 13, 15, 14, 13, 15, 13, 15]]\n assert candidate(mat = [[1, 9, 3, 7, 5], [6, 2, 8, 4, 10], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]) == [[1, 8, 3, 7, 5], [6, 2, 9, 4, 10], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]\n assert candidate(mat = [[15, 25, 35, 45, 55], [14, 24, 34, 44, 54], [13, 23, 33, 43, 53], [12, 22, 32, 42, 52], [11, 21, 31, 41, 51]]) == [[15, 25, 35, 45, 55], [14, 24, 34, 44, 54], [13, 23, 33, 43, 53], [12, 22, 32, 42, 52], [11, 21, 31, 41, 51]]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(mat = [[50, 30, 10, 90], [80, 60, 40, 20], [70, 50, 30, 10], [60, 40, 20, 80], [50, 30, 10, 70], [40, 20, 80, 60], [30, 10, 70, 50]]) == [[30, 10, 10, 90], [20, 50, 30, 20], [10, 50, 60, 40], [30, 40, 70, 80], [20, 50, 60, 80], [10, 50, 60, 70], [30, 40, 70, 80]]\n assert candidate(mat = [[9, 7, 5, 3, 1], [10, 8, 6, 4, 2], [11, 9, 7, 5, 3], [12, 10, 8, 6, 4], [13, 11, 9, 7, 5]]) == [[5, 4, 3, 2, 1], [7, 6, 5, 4, 3], [9, 8, 7, 6, 5], [11, 10, 9, 8, 7], [13, 12, 11, 10, 9]]\n assert candidate(mat = [[1, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]) == [[1, 4, 5, 6, 7, 10], [2, 3, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == [[1, 3, 4, 2, 9], [10, 8, 6, 5, 7], [11, 13, 14, 12, 19], [20, 18, 16, 15, 17]]\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, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 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]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92, 91], [1, 2, 3, 4, 5, 6, 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, 3, 4, 5, 6, 7, 8, 9, 10, 91], [1, 13, 14, 15, 16, 17, 18, 19, 20, 92], [11, 12, 24, 25, 26, 27, 28, 29, 30, 93], [21, 22, 23, 100, 99, 98, 97, 96, 95, 94]]\n assert candidate(mat = [[50, 40, 30, 20, 10], [55, 45, 35, 25, 15], [60, 50, 40, 30, 20], [65, 55, 45, 35, 25], [70, 60, 50, 40, 30]]) == [[30, 25, 20, 15, 10], [40, 35, 30, 25, 20], [50, 45, 40, 35, 30], [60, 55, 50, 45, 40], [70, 65, 60, 55, 50]]\n assert candidate(mat = [[1, 9, 2, 8, 3, 7, 4, 6, 5], [2, 8, 3, 7, 4, 6, 5, 9, 1], [3, 7, 4, 6, 5, 9, 1, 2, 8], [4, 6, 5, 9, 1, 2, 8, 3, 7], [5, 9, 1, 2, 8, 3, 7, 4, 6]]) == [[1, 1, 2, 4, 1, 2, 4, 1, 5], [2, 4, 3, 2, 4, 3, 5, 8, 6], [1, 2, 8, 3, 5, 8, 3, 7, 9], [4, 3, 5, 8, 6, 7, 8, 6, 7], [5, 9, 6, 7, 9, 9, 7, 9, 6]]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]) == [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]\n assert candidate(mat = [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13], [21, 20, 19, 18, 17]]) == [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13], [21, 20, 19, 18, 17]]\n assert candidate(mat = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == [[10, 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(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, 2, 3, 4, 5, 6]]) == [[4, 3, 2, 8, 14, 20], [4, 5, 6, 9, 15, 21], [3, 5, 11, 10, 16, 22], [2, 6, 12, 18, 17, 23], [1, 7, 13, 19, 25, 24]]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [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, 60, 59, 58, 57, 56, 55]]) == [[12, 11, 10, 9, 8, 7, 6, 17, 28, 39, 60], [1, 24, 23, 22, 21, 20, 19, 18, 29, 40, 59], [2, 13, 36, 35, 34, 33, 32, 31, 30, 41, 58], [3, 14, 25, 48, 47, 46, 45, 44, 43, 42, 57], [4, 15, 26, 37, 50, 51, 52, 53, 54, 55, 56], [5, 16, 27, 38, 49, 60, 59, 58, 57, 56, 55]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]]\n assert candidate(mat = [[9, 1, 4, 7, 3, 8], [6, 5, 2, 9, 1, 4], [3, 8, 5, 2, 9, 1], [8, 3, 9, 1, 4, 7], [1, 4, 7, 3, 8, 6]]) == [[1, 1, 4, 1, 3, 8], [3, 5, 2, 7, 1, 4], [3, 6, 5, 2, 9, 7], [4, 3, 8, 8, 4, 9], [1, 8, 7, 9, 9, 6]]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4], [3, 2, 1, 10, 9, 8, 7], [4, 3, 2, 1, 10, 9, 8], [5, 4, 3, 2, 1, 10, 9], [6, 5, 4, 3, 2, 1, 10]]) == [[2, 1, 8, 7, 6, 5, 4], [3, 2, 1, 10, 9, 8, 7], [4, 3, 2, 1, 10, 9, 8], [5, 4, 3, 2, 1, 10, 9], [6, 5, 4, 3, 10, 9, 10]]\n assert candidate(mat = [[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, 11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24, 25, 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]]) == [[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 65, 66], [3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 63, 82, 83], [2, 21, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 62, 81, 100], [1, 20, 39, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 80, 99], [18, 19, 38, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 98], [35, 36, 37, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]]\n assert candidate(mat = [[14, 13], [12, 11], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == [[11, 13], [9, 14], [7, 12], [5, 10], [3, 8], [1, 6], [2, 4]]\n assert candidate(mat = [[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, 2, 3, 4, 5, 6, 7, 8]]) == [[34, 42, 50, 58, 66, 74, 82, 90], [26, 43, 51, 59, 67, 75, 83, 91], [18, 35, 52, 60, 68, 76, 84, 92], [10, 27, 44, 61, 69, 77, 85, 93], [2, 19, 36, 53, 70, 78, 86, 94], [3, 11, 28, 45, 62, 79, 87, 95], [4, 8, 20, 37, 54, 71, 88, 96], [5, 7, 12, 29, 46, 63, 80, 97], [5, 6, 13, 21, 38, 55, 72, 89], [4, 6, 14, 22, 30, 47, 64, 81], [3, 7, 15, 23, 31, 39, 56, 73], [2, 8, 16, 24, 32, 40, 48, 65], [1, 9, 17, 25, 33, 41, 49, 57]]\n assert candidate(mat = [[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(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]]) == [[76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99], [80, 85, 90, 95, 100]]\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]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 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(mat = [[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, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]) == [[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, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]\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]]) == [[1, 2, 3, 4, 5], [6, 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(mat = [[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]) == [[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]\n assert candidate(mat = [[5, 20, 30, 40, 50], [15, 10, 35, 45, 55], [20, 25, 5, 50, 60], [25, 35, 45, 15, 65]]) == [[5, 20, 30, 40, 50], [15, 5, 35, 45, 55], [20, 25, 10, 50, 60], [25, 35, 45, 15, 65]]\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]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 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(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [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(mat = [[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]]) == [[19, 28, 37, 46, 55, 64, 73, 82, 91], [10, 29, 38, 47, 56, 65, 74, 83, 92], [1, 20, 39, 48, 57, 66, 75, 84, 93], [2, 11, 30, 49, 58, 67, 76, 85, 94], [3, 12, 21, 40, 59, 68, 77, 86, 95], [4, 13, 22, 31, 50, 69, 78, 87, 96], [5, 14, 23, 32, 41, 60, 79, 88, 97], [6, 15, 24, 33, 42, 51, 70, 89, 98], [7, 16, 25, 34, 43, 52, 61, 80, 99], [8, 17, 26, 35, 44, 53, 62, 71, 90], [9, 18, 27, 36, 45, 54, 63, 72, 81]]\n assert candidate(mat = [[99, 22, 33, 11, 44], [55, 66, 77, 88, 99], [10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [15, 25, 35, 45, 55]]) == [[30, 22, 33, 11, 44], [20, 55, 40, 50, 99], [10, 45, 66, 77, 88], [25, 35, 55, 90, 100], [15, 60, 70, 80, 99]]\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, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 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]]\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, 75, 74, 73, 72, 71]]) == [[72, 71, 77, 83, 89, 95], [73, 79, 78, 84, 90, 96], [74, 80, 86, 85, 91, 97], [75, 81, 87, 93, 92, 98], [76, 82, 88, 94, 100, 99]]\n assert candidate(mat = [[4, 3, 2, 1], [5, 9, 8, 7], [6, 10, 11, 12], [7, 6, 5, 4], [8, 7, 6, 5]]) == [[4, 3, 2, 1], [5, 4, 8, 7], [6, 5, 9, 12], [7, 6, 5, 11], [8, 7, 6, 10]]\n assert candidate(mat = [[9, 7, 8, 6, 5, 4], [3, 2, 1, 10, 11, 12], [15, 14, 13, 18, 17, 16], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == [[2, 1, 8, 6, 5, 4], [3, 9, 7, 10, 11, 12], [15, 14, 13, 18, 17, 16], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(mat = [[50, 24, 78, 42, 31], [63, 83, 92, 22, 58], [30, 50, 14, 32, 59], [97, 35, 88, 64, 50]]) == [[14, 24, 22, 42, 31], [50, 50, 32, 59, 58], [30, 63, 64, 50, 78], [97, 35, 88, 83, 92]]\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], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == [[1, 2, 2, 2, 1, 6], [3, 3, 3, 3, 4, 5], [2, 4, 4, 4, 3, 7], [4, 5, 5, 4, 5, 6], [3, 6, 5, 6, 5, 8], [8, 7, 7, 6, 6, 7]]\n assert candidate(mat = [[95, 85, 65, 25, 55, 75, 35, 45, 15], [10, 90, 80, 70, 60, 50, 40, 30, 20], [5, 15, 25, 35, 45, 55, 65, 75, 85]]) == [[25, 35, 45, 25, 50, 40, 30, 20, 15], [10, 90, 80, 65, 55, 55, 75, 35, 45], [5, 15, 95, 85, 70, 60, 65, 75, 85]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]) == [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]\n assert candidate(mat = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 1, 7, 1, 7, 1, 7, 1], [7, 7, 2, 2, 2, 2, 2, 2, 2, 2], [7, 1, 2, 3, 3, 3, 3, 3, 3, 3], [7, 1, 2, 3, 4, 4, 4, 4, 4, 4], [7, 1, 2, 3, 4, 5, 5, 5, 5, 5], [7, 1, 2, 3, 4, 5, 6, 6, 6, 6]]) == [[1, 2, 1, 2, 1, 2, 1, 2, 1, 7], [2, 2, 3, 2, 3, 2, 3, 2, 7, 7], [1, 3, 3, 4, 3, 4, 3, 4, 3, 7], [1, 2, 4, 4, 5, 4, 5, 4, 7, 7], [1, 2, 3, 5, 5, 6, 5, 6, 5, 7], [1, 2, 3, 4, 7, 6, 7, 6, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]]\n assert candidate(mat = [[9, 7, 11, 8, 5, 4], [12, 14, 10, 3, 13, 15], [6, 2, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25]]) == [[9, 7, 3, 8, 5, 4], [2, 14, 10, 11, 13, 15], [6, 12, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25]]\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], [15, 13, 11, 9, 7, 5, 3, 1]]) == [[1, 2, 3, 3, 1, 2, 1, 8], [3, 5, 6, 5, 4, 3, 6, 7], [1, 8, 7, 7, 5, 4, 5, 15], [15, 13, 11, 9, 7, 9, 11, 13]]\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]]) == [[76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99], [80, 85, 90, 95, 100]]\n assert candidate(mat = [[7, 17, 12, 5, 10, 9, 3], [14, 2, 11, 16, 13, 18, 8], [15, 4, 6, 1, 19, 12, 17], [10, 3, 15, 7, 2, 14, 6], [5, 9, 1, 18, 17, 13, 4]]) == [[2, 1, 4, 5, 10, 8, 3], [4, 6, 2, 12, 6, 17, 9], [1, 14, 7, 11, 14, 12, 18], [9, 3, 15, 7, 13, 16, 13], [5, 10, 15, 18, 17, 17, 19]]\n assert candidate(mat = [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13], [20, 19, 18, 17]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13], [20, 19, 18, 17]]\n assert candidate(mat = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3], [3, 2, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3], [3, 2, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3], [3, 2, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3], [3, 2, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3], [3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3], [3, 2, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 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, 2, 2, 3, 3], [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3], [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3], [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3], [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3], [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, 3, 3, 3, 3]]\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, 75, 74, 73, 72, 71]]) == [[72, 71, 77, 83, 89, 95], [73, 79, 78, 84, 90, 96], [74, 80, 86, 85, 91, 97], [75, 81, 87, 93, 92, 98], [76, 82, 88, 94, 100, 99]]\n assert candidate(mat = [[5, 12, 11, 10, 9], [8, 4, 3, 2, 1], [9, 8, 7, 6, 5], [10, 9, 8, 7, 6], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8]]) == [[4, 3, 2, 1, 9], [8, 5, 6, 5, 10], [9, 8, 7, 6, 11], [10, 9, 8, 7, 12], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8]]\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]]) == [[1, 2, 3, 2, 2, 1, 7], [3, 4, 4, 3, 3, 5, 6], [2, 6, 5, 5, 4, 4, 8], [8, 7, 7, 6, 5, 6, 7]]\n assert candidate(mat = [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]\n assert candidate(mat = [[33, 22, 11, 44, 55], [66, 77, 88, 99, 100], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [[3, 4, 5, 44, 55], [2, 9, 10, 11, 100], [1, 8, 15, 22, 99], [6, 7, 14, 33, 88], [11, 12, 13, 20, 77], [16, 17, 18, 19, 66]]\n assert candidate(mat = [[5, 20, 15, 80, 75], [45, 10, 55, 60, 15], [12, 65, 35, 90, 100], [10, 25, 40, 50, 65], [5, 15, 25, 35, 45]]) == [[5, 20, 15, 15, 75], [35, 10, 55, 60, 80], [12, 40, 35, 65, 100], [10, 25, 45, 45, 90], [5, 15, 25, 65, 50]]\n", "comparison": "exact"}, "public_tests": ["[[3,3,1,1],[2,2,1,2],[1,1,1,2]]", "[[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]"], "hints": ["Use a data structure to store all values of each diagonal.", "How to index the data structure with the id of the diagonal?", "All cells in the same diagonal (i,j) have the same difference so we can get the diagonal of a cell using the difference i-j."], "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().diagonalSort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:55+00:00", "tests_total": 81, "tests_dropped": 6, "flags": ["has_images"], "topic_tags": ["array", "sorting", "matrix"]}, "language": "python", "interface": {"raw_signature": "def diagonalSort(self, mat: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "diagonalSort", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1330, "task_id": "reverse-subarray-to-maximize-array-value", "difficulty": "Hard", "problem_description": "You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.\n\nYou are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.\n\nFind maximum possible value of the final array.\n\nExample 1:\n\nInput: nums = [2,3,1,5,4]\nOutput: 10\nExplanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10.\n\nExample 2:\n\nInput: nums = [2,4,9,24,2,1,10]\nOutput: 68\n\nConstraints:\n\n- 2 <= nums.length <= 3 * 10^4\n- -10^5 <= nums[i] <= 10^5\n- The answer is guaranteed to fit in a 32-bit integer.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 230\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(nums = [1, -1, 1, -1, 1]) == 8\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 10\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 800000\n assert candidate(nums = [-10, -5, 0, 5, 10]) == 40\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 230\n assert candidate(nums = [2, 4, 9, 24, 2, 1, 10]) == 68\n assert candidate(nums = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 9\n assert candidate(nums = [-1, 4, -2, 3]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000]) == 600000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 200\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 100000, 1, 100000, 1]) == 399996\n assert candidate(nums = [100, -100, 100, -100]) == 600\n assert candidate(nums = [100000, -100000, 100000, -100000]) == 600000\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000]) == 800000\n assert candidate(nums = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [2, 3, 1, 5, 4]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 38\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 4, 1, 9]) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500]) == 687500\n assert candidate(nums = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10]) == 180\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 6, 4, 2, 0]) == 29\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 580\n assert candidate(nums = [100000, 0, -100000, 100000, 0, -100000, 100000]) == 900000\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, 19, 21, 20]) == 91\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995]) == 11\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) == 38\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 53\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 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]) == 38\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400]) == 2900\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-50000, 50000, -50000, 50000, -50000]) == 400000\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 38\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000]) == 1000000\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]) == 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]) == 0\n assert candidate(nums = [100000, 0, -100000, 0, 100000, 0, -100000, 0, 100000]) == 900000\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 = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 580\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 23\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 53\n assert candidate(nums = [1, -100000, 2, -99999, 3, -99998, 4, -99997, 5, -99996]) == 900013\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 23\n assert candidate(nums = [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, 4, 1, 9]) == 36\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 43\n assert candidate(nums = [10000, 1000, 100, 10, 1, 0, -1, -10, -100, -1000, -10000]) == 31000\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6, -4, -5, -6, 7, 8, 9]) == 70\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 28\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]) == 219\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 38\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000]) == 1800000\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 800000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 23\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 675\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 17\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 320\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [-5, 5, -15, 15, -25, 25, -35, 35, -45, 45, -55, 55]) == 710\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 6, 4, 3, 2, 1]) == 59\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 107\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == 38\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 33\n assert candidate(nums = [1, 2, 3, 100, 3, 2, 1, 99, 2, 1, 0]) == 399\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, -10, 20, -20, 30, -30, 40, -40]) == 380\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 68\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000]) == 1400000\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000]) == 0\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991]) == 23\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 36\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 236\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 10000, 6, 7, 8, 9, 10]) == 20011\n assert candidate(nums = [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]) == 230\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 53\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 5800\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000]) == 12000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 859\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9]) == 48\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 140\n", "comparison": "exact"}, "public_tests": ["[2,3,1,5,4]", "[2,4,9,24,2,1,10]"], "hints": ["What's the score after reversing a sub-array [L, R] ?", "It's the score without reversing it + abs(a[R] - a[L-1]) + abs(a[L] - a[R+1]) - abs(a[L] - a[L-1]) - abs(a[R] - a[R+1])", "How to maximize that formula given that abs(x - y) = max(x - y, y - x) ?", "This can be written as max(max(a[R] - a[L - 1], a[L - 1] - a[R]) + max(a[R + 1] - a[L], a[L] - a[R + 1]) - value(L) - value(R + 1)) over all L < R where value(i) = abs(a[i] - a[i-1])", "This can be divided into 4 cases."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxValueAfterReverse", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:57+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxValueAfterReverse(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxValueAfterReverse", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1331, "task_id": "rank-transform-of-an-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, replace each element with its rank.\n\nThe rank represents how large the element is. The rank has the following rules:\n\n- Rank is an integer starting from 1.\n- The larger the element, the larger the rank. If two elements are equal, their rank must be the same.\n- Rank should be as small as possible.\n\nExample 1:\n\nInput: arr = [40,10,20,30]\nOutput: [4,1,2,3]\nExplanation: 40 is the largest element. 10 is the smallest. 20 is the second smallest. 30 is the third smallest.\n\nExample 2:\n\nInput: arr = [100,100,100]\nOutput: [1,1,1]\nExplanation: Same elements share the same rank.\n\nExample 3:\n\nInput: arr = [37,12,28,9,100,56,80,5,12]\nOutput: [5,3,4,2,8,6,7,1,3]\n\nConstraints:\n\n- 0 <= arr.length <= 10^5\n- -10^9 <= arr[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [-10, 100, 0, 5, 3]) == [1, 5, 2, 4, 3]\n assert candidate(arr = [-10, -20, -30, -40, -50]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(arr = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1000000000, -1000000000, 0, 500000000, -500000000]) == [5, 1, 3, 4, 2]\n assert candidate(arr = [1]) == [1]\n assert candidate(arr = [40, 10, 20, 30]) == [4, 1, 2, 3]\n assert candidate(arr = [1000000000, -1000000000, 0]) == [3, 1, 2]\n assert candidate(arr = [37, 12, 28, 9, 100, 56, 80, 5, 12]) == [5, 3, 4, 2, 8, 6, 7, 1, 3]\n assert candidate(arr = []) == []\n assert candidate(arr = [100, 100, 100]) == [1, 1, 1]\n assert candidate(arr = [1, 1, 2, 2, 3, 3]) == [1, 1, 2, 2, 3, 3]\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\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, 10, 12, 9, 13, 8, 14, 7, 15, 6, 16, 5, 17, 4, 18, 3, 19, 2, 20, 1]\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]\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\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]) == [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(arr = [100, 200, 100, 300, 200, 400, 300, 500]) == [1, 2, 1, 3, 2, 4, 3, 5]\n assert candidate(arr = [123456789, 987654321, 123456789, 987654321, 456789123]) == [1, 3, 1, 3, 2]\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]) == [1, 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(arr = [50, 20, 30, 40, 10, 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]) == [5, 2, 3, 4, 1, 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(arr = [10, 20, 20, 10, 30, 40, 50, 50, 40, 30]) == [1, 2, 2, 1, 3, 4, 5, 5, 4, 3]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, -1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\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, 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, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5]\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]) == [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(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, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 7, 9, 8, 10, 11, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 3, 2, 6, 5, 4, 7, 9, 8, 10, 11, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [-1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 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]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [1, 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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000, 999, 1001, 998, 1002, 997, 1003, 996, 1004]) == [5, 4, 6, 3, 7, 2, 8, 1, 9]\n assert candidate(arr = [1, 3, 2, 1, 4, 2, 3, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 2, 1, 4, 2, 3, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [4, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(arr = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [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(arr = [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(arr = [1000000000, -1000000000, 1000000000, -1000000000, 0, 0, 500000000, -500000000]) == [5, 1, 5, 1, 3, 3, 4, 2]\n assert candidate(arr = [-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]\n assert candidate(arr = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000, 125000000, -125000000, 62500000, -62500000]) == [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(arr = [5, 2, 9, 5, 9, 1, 5, 7, 8, 9, 1, 2, 3, 4, 6, 7, 8, 9]) == [5, 2, 9, 5, 9, 1, 5, 7, 8, 9, 1, 2, 3, 4, 6, 7, 8, 9]\n assert candidate(arr = [10, 20, 20, 10, 30, 40, 30, 20, 50, 60, 50, 40, 70, 80, 70, 60, 90, 100, 90, 80]) == [1, 2, 2, 1, 3, 4, 3, 2, 5, 6, 5, 4, 7, 8, 7, 6, 9, 10, 9, 8]\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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(arr = [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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\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, 10, 12, 9, 13, 8, 14, 7, 15, 6, 16, 5, 17, 4, 18, 3, 19, 2, 20, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 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]\n assert candidate(arr = [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4]) == [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4]\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 1, 4, 2, 1, 3, 5, 4]) == [5, 3, 1, 4, 2, 1, 3, 5, 4]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 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]\n assert candidate(arr = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1]) == [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]\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]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [50, 50, 40, 40, 30, 30, 20, 20, 10, 10, 5, 5, 1, 1, -1, -1, -5, -5, -10, -10]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr = [987654321, 123456789, 987654321, 123456789, 987654321]) == [2, 1, 2, 1, 2]\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]) == [1, 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(arr = [1000000, 999999, 1000001, 999998, 1000002, 999997, 1000003, 999996, 1000004, 999995]) == [6, 5, 7, 4, 8, 3, 9, 2, 10, 1]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [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]\n assert candidate(arr = [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]\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]) == [1, 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(arr = [-999999999, -888888888, -777777777, -666666666, -555555555, -444444444, -333333333, -222222222, -111111111, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 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]\n assert candidate(arr = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [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]) == [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [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]\n assert candidate(arr = [-1000000000, -999999999, -999999998, -999999997, -999999996, -999999995, -999999994, -999999993, -999999992, -999999991]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 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]\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, 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]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 5, 2, 3, 3, 9, 0, 123, -1, -100]) == [6, 5, 6, 4, 5, 5, 7, 3, 8, 2, 1]\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]) == [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 5, 2, 4, 3, 5, 1]) == [5, 3, 5, 2, 4, 3, 5, 1]\n assert candidate(arr = [-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]\n assert candidate(arr = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(arr = [100, 50, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\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]) == [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(arr = [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(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]) == [1, 2, 3, 4, 5, 6, 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(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(arr = [5, 3, 1, 2, 4, 3, 2, 1]) == [5, 3, 1, 2, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]) == [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]\n assert candidate(arr = [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, 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]\n assert candidate(arr = [5, 3, 1, 2, 4, 1, 3, 5, 2, 4, 6, 7, 8, 6, 7, 8, 9, 10, 9, 10]) == [5, 3, 1, 2, 4, 1, 3, 5, 2, 4, 6, 7, 8, 6, 7, 8, 9, 10, 9, 10]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [999999999, 1000000000, -1000000000, -999999999, 500000000, -500000000, 1, -1]) == [7, 8, 1, 2, 6, 3, 5, 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]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [-1, -2, -3, -1, -2, -3, -1, -2, -3]) == [3, 2, 1, 3, 2, 1, 3, 2, 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]) == [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]\n assert candidate(arr = [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, 26, 27, 28, 29, 30]) == [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, 26, 27, 28, 29, 30]\n assert candidate(arr = [1000, 999, 1000, 998, 1000, 997, 1000, 996, 1000, 995, 1000, 994, 1000, 993, 1000]) == [8, 7, 8, 6, 8, 5, 8, 4, 8, 3, 8, 2, 8, 1, 8]\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, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000000, 999999, 1000001, 1000000, 999998]) == [3, 2, 4, 3, 1]\n", "comparison": "exact"}, "public_tests": ["[40,10,20,30]", "[100,100,100]", "[37,12,28,9,100,56,80,5,12]"], "hints": ["Use a temporary array to copy the array and sort it.", "The rank of each element is the number of unique elements smaller than it in the sorted array plus one."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().arrayRankTransform", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:16:59+00:00", "tests_total": 113, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "sorting"]}, "language": "python", "interface": {"raw_signature": "def arrayRankTransform(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "arrayRankTransform", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1332, "task_id": "remove-palindromic-subsequences", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.\n\nReturn the minimum number of steps to make the given string empty.\n\nA string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.\n\nA string is called palindrome if is one that reads the same backward as well as forward.\n\nExample 1:\n\nInput: s = \"ababa\"\nOutput: 1\nExplanation: s is already a palindrome, so its entirety can be removed in a single step.\n\nExample 2:\n\nInput: s = \"abb\"\nOutput: 2\nExplanation: \"abb\" -> \"bb\" -> \"\".\nRemove palindromic subsequence \"a\" then \"bb\".\n\nExample 3:\n\nInput: s = \"baabb\"\nOutput: 2\nExplanation: \"baabb\" -> \"b\" -> \"\".\nRemove palindromic subsequence \"baab\" then \"b\".\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- s[i] is either 'a' or 'b'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"b\") == 1\n assert candidate(s = \"aabbab\") == 2\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"aababb\") == 2\n assert candidate(s = \"abbaab\") == 2\n assert candidate(s = \"ab\") == 2\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"ababa\") == 1\n assert candidate(s = \"bbaabaaa\") == 2\n assert candidate(s = \"aabbaa\") == 1\n assert candidate(s = \"abb\") == 2\n assert candidate(s = \"baabb\") == 2\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"bbbb\") == 1\n assert candidate(s = \"abab\") == 2\n assert candidate(s = \"baaaabb\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 2\n assert candidate(s = \"babbabbbaba\") == 2\n assert candidate(s = \"baabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 2\n assert candidate(s = \"bababababababababa\") == 2\n assert candidate(s = \"bbaabbababb\") == 2\n assert candidate(s = \"baaabaaaaaabbaaab\") == 2\n assert candidate(s = \"aabbaabbaabb\") == 2\n assert candidate(s = \"baabbaab\") == 1\n assert candidate(s = \"baaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababb\") == 2\n assert candidate(s = \"abaababaababaababa\") == 2\n assert candidate(s = \"aaabbaabbaabbaabba\") == 2\n assert candidate(s = \"aabaaaab\") == 2\n assert candidate(s = \"bbaaabbaaabbaaabbaa\") == 2\n assert candidate(s = \"aabbabbaa\") == 1\n assert candidate(s = \"bababa\") == 2\n assert candidate(s = \"aaaaaaaabbaaaaaaa\") == 2\n assert candidate(s = \"aaabbbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbb\") == 2\n assert candidate(s = \"aabbbbbaaa\") == 2\n assert candidate(s = \"abbbabbbabbb\") == 2\n assert candidate(s = \"abbaababbababbab\") == 2\n assert candidate(s = \"aabbaabbabbaabbaabbabbaabbabbaabbaabbabbaabbabbaabbaabbabbaabbaabbabbaabbaabbabbaabbaabbabbaabbaabb\") == 2\n assert candidate(s = \"baabbaabbbaaba\") == 2\n assert candidate(s = \"bbbbbaaaaaaaaabbbb\") == 2\n assert candidate(s = \"abbaabbbaabbaabbba\") == 2\n assert candidate(s = \"aaabbbabaabbaa\") == 2\n assert candidate(s = \"aaabbbbaaaaabbbbaa\") == 2\n assert candidate(s = \"bbbbbaaaaa\") == 2\n assert candidate(s = \"aabbbaaabbbaa\") == 1\n assert candidate(s = \"bbbbbaaabbbbbaaabbbb\") == 2\n assert candidate(s = \"baababababababababab\") == 2\n assert candidate(s = \"bbbaabbaabbaabbaabbb\") == 1\n assert candidate(s = \"bbbbbbbbbba\") == 2\n assert candidate(s = \"bbaabbaabbaabbaab\") == 2\n assert candidate(s = \"abbbabbbabbbbaba\") == 2\n assert candidate(s = \"babbabbabbabbabbab\") == 1\n assert candidate(s = \"abaaabbaaabbbaaaab\") == 2\n assert candidate(s = \"aabbaabbaab\") == 2\n assert candidate(s = \"aabbaabbbaabbaabbba\") == 2\n assert candidate(s = \"bbaabbaab\") == 2\n assert candidate(s = \"bbaabbbaaabb\") == 2\n assert candidate(s = \"bbbbbbbbbbb\") == 1\n assert candidate(s = \"abbaaabaaa\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"ababbbababbbabaabb\") == 2\n assert candidate(s = \"abbaabbaabbaabba\") == 1\n assert candidate(s = \"aabbbbaaabaaaabbbb\") == 2\n assert candidate(s = \"abbbabbbabbbabbbabbb\") == 2\n assert candidate(s = \"babababababababab\") == 1\n assert candidate(s = \"abbaabbbaabbaabbaa\") == 2\n assert candidate(s = \"bbaabaaaabb\") == 2\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"bababababa\") == 2\n assert candidate(s = \"aaabbbaaabbbbaaa\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbb\") == 2\n assert candidate(s = \"aabbaaabbbaaabbaaa\") == 2\n assert candidate(s = \"ababababababab\") == 2\n assert candidate(s = \"aaaaaa\") == 1\n assert candidate(s = \"abababababa\") == 1\n assert candidate(s = \"abababababababab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaa\") == 1\n assert candidate(s = \"baaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaa\") == 2\n assert candidate(s = \"abababababab\") == 2\n assert candidate(s = \"ababababababababab\") == 2\n assert candidate(s = \"aabaaabbaaaab\") == 2\n assert candidate(s = \"abababbabababababab\") == 2\n assert candidate(s = \"baaaabbbaabb\") == 2\n assert candidate(s = \"bbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaa\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"bbbababaabbabababb\") == 2\n assert candidate(s = \"bbbbabbbbb\") == 2\n assert candidate(s = \"aaaaaaabbbbb\") == 2\n assert candidate(s = \"bbaabbbaa\") == 2\n assert candidate(s = \"baabbaaabbbaabbaab\") == 2\n assert candidate(s = \"abbbbbba\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"babbbbabbbbabbbbab\") == 1\n assert candidate(s = \"abababababababababababababab\") == 2\n assert candidate(s = \"aabbbaaaabbbbaa\") == 2\n assert candidate(s = \"abaabaabaabaabaaba\") == 1\n assert candidate(s = \"aabbaabbbaaabbbaab\") == 2\n assert candidate(s = \"aabababababa\") == 2\n assert candidate(s = \"aaaabbbb\") == 2\n assert candidate(s = \"abbaabbbaabbaa\") == 2\n assert candidate(s = \"ababababababababababab\") == 2\n assert candidate(s = \"baabbaabbaabbaab\") == 1\n assert candidate(s = \"ababbababbab\") == 2\n assert candidate(s = \"abababababababababab\") == 2\n assert candidate(s = \"abaabaabaabaabaabaa\") == 2\n assert candidate(s = \"abababab\") == 2\n assert candidate(s = \"bbbbbaaabbbbabab\") == 2\n assert candidate(s = \"bababababababa\") == 2\n assert candidate(s = \"babababab\") == 1\n assert candidate(s = \"aabbabbbabaabbabbb\") == 2\n assert candidate(s = \"abababa\") == 1\n assert candidate(s = \"aabbbbbaa\") == 1\n assert candidate(s = \"bbbaaaabbbbbaaaabb\") == 2\n assert candidate(s = \"aabbaabbaabbaabbaabbaab\") == 2\n assert candidate(s = \"ababbbabaabab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaa\") == 2\n assert candidate(s = \"babab\") == 1\n assert candidate(s = \"abababababababababababa\") == 1\n assert candidate(s = \"aabbaabbbaa\") == 2\n assert candidate(s = \"babababababababababa\") == 2\n assert candidate(s = \"abbabbabb\") == 2\n assert candidate(s = \"bbbbbaaaabaaaabbbb\") == 2\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaa\") == 2\n assert candidate(s = \"ababababbababa\") == 2\n assert candidate(s = \"ababbbaba\") == 1\n assert candidate(s = \"abababaabbabababab\") == 2\n assert candidate(s = \"bbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"aabbaabbaabbaabbaa\") == 1\n assert candidate(s = \"aaaaabbbbbaaaa\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbaaaaaaaaa\") == 2\n assert candidate(s = \"aabbaabbabbaaabb\") == 2\n assert candidate(s = \"bbaabbaabbaa\") == 2\n assert candidate(s = \"aabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabb\") == 2\n assert candidate(s = \"bababbbabababbbaba\") == 2\n assert candidate(s = \"baabbaabbaabba\") == 2\n assert candidate(s = \"ababab\") == 2\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"ababbbbaababbbbaabab\") == 2\n assert candidate(s = \"bbaaabaaabaaaaabbb\") == 2\n assert candidate(s = \"bababababab\") == 1\n assert candidate(s = \"bababababababab\") == 1\n assert candidate(s = \"bbaaaabbbbaaa\") == 2\n assert candidate(s = \"bbbaabbbbabbbabbbba\") == 2\n assert candidate(s = \"abbaabbaabba\") == 1\n assert candidate(s = \"bbaabbaabbaabbaabbaabbaab\") == 2\n assert candidate(s = \"abaababa\") == 2\n assert candidate(s = \"ababbbababbbababbbab\") == 2\n assert candidate(s = \"ababbababbabab\") == 2\n assert candidate(s = \"baaaaab\") == 1\n assert candidate(s = \"aababbabaab\") == 2\n assert candidate(s = \"aabbaaabbaa\") == 1\n assert candidate(s = \"abababababababababa\") == 1\n assert candidate(s = \"aaaaaaaaabbbbbbbbb\") == 2\n assert candidate(s = \"bbbaaabbbbaaaabbba\") == 2\n assert candidate(s = \"bbaaaaabbbbba\") == 2\n assert candidate(s = \"abbbbaaaaabbba\") == 2\n assert candidate(s = \"abbaabba\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"aabbaaaabbbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbbaaaabb\") == 2\n assert candidate(s = \"abbbbabbbbabbbbabbbb\") == 2\n assert candidate(s = \"ababababa\") == 1\n assert candidate(s = \"abababbabaabbababbab\") == 2\n assert candidate(s = \"babbbbbbbabbbbbbb\") == 2\n assert candidate(s = \"bbaaaaaabbbaaaaaab\") == 2\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababab\") == 2\n assert candidate(s = \"bbbbbaaaaabbbbbaaaaa\") == 2\n assert candidate(s = \"ababbababa\") == 2\n assert candidate(s = \"babababa\") == 2\n assert candidate(s = \"aababbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabb\") == 2\n assert candidate(s = \"baabbaabbaab\") == 1\n assert candidate(s = \"ababbbababbbabaab\") == 2\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 2\n", "comparison": "exact"}, "public_tests": ["\"ababa\"", "\"abb\"", "\"baabb\""], "hints": ["Use the fact that string contains only 2 characters.", "Are subsequences composed of only one type of letter always palindrome strings ?"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removePalindromeSub", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:02+00:00", "tests_total": 172, "tests_dropped": 1, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def removePalindromeSub(self, s: str) -> int:", "container": "Solution", "callable": "removePalindromeSub", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1333, "task_id": "filter-restaurants-by-vegan-friendly-price-and-distance", "difficulty": "Medium", "problem_description": "Given the array restaurants where restaurants[i] = [id_i, rating_i, veganFriendly_i, price_i, distance_i]. You have to filter the restaurants using three filters.\n\nThe veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendly_i set to true) or false (meaning you can include any restaurant). In addition, you have the filters maxPrice and maxDistance which are the maximum value for price and distance of restaurants you should consider respectively.\n\nReturn the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id from highest to lowest. For simplicity veganFriendly_i and veganFriendly take value 1 when it is true, and 0 when it is false.\n\nExample 1:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 1, maxPrice = 50, maxDistance = 10\nOutput: [3,1,5]\nExplanation:\nThe restaurants are:\nRestaurant 1 [id=1, rating=4, veganFriendly=1, price=40, distance=10]\nRestaurant 2 [id=2, rating=8, veganFriendly=0, price=50, distance=5]\nRestaurant 3 [id=3, rating=8, veganFriendly=1, price=30, distance=4]\nRestaurant 4 [id=4, rating=10, veganFriendly=0, price=10, distance=3]\nRestaurant 5 [id=5, rating=1, veganFriendly=1, price=15, distance=1]\nAfter filter restaurants with veganFriendly = 1, maxPrice = 50 and maxDistance = 10 we have restaurant 3, restaurant 1 and restaurant 5 (ordered by rating from highest to lowest).\n\nExample 2:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 50, maxDistance = 10\nOutput: [4,3,2,1,5]\nExplanation: The restaurants are the same as in example 1, but in this case the filter veganFriendly = 0, therefore all restaurants are considered.\n\nExample 3:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 30, maxDistance = 3\nOutput: [4,5]\n\nConstraints:\n\n- 1 <= restaurants.length <= 10^4\n- restaurants[i].length == 5\n- 1 <= id_i, rating_i, price_i, distance_i<= 10^5\n- 1 <= maxPrice, maxDistance <= 10^5\n- veganFriendly_i and veganFriendly are 0 or 1.\n- All id_i are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 50,maxDistance = 10) == [4, 3, 2, 1, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 30,maxDistance = 3) == [4, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 1,maxPrice = 50,maxDistance = 10) == [3, 1, 5]\n assert candidate(restaurants = [[100, 95, 1, 10, 1], [200, 94, 0, 20, 2], [300, 93, 1, 30, 3], [400, 92, 0, 40, 4], [500, 91, 1, 50, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 5) == [100, 300, 500]\n assert candidate(restaurants = [[101, 9, 1, 25, 7], [102, 7, 0, 35, 12], [103, 9, 1, 20, 5], [104, 5, 0, 20, 8], [105, 9, 1, 20, 5], [106, 8, 1, 30, 3], [107, 6, 0, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [105, 103, 101, 106]\n assert candidate(restaurants = [[1001, 45, 1, 30, 12], [2002, 65, 0, 20, 6], [3003, 50, 1, 25, 7], [4004, 40, 0, 15, 4], [5005, 75, 1, 5, 2], [6006, 55, 0, 40, 22], [7007, 45, 1, 10, 16], [8008, 35, 0, 25, 12], [9009, 25, 1, 35, 22], [10010, 80, 1, 10, 6]],veganFriendly = 0,maxPrice = 45,maxDistance = 20) == [10010, 5005, 2002, 3003, 7007, 1001, 4004, 8008]\n assert candidate(restaurants = [[11, 3, 1, 20, 10], [12, 8, 1, 18, 8], [13, 5, 0, 15, 7], [14, 7, 0, 12, 6], [15, 9, 1, 9, 5]],veganFriendly = 1,maxPrice = 20,maxDistance = 10) == [15, 12, 11]\n assert candidate(restaurants = [[401, 5, 1, 10, 10], [402, 6, 1, 15, 9], [403, 7, 1, 20, 8], [404, 8, 1, 25, 7], [405, 9, 1, 30, 6], [406, 10, 1, 35, 5]],veganFriendly = 1,maxPrice = 20,maxDistance = 7) == []\n assert candidate(restaurants = [[101, 99, 1, 10, 5], [202, 98, 0, 20, 3], [303, 99, 1, 10, 2], [404, 98, 0, 25, 5], [505, 97, 1, 15, 4], [606, 98, 0, 10, 4]],veganFriendly = 1,maxPrice = 15,maxDistance = 5) == [303, 101, 505]\n assert candidate(restaurants = [[401, 10, 0, 10, 1], [402, 9, 1, 15, 2], [403, 8, 0, 20, 3], [404, 7, 1, 25, 4], [405, 6, 0, 30, 5], [406, 5, 1, 12, 6]],veganFriendly = 1,maxPrice = 25,maxDistance = 5) == [402, 404]\n assert candidate(restaurants = [[10, 9, 1, 15, 5], [11, 7, 0, 20, 6], [12, 9, 1, 18, 3], [13, 8, 0, 25, 4], [14, 7, 1, 10, 2], [15, 10, 0, 5, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [12, 10, 14]\n assert candidate(restaurants = [[30, 10, 1, 10, 1], [31, 9, 0, 15, 2], [32, 8, 1, 20, 3], [33, 7, 1, 25, 4], [34, 6, 0, 30, 5], [35, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [30, 32, 33]\n assert candidate(restaurants = [[26, 2, 1, 40, 10], [27, 8, 0, 35, 9], [28, 7, 1, 30, 8], [29, 9, 0, 25, 7], [30, 6, 1, 20, 6]],veganFriendly = 0,maxPrice = 35,maxDistance = 9) == [29, 27, 28, 30]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [505, 303, 101]\n assert candidate(restaurants = [[101, 50, 1, 10, 5], [202, 70, 0, 20, 3], [303, 70, 1, 10, 2], [404, 80, 0, 25, 5], [505, 60, 1, 15, 4], [606, 60, 0, 10, 4]],veganFriendly = 1,maxPrice = 15,maxDistance = 4) == [303, 505]\n assert candidate(restaurants = [[24, 9, 1, 20, 5], [25, 10, 0, 25, 3], [26, 8, 1, 15, 2], [27, 7, 1, 10, 1], [28, 6, 0, 5, 1], [29, 5, 1, 30, 4]],veganFriendly = 1,maxPrice = 20,maxDistance = 3) == [26, 27]\n assert candidate(restaurants = [[1, 100, 1, 1, 1], [2, 100, 1, 2, 2], [3, 100, 1, 3, 3], [4, 100, 1, 4, 4], [5, 100, 1, 5, 5], [6, 100, 1, 6, 6], [7, 100, 1, 7, 7], [8, 100, 1, 8, 8], [9, 100, 1, 9, 9], [10, 100, 1, 10, 10]],veganFriendly = 1,maxPrice = 5,maxDistance = 5) == [5, 4, 3, 2, 1]\n assert candidate(restaurants = [[101, 10, 0, 100, 100], [102, 9, 1, 95, 95], [103, 8, 0, 90, 90], [104, 7, 1, 85, 85], [105, 6, 0, 80, 80]],veganFriendly = 0,maxPrice = 90,maxDistance = 90) == [103, 104, 105]\n assert candidate(restaurants = [[10001, 5, 0, 50, 50], [20002, 15, 1, 40, 40], [30003, 25, 0, 30, 30], [40004, 35, 1, 20, 20], [50005, 45, 0, 10, 10], [60006, 55, 1, 5, 5]],veganFriendly = 0,maxPrice = 40,maxDistance = 40) == [60006, 50005, 40004, 30003, 20002]\n assert candidate(restaurants = [[42, 10, 1, 10, 1], [43, 9, 0, 15, 2], [44, 8, 1, 20, 3], [45, 7, 1, 25, 4], [46, 6, 0, 30, 5], [47, 5, 1, 35, 6]],veganFriendly = 0,maxPrice = 5,maxDistance = 1) == []\n assert candidate(restaurants = [[21, 6, 0, 30, 9], [22, 7, 0, 25, 7], [23, 9, 1, 18, 5], [24, 8, 1, 22, 4], [25, 10, 0, 15, 3]],veganFriendly = 1,maxPrice = 25,maxDistance = 6) == [23, 24]\n assert candidate(restaurants = [[54, 10, 1, 10, 1], [55, 9, 0, 15, 2], [56, 8, 1, 20, 3], [57, 7, 1, 25, 4], [58, 6, 0, 30, 5], [59, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 35,maxDistance = 6) == [54, 56, 57, 59]\n assert candidate(restaurants = [[901, 9, 0, 10, 1], [902, 8, 1, 15, 2], [903, 7, 0, 20, 3], [904, 6, 1, 25, 4], [905, 5, 0, 12, 5]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [901, 902, 903, 904, 905]\n assert candidate(restaurants = [[41, 2, 0, 45, 10], [42, 8, 1, 35, 9], [43, 7, 1, 30, 8], [44, 9, 0, 25, 7], [45, 6, 1, 20, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 7) == [45]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 0,maxPrice = 10,maxDistance = 5) == [606, 303, 101]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 1,maxPrice = 35,maxDistance = 15) == [1010, 505, 101, 707, 303]\n assert candidate(restaurants = [[601, 7, 1, 25, 10], [602, 8, 0, 30, 15], [603, 9, 1, 45, 8], [604, 6, 0, 35, 15], [605, 8, 1, 50, 6], [606, 9, 1, 35, 10], [607, 7, 0, 40, 8]],veganFriendly = 0,maxPrice = 50,maxDistance = 20) == [606, 603, 605, 602, 607, 601, 604]\n assert candidate(restaurants = [[701, 10, 0, 20, 20], [702, 9, 0, 25, 25], [703, 8, 0, 30, 30], [704, 7, 0, 35, 35], [705, 6, 0, 40, 40], [706, 5, 0, 45, 45], [707, 4, 0, 50, 50], [708, 3, 0, 55, 55], [709, 2, 0, 60, 60], [710, 1, 0, 65, 65]],veganFriendly = 0,maxPrice = 40,maxDistance = 40) == [701, 702, 703, 704, 705]\n assert candidate(restaurants = [[36, 5, 1, 15, 2], [37, 4, 0, 10, 3], [38, 3, 1, 5, 4], [39, 2, 1, 20, 5], [40, 1, 0, 25, 6], [41, 8, 1, 10, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [41, 36, 38, 39]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 1,maxPrice = 30,maxDistance = 20) == [303, 101, 505]\n assert candidate(restaurants = [[1, 5, 1, 10, 1], [2, 5, 1, 10, 1], [3, 5, 1, 10, 1], [4, 5, 1, 10, 1], [5, 5, 1, 10, 1]],veganFriendly = 1,maxPrice = 10,maxDistance = 1) == [5, 4, 3, 2, 1]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [505, 202, 606, 404, 303, 101]\n assert candidate(restaurants = [[101, 5, 1, 100, 5], [102, 9, 0, 50, 4], [103, 6, 1, 40, 3], [104, 7, 0, 30, 2], [105, 8, 1, 20, 1], [106, 4, 0, 10, 6], [107, 9, 1, 15, 2]],veganFriendly = 0,maxPrice = 50,maxDistance = 4) == [107, 102, 105, 104, 103]\n assert candidate(restaurants = [[35, 6, 0, 20, 17], [36, 7, 1, 45, 21], [37, 6, 0, 35, 15], [38, 9, 1, 25, 10], [39, 8, 0, 45, 25], [40, 11, 1, 10, 4], [41, 13, 0, 22, 18]],veganFriendly = 1,maxPrice = 45,maxDistance = 25) == [40, 38, 36]\n assert candidate(restaurants = [[201, 10, 0, 1000, 50], [202, 9, 1, 900, 45], [203, 8, 0, 800, 40], [204, 7, 1, 700, 35], [205, 6, 0, 600, 30], [206, 5, 1, 500, 25], [207, 4, 0, 400, 20], [208, 3, 1, 300, 15], [209, 2, 0, 200, 10], [210, 1, 1, 100, 5]],veganFriendly = 1,maxPrice = 500,maxDistance = 30) == [206, 208, 210]\n assert candidate(restaurants = [[301, 7, 0, 20, 4], [302, 9, 1, 10, 2], [303, 6, 0, 25, 5], [304, 8, 1, 15, 3], [305, 9, 0, 30, 1], [306, 7, 1, 12, 6]],veganFriendly = 0,maxPrice = 15,maxDistance = 4) == [302, 304]\n assert candidate(restaurants = [[401, 8, 1, 25, 10], [402, 7, 0, 30, 15], [403, 9, 1, 20, 5], [404, 8, 0, 20, 8], [405, 6, 1, 20, 5], [406, 9, 1, 30, 3], [407, 5, 0, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 15) == [406, 403, 401, 405]\n assert candidate(restaurants = [[101, 90, 1, 30, 5], [202, 85, 0, 40, 10], [303, 90, 1, 30, 4], [404, 85, 0, 45, 8], [505, 85, 1, 25, 6], [606, 80, 0, 35, 7]],veganFriendly = 1,maxPrice = 35,maxDistance = 10) == [303, 101, 505]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 0,maxPrice = 20,maxDistance = 5) == [1010, 505, 404, 202]\n assert candidate(restaurants = [[701, 6, 1, 25, 10], [702, 8, 0, 30, 15], [703, 7, 1, 45, 8], [704, 9, 0, 35, 15], [705, 5, 1, 50, 6], [706, 8, 1, 35, 10], [707, 6, 0, 40, 8]],veganFriendly = 1,maxPrice = 40,maxDistance = 15) == [706, 701]\n assert candidate(restaurants = [[22, 6, 0, 20, 17], [23, 7, 1, 45, 21], [24, 6, 0, 35, 15], [25, 9, 1, 25, 10], [26, 8, 0, 45, 25], [27, 11, 1, 10, 4]],veganFriendly = 1,maxPrice = 40,maxDistance = 20) == [27, 25]\n assert candidate(restaurants = [[301, 6, 1, 30, 10], [302, 8, 0, 40, 12], [303, 7, 1, 45, 8], [304, 9, 1, 50, 6], [305, 5, 0, 35, 15], [306, 8, 1, 45, 10], [307, 7, 0, 40, 8]],veganFriendly = 0,maxPrice = 50,maxDistance = 15) == [304, 306, 302, 307, 303, 301, 305]\n assert candidate(restaurants = [[101, 100, 1, 5, 5], [102, 100, 1, 5, 6], [103, 100, 1, 5, 7], [104, 100, 1, 5, 8], [105, 100, 1, 5, 9]],veganFriendly = 1,maxPrice = 5,maxDistance = 9) == [105, 104, 103, 102, 101]\n assert candidate(restaurants = [[501, 10, 0, 50, 100], [502, 10, 0, 55, 95], [503, 10, 0, 60, 90], [504, 10, 0, 65, 85], [505, 10, 0, 70, 80], [506, 10, 0, 75, 75], [507, 10, 0, 80, 70], [508, 10, 0, 85, 65], [509, 10, 0, 90, 60]],veganFriendly = 0,maxPrice = 80,maxDistance = 70) == [507]\n assert candidate(restaurants = [[36, 6, 1, 40, 9], [37, 8, 0, 35, 8], [38, 7, 1, 30, 7], [39, 9, 0, 25, 6], [40, 10, 1, 20, 5]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [40, 38]\n assert candidate(restaurants = [[101, 1, 1, 5, 5], [102, 1, 1, 6, 6], [103, 1, 1, 7, 7], [104, 1, 1, 8, 8], [105, 1, 1, 9, 9]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [105, 104, 103, 102, 101]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [1010, 505, 101, 707, 303, 909]\n assert candidate(restaurants = [[2001, 100, 0, 50, 50], [2002, 99, 1, 49, 49], [2003, 98, 0, 48, 48], [2004, 97, 1, 47, 47], [2005, 96, 0, 46, 46]],veganFriendly = 0,maxPrice = 50,maxDistance = 50) == [2001, 2002, 2003, 2004, 2005]\n assert candidate(restaurants = [[10, 10, 0, 100, 100], [20, 9, 1, 90, 90], [30, 8, 0, 80, 80], [40, 7, 1, 70, 70], [50, 6, 0, 60, 60]],veganFriendly = 0,maxPrice = 100,maxDistance = 100) == [10, 20, 30, 40, 50]\n assert candidate(restaurants = [[31, 1, 0, 45, 10], [32, 3, 0, 30, 8], [33, 2, 1, 25, 6], [34, 4, 1, 20, 5], [35, 5, 0, 15, 4]],veganFriendly = 1,maxPrice = 25,maxDistance = 7) == [34, 33]\n assert candidate(restaurants = [[101, 6, 0, 20, 5], [102, 9, 1, 18, 2], [103, 5, 0, 10, 3], [104, 8, 1, 12, 4], [105, 7, 1, 15, 6], [106, 9, 0, 22, 3]],veganFriendly = 0,maxPrice = 25,maxDistance = 6) == [106, 102, 104, 105, 101, 103]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 0,maxPrice = 55,maxDistance = 20) == [303, 101, 505, 202, 606, 404]\n assert candidate(restaurants = [[601, 9, 1, 10, 1], [602, 8, 0, 15, 2], [603, 7, 1, 20, 3], [604, 6, 0, 25, 4], [605, 5, 1, 12, 5]],veganFriendly = 1,maxPrice = 15,maxDistance = 4) == [601]\n assert candidate(restaurants = [[10001, 5, 0, 50, 50], [20002, 15, 1, 40, 40], [30003, 25, 0, 30, 30], [40004, 35, 1, 20, 20], [50005, 45, 0, 10, 10], [60006, 55, 1, 5, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 50) == [60006, 40004, 20002]\n assert candidate(restaurants = [[801, 8, 1, 15, 3], [802, 9, 0, 10, 2], [803, 7, 1, 25, 4], [804, 6, 0, 20, 5], [805, 5, 1, 12, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 4) == [801, 805]\n assert candidate(restaurants = [[48, 1, 1, 5, 1], [49, 2, 0, 10, 2], [50, 3, 1, 15, 3], [51, 4, 1, 20, 4], [52, 5, 0, 25, 5], [53, 6, 1, 30, 6]],veganFriendly = 1,maxPrice = 25,maxDistance = 5) == [51, 50, 48]\n assert candidate(restaurants = [[10, 9, 1, 25, 7], [20, 8, 0, 35, 9], [30, 10, 1, 20, 5], [40, 7, 0, 45, 3], [50, 6, 1, 15, 2]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [30, 10, 50]\n assert candidate(restaurants = [[1, 99, 0, 1, 1], [2, 98, 0, 2, 2], [3, 97, 0, 3, 3], [4, 96, 0, 4, 4], [5, 95, 0, 5, 5], [6, 94, 0, 6, 6], [7, 93, 0, 7, 7], [8, 92, 0, 8, 8], [9, 91, 0, 9, 9]],veganFriendly = 0,maxPrice = 9,maxDistance = 9) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(restaurants = [[3001, 9, 1, 9, 9], [3002, 8, 0, 8, 8], [3003, 7, 1, 7, 7], [3004, 6, 0, 6, 6], [3005, 5, 1, 5, 5], [3006, 4, 0, 4, 4], [3007, 3, 1, 3, 3], [3008, 2, 0, 2, 2], [3009, 1, 1, 1, 1]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [3001, 3003, 3005, 3007, 3009]\n assert candidate(restaurants = [[51, 6, 1, 40, 10], [52, 8, 1, 35, 9], [53, 7, 1, 30, 8], [54, 9, 1, 25, 7], [55, 10, 1, 20, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [55, 54, 53]\n assert candidate(restaurants = [[501, 6, 1, 10, 5], [502, 7, 0, 15, 4], [503, 8, 1, 20, 3], [504, 9, 0, 25, 2], [505, 10, 1, 12, 1]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [505, 504, 503, 502, 501]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 1,maxPrice = 100,maxDistance = 100) == [505, 303, 101]\n assert candidate(restaurants = [[201, 3, 0, 40, 15], [202, 5, 1, 45, 20], [203, 8, 1, 50, 10], [204, 4, 0, 50, 25], [205, 6, 0, 40, 15], [206, 7, 1, 45, 15], [207, 9, 1, 35, 10]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [207, 203, 206, 202]\n assert candidate(restaurants = [[100, 90, 1, 10, 20], [200, 85, 0, 15, 25], [300, 80, 1, 5, 15], [400, 75, 0, 25, 10], [500, 70, 1, 20, 5]],veganFriendly = 0,maxPrice = 25,maxDistance = 20) == [100, 300, 400, 500]\n assert candidate(restaurants = [[201, 8, 1, 10, 4], [202, 6, 0, 15, 3], [203, 9, 1, 20, 2], [204, 7, 0, 25, 5], [205, 8, 1, 12, 3], [206, 9, 0, 30, 4]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [203, 205, 201]\n assert candidate(restaurants = [[17, 2, 0, 30, 13], [18, 5, 1, 40, 18], [19, 7, 1, 50, 22], [20, 1, 0, 60, 30], [21, 4, 0, 10, 2]],veganFriendly = 1,maxPrice = 55,maxDistance = 28) == [19, 18]\n assert candidate(restaurants = [[11, 3, 1, 60, 20], [12, 8, 0, 70, 22], [13, 9, 1, 20, 10], [14, 10, 0, 5, 5], [15, 8, 1, 35, 12], [16, 12, 0, 15, 9]],veganFriendly = 0,maxPrice = 75,maxDistance = 25) == [16, 14, 13, 15, 12, 11]\n assert candidate(restaurants = [[66, 1, 1, 1, 1], [77, 1, 0, 2, 2], [88, 2, 1, 3, 3], [99, 2, 0, 4, 4], [100, 3, 1, 5, 5]],veganFriendly = 0,maxPrice = 5,maxDistance = 5) == [100, 99, 88, 77, 66]\n assert candidate(restaurants = [[12, 3, 0, 60, 7], [13, 2, 1, 45, 6], [14, 5, 1, 55, 8], [15, 4, 0, 35, 5], [16, 6, 1, 40, 9], [17, 7, 1, 30, 3]],veganFriendly = 1,maxPrice = 50,maxDistance = 10) == [17, 16, 13]\n assert candidate(restaurants = [[18, 9, 1, 20, 5], [19, 10, 0, 25, 3], [20, 8, 1, 15, 2], [21, 7, 1, 10, 1], [22, 6, 0, 5, 1], [23, 5, 1, 30, 4]],veganFriendly = 0,maxPrice = 100,maxDistance = 10) == [19, 18, 20, 21, 22, 23]\n assert candidate(restaurants = [[60, 10, 1, 10, 1], [61, 9, 0, 15, 2], [62, 8, 1, 20, 3], [63, 7, 1, 25, 4], [64, 6, 0, 30, 5], [65, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 10,maxDistance = 1) == [60]\n assert candidate(restaurants = [[1001, 1, 1, 1, 1], [1002, 2, 0, 2, 2], [1003, 3, 1, 3, 3], [1004, 4, 0, 4, 4], [1005, 5, 1, 5, 5], [1006, 6, 0, 6, 6], [1007, 7, 1, 7, 7]],veganFriendly = 1,maxPrice = 7,maxDistance = 7) == [1007, 1005, 1003, 1001]\n assert candidate(restaurants = [[28, 5, 0, 30, 15], [29, 8, 1, 40, 20], [30, 6, 0, 25, 10], [31, 7, 1, 5, 5], [32, 9, 0, 10, 4], [33, 12, 1, 35, 12], [34, 10, 0, 15, 9]],veganFriendly = 0,maxPrice = 55,maxDistance = 28) == [33, 34, 32, 29, 31, 30, 28]\n assert candidate(restaurants = [[10, 9, 1, 20, 1], [20, 8, 0, 10, 2], [30, 7, 1, 5, 3], [40, 10, 1, 15, 2], [50, 6, 0, 25, 4], [60, 8, 1, 30, 1]],veganFriendly = 1,maxPrice = 30,maxDistance = 3) == [40, 10, 60, 30]\n assert candidate(restaurants = [[6, 5, 1, 20, 5], [7, 7, 0, 25, 3], [8, 6, 1, 15, 2], [9, 9, 1, 10, 1], [10, 10, 0, 5, 1], [11, 8, 1, 30, 4]],veganFriendly = 1,maxPrice = 25,maxDistance = 4) == [9, 8]\n assert candidate(restaurants = [[1, 100, 1, 1, 1], [2, 99, 0, 2, 2], [3, 98, 1, 3, 3], [4, 97, 0, 4, 4], [5, 96, 1, 5, 5], [6, 95, 0, 6, 6], [7, 94, 1, 7, 7], [8, 93, 0, 8, 8], [9, 92, 1, 9, 9], [10, 91, 0, 10, 10]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [1, 3, 5, 7, 9]\n assert candidate(restaurants = [[6, 9, 0, 20, 6], [7, 7, 1, 15, 3], [8, 6, 1, 25, 2], [9, 10, 0, 5, 1], [10, 4, 1, 35, 8]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [7, 8]\n assert candidate(restaurants = [[1000, 95, 1, 40, 50], [2000, 90, 0, 50, 60], [3000, 85, 1, 30, 40], [4000, 80, 0, 40, 30], [5000, 75, 1, 20, 20], [6000, 70, 0, 30, 10]],veganFriendly = 1,maxPrice = 30,maxDistance = 30) == [5000]\n assert candidate(restaurants = [[501, 9, 1, 25, 7], [502, 6, 0, 40, 12], [503, 8, 1, 45, 8], [504, 7, 0, 35, 15], [505, 9, 1, 50, 6], [506, 6, 1, 35, 10], [507, 8, 0, 40, 8]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [505, 501, 503, 506]\n assert candidate(restaurants = [[11, 3, 1, 10, 10], [22, 2, 0, 9, 9], [33, 3, 1, 8, 8], [44, 2, 0, 7, 7], [55, 3, 1, 6, 6]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [55, 33, 11]\n assert candidate(restaurants = [[601, 5, 1, 5, 5], [602, 6, 1, 10, 10], [603, 7, 1, 15, 15], [604, 8, 1, 20, 20], [605, 9, 1, 25, 25], [606, 10, 1, 30, 30]],veganFriendly = 1,maxPrice = 25,maxDistance = 25) == [605, 604, 603, 602, 601]\n assert candidate(restaurants = [[11, 50, 1, 20, 10], [12, 50, 1, 20, 9], [13, 50, 1, 20, 8], [14, 50, 1, 20, 7], [15, 50, 1, 20, 6], [16, 50, 1, 20, 5], [17, 50, 1, 20, 4], [18, 50, 1, 20, 3], [19, 50, 1, 20, 2], [20, 50, 1, 20, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 10) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(restaurants = [[6, 6, 0, 55, 15], [7, 7, 1, 35, 7], [8, 9, 0, 25, 8], [9, 7, 1, 5, 1], [10, 5, 0, 10, 4]],veganFriendly = 1,maxPrice = 40,maxDistance = 10) == [9, 7]\n assert candidate(restaurants = [[16, 1, 0, 40, 7], [17, 3, 1, 20, 5], [18, 2, 1, 30, 4], [19, 4, 0, 50, 3], [20, 5, 1, 45, 2]],veganFriendly = 0,maxPrice = 45,maxDistance = 7) == [20, 17, 18, 16]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 1,maxPrice = 55,maxDistance = 20) == [303, 101, 505]\n assert candidate(restaurants = [[701, 10, 0, 20, 1], [702, 9, 1, 25, 2], [703, 8, 0, 30, 3], [704, 7, 1, 15, 4], [705, 6, 0, 10, 5]],veganFriendly = 0,maxPrice = 30,maxDistance = 5) == [701, 702, 703, 704, 705]\n assert candidate(restaurants = [[46, 1, 0, 50, 10], [47, 3, 1, 45, 9], [48, 2, 1, 40, 8], [49, 4, 0, 35, 7], [50, 5, 1, 30, 6]],veganFriendly = 0,maxPrice = 45,maxDistance = 9) == [50, 49, 47, 48]\n", "comparison": "exact"}, "public_tests": ["[[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]]\n1\n50\n10", "[[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]]\n0\n50\n10", "[[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]]\n0\n30\n3"], "hints": ["Do the filtering and sort as said. Note that the id may not be the index in the array."], "metadata": {"canonical_parameter_names": ["restaurants", "veganFriendly", "maxPrice", "maxDistance"], "leetcode_dataset_entry_point": "Solution().filterRestaurants", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:04+00:00", "tests_total": 90, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def filterRestaurants(self, restaurants: list[list[int]], veganFriendly: int, maxPrice: int, maxDistance: int) -> list[int]:", "container": "Solution", "callable": "filterRestaurants", "parameters": [{"name": "restaurants", "type": "list[list[int]]"}, {"name": "veganFriendly", "type": "int"}, {"name": "maxPrice", "type": "int"}, {"name": "maxDistance", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1334, "task_id": "find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance", "difficulty": "Medium", "problem_description": "There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [from_i, to_i, weight_i] represents a bidirectional and weighted edge between cities from_i and to_i, and given the integer distanceThreshold.\n\nReturn the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.\n\nNotice that the distance of a path connecting cities i and j is equal to the sum of the edges' weights along that path.\n\nExample 1:\n\nInput: n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4\nOutput: 3\nExplanation: The figure above describes the graph.\nThe neighboring cities at a distanceThreshold = 4 for each city are:\nCity 0 -> [City 1, City 2]\nCity 1 -> [City 0, City 2, City 3]\nCity 2 -> [City 0, City 1, City 3]\nCity 3 -> [City 1, City 2]\nCities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have to return city 3 since it has the greatest number.\n\nExample 2:\n\nInput: n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2\nOutput: 0\nExplanation: The figure above describes the graph.\nThe neighboring cities at a distanceThreshold = 2 for each city are:\nCity 0 -> [City 1]\nCity 1 -> [City 0, City 4]\nCity 2 -> [City 3, City 4]\nCity 3 -> [City 2, City 4]\nCity 4 -> [City 1, City 2, City 3]\nThe city 0 has 1 neighboring city at a distanceThreshold = 2.\n\nConstraints:\n\n- 2 <= n <= 100\n- 1 <= edges.length <= n * (n - 1) / 2\n- edges[i].length == 3\n- 0 <= from_i < to_i < n\n- 1 <= weight_i, distanceThreshold <= 10^4\n- All pairs (from_i, to_i) are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1]],distanceThreshold = 2) == 0\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 1], [1, 3, 4], [2, 3, 1]],distanceThreshold = 4) == 3\n assert candidate(n = 6,edges = [[0, 1, 10], [0, 2, 3], [1, 2, 1], [1, 3, 7], [2, 4, 2], [3, 4, 8], [4, 5, 6]],distanceThreshold = 20) == 5\n assert candidate(n = 3,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 5]],distanceThreshold = 10) == 2\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [2, 4, 1], [3, 4, 1], [3, 5, 1], [4, 5, 1], [4, 6, 1], [5, 6, 1]],distanceThreshold = 1) == 6\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 5, 3], [1, 2, 1], [1, 3, 4], [2, 4, 3], [2, 5, 2], [3, 4, 1], [3, 6, 5], [4, 7, 2], [5, 6, 1], [6, 7, 3], [7, 8, 1], [8, 9, 4]],distanceThreshold = 5) == 9\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [1, 3, 3], [1, 4, 7], [2, 3, 1], [2, 4, 2], [3, 4, 1], [3, 5, 2], [4, 5, 2]],distanceThreshold = 4) == 5\n assert candidate(n = 10,edges = [[0, 1, 3], [0, 2, 5], [0, 3, 7], [0, 4, 9], [1, 2, 4], [1, 3, 6], [1, 4, 8], [1, 5, 2], [2, 3, 3], [2, 4, 5], [2, 5, 7], [2, 6, 1], [3, 4, 4], [3, 5, 6], [3, 6, 8], [3, 7, 2], [4, 5, 3], [4, 6, 5], [4, 7, 7], [4, 8, 1], [5, 6, 4], [5, 7, 6], [5, 8, 8], [5, 9, 2], [6, 7, 3], [6, 8, 5], [6, 9, 7], [7, 8, 4], [7, 9, 6], [8, 9, 5]],distanceThreshold = 20) == 9\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [0, 5, 12], [1, 4, 14], [2, 5, 16]],distanceThreshold = 10) == 5\n assert candidate(n = 6,edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [0, 3, 25], [0, 2, 30], [1, 3, 35]],distanceThreshold = 50) == 5\n assert candidate(n = 8,edges = [[0, 1, 4], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 1], [3, 4, 3], [4, 5, 2], [4, 6, 6], [5, 6, 1], [6, 7, 3]],distanceThreshold = 6) == 7\n assert candidate(n = 6,edges = [[0, 1, 3], [0, 2, 4], [0, 4, 5], [1, 2, 1], [1, 3, 2], [1, 5, 6], [2, 3, 3], [2, 5, 1], [3, 5, 2], [4, 5, 4]],distanceThreshold = 7) == 5\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 4, 4], [0, 11, 6], [1, 2, 1], [1, 3, 3], [1, 4, 2], [2, 3, 1], [2, 4, 3], [2, 5, 2], [3, 4, 1], [3, 6, 4], [3, 7, 5], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 4], [5, 9, 5], [6, 8, 1], [6, 9, 3], [6, 10, 4], [7, 8, 2], [7, 9, 1], [7, 10, 3], [8, 9, 1], [8, 10, 2], [8, 11, 6], [9, 10, 1], [9, 11, 3], [10, 11, 2]],distanceThreshold = 5) == 11\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [0, 6, 10], [0, 3, 1], [1, 4, 1], [2, 5, 1]],distanceThreshold = 15) == 6\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [2, 3, 1], [2, 4, 2], [2, 5, 3], [2, 6, 4], [2, 7, 5], [2, 8, 6], [3, 4, 1], [3, 5, 2], [3, 6, 3], [3, 7, 4], [3, 8, 5], [4, 5, 1], [4, 6, 2], [4, 7, 3], [4, 8, 4], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [7, 8, 1]],distanceThreshold = 5) == 8\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 6, 5], [1, 2, 3], [1, 3, 1], [1, 6, 4], [2, 3, 1], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 2], [5, 6, 3]],distanceThreshold = 5) == 6\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [2, 3, 1], [2, 4, 2], [2, 5, 3], [2, 6, 4], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [5, 6, 1]],distanceThreshold = 10) == 6\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 3, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [2, 4, 2], [3, 4, 4], [3, 5, 6], [3, 6, 7], [4, 5, 1], [5, 6, 1], [5, 7, 3], [5, 8, 2], [6, 8, 4]],distanceThreshold = 10) == 0\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 3], [2, 3, 2], [2, 5, 5], [3, 4, 1], [3, 5, 3], [3, 6, 4], [4, 5, 1], [5, 6, 2]],distanceThreshold = 5) == 6\n assert candidate(n = 8,edges = [[0, 1, 7], [0, 2, 5], [1, 2, 9], [1, 3, 8], [1, 4, 4], [2, 3, 2], [2, 5, 3], [3, 5, 6], [3, 6, 7], [4, 5, 1], [4, 7, 3], [5, 6, 8], [6, 7, 6]],distanceThreshold = 15) == 7\n assert candidate(n = 7,edges = [[0, 1, 4], [0, 2, 6], [1, 2, 5], [1, 3, 3], [1, 4, 8], [2, 4, 7], [3, 4, 5], [4, 5, 9], [4, 6, 2]],distanceThreshold = 10) == 5\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 5], [0, 3, 6], [1, 2, 1], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [8, 9, 1]],distanceThreshold = 5) == 0\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [4, 5, 1]],distanceThreshold = 5) == 5\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 4, 15], [1, 5, 10], [2, 6, 9], [3, 7, 12]],distanceThreshold = 20) == 7\n assert candidate(n = 6,edges = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 1], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 2]],distanceThreshold = 4) == 0\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 3, 2], [2, 4, 3], [3, 4, 1], [3, 5, 1], [4, 5, 2]],distanceThreshold = 5) == 0\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [0, 3, 4], [3, 4, 5], [4, 5, 1], [2, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 9, 7]],distanceThreshold = 10) == 9\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 2], [1, 3, 6], [2, 4, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],distanceThreshold = 10) == 7\n assert candidate(n = 9,edges = [[0, 1, 4], [0, 2, 9], [0, 3, 5], [0, 4, 3], [1, 2, 10], [1, 3, 2], [1, 4, 8], [2, 3, 5], [2, 4, 7], [3, 4, 4], [5, 6, 2], [5, 7, 3], [5, 8, 5], [6, 7, 1], [6, 8, 4], [7, 8, 2]],distanceThreshold = 7) == 8\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 15], [0, 3, 10], [1, 2, 3], [1, 3, 12], [1, 4, 20], [2, 3, 7], [2, 4, 13], [2, 5, 8], [3, 4, 1], [3, 5, 6], [3, 6, 14], [4, 5, 9], [4, 6, 11], [5, 6, 5], [6, 7, 17], [6, 8, 22], [7, 8, 2], [7, 9, 23], [8, 9, 18]],distanceThreshold = 30) == 9\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [4, 5, 2], [4, 6, 3], [4, 7, 4], [5, 6, 1], [5, 7, 2], [6, 7, 1]],distanceThreshold = 3) == 7\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 6, 6], [1, 2, 1], [1, 5, 5], [2, 3, 1], [2, 4, 4], [3, 4, 1], [3, 6, 6], [4, 5, 1], [5, 6, 6]],distanceThreshold = 6) == 6\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 5, 10], [1, 2, 1], [1, 4, 3], [2, 3, 2], [3, 4, 2], [3, 5, 3], [4, 5, 5]],distanceThreshold = 6) == 5\n assert candidate(n = 8,edges = [[0, 1, 4], [1, 2, 4], [2, 3, 4], [3, 4, 4], [4, 5, 4], [5, 6, 4], [6, 7, 4], [0, 7, 8], [0, 3, 5], [1, 4, 5], [2, 5, 5], [3, 6, 5], [4, 7, 5]],distanceThreshold = 12) == 7\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 5], [0, 7, 6], [1, 2, 5], [1, 3, 3], [1, 6, 4], [1, 7, 3], [2, 3, 5], [2, 4, 5], [3, 4, 3], [3, 5, 2], [4, 5, 2], [4, 6, 5], [5, 6, 5], [6, 7, 5]],distanceThreshold = 8) == 0\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 40], [2, 4, 50], [3, 4, 60], [4, 5, 70], [5, 6, 80], [6, 7, 90], [7, 8, 100], [8, 9, 110], [0, 9, 120]],distanceThreshold = 200) == 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], [0, 8, 1]],distanceThreshold = 4) == 8\n assert candidate(n = 12,edges = [[0, 1, 7], [0, 2, 10], [0, 3, 12], [0, 4, 8], [0, 5, 9], [0, 6, 5], [0, 7, 2], [0, 8, 6], [0, 9, 8], [0, 10, 3], [0, 11, 4], [1, 2, 6], [1, 3, 4], [1, 4, 2], [1, 5, 7], [1, 6, 8], [1, 7, 9], [1, 8, 3], [1, 9, 5], [1, 10, 11], [1, 11, 2], [2, 3, 10], [2, 4, 3], [2, 5, 12], [2, 6, 6], [2, 7, 1], [2, 8, 4], [2, 9, 7], [2, 10, 5], [2, 11, 8], [3, 4, 5], [3, 5, 10], [3, 6, 9], [3, 7, 11], [3, 8, 2], [3, 9, 6], [3, 10, 1], [3, 11, 4], [4, 5, 2], [4, 6, 10], [4, 7, 3], [4, 8, 5], [4, 9, 1], [4, 10, 7], [4, 11, 8], [5, 6, 3], [5, 7, 11], [5, 8, 9], [5, 9, 4], [5, 10, 6], [5, 11, 2], [6, 7, 5], [6, 8, 10], [6, 9, 3], [6, 10, 12], [6, 11, 4], [7, 8, 3], [7, 9, 2], [7, 10, 5], [7, 11, 1], [8, 9, 5], [8, 10, 2], [8, 11, 4], [9, 10, 7], [9, 11, 3], [10, 11, 2]],distanceThreshold = 10) == 11\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 4], [0, 3, 5], [1, 2, 1], [1, 3, 8], [1, 4, 3], [2, 3, 2], [2, 4, 6], [3, 4, 7], [3, 5, 3], [4, 5, 1]],distanceThreshold = 5) == 5\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 4, 5], [1, 5, 6], [2, 6, 7], [2, 7, 8], [3, 7, 9]],distanceThreshold = 10) == 7\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [0, 5, 7]],distanceThreshold = 9) == 5\n assert candidate(n = 9,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [0, 7, 8], [0, 8, 9], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8], [6, 8, 9], [1, 4, 6], [2, 5, 7], [3, 6, 8], [4, 7, 9], [5, 8, 10], [1, 5, 8], [2, 6, 9], [3, 7, 10], [4, 8, 11], [1, 6, 9], [2, 7, 10], [3, 8, 11], [1, 7, 10], [2, 8, 11], [1, 8, 11]],distanceThreshold = 15) == 8\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 8], [0, 3, 7], [0, 4, 9], [0, 5, 10], [0, 6, 1], [0, 7, 2], [0, 8, 6], [0, 9, 8], [1, 2, 2], [1, 3, 9], [1, 4, 3], [1, 5, 5], [1, 6, 1], [1, 7, 4], [1, 8, 7], [1, 9, 1], [2, 3, 7], [2, 4, 5], [2, 5, 10], [2, 6, 6], [2, 7, 1], [2, 8, 4], [2, 9, 3], [3, 4, 3], [3, 5, 9], [3, 6, 5], [3, 7, 10], [3, 8, 6], [3, 9, 1], [4, 5, 5], [4, 6, 9], [4, 7, 7], [4, 8, 1], [4, 9, 8], [5, 6, 8], [5, 7, 6], [5, 8, 10], [5, 9, 4], [6, 7, 7], [6, 8, 5], [6, 9, 3], [7, 8, 4], [7, 9, 2], [8, 9, 5]],distanceThreshold = 10) == 9\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 3, 4], [1, 2, 1], [1, 4, 5], [2, 3, 1], [3, 4, 3], [4, 5, 2]],distanceThreshold = 5) == 5\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 7], [0, 3, 9], [1, 4, 11], [1, 5, 13], [2, 5, 15], [2, 6, 17], [3, 6, 19], [4, 7, 21], [4, 8, 23], [5, 7, 25], [5, 8, 27], [6, 8, 29]],distanceThreshold = 20) == 8\n", "comparison": "exact"}, "public_tests": ["4\n[[0,1,3],[1,2,1],[1,3,4],[2,3,1]]\n4", "5\n[[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]]\n2"], "hints": ["Use Floyd-Warshall's algorithm to compute any-point to any-point distances. (Or can also do Dijkstra from every node due to the weights are non-negative).", "For each city calculate the number of reachable cities within the threshold, then search for the optimal city."], "metadata": {"canonical_parameter_names": ["n", "edges", "distanceThreshold"], "leetcode_dataset_entry_point": "Solution().findTheCity", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:06+00:00", "tests_total": 61, "tests_dropped": 16, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming", "graph", "shortest-path", "dijkstra", "bellman-ford-algorithm", "floyd-warshall-algorithm"]}, "language": "python", "interface": {"raw_signature": "def findTheCity(self, n: int, edges: list[list[int]], distanceThreshold: int) -> int:", "container": "Solution", "callable": "findTheCity", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "distanceThreshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1335, "task_id": "minimum-difficulty-of-a-job-schedule", "difficulty": "Hard", "problem_description": "You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i^th job, you have to finish all the jobs j where 0 <= j < i).\n\nYou have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.\n\nYou are given an integer array jobDifficulty and an integer d. The difficulty of the i^th job is jobDifficulty[i].\n\nReturn the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.\n\nExample 1:\n\nInput: jobDifficulty = [6,5,4,3,2,1], d = 2\nOutput: 7\nExplanation: First day you can finish the first 5 jobs, total difficulty = 6.\nSecond day you can finish the last job, total difficulty = 1.\nThe difficulty of the schedule = 6 + 1 = 7\n\nExample 2:\n\nInput: jobDifficulty = [9,9,9], d = 4\nOutput: -1\nExplanation: If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.\n\nExample 3:\n\nInput: jobDifficulty = [1,1,1], d = 3\nOutput: 3\nExplanation: The schedule is one job per day. total difficulty will be 3.\n\nConstraints:\n\n- 1 <= jobDifficulty.length <= 300\n- 0 <= jobDifficulty[i] <= 1000\n- 1 <= d <= 10\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 55\n assert candidate(jobDifficulty = [300, 500, 1000],d = 3) == 1800\n assert candidate(jobDifficulty = [6, 5, 4, 3, 2, 1],d = 2) == 7\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 20\n assert candidate(jobDifficulty = [15, 97, 88, 92, 49],d = 2) == 112\n assert candidate(jobDifficulty = [7, 1, 7, 1, 7, 1],d = 3) == 15\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 25\n assert candidate(jobDifficulty = [0, 0, 0, 0],d = 4) == 0\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 3) == 80\n assert candidate(jobDifficulty = [1000, 0, 1000, 0, 1000],d = 3) == 2000\n assert candidate(jobDifficulty = [30, 10, 40, 20, 10, 50],d = 3) == 90\n assert candidate(jobDifficulty = [100, 200, 300],d = 1) == 300\n assert candidate(jobDifficulty = [3, 2, 1],d = 1) == 3\n assert candidate(jobDifficulty = [1],d = 1) == 1\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(jobDifficulty = [9, 9, 9],d = 4) == -1\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(jobDifficulty = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],d = 10) == 30\n assert candidate(jobDifficulty = [1, 2],d = 2) == 3\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 2) == 60\n assert candidate(jobDifficulty = [1, 1, 1],d = 3) == 3\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 5) == 150\n assert candidate(jobDifficulty = [500, 400, 300, 200, 100, 900, 800, 700, 600, 500],d = 4) == 1700\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],d = 5) == 32\n assert candidate(jobDifficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 10) == 550\n assert candidate(jobDifficulty = [10, 4, 15, 8, 12, 9, 5, 6, 7, 11, 3],d = 4) == 32\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 10) == 55\n assert candidate(jobDifficulty = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],d = 10) == 15\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 25\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 13\n assert candidate(jobDifficulty = [9, 4, 5, 3, 2, 8, 7, 1, 6, 10],d = 5) == 29\n assert candidate(jobDifficulty = [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],d = 10) == 180\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 10) == 65\n assert candidate(jobDifficulty = [300, 200, 100, 250, 400, 350, 500, 450, 550, 600],d = 5) == 1450\n assert candidate(jobDifficulty = [5, 8, 6, 5, 3, 4, 2, 7, 1, 9],d = 4) == 23\n assert candidate(jobDifficulty = [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],d = 5) == 400\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 10) == 60\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 16\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 1) == 30\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],d = 5) == 21\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 7) == 35\n assert candidate(jobDifficulty = [10, 100, 20, 50, 30, 70, 40, 60, 90, 80, 10, 200, 150, 300, 250],d = 5) == 480\n assert candidate(jobDifficulty = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 10) == 100\n assert candidate(jobDifficulty = [8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 11\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 300],d = 10) == 345\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],d = 5) == 25\n assert candidate(jobDifficulty = [9, 18, 1, 5, 19, 12, 4, 7, 8, 6],d = 5) == 44\n assert candidate(jobDifficulty = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],d = 10) == 9855\n assert candidate(jobDifficulty = [3, 6, 1, 9, 10, 5, 4, 8, 7, 2],d = 10) == 55\n assert candidate(jobDifficulty = [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],d = 5) == 1390\n assert candidate(jobDifficulty = [7, 8, 4, 3, 2, 9, 10, 11, 1, 2],d = 3) == 14\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 3) == 130\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 13\n assert candidate(jobDifficulty = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],d = 10) == 3250\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],d = 5) == 1400\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],d = 10) == 5500\n assert candidate(jobDifficulty = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 5) == 300\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 5) == 40\n assert candidate(jobDifficulty = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 10) == 45\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [3, 6, 5, 10, 12, 8, 7, 4, 15, 11, 9, 1, 14, 13, 2, 16, 18, 17, 19, 20, 21, 22, 23, 24, 25],d = 10) == 86\n assert candidate(jobDifficulty = [300, 200, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],d = 10) == 300\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 2) == 20\n assert candidate(jobDifficulty = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16],d = 10) == 69\n assert candidate(jobDifficulty = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 50, 100, 150, 200, 250, 300],d = 10) == 2300\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],d = 2) == 1100\n assert candidate(jobDifficulty = [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],d = 10) == 140\n assert candidate(jobDifficulty = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],d = 5) == 2993\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 3) == 130\n assert candidate(jobDifficulty = [300, 250, 200, 150, 100, 50, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 10) == 353\n assert candidate(jobDifficulty = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],d = 10) == 10000\n assert candidate(jobDifficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 10) == 550\n assert candidate(jobDifficulty = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],d = 5) == 500\n assert candidate(jobDifficulty = [9, 18, 7, 16, 15, 14, 13, 2, 11, 10, 8, 6, 5, 4, 3, 1, 12, 17, 19, 20],d = 5) == 46\n assert candidate(jobDifficulty = [500, 300, 700, 100, 200, 400, 800, 600, 900],d = 4) == 1900\n assert candidate(jobDifficulty = [5, 8, 3, 1, 9, 4, 6, 7, 2, 10, 15, 12, 14, 11, 13, 16, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 8) == 64\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 7) == 31\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 25\n assert candidate(jobDifficulty = [2, 3, 6, 5, 4, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15],d = 7) == 41\n assert candidate(jobDifficulty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],d = 1) == 0\n assert candidate(jobDifficulty = [300, 250, 200, 150, 100, 50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],d = 7) == 1600\n assert candidate(jobDifficulty = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],d = 4) == 25\n assert candidate(jobDifficulty = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105],d = 7) == 240\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 10) == 75\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 41\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 7) == 36\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [200, 150, 100, 50, 0, 50, 100, 150, 200],d = 6) == 600\n assert candidate(jobDifficulty = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],d = 10) == 10000\n assert candidate(jobDifficulty = [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],d = 5) == 400\n", "comparison": "exact"}, "public_tests": ["[6,5,4,3,2,1]\n2", "[9,9,9]\n4", "[1,1,1]\n3"], "hints": ["Use DP. Try to cut the array into d non-empty sub-arrays. Try all possible cuts for the array.", "Use dp[i][j] where DP states are i the index of the last cut and j the number of remaining cuts. Complexity is O(n * n * d)."], "metadata": {"canonical_parameter_names": ["jobDifficulty", "d"], "leetcode_dataset_entry_point": "Solution().minDifficulty", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:08+00:00", "tests_total": 111, "tests_dropped": 18, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minDifficulty(self, jobDifficulty: list[int], d: int) -> int:", "container": "Solution", "callable": "minDifficulty", "parameters": [{"name": "jobDifficulty", "type": "list[int]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1337, "task_id": "the-k-weakest-rows-in-a-matrix", "difficulty": "Easy", "problem_description": "You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.\n\nA row i is weaker than a row j if one of the following is true:\n\n- The number of soldiers in row i is less than the number of soldiers in row j.\n- Both rows have the same number of soldiers and i < j.\n\nReturn the indices of the k weakest rows in the matrix ordered from weakest to strongest.\n\nExample 1:\n\nInput: mat =\n[[1,1,0,0,0],\n [1,1,1,1,0],\n [1,0,0,0,0],\n [1,1,0,0,0],\n [1,1,1,1,1]],\nk = 3\nOutput: [2,0,3]\nExplanation:\nThe number of soldiers in each row is:\n- Row 0: 2\n- Row 1: 4\n- Row 2: 1\n- Row 3: 2\n- Row 4: 5\nThe rows ordered from weakest to strongest are [2,0,3,1,4].\n\nExample 2:\n\nInput: mat =\n[[1,0,0,0],\n [1,1,1,1],\n [1,0,0,0],\n [1,0,0,0]],\nk = 2\nOutput: [0,2]\nExplanation:\nThe number of soldiers in each row is:\n- Row 0: 1\n- Row 1: 4\n- Row 2: 1\n- Row 3: 1\nThe rows ordered from weakest to strongest are [0,2,3,1].\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 2 <= n, m <= 100\n- 1 <= k <= m\n- matrix[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[0, 0, 0, 0], [1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 1, 1]],k = 3) == [1, 2, 0]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 1) == [0]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 3) == [2, 0, 3]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 4) == [3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 4) == [2, 3, 0, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 1) == [0]\n assert candidate(mat = [[1, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0]],k = 2) == [0, 2]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 5) == [2, 3, 0, 1, 4]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 0, 0]],k = 2) == [1, 2]\n assert candidate(mat = [[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, 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, 0, 0, 0, 0, 0, 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) == [9, 10, 8, 7, 6, 5, 4]\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], [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, 0, 0, 0, 0, 0, 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) == [10, 11, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [6, 5, 4, 3, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [5, 4, 3, 2, 1]\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]],k = 4) == [0, 1, 2, 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], [1, 1, 1, 1, 1, 1, 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, 1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 2) == [4, 3]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],k = 7) == [1, 5, 3, 0, 2, 4, 6]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0]],k = 6) == [1, 8, 9, 0, 3, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 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]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0]],k = 5) == [3, 0, 2, 1, 4]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 2) == [3, 4]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],k = 6) == [1, 3, 5, 0, 2, 4]\n assert candidate(mat = [[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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 3) == [3, 2, 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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 7) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(mat = [[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]],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 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]],k = 5) == [1, 7, 6, 5, 3]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [5, 6, 7, 4, 3]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 5) == [3, 1, 5, 4, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]],k = 3) == [3, 2, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 0]\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], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 4) == [1, 5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [3, 4, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],k = 3) == [4, 3, 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, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 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, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]],k = 4) == [1, 0, 3, 2]\n assert candidate(mat = [[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]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],k = 3) == [3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]],k = 5) == [3, 4, 1, 0, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 4, 2, 0, 3]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 1]\n assert candidate(mat = [[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], [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]],k = 4) == [8, 9, 7, 0]\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, 1, 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, 0, 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, 0, 0], [1, 1, 1, 1, 1, 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, 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, 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], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],k = 6) == [5, 0, 1, 2, 3, 4]\n assert candidate(mat = [[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], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 0, 2, 3, 4]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 3) == [5, 4, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 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, 1, 0, 0], [1, 1, 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, 0, 0]],k = 4) == [5, 1, 6, 4]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [2, 3, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0]],k = 6) == [4, 5, 0, 7, 1, 6]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]],k = 5) == [3, 4, 5, 0, 1]\n assert candidate(mat = [[1, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 0]],k = 4) == [1, 0, 5, 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, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 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]],k = 4) == [0, 1, 2, 3]\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], [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, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[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) == [1, 3, 4, 0, 2]\n assert candidate(mat = [[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, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 4) == [2, 1, 5, 0]\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]],k = 7) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],k = 6) == [2, 0, 3, 4, 1, 5]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\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], [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, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [10, 9, 8, 7, 6, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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, 1, 2]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]],k = 4) == [0, 1, 2, 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], [1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 2) == [0, 1]\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], [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, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [9, 8, 7, 6, 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], [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, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [9, 8, 7, 6, 5, 4, 3]\n", "comparison": "exact"}, "public_tests": ["[[1,1,0,0,0],[1,1,1,1,0],[1,0,0,0,0],[1,1,0,0,0],[1,1,1,1,1]]\n3", "[[1,0,0,0],[1,1,1,1],[1,0,0,0],[1,0,0,0]]\n2"], "hints": ["Sort the matrix row indexes by the number of soldiers and then row indexes."], "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().kWeakestRows", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:11+00:00", "tests_total": 80, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search", "sorting", "heap-priority-queue", "matrix"]}, "language": "python", "interface": {"raw_signature": "def kWeakestRows(self, mat: list[list[int]], k: int) -> list[int]:", "container": "Solution", "callable": "kWeakestRows", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1338, "task_id": "reduce-array-size-to-the-half", "difficulty": "Medium", "problem_description": "You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.\n\nReturn the minimum size of the set so that at least half of the integers of the array are removed.\n\nExample 1:\n\nInput: arr = [3,3,3,3,5,5,5,2,2,7]\nOutput: 2\nExplanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array).\nPossible sets of size 2 are {3,5},{3,2},{5,2}.\nChoosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.\n\nExample 2:\n\nInput: arr = [7,7,7,7,7,7]\nOutput: 1\nExplanation: The only possible set you can choose is {7}. This will make the new array empty.\n\nConstraints:\n\n- 2 <= arr.length <= 10^5\n- arr.length is even.\n- 1 <= arr[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [10, 10, 20, 20, 20, 30, 30, 30, 30, 30]) == 1\n assert candidate(arr = [3, 3, 3, 3, 5, 5, 5, 2, 2, 7]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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]) == 2\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20, 20]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 4, 5]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [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]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 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]) == 2\n assert candidate(arr = [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, 8]) == 3\n assert candidate(arr = [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, 5, 5, 5, 5, 5, 5, 5, 5, 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(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]) == 25\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\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]) == 8\n assert candidate(arr = [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, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [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]) == 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, 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]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 3\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 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]) == 3\n assert candidate(arr = [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, 3, 3, 3, 3]) == 1\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, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [1, 1, 2, 2, 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]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 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]) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == 2\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]) == 1\n assert candidate(arr = [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]) == 5\n assert candidate(arr = [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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [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]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\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]) == 5\n assert candidate(arr = [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]) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70]) == 3\n assert candidate(arr = [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]) == 2\n assert candidate(arr = [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, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 25\n assert candidate(arr = [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]) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 2\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, 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(arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == 2\n assert candidate(arr = [10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\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]) == 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, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 2, 2, 2, 3, 3, 4]) == 1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 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\n assert candidate(arr = [1, 1, 1, 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, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 1\n", "comparison": "exact"}, "public_tests": ["[3,3,3,3,5,5,5,2,2,7]", "[7,7,7,7,7,7]"], "hints": ["Count the frequency of each integer in the array.", "Start with an empty set, add to the set the integer with the maximum frequency.", "Keep Adding the integer with the max frequency until you remove at least half of the integers."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minSetSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:13+00:00", "tests_total": 85, "tests_dropped": 24, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def minSetSize(self, arr: list[int]) -> int:", "container": "Solution", "callable": "minSetSize", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1340, "task_id": "jump-game-v", "difficulty": "Hard", "problem_description": "Given an array of integers arr and an integer d. In one step you can jump from index i to index:\n\n- i + x where: i + x < arr.length and 0 < x <= d.\n- i - x where: i - x >= 0 and 0 < x <= d.\n\nIn addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).\n\nYou can choose any index of the array and start jumping. Return the maximum number of indices you can visit.\n\nNotice that you can not jump outside of the array at any time.\n\nExample 1:\n\nInput: arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2\nOutput: 4\nExplanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.\nNote that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.\nSimilarly You cannot jump from index 3 to index 2 or index 1.\n\nExample 2:\n\nInput: arr = [3,3,3,3,3], d = 3\nOutput: 1\nExplanation: You can start at any index. You always cannot jump to any index.\n\nExample 3:\n\nInput: arr = [7,6,5,4,3,2,1], d = 1\nOutput: 7\nExplanation: Start at index 0. You can visit all the indicies.\n\nConstraints:\n\n- 1 <= arr.length <= 1000\n- 1 <= arr[i] <= 10^5\n- 1 <= d <= arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],d = 2) == 5\n assert candidate(arr = [3, 3, 3, 3, 3],d = 3) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],d = 4) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],d = 1) == 7\n assert candidate(arr = [6, 4, 14, 6, 8, 13, 9, 7, 10, 6, 12],d = 2) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],d = 2) == 2\n assert candidate(arr = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 1\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [3, 5, 2, 1, 4, 7, 6, 8, 9, 10],d = 3) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 4) == 10\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 1],d = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1],d = 3) == 5\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],d = 10) == 20\n assert candidate(arr = [1, 5, 3, 8, 2, 7, 4, 9, 6, 10],d = 5) == 5\n assert candidate(arr = [10, 1, 10, 1, 10, 1, 10],d = 2) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],d = 6) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17],d = 4) == 13\n assert candidate(arr = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 17\n assert candidate(arr = [6, 1, 5, 3, 2, 7, 4],d = 3) == 4\n assert candidate(arr = [6, 8, 9, 2, 1, 5, 3, 4, 7],d = 2) == 3\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 1) == 2\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 2) == 6\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 1) == 9\n assert candidate(arr = [6, 12, 8, 14, 3, 10, 11, 9, 5, 7, 2, 4, 13, 1, 6],d = 4) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 15\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 20\n assert candidate(arr = [10, 20, 30, 40, 50, 45, 44, 43, 42, 41],d = 3) == 6\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 6) == 15\n assert candidate(arr = [4, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],d = 3) == 4\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 3) == 5\n assert candidate(arr = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],d = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 2) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 2) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 10) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 3) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10],d = 5) == 6\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 2) == 6\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8],d = 2) == 5\n assert candidate(arr = [3, 8, 1, 6, 2, 9, 5, 4, 7],d = 3) == 4\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 10\n assert candidate(arr = [2, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8],d = 2) == 3\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1],d = 2) == 3\n assert candidate(arr = [8, 3, 5, 2, 4, 6, 7, 1, 9],d = 3) == 6\n assert candidate(arr = [3, 1, 5, 4, 2, 6, 7, 8, 9, 1],d = 5) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 5) == 10\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 7, 9],d = 3) == 6\n assert candidate(arr = [10, 20, 15, 25, 30, 5, 40, 35, 50, 45],d = 5) == 6\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 1) == 1\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10],d = 1) == 2\n assert candidate(arr = [1, 6, 5, 4, 3, 2, 7],d = 3) == 5\n assert candidate(arr = [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],d = 5) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 15\n assert candidate(arr = [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],d = 2) == 19\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [5, 1, 4, 1, 3, 1, 2, 1],d = 2) == 5\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],d = 5) == 20\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 9) == 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],d = 3) == 20\n assert candidate(arr = [5, 6, 1, 2, 9, 3, 4, 8, 7, 10],d = 3) == 4\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],d = 4) == 2\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [1, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],d = 4) == 5\n assert candidate(arr = [1, 6, 3, 5, 2, 4, 7, 8, 10, 9],d = 4) == 6\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],d = 5) == 10\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],d = 3) == 11\n assert candidate(arr = [3, 1, 2, 1, 3, 1, 2, 1, 3],d = 1) == 2\n assert candidate(arr = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],d = 5) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 4) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 4) == 9\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],d = 5) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 3) == 6\n assert candidate(arr = [10, 2, 8, 4, 7, 9, 3, 1, 5, 6],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],d = 2) == 3\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 5) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 3) == 10\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 4) == 10\n assert candidate(arr = [7, 2, 8, 9, 1, 3, 5, 6, 4],d = 3) == 4\n assert candidate(arr = [5, 1, 3, 4, 2, 6, 7, 8, 9, 10],d = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],d = 3) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 9\n assert candidate(arr = [5, 1, 3, 2, 4, 6, 7, 8, 10, 9],d = 2) == 7\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 2) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1],d = 2) == 6\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9],d = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],d = 3) == 8\n assert candidate(arr = [8, 7, 6, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8],d = 3) == 5\n assert candidate(arr = [3, 5, 1, 2, 4, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 4) == 18\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10],d = 4) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 5, 5, 5, 1, 5, 5, 5, 1],d = 2) == 2\n assert candidate(arr = [2, 1, 5, 3, 4, 8, 6, 7, 10, 9],d = 3) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5],d = 5) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 10\n assert candidate(arr = [8, 3, 5, 2, 4, 7, 6, 1, 10, 9],d = 5) == 5\n assert candidate(arr = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],d = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n", "comparison": "exact"}, "public_tests": ["[6,4,14,6,8,13,9,7,10,6,12]\n2", "[3,3,3,3,3]\n3", "[7,6,5,4,3,2,1]\n1"], "hints": ["Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]).", "dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i."], "metadata": {"canonical_parameter_names": ["arr", "d"], "leetcode_dataset_entry_point": "Solution().maxJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:18+00:00", "tests_total": 122, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxJumps(self, arr: list[int], d: int) -> int:", "container": "Solution", "callable": "maxJumps", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1342, "task_id": "number-of-steps-to-reduce-a-number-to-zero", "difficulty": "Easy", "problem_description": "Given an integer num, return the number of steps to reduce it to zero.\n\nIn one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.\n\nExample 1:\n\nInput: num = 14\nOutput: 6\nExplanation:\nStep 1) 14 is even; divide by 2 and obtain 7.\nStep 2) 7 is odd; subtract 1 and obtain 6.\nStep 3) 6 is even; divide by 2 and obtain 3.\nStep 4) 3 is odd; subtract 1 and obtain 2.\nStep 5) 2 is even; divide by 2 and obtain 1.\nStep 6) 1 is odd; subtract 1 and obtain 0.\n\nExample 2:\n\nInput: num = 8\nOutput: 4\nExplanation:\nStep 1) 8 is even; divide by 2 and obtain 4.\nStep 2) 4 is even; divide by 2 and obtain 2.\nStep 3) 2 is even; divide by 2 and obtain 1.\nStep 4) 1 is odd; subtract 1 and obtain 0.\n\nExample 3:\n\nInput: num = 123\nOutput: 12\n\nConstraints:\n\n- 0 <= num <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 14) == 6\n assert candidate(num = 1000000) == 26\n assert candidate(num = 8) == 4\n assert candidate(num = 65535) == 31\n assert candidate(num = 0) == 0\n assert candidate(num = 2) == 2\n assert candidate(num = 1) == 1\n assert candidate(num = 123) == 12\n assert candidate(num = 8191) == 25\n assert candidate(num = 750000) == 29\n assert candidate(num = 500000) == 25\n assert candidate(num = 131072) == 18\n assert candidate(num = 1023) == 19\n assert candidate(num = 777777) == 31\n assert candidate(num = 127) == 13\n assert candidate(num = 888888) == 27\n assert candidate(num = 16384) == 15\n assert candidate(num = 31) == 9\n assert candidate(num = 100001) == 23\n assert candidate(num = 8192) == 14\n assert candidate(num = 15) == 7\n assert candidate(num = 32768) == 16\n assert candidate(num = 63) == 11\n assert candidate(num = 3125) == 17\n assert candidate(num = 131071) == 33\n assert candidate(num = 16383) == 27\n assert candidate(num = 665772) == 27\n assert candidate(num = 4096) == 13\n assert candidate(num = 511) == 17\n assert candidate(num = 524288) == 20\n assert candidate(num = 7) == 5\n assert candidate(num = 543210) == 28\n assert candidate(num = 567890) == 27\n assert candidate(num = 255) == 15\n assert candidate(num = 1024) == 11\n assert candidate(num = 100000) == 22\n assert candidate(num = 54321) == 22\n assert candidate(num = 262143) == 35\n assert candidate(num = 123456) == 22\n assert candidate(num = 999999) == 31\n assert candidate(num = 32767) == 29\n assert candidate(num = 65536) == 17\n assert candidate(num = 2048) == 12\n assert candidate(num = 3) == 3\n assert candidate(num = 987654) == 27\n", "comparison": "exact"}, "public_tests": ["14", "8", "123"], "hints": ["Simulate the process to get the final answer."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:20+00:00", "tests_total": 59, "tests_dropped": 14, "flags": [], "topic_tags": ["math", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def numberOfSteps(self, num: int) -> int:", "container": "Solution", "callable": "numberOfSteps", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1343, "task_id": "number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold", "difficulty": "Medium", "problem_description": "Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.\n\nExample 1:\n\nInput: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4\nOutput: 3\nExplanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).\n\nExample 2:\n\nInput: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5\nOutput: 6\nExplanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^4\n- 1 <= k <= arr.length\n- 0 <= threshold <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 5, 5, 5, 8],k = 3,threshold = 4) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],k = 3,threshold = 5) == 5\n assert candidate(arr = [10000, 10000, 10000],k = 3,threshold = 10000) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 3) == 2\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 1,threshold = 10000) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],k = 2,threshold = 1) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50],k = 1,threshold = 10) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,threshold = 1) == 6\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5,threshold = 5) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 4,threshold = 6) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 5,threshold = 5) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 5,threshold = 10000) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],k = 4,threshold = 3) == 4\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2,threshold = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 2) == 3\n assert candidate(arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3],k = 3,threshold = 5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50],k = 4,threshold = 25) == 2\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 6,threshold = 15) == 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],k = 10,threshold = 13) == 8\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 8, 7, 9, 10],k = 3,threshold = 6) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7,threshold = 7) == 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 = 10,threshold = 10.5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,threshold = 55) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3,threshold = 3) == 6\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,threshold = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 6,threshold = 10) == 8\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 = 5,threshold = 5) == 9\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20,threshold = 9) == 1\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,threshold = 5) == 11\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 = 7,threshold = 10) == 8\n assert candidate(arr = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 6,threshold = 3) == 8\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 10,threshold = 25) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 20,threshold = 5000) == 1\n assert candidate(arr = [3, 6, 1, 3, 9, 6, 1, 7, 8, 2],k = 3,threshold = 5) == 4\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 = 5,threshold = 5) == 9\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 = 10,threshold = 3) == 11\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 15,threshold = 50) == 6\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 = 19,threshold = 1) == 2\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 11,threshold = 800) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,threshold = 5) == 4\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 7,threshold = 5000) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 10,threshold = 5000) == 6\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 3,threshold = 10) == 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],k = 10,threshold = 1) == 11\n assert candidate(arr = [4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000],k = 3,threshold = 5000) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5.5) == 3\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 5,threshold = 5000) == 3\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 = 5,threshold = 1.5) == 8\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 3,threshold = 10) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2,threshold = 5) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,threshold = 8) == 6\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 = 5,threshold = 5) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,threshold = 55) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7,threshold = 15) == 5\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10,threshold = 10000) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5,threshold = 12) == 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],k = 10,threshold = 10) == 6\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 7,threshold = 92) == 5\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 = 5,threshold = 20) == 8\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 = 5,threshold = 15) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3,threshold = 55) == 4\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 8,threshold = 9000) == 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],k = 6,threshold = 10) == 8\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 550) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7,threshold = 1) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 4) == 9\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3,threshold = 2) == 18\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5,threshold = 5000) == 6\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 = 10,threshold = 10.5) == 6\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 2,threshold = 5000) == 9\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 7,threshold = 15) == 4\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, 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,threshold = 1) == 73\n assert candidate(arr = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6,threshold = 5) == 9\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 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],k = 5,threshold = 10) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7,threshold = 15) == 5\n assert candidate(arr = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 10,threshold = 15) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,threshold = 15) == 6\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 4,threshold = 2) == 18\n assert candidate(arr = [1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10],k = 3,threshold = 3) == 7\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6,threshold = 55) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,threshold = 55) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 450) == 4\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 = 3,threshold = 15) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6,threshold = 10) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,threshold = 500) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9,threshold = 9999) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,threshold = 8) == 3\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,threshold = 15) == 4\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 8,threshold = 100) == 9\n assert candidate(arr = [3, 5, 1, 8, 7, 9, 4, 6, 2, 10, 11, 12],k = 5,threshold = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2,threshold = 500) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\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 = 10,threshold = 0.5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 6) == 3\n", "comparison": "exact"}, "public_tests": ["[2,2,2,2,5,5,5,8]\n3\n4", "[11,13,17,23,29,31,7,5,2,3]\n3\n5"], "hints": ["Start with a window of size K and test its average against the threshold.", "Keep moving the window by one element maintaining its size k until you cover the whole array. Count the number of windows that have an average greater than or equal to the threshold."], "metadata": {"canonical_parameter_names": ["arr", "k", "threshold"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:22+00:00", "tests_total": 108, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def numOfSubarrays(self, arr: list[int], k: int, threshold: int) -> int:", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1344, "task_id": "angle-between-hands-of-a-clock", "difficulty": "Medium", "problem_description": "Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.\n\nAnswers within 10^-5 of the actual value will be accepted as correct.\n\nExample 1:\n\nInput: hour = 12, minutes = 30\nOutput: 165\n\nExample 2:\n\nInput: hour = 3, minutes = 30\nOutput: 75\n\nExample 3:\n\nInput: hour = 3, minutes = 15\nOutput: 7.5\n\nConstraints:\n\n- 1 <= hour <= 12\n- 0 <= minutes <= 59\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(hour=3, minutes=30), 75.0)\n assert answers_match(candidate(hour=11, minutes=59), 5.5)\n assert answers_match(candidate(hour=3, minutes=15), 7.5)\n assert answers_match(candidate(hour=7, minutes=30), 45.0)\n assert answers_match(candidate(hour=11, minutes=0), 30.0)\n assert answers_match(candidate(hour=2, minutes=10), 5.0)\n assert answers_match(candidate(hour=12, minutes=30), 165.0)\n assert answers_match(candidate(hour=1, minutes=0), 30.0)\n assert answers_match(candidate(hour=1, minutes=55), 87.5)\n assert answers_match(candidate(hour=9, minutes=45), 22.5)\n assert answers_match(candidate(hour=1, minutes=5), 2.5)\n assert answers_match(candidate(hour=12, minutes=0), 0.0)\n assert answers_match(candidate(hour=6, minutes=0), 180.0)\n assert answers_match(candidate(hour=7, minutes=10), 155.0)\n assert answers_match(candidate(hour=7, minutes=35), 17.5)\n assert answers_match(candidate(hour=2, minutes=5), 32.5)\n assert answers_match(candidate(hour=6, minutes=15), 97.5)\n assert answers_match(candidate(hour=5, minutes=0), 150.0)\n assert answers_match(candidate(hour=2, minutes=47), 161.5)\n assert answers_match(candidate(hour=4, minutes=0), 120.0)\n assert answers_match(candidate(hour=10, minutes=25), 162.5)\n assert answers_match(candidate(hour=8, minutes=23), 113.5)\n assert answers_match(candidate(hour=11, minutes=15), 112.5)\n assert answers_match(candidate(hour=4, minutes=50), 155.0)\n assert answers_match(candidate(hour=8, minutes=18), 141.0)\n assert answers_match(candidate(hour=8, minutes=20), 130.0)\n assert answers_match(candidate(hour=10, minutes=31), 129.5)\n assert answers_match(candidate(hour=5, minutes=10), 95.0)\n assert answers_match(candidate(hour=12, minutes=15), 82.5)\n assert answers_match(candidate(hour=5, minutes=14), 73.0)\n assert answers_match(candidate(hour=5, minutes=45), 97.5)\n assert answers_match(candidate(hour=12, minutes=59), 35.5)\n assert answers_match(candidate(hour=12, minutes=1), 5.5)\n assert answers_match(candidate(hour=10, minutes=10), 115.0)\n assert answers_match(candidate(hour=7, minutes=22), 89.0)\n assert answers_match(candidate(hour=12, minutes=47), 101.5)\n assert answers_match(candidate(hour=2, minutes=40), 160.0)\n assert answers_match(candidate(hour=5, minutes=55), 152.5)\n assert answers_match(candidate(hour=7, minutes=0), 150.0)\n assert answers_match(candidate(hour=4, minutes=48), 144.0)\n assert answers_match(candidate(hour=6, minutes=37), 23.5)\n assert answers_match(candidate(hour=2, minutes=24), 72.0)\n assert answers_match(candidate(hour=8, minutes=40), 20.0)\n assert answers_match(candidate(hour=5, minutes=15), 67.5)\n assert answers_match(candidate(hour=4, minutes=10), 65.0)\n assert answers_match(candidate(hour=8, minutes=50), 35.0)\n assert answers_match(candidate(hour=4, minutes=40), 100.0)\n assert answers_match(candidate(hour=4, minutes=25), 17.5)\n assert answers_match(candidate(hour=1, minutes=37), 173.5)\n assert answers_match(candidate(hour=3, minutes=47), 168.5)\n assert answers_match(candidate(hour=10, minutes=48), 36.0)\n assert answers_match(candidate(hour=8, minutes=32), 64.0)\n assert answers_match(candidate(hour=1, minutes=10), 25.0)\n assert answers_match(candidate(hour=7, minutes=5), 177.5)\n assert answers_match(candidate(hour=6, minutes=30), 15.0)\n assert answers_match(candidate(hour=7, minutes=59), 114.5)\n assert answers_match(candidate(hour=8, minutes=28), 86.0)\n assert answers_match(candidate(hour=9, minutes=27), 121.5)\n assert answers_match(candidate(hour=4, minutes=55), 177.5)\n assert answers_match(candidate(hour=10, minutes=35), 107.5)\n assert answers_match(candidate(hour=7, minutes=32), 34.0)\n assert answers_match(candidate(hour=6, minutes=33), 1.5)\n assert answers_match(candidate(hour=10, minutes=20), 170.0)\n assert answers_match(candidate(hour=1, minutes=50), 115.0)\n assert answers_match(candidate(hour=5, minutes=37), 53.5)\n assert answers_match(candidate(hour=5, minutes=47), 108.5)\n assert answers_match(candidate(hour=11, minutes=5), 57.5)\n assert answers_match(candidate(hour=2, minutes=30), 105.0)\n assert answers_match(candidate(hour=2, minutes=20), 50.0)\n assert answers_match(candidate(hour=12, minutes=45), 112.5)\n assert answers_match(candidate(hour=8, minutes=0), 120.0)\n assert answers_match(candidate(hour=7, minutes=47), 48.5)\n", "comparison": "float"}, "public_tests": ["12\n30", "3\n30", "3\n15"], "hints": ["The tricky part is determining how the minute hand affects the position of the hour hand.", "Calculate the angles separately then find the difference."], "metadata": {"canonical_parameter_names": ["hour", "minutes"], "leetcode_dataset_entry_point": "Solution().angleClock", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:24+00:00", "tests_total": 72, "tests_dropped": 0, "flags": ["decimal_answer", "has_images"], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def angleClock(self, hour: int, minutes: int) -> float:", "container": "Solution", "callable": "angleClock", "parameters": [{"name": "hour", "type": "int"}, {"name": "minutes", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1345, "task_id": "jump-game-iv", "difficulty": "Hard", "problem_description": "Given an array of integers arr, you are initially positioned at the first index of the array.\n\nIn one step you can jump from index i to index:\n\n- i + 1 where: i + 1 < arr.length.\n- i - 1 where: i - 1 >= 0.\n- j where: arr[i] == arr[j] and i != j.\n\nReturn the minimum number of steps to reach the last index of the array.\n\nNotice that you can not jump outside of the array at any time.\n\nExample 1:\n\nInput: arr = [100,-23,-23,404,100,23,23,23,3,404]\nOutput: 3\nExplanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.\n\nExample 2:\n\nInput: arr = [7]\nOutput: 0\nExplanation: Start index is the last index. You do not need to jump.\n\nExample 3:\n\nInput: arr = [7,6,9,6,9,6,9,7]\nOutput: 1\nExplanation: You can jump directly from index 0 to index 7 which is last index of the array.\n\nConstraints:\n\n- 1 <= arr.length <= 5 * 10^4\n- -10^8 <= arr[i] <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [11, 22, 7, 7, 7, 7, 7, 7, 7, 22, 13]) == 3\n assert candidate(arr = [6, 1, 9, 6, 9, 1, 9, 6, 1, 9]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 11, 11, 11, 11, 11, 11]) == 3\n assert candidate(arr = [7, 6, 9, 6, 9, 6, 9, 7]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 2\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\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 2, 3, 5, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [100, -23, -23, 404, 100, 23, 23, 23, 3, 404]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7, 7, 7, 7, 11, 11, 11, 11, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 12, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 20, 30, 20, 10, 10, 20, 30, 10]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 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]) == 1\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, 5, 5, 5, 5, 5, 5, 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(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1]) == 1\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [6, 1, 9, 8, 4, 10, 9, 4, 10, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9]) == 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, 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, 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\n assert candidate(arr = [10, 22, 10, 20, 11, 22, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110, 10, 120, 10, 130, 10, 140, 10, 150, 10, 160, 10, 170, 10, 180, 10, 190, 10, 200]) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 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\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [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\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\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [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, 10, 10, 10, 10, 10, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [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, 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]) == 1\n assert candidate(arr = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(arr = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\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]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [1, 3, 5, 3, 1, 2, 4, 2, 6, 4, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\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, 2]) == 2\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, 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]) == 37\n assert candidate(arr = [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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [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]) == 1\n assert candidate(arr = [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(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]) == 1\n assert candidate(arr = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [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, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4]) == 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, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n", "comparison": "exact"}, "public_tests": ["[100,-23,-23,404,100,23,23,23,3,404]", "[7]", "[7,6,9,6,9,6,9,7]"], "hints": ["Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j].", "Start bfs from node 0 and keep distance. The answer is the distance when you reach node n-1."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:27+00:00", "tests_total": 60, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def minJumps(self, arr: list[int]) -> int:", "container": "Solution", "callable": "minJumps", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1346, "task_id": "check-if-n-and-its-double-exist", "difficulty": "Easy", "problem_description": "Given an array arr of integers, check if there exist two indices i and j such that :\n\n- i != j\n- 0 <= i, j < arr.length\n- arr[i] == 2 * arr[j]\n\nExample 1:\n\nInput: arr = [10,2,5,3]\nOutput: true\nExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]\n\nExample 2:\n\nInput: arr = [3,1,7,11]\nOutput: false\nExplanation: There is no i and j that satisfy the conditions.\n\nConstraints:\n\n- 2 <= arr.length <= 500\n- -10^3 <= arr[i] <= 10^3\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [6, 10, 1, 0, -3, 3]) == True\n assert candidate(arr = [-3, -6, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [-10, -20, -5, -3]) == True\n assert candidate(arr = [1, 2, 3, 6, 12]) == True\n assert candidate(arr = [0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-10, 10]) == False\n assert candidate(arr = [10, 2, 5, 3]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(arr = [1, 2, 4, 8, 16]) == True\n assert candidate(arr = [-2, 0, 10, -19, 4, 6, -8]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == False\n assert candidate(arr = [3, 1, 7, 11]) == False\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [-10, -5, -3, -1, 2]) == True\n assert candidate(arr = [10, 5, 15, 20, 25]) == True\n assert candidate(arr = [1, -1, 2, -2, 4, -4, 8, -8, 16, -16]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8]) == True\n assert candidate(arr = [2, 1, 4, 2, 8, 4, 16]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 20, 40]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [-100, -50, -25, -12, -6, -3, -1, 0, 1, 2, 4]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -10, -20]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [101, 202, 50, 25, 12, 6, 3]) == True\n assert candidate(arr = [1000, 501, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 60]) == True\n assert candidate(arr = [-1, 2, -3, 6, -4, 8]) == False\n assert candidate(arr = [-10, -20, 5, 3, 15]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 250, 125]) == True\n assert candidate(arr = [-1, -2, -3, -6, -12]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [100, 50, 25, 12.5, 6.25, 3.125, 1.5625]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]) == True\n assert candidate(arr = [3, 6, 9, 18, 27, 54, 81]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 36, 72]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5]) == True\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [0, 0, 1, 2, 4]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 38]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(arr = [-2, 2, -4, 4, -8, 8, -16, 16]) == True\n assert candidate(arr = [-10, -5, -15, -20, -25]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [-1, 1, -2, 2, -4, 4, 8, -8]) == True\n assert candidate(arr = [0, 1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [13, 26, 52, 104, 208, 416]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [-5, 10, -15, 20, -25, 50, -75]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 75]) == True\n assert candidate(arr = [6, 12, 18, 24, 48]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40]) == True\n assert candidate(arr = [1000, -500, 250, -125, 62.5, 31.25]) == True\n assert candidate(arr = [-1, 2, -2, 4, -4, 8]) == True\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) == True\n assert candidate(arr = [15, 30, 45, 90, 135, 270]) == True\n assert candidate(arr = [-10, -5, -1, -2, -3, -4, -6, -8, -12, -16]) == True\n assert candidate(arr = [10, 20, 40, 80, 160, 320, 640]) == True\n assert candidate(arr = [-10, -5, 0, 5, 10]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -100, -200, -300]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15, -18, -21, -24]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 10]) == True\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [100, 51, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 17, 19, 21]) == False\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 3, 9, 27, 81, 243, 729]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 8, 16]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [9, 18, 36, 72, 144, 288, 576]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 18, 36, 72]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62.5]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0]) == True\n assert candidate(arr = [1, 5, 10, 20, 25, 50, 100]) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [-2, -4, -6, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -200, -300, -150]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60, 120, 240]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, -1, -2, -4]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896]) == True\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 115]) == True\n assert candidate(arr = [10, 5, 15, 20, 2, 25, 50]) == True\n assert candidate(arr = [-2, -4, -1, -3, -5, -10]) == True\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 27, 54]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0, 32, 0, 64, 0, 128, 0]) == True\n assert candidate(arr = [-2, -4, -8, -16, -32, -64, -128]) == True\n", "comparison": "exact"}, "public_tests": ["[10,2,5,3]", "[3,1,7,11]"], "hints": ["Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1].", "On each step of the loop check if we have seen the element 2 * arr[i] so far.", "Also check if we have seen arr[i] / 2 in case arr[i] % 2 == 0."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().checkIfExist", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:29+00:00", "tests_total": 147, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def checkIfExist(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "checkIfExist", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1347, "task_id": "minimum-number-of-steps-to-make-two-strings-anagram", "difficulty": "Medium", "problem_description": "You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.\n\nReturn the minimum number of steps to make t an anagram of s.\n\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 = \"bab\", t = \"aba\"\nOutput: 1\nExplanation: Replace the first 'a' in t with b, t = \"bba\" which is anagram of s.\n\nExample 2:\n\nInput: s = \"leetcode\", t = \"practice\"\nOutput: 5\nExplanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.\n\nExample 3:\n\nInput: s = \"anagram\", t = \"mangaar\"\nOutput: 0\nExplanation: \"anagram\" and \"mangaar\" are anagrams.\n\nConstraints:\n\n- 1 <= s.length <= 5 * 10^4\n- s.length == t.length\n- s and t consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abacabadabacaba\",t = \"abcadbabacabaab\") == 1\n assert candidate(s = \"transform\",t = \"formartin\") == 1\n assert candidate(s = \"aabbcc\",t = \"ccbbaa\") == 0\n assert candidate(s = \"minimum\",t = \"numinum\") == 2\n assert candidate(s = \"hello\",t = \"bello\") == 1\n assert candidate(s = \"leetcode\",t = \"practice\") == 5\n assert candidate(s = \"aaabbb\",t = \"bbbaaa\") == 0\n assert candidate(s = \"transform\",t = \"formtrans\") == 0\n assert candidate(s = \"anagram\",t = \"mangaar\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 0\n assert candidate(s = \"bab\",t = \"aba\") == 1\n assert candidate(s = \"aaa\",t = \"bbb\") == 3\n assert candidate(s = \"abc\",t = \"def\") == 3\n assert candidate(s = \"abcde\",t = \"edcba\") == 0\n assert candidate(s = \"xyz\",t = \"zyx\") == 0\n assert candidate(s = \"optimization\",t = \"inipotizaton\") == 1\n assert candidate(s = \"pythonprogramming\",t = \"gnimmargorpnohtyp\") == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",t = \"abcdefghijklmnopqrstuvwzyx\") == 0\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"aquickbrownfoxjumpsoverthelazydog\") == 0\n assert candidate(s = \"bbaacc\",t = \"aabacc\") == 1\n assert candidate(s = \"aabbccddeeff\",t = \"fedcbafedcba\") == 0\n assert candidate(s = \"xylophone\",t = \"poloxynhe\") == 0\n assert candidate(s = \"strength\",t = \"grenstht\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"prognimmargyphnot\") == 0\n assert candidate(s = \"algorithms\",t = \"logarithms\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"programmingpython\") == 0\n assert candidate(s = \"longestword\",t = \"wordlongset\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"mississippi\",t = \"ppissimisss\") == 1\n assert candidate(s = \"mississippi\",t = \"pississippi\") == 1\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 0\n assert candidate(s = \"abracadabra\",t = \"arabracadab\") == 0\n assert candidate(s = \"permutations\",t = \"interpromust\") == 1\n assert candidate(s = \"aabbcceeddffee\",t = \"eeddffccbbbaaa\") == 2\n assert candidate(s = \"programmingisfun\",t = \"funprogrammingis\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"elephant\",t = \"tehlanpe\") == 0\n assert candidate(s = \"elephant\",t = \"talehpen\") == 0\n assert candidate(s = \"permutations\",t = \"pertumations\") == 0\n assert candidate(s = \"synchronized\",t = \"chronizedsyn\") == 0\n assert candidate(s = \"thisisaverylongstring\",t = \"stringlongaverythisis\") == 0\n assert candidate(s = \"interstellar\",t = \"stellarestri\") == 1\n assert candidate(s = \"mississippi\",t = \"pisissmipis\") == 0\n assert candidate(s = \"mississippi\",t = \"psissimippi\") == 1\n assert candidate(s = \"amazingrace\",t = \"raceingazam\") == 0\n assert candidate(s = \"reducibility\",t = \"reducibility\") == 0\n assert candidate(s = \"recharacterization\",t = \"characterizationre\") == 0\n assert candidate(s = \"programming\",t = \"gimmnoprram\") == 1\n assert candidate(s = \"programming\",t = \"remmprogain\") == 1\n assert candidate(s = \"multimedia\",t = \"meediamult\") == 1\n assert candidate(s = \"xylophone\",t = \"phonexylo\") == 0\n assert candidate(s = \"mississippi\",t = \"ssissippiim\") == 0\n assert candidate(s = \"anagramanagram\",t = \"mangaarmangaar\") == 0\n assert candidate(s = \"congratulations\",t = \"congratulations\") == 0\n assert candidate(s = \"algorithm\",t = \"logarithm\") == 0\n assert candidate(s = \"racecar\",t = \"carrace\") == 0\n assert candidate(s = \"congratulations\",t = \"gratulationscon\") == 0\n assert candidate(s = \"optimization\",t = \"tionsimipazy\") == 2\n assert candidate(s = \"rhythm\",t = \"myrthh\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"ffeeddccbbaa\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"unitedstates\",t = \"statedinutes\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"expialidocioussupercalifragilistic\") == 0\n assert candidate(s = \"abacabadabacabadabacabad\",t = \"bacdabcdabcdabcdabcdabcd\") == 6\n assert candidate(s = \"abacaxi\",t = \"xicabaa\") == 0\n assert candidate(s = \"programming\",t = \"gnimmargorp\") == 0\n assert candidate(s = \"mississippi\",t = \"ppiimississ\") == 0\n", "comparison": "exact"}, "public_tests": ["\"bab\"\n\"aba\"", "\"leetcode\"\n\"practice\"", "\"anagram\"\n\"mangaar\""], "hints": ["Count the frequency of characters of each string.", "Loop over all characters if the frequency of a character in t is less than the frequency of the same character in s then add the difference between the frequencies to the answer."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:31+00:00", "tests_total": 113, "tests_dropped": 44, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def minSteps(self, s: str, t: str) -> int:", "container": "Solution", "callable": "minSteps", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1349, "task_id": "maximum-students-taking-exam", "difficulty": "Hard", "problem_description": "Given a m * n matrix seats that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.\n\nStudents can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible.\n\nStudents must be placed in seats in good condition.\n\nExample 1:\n\nInput: seats = [[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],\n [\".\",\"#\",\"#\",\"#\",\"#\",\".\"],\n [\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]\nOutput: 4\nExplanation: Teacher can place 4 students in available seats so they don't cheat on the exam.\n\nExample 2:\n\nInput: seats = [[\".\",\"#\"],\n [\"#\",\"#\"],\n [\"#\",\".\"],\n [\"#\",\"#\"],\n [\".\",\"#\"]]\nOutput: 3\nExplanation: Place all students in available seats.\n\nExample 3:\n\nInput: seats = [[\"#\",\".\",\".\",\".\",\"#\"],\n [\".\",\"#\",\".\",\"#\",\".\"],\n [\".\",\".\",\"#\",\".\",\".\"],\n [\".\",\"#\",\".\",\"#\",\".\"],\n [\"#\",\".\",\".\",\".\",\"#\"]]\nOutput: 10\nExplanation: Place students in available seats in column 1, 3 and 5.\n\nConstraints:\n\n- seats contains only characters '.' and'#'.\n- m == seats.length\n- n == seats[i].length\n- 1 <= m <= 8\n- 1 <= n <= 8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['.', '.#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 31\n assert candidate(seats = [['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.'], ['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.']]) == 8\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == 15\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#']]) == 9\n assert candidate(seats = [['#', '.', '#', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 30\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 14\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '.', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.']]) == 21\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#', '.', '#']]) == 19\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '#', '.', '#', '.', '.', '#'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '#', '.', '#']]) == 20\n assert candidate(seats = [['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]) == 0\n assert candidate(seats = [['.', '.', '#', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.']]) == 16\n assert candidate(seats = [['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.'], ['.', '.', '.', '#', '.', '#']]) == 13\n assert candidate(seats = [['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['#', '#', '.', '#', '#', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.']]) == 15\n assert candidate(seats = [['.', '.', '#', '#', '.', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 14\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 22\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]) == 6\n assert candidate(seats = [['#', '.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '#']]) == 11\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 24\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '#', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 29\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#']]) == 7\n assert candidate(seats = [['#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 20\n assert candidate(seats = [['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.']]) == 12\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '#', '.']]) == 15\n", "comparison": "exact"}, "public_tests": ["[[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],[\".\",\"#\",\"#\",\"#\",\"#\",\".\"],[\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]", "[[\".\",\"#\"],[\"#\",\"#\"],[\"#\",\".\"],[\"#\",\"#\"],[\".\",\"#\"]]", "[[\"#\",\".\",\".\",\".\",\"#\"],[\".\",\"#\",\".\",\"#\",\".\"],[\".\",\".\",\"#\",\".\",\".\"],[\".\",\"#\",\".\",\"#\",\".\"],[\"#\",\".\",\".\",\".\",\"#\"]]"], "hints": ["Students in row i only can see exams in row i+1.", "Use Dynamic programming to compute the result given a (current row, bitmask people seated in previous row)."], "metadata": {"canonical_parameter_names": ["seats"], "leetcode_dataset_entry_point": "Solution().maxStudents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:33+00:00", "tests_total": 66, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "matrix", "bitmask", "maximum-flow", "maximum-matching", "bipartite-graph", "edmonds-karp-algorithm", "mpm-algorithm", "push-relabel-algorithm", "minimum-cut", "matching-graph", "flow-network", "dinics-algorithm"]}, "language": "python", "interface": {"raw_signature": "def maxStudents(self, seats: list[list[str]]) -> int:", "container": "Solution", "callable": "maxStudents", "parameters": [{"name": "seats", "type": "list[list[str]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1351, "task_id": "count-negative-numbers-in-a-sorted-matrix", "difficulty": "Easy", "problem_description": "Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.\n\nExample 1:\n\nInput: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]\nOutput: 8\nExplanation: There are 8 negatives number in the matrix.\n\nExample 2:\n\nInput: grid = [[3,2],[1,0]]\nOutput: 0\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 100\n- -100 <= grid[i][j] <= 100\n\nFollow up: Could you find an O(n + m) solution?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -1], [-1, -1]]) == 4\n assert candidate(grid = [[-3], [-2], [-1], [0], [1]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[-1, -1, -1], [-5, -5, -5]]) == 6\n assert candidate(grid = [[3, 2], [1, 0]]) == 0\n assert candidate(grid = [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]]) == 8\n assert candidate(grid = [[1, -1], [-1, -1]]) == 3\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 = [[5, 2, 1], [4, 3, 1], [3, 2, 1]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[100, 90, 80, -10], [-9, -8, -7, -6], [-5, -4, -3, -2], [-4, -3, -2, -1]]) == 13\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[-5]]) == 1\n assert candidate(grid = [[1, 2, 3], [0, -1, -2], [-3, -4, -5]]) == 5\n assert candidate(grid = [[-1]]) == 1\n assert candidate(grid = [[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]]) == 6\n assert candidate(grid = [[-1, 0], [0, -1]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 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]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 0], [-1, 0, 0, 0, 0], [-1, -1, 0, 0, 0], [-1, -1, -1, 0, 0], [-1, -1, -1, -1, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, -1]]) == 1\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]]) == 25\n assert candidate(grid = [[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], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\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, -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]]) == 100\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-2, -2, -2, -2, -2, -2, -2, -2, -2, -2], [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3]]) == 30\n assert candidate(grid = [[1, 1, 1, -1, -1, -1], [1, 1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[9, -9, 8, -8], [7, -7, 6, -6], [5, -5, 4, -4], [3, -3, 2, -2], [1, -1, 0, -1]]) == 15\n assert candidate(grid = [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, -1, -2], [-3, -4, -5, -6, -7, -8], [-9, -10, -11, -12, -13, -14]]) == 14\n assert candidate(grid = [[10, -10, 20, -20, 30, -30], [9, -9, 18, -18, 27, -27], [8, -8, 16, -16, 24, -24], [7, -7, 14, -14, 21, -21]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, -1, -1, -1], [0, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[-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]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 20\n assert candidate(grid = [[1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1]]) == 15\n assert candidate(grid = [[-50, -40, -30, -20, -10], [30, 20, 10, 0, -10], [-20, -10, 0, 10, 20], [10, 0, 10, 20, 30], [0, 10, 20, 30, 40]]) == 0\n assert candidate(grid = [[90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-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\n assert candidate(grid = [[-1, -1, -1, 0], [1, 0, -1, -1], [1, -1, -1, -1], [-1, -1, -1, -1]]) == 11\n assert candidate(grid = [[-3, -2, -1, 0], [2, 1, 0, -1], [1, 0, -1, -2], [0, -1, -2, -3]]) == 6\n assert candidate(grid = [[10, -5, 3, 2, -1], [-3, 0, -1, 0, -4], [-5, -6, -7, -8, -9]]) == 14\n assert candidate(grid = [[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], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-100, -99, -98, -97, -96], [0, 0, 0, -1, -2], [-3, -4, -5, -6, -7], [-8, -9, -10, -11, -12]]) == 14\n assert candidate(grid = [[1, -1, -2, -3], [-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6]]) == 15\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]]) == 30\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, 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, -1], [0, 0, 0, 0, 0, 0, 0, -1, -1, -1], [0, 0, 0, 0, 0, 0, -1, -1, -1, -1], [0, 0, 0, 0, 0, -1, -1, -1, -1, -1], [0, 0, 0, 0, -1, -1, -1, -1, -1, -1], [0, 0, 0, -1, -1, -1, -1, -1, -1, -1], [0, 0, -1, -1, -1, -1, -1, -1, -1, -1], [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 45\n assert candidate(grid = [[-1, 0, 1, 2, 3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50]]) == 14\n assert candidate(grid = [[10, -10, 20, -20], [5, -5, 15, -15], [0, 0, 0, 0], [-1, -2, -3, -4]]) == 4\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, 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], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-11, -12, -13, -14, -15, -16, -17, -18, -19, -20], [-21, -22, -23, -24, -25, -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(grid = [[-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == 15\n assert candidate(grid = [[2, 1, 0, -1, -2], [1, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6]]) == 19\n assert candidate(grid = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [80, 70, 60, 50, 40, 30, 20, 10, 0, -10], [70, 60, 50, 40, 30, 20, 10, 0, -10, -20], [60, 50, 40, 30, 20, 10, 0, -10, -20, -30]]) == 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\n assert candidate(grid = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 16\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\n assert candidate(grid = [[1, -1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, -1, -2], [2, 1, -2, -3, -4], [1, 0, -3, -4, -5]]) == 8\n assert candidate(grid = [[10, -5, -4, -3], [-7, -6, -5, -4], [-8, -7, -6, -5], [-9, -8, -7, -6]]) == 15\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5]]) == 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]]) == 25\n assert candidate(grid = [[1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 90\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, 0, -1, -2], [0, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5]]) == 15\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], [-50, -49, -48, -47, -46, -45, -44, -43, -42, -41], [-40, -39, -38, -37, -36, -35, -34, -33, -32, -31], [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21], [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11], [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]]) == 100\n assert candidate(grid = [[-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]]) == 25\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, -1, -2], [0, -1, -2, -3], [-1, -2, -3, -4]]) == 9\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1]]) == 20\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, -1], [0, 0, -1, -1], [0, -1, -1, -1]]) == 6\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5], [30, 20, 10, 0, -10]]) == 2\n assert candidate(grid = [[10, 8, 6, 4, 2, 0, -2, -4], [-6, -8, -10, -12, -14, -16, -18, -20], [-10, -12, -14, -16, -18, -20, -22, -24]]) == 18\n assert candidate(grid = [[-10, -20, -30, -40], [-20, -30, -40, -50], [-30, -40, -50, -60], [-40, -50, -60, -70]]) == 16\n assert candidate(grid = [[-100, -99, -98, -97], [-96, -95, -94, -93], [-92, -91, -90, -89], [-88, -87, -86, -85]]) == 16\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]]) == 0\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 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]]) == 40\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]]) == 24\n assert candidate(grid = [[-100, -99, -98], [-99, -98, -97], [-98, -97, -96], [-97, -96, -95]]) == 12\n assert candidate(grid = [[10, 5, 0, -10, -20], [-5, -15, -20, -25, -30], [-1, -2, -3, -4, -5]]) == 12\n assert candidate(grid = [[1, -1, 0], [1, -1, 0], [1, -1, 0]]) == 6\n assert candidate(grid = [[1, 0, -1], [-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == 10\n assert candidate(grid = [[9, 7, 5, 3, 1], [-1, -3, -5, -7, -9], [-2, -4, -6, -8, -10], [-3, -6, -9, -12, -15]]) == 15\n assert candidate(grid = [[0, 0, 0], [0, 0, -1], [0, -1, -2], [-1, -2, -3]]) == 6\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, -1], [3, 2, 1, -1, -2], [2, 1, -1, -2, -3], [1, -1, -2, -3, -4]]) == 10\n assert candidate(grid = [[1, 0, -1], [-1, 0, 1], [0, 1, -1]]) == 1\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -2, -3], [7, 6, 5, 4, 3, 2, 1, -3, -4, -5]]) == 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, -1, -1], [0, 0, 0, -1, -1, -2], [-1, -1, -2, -3, -4, -5]]) == 11\n assert candidate(grid = [[-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]]) == 10\n assert candidate(grid = [[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]]) == 28\n assert candidate(grid = [[5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 9\n assert candidate(grid = [[5, 4, 3, 2, 1], [-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -1, -2], [7, 6, 5, 4, 3, 2, 1, -1, -2, -3], [6, 5, 4, 3, 2, 1, -1, -2, -3, -4], [5, 4, 3, 2, 1, -1, -2, -3, -4, -5], [4, 3, 2, 1, -1, -2, -3, -4, -5, -6], [3, 2, 1, -1, -2, -3, -4, -5, -6, -7], [2, 1, -1, -2, -3, -4, -5, -6, -7, -8], [1, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 45\n assert candidate(grid = [[100, -50, 0], [90, -40, 0], [80, -30, 0], [70, -20, 0], [60, -10, 0]]) == 10\n", "comparison": "exact"}, "public_tests": ["[[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]", "[[3,2],[1,0]]"], "hints": ["Use binary search for optimization or simply brute force."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countNegatives", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:36+00:00", "tests_total": 96, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "binary-search", "matrix"]}, "language": "python", "interface": {"raw_signature": "def countNegatives(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "countNegatives", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1353, "task_id": "maximum-number-of-events-that-can-be-attended", "difficulty": "Medium", "problem_description": "You are given an array of events where events[i] = [startDay_i, endDay_i]. Every event i starts at startDay_iand ends at endDay_i.\n\nYou can attend an event i at any day d where startDay_i <= d <= endDay_i. You can only attend one event at any time d.\n\nReturn the maximum number of events you can attend.\n\nExample 1:\n\nInput: events = [[1,2],[2,3],[3,4]]\nOutput: 3\nExplanation: You can attend all the three events.\nOne way to attend them all is as shown.\nAttend the first event on day 1.\nAttend the second event on day 2.\nAttend the third event on day 3.\n\nExample 2:\n\nInput: events= [[1,2],[2,3],[3,4],[1,2]]\nOutput: 4\n\nConstraints:\n\n- 1 <= events.length <= 10^5\n- events[i].length == 2\n- 1 <= startDay_i <= endDay_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]]) == 5\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(events = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == 5\n assert candidate(events = [[5, 5], [1, 5], [1, 5], [1, 5]]) == 4\n assert candidate(events = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15]]) == 7\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 5\n assert candidate(events = [[1, 2], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(events = [[1, 5], [1, 5], [1, 5], [2, 3], [2, 3]]) == 5\n assert candidate(events = [[1, 2], [2, 3], [3, 4]]) == 3\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 2]]) == 4\n assert candidate(events = [[1, 10], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(events = [[1, 10], [2, 3], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 8\n assert candidate(events = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 2\n assert candidate(events = [[1, 2], [2, 2], [3, 4], [4, 5]]) == 4\n assert candidate(events = [[1, 100], [1, 100], [1, 100]]) == 3\n assert candidate(events = [[1, 100000], [1, 100000], [1, 100000], [1, 100000], [1, 100000]]) == 5\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 9\n assert candidate(events = [[1, 2], [2, 2], [3, 3], [3, 4]]) == 4\n assert candidate(events = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 4\n assert candidate(events = [[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]]) == 20\n assert candidate(events = [[1, 100000], [50000, 60000], [50000, 55000], [30000, 40000], [10000, 20000], [60000, 70000]]) == 6\n assert candidate(events = [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 11\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == 11\n assert candidate(events = [[1, 30000], [2, 29999], [3, 29998], [4, 29997], [5, 29996], [6, 29995], [7, 29994], [8, 29993], [9, 29992], [10, 29991]]) == 10\n assert candidate(events = [[1, 3], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13]]) == 10\n assert candidate(events = [[1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000]]) == 6\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == 10\n assert candidate(events = [[1, 3], [2, 3], [3, 3], [4, 6], [5, 6], [6, 6], [7, 9], [8, 9], [9, 9], [10, 12], [11, 12], [12, 12]]) == 12\n assert candidate(events = [[1, 5], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == 15\n assert candidate(events = [[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], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]]) == 29\n assert candidate(events = [[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]]) == 17\n assert candidate(events = [[1, 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]]) == 30\n assert candidate(events = [[1, 100], [1, 100], [2, 99], [2, 99], [3, 98], [3, 98], [4, 97], [4, 97], [5, 96], [5, 96], [6, 95], [6, 95]]) == 12\n assert candidate(events = [[2, 2], [3, 3], [1, 2], [1, 3], [1, 4]]) == 4\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(events = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16]]) == 15\n assert candidate(events = [[1, 2], [2, 3], [3, 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], [1, 2], [2, 3], [3, 4], [4, 5]]) == 16\n assert candidate(events = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [16, 20], [17, 20], [18, 20], [19, 20], [20, 20]]) == 20\n assert candidate(events = [[1, 2], [3, 4], [2, 3], [4, 5], [1, 5]]) == 5\n assert candidate(events = [[5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]]) == 11\n assert candidate(events = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 5], [5, 10], [1, 3], [3, 5]]) == 10\n assert candidate(events = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [7, 8], [7, 8], [7, 8]]) == 8\n assert candidate(events = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [6, 7], [7, 8], [7, 8], [7, 8], [7, 8], [8, 9], [8, 9], [8, 9], [8, 9], [9, 10], [9, 10], [9, 10], [9, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [3, 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]]) == 20\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 20], [2, 3], [3, 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]]) == 19\n assert candidate(events = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 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(events = [[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]]) == 10\n assert candidate(events = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 5], [3, 4], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 9\n assert candidate(events = [[1, 2], [2, 3], [3, 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]]) == 15\n assert candidate(events = [[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]]) == 18\n assert candidate(events = [[2, 4], [2, 5], [2, 7], [2, 8], [2, 9], [4, 7], [5, 7], [5, 8], [5, 9], [7, 10], [8, 10], [9, 10]]) == 9\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20]]) == 20\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 4], [1, 4], [1, 4], [2, 4], [2, 4], [3, 4], [3, 4], [4, 4], [4, 4], [4, 4]]) == 4\n assert candidate(events = [[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]]) == 20\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 2\n assert candidate(events = [[1, 5], [5, 5], [1, 5], [2, 3], [4, 6]]) == 5\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12]]) == 11\n assert candidate(events = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34], [31, 35], [32, 36], [33, 37], [34, 38], [35, 39], [36, 40], [37, 41], [38, 42], [39, 43], [40, 44], [41, 45], [42, 46], [43, 47], [44, 48], [45, 49], [46, 50]]) == 46\n assert candidate(events = [[1, 5], [2, 3], [3, 4], [2, 5], [1, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 5\n assert candidate(events = [[10, 15], [20, 25], [15, 20], [25, 30], [10, 25], [20, 30], [15, 30]]) == 7\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [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(events = [[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, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41], [41, 43], [43, 45], [45, 47], [47, 49], [49, 51], [51, 53], [53, 55], [55, 57], [57, 59], [59, 61], [61, 63]]) == 31\n assert candidate(events = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60]]) == 10\n assert candidate(events = [[1, 50000], [50001, 100000], [1, 2], [2, 3], [3, 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]]) == 22\n assert candidate(events = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21]]) == 10\n assert candidate(events = [[1, 3], [1, 10], [2, 5], [2, 8], [3, 6], [3, 9], [4, 7], [4, 10], [5, 8], [5, 11], [6, 9], [6, 12], [7, 10], [7, 13], [8, 11], [8, 14], [9, 12], [9, 15], [10, 13], [10, 16]]) == 16\n assert candidate(events = [[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\n assert candidate(events = [[5, 5], [1, 5], [1, 5], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5]]) == 5\n assert candidate(events = [[1, 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]]) == 20\n assert candidate(events = [[1, 2], [3, 4], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 10\n assert candidate(events = [[10, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100], [101, 110], [111, 120], [121, 130], [131, 140], [141, 150], [151, 160]]) == 15\n assert candidate(events = [[1, 5], [1, 5], [2, 6], [2, 6], [3, 7], [3, 7], [4, 8], [4, 8], [5, 9], [5, 9], [6, 10], [6, 10], [7, 11], [7, 11], [8, 12], [8, 12], [9, 13], [9, 13], [10, 14], [10, 14]]) == 14\n assert candidate(events = [[3, 6], [2, 6], [1, 6], [1, 5], [2, 5], [3, 5], [2, 4], [3, 4], [4, 5], [4, 6], [4, 7]]) == 7\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(events = [[1, 3], [2, 5], [3, 7], [4, 10], [5, 15], [6, 20], [7, 25], [8, 30], [9, 35], [10, 40]]) == 10\n assert candidate(events = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]]) == 6\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7]]) == 7\n assert candidate(events = [[1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6]]) == 6\n assert candidate(events = [[1, 10], [1, 20], [1, 30], [2, 20], [2, 30], [2, 40], [3, 30], [3, 40], [3, 50], [4, 40], [4, 50], [4, 60], [5, 50], [5, 60], [5, 70]]) == 15\n assert candidate(events = [[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], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 20000], [1, 30000], [2, 30000], [2, 40000], [3, 40000], [3, 50000], [4, 50000], [4, 60000], [5, 60000], [5, 70000]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 5], [5, 6], [6, 10], [10, 15]]) == 5\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[3,4]]", "[[1,2],[2,3],[3,4],[1,2]]"], "hints": ["Sort the events by the start time and in case of tie by the end time in ascending order.", "Loop over the sorted events. Attend as much as you can and keep the last day occupied. When you try to attend new event keep in mind the first day you can attend a new event in."], "metadata": {"canonical_parameter_names": ["events"], "leetcode_dataset_entry_point": "Solution().maxEvents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:38+00:00", "tests_total": 98, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxEvents(self, events: list[list[int]]) -> int:", "container": "Solution", "callable": "maxEvents", "parameters": [{"name": "events", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1354, "task_id": "construct-target-array-with-multiple-sums", "difficulty": "Hard", "problem_description": "You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :\n\n- let x be the sum of all elements currently in your array.\n- choose index i, such that 0 <= i < n and set the value of arr at index i to x.\n- You may repeat this procedure as many times as needed.\n\nReturn true if it is possible to construct the target array from arr, otherwise, return false.\n\nExample 1:\n\nInput: target = [9,3,5]\nOutput: true\nExplanation: Start with arr = [1, 1, 1]\n[1, 1, 1], sum = 3 choose index 1\n[1, 3, 1], sum = 5 choose index 2\n[1, 3, 5], sum = 9 choose index 0\n[9, 3, 5] Done\n\nExample 2:\n\nInput: target = [1,1,1,2]\nOutput: false\nExplanation: Impossible to create target array from [1,1,1,1].\n\nExample 3:\n\nInput: target = [8,5]\nOutput: true\n\nConstraints:\n\n- n == target.length\n- 1 <= n <= 5 * 10^4\n- 1 <= target[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5]) == False\n assert candidate(target = [1000000000, 1, 1]) == False\n assert candidate(target = [5, 7, 1]) == True\n assert candidate(target = [10, 1]) == True\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [5, 5, 5]) == False\n assert candidate(target = [1000000000, 1000000000]) == False\n assert candidate(target = [1000000000, 1]) == True\n assert candidate(target = [1, 1, 1, 2]) == False\n assert candidate(target = [5, 10, 15]) == False\n assert candidate(target = [1, 1000000000, 1000000000]) == False\n assert candidate(target = [9, 3, 5]) == True\n assert candidate(target = [1, 1, 1]) == True\n assert candidate(target = [2, 900000000]) == False\n assert candidate(target = [8, 5]) == True\n assert candidate(target = [1, 1000000000]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(target = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == False\n assert candidate(target = [21, 17, 13, 9, 5, 1]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(target = [100, 100, 100, 100, 100, 99, 98, 97, 96, 95]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == False\n assert candidate(target = [37, 11, 25, 7, 19]) == False\n assert candidate(target = [41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == False\n assert candidate(target = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == False\n assert candidate(target = [2, 6, 10, 14, 18, 22]) == False\n assert candidate(target = [100, 100, 100, 100, 99]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == False\n assert candidate(target = [13, 11, 10]) == False\n assert candidate(target = [81, 27, 9, 3, 1]) == False\n assert candidate(target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == False\n assert candidate(target = [5, 7, 9, 13, 21, 34, 55]) == False\n assert candidate(target = [10, 5, 15, 20]) == False\n assert candidate(target = [987, 654, 321]) == False\n assert candidate(target = [18, 5, 7]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == False\n assert candidate(target = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(target = [3, 5, 11, 13, 17]) == False\n assert candidate(target = [50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == False\n assert candidate(target = [21, 15, 12]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [7, 14, 21, 28, 35, 42, 49]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [123456789, 987654321, 456789123, 321987654]) == False\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == False\n assert candidate(target = [999999999, 999999999, 1]) == False\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [8, 13, 21, 34, 55, 89]) == False\n assert candidate(target = [100, 99, 98, 97]) == False\n assert candidate(target = [1000000000, 1, 1, 1, 1]) == False\n assert candidate(target = [123456789, 987654321, 111111111]) == False\n assert candidate(target = [17, 7, 17, 7, 17]) == False\n assert candidate(target = [4, 12, 33, 55]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(target = [45, 12, 18, 30, 36, 24]) == False\n assert candidate(target = [314159265, 271828182, 161803398, 141421356]) == False\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == False\n assert candidate(target = [7, 11, 15, 22]) == False\n assert candidate(target = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == False\n assert candidate(target = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == False\n assert candidate(target = [999999999, 1, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == False\n assert candidate(target = [33, 17, 13]) == True\n assert candidate(target = [1, 1, 2, 3, 6, 11, 20, 37, 68]) == False\n assert candidate(target = [101, 103, 107, 109]) == False\n assert candidate(target = [10, 15, 3]) == False\n assert candidate(target = [7, 18, 5, 4]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [2, 900000000, 900000000]) == False\n assert candidate(target = [123456789, 987654321]) == False\n assert candidate(target = [100, 200, 300, 400, 500]) == False\n assert candidate(target = [1, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == False\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == False\n assert candidate(target = [5, 11, 19, 29, 41]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == False\n assert candidate(target = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == False\n assert candidate(target = [10, 15, 20, 30]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == False\n assert candidate(target = [1000000000, 1000000000, 999999999, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(target = [123456789, 987654321, 456789123, 321987654, 654321987, 789456123, 123789456, 456123789, 789654321, 987456123]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == False\n assert candidate(target = [3, 9, 20, 5]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n", "comparison": "exact"}, "public_tests": ["[9,3,5]", "[1,1,1,2]", "[8,5]"], "hints": ["Given that the sum is strictly increasing, the largest element in the target must be formed in the last step by adding the total sum in the previous step. Thus, we can simulate the process in a reversed way.", "Subtract the largest with the rest of the array, and put the new element into the array. Repeat until all elements become one"], "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().isPossible", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:40+00:00", "tests_total": 99, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def isPossible(self, target: list[int]) -> bool:", "container": "Solution", "callable": "isPossible", "parameters": [{"name": "target", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1356, "task_id": "sort-integers-by-the-number-of-1-bits", "difficulty": "Easy", "problem_description": "You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.\n\nReturn the array after sorting it.\n\nExample 1:\n\nInput: arr = [0,1,2,3,4,5,6,7,8]\nOutput: [0,1,2,4,8,3,5,6,7]\nExplantion: [0] is the only integer with 0 bits.\n[1,2,4,8] all have 1 bit.\n[3,5,6] have 2 bits.\n[7] has 3 bits.\nThe sorted array by bits is [0,1,2,4,8,3,5,6,7]\n\nExample 2:\n\nInput: arr = [1024,512,256,128,64,32,16,8,4,2,1]\nOutput: [1,2,4,8,16,32,64,128,256,512,1024]\nExplantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order.\n\nConstraints:\n\n- 1 <= arr.length <= 500\n- 0 <= arr[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 7, 8, 9]) == [8, 3, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9]) == [1, 3, 5, 9, 7]\n assert candidate(arr = [1, 0, 2, 3, 4]) == [0, 1, 2, 4, 3]\n assert candidate(arr = [3, 8, 3, 6, 5, 7, 9, 2]) == [2, 8, 3, 3, 5, 6, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 9, 7, 11, 13, 15]\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, 4, 8, 3, 5, 6, 7]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n assert candidate(arr = [10, 100, 1000, 10000]) == [10, 100, 10000, 1000]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 16, 8, 4, 2]) == [0, 1, 2, 4, 8, 16, 3, 7, 15, 31]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [123, 456, 789, 101, 234, 567, 890, 112, 345, 678]) == [112, 101, 456, 234, 345, 678, 789, 123, 567, 890]\n assert candidate(arr = [4095, 4094, 4093, 4092, 4091, 4090, 4089, 4088, 4087, 4086, 4085, 4084]) == [4084, 4088, 4085, 4086, 4089, 4090, 4092, 4087, 4091, 4093, 4094, 4095]\n assert candidate(arr = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]\n assert candidate(arr = [123, 456, 789, 101, 234, 567, 890, 111, 222, 333]) == [101, 456, 234, 333, 789, 111, 123, 222, 567, 890]\n assert candidate(arr = [33, 2, 7, 5, 8, 9, 6, 11, 14]) == [2, 8, 5, 6, 9, 33, 7, 11, 14]\n assert candidate(arr = [9, 5, 3, 7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47]) == [3, 5, 9, 7, 11, 13, 19, 21, 37, 41, 23, 29, 43, 31, 47]\n assert candidate(arr = [1234, 4321, 5678, 8765, 9876, 6789, 2345, 5432]) == [1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765]\n assert candidate(arr = [3, 7, 8, 9, 6, 5, 2, 1, 0, 4]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 7]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32]) == [0, 1, 2, 4, 8, 16, 32, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [49, 33, 25, 17, 9, 5, 3, 1, 0, 2, 6, 10, 18, 34, 66, 130]) == [0, 1, 2, 3, 5, 6, 9, 10, 17, 18, 33, 34, 66, 130, 25, 49]\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, 1, 1]\n assert candidate(arr = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048]\n assert candidate(arr = [13, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [17, 18, 20, 24, 13, 19, 21, 22, 25, 26, 28, 23, 27, 29, 30]\n assert candidate(arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [3, 5, 17, 7, 11, 13, 19, 37, 41, 23, 29, 43, 53, 31, 47]\n assert candidate(arr = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012]) == [3456, 1234, 2345, 6789, 8901, 9012, 5678, 4567, 7890]\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717]) == [101, 202, 404, 808, 1313, 1616, 707, 1414, 303, 606, 909, 1111, 1212, 505, 1010, 1717, 1515]\n assert candidate(arr = [63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48]) == [48, 49, 50, 52, 56, 51, 53, 54, 57, 58, 60, 55, 59, 61, 62, 63]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [5, 3, 15, 7, 8, 12, 9, 6, 2, 4, 10, 14, 13, 11, 1]) == [1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 15]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [9, 5, 6, 2, 31, 14, 12, 10, 28, 20, 24]) == [2, 5, 6, 9, 10, 12, 20, 24, 14, 28, 31]\n assert candidate(arr = [1001, 1010, 1011, 1100, 1101, 1110, 1111, 100, 101, 110, 111, 10, 1, 0]) == [0, 1, 10, 100, 101, 1100, 110, 1101, 1110, 111, 1111, 1001, 1010, 1011]\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988]) == [9988, 9992, 10000, 9989, 9990, 9993, 9994, 9996, 9991, 9995, 9997, 9998, 9999]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1110, 1101, 1100, 1011, 1010, 1001, 1000, 999, 888, 777, 666, 555, 444, 333, 222, 111, 110, 101, 100, 99, 88, 77, 66, 55, 44, 33, 22, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 33, 66, 7, 11, 22, 44, 88, 100, 77, 99, 101, 777, 1100, 55, 110, 333, 555, 666, 1101, 1110, 3333, 6666, 111, 222, 444, 888, 1000, 1111, 2222, 4444, 8888, 1001, 1010, 7777, 999, 1011, 5555, 9999]\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]\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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [1, 2, 4, 8, 16, 32, 3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 31, 47, 55, 59, 61, 62, 63]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 32, 16, 8, 4, 2]) == [0, 1, 2, 4, 8, 16, 32, 3, 7, 15, 31]\n assert candidate(arr = [15, 31, 63, 127, 255, 511, 1023, 2047]) == [15, 31, 63, 127, 255, 511, 1023, 2047]\n assert candidate(arr = [500, 125, 62, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 3, 7, 15, 31, 62, 125, 500]\n assert candidate(arr = [129, 258, 516, 1032, 2064, 4128, 8256]) == [129, 258, 516, 1032, 2064, 4128, 8256]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]\n assert candidate(arr = [1001, 1010, 1100, 1101, 1110, 1111, 999, 998, 997, 996, 995, 994]) == [1100, 1101, 1110, 994, 996, 1111, 995, 997, 998, 1001, 1010, 999]\n assert candidate(arr = [9, 5, 1, 3, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 3, 5, 6, 7, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 7, 13, 14, 19, 21, 22, 25, 26, 28, 15, 23, 27, 29, 30]\n assert candidate(arr = [13, 29, 11, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 3, 7, 11, 13, 29]\n assert candidate(arr = [1001, 1100, 1010, 1110, 1000, 1111, 1101, 1011, 111, 110, 101, 11, 10, 1, 0]) == [0, 1, 10, 11, 101, 1100, 110, 1101, 1110, 111, 1000, 1111, 1001, 1010, 1011]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1010, 1101, 1000, 111, 110, 101, 11, 10, 1, 0]) == [0, 1, 10, 11, 101, 110, 1101, 3333, 6666, 111, 1000, 1111, 2222, 4444, 8888, 1010, 7777, 5555, 9999]\n assert candidate(arr = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]\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, 4, 8, 16, 3, 5, 6, 9, 10, 12, 17, 18, 20, 7, 11, 13, 14, 19, 15]\n assert candidate(arr = [1234, 4321, 5678, 8765, 9876, 6789, 3456, 7890]) == [3456, 1234, 4321, 6789, 9876, 5678, 8765, 7890]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 3, 7, 15, 31]\n assert candidate(arr = [5, 3, 15, 7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [3, 5, 7, 11, 13, 19, 21, 37, 41, 67, 73, 97, 15, 23, 29, 43, 53, 71, 83, 89, 31, 47, 59, 61, 79]\n assert candidate(arr = [31, 29, 28, 27, 26, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 26, 28, 15, 23, 27, 29, 31]\n assert candidate(arr = [3, 5, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == [3, 5, 6, 9, 12, 18, 24, 33, 36, 21, 42, 15, 27, 30, 39, 45]\n assert candidate(arr = [1234, 4321, 2345, 5432, 3456, 6543, 4567, 7654, 5678, 8765, 6789, 9876, 7890, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 15, 3456, 1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765, 4567, 6543, 7890, 7654]\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == [9992, 10000, 9989, 9990, 9993, 9994, 9996, 9991, 9995, 9997, 9998, 9999]\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [17, 18, 20, 24, 19, 21, 22, 25, 26, 28, 23, 27, 29, 30, 31]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [777, 888, 999, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == [777, 3333, 6666, 888, 1111, 2222, 4444, 8888, 7777, 999, 5555, 9999]\n assert candidate(arr = [9, 5, 3, 7, 11, 13, 14, 19, 21, 22, 25, 29]) == [3, 5, 9, 7, 11, 13, 14, 19, 21, 22, 25, 29]\n assert candidate(arr = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012]) == [1008, 1001, 1002, 1004, 1009, 1010, 1012, 1003, 1005, 1006, 1011, 1007]\n assert candidate(arr = [9, 5, 6, 7, 8, 4, 2, 3, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 7]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [100, 200, 400, 800, 300, 600, 900, 1100, 1200, 500, 700, 1000]\n assert candidate(arr = [13, 7, 14, 28, 35, 42, 56, 70, 84, 98]) == [7, 13, 14, 28, 35, 42, 56, 70, 84, 98]\n assert candidate(arr = [9, 5, 3, 7, 2, 8, 6, 4, 1, 0, 11, 13, 14, 10, 12]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14]\n assert candidate(arr = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == [0, 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]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1023, 511]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 511, 1023]\n assert candidate(arr = [15, 7, 3, 1, 0, 8, 16, 4]) == [0, 1, 4, 8, 16, 3, 7, 15]\n assert candidate(arr = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == [9009, 1001, 2002, 4004, 5005, 8008, 3003, 6006, 7007]\n assert candidate(arr = [1374, 8314, 5296, 7916, 4154, 9666, 8078, 2933, 269, 9218, 4688, 7266, 2650, 9016, 1350, 8202]) == [8202, 9218, 269, 4688, 1350, 4154, 5296, 2650, 7266, 8314, 9016, 9666, 1374, 2933, 7916, 8078]\n assert candidate(arr = [1234, 4321, 5678, 8765, 2345, 5432, 6789, 9876, 3456, 6543, 7890, 8907]) == [3456, 1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765, 8907, 6543, 7890]\n assert candidate(arr = [13, 9, 6, 5, 12, 10, 3, 7, 2, 8, 4, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 13]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 2, 4, 8, 16]) == [0, 1, 2, 4, 8, 16, 3, 7, 15, 31]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == [0, 1, 1, 3, 3, 7, 7, 15, 15, 31, 31, 63, 63, 127, 127, 255, 255, 511, 511, 1023, 1023]\n assert candidate(arr = [5, 3, 1, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 3, 5, 9, 17, 33, 7, 11, 13, 19, 21, 25, 35, 37, 15, 23, 27, 29, 39, 31]\n", "comparison": "exact"}, "public_tests": ["[0,1,2,3,4,5,6,7,8]", "[1024,512,256,128,64,32,16,8,4,2,1]"], "hints": ["Simulate the problem. Count the number of 1's in the binary representation of each integer.", "Sort by the number of 1's ascending and by the value in case of tie."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sortByBits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:42+00:00", "tests_total": 96, "tests_dropped": 15, "flags": [], "topic_tags": ["array", "bit-manipulation", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def sortByBits(self, arr: list[int]) -> list[int]:", "container": "Solution", "callable": "sortByBits", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1358, "task_id": "number-of-substrings-containing-all-three-characters", "difficulty": "Medium", "problem_description": "Given a string s consisting only of characters a, b and c.\n\nReturn the number of substrings containing at least one occurrence of all these characters a, b and c.\n\nExample 1:\n\nInput: s = \"abcabc\"\nOutput: 10\nExplanation: The substrings containing at least one occurrence of the characters a, b and c are \"abc\", \"abca\", \"abcab\", \"abcabc\", \"bca\", \"bcab\", \"bcabc\", \"cab\", \"cabc\" and \"abc\" (again).\n\nExample 2:\n\nInput: s = \"aaacb\"\nOutput: 3\nExplanation: The substrings containing at least one occurrence of the characters a, b and c are \"aaacb\", \"aacb\" and \"acb\".\n\nExample 3:\n\nInput: s = \"abc\"\nOutput: 1\n\nConstraints:\n\n- 3 <= s.length <= 5 x 10^4\n- s only consists of 'a', 'b' or 'c' characters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"abcba\") == 5\n assert candidate(s = \"cba\") == 1\n assert candidate(s = \"cbaacb\") == 8\n assert candidate(s = \"bbbacbac\") == 18\n assert candidate(s = \"ccccabc\") == 9\n assert candidate(s = \"abcabcabc\") == 28\n assert candidate(s = \"abcabcabcabc\") == 55\n assert candidate(s = \"aabbc\") == 2\n assert candidate(s = \"cccbaab\") == 9\n assert candidate(s = \"aabbbc\") == 2\n assert candidate(s = \"aabcbc\") == 6\n assert candidate(s = \"abcabc\") == 10\n assert candidate(s = \"aabbaacc\") == 8\n assert candidate(s = \"abacbc\") == 8\n assert candidate(s = \"abacabacabc\") == 41\n assert candidate(s = \"aaaabbbbcccc\") == 16\n assert candidate(s = \"ccbaaabb\") == 10\n assert candidate(s = \"baccab\") == 7\n assert candidate(s = \"bca\") == 1\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"ccccbaaa\") == 12\n assert candidate(s = \"aaacb\") == 3\n assert candidate(s = \"ccccbaab\") == 12\n assert candidate(s = \"abcababc\") == 18\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaabbbccc\") == 12\n assert candidate(s = \"abacbac\") == 14\n assert candidate(s = \"abcacbacbacbabc\") == 89\n assert candidate(s = \"aabbcacabcabc\") == 59\n assert candidate(s = \"ccabababc\") == 17\n assert candidate(s = \"abacbabacbabacbab\") == 112\n assert candidate(s = \"aabccbabcbacbac\") == 85\n assert candidate(s = \"abcabcabccba\") == 52\n assert candidate(s = \"aabbccbaa\") == 18\n assert candidate(s = \"aaabbbcccbbbccc\") == 27\n assert candidate(s = \"acbacbacbacbacb\") == 91\n assert candidate(s = \"abacbacbacb\") == 44\n assert candidate(s = \"aabcbacbacbabc\") == 75\n assert candidate(s = \"bcabcabcabcabc\") == 78\n assert candidate(s = \"aaabbbcccabcabcabc\") == 115\n assert candidate(s = \"abacbacbacbacbabcababcabc\") == 271\n assert candidate(s = \"acbacbacbacb\") == 55\n assert candidate(s = \"abacbacbacbabc\") == 76\n assert candidate(s = \"cccbbbaaa\") == 9\n assert candidate(s = \"caabcbacbacb\") == 52\n assert candidate(s = \"abbbcccaabbbabc\") == 59\n assert candidate(s = \"abacbcabc\") == 26\n assert candidate(s = \"aaabbbcccbbbaaa\") == 45\n assert candidate(s = \"bacbacbacbacb\") == 66\n assert candidate(s = \"cabcbacbacbabcb\") == 88\n assert candidate(s = \"abacbcacab\") == 31\n assert candidate(s = \"bbbbbbcccaaa\") == 18\n assert candidate(s = \"aaaaaaaaaabbbccc\") == 30\n assert candidate(s = \"ccbbbaaabbbccc\") == 36\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 406\n assert candidate(s = \"abcabcabcab\") == 45\n assert candidate(s = \"aabbaaccabcabcabc\") == 104\n assert candidate(s = \"bacbacbacbacbacba\") == 120\n assert candidate(s = \"ccccbbbaaaaa\") == 20\n assert candidate(s = \"abababababababab\") == 0\n assert candidate(s = \"abacbcabcabcab\") == 76\n assert candidate(s = \"abababababab\") == 0\n assert candidate(s = \"cacbacbacbac\") == 54\n assert candidate(s = \"cabbacbac\") == 25\n assert candidate(s = \"aabbaacccbaab\") == 45\n assert candidate(s = \"abcabcabcabcabcabc\") == 136\n assert candidate(s = \"cbacbacbacbac\") == 66\n assert candidate(s = \"aabbbcccaaaabbbccc\") == 86\n assert candidate(s = \"bacbacbacbacba\") == 78\n assert candidate(s = \"aabacababaac\") == 40\n assert candidate(s = \"abcababccbaabc\") == 69\n assert candidate(s = \"ababababcabcab\") == 57\n assert candidate(s = \"aaabbbcccbbb\") == 18\n assert candidate(s = \"abcabcabcabcababc\") == 117\n assert candidate(s = \"abccbaabccbaab\") == 66\n assert candidate(s = \"baccabaccabacc\") == 69\n assert candidate(s = \"abacbcacbacb\") == 52\n assert candidate(s = \"cccccbbaaaabbbccc\") == 68\n assert candidate(s = \"bbcccaabbcccaab\") == 65\n assert candidate(s = \"aabbbccccaaaabbbbccc\") == 103\n assert candidate(s = \"abababab\") == 0\n assert candidate(s = \"cbacbacbacbacbacbacbacbacbacbacb\") == 465\n assert candidate(s = \"abcbaabcbaabc\") == 58\n assert candidate(s = \"aabcbabacabc\") == 49\n assert candidate(s = \"aabacbacbacbac\") == 75\n assert candidate(s = \"aabbaaccbbacbbacaacabcbacbacbacbac\") == 498\n assert candidate(s = \"abacbabacbabac\") == 71\n assert candidate(s = \"aabbbcccaabbbabc\") == 70\n assert candidate(s = \"aaaabbccccabbbccc\") == 85\n assert candidate(s = \"cccaaaabbbcccbbb\") == 51\n assert candidate(s = \"ccccbbaaaabc\") == 30\n assert candidate(s = \"acbacbacbacbacbacbacbacbacbacbac\") == 465\n assert candidate(s = \"abcbbccaaa\") == 20\n assert candidate(s = \"cccaabbbaaacc\") == 34\n assert candidate(s = \"ccccccccabbaabbcbbb\") == 100\n assert candidate(s = \"cccbababac\") == 23\n assert candidate(s = \"ccccabcabcabc\") == 60\n assert candidate(s = \"aabacbababcabc\") == 69\n assert candidate(s = \"aaabbbcccbbbaaabbbc\") == 87\n assert candidate(s = \"abccabccabccabc\") == 85\n assert candidate(s = \"abcbacbacbacbaca\") == 103\n assert candidate(s = \"abcabcabcabacbacb\") == 119\n assert candidate(s = \"aabbbcccabcabcabc\") == 103\n assert candidate(s = \"abacbcabcabc\") == 53\n assert candidate(s = \"aabbaaccaabbcc\") == 52\n assert candidate(s = \"abcabcabacbcab\") == 76\n assert candidate(s = \"aabbbccc\") == 6\n assert candidate(s = \"aabbaacccbbcabab\") == 77\n assert candidate(s = \"babababacacacacbcbbcbcbcbacbacbacb\") == 441\n assert candidate(s = \"cacbacbacbacbacbac\") == 135\n assert candidate(s = \"cccbbaaaabacbacb\") == 78\n assert candidate(s = \"ccccbbbaaa\") == 12\n assert candidate(s = \"aaaaaaaaaabcabcabcabcabc\") == 208\n assert candidate(s = \"aabbbccccaaa\") == 23\n assert candidate(s = \"abacbacbac\") == 35\n assert candidate(s = \"aabbbaccccba\") == 36\n assert candidate(s = \"ccbaabccababab\") == 62\n assert candidate(s = \"ccccbaabccc\") == 33\n assert candidate(s = \"ccccbaa\") == 8\n assert candidate(s = \"bacabcabcabcabcabcabcabc\") == 252\n assert candidate(s = \"ccccccaaaabbbccc\") == 48\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 496\n assert candidate(s = \"abacbabcc\") == 25\n assert candidate(s = \"abacbacbacbacb\") == 77\n assert candidate(s = \"bacbacbacbacbacbacbac\") == 190\n assert candidate(s = \"abcabcabcabcabc\") == 91\n assert candidate(s = \"bbaacccaaaabbccba\") == 76\n assert candidate(s = \"aaaaabbbbbccccc\") == 25\n assert candidate(s = \"aaabbbcccabc\") == 34\n", "comparison": "exact"}, "public_tests": ["\"abcabc\"", "\"aaacb\"", "\"abc\""], "hints": ["For each position we simply need to find the first occurrence of a/b/c on or after this position.", "So we can pre-compute three link-list of indices of each a, b, and c."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:44+00:00", "tests_total": 130, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def numberOfSubstrings(self, s: str) -> int:", "container": "Solution", "callable": "numberOfSubstrings", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1359, "task_id": "count-all-valid-pickup-and-delivery-options", "difficulty": "Hard", "problem_description": "Given n orders, each order consists of a pickup and a delivery service.\n\nCount all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).\n\nSince the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: Unique order (P1, D1), Delivery 1 always is after of Pickup 1.\n\nExample 2:\n\nInput: n = 2\nOutput: 6\nExplanation: All possible orders:\n(P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).\nThis is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.\n\nExample 3:\n\nInput: n = 3\nOutput: 90\n\nConstraints:\n\n- 1 <= n <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 90\n assert candidate(n = 250) == 418733499\n assert candidate(n = 100) == 14159051\n assert candidate(n = 4) == 2520\n assert candidate(n = 2) == 6\n assert candidate(n = 20) == 580270580\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 764678010\n assert candidate(n = 50) == 784760423\n assert candidate(n = 10) == 850728840\n assert candidate(n = 5) == 113400\n assert candidate(n = 12) == 67543367\n assert candidate(n = 125) == 129345050\n assert candidate(n = 110) == 120658916\n assert candidate(n = 300) == 234038968\n assert candidate(n = 60) == 988537746\n assert candidate(n = 30) == 920731808\n assert candidate(n = 450) == 586675271\n assert candidate(n = 80) == 189044563\n assert candidate(n = 175) == 82390790\n assert candidate(n = 495) == 498394413\n assert candidate(n = 8) == 729647433\n assert candidate(n = 18) == 368349166\n assert candidate(n = 75) == 149163518\n assert candidate(n = 350) == 436707893\n assert candidate(n = 150) == 707081203\n assert candidate(n = 15) == 621371750\n assert candidate(n = 200) == 880584563\n assert candidate(n = 400) == 467993882\n assert candidate(n = 499) == 496638171\n assert candidate(n = 55) == 22089728\n assert candidate(n = 25) == 586091532\n", "comparison": "exact"}, "public_tests": ["1", "2", "3"], "hints": ["Use the permutation and combination theory to add one (P, D) pair each time until n pairs."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countOrders", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:47+00:00", "tests_total": 32, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "combinatorics"]}, "language": "python", "interface": {"raw_signature": "def countOrders(self, n: int) -> int:", "container": "Solution", "callable": "countOrders", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1360, "task_id": "number-of-days-between-two-dates", "difficulty": "Easy", "problem_description": "Write a program to count the number of days between two dates.\n\nThe two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.\n\nExample 1:\n\nInput: date1 = \"2019-06-29\", date2 = \"2019-06-30\"\nOutput: 1\n\nExample 2:\n\nInput: date1 = \"2020-01-15\", date2 = \"2019-12-31\"\nOutput: 15\n\nConstraints:\n\n- The given dates are valid dates between the years 1971 and 2100.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date1 = \"2019-02-28\",date2 = \"2019-03-01\") == 1\n assert candidate(date1 = \"2020-01-15\",date2 = \"2019-12-31\") == 15\n assert candidate(date1 = \"2000-03-01\",date2 = \"2000-02-29\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-10-02\") == 1\n assert candidate(date1 = \"2022-02-28\",date2 = \"2022-03-01\") == 1\n assert candidate(date1 = \"2012-01-01\",date2 = \"2012-12-31\") == 365\n assert candidate(date1 = \"2021-10-10\",date2 = \"2021-10-10\") == 0\n assert candidate(date1 = \"2021-10-01\",date2 = \"2021-10-10\") == 9\n assert candidate(date1 = \"2020-02-28\",date2 = \"2020-03-01\") == 2\n assert candidate(date1 = \"1971-01-01\",date2 = \"2100-12-31\") == 47481\n assert candidate(date1 = \"2019-06-29\",date2 = \"2019-06-30\") == 1\n assert candidate(date1 = \"2023-01-01\",date2 = \"2023-12-31\") == 364\n assert candidate(date1 = \"2023-01-01\",date2 = \"2023-01-01\") == 0\n assert candidate(date1 = \"2050-06-15\",date2 = \"2050-06-14\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-10-01\") == 0\n assert candidate(date1 = \"2016-02-29\",date2 = \"2016-02-28\") == 1\n assert candidate(date1 = \"2000-02-28\",date2 = \"2000-03-01\") == 2\n assert candidate(date1 = \"2023-04-10\",date2 = \"2023-04-01\") == 9\n assert candidate(date1 = \"2000-02-29\",date2 = \"2000-03-01\") == 1\n assert candidate(date1 = \"2100-02-28\",date2 = \"2100-03-01\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-01\") == 30\n assert candidate(date1 = \"1971-01-02\",date2 = \"1971-01-01\") == 1\n assert candidate(date1 = \"2012-02-29\",date2 = \"2012-03-31\") == 31\n assert candidate(date1 = \"1985-04-12\",date2 = \"2023-07-25\") == 13983\n assert candidate(date1 = \"1972-02-29\",date2 = \"1972-03-01\") == 1\n assert candidate(date1 = \"2017-10-01\",date2 = \"2018-10-01\") == 365\n assert candidate(date1 = \"2023-06-04\",date2 = \"2023-06-04\") == 0\n assert candidate(date1 = \"2004-02-28\",date2 = \"2004-03-01\") == 2\n assert candidate(date1 = \"2021-06-30\",date2 = \"2021-09-30\") == 92\n assert candidate(date1 = \"2004-03-01\",date2 = \"2004-02-29\") == 1\n assert candidate(date1 = \"2025-01-01\",date2 = \"2026-01-01\") == 365\n assert candidate(date1 = \"2024-03-01\",date2 = \"2024-02-29\") == 1\n assert candidate(date1 = \"2023-11-30\",date2 = \"2023-12-01\") == 1\n assert candidate(date1 = \"2100-01-01\",date2 = \"2100-12-31\") == 364\n assert candidate(date1 = \"2020-02-29\",date2 = \"2020-03-01\") == 1\n assert candidate(date1 = \"2015-06-30\",date2 = \"2016-06-30\") == 366\n assert candidate(date1 = \"1980-02-29\",date2 = \"1981-02-28\") == 365\n assert candidate(date1 = \"2099-12-31\",date2 = \"2100-01-01\") == 1\n assert candidate(date1 = \"2023-06-01\",date2 = \"2023-07-01\") == 30\n assert candidate(date1 = \"2100-12-31\",date2 = \"2099-12-31\") == 365\n assert candidate(date1 = \"2020-02-01\",date2 = \"2021-02-01\") == 366\n assert candidate(date1 = \"2000-01-01\",date2 = \"2100-12-31\") == 36889\n assert candidate(date1 = \"2016-02-29\",date2 = \"2017-02-28\") == 365\n assert candidate(date1 = \"2020-01-31\",date2 = \"2020-02-29\") == 29\n assert candidate(date1 = \"1980-02-28\",date2 = \"1980-03-01\") == 2\n assert candidate(date1 = \"2050-11-15\",date2 = \"2050-11-15\") == 0\n assert candidate(date1 = \"2099-12-30\",date2 = \"2100-01-01\") == 2\n assert candidate(date1 = \"2024-11-01\",date2 = \"2023-11-01\") == 366\n assert candidate(date1 = \"2016-06-30\",date2 = \"2016-06-01\") == 29\n assert candidate(date1 = \"2023-02-28\",date2 = \"2024-02-29\") == 366\n assert candidate(date1 = \"2019-01-31\",date2 = \"2019-02-28\") == 28\n assert candidate(date1 = \"2021-01-01\",date2 = \"2021-12-31\") == 364\n assert candidate(date1 = \"2024-02-28\",date2 = \"2024-02-29\") == 1\n assert candidate(date1 = \"2004-12-31\",date2 = \"2005-01-01\") == 1\n assert candidate(date1 = \"2023-06-05\",date2 = \"2023-06-04\") == 1\n assert candidate(date1 = \"2016-02-28\",date2 = \"2016-02-29\") == 1\n assert candidate(date1 = \"2023-04-30\",date2 = \"2023-05-01\") == 1\n assert candidate(date1 = \"2019-12-31\",date2 = \"2020-01-01\") == 1\n assert candidate(date1 = \"2025-12-31\",date2 = \"2026-01-01\") == 1\n assert candidate(date1 = \"2023-06-30\",date2 = \"2023-07-01\") == 1\n assert candidate(date1 = \"2000-02-29\",date2 = \"2004-02-29\") == 1461\n assert candidate(date1 = \"2021-12-31\",date2 = \"2022-01-01\") == 1\n assert candidate(date1 = \"2024-02-28\",date2 = \"2024-03-01\") == 2\n assert candidate(date1 = \"2077-07-04\",date2 = \"2077-07-05\") == 1\n assert candidate(date1 = \"2018-04-30\",date2 = \"2018-05-01\") == 1\n assert candidate(date1 = \"2019-10-15\",date2 = \"2020-10-15\") == 366\n assert candidate(date1 = \"2004-02-29\",date2 = \"2004-03-01\") == 1\n assert candidate(date1 = \"2012-12-31\",date2 = \"2013-01-01\") == 1\n assert candidate(date1 = \"1999-02-28\",date2 = \"1999-03-01\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-29\") == 2\n assert candidate(date1 = \"2012-02-28\",date2 = \"2012-03-01\") == 2\n assert candidate(date1 = \"2020-03-01\",date2 = \"2020-02-28\") == 2\n assert candidate(date1 = \"2020-02-29\",date2 = \"2019-02-28\") == 366\n assert candidate(date1 = \"2000-01-01\",date2 = \"2000-12-31\") == 365\n assert candidate(date1 = \"2023-10-15\",date2 = \"2024-10-15\") == 366\n assert candidate(date1 = \"2023-08-31\",date2 = \"2023-09-01\") == 1\n assert candidate(date1 = \"2024-02-29\",date2 = \"2024-03-01\") == 1\n assert candidate(date1 = \"2015-06-15\",date2 = \"2015-06-14\") == 1\n assert candidate(date1 = \"2000-01-01\",date2 = \"2004-01-01\") == 1461\n assert candidate(date1 = \"1999-12-31\",date2 = \"1971-01-01\") == 10591\n assert candidate(date1 = \"2024-12-31\",date2 = \"2025-01-01\") == 1\n assert candidate(date1 = \"1980-06-15\",date2 = \"1980-07-15\") == 30\n assert candidate(date1 = \"2023-03-01\",date2 = \"2023-02-28\") == 1\n assert candidate(date1 = \"2023-10-02\",date2 = \"2023-10-01\") == 1\n assert candidate(date1 = \"2020-03-01\",date2 = \"2020-02-29\") == 1\n assert candidate(date1 = \"2050-06-15\",date2 = \"2050-07-15\") == 30\n assert candidate(date1 = \"2021-06-01\",date2 = \"2022-06-01\") == 365\n assert candidate(date1 = \"2023-12-31\",date2 = \"2023-01-01\") == 364\n assert candidate(date1 = \"2019-12-31\",date2 = \"2020-01-31\") == 31\n assert candidate(date1 = \"2023-05-31\",date2 = \"2023-06-01\") == 1\n assert candidate(date1 = \"1971-01-01\",date2 = \"1971-01-02\") == 1\n assert candidate(date1 = \"1996-02-29\",date2 = \"1997-02-28\") == 365\n assert candidate(date1 = \"2023-12-31\",date2 = \"2024-01-01\") == 1\n assert candidate(date1 = \"2019-11-11\",date2 = \"2020-02-29\") == 110\n assert candidate(date1 = \"2100-12-31\",date2 = \"2100-01-01\") == 364\n assert candidate(date1 = \"2023-01-31\",date2 = \"2023-02-28\") == 28\n assert candidate(date1 = \"2100-12-31\",date2 = \"2100-12-30\") == 1\n assert candidate(date1 = \"2023-09-30\",date2 = \"2023-10-01\") == 1\n assert candidate(date1 = \"2023-10-31\",date2 = \"2023-11-01\") == 1\n assert candidate(date1 = \"2023-11-05\",date2 = \"2024-11-05\") == 366\n assert candidate(date1 = \"2019-02-28\",date2 = \"2020-02-29\") == 366\n assert candidate(date1 = \"1972-02-28\",date2 = \"1972-02-29\") == 1\n assert candidate(date1 = \"2023-10-15\",date2 = \"2023-10-15\") == 0\n assert candidate(date1 = \"2019-06-15\",date2 = \"2019-06-14\") == 1\n assert candidate(date1 = \"1996-02-28\",date2 = \"1996-02-29\") == 1\n assert candidate(date1 = \"1996-04-15\",date2 = \"1996-05-15\") == 30\n assert candidate(date1 = \"1980-03-01\",date2 = \"1980-02-29\") == 1\n assert candidate(date1 = \"2023-10-15\",date2 = \"2022-10-15\") == 365\n assert candidate(date1 = \"2024-03-15\",date2 = \"2024-03-01\") == 14\n assert candidate(date1 = \"2024-03-01\",date2 = \"2025-03-01\") == 365\n assert candidate(date1 = \"2023-06-04\",date2 = \"2023-06-05\") == 1\n assert candidate(date1 = \"2022-12-31\",date2 = \"2023-01-01\") == 1\n assert candidate(date1 = \"2000-01-01\",date2 = \"2001-01-01\") == 366\n assert candidate(date1 = \"2023-11-01\",date2 = \"2024-11-01\") == 366\n assert candidate(date1 = \"1971-01-01\",date2 = \"1971-12-31\") == 364\n assert candidate(date1 = \"2050-12-31\",date2 = \"2051-01-01\") == 1\n assert candidate(date1 = \"2000-02-29\",date2 = \"1999-02-28\") == 366\n assert candidate(date1 = \"2004-02-28\",date2 = \"2004-02-29\") == 1\n assert candidate(date1 = \"2020-01-01\",date2 = \"2020-12-31\") == 365\n assert candidate(date1 = \"2012-02-29\",date2 = \"2012-03-01\") == 1\n assert candidate(date1 = \"2024-02-28\",date2 = \"2025-02-28\") == 366\n assert candidate(date1 = \"2012-02-29\",date2 = \"2013-02-28\") == 365\n assert candidate(date1 = \"2020-02-28\",date2 = \"2020-02-29\") == 1\n assert candidate(date1 = \"2016-06-01\",date2 = \"2016-06-30\") == 29\n assert candidate(date1 = \"2008-02-29\",date2 = \"2009-02-28\") == 365\n assert candidate(date1 = \"2023-02-14\",date2 = \"2023-03-14\") == 28\n assert candidate(date1 = \"2023-07-31\",date2 = \"2023-08-01\") == 1\n assert candidate(date1 = \"1987-07-04\",date2 = \"1999-07-04\") == 4383\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-30\") == 1\n assert candidate(date1 = \"2016-02-28\",date2 = \"2016-03-01\") == 2\n assert candidate(date1 = \"1980-02-29\",date2 = \"1980-03-01\") == 1\n assert candidate(date1 = \"2025-06-15\",date2 = \"2026-06-15\") == 365\n assert candidate(date1 = \"2023-01-01\",date2 = \"2024-01-01\") == 365\n assert candidate(date1 = \"2023-05-05\",date2 = \"2022-05-05\") == 365\n assert candidate(date1 = \"2023-09-29\",date2 = \"2023-10-01\") == 2\n assert candidate(date1 = \"2016-02-29\",date2 = \"2016-03-01\") == 1\n assert candidate(date1 = \"1999-12-31\",date2 = \"2000-01-01\") == 1\n assert candidate(date1 = \"2019-09-15\",date2 = \"2023-09-15\") == 1461\n", "comparison": "exact"}, "public_tests": ["\"2019-06-29\"\n\"2019-06-30\"", "\"2020-01-15\"\n\"2019-12-31\""], "hints": ["Create a function f(date) that counts the number of days from 1900-01-01 to date. How can we calculate the answer ?", "The answer is just |f(date1) - f(date2)|.", "How to construct f(date) ?", "For each year from 1900 to year - 1 sum up 365 or 366 in case of leap years. Then sum up for each month the number of days, consider the case when the current year is leap, finally sum up the days."], "metadata": {"canonical_parameter_names": ["date1", "date2"], "leetcode_dataset_entry_point": "Solution().daysBetweenDates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:49+00:00", "tests_total": 138, "tests_dropped": 0, "flags": ["figure_reference"], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def daysBetweenDates(self, date1: str, date2: str) -> int:", "container": "Solution", "callable": "daysBetweenDates", "parameters": [{"name": "date1", "type": "str"}, {"name": "date2", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1361, "task_id": "validate-binary-tree-nodes", "difficulty": "Medium", "problem_description": "You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.\n\nIf node i has no left child then leftChild[i] will equal -1, similarly for the right child.\n\nNote that the nodes have no values and that we only use the node numbers in this problem.\n\nExample 1:\n\nInput: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,-1,-1,-1]\nOutput: true\n\nExample 2:\n\nInput: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,3,-1,-1]\nOutput: false\n\nExample 3:\n\nInput: n = 2, leftChild = [1,0], rightChild = [-1,-1]\nOutput: false\n\nConstraints:\n\n- n == leftChild.length == rightChild.length\n- 1 <= n <= 10^4\n- -1 <= leftChild[i], rightChild[i] <= n - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,leftChild = [1, 0],rightChild = [-1, -1]) == False\n assert candidate(n = 3,leftChild = [1, -1, -1],rightChild = [2, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 0, -1],rightChild = [-1, -1, -1]) == False\n assert candidate(n = 1,leftChild = [-1],rightChild = [-1]) == True\n assert candidate(n = 4,leftChild = [1, -1, 3, -1],rightChild = [2, -1, -1, -1]) == True\n assert candidate(n = 4,leftChild = [1, -1, 3, -1],rightChild = [2, 3, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, 3, 4, -1],rightChild = [-1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [4, 5, -1, -1, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 2, -1],rightChild = [-1, -1, 1]) == False\n assert candidate(n = 5,leftChild = [1, 3, -1, -1, -1],rightChild = [2, 4, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, -1, -1, -1]) == True\n assert candidate(n = 13,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, 3, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [2, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, -1, 2, 0, -1],rightChild = [-1, 2, -1, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, 3, 4],rightChild = [-1, -1, 5, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, -1, -1, -1],rightChild = [5, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],rightChild = [5, 6, 7, 8, -1, 9, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, 0]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, 5, -1],rightChild = [2, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, 6, 7, -1],rightChild = [-1, 5, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, 2],rightChild = [-1, 3, 4, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, 5, 0, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, -1, -1],rightChild = [-1, -1, -1, 4, -1, 5, 6, 7]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [-1, -1, 3, 4, 5, 6, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, -1, 6, 7],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, 7, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1],rightChild = [-1, 6, 7, -1, -1, 8, -1, -1, 9, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [-1, -1, 4, -1, 5, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, 6, -1],rightChild = [3, 4, 5, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 12,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, 5, 6, 7, 8, 9, -1],rightChild = [-1, 3, 4, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1, -1, -1, 7]) == False\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, 6, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, 4, -1],rightChild = [-1, 3, -1, 5, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, 2, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 3, -1, -1, -1],rightChild = [-1, 2, 4, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, 4, -1, -1],rightChild = [-1, -1, 3, -1, 5, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, 0],rightChild = [-1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, -1, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, 6, 7, -1, -1]) == False\n assert candidate(n = 11,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, 4, -1],rightChild = [-1, -1, -1, 5, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, -1, 3, 5, -1, 7, -1, -1],rightChild = [2, 4, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [-1, -1, 3, 4, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, -1, 2, -1, -1],rightChild = [2, 3, 4, -1, 5, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [-1, -1, -1, -1, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, -1, 5]) == False\n assert candidate(n = 8,leftChild = [1, -1, 2, -1, 3, 4, -1, -1],rightChild = [-1, 5, -1, 6, 7, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, 6, 7],rightChild = [3, 4, 5, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, -1, -1],rightChild = [5, -1, 6, -1, 7, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 3, 5, -1, -1],rightChild = [2, 4, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, -1, -1, 5, -1, -1, -1],rightChild = [2, 3, 4, 6, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, 5, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, -1, 5, 6],rightChild = [-1, -1, -1, 4, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [-1, 3, -1, 4, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, -1, 6, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, 4, -1, -1],rightChild = [3, -1, 5, 6, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [-1, 3, 4, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 2, -1, 3, -1],rightChild = [-1, -1, -1, -1, -1, 4]) == False\n assert candidate(n = 10,leftChild = [1, -1, 3, -1, -1, 6, -1, -1, -1, -1],rightChild = [2, 4, 5, 7, 8, 9, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, 7, -1, 9],rightChild = [-1, -1, -1, -1, 5, 6, 8, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, 5, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, -1, -1, -1, 7, -1],rightChild = [-1, -1, -1, -1, 5, 6, 8, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],rightChild = [-1, 5, 6, 7, -1, 8, 9, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [-1, -1, -1, 4, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [2, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 12,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [-1, -1, 5, -1, 3, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 3, -1, -1, -1],rightChild = [2, -1, -1, 4, 5, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, -1, -1, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1, -1, 9]) == False\n assert candidate(n = 7,leftChild = [1, -1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, 5, -1, -1],rightChild = [4, -1, -1, -1, 6, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, 3, 4, -1],rightChild = [-1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, 4],rightChild = [2, -1, 3, -1, 5, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, -1, -1, -1],rightChild = [5, -1, 4, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, 4],rightChild = [-1, -1, -1, 3, -1]) == False\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, -1, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, 8, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, -1, -1, -1],rightChild = [4, 5, 6, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, 3, -1],rightChild = [4, -1, -1, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, -1, 2, 3, -1, 4, -1],rightChild = [-1, -1, -1, 5, 6, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [7, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, -1, -1, -1, -1, -1, -1],rightChild = [4, 5, 6, 7, 8, -1, -1, -1, -1]) == True\n assert candidate(n = 12,leftChild = [1, 2, -1, 4, -1, 6, -1, -1, 8, -1, -1, -1],rightChild = [-1, 3, 5, -1, 7, -1, 9, -1, 10, -1, 11, -1]) == False\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, -1, 3, -1, 4]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, 7, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1, 9],rightChild = [2, -1, -1, -1, 5, 6, -1, -1, 9, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, 7, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, -1, -1],rightChild = [-1, -1, -1, -1, 5, 6, 7, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, 6, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, -1, 4, -1, -1, 7, -1, -1],rightChild = [-1, 3, -1, -1, 5, 6, -1, -1, 8]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, 7, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [2, 4, 3, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, -1, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 2, -1, -1, -1],rightChild = [2, -1, 3, 4, 5, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, 4, -1],rightChild = [-1, -1, 3, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, 3, 4, -1, 5, 6, -1],rightChild = [-1, -1, -1, 3, 5, 6, 7, 8, 9, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, 3, 5, -1],rightChild = [4, -1, -1, -1, 6, -1, 7, -1]) == True\n assert candidate(n = 8,leftChild = [1, -1, -1, 4, -1, -1, -1, -1],rightChild = [2, 3, 5, -1, 6, 7, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, -1, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1, -1]) == True\n assert candidate(n = 11,leftChild = [1, 2, -1, 4, 5, 6, -1, 8, -1, -1, -1],rightChild = [-1, 3, -1, 7, -1, -1, 9, -1, 10, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, 6, 7, -1],rightChild = [-1, -1, 3, 4, 5, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, -1, 4, 5, -1, -1, -1, -1],rightChild = [-1, -1, 3, -1, -1, 6, -1, -1, 7]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, 3, 4, 5, 6, -1],rightChild = [-1, -1, -1, -1, -1, 7, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, 6, 7],rightChild = [5, -1, -1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [5, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, -1, 2, 3, -1, 4, 5, 6, 7, 8],rightChild = [-1, 2, 3, -1, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [-1, 2, 3, 4, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, 5, 6],rightChild = [2, -1, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, -1, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, 9, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, 6, 7, -1],rightChild = [5, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, 6, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 4,leftChild = [1, -1, -1, -1],rightChild = [2, 3, 0, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 3, -1, -1, 4],rightChild = [2, 5, -1, -1, -1, -1]) == True\n assert candidate(n = 11,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1],rightChild = [5, 6, 7, 8, 9, -1, 10, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, 4],rightChild = [3, -1, -1, -1, 5, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, -1, 5]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == False\n", "comparison": "exact"}, "public_tests": ["4\n[1,-1,3,-1]\n[2,-1,-1,-1]", "4\n[1,-1,3,-1]\n[2,3,-1,-1]", "2\n[1,0]\n[-1,-1]"], "hints": ["Find the parent of each node.", "A valid tree must have nodes with only one parent and exactly one node with no parent."], "metadata": {"canonical_parameter_names": ["n", "leftChild", "rightChild"], "leetcode_dataset_entry_point": "Solution().validateBinaryTreeNodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:51+00:00", "tests_total": 137, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["tree", "depth-first-search", "breadth-first-search", "union-find", "graph", "binary-tree"]}, "language": "python", "interface": {"raw_signature": "def validateBinaryTreeNodes(self, n: int, leftChild: list[int], rightChild: list[int]) -> bool:", "container": "Solution", "callable": "validateBinaryTreeNodes", "parameters": [{"name": "n", "type": "int"}, {"name": "leftChild", "type": "list[int]"}, {"name": "rightChild", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1362, "task_id": "closest-divisors", "difficulty": "Medium", "problem_description": "Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.\n\nReturn the two integers in any order.\n\nExample 1:\n\nInput: num = 8\nOutput: [3,3]\nExplanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.\n\nExample 2:\n\nInput: num = 123\nOutput: [5,25]\n\nExample 3:\n\nInput: num = 999\nOutput: [40,25]\n\nConstraints:\n\n- 1 <= num <= 10^9\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(num=1000000000), [23658, 42269])\n assert answers_match(candidate(num=999), [25, 40])\n assert answers_match(candidate(num=8), [3, 3])\n assert answers_match(candidate(num=1), [1, 2])\n assert answers_match(candidate(num=100), [6, 17])\n assert answers_match(candidate(num=123), [5, 25])\n assert answers_match(candidate(num=100000000), [7122, 14041])\n assert answers_match(candidate(num=111111111), [9352, 11881])\n assert answers_match(candidate(num=555555555), [1457, 381301])\n assert answers_match(candidate(num=456789), [170, 2687])\n assert answers_match(candidate(num=888888888), [21847, 40687])\n assert answers_match(candidate(num=999999998), [31250, 32000])\n assert answers_match(candidate(num=4), [2, 3])\n assert answers_match(candidate(num=234567890), [13707, 17113])\n assert answers_match(candidate(num=999999997), [2997, 333667])\n assert answers_match(candidate(num=1048575), [1024, 1024])\n assert answers_match(candidate(num=800000000), [20201, 39602])\n assert answers_match(candidate(num=123456789), [370, 333667])\n assert answers_match(candidate(num=300000000), [49, 6122449])\n assert answers_match(candidate(num=104729), [30, 3491])\n assert answers_match(candidate(num=65535), [256, 256])\n assert answers_match(candidate(num=500000000), [11829, 42269])\n assert answers_match(candidate(num=499999999), [20000, 25000])\n assert answers_match(candidate(num=135792468), [7810, 17387])\n assert answers_match(candidate(num=77777777), [7213, 10783])\n assert answers_match(candidate(num=100000001), [7122, 14041])\n assert answers_match(candidate(num=499999), [625, 800])\n assert answers_match(candidate(num=319912345), [12039, 26573])\n assert answers_match(candidate(num=345678901), [10853, 31851])\n assert answers_match(candidate(num=456789123), [17525, 26065])\n assert answers_match(candidate(num=789012345), [24293, 32479])\n assert answers_match(candidate(num=987654321), [1402, 704461])\n assert answers_match(candidate(num=1048576), [17, 61681])\n assert answers_match(candidate(num=2), [2, 2])\n assert answers_match(candidate(num=8675309), [2653, 3270])\n assert answers_match(candidate(num=600000001), [98, 6122449])\n assert answers_match(candidate(num=42424242), [124, 342131])\n assert answers_match(candidate(num=999999999), [31250, 32000])\n assert answers_match(candidate(num=1000000), [101, 9901])\n assert answers_match(candidate(num=49), [5, 10])\n assert answers_match(candidate(num=750000000), [4727, 158663])\n assert answers_match(candidate(num=876543210), [12652, 69281])\n assert answers_match(candidate(num=500000001), [3362, 148721])\n assert answers_match(candidate(num=65536), [198, 331])\n assert answers_match(candidate(num=314159), [560, 561])\n assert answers_match(candidate(num=271828182), [11, 24711653])\n assert answers_match(candidate(num=678901234), [22686, 29926])\n assert answers_match(candidate(num=3), [2, 2])\n assert answers_match(candidate(num=15), [4, 4])\n", "comparison": "unordered"}, "public_tests": ["8", "123", "999"], "hints": ["Find the divisors of n+1 and n+2.", "To find the divisors of a number, you only need to iterate to the square root of that number."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().closestDivisors", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:53+00:00", "tests_total": 53, "tests_dropped": 4, "flags": ["any_order"], "topic_tags": ["math", "prime-factorization"]}, "language": "python", "interface": {"raw_signature": "def closestDivisors(self, num: int) -> list[int]:", "container": "Solution", "callable": "closestDivisors", "parameters": [{"name": "num", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1363, "task_id": "largest-multiple-of-three", "difficulty": "Hard", "problem_description": "Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.\n\nSince the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros.\n\nExample 1:\n\nInput: digits = [8,1,9]\nOutput: \"981\"\n\nExample 2:\n\nInput: digits = [8,6,7,1,0]\nOutput: \"8760\"\n\nExample 3:\n\nInput: digits = [1]\nOutput: \"\"\n\nConstraints:\n\n- 1 <= digits.length <= 10^4\n- 0 <= digits[i] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [5, 5, 5]) == \"555\"\n assert candidate(digits = [3, 3, 3]) == \"333\"\n assert candidate(digits = [3, 3, 3, 3, 3]) == \"33333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9876543210\"\n assert candidate(digits = [0, 0, 0]) == \"0\"\n assert candidate(digits = [3, 3, 3, 3]) == \"3333\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2]) == \"222222\"\n assert candidate(digits = [3, 6, 9, 1, 8]) == \"98631\"\n assert candidate(digits = [8, 6, 7, 1, 0]) == \"8760\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"987654321\"\n assert candidate(digits = [1]) == \"\"\n assert candidate(digits = [1, 4, 7, 8, 5, 2]) == \"875421\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == \"333222111\"\n assert candidate(digits = [3, 6, 9, 3, 6, 9]) == \"996633\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5]) == \"555555\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2]) == \"222111\"\n assert candidate(digits = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0]) == \"9876543210\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2]) == \"222222\"\n assert candidate(digits = [8, 1, 9]) == \"981\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876543210\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5]) == \"555555\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111\"\n assert candidate(digits = [2, 5, 8, 1, 4, 7, 0, 3, 6, 9]) == \"9876543210\"\n assert candidate(digits = [0, 0, 0, 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(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == \"33333222222\"\n assert candidate(digits = [2, 3, 6, 9, 9, 3, 2, 6, 2, 3]) == \"9966333222\"\n assert candidate(digits = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == \"3333300000\"\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"33333333333333333333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(digits = [9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0]) == \"99999666663333300000\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 0, 0, 0]) == \"555555000\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == \"444333222111\"\n assert candidate(digits = [2, 5, 8, 2, 6, 3, 6, 9, 0, 5]) == \"98665530\"\n assert candidate(digits = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4]) == \"988776655443210\"\n assert candidate(digits = [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]) == \"333333333222222222111111111\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == \"555555555\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == \"9876543210000\"\n assert candidate(digits = [7, 8, 5, 2, 3, 6, 1, 4, 9, 0]) == \"9876543210\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == \"987654321000000\"\n assert candidate(digits = [1, 4, 7, 1, 4, 7, 1, 4, 7]) == \"777444111\"\n assert candidate(digits = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"22222222222222222221\"\n assert candidate(digits = [2, 5, 8, 5, 2, 8, 5, 2, 8]) == \"888555222\"\n assert candidate(digits = [5, 8, 4, 2, 7, 9, 3, 6, 0, 1]) == \"9876543210\"\n assert candidate(digits = [2, 3, 4, 5, 6, 7, 8, 9]) == \"9876543\"\n assert candidate(digits = [7, 8, 9, 4, 5, 6, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4]) == \"9988776655443210\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"99887766554433221100\"\n assert candidate(digits = [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]) == \"999888777666555444333222111000\"\n assert candidate(digits = [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]) == \"999888777666555444333222111\"\n assert candidate(digits = [6, 3, 2, 1, 0, 9, 8, 7, 4, 5]) == \"9876543210\"\n assert candidate(digits = [4, 7, 4, 7, 4, 7]) == \"777444\"\n assert candidate(digits = [3, 3, 3, 6, 6, 6, 9, 9, 9, 0, 0, 0]) == \"999666333000\"\n assert candidate(digits = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == \"33333333333330000000000000\"\n assert candidate(digits = [5, 2, 5, 2, 5, 2, 5, 2, 5]) == \"555552222\"\n assert candidate(digits = [5, 8, 3, 9, 2, 6, 1, 0]) == \"9865320\"\n assert candidate(digits = [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]) == \"999888777666555444333222111\"\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == \"864000000\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8]) == \"888888888855555555\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777777777\"\n assert candidate(digits = [2, 4, 6, 8, 0, 1, 3, 5, 7, 9]) == \"9876543210\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777777777777777777777\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7]) == \"777777777744444444441111111111\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111111111111\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111111\"\n assert candidate(digits = [1, 4, 7, 2, 5, 8, 3, 6, 9]) == \"987654321\"\n assert candidate(digits = [9, 9, 9, 6, 6, 6, 3, 3, 3, 0, 0, 0]) == \"999666333000\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"999999999999999\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777\"\n", "comparison": "exact"}, "public_tests": ["[8,1,9]", "[8,6,7,1,0]", "[1]"], "hints": ["A number is a multiple of three if and only if its sum of digits is a multiple of three.", "Use dynamic programming.", "To find the maximum number, try to maximize the number of digits of the number.", "Sort the digits in descending order to find the maximum number."], "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().largestMultipleOfThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:56+00:00", "tests_total": 72, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def largestMultipleOfThree(self, digits: list[int]) -> str:", "container": "Solution", "callable": "largestMultipleOfThree", "parameters": [{"name": "digits", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1365, "task_id": "how-many-numbers-are-smaller-than-the-current-number", "difficulty": "Easy", "problem_description": "Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].\n\nReturn the answer in an array.\n\nExample 1:\n\nInput: nums = [8,1,2,2,3]\nOutput: [4,0,1,1,3]\nExplanation:\nFor nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3).\nFor nums[1]=1 does not exist any smaller number than it.\nFor nums[2]=2 there exist one smaller number than it (1).\nFor nums[3]=2 there exist one smaller number than it (1).\nFor nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).\n\nExample 2:\n\nInput: nums = [6,5,4,8]\nOutput: [2,1,0,3]\n\nExample 3:\n\nInput: nums = [7,7,7,7]\nOutput: [0,0,0,0]\n\nConstraints:\n\n- 2 <= nums.length <= 500\n- 0 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [8, 1, 2, 2, 3]) == [4, 0, 1, 1, 3]\n assert candidate(nums = [100, 99, 98, 97, 96]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3]) == [0, 0, 2, 2, 4, 4, 6, 6]\n assert candidate(nums = [100, 99, 98, 97]) == [3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [3, 0, 1, 2, 5]) == [3, 0, 1, 2, 4]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 2, 0, 3, 4]) == [1, 2, 0, 3, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [100, 0, 50, 25, 75]) == [4, 0, 2, 1, 3]\n assert candidate(nums = [3, 0, 6, 1, 5]) == [2, 0, 4, 1, 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]\n assert candidate(nums = [6, 5, 4, 8]) == [2, 1, 0, 3]\n assert candidate(nums = [5, 5, 5, 5, 1]) == [1, 1, 1, 1, 0]\n assert candidate(nums = [0, 0, 0, 1]) == [0, 0, 0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [7, 7, 7, 7]) == [0, 0, 0, 0]\n assert candidate(nums = [50, 20, 30, 10, 40]) == [4, 1, 2, 0, 3]\n assert candidate(nums = [3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100, 0, 50, 25, 75, 12, 37, 62, 88, 99]) == [9, 0, 4, 2, 6, 1, 3, 5, 7, 8]\n assert candidate(nums = [0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100]) == [0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56]\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, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [8, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [13, 0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 16, 16, 18, 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]) == [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, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == [0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 12]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 100, 99, 98, 97]) == [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]\n assert candidate(nums = [5, 8, 3, 9, 1, 7, 4, 6, 2, 0]) == [5, 8, 3, 9, 1, 7, 4, 6, 2, 0]\n assert candidate(nums = [42, 23, 78, 56, 34, 12, 90, 67, 89, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11]) == [13, 11, 16, 14, 12, 10, 18, 15, 17, 1, 2, 0, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 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(nums = [42, 31, 77, 28, 55, 19, 89, 64, 42, 77]) == [3, 2, 7, 1, 5, 0, 9, 6, 3, 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]) == [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]\n assert candidate(nums = [25, 50, 75, 100, 25, 50, 75, 100]) == [0, 2, 4, 6, 0, 2, 4, 6]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == [0, 2, 4, 6, 8, 10, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [47, 53, 100, 42, 55, 80, 86, 29, 93, 37, 48, 51, 21, 79, 68, 94, 3, 8, 58, 52]) == [6, 10, 19, 5, 11, 15, 16, 3, 17, 4, 7, 8, 2, 14, 13, 18, 0, 1, 12, 9]\n assert candidate(nums = [100, 99, 98, 97, 96, 95]) == [5, 4, 3, 2, 1, 0]\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]) == [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 = [2, 1, 0, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [2, 1, 0, 3, 4, 9, 8, 7, 6, 5, 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, 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]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9, 10]) == [4, 2, 0, 1, 3, 5, 7, 6, 8, 9]\n assert candidate(nums = [34, 67, 23, 89, 23, 67, 34, 23, 67, 89]) == [3, 5, 0, 8, 0, 5, 3, 0, 5, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 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 = [50, 25, 75, 25, 50, 75, 50, 25, 75, 50]) == [3, 0, 7, 0, 3, 7, 3, 0, 7, 3]\n assert candidate(nums = [50, 25, 75, 12, 37, 88, 63, 49, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [14, 11, 16, 10, 12, 17, 15, 13, 18, 0, 1, 2, 3, 4, 5, 6, 7, 8, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [3, 1, 2, 4, 5, 9, 8, 7, 6, 0]) == [3, 1, 2, 4, 5, 9, 8, 7, 6, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [50, 24, 7, 9, 12, 33, 18, 42, 60, 5]) == [8, 5, 1, 2, 3, 6, 4, 7, 9, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [50, 20, 10, 30, 40, 5, 15, 25, 35, 45]) == [9, 3, 1, 5, 7, 0, 2, 4, 6, 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]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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, 10, 10, 12, 12, 14, 14, 16, 16]\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 0, 0, 0]) == [7, 7, 7, 5, 5, 3, 3, 0, 0, 0]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60]) == [9, 7, 5, 3, 1, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8]\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11]) == [2, 4, 6, 8, 1, 3, 5, 7, 9, 0]\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 2, 2, 2, 2]) == [3, 3, 3, 0, 0, 0, 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]) == [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]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [0, 2, 1, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0]) == [9, 8, 7, 6, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, 0, 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, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 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(nums = [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, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [0, 100, 50, 25, 75, 20, 80, 30, 60, 40, 90]) == [0, 10, 5, 2, 7, 1, 8, 3, 6, 4, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == [4, 9, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5]) == [13, 11, 9, 7, 5, 4, 3, 2, 1, 0, 13, 11, 9, 7, 5]\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == [0, 0, 2, 2, 4, 4, 6, 6, 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]) == [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]\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]) == [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 = [50, 20, 30, 10, 40]) == [4, 1, 2, 0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0]) == [15, 12, 9, 6, 3, 0, 15, 12, 9, 6, 3, 0, 15, 12, 9, 6, 3, 0]\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 20, 10, 40, 40, 50, 50, 60, 60, 70]) == [0, 3, 3, 0, 6, 6, 3, 0, 8, 8, 10, 10, 12, 12, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 25, 75, 25, 75, 50, 25, 75, 50, 25]) == [4, 0, 7, 0, 7, 4, 0, 7, 4, 0]\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == [0, 2, 1, 3, 5, 4, 6, 8, 7, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [49, 38, 27, 16, 5, 48, 37, 26, 15, 4, 47, 36, 25, 14, 3, 46, 35, 24, 13, 2, 45, 34, 23, 12, 1, 44, 33, 22, 11, 0]) == [29, 23, 17, 11, 5, 28, 22, 16, 10, 4, 27, 21, 15, 9, 3, 26, 20, 14, 8, 2, 25, 19, 13, 7, 1, 24, 18, 12, 6, 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, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [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, 20, 10, 30, 40, 50, 10]) == [0, 3, 0, 4, 5, 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]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 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, 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, 0]) == [27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0]\n assert candidate(nums = [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, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\n assert candidate(nums = [33, 10, 55, 72, 21, 45, 66, 100, 33, 55, 72, 21, 45, 66, 100, 33, 55, 72, 21, 45, 66, 100]) == [4, 0, 10, 16, 1, 7, 13, 19, 4, 10, 16, 1, 7, 13, 19, 4, 10, 16, 1, 7, 13, 19]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == [18, 14, 10, 6, 2, 0, 2, 6, 10, 14, 18, 14, 10, 6, 2, 0, 2, 6, 10, 14]\n assert candidate(nums = [34, 23, 56, 12, 78, 45, 90, 67, 34, 23, 12, 56, 78, 45, 67, 90]) == [4, 2, 8, 0, 12, 6, 14, 10, 4, 2, 0, 8, 12, 6, 10, 14]\n assert candidate(nums = [42, 32, 55, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == [4, 2, 6, 0, 1, 3, 5, 6, 8, 9, 10, 11]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == [0, 2, 4, 6, 8, 10, 11, 12, 13, 14, 0, 2, 4, 6, 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, 0]) == [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]\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, 0]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [0, 19, 1, 18, 2, 17, 3, 16, 4, 15, 5, 14, 6, 13, 7, 12, 8, 11, 9, 10]\n assert candidate(nums = [45, 67, 89, 23, 34, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89]) == [5, 9, 13, 1, 3, 7, 11, 15, 0, 3, 7, 11, 15, 1, 5, 9, 13]\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 50]) == [0, 2, 0, 2, 4, 5, 6]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [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]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n", "comparison": "exact"}, "public_tests": ["[8,1,2,2,3]", "[6,5,4,8]", "[7,7,7,7]"], "hints": ["Brute force for each array element.", "In order to improve the time complexity, we can sort the array and get the answer for each array element."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallerNumbersThanCurrent", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:58+00:00", "tests_total": 110, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "sorting", "counting-sort"]}, "language": "python", "interface": {"raw_signature": "def smallerNumbersThanCurrent(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "smallerNumbersThanCurrent", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1366, "task_id": "rank-teams-by-votes", "difficulty": "Medium", "problem_description": "In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition.\n\nThe ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they tie again, we continue this process until the ties are resolved. If two or more teams are still tied after considering all positions, we rank them alphabetically based on their team letter.\n\nYou are given an array of strings votes which is the votes of all voters in the ranking systems. Sort all teams according to the ranking system described above.\n\nReturn a string of all teams sorted by the ranking system.\n\nExample 1:\n\nInput: votes = [\"ABC\",\"ACB\",\"ABC\",\"ACB\",\"ACB\"]\nOutput: \"ACB\"\nExplanation:\nTeam A was ranked first place by 5 voters. No other team was voted as first place, so team A is the first team.\nTeam B was ranked second by 2 voters and ranked third by 3 voters.\nTeam C was ranked second by 3 voters and ranked third by 2 voters.\nAs most of the voters ranked C second, team C is the second team, and team B is the third.\n\nExample 2:\n\nInput: votes = [\"WXYZ\",\"XYZW\"]\nOutput: \"XWYZ\"\nExplanation:\nX is the winner due to the tie-breaking rule. X has the same votes as W for the first position, but X has one vote in the second position, while W does not have any votes in the second position.\n\nExample 3:\n\nInput: votes = [\"ZMNAGUEDSJYLBOPHRQICWFXTVK\"]\nOutput: \"ZMNAGUEDSJYLBOPHRQICWFXTVK\"\nExplanation: Only one voter, so their votes are used for the ranking.\n\nConstraints:\n\n- 1 <= votes.length <= 1000\n- 1 <= votes[i].length <= 26\n- votes[i].length == votes[j].length for 0 <= i, j < votes.length.\n- votes[i][j] is an English uppercase letter.\n- All characters of votes[i] are unique.\n- All the characters that occur in votes[0] also occur in votes[j] where 1 <= j < votes.length.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(votes = ['ABC', 'ACB', 'ABC', 'ACB', 'ACB']) == \"ACB\"\n assert candidate(votes = ['WXYZ', 'XYZW']) == \"XWYZ\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'ABC']) == \"ABC\"\n assert candidate(votes = ['A', 'B', 'C', 'D', 'E']) == \"ABCDE\"\n assert candidate(votes = ['ABCDEF', 'BCDEFA', 'CDEFAB', 'DEFABC', 'EFABCD', 'FABCDE']) == \"ABCDEF\"\n assert candidate(votes = ['BCA', 'CAB', 'CBA', 'ABC', 'ACB', 'BAC']) == \"ABC\"\n assert candidate(votes = ['A', 'A', 'A', 'A', 'A']) == \"A\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'ABC', 'ABC', 'ACB']) == \"ACB\"\n assert candidate(votes = ['A', 'A', 'A', 'A']) == \"A\"\n assert candidate(votes = ['ZMNAGUEDSJYLBOPHRQICWFXTVK']) == \"ZMNAGUEDSJYLBOPHRQICWFXTVK\"\n assert candidate(votes = ['RGB', 'GBR', 'BRG', 'RBB', 'BBR', 'RBB', 'RRG', 'GRR']) == \"RBG\"\n assert candidate(votes = ['ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ZYXWVUTSRQPONMLKJIHGFEDCBA']) == \"AZBYCXDWEVFUGTHSIRJQKPLOMN\"\n assert candidate(votes = ['BCA', 'CAB', 'ABC', 'ACB', 'BAC']) == \"ABC\"\n assert candidate(votes = ['GHIJKL', 'LKHGJI', 'HKLGJI', 'IGJLKH', 'JIGKHL', 'KGLHJI', 'GHILJK']) == \"GHKILJ\"\n assert candidate(votes = ['LMNO', 'NOLM', 'OLMN', 'MNLO', 'LNMO', 'ONML', 'MLOL', 'LONM', 'MOLN', 'NOML', 'OMNL', 'LMON', 'NLMO', 'OMLN', 'LMNO', 'NOLM', 'OLMN', 'MNLO', 'LNMO', 'ONML', 'MLOL', 'LONM', 'MOLN', 'NOML', 'OMNL']) == \"OLMN\"\n assert candidate(votes = ['ABCDEFGH', 'BCDEFGHA', 'CDEFGHAB', 'DEFGHABC', 'EFGHABCD', 'FGHABCDE', 'GHABCDEF', 'HABCDEFG']) == \"ABCDEFGH\"\n assert candidate(votes = ['ABCDEFG', 'GFEDCBA', 'FBCDEAG', 'BCDEAFG', 'CDEABGF', 'DEABCFG', 'EABCDFG']) == \"BCEDAFG\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC', 'ABCD', 'ABCD']) == \"ABCD\"\n assert candidate(votes = ['QWOP', 'WOPQ', 'OPQW', 'PQWO', 'QWPO', 'WPOQ', 'OPWQ', 'POWQ']) == \"PWOQ\"\n assert candidate(votes = ['QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ']) == \"MQNWBERVCTXYUZILKOJPAHGSDF\"\n assert candidate(votes = ['MNO', 'OMN', 'NMO', 'MON', 'NMN', 'OMM', 'NMM', 'MMM']) == \"MNO\"\n assert candidate(votes = ['UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ']) == \"UVWXYZ\"\n assert candidate(votes = ['MATH', 'TEAM', 'META', 'HATE', 'HEAT', 'MATE', 'TAME', 'TIME']) == \"TMHAEI\"\n assert candidate(votes = ['ZYX', 'XYZ', 'YZX', 'XZY', 'YXZ', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS', 'PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS', 'PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS']) == \"QPRST\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC', 'ACBD']) == \"ACBD\"\n assert candidate(votes = ['PQR', 'QPR', 'RQP', 'PRQ', 'RPQ', 'QRP', 'PQR', 'RQP', 'QRP', 'PRQ']) == \"PQR\"\n assert candidate(votes = ['ZYX', 'YZX', 'XZY', 'XYZ', 'YXZ', 'ZXY', 'YZX', 'ZXY']) == \"ZYX\"\n assert candidate(votes = ['ABCDE', 'EDCBA', 'CBADE', 'BCADE', 'DECAB']) == \"BCDEA\"\n assert candidate(votes = ['ABC', 'BAC', 'BCA', 'CAB', 'CBA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB', 'CAB', 'CBA', 'BCA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB']) == \"CBA\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC']) == \"ABCD\"\n assert candidate(votes = ['AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA']) == \"AB\"\n assert candidate(votes = ['QWERTYUIOPASDFGHJKLZXCVBNM', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'QWERTYUIOPASDFGHJKLZXCVBNM']) == \"QWERTYUIOPASDFGHJKLZXCVBNM\"\n assert candidate(votes = ['XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG']) == \"IHGFEJ\"\n assert candidate(votes = ['XYZ', 'YZX', 'ZXY', 'YXZ', 'XZY', 'ZYX', 'XYZ', 'YZX']) == \"YXZ\"\n assert candidate(votes = ['AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA']) == \"AB\"\n assert candidate(votes = ['TLI', 'LIT', 'ITL', 'TIL', 'ILT', 'LTI', 'TIL', 'LTI', 'ILT', 'TLI']) == \"TLI\"\n assert candidate(votes = ['QWERTY', 'QWRETY', 'QWRTEY', 'QWRTYE', 'QWRYTE']) == \"QWRETY\"\n assert candidate(votes = ['ZEBRA', 'BRACE', 'BEZAR', 'RABZE', 'AREBZ', 'ZERBA']) == \"BZRAEC\"\n assert candidate(votes = ['ZYX', 'YXZ', 'XYZ', 'YZX', 'XZY', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['GHIJK', 'HIJKG', 'IJKGH', 'JKGHI', 'KGIJH', 'GHIJK', 'HGIJK', 'IGHJK', 'JGIHK', 'KGIJH']) == \"GHIJK\"\n assert candidate(votes = ['WXYZ', 'YZWX', 'ZWXY', 'XWYZ', 'WZYX', 'XYZW']) == \"WXZY\"\n assert candidate(votes = ['PQRSTU', 'QPRSTU', 'QRPTSU', 'QRSTUP', 'QPRTSU', 'QTRPSU', 'QTRSPU', 'QTSRPU', 'QTSPUR', 'QTPRSU', 'QTPSUR', 'QTUSPR', 'QTUSRP', 'QTURPS', 'QTURSP', 'QTUPRS', 'QTUPSR', 'QTRSPU', 'QTSRPU', 'QTRPUS', 'QTRUPS', 'QTPRSU', 'QTPSUR', 'QTUSPR', 'QTURPS', 'QTURSP', 'QTUPRS', 'QTUPSR']) == \"QPTRUS\"\n assert candidate(votes = ['ABCD', 'DCBA', 'BCAD', 'CADB', 'ACDB', 'DABC', 'BCDA']) == \"ABDC\"\n assert candidate(votes = ['LOVE', 'VOTE', 'LEVO', 'OVEL', 'VOLE', 'ELOV']) == \"VLOET\"\n assert candidate(votes = ['LMNO', 'MLON', 'OLNM', 'NOLM', 'ONML', 'MNLO', 'LOMN', 'LONM', 'NMLO', 'OMNL', 'NOLM', 'OLNM']) == \"OLNM\"\n assert candidate(votes = ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D', 'E', 'E', 'E', 'E', 'F', 'F', 'F', 'F', 'G', 'G', 'G', 'G', 'H', 'H', 'H', 'H', 'I', 'I', 'I', 'I', 'J', 'J', 'J', 'J', 'K', 'K', 'K', 'K', 'L', 'L', 'L', 'L', 'M', 'M', 'M', 'M', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'P', 'P', 'P', 'P', 'Q', 'Q', 'Q', 'Q', 'R', 'R', 'R', 'R', 'S', 'S', 'S', 'S', 'T', 'T', 'T', 'T', 'U', 'U', 'U', 'U', 'V', 'V', 'V', 'V', 'W', 'W', 'W', 'W', 'X', 'X', 'X', 'X', 'Y', 'Y', 'Y', 'Y', 'Z', 'Z', 'Z', 'Z']) == \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(votes = ['ABCDEF', 'FEDCBA', 'DEFABC', 'BCDAFE', 'CBAFED', 'AFECBD', 'BDFECA']) == \"BAFDCE\"\n assert candidate(votes = ['AC', 'CA', 'AC', 'CA', 'AC', 'CA', 'AC', 'CA', 'AC', 'CA']) == \"AC\"\n assert candidate(votes = ['LMNO', 'MLNO', 'NOLM', 'OLMN', 'NOML', 'OMNL', 'LONM', 'OLNM', 'MOLN', 'LNOM', 'LOMN', 'MONL', 'NLOM', 'LNMO', 'LNMN', 'OMLN', 'NOLM', 'NLMO', 'MOLN', 'ONLM', 'OMNL', 'LONM', 'OLNM', 'MOLN', 'LNOM', 'LOMN', 'MONL', 'NLOM', 'LNMO', 'LNMN']) == \"LONM\"\n assert candidate(votes = ['PQRST', 'QPRST', 'RSPTQ', 'TRPQS', 'SQPTR', 'PRQST', 'PQRST', 'RQPTS', 'TQRS', 'SPRQT']) == \"PRSTQ\"\n assert candidate(votes = ['PQR', 'QRP', 'RPQ', 'PRQ', 'QPR', 'RQP', 'PQR', 'QRP', 'RPQ', 'PRQ', 'QPR', 'RQP']) == \"PQR\"\n assert candidate(votes = ['ABCDE', 'ACBDE', 'CABDE', 'BCADE', 'DCABE']) == \"ACBDE\"\n assert candidate(votes = ['XYZ', 'YXZ', 'YZX', 'ZXY', 'ZYX', 'XZY', 'YZX', 'ZYX', 'XYZ', 'YXZ', 'XZY', 'XYZ']) == \"XYZ\"\n assert candidate(votes = ['FGHIJK', 'GHIJKF', 'HIJKFG', 'IJKFGH', 'JKFGHI', 'KFGHIJ', 'FGHIJK', 'GHIJKF', 'HIJKFG', 'IJKFGH']) == \"IHGFJK\"\n assert candidate(votes = ['ACBD', 'BDAC', 'CDAB', 'DABC', 'ABCD', 'BACD', 'CABD', 'DABC', 'ACDB', 'BCDA']) == \"ABCD\"\n assert candidate(votes = ['ABCD', 'ABDC', 'ACBD', 'ACDB', 'ADBC', 'ADCB', 'BACD', 'BADC', 'BCAD', 'BCDA', 'BDAC', 'BDCA', 'CABD', 'CADB', 'CBAD', 'CBDA', 'CDAB', 'CDBA', 'DABC', 'DACB', 'DBAC', 'DBCA', 'DCAB', 'DCBA']) == \"ABCD\"\n assert candidate(votes = ['UVWX', 'VWXU', 'WXUV', 'XUVW', 'UVWX', 'VWXU', 'WXUV', 'XUVW', 'UVWX', 'VWXU']) == \"VUWX\"\n assert candidate(votes = ['ZR', 'RZ', 'ZR', 'RZ', 'ZR']) == \"ZR\"\n assert candidate(votes = ['SUNNY', 'UNNYS', 'NUNYS', 'NNYSU', 'NUYNS', 'USNNY', 'NSUNY']) == \"NUSY\"\n assert candidate(votes = ['HELLO', 'OLLEH', 'LOHEL', 'LLOEH', 'HLOEL', 'ELOHL', 'ELLOH', 'OLEHL', 'LELOH', 'OHELL']) == \"LOEH\"\n assert candidate(votes = ['ACB', 'BAC', 'CBA', 'BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'BCA', 'CAB', 'ACB', 'BAC', 'CBA']) == \"CBA\"\n assert candidate(votes = ['EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH']) == \"EFGIJH\"\n assert candidate(votes = ['QWRTY', 'QWYRT', 'WQRTY', 'WQYRT', 'RTQWY', 'RTYQW', 'YRQWT', 'YRTQW', 'TWQRY', 'TYWQR']) == \"WQRTY\"\n assert candidate(votes = ['PYTHON', 'TYHONP', 'YHTNPO', 'HNOTYP', 'NOTYHP', 'OTHNYP']) == \"YTHONP\"\n assert candidate(votes = ['MNO', 'NOM', 'OMN', 'MON', 'NMO', 'OMN', 'MNO']) == \"MNO\"\n assert candidate(votes = ['MNO', 'OMN', 'NMO', 'MON', 'NOM', 'OMN']) == \"MON\"\n assert candidate(votes = ['ABCD', 'DCBA', 'BCDA', 'CBAD', 'ADBC', 'BDAC', 'ACBD', 'CADB', 'DABC', 'DBCA']) == \"ADBC\"\n assert candidate(votes = ['FGHIJ', 'IJFGH', 'JFGHI', 'HGIJF', 'IGHFJ', 'GFHIJ']) == \"IGFJH\"\n assert candidate(votes = ['VWXYZ', 'YZWXV', 'ZWXYV', 'XWYZV', 'WZYXV', 'XYZWV', 'VWYZX', 'WVXYZ', 'XYZVW', 'YZXVW', 'ZXYVW', 'VZWXY', 'WXYVZ', 'XVZXY', 'YZVWX', 'ZVXYW', 'VXYWZ', 'XYWVZ', 'YWVZX', 'YVZXW', 'VZXWY', 'ZXWYV', 'XWYVZ']) == \"XVYZW\"\n assert candidate(votes = ['ABCDE', 'ABCDE', 'ABCDE', 'EABCD', 'DEABC']) == \"AEDBC\"\n assert candidate(votes = ['UV', 'VU', 'UV', 'UV', 'VU', 'UV', 'UV', 'VU', 'VU', 'VU', 'UV', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU']) == \"VU\"\n", "comparison": "exact"}, "public_tests": ["[\"ABC\",\"ACB\",\"ABC\",\"ACB\",\"ACB\"]", "[\"WXYZ\",\"XYZW\"]", "[\"ZMNAGUEDSJYLBOPHRQICWFXTVK\"]"], "hints": ["Build array rank where rank[i][j] is the number of votes for team i to be the j-th rank.", "Sort the teams by rank array. if rank array is the same for two or more teams, sort them by the ID in ascending order."], "metadata": {"canonical_parameter_names": ["votes"], "leetcode_dataset_entry_point": "Solution().rankTeams", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:00+00:00", "tests_total": 73, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def rankTeams(self, votes: list[str]) -> str:", "container": "Solution", "callable": "rankTeams", "parameters": [{"name": "votes", "type": "list[str]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1368, "task_id": "minimum-cost-to-make-at-least-one-valid-path-in-a-grid", "difficulty": "Hard", "problem_description": "Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be:\n\n- 1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])\n- 2 which means go to the cell to the left. (i.e go from grid[i][j] to grid[i][j - 1])\n- 3 which means go to the lower cell. (i.e go from grid[i][j] to grid[i + 1][j])\n- 4 which means go to the upper cell. (i.e go from grid[i][j] to grid[i - 1][j])\n\nNotice that there could be some signs on the cells of the grid that point outside the grid.\n\nYou will initially start at the upper left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1) following the signs on the grid. The valid path does not have to be the shortest.\n\nYou can modify the sign on a cell with cost = 1. You can modify the sign on a cell one time only.\n\nReturn the minimum cost to make the grid have at least one valid path.\n\nExample 1:\n\nInput: grid = [[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]\nOutput: 3\nExplanation: You will start at point (0, 0).\nThe path to (3, 3) is as follows. (0, 0) --> (0, 1) --> (0, 2) --> (0, 3) change the arrow to down with cost = 1 --> (1, 3) --> (1, 2) --> (1, 1) --> (1, 0) change the arrow to down with cost = 1 --> (2, 0) --> (2, 1) --> (2, 2) --> (2, 3) change the arrow to down with cost = 1 --> (3, 3)\nThe total cost = 3.\n\nExample 2:\n\nInput: grid = [[1,1,3],[3,2,2],[1,1,4]]\nOutput: 0\nExplanation: You can follow the path from (0, 0) to (2, 2).\n\nExample 3:\n\nInput: grid = [[1,2],[4,3]]\nOutput: 1\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 100\n- 1 <= grid[i][j] <= 4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == 3\n assert candidate(grid = [[4, 4, 4], [4, 4, 4], [4, 4, 4]]) == 4\n assert candidate(grid = [[2, 3, 4, 1], [4, 2, 3, 1], [3, 4, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[3, 4, 2, 1], [4, 2, 3, 1], [2, 1, 4, 3], [1, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [1, 1, 1, 1], [2, 2, 2, 2]]) == 3\n assert candidate(grid = [[4, 2, 3], [1, 2, 1], [1, 2, 4]]) == 3\n assert candidate(grid = [[2, 1, 1], [1, 2, 2], [2, 2, 1]]) == 3\n assert candidate(grid = [[1, 2], [4, 3]]) == 1\n assert candidate(grid = [[1, 1, 3], [3, 2, 2], [1, 1, 4]]) == 0\n assert candidate(grid = [[4, 2, 3], [1, 3, 2], [2, 1, 4]]) == 1\n assert candidate(grid = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2], [1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2], [1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2]]) == 5\n assert candidate(grid = [[4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 3, 3, 3, 3, 3, 3, 3, 3, 4], [4, 3, 2, 2, 2, 2, 2, 2, 3, 4], [4, 3, 2, 1, 1, 1, 2, 2, 3, 4], [4, 3, 2, 1, 4, 1, 2, 2, 3, 4], [4, 3, 2, 1, 4, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 4, 4, 1, 3, 4], [4, 3, 2, 1, 4, 4, 4, 4, 3, 4], [4, 3, 2, 1, 4, 4, 4, 4, 4, 4], [4, 3, 2, 1, 4, 4, 4, 4, 4, 4]]) == 8\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]]) == 8\n assert candidate(grid = [[1, 1, 1, 4, 1, 1], [2, 2, 2, 4, 2, 2], [1, 1, 1, 4, 1, 1], [4, 4, 4, 1, 4, 4], [1, 1, 1, 4, 1, 1], [2, 2, 2, 4, 2, 2]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 3, 4], [3, 2, 1, 4, 3], [1, 2, 3, 4, 1], [3, 4, 1, 2, 3], [2, 1, 4, 3, 2]]) == 2\n assert candidate(grid = [[1, 1, 1, 2, 3, 4], [4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 2, 1], [2, 3, 4, 1, 3, 4]]) == 3\n assert candidate(grid = [[1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1]]) == 3\n assert candidate(grid = [[1, 3, 2, 3, 4], [4, 2, 3, 1, 2], [3, 1, 4, 2, 3], [2, 4, 1, 3, 4], [1, 2, 3, 4, 1]]) == 3\n assert candidate(grid = [[2, 1, 2, 3, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2]]) == 4\n assert candidate(grid = [[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]]) == 4\n assert candidate(grid = [[3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3]]) == 8\n assert candidate(grid = [[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], [1, 2, 1, 2, 1, 2]]) == 5\n assert candidate(grid = [[1, 1, 2, 4, 3], [3, 2, 1, 1, 4], [1, 3, 4, 1, 2], [2, 1, 3, 4, 1], [3, 4, 1, 2, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4], [2, 1, 4, 3, 2, 1, 4, 3]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3]]) == 9\n assert candidate(grid = [[2, 2, 2, 4, 4], [4, 3, 3, 2, 1], [3, 1, 1, 3, 2], [2, 1, 4, 3, 1], [4, 3, 2, 1, 2]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 3, 2], [2, 3, 4, 1]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 6\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], [1, 2, 3, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]]) == 6\n assert candidate(grid = [[1, 4, 3, 3, 2, 2, 1, 1, 2, 4], [3, 4, 4, 2, 2, 1, 4, 3, 2, 4], [4, 3, 2, 4, 2, 1, 1, 1, 4, 3], [3, 4, 2, 2, 1, 1, 4, 3, 2, 4], [1, 2, 4, 1, 3, 3, 2, 2, 4, 3], [3, 2, 3, 4, 3, 4, 1, 1, 2, 3], [4, 3, 4, 2, 1, 1, 2, 2, 3, 4], [3, 4, 3, 1, 2, 2, 3, 4, 1, 2], [1, 2, 4, 3, 2, 2, 1, 1, 4, 3], [3, 2, 3, 4, 1, 1, 2, 2, 3, 4]]) == 6\n assert candidate(grid = [[1, 3, 2, 4, 1], [1, 1, 3, 2, 4], [3, 4, 1, 1, 3], [2, 3, 4, 1, 1], [1, 2, 3, 4, 2]]) == 1\n assert candidate(grid = [[3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]]) == 9\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]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 1, 2], [3, 4, 1, 2, 3, 4], [2, 1, 4, 3, 2, 1], [4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2], [3, 4, 1, 2, 3, 4]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [4, 3, 2, 1, 4], [1, 2, 3, 4, 1], [4, 3, 2, 1, 4], [1, 2, 3, 4, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4]]) == 5\n assert candidate(grid = [[4, 2, 3, 1, 3, 1, 4], [2, 4, 3, 2, 1, 3, 2], [3, 1, 4, 3, 2, 4, 3], [1, 3, 2, 4, 3, 1, 2], [4, 2, 3, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[3, 3, 2, 1, 1], [4, 3, 2, 4, 3], [2, 3, 3, 4, 2], [1, 4, 4, 4, 1], [2, 2, 3, 1, 2]]) == 4\n assert candidate(grid = [[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, 1, 1, 2, 2]]) == 4\n assert candidate(grid = [[2, 3, 4, 1, 2], [1, 2, 3, 4, 1], [4, 1, 2, 3, 4], [3, 4, 1, 2, 3], [2, 1, 4, 3, 1]]) == 4\n assert candidate(grid = [[1, 4, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4], [1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [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, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2]]) == 7\n assert candidate(grid = [[3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1], [3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 4], [2, 4, 3, 1], [3, 1, 4, 2], [4, 2, 1, 3]]) == 2\n assert candidate(grid = [[1, 3, 1, 1, 3, 2], [1, 2, 2, 2, 3, 3], [2, 2, 2, 1, 1, 3], [3, 3, 1, 2, 2, 3], [3, 2, 3, 3, 1, 1], [1, 1, 1, 3, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 1, 2, 1], [3, 4, 3, 4, 3], [1, 2, 1, 2, 1], [3, 4, 3, 4, 3], [1, 2, 1, 2, 1]]) == 4\n assert candidate(grid = [[1, 3, 4, 3, 1, 2], [2, 4, 3, 1, 2, 3], [3, 1, 2, 3, 4, 1], [4, 2, 3, 4, 1, 2], [1, 3, 4, 1, 2, 3], [2, 4, 1, 2, 3, 4]]) == 4\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, 1, 1, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4, 3, 1], [1, 2, 3, 4, 1, 2, 3, 4, 4, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 3, 1, 1, 1], [1, 4, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 1, 1, 2, 3, 3, 3, 4], [2, 2, 2, 1, 1, 1, 4, 3], [3, 3, 2, 2, 2, 4, 1, 2], [4, 4, 3, 3, 3, 1, 2, 1], [1, 1, 4, 4, 4, 2, 1, 3], [2, 2, 1, 1, 1, 3, 2, 4], [3, 3, 2, 2, 2, 4, 3, 1], [4, 4, 3, 3, 3, 1, 4, 2]]) == 6\n assert candidate(grid = [[4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[2, 2, 2, 1, 1], [1, 1, 1, 2, 2], [2, 2, 2, 1, 1], [1, 1, 1, 2, 2], [2, 2, 2, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 4, 1], [2, 4, 1, 3, 2], [3, 1, 4, 2, 3], [4, 2, 3, 1, 4], [1, 4, 3, 2, 1]]) == 3\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == 3\n assert candidate(grid = [[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]]) == 4\n assert candidate(grid = [[2, 3, 4, 1, 1, 2], [1, 4, 2, 3, 4, 2], [2, 3, 1, 4, 2, 3], [3, 4, 2, 1, 3, 4], [4, 1, 3, 2, 4, 1], [1, 2, 4, 3, 1, 2]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1], [4, 1, 2, 3, 4, 1, 2], [1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4]]) == 6\n assert candidate(grid = [[1, 2, 2, 2, 3, 3, 1], [3, 1, 1, 1, 1, 2, 3], [2, 3, 3, 3, 2, 3, 2], [1, 1, 1, 1, 3, 2, 1], [2, 3, 2, 3, 1, 1, 2], [3, 2, 3, 2, 1, 2, 3], [1, 2, 1, 2, 3, 3, 1]]) == 3\n assert candidate(grid = [[2, 3, 4, 1], [4, 1, 2, 3], [1, 2, 3, 4], [3, 4, 1, 2]]) == 2\n assert candidate(grid = [[3, 3, 2, 1, 1], [2, 1, 1, 4, 1], [1, 2, 1, 4, 3], [2, 1, 4, 2, 4], [1, 2, 3, 4, 4]]) == 4\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [3, 3, 4, 4, 1, 1], [2, 2, 1, 1, 4, 4], [4, 4, 3, 3, 2, 2], [1, 1, 2, 2, 3, 3], [3, 3, 4, 4, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1]]) == 3\n assert candidate(grid = [[4, 1, 1, 1, 3], [2, 4, 2, 4, 2], [1, 2, 1, 2, 1], [3, 2, 3, 2, 3], [1, 4, 1, 4, 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]]) == 4\n assert candidate(grid = [[2, 2, 4, 1, 2, 4, 1, 3, 3, 4], [1, 1, 1, 3, 3, 4, 2, 1, 3, 1], [3, 2, 2, 1, 1, 2, 4, 4, 4, 3], [4, 1, 3, 2, 4, 1, 3, 2, 3, 1], [2, 3, 4, 2, 1, 4, 1, 1, 3, 4], [1, 4, 1, 4, 2, 1, 2, 4, 3, 4]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4], [2, 3, 4, 1, 2, 3, 4, 1], [3, 4, 1, 2, 3, 4, 1, 2], [4, 1, 2, 3, 4, 1, 2, 3], [1, 2, 3, 4, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[1, 3, 2, 4, 1, 2, 3, 4], [2, 4, 3, 1, 2, 3, 4, 1], [3, 1, 4, 2, 3, 4, 1, 2], [4, 2, 3, 4, 1, 2, 3, 4], [1, 3, 4, 1, 2, 3, 4, 1], [2, 4, 1, 2, 3, 4, 1, 2], [3, 1, 2, 3, 4, 1, 2, 3], [4, 2, 3, 4, 1, 2, 3, 4]]) == 6\n assert candidate(grid = [[1, 2, 2, 3], [3, 4, 1, 2], [1, 3, 4, 2], [2, 1, 3, 4]]) == 2\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], [1, 1, 1, 1, 1, 1, 1, 1, 1], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1], [4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3]]) == 5\n assert candidate(grid = [[3, 1, 1, 2, 1, 4, 1], [3, 3, 4, 1, 3, 3, 3], [3, 4, 2, 2, 3, 1, 3], [3, 3, 3, 1, 1, 4, 3], [1, 3, 2, 3, 4, 4, 2], [2, 2, 4, 1, 3, 2, 4], [4, 4, 1, 1, 2, 3, 3]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3]]) == 9\n assert candidate(grid = [[3, 1, 2, 1, 4], [1, 4, 3, 2, 1], [2, 3, 4, 1, 2], [4, 1, 2, 3, 4], [1, 2, 3, 4, 3]]) == 3\n assert candidate(grid = [[4, 4, 4, 2, 4, 1, 2, 4], [1, 4, 2, 4, 2, 4, 4, 4], [2, 1, 3, 3, 1, 3, 3, 1], [4, 2, 3, 4, 1, 2, 4, 4], [1, 3, 4, 4, 1, 2, 3, 1], [2, 4, 2, 2, 4, 4, 1, 2], [4, 3, 4, 2, 1, 2, 3, 4], [4, 4, 4, 1, 3, 4, 2, 3]]) == 7\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 1, 2, 1, 2, 1, 2], [3, 3, 3, 3, 3, 3, 3], [1, 2, 1, 2, 1, 2, 1], [3, 3, 3, 3, 3, 3, 3], [2, 1, 2, 1, 2, 1, 2]]) == 4\n assert candidate(grid = [[4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1]]) == 6\n assert candidate(grid = [[4, 1, 2, 3], [3, 4, 1, 2], [2, 3, 4, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]", "[[1,1,3],[3,2,2],[1,1,4]]", "[[1,2],[4,3]]"], "hints": ["Build a graph where grid[i][j] is connected to all the four side-adjacent cells with weighted edge. the weight is 0 if the sign is pointing to the adjacent cell or 1 otherwise.", "Do BFS from (0, 0) visit all edges with weight = 0 first. the answer is the distance to (m -1, n - 1)."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:04+00:00", "tests_total": 87, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "breadth-first-search", "graph", "heap-priority-queue", "matrix", "shortest-path", "0-1-bfs", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1370, "task_id": "increasing-decreasing-string", "difficulty": "Easy", "problem_description": "You are given a string s. Reorder the string using the following algorithm:\n\n1. Remove the smallest character from s and append it to the result.\n2. Remove the smallest character from s that is greater than the last appended character, and append it to the result.\n3. Repeat step 2 until no more characters can be removed.\n4. Remove the largest character from s and append it to the result.\n5. Remove the largest character from s that is smaller than the last appended character, and append it to the result.\n6. Repeat step 5 until no more characters can be removed.\n7. Repeat steps 1 through 6 until all characters from s have been removed.\n\nIf the smallest or largest character appears more than once, you may choose any occurrence to append to the result.\n\nReturn the resulting string after reordering s using this algorithm.\n\nExample 1:\n\nInput: s = \"aaaabbbbcccc\"\nOutput: \"abccbaabccba\"\nExplanation: After steps 1, 2 and 3 of the first iteration, result = \"abc\"\nAfter steps 4, 5 and 6 of the first iteration, result = \"abccba\"\nFirst iteration is done. Now s = \"aabbcc\" and we go back to step 1\nAfter steps 1, 2 and 3 of the second iteration, result = \"abccbaabc\"\nAfter steps 4, 5 and 6 of the second iteration, result = \"abccbaabccba\"\n\nExample 2:\n\nInput: s = \"rat\"\nOutput: \"art\"\nExplanation: The word \"rat\" becomes \"art\" after re-ordering it with the mentioned algorithm.\n\nConstraints:\n\n- 1 <= s.length <= 500\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"rqy\") == \"qry\"\n assert candidate(s = \"fuvofn\") == \"fnouvf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"vibhu\") == \"bhiuv\"\n assert candidate(s = \"xyyzz\") == \"xyzzy\"\n assert candidate(s = \"ijkpqxz\") == \"ijkpqxz\"\n assert candidate(s = \"hfnmwy\") == \"fhmnwy\"\n assert candidate(s = \"tkfjkj\") == \"fjktkj\"\n assert candidate(s = \"rat\") == \"art\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"abacabadabacaba\") == \"abcdcbaabbaaaaa\"\n assert candidate(s = \"ukqay\") == \"akquy\"\n assert candidate(s = \"spo\") == \"ops\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcddcbaabcddcbaabcddcbaabcddcba\"\n assert candidate(s = \"ukqms\") == \"kmqsu\"\n assert candidate(s = \"leetcode\") == \"cdelotee\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaaabbbbcccc\") == \"abccbaabccba\"\n assert candidate(s = \"ggggggg\") == \"ggggggg\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abacaba\") == \"abcbaaa\"\n assert candidate(s = \"aaaazzzz\") == \"azzaazza\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"wzyzxwzyzxwzyz\") == \"wxyzzyxwwyzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazzzzzzzzzzzzzzz\"\n assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\") == \"xyzzyxxyzzyxxyzzyxxyzzyxxyzzyxxyzzyxxyzzyx\"\n assert candidate(s = \"abacabadabacabadabacabad\") == \"abcddcbaabcdbaabbaaaaaaa\"\n assert candidate(s = \"rearrange\") == \"aegnrrear\"\n assert candidate(s = \"abcdefghiabcdefghiabcdefghiabcdefghiabcdefghi\") == \"abcdefghiihgfedcbaabcdefghiihgfedcbaabcdefghi\"\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmkjihgfexyzzyz\"\n assert candidate(s = \"zzzzzyyyxxxwwwwvvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmkjihgfedcvwxyzzwz\"\n assert candidate(s = \"qwertypoiuytrewqpoiuytr\") == \"eiopqrtuwyywutrqpoierty\"\n assert candidate(s = \"aabbccccdddd\") == \"abcddcbacddc\"\n assert candidate(s = \"ppqqrrsstttuuuuvvvwwxxxyyyzzzz\") == \"pqrstuvwxyzzyxwvutsrqptuvxyzzu\"\n assert candidate(s = \"thisisaverylongstringthatneedstobesortedbythealgorithm\") == \"abdeghilmnorstvyytsronlihgedbaaeghinorsttsroiheesttett\"\n assert candidate(s = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == \"jkllkjjkllkjjkllkjjkllkjjkllkjjkllkjjkllkj\"\n assert candidate(s = \"abcdabcdbcdabcdabcdbcdabcdabcdbcd\") == \"abcddcbaabcddcbaabcddcbabcddcbbcd\"\n assert candidate(s = \"nnnnoooppqqrrsssttuuuvvwwxxxyyyzzz\") == \"nopqrstuvwxyzzyxwvutsrqponnosuxyzn\"\n assert candidate(s = \"svilikwd\") == \"diklsvwi\"\n assert candidate(s = \"ppqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpq\") == \"pqqppqqppqqppqqppqqppqqppqqppqqppqqppqqppqqppqp\"\n assert candidate(s = \"zabzabzabzabzabzabzabzabzabzabzabzabzab\") == \"abzzbaabzzbaabzzbaabzzbaabzzbaabzzbaabz\"\n assert candidate(s = \"ppqpqpppqpppqpppqpqppppqpqpppppp\") == \"pqqppqqppqqppqqppppppppppppppppp\"\n assert candidate(s = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzfedcba\"\n assert candidate(s = \"successfultesting\") == \"cefgilnstuutsecss\"\n assert candidate(s = \"mmuuxxxaannnltttvvvsssss\") == \"almnstuvxxvutsnmanstvxss\"\n assert candidate(s = \"abababababababababababab\") == \"abbaabbaabbaabbaabbaabba\"\n assert candidate(s = \"aabbbcccddddeeeeefffffff\") == \"abcdeffedcbabcdeffedefff\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwwwxxyyzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmopqrstuvwz\"\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == \"abcdrrdcbaabcdrrbaabrrbaaaaaaaaaa\"\n assert candidate(s = \"xyzzzyyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxyz\"\n assert candidate(s = \"abcdabcdbca\") == \"abcddcbaabc\"\n assert candidate(s = \"zzzzzyyyyyxxxxxxwwwwvvvvuuuuttttssssrrrrqqqqpppplllloooonnnnmmmmlkkkkjjjjiiihhhhggggffffeeeedddccccbbbaaaaaa\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjhgfecaalxyzxa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazz\"\n assert candidate(s = \"abcdefabcdefabcdefabcdef\") == \"abcdeffedcbaabcdeffedcba\"\n assert candidate(s = \"banana\") == \"abnnaa\"\n assert candidate(s = \"gggggggggggggggggggggggggg\") == \"gggggggggggggggggggggggggg\"\n assert candidate(s = \"mmmmnnnnnnnnlllllkkkkjjjjiiihhhhggggffffffeeeeeeeedddddcccccbbbbbaaaaa\") == \"abcdefghijklmnnmlkjihgfedcbaabcdefghijklmnnmlkjhgfedcbaabcdeflnnfeenne\"\n assert candidate(s = \"mamamamamamamamamamamama\") == \"ammaammaammaammaammaamma\"\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppp\") == \"pppppppppppppppppppppppppppppppppppppppppppppppppppppp\"\n assert candidate(s = \"elephantzoo\") == \"aehlnoptzoe\"\n assert candidate(s = \"elephant\") == \"aehlnpte\"\n assert candidate(s = \"algorithm\") == \"aghilmort\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazzzzzz\"\n assert candidate(s = \"bcaaacbcabcabcabcabcabcabcabc\") == \"abccbaabccbaabccbaabccbaabcca\"\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmiklopqazwsxedcrfvtgbyhnujmiklop\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"mississippi\") == \"impsspiissi\"\n assert candidate(s = \"flfrffvfrmfvffvvfrrfmfffffrfrfrff\") == \"flmrvvrmffrvvrffrrffrffffffffffff\"\n assert candidate(s = \"abcdefgfedcbabcdefgfedcba\") == \"abcdefggfedcbaabcdeffedcb\"\n", "comparison": "exact"}, "public_tests": ["\"aaaabbbbcccc\"", "\"rat\""], "hints": ["Count the frequency of each character.", "Loop over all character from 'a' to 'z' and append the character if it exists and decrease frequency by 1. Do the same from 'z' to 'a'.", "Keep repeating until the frequency of all characters is zero."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:07+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "python", "interface": {"raw_signature": "def sortString(self, s: str) -> str:", "container": "Solution", "callable": "sortString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1371, "task_id": "find-the-longest-substring-containing-vowels-in-even-counts", "difficulty": "Medium", "problem_description": "Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.\n\nExample 1:\n\nInput: s = \"eleetminicoworoep\"\nOutput: 13\nExplanation: The longest substring is \"leetminicowor\" which contains two each of the vowels: e, i and o and zero of the vowels: a and u.\n\nExample 2:\n\nInput: s = \"leetcodeisgreat\"\nOutput: 5\nExplanation: The longest substring is \"leetc\" which contains two e's.\n\nExample 3:\n\nInput: s = \"bcbcbc\"\nOutput: 6\nExplanation: In this case, the given string \"bcbcbc\" is the longest because all vowels: a, e, i, o and u appear zero times.\n\nConstraints:\n\n- 1 <= s.length <= 5 x 10^5\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"bcbcbc\") == 6\n assert candidate(s = \"cbacdcdcdbacdbad\") == 14\n assert candidate(s = \"aeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"aaaaaeeeeeiioooouuuu\") == 14\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 26\n assert candidate(s = \"aaeeiioouu\") == 10\n assert candidate(s = \"aeiou\") == 0\n assert candidate(s = \"aaaaa\") == 4\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"leetcodeisgreat\") == 5\n assert candidate(s = \"abacabadabacaba\") == 15\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaaaaea\") == 18\n assert candidate(s = \"\") == 0\n assert candidate(s = \"aeeeeeiiiiioooouuuu\") == 12\n assert candidate(s = \"xyz\") == 3\n assert candidate(s = \"abcdefghiijkeilmnopqrstuvwxyzaeiou\") == 12\n assert candidate(s = \"aabbeeaabbeeaabb\") == 16\n assert candidate(s = \"eiouaeiouaeiou\") == 10\n assert candidate(s = \"eleetminicoworoep\") == 13\n assert candidate(s = \"bbaeixaaaaooxu\") == 8\n assert candidate(s = \"aioieu\") == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\") == 21\n assert candidate(s = \"aeiaaioaaaaeiiiiiioooeeeauuaeuia\") == 28\n assert candidate(s = \"aabbccddeeff\") == 12\n assert candidate(s = \"leetcodeleetcode\") == 16\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"zxcvbnmlkjhgfdsapoiuytrewq\") == 15\n assert candidate(s = \"aaaaaaaa\") == 8\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouxyzuvwaeiouaeiouaeiou\") == 45\n assert candidate(s = \"eeioouuuaeeioouuua\") == 18\n assert candidate(s = \"aeiouaeiouaeiou\") == 10\n assert candidate(s = \"abacaxebecixodeoxou\") == 9\n assert candidate(s = \"thisisaverylongstringwithvariousvowels\") == 13\n assert candidate(s = \"eiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 40\n assert candidate(s = \"uoieaouioeaoieauoi\") == 12\n assert candidate(s = \"mamad\") == 5\n assert candidate(s = \"leetcodeleetcodeleetcode\") == 21\n assert candidate(s = \"bbaaccddeeffgg\") == 14\n assert candidate(s = \"eiouaeiouaieouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"xyzuvwaeiouaeiouxyzuvwaeiouaeiouxyzuvwaeiouaeiou\") == 47\n assert candidate(s = \"abcdeabcdeabcde\") == 13\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouabcdeffedcbaaeiouaeiou\") == 52\n assert candidate(s = \"xyzabcdeiouaeiouabcdeiouaeiouxyz\") == 32\n assert candidate(s = \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"bcbcbcbaeibcbcbcbaeibcbcbc\") == 26\n assert candidate(s = \"aeeeeiiiooouuuuuuuuu\") == 10\n assert candidate(s = \"bcbcbcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"abacaxebecixodeoxouabacaxebecixodeoxou\") == 38\n assert candidate(s = \"zzzaeizzzaeiouzzzaeiouzzz\") == 19\n assert candidate(s = \"aeiouabcdefghijklmnopqrstuvwxyzaeiou\") == 31\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 52\n assert candidate(s = \"uvceeaieeaaceeaiaa\") == 17\n assert candidate(s = \"aebecixodeoxouaebecixodeoxou\") == 28\n assert candidate(s = \"vvvvvvvvvvvvvvvvvv\") == 18\n assert candidate(s = \"aebecidofugoeiaoeiu\") == 4\n assert candidate(s = \"aeiouaeiouabcdeffedcbaaeiouaeiou\") == 32\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaeiouaeiouaeiou\") == 41\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(s = \"leetcodeisgreataeiou\") == 17\n assert candidate(s = \"aeiouaeiouaeiouxyzuvw\") == 17\n assert candidate(s = \"abcdeffedcbabcdeffedcbabcdeffedcbabcdeffedcb\") == 44\n assert candidate(s = \"xyzuvwaeiouxyzuvwaeiou\") == 22\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmaeiouaeiou\") == 31\n assert candidate(s = \"vwxyz\") == 5\n assert candidate(s = \"aabbccddeeffgg\") == 14\n assert candidate(s = \"eleetminicoworoepzzzzzzzzzz\") == 13\n assert candidate(s = \"abecidofug\") == 1\n assert candidate(s = \"eiouaieouaieoua\") == 10\n assert candidate(s = \"aeiaoeiuioeiuaeiaoeiuioeiuaeiaoeiuioeiaoeiu\") == 26\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 50\n assert candidate(s = \"eiouaeiouaeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"eleetminicoworoepaeiou\") == 13\n assert candidate(s = \"eeioouuuaeeioouuuaeeioouuuaeeioouuua\") == 36\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 50\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 24\n assert candidate(s = \"leetcodeisgreatleetcodeisgreatleetcodeisgreat\") == 35\n", "comparison": "exact"}, "public_tests": ["\"eleetminicoworoep\"", "\"leetcodeisgreat\"", "\"bcbcbc\""], "hints": ["Represent the counts (odd or even) of vowels with a bitmask.", "Precompute the prefix xor for the bitmask of vowels and then get the longest valid substring."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().findTheLongestSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:09+00:00", "tests_total": 77, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def findTheLongestSubstring(self, s: str) -> int:", "container": "Solution", "callable": "findTheLongestSubstring", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1374, "task_id": "generate-a-string-with-characters-that-have-odd-counts", "difficulty": "Easy", "problem_description": "Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.\n\nThe returned string must contain only lowercase English letters. If there are multiples valid strings, return any of them.\n\nExample 1:\n\nInput: n = 4\nOutput: \"pppz\"\nExplanation: \"pppz\" is a valid string since the character 'p' occurs three times and the character 'z' occurs once. Note that there are many other valid strings such as \"ohhh\" and \"love\".\n\nExample 2:\n\nInput: n = 2\nOutput: \"xy\"\nExplanation: \"xy\" is a valid string since the characters 'x' and 'y' occur once. Note that there are many other valid strings such as \"ag\" and \"ur\".\n\nExample 3:\n\nInput: n = 7\nOutput: \"holasss\"\n\nConstraints:\n\n- 1 <= n <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 250) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 3) == \"aaa\"\n assert candidate(n = 100) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 4) == \"aaab\"\n assert candidate(n = 2) == \"ab\"\n assert candidate(n = 1) == \"a\"\n assert candidate(n = 500) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 7) == \"aaaaaaa\"\n assert candidate(n = 10) == \"aaaaaaaaab\"\n assert candidate(n = 97) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 267) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 279) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 49) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 125) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 47) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 21) == \"aaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 50) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 5) == \"aaaaa\"\n assert candidate(n = 300) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 222) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 333) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 123) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 87) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 450) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 99) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 37) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 64) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 257) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 23) == \"aaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 167) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 42) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 51) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 175) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 251) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 101) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 495) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 299) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 255) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 375) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 27) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 75) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 249) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 150) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 11) == \"aaaaaaaaaaa\"\n assert candidate(n = 497) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 498) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 399) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 400) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 41) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 275) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 9) == \"aaaaaaaaa\"\n assert candidate(n = 301) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 31) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 200) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 83) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 499) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 199) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 13) == \"aaaaaaaaaaaaa\"\n", "comparison": "exact"}, "public_tests": ["4", "2", "7"], "hints": ["If n is odd, return a string of size n formed only by 'a', else return string formed with n-1 'a' and 1 'b''."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().generateTheString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:15+00:00", "tests_total": 58, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def generateTheString(self, n: int) -> str:", "container": "Solution", "callable": "generateTheString", "parameters": [{"name": "n", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1375, "task_id": "number-of-times-binary-string-is-prefix-aligned", "difficulty": "Medium", "problem_description": "You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array flips where flips[i] indicates that the bit at index flips[i] will be flipped in the i^th step.\n\nA binary string is prefix-aligned if, after the i^th step, all the bits in the inclusive range [1, i] are ones and all the other bits are zeros.\n\nReturn the number of times the binary string is prefix-aligned during the flipping process.\n\nExample 1:\n\nInput: flips = [3,2,4,1,5]\nOutput: 2\nExplanation: The binary string is initially \"00000\".\nAfter applying step 1: The string becomes \"00100\", which is not prefix-aligned.\nAfter applying step 2: The string becomes \"01100\", which is not prefix-aligned.\nAfter applying step 3: The string becomes \"01110\", which is not prefix-aligned.\nAfter applying step 4: The string becomes \"11110\", which is prefix-aligned.\nAfter applying step 5: The string becomes \"11111\", which is prefix-aligned.\nWe can see that the string was prefix-aligned 2 times, so we return 2.\n\nExample 2:\n\nInput: flips = [4,1,2,3]\nOutput: 1\nExplanation: The binary string is initially \"0000\".\nAfter applying step 1: The string becomes \"0001\", which is not prefix-aligned.\nAfter applying step 2: The string becomes \"1001\", which is not prefix-aligned.\nAfter applying step 3: The string becomes \"1101\", which is not prefix-aligned.\nAfter applying step 4: The string becomes \"1111\", which is prefix-aligned.\nWe can see that the string was prefix-aligned 1 time, so we return 1.\n\nConstraints:\n\n- n == flips.length\n- 1 <= n <= 5 * 10^4\n- flips is a permutation of the integers in the range [1, n].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(flips = [5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 5]) == 5\n assert candidate(flips = [2, 1, 3, 5, 4]) == 3\n assert candidate(flips = [3, 2, 4, 1, 5]) == 2\n assert candidate(flips = [4, 1, 2, 3]) == 1\n assert candidate(flips = [2, 1, 5, 3, 4]) == 2\n assert candidate(flips = [5, 1, 4, 3, 2, 7, 6, 9, 8, 10]) == 4\n assert candidate(flips = [2, 3, 1, 5, 4]) == 2\n assert candidate(flips = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == 6\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 3\n assert candidate(flips = [1, 4, 3, 2, 5, 8, 6, 7, 10, 9]) == 5\n assert candidate(flips = [3, 1, 4, 2, 5, 7, 6, 9, 8, 10]) == 5\n assert candidate(flips = [3, 1, 2, 6, 5, 4, 7, 8, 9, 10]) == 6\n assert candidate(flips = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10, 11]) == 6\n assert candidate(flips = [1, 3, 2, 5, 4, 6]) == 4\n assert candidate(flips = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 3\n assert candidate(flips = [2, 5, 6, 1, 4, 3, 8, 9, 7, 10]) == 3\n assert candidate(flips = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 6\n assert candidate(flips = [1, 3, 5, 7, 2, 4, 6, 8, 9, 10]) == 5\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 2\n assert candidate(flips = [6, 1, 3, 5, 2, 4]) == 1\n assert candidate(flips = [14, 12, 10, 8, 6, 4, 2, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(flips = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 5\n assert candidate(flips = [3, 1, 2, 5, 4, 7, 6, 9, 8, 10]) == 5\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(flips = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(flips = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n assert candidate(flips = [6, 3, 1, 4, 2, 5, 7, 8, 9, 10]) == 5\n assert candidate(flips = [2, 1, 5, 4, 3, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9]) == 6\n assert candidate(flips = [5, 2, 3, 4, 1, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]) == 2\n assert candidate(flips = [10, 1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 11]) == 1\n assert candidate(flips = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 5, 3, 4, 2, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == 5\n assert candidate(flips = [1, 3, 5, 2, 4, 6]) == 3\n assert candidate(flips = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 22\n assert candidate(flips = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 5, 4, 3, 6, 8, 7, 10, 9]) == 6\n assert candidate(flips = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [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(flips = [5, 3, 1, 2, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(flips = [2, 3, 1, 5, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == 9\n assert candidate(flips = [1, 2, 4, 3, 5, 7, 6, 8, 10, 9]) == 7\n assert candidate(flips = [5, 1, 4, 3, 2, 6]) == 2\n assert candidate(flips = [5, 2, 3, 1, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(flips = [10, 5, 8, 7, 9, 3, 1, 2, 4, 6]) == 1\n assert candidate(flips = [1, 3, 2, 5, 4, 6, 7]) == 5\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == 2\n assert candidate(flips = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10]) == 3\n assert candidate(flips = [1, 3, 2, 5, 4]) == 3\n assert candidate(flips = [1, 2, 5, 3, 6, 4, 7, 8, 10, 9]) == 6\n assert candidate(flips = [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(flips = [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]) == 3\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(flips = [7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 3, 5, 2, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(flips = [5, 1, 3, 2, 6, 4, 8, 7, 10, 9]) == 3\n assert candidate(flips = [10, 5, 8, 7, 3, 2, 9, 4, 6, 1]) == 1\n assert candidate(flips = [1, 3, 5, 2, 4]) == 2\n assert candidate(flips = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == 5\n assert candidate(flips = [1, 4, 2, 3, 7, 5, 6, 10, 8, 9]) == 4\n assert candidate(flips = [3, 1, 2, 5, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 3, 2, 4, 5, 7, 6, 8, 10, 9]) == 7\n assert candidate(flips = [6, 3, 1, 5, 2, 4, 10, 7, 9, 8]) == 2\n assert candidate(flips = [5, 1, 6, 2, 7, 3, 8, 4, 9, 10]) == 3\n assert candidate(flips = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 6, 5, 7, 8, 9, 10]) == 9\n assert candidate(flips = [2, 1, 5, 4, 3, 8, 6, 7, 10, 9]) == 4\n assert candidate(flips = [2, 1, 4, 3, 6, 5, 7]) == 4\n assert candidate(flips = [5, 2, 1, 3, 4, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [1, 2, 10, 5, 4, 9, 6, 7, 3, 8]) == 3\n assert candidate(flips = [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]) == 1\n assert candidate(flips = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(flips = [2, 3, 1, 5, 6, 4, 8, 7, 10, 9]) == 4\n assert candidate(flips = [7, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(flips = [1, 5, 3, 4, 2, 6, 7, 8, 10, 9]) == 6\n assert candidate(flips = [2, 1, 3, 5, 4, 6, 7, 8]) == 6\n assert candidate(flips = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(flips = [1, 2, 5, 4, 3, 6, 7, 8, 9, 10]) == 8\n assert candidate(flips = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 26\n assert candidate(flips = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(flips = [10, 5, 1, 6, 2, 7, 3, 8, 4, 9]) == 1\n assert candidate(flips = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 6\n", "comparison": "exact"}, "public_tests": ["[3,2,4,1,5]", "[4,1,2,3]"], "hints": ["If in the step x all bulb shines then bulbs 1,2,3,..,x should shines too."], "metadata": {"canonical_parameter_names": ["flips"], "leetcode_dataset_entry_point": "Solution().numTimesAllBlue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:18+00:00", "tests_total": 91, "tests_dropped": 0, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def numTimesAllBlue(self, flips: list[int]) -> int:", "container": "Solution", "callable": "numTimesAllBlue", "parameters": [{"name": "flips", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1376, "task_id": "time-needed-to-inform-all-employees", "difficulty": "Medium", "problem_description": "A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.\n\nEach employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination relationships have a tree structure.\n\nThe head of the company wants to inform all the company employees of an urgent piece of news. He will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news.\n\nThe i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e., After informTime[i] minutes, all his direct subordinates can start spreading the news).\n\nReturn the number of minutes needed to inform all the employees about the urgent news.\n\nExample 1:\n\nInput: n = 1, headID = 0, manager = [-1], informTime = [0]\nOutput: 0\nExplanation: The head of the company is the only employee in the company.\n\nExample 2:\n\nInput: n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0]\nOutput: 1\nExplanation: The head of the company with id = 2 is the direct manager of all the employees in the company and needs 1 minute to inform them all.\nThe tree structure of the employees in the company is shown.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- 0 <= headID < n\n- manager.length == n\n- 0 <= manager[i] < n\n- manager[headID] == -1\n- informTime.length == n\n- 0 <= informTime[i] <= 1000\n- informTime[i] == 0 if employee i has no subordinates.\n- It is guaranteed that all the employees can be informed.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,headID = 2,manager = [2, 2, -1, 2, 2, 2],informTime = [0, 0, 1, 0, 0, 0]) == 1\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(n = 1,headID = 0,manager = [-1],informTime = [0]) == 0\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 954]) == 1116\n assert candidate(n = 7,headID = 6,manager = [1, 2, 3, 4, 5, 6, -1],informTime = [0, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 956]) == 1118\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 914]) == 1076\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 33, 12, 45, 78, 12, 34, 56, 23]) == 112\n assert candidate(n = 12,headID = 5,manager = [2, 2, 3, 4, 5, -1, 3, 5, 3, 5, 5, 4],informTime = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(n = 20,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],informTime = [0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9]) == 4\n assert candidate(n = 20,headID = 19,manager = [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1],informTime = [0, 6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0]) == 0\n assert candidate(n = 15,headID = 7,manager = [6, 6, 6, 7, 7, 7, 7, -1, 8, 8, 8, 9, 9, 10, 10],informTime = [1, 1, 1, 2, 2, 2, 3, 0, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(n = 18,headID = 9,manager = [9, 9, 9, 9, 9, 9, 9, 9, 9, -1, 10, 10, 11, 11, 12, 12, 13, 13],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 2, 2, 1, 1, 3, 3, 4, 4, 5]) == 3\n assert candidate(n = 15,headID = 5,manager = [5, 5, 5, 5, 5, -1, 6, 6, 7, 7, 8, 8, 9, 9, 10],informTime = [0, 12, 34, 56, 78, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 90\n assert candidate(n = 15,headID = 7,manager = [7, 7, 7, 7, 7, 7, 7, -1, 8, 8, 9, 9, 10, 10, 11],informTime = [0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0]) == 23\n assert candidate(n = 15,headID = 7,manager = [10, 9, 9, 9, 10, 10, 7, -1, 6, 6, 6, 4, 4, 3, 3],informTime = [0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 0, 1, 1, 2, 2]) == 6\n assert candidate(n = 17,headID = 10,manager = [10, 10, 10, 11, 11, 12, 12, 13, 13, 14, -1, 15, 15, 16, 16, 16, 16],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 50, 50, 20, 20, 10, 10]) == 100\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 34, 23, 56, 45, 12, 89, 34, 12]) == 123\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 13, 10, 15, 20, 8, 5, 7, 12]) == 82\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 2, 1, 1, 3, 1, 1, 0, 0, 0]) == 5\n assert candidate(n = 20,headID = 0,manager = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],informTime = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 160\n assert candidate(n = 25,headID = 24,manager = [19, 19, 19, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 0]) == 55\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 34, 0, 0, 0, 0, 0, 0, 0]) == 67\n assert candidate(n = 12,headID = 3,manager = [3, 3, 3, -1, 4, 4, 5, 5, 6, 6, 7, 7],informTime = [0, 0, 0, 100, 50, 50, 25, 25, 10, 10, 5, 5]) == 100\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],informTime = [0, 6, 5, 4, 3, 2, 1, 7, 8, 9]) == 6\n assert candidate(n = 15,headID = 7,manager = [10, 9, 9, 10, 8, 8, 7, -1, 10, 10, 10, 11, 11, 12, 12],informTime = [0, 6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(n = 15,headID = 14,manager = [10, 9, 12, 5, 5, 14, 6, 6, 8, 9, 9, 12, 12, 13, -1],informTime = [0, 23, 34, 0, 0, 18, 19, 12, 21, 13, 18, 28, 35, 0, 0]) == 18\n assert candidate(n = 20,headID = 15,manager = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -1, 16, 16, 16, 16],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2]) == 0\n assert candidate(n = 20,headID = 19,manager = [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, -1],informTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 0\n assert candidate(n = 9,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2],informTime = [0, 30, 40, 50, 60, 70, 80, 90, 100]) == 40\n assert candidate(n = 18,headID = 4,manager = [4, 4, 4, 4, -1, 12, 13, 12, 13, 12, 13, 4, 14, 14, 4, 15, 16, 15],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 18, 0, 0, 0]) == 18\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 13,headID = 0,manager = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],informTime = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 88\n", "comparison": "exact"}, "public_tests": ["1\n0\n[-1]\n[0]", "6\n2\n[2,2,-1,2,2,2]\n[0,0,1,0,0,0]"], "hints": ["The company can be represented as a tree, headID is always the root.", "Store for each node the time needed to be informed of the news.", "Answer is the max time a leaf node needs to be informed."], "metadata": {"canonical_parameter_names": ["n", "headID", "manager", "informTime"], "leetcode_dataset_entry_point": "Solution().numOfMinutes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:20+00:00", "tests_total": 43, "tests_dropped": 9, "flags": ["has_images"], "topic_tags": ["tree", "depth-first-search", "breadth-first-search"]}, "language": "python", "interface": {"raw_signature": "def numOfMinutes(self, n: int, headID: int, manager: list[int], informTime: list[int]) -> int:", "container": "Solution", "callable": "numOfMinutes", "parameters": [{"name": "n", "type": "int"}, {"name": "headID", "type": "int"}, {"name": "manager", "type": "list[int]"}, {"name": "informTime", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1377, "task_id": "frog-position-after-t-seconds", "difficulty": "Hard", "problem_description": "Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices, it jumps randomly to one of them with the same probability. Otherwise, when the frog can not jump to any unvisited vertex, it jumps forever on the same vertex.\n\nThe edges of the undirected tree are given in the array edges, where edges[i] = [a_i, b_i] means that exists an edge connecting the vertices a_i and b_i.\n\nReturn the probability that after t seconds the frog is on the vertex target. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4\nOutput: 0.16666666666666666\nExplanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666.\n\nExample 2:\n\nInput: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7\nOutput: 0.3333333333333333\nExplanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1.\n\nConstraints:\n\n- 1 <= n <= 100\n- edges.length == n - 1\n- edges[i].length == 2\n- 1 <= a_i, b_i <= n\n- 1 <= t <= 50\n- 1 <= target <= n\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=10, edges=[[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]], t=4, target=10), 0.16666666666666666)\n assert answers_match(candidate(n=6, edges=[[1, 2], [1, 3], [2, 4], [2, 5], [3, 6]], t=2, target=5), 0.25)\n assert answers_match(candidate(n=4, edges=[[1, 2], [1, 3], [2, 4]], t=2, target=4), 0.5)\n assert answers_match(candidate(n=7, edges=[[1, 2], [1, 3], [1, 7], [2, 4], [2, 6], [3, 5]], t=2, target=4), 0.16666666666666666)\n assert answers_match(candidate(n=7, edges=[[1, 2], [1, 3], [1, 7], [2, 4], [2, 6], [3, 5]], t=1, target=7), 0.3333333333333333)\n assert answers_match(candidate(n=1, edges=[], t=10, target=1), 1.0)\n assert answers_match(candidate(n=5, edges=[[1, 2], [1, 3], [1, 4], [2, 5]], t=3, target=5), 0.3333333333333333)\n assert answers_match(candidate(n=5, edges=[[1, 2], [1, 3], [1, 4], [1, 5]], t=1, target=3), 0.25)\n assert answers_match(candidate(n=5, edges=[[1, 2], [1, 3], [2, 4], [2, 5]], t=2, target=4), 0.25)\n assert answers_match(candidate(n=3, edges=[[1, 2], [1, 3]], t=2, target=1), 0)\n assert answers_match(candidate(n=10, edges=[[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10]], t=4, target=6), 0.125)\n assert answers_match(candidate(n=5, edges=[[1, 2], [1, 3], [1, 4], [1, 5]], t=2, target=3), 0.25)\n assert answers_match(candidate(n=1, edges=[], t=1, target=1), 1.0)\n assert answers_match(candidate(n=4, edges=[[1, 2], [1, 3], [2, 4]], t=3, target=2), 0)\n assert answers_match(candidate(n=3, edges=[[1, 2], [1, 3]], t=1, target=2), 0.5)\n assert answers_match(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]], t=5, target=15), 0.125)\n assert answers_match(candidate(n=30, edges=[[1, 2], [1, 3], [2, 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], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30]], t=5, target=29), 0.041666666666666664)\n assert answers_match(candidate(n=14, 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]], t=5, target=14), 0.08333333333333333)\n assert answers_match(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]], t=7, target=40), 0.03125)\n assert answers_match(candidate(n=9, edges=[[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]], t=3, target=9), 0.3333333333333333)\n assert answers_match(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], [9, 17], [9, 18]], t=4, target=16), 0.125)\n assert answers_match(candidate(n=30, 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], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25], [9, 26], [9, 27], [10, 28], [10, 29], [10, 30]], t=6, target=16), 0.037037037037037035)\n assert answers_match(candidate(n=12, edges=[[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]], t=3, target=12), 0.08333333333333333)\n assert answers_match(candidate(n=28, 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]], t=6, target=24), 0.0625)\n assert answers_match(candidate(n=35, 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]], t=15, target=34), 0.03125)\n assert answers_match(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]], t=5, target=15), 0.125)\n assert answers_match(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]], t=6, target=22), 0.0625)\n assert answers_match(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]], t=4, target=24), 0.0625)\n assert answers_match(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]], t=5, target=11), 0.08333333333333333)\n assert answers_match(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]], t=10, target=30), 0.125)\n assert answers_match(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]], t=3, target=11), 0.16666666666666666)\n assert answers_match(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], [9, 17], [10, 18]], t=4, target=13), 0.125)\n assert answers_match(candidate(n=25, 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], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25]], t=5, target=22), 0.037037037037037035)\n assert answers_match(candidate(n=12, edges=[[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12]], t=4, target=10), 0.05555555555555555)\n assert answers_match(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]], t=5, target=16), 0.0625)\n assert answers_match(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]], t=7, target=24), 0.0625)\n assert answers_match(candidate(n=40, edges=[[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], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [10, 27], [11, 28], [11, 29], [11, 30], [12, 31], [12, 32], [12, 33], [13, 34], [13, 35], [14, 36], [14, 37], [14, 38], [15, 39], [15, 40]], t=6, target=39), 0.027777777777777776)\n assert answers_match(candidate(n=35, 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]], t=9, target=32), 0.03125)\n assert answers_match(candidate(n=35, 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], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25], [9, 26], [9, 27], [10, 28], [10, 29], [10, 30], [11, 31], [11, 32], [11, 33], [12, 34], [12, 35]], t=7, target=25), 0.037037037037037035)\n assert answers_match(candidate(n=22, 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]], t=5, target=18), 0.0625)\n assert answers_match(candidate(n=15, edges=[[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [8, 15]], t=3, target=10), 0.08333333333333333)\n assert answers_match(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]], t=3, target=12), 0.25)\n assert answers_match(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]], t=7, target=16), 0.0625)\n assert answers_match(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]], t=5, target=17), 0.08333333333333333)\n assert answers_match(candidate(n=20, edges=[[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]], t=5, target=13), 0.08333333333333333)\n assert answers_match(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]], t=3, target=11), 0.08333333333333333)\n assert answers_match(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]], t=6, target=16), 0.08333333333333333)\n assert answers_match(candidate(n=20, edges=[[1, 2], [1, 3], [2, 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]], t=4, target=15), 0.125)\n assert answers_match(candidate(n=18, 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], [10, 16], [11, 17], [12, 18]], t=3, target=18), 0)\n assert answers_match(candidate(n=30, 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], [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]], t=5, target=23), 0.037037037037037035)\n assert answers_match(candidate(n=13, 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]], t=5, target=13), 0.16666666666666666)\n assert answers_match(candidate(n=18, 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]], t=4, target=18), 0.08333333333333333)\n assert answers_match(candidate(n=30, 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], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]], t=8, target=27), 0.041666666666666664)\n assert answers_match(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]], t=7, target=28), 0.0625)\n assert answers_match(candidate(n=16, 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]], t=6, target=16), 0.08333333333333333)\n assert answers_match(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]], t=7, target=25), 0.0625)\n assert answers_match(candidate(n=25, 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], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [9, 22], [9, 23], [10, 24], [10, 25]], t=5, target=20), 0.05555555555555555)\n assert answers_match(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]], t=3, target=12), 0.125)\n assert answers_match(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], [9, 20]], t=6, target=15), 0.08333333333333333)\n assert answers_match(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]], t=4, target=15), 0.08333333333333333)\n assert answers_match(candidate(n=11, edges=[[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]], t=4, target=11), 0.16666666666666666)\n assert answers_match(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]], t=5, target=29), 0.0625)\n assert answers_match(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]], t=4, target=9), 0.125)\n assert answers_match(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]], t=6, target=20), 0.125)\n", "comparison": "float"}, "public_tests": ["7\n[[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]]\n2\n4", "7\n[[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]]\n1\n7"], "hints": ["Use a variation of DFS with parameters 'curent_vertex' and 'current_time'.", "Update the probability considering to jump to one of the children vertices."], "metadata": {"canonical_parameter_names": ["n", "edges", "t", "target"], "leetcode_dataset_entry_point": "Solution().frogPosition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:23+00:00", "tests_total": 64, "tests_dropped": 0, "flags": ["figure_reference", "decimal_answer", "has_images"], "topic_tags": ["tree", "depth-first-search", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def frogPosition(self, n: int, edges: list[list[int]], t: int, target: int) -> float:", "container": "Solution", "callable": "frogPosition", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "t", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1380, "task_id": "lucky-numbers-in-a-matrix", "difficulty": "Easy", "problem_description": "Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.\n\nA lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.\n\nExample 1:\n\nInput: matrix = [[3,7,8],[9,11,13],[15,16,17]]\nOutput: [15]\nExplanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nExample 2:\n\nInput: matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]]\nOutput: [12]\nExplanation: 12 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nExample 3:\n\nInput: matrix = [[7,8],[1,2]]\nOutput: [7]\nExplanation: 7 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= n, m <= 50\n- 1 <= matrix[i][j] <= 10^5.\n- All elements in the matrix are distinct.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(matrix=[[5, 9, 11], [9, 4, 8], [3, 15, 17]]), [])\n assert answers_match(candidate(matrix=[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]), [13])\n assert answers_match(candidate(matrix=[[33, 18, 46, 39], [68, 35, 41, 26], [55, 87, 52, 37], [17, 47, 99, 22]]), [])\n assert answers_match(candidate(matrix=[[3, 7, 8], [9, 11, 13], [15, 16, 17]]), [15])\n assert answers_match(candidate(matrix=[[5, 1, 4], [1, 5, 7], [8, 3, 2]]), [])\n assert answers_match(candidate(matrix=[[3, 6], [7, 1], [5, 9]]), [])\n assert answers_match(candidate(matrix=[[40, 10], [24, 30]]), [])\n assert answers_match(candidate(matrix=[[5, 9, 11], [9, 2, 8], [1, 6, 3]]), [])\n assert answers_match(candidate(matrix=[[1, 10, 4, 2], [9, 3, 8, 7], [15, 16, 17, 12]]), [12])\n assert answers_match(candidate(matrix=[[1]]), [1])\n assert answers_match(candidate(matrix=[[7, 8], [1, 2]]), [7])\n assert answers_match(candidate(matrix=[[36376, 85652], [55712, 5396]]), [])\n assert answers_match(candidate(matrix=[[33, 18, 46], [19, 66, 58], [54, 88, 92]]), [54])\n assert answers_match(candidate(matrix=[[100000, 99999, 99998, 99997], [99996, 99995, 99994, 99993], [99992, 99991, 99990, 99989]]), [99997])\n assert answers_match(candidate(matrix=[[23, 45, 12, 78, 56], [89, 34, 23, 10, 32], [67, 88, 90, 11, 54], [12, 34, 56, 78, 90], [100, 200, 300, 400, 500]]), [100])\n assert answers_match(candidate(matrix=[[100000, 90000, 80000], [70000, 60000, 50000], [40000, 30000, 20000]]), [80000])\n assert answers_match(candidate(matrix=[[1, 3, 5, 7, 9], [10, 12, 14, 16, 18], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28], [21, 23, 25, 27, 29]]), [21])\n assert answers_match(candidate(matrix=[[55, 54, 53, 52, 51], [45, 44, 43, 42, 41], [35, 34, 33, 32, 31], [25, 24, 23, 22, 21], [15, 14, 13, 12, 11]]), [51])\n assert answers_match(candidate(matrix=[[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]]), [46])\n assert answers_match(candidate(matrix=[[100000, 99999, 99998], [1, 2, 3], [99997, 99996, 99995]]), [99998])\n assert answers_match(candidate(matrix=[[12345, 67890, 23456, 34567], [78901, 89012, 90123, 12346], [65432, 54321, 43210, 32109]]), [])\n assert answers_match(candidate(matrix=[[3, 6, 9, 12, 15], [2, 5, 8, 11, 14], [1, 4, 7, 10, 13]]), [3])\n assert answers_match(candidate(matrix=[[34, 56, 12, 90], [78, 89, 45, 67], [23, 34, 56, 78], [90, 12, 34, 56]]), [])\n assert answers_match(candidate(matrix=[[42, 58, 76], [89, 21, 34], [95, 67, 12], [56, 45, 83]]), [])\n assert answers_match(candidate(matrix=[[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]]), [])\n assert answers_match(candidate(matrix=[[47, 2, 37, 58, 59], [1, 53, 34, 24, 60], [4, 22, 50, 18, 61], [11, 49, 16, 57, 35], [54, 3, 14, 13, 55]]), [])\n assert answers_match(candidate(matrix=[[50000, 40000, 30000, 20000, 10000], [40001, 30001, 20001, 10001, 50001], [30002, 20002, 10002, 50002, 40002], [20003, 10003, 50003, 40003, 30003], [10004, 50004, 40004, 30004, 20004]]), [])\n assert answers_match(candidate(matrix=[[25, 15, 35, 20], [10, 5, 45, 40], [30, 2, 60, 50], [65, 55, 5, 3]]), [])\n assert answers_match(candidate(matrix=[[50000, 40000, 30000, 20000, 10000], [90000, 80000, 70000, 60000, 50000], [1, 2, 3, 4, 5]]), [50000])\n assert answers_match(candidate(matrix=[[100000, 99999, 99998], [1, 2, 3], [99997, 99996, 99995]]), [99998])\n assert answers_match(candidate(matrix=[[100000, 1, 100, 10], [1000, 99999, 2, 50], [99998, 500, 3, 1000], [50, 10000, 100000, 4]]), [])\n assert answers_match(candidate(matrix=[[50000, 50001, 50002, 50003, 50004], [49999, 49998, 49997, 49996, 49995], [49994, 49993, 49992, 49991, 49990]]), [50000])\n assert answers_match(candidate(matrix=[[99999, 1, 2, 3, 4, 5], [5, 99998, 6, 7, 8, 9], [9, 10, 99997, 12, 13, 14], [14, 15, 16, 99996, 18, 19], [19, 20, 21, 22, 99995, 24]]), [])\n assert answers_match(candidate(matrix=[[42, 41, 44, 43], [38, 39, 36, 37], [46, 45, 48, 47], [50, 49, 52, 51]]), [49])\n assert answers_match(candidate(matrix=[[50000, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23], [24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35], [36, 37, 38, 39], [40, 41, 42, 43], [44, 45, 46, 47], [48, 49, 50, 51]]), [])\n assert answers_match(candidate(matrix=[[34, 77, 56, 23], [89, 10, 45, 67], [55, 88, 22, 33], [44, 66, 77, 88]]), [])\n assert answers_match(candidate(matrix=[[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 23, 25, 27, 29]]), [21])\n assert answers_match(candidate(matrix=[[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986], [99985, 99984, 99983, 99982, 99981]]), [99996])\n assert answers_match(candidate(matrix=[[10, 20, 30, 40], [9, 8, 7, 6], [5, 4, 3, 2], [1, 18, 19, 20]]), [10])\n assert answers_match(candidate(matrix=[[50000, 1, 50001, 50002], [50003, 50004, 50005, 50006], [50007, 50008, 2, 50009], [50010, 50011, 50012, 50013]]), [50010])\n assert answers_match(candidate(matrix=[[33, 44, 55, 66, 77, 88, 99], [22, 34, 45, 56, 67, 78, 89], [11, 23, 35, 46, 57, 68, 79], [10, 21, 32, 43, 54, 65, 76], [9, 20, 31, 42, 53, 64, 75], [8, 19, 30, 41, 52, 63, 74], [7, 18, 29, 40, 51, 62, 73]]), [33])\n assert answers_match(candidate(matrix=[[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]), [16])\n assert answers_match(candidate(matrix=[[8, 16, 9, 12, 15], [10, 5, 14, 6, 13], [18, 17, 11, 7, 4], [19, 20, 3, 1, 2]]), [])\n assert answers_match(candidate(matrix=[[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [5, 1, 55, 59, 60], [2, 3, 6, 7, 8], [61, 62, 63, 64, 65]]), [61])\n assert answers_match(candidate(matrix=[[50000, 49999, 1], [49998, 49997, 2], [49996, 49995, 3]]), [3])\n assert answers_match(candidate(matrix=[[3, 6, 8, 14, 5], [20, 10, 16, 19, 17], [7, 1, 15, 4, 13], [18, 9, 21, 12, 11]]), [10])\n assert answers_match(candidate(matrix=[[40, 20, 60, 70], [30, 10, 50, 80], [25, 5, 35, 90], [15, 2, 45, 100]]), [20])\n assert answers_match(candidate(matrix=[[8, 5, 9, 10, 7], [6, 1, 3, 4, 2], [11, 12, 14, 15, 13], [16, 17, 19, 20, 18], [21, 22, 24, 25, 23]]), [21])\n assert answers_match(candidate(matrix=[[10, 15, 20, 25], [5, 30, 35, 40], [45, 41, 42, 43], [50, 55, 60, 65]]), [50])\n assert answers_match(candidate(matrix=[[85, 21, 17, 45], [62, 59, 100, 58], [90, 28, 29, 83]]), [])\n assert answers_match(candidate(matrix=[[34, 67, 89, 12], [12, 98, 23, 45], [56, 33, 78, 88], [87, 66, 55, 44]]), [])\n assert answers_match(candidate(matrix=[[100, 200, 300, 400], [150, 250, 350, 450], [50, 150, 250, 350], [200, 300, 400, 500]]), [200])\n assert answers_match(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]]), [96])\n assert answers_match(candidate(matrix=[[10000, 10001, 10002], [9999, 10000, 10003], [9998, 9997, 10000]]), [10000])\n assert answers_match(candidate(matrix=[[98, 99, 100], [95, 96, 97], [92, 93, 94], [89, 90, 91]]), [98])\n assert answers_match(candidate(matrix=[[5, 3, 9, 1], [8, 4, 2, 7], [6, 10, 12, 11]]), [])\n assert answers_match(candidate(matrix=[[55, 56, 57], [54, 53, 58], [51, 52, 59]]), [55])\n assert answers_match(candidate(matrix=[[101, 102, 103, 104], [105, 106, 107, 108], [109, 110, 111, 112], [113, 114, 115, 116], [117, 118, 119, 120]]), [117])\n assert answers_match(candidate(matrix=[[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [1, 5, 4, 3, 2], [3, 4, 5, 1, 2]]), [])\n assert answers_match(candidate(matrix=[[9, 8, 7, 6], [5, 4, 3, 2], [1, 10, 11, 12], [13, 14, 15, 16]]), [13])\n assert answers_match(candidate(matrix=[[10, 50, 30, 40], [60, 20, 90, 80], [70, 100, 110, 120], [130, 140, 150, 160]]), [130])\n assert answers_match(candidate(matrix=[[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [1, 101, 201, 301, 401], [9, 109, 209, 309, 409], [8, 108, 208, 308, 408]]), [])\n assert answers_match(candidate(matrix=[[55, 65, 75, 85, 95], [15, 25, 35, 45, 5], [60, 70, 80, 90, 100], [1, 2, 3, 4, 6]]), [60])\n assert answers_match(candidate(matrix=[[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10]]), [10])\n assert answers_match(candidate(matrix=[[23, 24, 25, 26, 27], [18, 19, 20, 21, 22], [13, 14, 15, 16, 17], [8, 9, 10, 11, 12], [3, 4, 5, 6, 7], [1, 2, 3, 4, 5]]), [23])\n assert answers_match(candidate(matrix=[[5, 12, 45, 32], [99, 3, 87, 67], [15, 16, 17, 18], [20, 21, 22, 23]]), [])\n assert answers_match(candidate(matrix=[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]), [31])\n assert answers_match(candidate(matrix=[[22, 34, 40, 54], [2, 3, 7, 65], [99, 23, 35, 22]]), [])\n assert answers_match(candidate(matrix=[[1, 99999, 2, 99998, 3, 99997], [99996, 4, 99995, 5, 99994, 6], [7, 99993, 8, 99992, 9, 99991]]), [])\n assert answers_match(candidate(matrix=[[500, 400, 300], [200, 100, 300], [150, 50, 400], [450, 350, 250]]), [])\n assert answers_match(candidate(matrix=[[99999, 10000, 10001], [99998, 99997, 10002], [1, 99996, 99995]]), [])\n assert answers_match(candidate(matrix=[[10, 20, 30, 40], [50, 60, 70, 80], [1, 2, 3, 4], [5, 6, 7, 9]]), [50])\n assert answers_match(candidate(matrix=[[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]]), [21])\n assert answers_match(candidate(matrix=[[2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]), [])\n assert answers_match(candidate(matrix=[[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [9, 19, 29, 39, 49], [8, 18, 28, 38, 48]]), [10])\n assert answers_match(candidate(matrix=[[100, 200, 300, 400, 500], [99, 199, 299, 399, 499], [98, 198, 298, 398, 498], [97, 197, 297, 397, 497], [96, 196, 296, 396, 496]]), [100])\n assert answers_match(candidate(matrix=[[34, 73, 89, 52], [12, 76, 87, 42], [61, 94, 66, 21], [71, 54, 62, 78]]), [])\n assert answers_match(candidate(matrix=[[100000, 99999, 99998], [99997, 99996, 99995], [99994, 99993, 99992]]), [99998])\n assert answers_match(candidate(matrix=[[999, 888, 777], [666, 555, 444], [333, 222, 111], [99, 88, 77]]), [777])\n assert answers_match(candidate(matrix=[[100, 200, 300], [250, 150, 100], [100, 300, 200], [50, 400, 250]]), [])\n assert answers_match(candidate(matrix=[[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]]), [31])\n assert answers_match(candidate(matrix=[[2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [12, 10, 8, 6, 4, 2], [13, 15, 17, 19, 21, 23]]), [13])\n", "comparison": "unordered"}, "public_tests": ["[[3,7,8],[9,11,13],[15,16,17]]", "[[1,10,4,2],[9,3,8,7],[15,16,17,12]]", "[[7,8],[1,2]]"], "hints": ["Find out and save the minimum of each row and maximum of each column in two lists.", "Then scan through the whole matrix to identify the elements that satisfy the criteria."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().luckyNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:27+00:00", "tests_total": 87, "tests_dropped": 5, "flags": ["any_order"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def luckyNumbers(self, matrix: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "luckyNumbers", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1383, "task_id": "maximum-performance-of-a-team", "difficulty": "Hard", "problem_description": "You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the i^th engineer respectively.\n\nChoose at most k different engineers out of the n engineers to form a team with the maximum performance.\n\nThe performance of a team is the sum of its engineers' speeds multiplied by the minimum efficiency among its engineers.\n\nReturn the maximum performance of this team. Since the answer can be a huge number, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2\nOutput: 60\nExplanation:\nWe have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.\n\nExample 2:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3\nOutput: 68\nExplanation:\nThis is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.\n\nExample 3:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4\nOutput: 72\n\nConstraints:\n\n- 1 <= k <= n <= 10^5\n- speed.length == n\n- efficiency.length == n\n- 1 <= speed[i] <= 10^5\n- 1 <= efficiency[i] <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 2) == 60\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 3) == 68\n assert candidate(n = 5,speed = [4, 1, 12, 7, 8],efficiency = [2, 10, 8, 19, 4],k = 3) == 160\n assert candidate(n = 1,speed = [1],efficiency = [1],k = 1) == 1\n assert candidate(n = 10,speed = [9, 7, 6, 5, 4, 3, 2, 1, 10, 8],efficiency = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 40\n assert candidate(n = 3,speed = [2, 8, 2],efficiency = [2, 7, 1],k = 2) == 56\n assert candidate(n = 10,speed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 180\n assert candidate(n = 5,speed = [3, 5, 9, 7, 6],efficiency = [5, 3, 8, 6, 2],k = 4) == 96\n assert candidate(n = 5,speed = [5, 4, 3, 2, 1],efficiency = [1, 2, 3, 4, 5],k = 3) == 18\n assert candidate(n = 5,speed = [10, 20, 30, 40, 50],efficiency = [50, 40, 30, 20, 10],k = 3) == 1800\n assert candidate(n = 3,speed = [1, 2, 3],efficiency = [3, 2, 1],k = 2) == 6\n assert candidate(n = 10,speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 100\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 4) == 72\n assert candidate(n = 5,speed = [1, 1, 1, 1, 1],efficiency = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(n = 10,speed = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],efficiency = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 996499717\n assert candidate(n = 10,speed = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],efficiency = [50, 40, 30, 20, 10, 90, 80, 70, 60, 50],k = 3) == 13650\n assert candidate(n = 20,speed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],efficiency = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 10) == 2400\n assert candidate(n = 20,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10) == 980000000\n assert candidate(n = 5,speed = [10, 10, 10, 10, 10],efficiency = [10, 10, 10, 10, 10],k = 3) == 300\n assert candidate(n = 10,speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(n = 50,speed = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000, 41000, 42000, 43000, 44000, 45000, 46000, 47000, 48000, 49000, 50000],efficiency = [50000, 49000, 48000, 47000, 46000, 45000, 44000, 43000, 42000, 41000, 40000, 39000, 38000, 37000, 36000, 35000, 34000, 33000, 32000, 31000, 30000, 29000, 28000, 27000, 26000, 25000, 24000, 23000, 22000, 21000, 20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 25) == 499999937\n assert candidate(n = 8,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000],efficiency = [100, 150, 200, 250, 300, 350, 400, 450],k = 4) == 55000000\n assert candidate(n = 15,speed = [2, 4, 5, 7, 8, 10, 12, 15, 18, 20, 25, 30, 35, 40, 45],efficiency = [3, 5, 2, 8, 7, 4, 6, 9, 10, 11, 13, 12, 15, 14, 16],k = 6) == 2145\n assert candidate(n = 15,speed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],efficiency = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30],k = 8) == 15300\n assert candidate(n = 15,speed = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 2450\n assert candidate(n = 20,speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],efficiency = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 680\n assert candidate(n = 25,speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],efficiency = [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) == 1350\n assert candidate(n = 20,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],efficiency = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 68000\n assert candidate(n = 50,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000],efficiency = [5000, 4900, 4800, 4700, 4600, 4500, 4400, 4300, 4200, 4100, 4000, 3900, 3800, 3700, 3600, 3500, 3400, 3300, 3200, 3100, 3000, 2900, 2800, 2700, 2600, 2500, 2400, 2300, 2200, 2100, 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 25) == 95000000\n assert candidate(n = 12,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],efficiency = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12],k = 6) == 40000\n assert candidate(n = 10,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 5500\n assert candidate(n = 15,speed = [5, 3, 8, 2, 7, 6, 4, 9, 1, 11, 10, 12, 13, 14, 15],efficiency = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 290\n assert candidate(n = 10,speed = [1, 100000, 100, 1000, 10000, 10, 100000, 10000, 1000, 1],efficiency = [100000, 1, 10000, 100, 1000, 100000, 1000, 100, 10, 1],k = 5) == 110111000\n assert candidate(n = 20,speed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],efficiency = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 10) == 17000\n assert candidate(n = 15,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],efficiency = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 2940\n assert candidate(n = 20,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],efficiency = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 68000\n assert candidate(n = 75,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750],efficiency = [750, 740, 730, 720, 710, 700, 690, 680, 670, 660, 650, 640, 630, 620, 610, 600, 590, 580, 570, 560, 550, 540, 530, 520, 510, 500, 490, 480, 470, 460, 450, 440, 430, 420, 410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 50) == 3315000\n", "comparison": "exact"}, "public_tests": ["6\n[2,10,3,1,5,8]\n[5,4,3,9,7,2]\n2", "6\n[2,10,3,1,5,8]\n[5,4,3,9,7,2]\n3", "6\n[2,10,3,1,5,8]\n[5,4,3,9,7,2]\n4"], "hints": ["Keep track of the engineers by their efficiency in decreasing order.", "Starting from one engineer, to build a team, it suffices to bring K-1 more engineers who have higher efficiencies as well as high speeds."], "metadata": {"canonical_parameter_names": ["n", "speed", "efficiency", "k"], "leetcode_dataset_entry_point": "Solution().maxPerformance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:32+00:00", "tests_total": 41, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "greedy", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxPerformance(self, n: int, speed: list[int], efficiency: list[int], k: int) -> int:", "container": "Solution", "callable": "maxPerformance", "parameters": [{"name": "n", "type": "int"}, {"name": "speed", "type": "list[int]"}, {"name": "efficiency", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1385, "task_id": "find-the-distance-value-between-two-arrays", "difficulty": "Easy", "problem_description": "Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.\n\nThe distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.\n\nExample 1:\n\nInput: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2\nOutput: 2\nExplanation:\nFor arr1[0]=4 we have:\n|4-10|=6 > d=2\n|4-9|=5 > d=2\n|4-1|=3 > d=2\n|4-8|=4 > d=2\nFor arr1[1]=5 we have:\n|5-10|=5 > d=2\n|5-9|=4 > d=2\n|5-1|=4 > d=2\n|5-8|=3 > d=2\nFor arr1[2]=8 we have:\n|8-10|=2 <= d=2\n|8-9|=1 <= d=2\n|8-1|=7 > d=2\n|8-8|=0 <= d=2\n\nExample 2:\n\nInput: arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3\nOutput: 2\n\nExample 3:\n\nInput: arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6\nOutput: 1\n\nConstraints:\n\n- 1 <= arr1.length, arr2.length <= 500\n- -1000 <= arr1[i], arr2[j] <= 1000\n- 0 <= d <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [10, 20, 30],arr2 = [5, 15, 25],d = 4) == 3\n assert candidate(arr1 = [4, 5, 8],arr2 = [10, 9, 1, 8],d = 2) == 2\n assert candidate(arr1 = [1, 4, 2, 3],arr2 = [-4, -3, 6, 10, 20, 30],d = 3) == 2\n assert candidate(arr1 = [-1, -2, -3],arr2 = [1, 2, 3],d = 2) == 2\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4],d = 0) == 4\n assert candidate(arr1 = [1],arr2 = [1],d = 0) == 0\n assert candidate(arr1 = [2, 1, 100, 3],arr2 = [-5, -2, 10, -3, 7],d = 6) == 1\n assert candidate(arr1 = [1, 2, 3],arr2 = [4, 5, 6],d = 0) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 1) == 4\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],d = 49) == 0\n assert candidate(arr1 = [-1000, -900, -800, -700, -600],arr2 = [600, 700, 800, 900, 1000],d = 100) == 5\n assert candidate(arr1 = [-100, -200, -300],arr2 = [-50, -150, -250],d = 49) == 3\n assert candidate(arr1 = [500, 500, 500, 500, 500],arr2 = [500, 500, 500, 500, 500],d = 0) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [1, 2, 3, 4, 5],d = 5) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 10) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [0, 100, 200, 300, 400],arr2 = [50, 150, 250, 350, 450],d = 50) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 150, 250, 350, 450],d = 49) == 5\n assert candidate(arr1 = [0, 5, 10, 15, 20],arr2 = [3, 6, 9, 12, 18],d = 2) == 2\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [0, 100, 200, 300, 400, 500],d = 99) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 9) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 4) == 5\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 1) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, -1, 2, -2],d = 1) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 0) == 5\n assert candidate(arr1 = [-10, -20, -30],arr2 = [10, 20, 30],d = 19) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [90, 190, 290, 390, 490],d = 9) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 3, 5, 7, 9],d = 0) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 0) == 5\n assert candidate(arr1 = [5, 5, 5, 5, 5],arr2 = [1, 2, 3, 4, 6],d = 1) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [0, 2, 4, 6, 8],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],d = 3) == 3\n assert candidate(arr1 = [-10, -20, -30, -40],arr2 = [-11, -21, -31, -41],d = 0) == 4\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [5],d = 1) == 7\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 0) == 1\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5],d = 0) == 5\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2],d = 0) == 5\n assert candidate(arr1 = [2, 4, 6, 8, 10],arr2 = [1, 3, 5, 7, 9],d = 1) == 0\n assert candidate(arr1 = [1000, -1000, 500, -500],arr2 = [1000, -1000, 500, -500],d = 0) == 0\n assert candidate(arr1 = [5, 10, 15, 20, 25],arr2 = [3, 6, 9, 12, 18],d = 2) == 2\n assert candidate(arr1 = [5, 15, 25, 35, 45],arr2 = [0, 10, 20, 30, 40],d = 4) == 5\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [-100, -200, -300, -400, -500],d = 100) == 5\n assert candidate(arr1 = [100, 200, 300, 400],arr2 = [50, 150, 250, 350],d = 49) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 8) == 1\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [0, 0, 0, 0, 0],d = 1) == 4\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 5) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 0) == 5\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [150, 250, 350, 450],d = 49) == 5\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [0, 0, 0, 0, 0],d = 2) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 5) == 4\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4],d = 0) == 4\n assert candidate(arr1 = [-5, -10, -15, -20, -25],arr2 = [5, 10, 15, 20, 25],d = 4) == 5\n assert candidate(arr1 = [50, 51, 52, 53, 54, 55],arr2 = [50, 55],d = 0) == 4\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 5) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],d = 9) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [0, 2, 4, 6, 8],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 4) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 5) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 10) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 0) == 0\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [-1, -2, -3, -4, -5],d = 1) == 0\n assert candidate(arr1 = [100, 200, 300],arr2 = [95, 195, 295, 105, 205, 305],d = 5) == 0\n assert candidate(arr1 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],arr2 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],d = 2) == 0\n assert candidate(arr1 = [-100, -90, -80, -70, -60, -50],arr2 = [-95, -85, -75, -65, -55],d = 4) == 6\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],d = 9) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1],d = 1) == 0\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],d = 1) == 7\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5],d = 0) == 0\n assert candidate(arr1 = [0, 10, 20, 30, 40],arr2 = [5, 15, 25, 35, 45],d = 5) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 8) == 9\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],d = 0) == 10\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 9) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 6) == 0\n assert candidate(arr1 = [0, 100, 200],arr2 = [50, 150, 250],d = 49) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [-1, -2, -3, -4, -5],d = 1) == 5\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [1],d = 1) == 0\n assert candidate(arr1 = [-50, -40, -30, -20, -10],arr2 = [-45, -35, -25, -15, -5],d = 4) == 5\n assert candidate(arr1 = [-10, -20, -30, -40, -50],arr2 = [-5, -15, -25, -35, -45, -55],d = 9) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [0, 0, 0, 0],d = 0) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 150, 250, 350, 450, 550],d = 49) == 5\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [-95, -195, -295, -395, -495, -595],d = 5) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2],d = 1) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [0, 6, 7, 8, 9],d = 1) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [90, 190, 290, 390, 490],d = 5) == 5\n assert candidate(arr1 = [1, 10, 100, 1000],arr2 = [-1, -10, -100, -1000],d = 5) == 3\n assert candidate(arr1 = [100, 200, 300, 400],arr2 = [99, 199, 299, 399],d = 1) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [-100, -200, -300, -400],arr2 = [-50, -150, -250, -350],d = 49) == 4\n assert candidate(arr1 = [5, 15, 25, 35],arr2 = [10, 20, 30, 40],d = 5) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 1) == 4\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [1, 3, 5, 7, 9],d = 0) == 5\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 3, 4, 5, 6],d = 0) == 5\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16],d = 0) == 8\n assert candidate(arr1 = [-50, -40, -30, -20, -10],arr2 = [-60, -55, -45, -35, -25],d = 5) == 1\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [15, 25, 35, 45, 55],d = 4) == 5\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90],arr2 = [1, 11, 21, 31, 41, 51, 61, 71, 81],d = 9) == 0\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [-50, -150, -250, -350, -450],d = 49) == 5\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [550, 450, 350, 250, 150],d = 49) == 5\n assert candidate(arr1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],arr2 = [-5, 0, 5],d = 2) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 4) == 1\n assert candidate(arr1 = [-50, -25, 0, 25, 50],arr2 = [-30, -15, 15, 30],d = 14) == 3\n", "comparison": "exact"}, "public_tests": ["[4,5,8]\n[10,9,1,8]\n2", "[1,4,2,3]\n[-4,-3,6,10,20,30]\n3", "[2,1,100,3]\n[-5,-2,10,-3,7]\n6"], "hints": ["Sort 'arr2' and use binary search to get the closest element for each 'arr1[i]', it gives a time complexity of O(nlogn)."], "metadata": {"canonical_parameter_names": ["arr1", "arr2", "d"], "leetcode_dataset_entry_point": "Solution().findTheDistanceValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:34+00:00", "tests_total": 115, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def findTheDistanceValue(self, arr1: list[int], arr2: list[int], d: int) -> int:", "container": "Solution", "callable": "findTheDistanceValue", "parameters": [{"name": "arr1", "type": "list[int]"}, {"name": "arr2", "type": "list[int]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1386, "task_id": "cinema-seat-allocation", "difficulty": "Medium", "problem_description": "A cinema has n rows of seats, numbered from 1 to n. Each row has 10 seats, numbered from 1 to 10.\n\nYou are given a 2D integer array reservedSeats, where reservedSeats[i] = [row_i, seat_i] means that seat seat_i in row row_i is already reserved.\n\nA four-person group must be assigned to four seats in the same row. The group can be seated in one of the following seat blocks:\n\n- seats 2, 3, 4, 5\n- seats 4, 5, 6, 7\n- seats 6, 7, 8, 9\n\nA block can be used only if none of its seats are reserved. Each seat can be assigned to at most one group.\n\nReturn an integer denoting the maximum number of four-person groups that can be assigned.\n\nExample 1:\n\nInput: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]\nOutput: 4\nExplanation: The figure above shows an optimal allocation of four groups. Seats marked in blue are already reserved, and each set of four contiguous seats marked in orange is assigned to one group.\n\nExample 2:\n\nInput: n = 2, reservedSeats = [[2,1],[1,8],[2,6]]\nOutput: 2\n\nExample 3:\n\nInput: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]\nOutput: 4\n\nConstraints:\n\n- 1 <= n <= 10^9\n- 1 <= reservedSeats.length <= min(10 * n, 10^4)\n- reservedSeats[i] == [row_i, seat_i]\n- 1 <= row_i <= n\n- 1 <= seat_i <= 10\n- All reservedSeats[i] are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 8\n assert candidate(n = 4,reservedSeats = [[4, 3], [1, 4], [4, 6], [1, 7]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(n = 5,reservedSeats = [[5, 5], [5, 6], [5, 7], [5, 8]]) == 8\n assert candidate(n = 2,reservedSeats = [[2, 1], [1, 8], [2, 6]]) == 2\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 6\n assert candidate(n = 5,reservedSeats = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 10\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [5, 7], [5, 8]]) == 4\n assert candidate(n = 1000000000,reservedSeats = [[500000000, 5]]) == 1999999999\n assert candidate(n = 10,reservedSeats = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 15\n assert candidate(n = 1000000000,reservedSeats = [[1, 2], [1000000000, 9]]) == 1999999998\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [4, 9], [5, 2], [5, 3], [6, 4], [6, 5], [7, 6], [7, 7], [8, 4], [8, 5], [9, 8], [9, 9]]) == 11\n assert candidate(n = 1,reservedSeats = [[1, 5]]) == 1\n assert candidate(n = 5,reservedSeats = [[2, 4], [2, 5], [2, 6], [2, 7]]) == 8\n assert candidate(n = 5,reservedSeats = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 5\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 1], [3, 10], [4, 2], [4, 3], [5, 4], [5, 5], [6, 2], [6, 3], [7, 8], [7, 9], [8, 4], [8, 5], [9, 6], [9, 7]]) == 12\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 8], [2, 6], [3, 1], [3, 10]]) == 4\n assert candidate(n = 20,reservedSeats = [[5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [10, 2], [10, 3], [10, 8], [10, 9], [15, 4], [15, 5], [15, 6], [15, 7], [20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10]]) == 33\n assert candidate(n = 10,reservedSeats = [[3, 2], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7], [7, 7], [7, 8], [8, 8], [8, 9], [9, 9], [9, 10], [10, 10]]) == 12\n assert candidate(n = 30,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 2], [10, 3], [10, 4], [10, 5], [11, 6], [11, 7], [11, 8], [11, 9], [12, 2], [12, 3], [12, 4], [12, 5], [13, 6], [13, 7], [13, 8], [13, 9], [14, 2], [14, 3], [14, 4], [14, 5], [15, 6], [15, 7], [15, 8], [15, 9], [16, 2], [16, 3], [16, 4], [16, 5], [17, 6], [17, 7], [17, 8], [17, 9], [18, 2], [18, 3], [18, 4], [18, 5], [19, 6], [19, 7], [19, 8], [19, 9], [20, 2], [20, 3], [20, 4], [20, 5], [21, 6], [21, 7], [21, 8], [21, 9], [22, 2], [22, 3], [22, 4], [22, 5], [23, 6], [23, 7], [23, 8], [23, 9], [24, 2], [24, 3], [24, 4], [24, 5], [25, 6], [25, 7], [25, 8], [25, 9], [26, 2], [26, 3], [26, 4], [26, 5], [27, 6], [27, 7], [27, 8], [27, 9], [28, 2], [28, 3], [28, 4], [28, 5], [29, 6], [29, 7], [29, 8], [29, 9], [30, 2], [30, 3], [30, 4], [30, 5]]) == 28\n assert candidate(n = 7,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5]]) == 8\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 16\n assert candidate(n = 100,reservedSeats = [[10, 3], [10, 4], [20, 3], [20, 4], [30, 3], [30, 4], [40, 3], [40, 4], [50, 3], [50, 4], [60, 3], [60, 4], [70, 3], [70, 4], [80, 3], [80, 4], [90, 3], [90, 4]]) == 191\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [6, 3], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 5], [9, 6], [10, 3], [10, 4], [10, 5], [10, 6]]) == 2\n assert candidate(n = 10,reservedSeats = [[2, 5], [3, 4], [3, 5], [3, 6], [4, 3], [4, 4], [4, 5], [4, 6], [5, 5], [5, 6], [6, 7], [6, 8], [7, 3], [7, 4], [8, 5], [8, 6], [9, 7], [9, 8]]) == 8\n assert candidate(n = 20,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 5], [2, 6], [3, 3], [3, 4], [4, 7], [4, 8], [5, 2], [5, 3], [6, 8], [6, 9], [7, 1], [7, 2], [8, 5], [8, 6], [9, 4], [9, 5], [10, 9], [10, 10], [11, 1], [11, 10], [12, 2], [12, 9], [13, 3], [13, 8], [14, 4], [14, 7], [15, 5], [15, 6], [16, 2], [16, 3], [17, 8], [17, 9], [18, 4], [18, 5], [19, 6], [19, 7], [20, 1], [20, 10]]) == 17\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 9], [2, 5], [2, 6], [3, 3], [3, 4], [3, 7], [3, 8], [4, 2], [4, 9], [5, 3], [5, 8], [6, 5], [6, 6], [7, 2], [7, 9], [8, 3], [8, 8], [9, 4], [9, 7], [10, 2], [10, 9], [11, 5], [11, 6], [12, 3], [12, 8], [13, 2], [13, 9], [14, 3], [14, 8], [15, 5], [15, 6], [16, 2], [16, 9], [17, 3], [17, 8], [18, 5], [18, 6], [19, 2], [19, 9], [20, 3], [20, 8]]) == 13\n assert candidate(n = 10,reservedSeats = [[1, 1], [1, 10], [2, 2], [2, 9], [3, 3], [3, 8], [4, 4], [4, 7], [5, 5], [5, 6], [6, 1], [6, 10], [7, 2], [7, 9], [8, 3], [8, 8], [9, 4], [9, 7], [10, 5], [10, 6]]) == 8\n assert candidate(n = 15,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 10], [5, 3], [5, 4], [5, 7], [5, 8], [6, 1], [6, 10], [7, 2], [7, 3], [7, 8], [7, 9], [8, 2], [8, 3], [8, 8], [8, 9], [9, 1], [9, 10], [10, 4], [10, 5], [10, 6], [10, 7], [11, 2], [11, 3], [11, 8], [11, 9], [12, 4], [12, 5], [12, 6], [12, 7], [13, 1], [13, 10], [14, 2], [14, 3], [14, 8], [14, 9], [15, 4], [15, 5], [15, 6], [15, 7]]) == 15\n assert candidate(n = 15,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 1], [5, 10], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 3], [7, 8], [7, 9], [8, 5], [8, 6], [9, 4], [9, 5], [9, 6], [9, 7], [10, 2], [10, 3], [11, 8], [11, 9], [12, 5], [12, 6], [13, 3], [13, 4], [14, 7], [14, 8], [15, 1], [15, 10]]) == 11\n assert candidate(n = 7,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10]]) == 12\n assert candidate(n = 8,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [6, 2], [6, 3], [6, 4], [6, 5], [7, 2], [7, 3], [7, 4], [7, 5], [8, 2], [8, 3], [8, 4], [8, 5]]) == 8\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 9], [8, 1], [8, 10], [9, 3], [9, 4], [9, 7], [9, 8], [10, 2], [10, 3], [10, 8], [10, 9]]) == 9\n assert candidate(n = 15,reservedSeats = [[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]]) == 17\n assert candidate(n = 10,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 9], [8, 1], [8, 10], [9, 3], [9, 4], [9, 7], [9, 8], [10, 2], [10, 3], [10, 8], [10, 9]]) == 7\n assert candidate(n = 30,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 2], [4, 3], [4, 4], [4, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 2], [10, 3], [10, 4], [10, 5]]) == 51\n assert candidate(n = 100,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [75, 2], [75, 3], [75, 4], [75, 5], [75, 6], [75, 7], [75, 8], [75, 9], [75, 10], [99, 2], [99, 3], [99, 4], [99, 5], [99, 6], [99, 7], [99, 8], [99, 9], [99, 10]]) == 192\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9]]) == 1\n assert candidate(n = 7,reservedSeats = [[1, 4], [1, 5], [1, 6], [1, 7], [2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 7], [4, 8], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5]]) == 3\n assert candidate(n = 25,reservedSeats = [[10, 2], [10, 3], [11, 8], [11, 9], [12, 4], [12, 5], [13, 6], [13, 7], [14, 2], [14, 3], [15, 8], [15, 9], [16, 4], [16, 5], [17, 6], [17, 7], [18, 2], [18, 3], [19, 8], [19, 9], [20, 4], [20, 5], [21, 6], [21, 7], [22, 2], [22, 3], [23, 8], [23, 9], [24, 4], [24, 5], [25, 6], [25, 7], [1, 2], [1, 3], [2, 8], [2, 9], [3, 4], [3, 5], [4, 6], [4, 7], [5, 2], [5, 3], [6, 8], [6, 9], [7, 4], [7, 5], [8, 6], [8, 7], [9, 2], [9, 3]]) == 25\n assert candidate(n = 12,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 2], [2, 3], [3, 4], [3, 5], [4, 7], [4, 8], [5, 2], [5, 3], [6, 8], [6, 9], [7, 1], [7, 2], [8, 5], [8, 6], [9, 4], [9, 5], [10, 9], [10, 10], [11, 1], [11, 10], [12, 2], [12, 9]]) == 11\n assert candidate(n = 6,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [2, 7], [2, 8], [3, 3], [3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 8], [5, 9], [6, 5], [6, 6], [6, 7], [6, 8]]) == 2\n assert candidate(n = 1000,reservedSeats = [[1, 2], [1, 3], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3], [5, 2], [5, 3], [6, 2], [6, 3], [7, 2], [7, 3], [8, 2], [8, 3], [9, 2], [9, 3], [10, 2], [10, 3]]) == 1990\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9], [5, 3], [5, 4], [5, 7], [5, 8], [6, 1], [6, 10], [7, 5], [7, 6], [8, 4], [8, 5], [8, 6], [8, 7], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7]]) == 6\n assert candidate(n = 100,reservedSeats = [[1, 1], [1, 10], [10, 1], [10, 10], [20, 1], [20, 10], [30, 1], [30, 10], [40, 1], [40, 10], [50, 1], [50, 10], [60, 1], [60, 10], [70, 1], [70, 10], [80, 1], [80, 10], [90, 1], [90, 10], [100, 1], [100, 10]]) == 200\n assert candidate(n = 50,reservedSeats = [[10, 2], [10, 3], [10, 8], [10, 9], [20, 4], [20, 5], [20, 6], [20, 7], [30, 1], [30, 10], [40, 2], [40, 3], [40, 8], [40, 9], [50, 2], [50, 3], [50, 8], [50, 9]]) == 95\n assert candidate(n = 100,reservedSeats = [[50, 4], [50, 5], [50, 6], [50, 7], [51, 2], [51, 3], [51, 8], [51, 9], [52, 4], [52, 5], [52, 6], [52, 7], [53, 2], [53, 3], [53, 8], [53, 9], [54, 4], [54, 5], [54, 6], [54, 7], [55, 2], [55, 3], [55, 8], [55, 9], [56, 4], [56, 5], [56, 6], [56, 7], [57, 2], [57, 3], [57, 8], [57, 9], [58, 4], [58, 5], [58, 6], [58, 7]]) == 186\n assert candidate(n = 10,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 1], [5, 10], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 3], [7, 8], [7, 9], [8, 5], [8, 6], [9, 4], [9, 5], [9, 6], [9, 7], [10, 2], [10, 3], [10, 8], [10, 9]]) == 6\n assert candidate(n = 15,reservedSeats = [[5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 2], [6, 3], [6, 8], [6, 9], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 2], [9, 3], [9, 8], [9, 9]]) == 22\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10]]) == 15\n assert candidate(n = 100,reservedSeats = [[10, 2], [10, 3], [10, 4], [10, 5], [20, 4], [20, 5], [30, 6], [30, 7], [40, 8], [40, 9], [50, 2], [50, 3], [60, 4], [60, 5], [70, 6], [70, 7], [80, 8], [80, 9], [90, 2], [90, 3]]) == 191\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 0\n assert candidate(n = 20,reservedSeats = [[5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 36\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [3, 7], [4, 6], [4, 7], [4, 8], [4, 9], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7]]) == 8\n assert candidate(n = 5,reservedSeats = [[1, 5], [1, 6], [2, 4], [2, 5], [3, 7], [3, 8], [4, 3], [4, 4], [5, 9], [5, 10]]) == 4\n assert candidate(n = 100,reservedSeats = [[10, 3], [10, 4], [10, 5], [10, 6], [20, 2], [20, 3], [20, 8], [20, 9], [30, 4], [30, 5], [30, 6], [30, 7], [40, 1], [40, 2], [40, 3], [40, 4], [40, 5], [40, 6], [40, 7], [40, 8], [40, 9], [40, 10], [50, 4], [50, 5], [50, 6], [50, 7], [60, 2], [60, 3], [60, 8], [60, 9], [70, 4], [70, 5], [70, 6], [70, 7], [80, 1], [80, 2], [80, 3], [80, 4], [80, 5], [80, 6], [80, 7], [80, 8], [80, 9], [80, 10], [90, 3], [90, 4], [90, 5], [90, 6], [100, 2], [100, 3], [100, 8], [100, 9]]) == 183\n assert candidate(n = 25,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [6, 3], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 5], [9, 6], [10, 3], [10, 4], [10, 5], [10, 6], [11, 5], [11, 6], [12, 3], [12, 4], [12, 5], [12, 6], [13, 4], [13, 5], [13, 6], [13, 7], [14, 3], [14, 4], [14, 5], [14, 6], [15, 5], [15, 6], [16, 3], [16, 4], [16, 5], [16, 6], [17, 4], [17, 5], [17, 6], [17, 7], [18, 3], [18, 4], [18, 5], [18, 6], [19, 5], [19, 6], [20, 3], [20, 4], [20, 5], [20, 6], [21, 5], [21, 6], [22, 3], [22, 4], [22, 5], [22, 6], [23, 4], [23, 5], [23, 6], [23, 7], [24, 3], [24, 4], [24, 5], [24, 6], [25, 5], [25, 6]]) == 2\n assert candidate(n = 1000,reservedSeats = [[100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [200, 2], [200, 3], [200, 4], [200, 5], [200, 6], [200, 7], [200, 8], [500, 2], [500, 3], [500, 4], [500, 5], [500, 6], [500, 7], [500, 8], [500, 9], [500, 10], [750, 2], [750, 3], [750, 4], [750, 5], [750, 6], [750, 7], [750, 8], [750, 9], [750, 10], [900, 2], [900, 3], [900, 4], [900, 5], [900, 6], [900, 7], [900, 8], [900, 9], [900, 10], [999, 2], [999, 3], [999, 4], [999, 5], [999, 6], [999, 7], [999, 8], [999, 9], [999, 10]]) == 1988\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9]]) == 15\n assert candidate(n = 15,reservedSeats = [[5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 8], [6, 9], [7, 2], [7, 3], [7, 4], [7, 5], [8, 6], [8, 7], [8, 8], [8, 9]]) == 25\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5], [8, 6], [8, 7], [9, 8], [9, 9], [10, 10], [10, 1]]) == 32\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 5], [5, 6]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 1], [1, 10], [2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 5], [5, 6], [5, 7], [5, 8]]) == 3\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [2, 7], [3, 6], [3, 7], [3, 8], [3, 9], [4, 8], [4, 9], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == 3\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 2], [5, 3], [6, 4], [6, 5], [7, 6], [7, 7], [8, 8], [8, 9], [9, 2], [9, 3], [10, 4], [10, 5]]) == 30\n assert candidate(n = 15,reservedSeats = [[1, 2], [1, 3], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 8], [7, 9], [8, 1], [8, 10], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7], [11, 2], [11, 3], [11, 8], [11, 9], [12, 1], [12, 10], [13, 2], [13, 3], [13, 8], [13, 9], [14, 4], [14, 5], [14, 6], [14, 7], [15, 2], [15, 3], [15, 8], [15, 9]]) == 14\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 8], [2, 9], [3, 4], [3, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 8], [8, 9], [9, 4], [9, 5], [10, 6], [10, 7], [11, 2], [11, 3], [12, 8], [12, 9], [13, 4], [13, 5], [14, 6], [14, 7], [15, 2], [15, 3], [16, 8], [16, 9], [17, 4], [17, 5], [18, 6], [18, 7], [19, 2], [19, 3], [20, 8], [20, 9]]) == 20\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [3, 6], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 9], [7, 7], [7, 8], [8, 2], [8, 3], [9, 8], [9, 9], [10, 10]]) == 11\n assert candidate(n = 15,reservedSeats = [[2, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 2], [6, 3], [7, 4], [7, 5], [8, 6], [8, 7], [9, 8], [9, 9], [10, 10], [11, 1], [11, 2], [12, 3], [12, 4], [13, 5], [13, 6], [14, 7], [14, 8], [15, 9]]) == 15\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8]]) == 3\n assert candidate(n = 50,reservedSeats = [[10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [25, 5], [25, 6], [25, 7], [25, 8]]) == 94\n assert candidate(n = 20,reservedSeats = [[1, 5], [2, 4], [3, 6], [4, 7], [5, 8], [6, 9], [7, 2], [8, 3], [9, 4], [10, 5], [11, 6], [12, 7], [13, 8], [14, 9], [15, 2], [16, 3], [17, 4], [18, 5], [19, 6], [20, 7]]) == 20\n assert candidate(n = 20,reservedSeats = [[5, 2], [5, 3], [5, 8], [5, 9], [10, 4], [10, 5], [10, 6], [10, 7], [15, 1], [15, 10], [20, 2], [20, 3], [20, 8], [20, 9]]) == 36\n assert candidate(n = 50,reservedSeats = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [10, 2], [10, 3], [10, 8], [10, 9], [15, 1], [15, 2], [15, 3], [15, 4], [15, 5], [15, 6], [15, 7], [15, 8], [15, 9], [15, 10], [20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10], [25, 1], [25, 2], [25, 3], [25, 4], [25, 5], [25, 6], [25, 7], [25, 8], [25, 9], [25, 10], [30, 1], [30, 2], [30, 3], [30, 4], [30, 5], [30, 6], [30, 7], [30, 8], [30, 9], [30, 10], [35, 1], [35, 2], [35, 3], [35, 4], [35, 5], [35, 6], [35, 7], [35, 8], [35, 9], [35, 10], [40, 1], [40, 2], [40, 3], [40, 4], [40, 5], [40, 6], [40, 7], [40, 8], [40, 9], [40, 10], [45, 1], [45, 2], [45, 3], [45, 4], [45, 5], [45, 6], [45, 7], [45, 8], [45, 9], [45, 10]]) == 83\n", "comparison": "exact"}, "public_tests": ["3\n[[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]", "2\n[[2,1],[1,8],[2,6]]", "4\n[[4,3],[1,4],[4,6],[1,7]]"], "hints": ["Note you can allocate at most two four-person groups in one row.", "Greedily check if you can allocate seats for two groups, one group or none.", "Process only rows that appear in the input, for other rows you can always allocate seats for two groups."], "metadata": {"canonical_parameter_names": ["n", "reservedSeats"], "leetcode_dataset_entry_point": "Solution().maxNumberOfFamilies", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:36+00:00", "tests_total": 76, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "hash-table", "greedy", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def maxNumberOfFamilies(self, n: int, reservedSeats: list[list[int]]) -> int:", "container": "Solution", "callable": "maxNumberOfFamilies", "parameters": [{"name": "n", "type": "int"}, {"name": "reservedSeats", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1387, "task_id": "sort-integers-by-the-power-value", "difficulty": "Medium", "problem_description": "The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:\n\n- if x is even then x = x / 2\n- if x is odd then x = 3 * x + 1\n\nFor example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).\n\nGiven three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.\n\nReturn the k^th integer in the range [lo, hi] sorted by the power value.\n\nNotice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.\n\nExample 1:\n\nInput: lo = 12, hi = 15, k = 2\nOutput: 13\nExplanation: The power of 12 is 9 (12 --> 6 --> 3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1)\nThe power of 13 is 9\nThe power of 14 is 17\nThe power of 15 is 17\nThe interval sorted by the power value [12,13,14,15]. For k = 2 answer is the second element which is 13.\nNotice that 12 and 13 have the same power value and we sorted them in ascending order. Same for 14 and 15.\n\nExample 2:\n\nInput: lo = 7, hi = 11, k = 4\nOutput: 7\nExplanation: The power array corresponding to the interval [7, 8, 9, 10, 11] is [16, 3, 19, 6, 14].\nThe interval sorted by power is [8, 10, 11, 7, 9].\nThe fourth number in the sorted array is 7.\n\nConstraints:\n\n- 1 <= lo <= hi <= 1000\n- 1 <= k <= hi - lo + 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lo = 1,hi = 10,k = 1) == 1\n assert candidate(lo = 5,hi = 5,k = 1) == 5\n assert candidate(lo = 12,hi = 15,k = 2) == 13\n assert candidate(lo = 1,hi = 10,k = 5) == 5\n assert candidate(lo = 10,hi = 20,k = 5) == 13\n assert candidate(lo = 7,hi = 11,k = 4) == 7\n assert candidate(lo = 10,hi = 20,k = 3) == 20\n assert candidate(lo = 1,hi = 10,k = 3) == 4\n assert candidate(lo = 300,hi = 500,k = 100) == 370\n assert candidate(lo = 100,hi = 200,k = 1) == 128\n assert candidate(lo = 300,hi = 700,k = 150) == 613\n assert candidate(lo = 700,hi = 800,k = 18) == 794\n assert candidate(lo = 100,hi = 200,k = 75) == 183\n assert candidate(lo = 1,hi = 100,k = 100) == 97\n assert candidate(lo = 700,hi = 800,k = 50) == 766\n assert candidate(lo = 800,hi = 900,k = 5) == 802\n assert candidate(lo = 900,hi = 1000,k = 50) == 988\n assert candidate(lo = 600,hi = 800,k = 150) == 756\n assert candidate(lo = 800,hi = 1000,k = 50) == 912\n assert candidate(lo = 500,hi = 900,k = 100) == 692\n assert candidate(lo = 400,hi = 600,k = 100) == 489\n assert candidate(lo = 400,hi = 700,k = 120) == 418\n assert candidate(lo = 750,hi = 850,k = 50) == 758\n assert candidate(lo = 300,hi = 400,k = 100) == 313\n assert candidate(lo = 5,hi = 25,k = 1) == 8\n assert candidate(lo = 300,hi = 350,k = 30) == 338\n assert candidate(lo = 950,hi = 1000,k = 25) == 984\n assert candidate(lo = 200,hi = 300,k = 1) == 256\n assert candidate(lo = 800,hi = 900,k = 50) == 855\n assert candidate(lo = 800,hi = 900,k = 85) == 898\n assert candidate(lo = 500,hi = 600,k = 50) == 509\n assert candidate(lo = 250,hi = 450,k = 150) == 428\n assert candidate(lo = 150,hi = 450,k = 100) == 173\n assert candidate(lo = 300,hi = 350,k = 10) == 309\n assert candidate(lo = 300,hi = 600,k = 150) == 374\n assert candidate(lo = 100,hi = 200,k = 10) == 138\n assert candidate(lo = 400,hi = 600,k = 150) == 486\n assert candidate(lo = 900,hi = 1000,k = 10) == 965\n assert candidate(lo = 250,hi = 500,k = 100) == 312\n assert candidate(lo = 300,hi = 400,k = 50) == 367\n assert candidate(lo = 500,hi = 1000,k = 250) == 658\n assert candidate(lo = 300,hi = 350,k = 25) == 315\n assert candidate(lo = 200,hi = 300,k = 75) == 242\n assert candidate(lo = 50,hi = 150,k = 25) == 56\n assert candidate(lo = 250,hi = 350,k = 100) == 313\n assert candidate(lo = 50,hi = 75,k = 1) == 64\n assert candidate(lo = 500,hi = 1000,k = 150) == 943\n assert candidate(lo = 100,hi = 800,k = 200) == 547\n assert candidate(lo = 100,hi = 500,k = 30) == 150\n assert candidate(lo = 1,hi = 500,k = 250) == 465\n assert candidate(lo = 400,hi = 600,k = 120) == 590\n assert candidate(lo = 1,hi = 100,k = 10) == 3\n assert candidate(lo = 200,hi = 300,k = 50) == 271\n assert candidate(lo = 250,hi = 750,k = 250) == 741\n assert candidate(lo = 300,hi = 400,k = 5) == 384\n assert candidate(lo = 400,hi = 600,k = 200) == 487\n assert candidate(lo = 1,hi = 500,k = 150) == 163\n assert candidate(lo = 150,hi = 250,k = 20) == 234\n assert candidate(lo = 800,hi = 1000,k = 200) == 937\n assert candidate(lo = 1,hi = 1000,k = 1) == 1\n assert candidate(lo = 999,hi = 1000,k = 1) == 999\n assert candidate(lo = 1,hi = 1000,k = 500) == 606\n assert candidate(lo = 200,hi = 300,k = 100) == 231\n assert candidate(lo = 200,hi = 300,k = 10) == 280\n assert candidate(lo = 300,hi = 700,k = 250) == 699\n assert candidate(lo = 250,hi = 400,k = 100) == 263\n assert candidate(lo = 750,hi = 850,k = 30) == 813\n assert candidate(lo = 100,hi = 300,k = 150) == 242\n assert candidate(lo = 25,hi = 75,k = 25) == 36\n assert candidate(lo = 400,hi = 500,k = 100) == 487\n assert candidate(lo = 800,hi = 900,k = 80) == 874\n assert candidate(lo = 50,hi = 75,k = 25) == 55\n assert candidate(lo = 150,hi = 300,k = 75) == 210\n assert candidate(lo = 1,hi = 100,k = 1) == 1\n assert candidate(lo = 500,hi = 1000,k = 300) == 754\n assert candidate(lo = 600,hi = 700,k = 20) == 663\n assert candidate(lo = 800,hi = 900,k = 100) == 889\n assert candidate(lo = 200,hi = 400,k = 150) == 243\n assert candidate(lo = 100,hi = 200,k = 100) == 129\n assert candidate(lo = 100,hi = 200,k = 50) == 114\n assert candidate(lo = 800,hi = 900,k = 25) == 882\n assert candidate(lo = 1,hi = 100,k = 50) == 9\n assert candidate(lo = 500,hi = 600,k = 25) == 538\n assert candidate(lo = 50,hi = 150,k = 50) == 66\n assert candidate(lo = 1000,hi = 1000,k = 1) == 1000\n assert candidate(lo = 1,hi = 100,k = 75) == 67\n assert candidate(lo = 900,hi = 999,k = 15) == 985\n assert candidate(lo = 2,hi = 10,k = 5) == 10\n assert candidate(lo = 1,hi = 1000,k = 750) == 322\n assert candidate(lo = 600,hi = 900,k = 150) == 718\n assert candidate(lo = 50,hi = 100,k = 15) == 93\n assert candidate(lo = 1,hi = 1,k = 1) == 1\n assert candidate(lo = 600,hi = 800,k = 100) == 676\n", "comparison": "exact"}, "public_tests": ["12\n15\n2", "7\n11\n4"], "hints": ["Use dynamic programming to get the power of each integer of the intervals.", "Sort all the integers of the interval by the power value and return the k-th in the sorted list."], "metadata": {"canonical_parameter_names": ["lo", "hi", "k"], "leetcode_dataset_entry_point": "Solution().getKth", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:39+00:00", "tests_total": 93, "tests_dropped": 0, "flags": [], "topic_tags": ["dynamic-programming", "memoization", "sorting"]}, "language": "python", "interface": {"raw_signature": "def getKth(self, lo: int, hi: int, k: int) -> int:", "container": "Solution", "callable": "getKth", "parameters": [{"name": "lo", "type": "int"}, {"name": "hi", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1388, "task_id": "pizza-with-3n-slices", "difficulty": "Hard", "problem_description": "There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:\n\n- You will pick any pizza slice.\n- Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.\n- Your friend Bob will pick the next slice in the clockwise direction of your pick.\n- Repeat until there are no more slices of pizzas.\n\nGiven an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.\n\nExample 1:\n\nInput: slices = [1,2,3,4,5,6]\nOutput: 10\nExplanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.\n\nExample 2:\n\nInput: slices = [8,9,8,6,1,1]\nOutput: 16\nExplanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.\n\nConstraints:\n\n- 3 * n == slices.length\n- 1 <= slices.length <= 500\n- 1 <= slices[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(slices = [9, 7, 7, 7, 6, 6]) == 16\n assert candidate(slices = [1000, 1000, 1000, 1000, 1000, 1000]) == 2000\n assert candidate(slices = [10, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(slices = [1, 2, 3, 4, 1, 2]) == 6\n assert candidate(slices = [8, 9, 8, 6, 1, 1]) == 16\n assert candidate(slices = [10, 1, 1, 1, 1, 10]) == 11\n assert candidate(slices = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 36\n assert candidate(slices = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 21\n assert candidate(slices = [7, 7, 7, 7, 7, 7, 7]) == 14\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1]) == 2000\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(slices = [5, 7, 8, 6, 3, 4]) == 13\n assert candidate(slices = [1, 3, 1, 5, 2, 5, 1, 5, 6]) == 16\n assert candidate(slices = [1, 2, 3, 4, 5, 6]) == 10\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(slices = [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]) == 2100\n assert candidate(slices = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 798\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 78\n assert candidate(slices = [1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000]) == 4000\n assert candidate(slices = [5, 3, 9, 7, 1, 4, 8, 6, 2, 10, 12, 11]) == 38\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(slices = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5, 500, 6]) == 2000\n assert candidate(slices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8]) == 280\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 100, 200, 300, 400, 500, 600]) == 2000\n assert candidate(slices = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 400\n assert candidate(slices = [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800]) == 3200\n assert candidate(slices = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6]) == 394\n assert candidate(slices = [900, 100, 200, 300, 400, 500, 600, 700, 800, 100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 200, 300, 400, 500, 600, 700]) == 5400\n assert candidate(slices = [10, 1, 15, 2, 20, 3, 25, 4, 30, 5, 35, 6]) == 110\n assert candidate(slices = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [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]) == 144\n assert candidate(slices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == 3450\n assert candidate(slices = [15, 1, 25, 3, 20, 4, 2, 30, 5, 6, 7, 8]) == 90\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 560\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(slices = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995]) == 3994\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 36\n assert candidate(slices = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 12\n assert candidate(slices = [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]) == 2278\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 550\n assert candidate(slices = [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]) == 144\n assert candidate(slices = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 3600\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 3485\n assert candidate(slices = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 2000\n assert candidate(slices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(slices = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 60\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 360\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 36\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 12, 11]) == 35\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 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(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(slices = [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, 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]) == 21000\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 144\n assert candidate(slices = [300, 1, 100, 2, 200, 3, 150, 4, 250, 5, 350, 6]) == 1100\n assert candidate(slices = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 64\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [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]) == 5000\n assert candidate(slices = [12, 3, 11, 4, 2, 5, 6, 7, 8, 9, 10, 1]) == 41\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 2244\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 5050\n assert candidate(slices = [5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8]) == 75\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 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(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11]) == 36\n assert candidate(slices = [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]) == 210\n assert candidate(slices = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5, 999, 6, 999, 7, 999, 8, 999, 9, 999, 10, 999, 11, 999, 12, 999, 13, 999, 14, 999, 15]) == 9990\n assert candidate(slices = [9, 2, 8, 1, 5, 6, 7, 3, 4, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 60\n assert candidate(slices = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 3996\n assert candidate(slices = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5, 500, 6]) == 2000\n assert candidate(slices = [200, 150, 100, 50, 100, 150, 200, 250, 300, 350, 400, 450]) == 1200\n assert candidate(slices = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(slices = [5, 7, 4, 6, 10, 3, 8, 2, 9, 1, 11, 6]) == 38\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 560\n assert candidate(slices = [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]) == 1000\n assert candidate(slices = [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]) == 76\n assert candidate(slices = [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]) == 2100\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10]) == 55\n assert candidate(slices = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == 39\n assert candidate(slices = [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]) == 97\n assert candidate(slices = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(slices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 180\n assert candidate(slices = [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]) == 5600\n assert candidate(slices = [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(slices = [10, 5, 1, 2, 8, 3, 9, 4, 7, 6, 11, 12]) == 38\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [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]) == 50\n assert candidate(slices = [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(slices = [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]) == 114\n assert candidate(slices = [500, 1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6]) == 3994\n assert candidate(slices = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10, 11]) == 127\n assert candidate(slices = [900, 100, 800, 200, 700, 300, 600, 400, 500, 500, 600, 400]) == 3000\n assert candidate(slices = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 28\n assert candidate(slices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(slices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(slices = [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, 226, 227, 228, 229, 230]) == 2210\n assert candidate(slices = [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]) == 560\n assert candidate(slices = [12, 3, 14, 5, 16, 7, 18, 9, 11, 2, 13, 4]) == 61\n assert candidate(slices = [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]) == 10000\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 90\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1]) == 31\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 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(slices = [500, 300, 200, 400, 100, 600, 700, 800, 900, 100, 100, 100]) == 2500\n assert candidate(slices = [2, 5, 3, 4, 8, 1, 9, 7, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6]", "[8,9,8,6,1,1]"], "hints": ["By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array.", "The first one in the array is considered next to the last one in the array. Use Dynamic Programming to solve it."], "metadata": {"canonical_parameter_names": ["slices"], "leetcode_dataset_entry_point": "Solution().maxSizeSlices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:41+00:00", "tests_total": 111, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxSizeSlices(self, slices: list[int]) -> int:", "container": "Solution", "callable": "maxSizeSlices", "parameters": [{"name": "slices", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1389, "task_id": "create-target-array-in-the-given-order", "difficulty": "Easy", "problem_description": "Given two arrays of integers nums and index. Your task is to create target array under the following rules:\n\n- Initially target array is empty.\n- From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.\n- Repeat the previous step until there are no elements to read in nums and index.\n\nReturn the target array.\n\nIt is guaranteed that the insertion operations will be valid.\n\nExample 1:\n\nInput: nums = [0,1,2,3,4], index = [0,1,2,2,1]\nOutput: [0,4,1,3,2]\nExplanation:\nnums index target\n0 0 [0]\n1 1 [0,1]\n2 2 [0,1,2]\n3 2 [0,1,3,2]\n4 1 [0,4,1,3,2]\n\nExample 2:\n\nInput: nums = [1,2,3,4,0], index = [0,1,2,3,0]\nOutput: [0,1,2,3,4]\nExplanation:\nnums index target\n1 0 [1]\n2 1 [1,2]\n3 2 [1,2,3]\n4 3 [1,2,3,4]\n0 0 [0,1,2,3,4]\n\nExample 3:\n\nInput: nums = [1], index = [0]\nOutput: [1]\n\nConstraints:\n\n- 1 <= nums.length, index.length <= 100\n- nums.length == index.length\n- 0 <= nums[i] <= 100\n- 0 <= index[i] <= i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1],index = [0]) == [1]\n assert candidate(nums = [10, 9, 8, 7, 6],index = [0, 1, 1, 1, 1]) == [10, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4],index = [0, 1, 2, 2, 1]) == [0, 4, 1, 3, 2]\n assert candidate(nums = [5, 5, 5, 5],index = [0, 1, 2, 0]) == [5, 5, 5, 5]\n assert candidate(nums = [5, 5, 5, 5],index = [0, 1, 2, 3]) == [5, 5, 5, 5]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [0, 0, 0, 0, 0]) == [5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2],index = [0, 0, 1]) == [3, 2, 1]\n assert candidate(nums = [0, 0, 0, 0],index = [0, 1, 2, 3]) == [0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [0, 1, 2, 3, 4]) == [9, 8, 7, 6, 5]\n assert candidate(nums = [1, 3, 2],index = [0, 1, 1]) == [1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 0],index = [0, 1, 2, 3, 0]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [9, 8, 7, 6],index = [0, 0, 1, 2]) == [8, 7, 6, 9]\n assert candidate(nums = [9, 8, 7, 6],index = [0, 0, 0, 0]) == [6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [5, 5, 3, 2, 6, 5, 9, 4, 1, 3, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [0, 1, 2, 3, 4, 5, 6]) == [7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],index = [0, 1, 2, 2, 2, 2]) == [5, 10, 30, 25, 20, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [3, 1, 2],index = [0, 1, 1]) == [3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 0, 3, 2, 3, 4, 5, 6, 7]) == [3, 1, 5, 6, 7, 8, 9, 10, 2, 4]\n assert candidate(nums = [5, 3, 7, 1, 9],index = [0, 1, 1, 2, 3]) == [5, 7, 1, 9, 3]\n assert candidate(nums = [1, 3, 2, 5, 4],index = [0, 1, 1, 2, 3]) == [1, 2, 5, 4, 3]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [0, 0, 0, 0, 0, 0]) == [95, 96, 97, 98, 99, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],index = [0, 1, 2, 3, 4, 5, 6, 7]) == [5, 3, 8, 6, 2, 7, 4, 1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13],index = [0, 1, 2, 0, 1, 2, 3]) == [10, 11, 12, 13, 7, 8, 9]\n assert candidate(nums = [5, 3, 8, 9, 2],index = [0, 1, 2, 3, 4]) == [5, 3, 8, 9, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 0, 1, 2, 1, 0, 3, 4, 5, 6]) == [6, 2, 5, 7, 8, 9, 10, 3, 4, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],index = [0, 1, 0, 2, 1, 3, 0]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],index = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 0, 0, 0, 0]) == [9, 7, 5, 3, 1]\n assert candidate(nums = [100, 90, 80, 70, 60],index = [0, 1, 2, 3, 4]) == [100, 90, 80, 70, 60]\n assert candidate(nums = [1, 3, 2, 5, 4, 8, 7, 6, 10, 9],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [9, 10, 6, 7, 8, 4, 5, 2, 3, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 0, 1, 1, 0, 2, 3, 4, 5, 6, 7]) == [5, 1, 9, 2, 6, 5, 3, 5, 1, 4, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [6, 6, 6, 6, 6],index = [0, 0, 1, 1, 2]) == [6, 6, 6, 6, 6]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 1, 0, 2, 3]) == [30, 10, 40, 50, 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],index = [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, 20]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 4, 3, 2, 1],index = [0, 1, 2, 2, 2]) == [5, 4, 1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4],index = [0, 0, 0, 0]) == [4, 3, 2, 1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12],index = [0, 0, 1, 1, 2, 2]) == [8, 10, 12, 11, 9, 7]\n assert candidate(nums = [1, 3, 2, 5, 4],index = [0, 0, 1, 1, 2]) == [3, 5, 4, 2, 1]\n assert candidate(nums = [0, 1, 0, 1, 0],index = [0, 1, 2, 3, 4]) == [0, 1, 0, 1, 0]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6],index = [0, 1, 1, 3, 4, 5, 5]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 0, 1, 2, 3]) == [3, 5, 7, 9, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],index = [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 = [10, 9, 8, 7, 6, 5],index = [0, 1, 1, 0, 3, 2]) == [7, 10, 5, 8, 6, 9]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 1, 0, 1, 2, 0, 3, 0, 4, 5, 6]) == [6, 9, 4, 1, 5, 3, 5, 2, 5, 3, 1]\n assert candidate(nums = [0, 1, 1, 1, 0],index = [0, 1, 2, 2, 0]) == [0, 0, 1, 1, 1]\n assert candidate(nums = [6, 5, 4, 3, 2, 1],index = [0, 0, 0, 0, 0, 0]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [0, 1, 0, 2, 1, 3]) == [98, 96, 100, 95, 97, 99]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 0, 0, 0, 4]) == [40, 30, 20, 10, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [0, 1, 0, 1, 0],index = [0, 1, 0, 1, 0]) == [0, 0, 1, 0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 0, 2, 3, 4, 5, 6, 7, 8]) == [3, 1, 4, 5, 6, 7, 8, 9, 10, 2]\n assert candidate(nums = [1, 1, 1, 1, 1],index = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [0, 0, 0, 0, 0, 0, 0]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [33, 22, 11, 66, 55, 44],index = [0, 0, 0, 0, 0, 0]) == [44, 55, 66, 11, 22, 33]\n assert candidate(nums = [1, 1, 1, 1, 1],index = [0, 1, 0, 2, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 1, 2, 0, 3]) == [7, 1, 3, 9, 5]\n", "comparison": "exact"}, "public_tests": ["[0,1,2,3,4]\n[0,1,2,2,1]", "[1,2,3,4,0]\n[0,1,2,3,0]", "[1]\n[0]"], "hints": ["Simulate the process and fill corresponding numbers in the designated spots."], "metadata": {"canonical_parameter_names": ["nums", "index"], "leetcode_dataset_entry_point": "Solution().createTargetArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:43+00:00", "tests_total": 115, "tests_dropped": 46, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def createTargetArray(self, nums: list[int], index: list[int]) -> list[int]:", "container": "Solution", "callable": "createTargetArray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "index", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1390, "task_id": "four-divisors", "difficulty": "Medium", "problem_description": "Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.\n\nExample 1:\n\nInput: nums = [21,4,7]\nOutput: 32\nExplanation:\n21 has 4 divisors: 1, 3, 7, 21\n4 has 3 divisors: 1, 2, 4\n7 has 2 divisors: 1, 7\nThe answer is the sum of divisors of 21 only.\n\nExample 2:\n\nInput: nums = [21,21]\nOutput: 64\n\nExample 3:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length <= 10^4\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [101, 103, 107, 109, 113]) == 0\n assert candidate(nums = [2310, 2320, 2330, 2340, 2350]) == 0\n assert candidate(nums = [30, 44, 25, 63]) == 0\n assert candidate(nums = [30, 100, 49]) == 0\n assert candidate(nums = [6, 8, 10, 12, 14]) == 69\n assert candidate(nums = [100, 121, 144, 169]) == 0\n assert candidate(nums = [11, 13, 17, 19, 23]) == 0\n assert candidate(nums = [15, 21, 28, 30, 35]) == 104\n assert candidate(nums = [105, 106, 107, 108, 109]) == 162\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [110, 111, 112, 113, 114]) == 152\n assert candidate(nums = [21, 21]) == 64\n assert candidate(nums = [15, 21, 25, 49, 77]) == 152\n assert candidate(nums = [6, 8, 10, 12]) == 45\n assert candidate(nums = [10, 15, 21, 28, 30]) == 74\n assert candidate(nums = [100, 101, 102, 103, 104]) == 0\n assert candidate(nums = [30, 49, 64, 81, 97]) == 0\n assert candidate(nums = [30, 49, 64, 81]) == 0\n assert candidate(nums = [10, 15, 21, 22]) == 110\n assert candidate(nums = [21, 4, 7]) == 32\n assert candidate(nums = [30, 40, 50, 60, 70]) == 0\n assert candidate(nums = [1001, 1009, 1013, 1019, 1021]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 0\n assert candidate(nums = [10, 15, 21, 22, 28]) == 110\n assert candidate(nums = [15, 28, 91]) == 136\n assert candidate(nums = [36, 49, 64, 81, 100]) == 0\n assert candidate(nums = [6, 8, 10, 12, 14]) == 69\n assert candidate(nums = [100, 101, 102, 103, 104]) == 0\n assert candidate(nums = [500, 525, 546, 567, 570, 588, 594, 616, 630, 646, 660, 672, 684]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 162\n assert candidate(nums = [144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484]) == 0\n assert candidate(nums = [231, 252, 273, 294, 315]) == 0\n assert candidate(nums = [901, 903, 917, 923, 925, 927, 931, 943, 945, 949, 957, 963, 965, 979, 987, 989, 993, 995, 999, 1001]) == 10908\n assert candidate(nums = [323, 333, 341, 351, 361]) == 744\n assert candidate(nums = [145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165]) == 1242\n assert candidate(nums = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010]) == 36664\n assert candidate(nums = [231, 275, 299, 322, 341, 361, 385, 407, 429, 451, 473, 495]) == 2208\n assert candidate(nums = [500, 505, 511, 513, 529, 539, 551, 561, 573, 583, 585, 595, 605, 621, 627, 637, 645, 651, 655, 667, 685]) == 5560\n assert candidate(nums = [220, 280, 300, 330, 350]) == 0\n assert candidate(nums = [882, 924, 966, 1008, 1050]) == 0\n assert candidate(nums = [2048, 2187, 2345, 2500, 2648, 2809, 3003, 3215, 3432, 3654, 3888]) == 3864\n assert candidate(nums = [100, 121, 143, 169, 181]) == 168\n assert candidate(nums = [5005, 5007, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087]) == 6680\n assert candidate(nums = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1005, 1006, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021, 1023, 1025, 1027, 1029, 1031, 1033, 1035, 1037, 1039, 1041, 1043, 1045, 1047, 1049, 1051, 1053, 1055]) == 12524\n assert candidate(nums = [56, 84, 91, 112, 119, 126, 133]) == 416\n assert candidate(nums = [1100, 1120, 1122, 1134, 1140, 1155, 1166, 1176, 1183, 1197, 1209, 1225, 1232, 1242, 1254, 1260, 1275]) == 0\n assert candidate(nums = [1485, 1506, 1527, 1548, 1569]) == 4136\n assert candidate(nums = [100, 121, 144, 169, 196, 225]) == 0\n assert candidate(nums = [1275, 1296, 1317, 1338, 1359]) == 1760\n assert candidate(nums = [10001, 10003, 10007, 10009, 10037, 10039, 10061, 10067, 10079]) == 21652\n assert candidate(nums = [1330, 1333, 1343, 1353, 1369]) == 2848\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [1105, 1111, 1122, 1147, 1159]) == 3680\n assert candidate(nums = [100000, 99999, 99997, 99989, 99971, 99959, 99949, 99929, 99907]) == 206104\n assert candidate(nums = [961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600]) == 0\n assert candidate(nums = [100, 121, 143, 169, 189]) == 168\n assert candidate(nums = [12, 18, 20, 24, 30, 36, 40, 42, 44, 45, 48, 50]) == 0\n assert candidate(nums = [435, 456, 477, 498, 519]) == 696\n assert candidate(nums = [540, 561, 582, 603, 624]) == 0\n assert candidate(nums = [11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996]) == 0\n assert candidate(nums = [221, 231, 253, 273, 299]) == 876\n assert candidate(nums = [1380, 1401, 1422, 1443, 1464]) == 1872\n assert candidate(nums = [1820, 1833, 1849, 1859, 1877]) == 0\n assert candidate(nums = [713, 721, 741, 759, 779]) == 2440\n assert candidate(nums = [1170, 1191, 1212, 1233, 1254]) == 1592\n assert candidate(nums = [130, 156, 168, 182, 208, 224, 234]) == 0\n assert candidate(nums = [407, 413, 437, 459, 463]) == 1416\n assert candidate(nums = [29, 41, 53, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 0\n assert candidate(nums = [960, 981, 1002, 1023, 1044]) == 0\n assert candidate(nums = [1363, 1403, 1459, 1489, 1517]) == 4524\n assert candidate(nums = [496, 504, 512, 520, 528]) == 0\n assert candidate(nums = [245, 273, 294, 322, 338, 364, 378]) == 0\n assert candidate(nums = [729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739]) == 2712\n assert candidate(nums = [385, 405, 429, 441, 455, 462, 473, 483, 495]) == 528\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(nums = [1800, 1821, 1842, 1863, 1884]) == 2432\n assert candidate(nums = [100, 121, 144, 169, 196]) == 0\n assert candidate(nums = [1065, 1086, 1107, 1128, 1149]) == 1536\n assert candidate(nums = [1369, 1521, 1681, 1849, 2025, 2209, 2401, 2601, 2809, 3025, 3249]) == 0\n assert candidate(nums = [2115, 2136, 2157, 2178, 2199]) == 5816\n assert candidate(nums = [120, 180, 240, 300, 360]) == 0\n assert candidate(nums = [1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063]) == 0\n assert candidate(nums = [1111, 1189, 1247, 1271, 1309]) == 5148\n assert candidate(nums = [2002, 2014, 2021, 2035, 2047]) == 4272\n assert candidate(nums = [1610, 1619, 1643, 1657, 1679]) == 3504\n assert candidate(nums = [110, 132, 154, 176, 198]) == 0\n assert candidate(nums = [913, 943, 979, 1009, 1037]) == 4212\n assert candidate(nums = [700, 715, 729, 741, 756, 765, 777, 784, 792, 805, 819, 828, 832, 840, 855]) == 0\n assert candidate(nums = [330, 351, 372, 393, 414]) == 528\n assert candidate(nums = [855, 876, 897, 918, 939]) == 1256\n assert candidate(nums = [1155, 1365, 1785, 1995, 2310, 2730, 3003, 3276, 3570]) == 0\n assert candidate(nums = [900, 910, 924, 936, 945, 966, 975, 990, 1001, 1008, 1014, 1029, 1035, 1053, 1056, 1065]) == 0\n assert candidate(nums = [561, 609, 657, 703, 759]) == 760\n assert candidate(nums = [1430, 1441, 1451, 1463, 1481]) == 1584\n assert candidate(nums = [100, 121, 143, 169, 180]) == 168\n assert candidate(nums = [1541, 1547, 1561, 1577, 1589]) == 6928\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(nums = [1925, 1931, 1943, 1946, 1957]) == 4120\n assert candidate(nums = [1729, 1739, 1751, 1763, 1771]) == 5544\n assert candidate(nums = [143, 221, 247, 299, 323]) == 1396\n assert candidate(nums = [1905, 1926, 1947, 1968, 1989]) == 0\n assert candidate(nums = [600, 625, 648, 675, 700, 729, 756, 784, 810, 841, 864, 891]) == 0\n assert candidate(nums = [667, 713, 779, 817, 851]) == 4120\n assert candidate(nums = [65537, 65539, 65543, 65551, 65561, 65579, 65591, 65597]) == 208140\n assert candidate(nums = [645, 666, 687, 708, 729]) == 920\n assert candidate(nums = [105, 126, 147, 168, 189]) == 0\n assert candidate(nums = [1386, 1452, 1518, 1584, 1650]) == 0\n assert candidate(nums = [903, 913, 924, 931, 943]) == 2016\n assert candidate(nums = [841, 961, 1089, 1225, 1369]) == 0\n assert candidate(nums = [609, 621, 637, 651, 671]) == 744\n assert candidate(nums = [121, 125, 143, 147, 169, 175, 182, 189, 196, 209, 221, 225, 245, 253, 265, 275, 287, 299]) == 2100\n assert candidate(nums = [1695, 1716, 1737, 1758, 1779]) == 2376\n assert candidate(nums = [1590, 1611, 1632, 1653, 1674]) == 0\n assert candidate(nums = [496, 672, 728, 840, 924]) == 0\n assert candidate(nums = [121, 144, 169, 196, 225]) == 0\n assert candidate(nums = [1105, 1365, 1615, 1885, 2145, 2415, 2685, 2955, 3225, 3495, 3765]) == 0\n assert candidate(nums = [506, 518, 529, 539, 551]) == 600\n assert candidate(nums = [1331, 1369, 1406, 1444, 1482, 1521, 1562, 1600, 1640, 1681, 1722, 1764]) == 1464\n assert candidate(nums = [406, 429, 455, 462, 494, 518, 546]) == 0\n assert candidate(nums = [45, 60, 77, 84, 91, 99, 100]) == 208\n assert candidate(nums = [325, 351, 375, 399, 425]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 458\n assert candidate(nums = [2010, 2031, 2052, 2073, 2094]) == 5480\n assert candidate(nums = [120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130]) == 686\n assert candidate(nums = [1001, 1007, 1029, 1045, 1067]) == 2256\n assert candidate(nums = [805, 819, 836, 851, 869]) == 1872\n assert candidate(nums = [1221, 1235, 1241, 1254, 1265]) == 1332\n assert candidate(nums = [750, 771, 792, 813, 834]) == 2120\n assert candidate(nums = [703, 707, 713, 725, 729, 735, 741, 745, 749, 759, 763, 779, 783, 799, 803, 805, 815, 825, 833, 835, 837, 841]) == 9572\n assert candidate(nums = [77, 110, 143, 176, 209]) == 504\n assert candidate(nums = [324, 325, 329, 333, 341, 343, 345, 351, 357, 361, 363, 371, 375, 385, 387, 399, 405, 425, 427, 429, 441, 451]) == 2600\n assert candidate(nums = [1021, 1031, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097]) == 0\n assert candidate(nums = [391, 437, 493, 529, 551]) == 2052\n assert candidate(nums = [231, 255, 273, 297, 315, 333, 351]) == 0\n", "comparison": "exact"}, "public_tests": ["[21,4,7]", "[21,21]", "[1,2,3,4,5]"], "hints": ["Find the divisors of each element in the array.", "You only need to loop to the square root of a number to find its divisors."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumFourDivisors", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:45+00:00", "tests_total": 136, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "math", "prime-factorization", "sieve-theory"]}, "language": "python", "interface": {"raw_signature": "def sumFourDivisors(self, nums: list[int]) -> int:", "container": "Solution", "callable": "sumFourDivisors", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1391, "task_id": "check-if-there-is-a-valid-path-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be:\n\n- 1 which means a street connecting the left cell and the right cell.\n- 2 which means a street connecting the upper cell and the lower cell.\n- 3 which means a street connecting the left cell and the lower cell.\n- 4 which means a street connecting the right cell and the lower cell.\n- 5 which means a street connecting the left cell and the upper cell.\n- 6 which means a street connecting the right cell and the upper cell.\n\nYou will initially start at the street of the upper-left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1). The path should only follow the streets.\n\nNotice that you are not allowed to change any street.\n\nReturn true if there is a valid path in the grid or false otherwise.\n\nExample 1:\n\nInput: grid = [[2,4,3],[6,5,2]]\nOutput: true\nExplanation: As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).\n\nExample 2:\n\nInput: grid = [[1,2,1],[1,2,1]]\nOutput: false\nExplanation: As shown you the street at cell (0, 0) is not connected with any street of any other cell and you will get stuck at cell (0, 0)\n\nExample 3:\n\nInput: grid = [[1,1,2]]\nOutput: false\nExplanation: You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 300\n- 1 <= grid[i][j] <= 6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[4, 3, 2, 1], [2, 1, 4, 3], [3, 2, 1, 4]]) == False\n assert candidate(grid = [[2], [2], [2]]) == True\n assert candidate(grid = [[1, 1, 2]]) == False\n assert candidate(grid = [[2, 4, 3], [6, 5, 2]]) == True\n assert candidate(grid = [[4, 1, 3], [6, 1, 6], [3, 2, 4]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 3]]) == True\n assert candidate(grid = [[2, 6, 6, 5], [6, 6, 5, 6], [5, 6, 6, 6], [6, 5, 2, 6]]) == False\n assert candidate(grid = [[1, 3, 5, 1], [1, 2, 1, 2], [1, 2, 1, 2]]) == False\n assert candidate(grid = [[5, 3, 1, 1, 2, 3, 6, 4, 4, 5], [6, 1, 3, 2, 2, 1, 4, 3, 5, 4], [4, 3, 5, 1, 2, 2, 2, 1, 3, 4], [4, 1, 4, 2, 3, 3, 1, 1, 2, 4], [1, 2, 2, 4, 2, 3, 3, 3, 1, 4], [2, 2, 4, 1, 4, 2, 1, 1, 3, 4], [6, 4, 4, 1, 4, 1, 3, 1, 4, 1], [5, 1, 5, 4, 2, 2, 1, 2, 6, 4], [1, 1, 3, 1, 2, 5, 2, 3, 6, 5], [2, 2, 1, 4, 4, 1, 3, 1, 4, 6]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 3]]) == False\n assert candidate(grid = [[1, 2, 1], [1, 2, 1]]) == False\n assert candidate(grid = [[4, 3, 3], [6, 5, 2]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1], [1, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 1], [1, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 1], [1, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 2, 2, 2, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 1, 1, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 6, 1, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 6, 5, 2, 3, 4, 5, 6, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 4, 2, 5, 6], [2, 6, 5, 3, 3], [5, 4, 1, 6, 2], [1, 2, 1, 2, 1], [1, 3, 6, 4, 5]]) == False\n assert candidate(grid = [[3, 1, 1, 2, 2, 5, 2, 1, 5, 4], [4, 6, 5, 3, 5, 1, 6, 1, 4, 1], [2, 4, 2, 6, 1, 3, 2, 1, 6, 5], [1, 4, 2, 1, 5, 4, 2, 6, 3, 1], [2, 5, 1, 4, 6, 2, 3, 1, 5, 4], [1, 3, 4, 2, 1, 6, 5, 4, 2, 3], [4, 2, 1, 5, 4, 2, 1, 6, 5, 1], [2, 5, 1, 4, 6, 2, 3, 1, 4, 2], [5, 1, 4, 2, 1, 5, 4, 2, 1, 6], [6, 3, 2, 1, 5, 4, 1, 6, 5, 3]]) == False\n assert candidate(grid = [[3, 2, 1, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6], [6, 1, 2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[3, 3, 6, 6, 4, 4, 5, 2, 5, 4], [3, 6, 3, 1, 2, 2, 3, 1, 3, 5], [4, 2, 2, 6, 3, 5, 5, 4, 1, 2], [1, 1, 5, 2, 1, 1, 1, 2, 6, 5], [2, 3, 1, 2, 1, 2, 1, 4, 1, 5]]) == False\n assert candidate(grid = [[2, 3, 4, 5, 1, 1, 5, 6, 3, 3], [4, 2, 5, 2, 1, 1, 1, 3, 5, 2], [5, 5, 5, 6, 4, 4, 2, 4, 5, 5], [2, 3, 1, 1, 3, 1, 4, 5, 4, 4], [2, 1, 1, 4, 5, 3, 2, 1, 4, 5], [3, 4, 5, 4, 6, 6, 3, 2, 5, 1], [6, 4, 3, 1, 5, 6, 1, 3, 3, 3], [1, 2, 5, 5, 4, 3, 3, 3, 3, 2], [3, 1, 4, 4, 3, 6, 1, 4, 4, 5], [1, 1, 2, 5, 2, 3, 3, 5, 4, 5]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 6], [3, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4]]) == False\n assert candidate(grid = [[6, 3, 1, 4, 3, 2], [4, 2, 3, 6, 5, 4], [1, 5, 4, 2, 1, 6], [4, 2, 1, 6, 5, 4], [3, 6, 5, 4, 2, 1], [6, 5, 4, 2, 1, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[4, 3, 1, 5, 2, 3, 6, 4, 4, 5], [6, 5, 3, 2, 2, 1, 4, 3, 5, 4], [4, 3, 5, 1, 2, 2, 2, 1, 3, 4], [4, 1, 4, 2, 3, 3, 1, 1, 2, 4], [1, 2, 2, 4, 2, 3, 3, 3, 1, 4], [2, 2, 4, 1, 4, 2, 1, 1, 3, 4], [6, 4, 4, 1, 4, 1, 3, 1, 4, 1], [5, 1, 5, 4, 2, 2, 1, 2, 6, 4], [1, 1, 3, 1, 2, 5, 2, 3, 6, 5], [2, 2, 1, 4, 4, 1, 3, 1, 4, 6]]) == False\n assert candidate(grid = [[2, 5, 3, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2, 4], [4, 3, 2, 1, 6, 5, 3], [3, 2, 1, 6, 5, 4, 2], [6, 5, 4, 2, 1, 4, 3], [5, 4, 2, 1, 6, 5, 1], [2, 1, 6, 5, 4, 2, 6]]) == False\n assert candidate(grid = [[3, 2, 1, 6, 5, 4], [2, 1, 4, 3, 6, 5], [1, 6, 3, 4, 5, 2], [6, 5, 1, 4, 3, 2], [3, 2, 6, 5, 4, 1], [4, 3, 5, 2, 1, 6]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 4, 5, 2, 1, 6, 5, 4], [6, 4, 3, 1, 6, 5, 4, 3], [5, 3, 2, 4, 5, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3], [1, 6, 5, 4, 1, 6, 5, 4], [4, 2, 1, 6, 4, 2, 1, 6], [3, 6, 5, 4, 3, 6, 5, 4], [6, 5, 4, 2, 6, 5, 4, 2]]) == False\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], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == False\n assert candidate(grid = [[5, 6, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[1, 5, 1, 3, 3], [1, 1, 4, 1, 6], [3, 2, 5, 1, 2], [3, 1, 5, 1, 3], [1, 1, 6, 1, 2]]) == False\n assert candidate(grid = [[5, 2, 1, 6], [6, 5, 2, 1], [1, 6, 5, 2], [2, 1, 6, 5]]) == False\n assert candidate(grid = [[1, 4, 3, 6, 2, 6, 1, 1, 6, 6], [6, 6, 2, 2, 4, 4, 4, 6, 1, 6], [3, 6, 1, 1, 3, 6, 6, 1, 6, 5], [6, 3, 2, 2, 3, 6, 6, 5, 1, 1], [1, 4, 6, 3, 4, 6, 3, 2, 6, 3], [6, 5, 5, 4, 2, 3, 3, 4, 1, 6], [6, 6, 1, 5, 2, 5, 6, 3, 4, 4], [4, 5, 6, 5, 2, 3, 5, 6, 3, 4], [1, 3, 4, 6, 5, 6, 5, 3, 5, 6], [6, 4, 6, 1, 5, 6, 4, 4, 4, 4]]) == False\n assert candidate(grid = [[2, 3, 1, 4, 2, 3, 6, 5, 1, 4], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2], [5, 3, 4, 2, 5, 3, 4, 2, 5, 3], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2], [5, 3, 4, 2, 5, 3, 4, 2, 5, 3], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2]]) == False\n assert candidate(grid = [[4, 2, 3, 1, 5, 4, 2, 5, 6, 2], [5, 1, 1, 1, 2, 3, 3, 4, 4, 4], [2, 2, 6, 5, 4, 4, 4, 1, 5, 6], [4, 3, 2, 1, 5, 3, 4, 5, 1, 2], [3, 2, 2, 3, 5, 1, 4, 1, 3, 6], [5, 4, 2, 4, 4, 3, 5, 1, 4, 6], [3, 4, 3, 2, 5, 2, 3, 2, 1, 2], [5, 3, 2, 2, 6, 1, 4, 3, 5, 5], [6, 5, 4, 1, 3, 6, 2, 3, 5, 1], [2, 1, 4, 5, 2, 3, 4, 4, 3, 4]]) == False\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]]) == False\n assert candidate(grid = [[6, 5, 4, 3, 2, 1, 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], [6, 5, 4, 3, 2, 1, 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]]) == False\n assert candidate(grid = [[6, 1, 1, 1, 1, 1, 2, 4, 3, 2], [5, 4, 6, 5, 4, 2, 2, 5, 4, 6], [3, 2, 2, 6, 4, 1, 3, 1, 1, 3], [5, 3, 2, 1, 2, 5, 4, 3, 4, 4], [5, 2, 1, 4, 3, 3, 3, 1, 2, 5], [1, 2, 3, 1, 6, 1, 4, 4, 5, 3], [3, 1, 4, 4, 1, 4, 1, 4, 2, 4], [1, 2, 6, 3, 4, 1, 5, 1, 1, 1], [3, 4, 2, 1, 6, 3, 2, 6, 4, 1], [1, 5, 6, 5, 6, 4, 2, 4, 5, 3]]) == False\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], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == False\n assert candidate(grid = [[5, 2, 3, 1, 2, 6, 4, 4, 5, 3, 1, 2], [3, 1, 5, 4, 2, 3, 2, 1, 5, 4, 2, 3], [2, 6, 4, 3, 6, 5, 3, 5, 4, 3, 6, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 5, 4, 3, 2], [2, 3, 4, 5, 6, 1, 4, 3, 2, 1], [3, 4, 5, 6, 1, 2, 5, 4, 3, 2], [4, 5, 6, 1, 2, 3, 6, 5, 4, 3], [5, 6, 1, 2, 3, 4, 1, 6, 5, 4], [6, 1, 2, 3, 4, 5, 2, 1, 6, 5]]) == False\n assert candidate(grid = [[2, 6, 6, 2, 6, 6, 2, 2, 2, 5], [3, 3, 3, 5, 5, 3, 5, 6, 5, 6], [1, 5, 6, 4, 5, 6, 1, 1, 6, 3], [1, 4, 5, 6, 4, 3, 6, 4, 1, 6], [3, 3, 3, 2, 5, 4, 1, 4, 4, 1], [1, 5, 4, 1, 3, 3, 5, 4, 1, 6], [1, 1, 4, 1, 4, 2, 1, 1, 3, 6], [1, 4, 5, 2, 1, 4, 4, 6, 4, 5], [5, 1, 6, 6, 1, 6, 3, 5, 1, 3], [4, 3, 5, 1, 4, 1, 4, 1, 5, 1]]) == False\n assert candidate(grid = [[1, 3, 6, 2, 6, 5, 6, 1, 3, 6], [1, 4, 5, 2, 5, 1, 3, 5, 2, 1], [5, 4, 5, 2, 3, 3, 3, 2, 6, 4], [4, 4, 1, 1, 6, 2, 4, 3, 4, 4], [4, 1, 6, 5, 3, 5, 1, 5, 4, 3], [6, 6, 3, 4, 2, 3, 5, 5, 2, 3], [3, 2, 2, 2, 5, 1, 4, 5, 3, 2], [1, 2, 2, 3, 1, 4, 5, 1, 3, 1], [6, 4, 1, 2, 1, 6, 4, 5, 2, 6], [2, 5, 4, 3, 1, 6, 2, 1, 1, 6]]) == False\n assert candidate(grid = [[5, 3, 4, 2, 1, 4, 2, 5, 3, 6], [6, 4, 5, 1, 2, 3, 5, 2, 4, 1], [3, 2, 1, 4, 5, 6, 1, 4, 5, 2], [2, 1, 4, 5, 6, 1, 4, 5, 6, 3], [1, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[5, 5, 1, 6, 3, 1, 4, 2, 5, 4], [2, 1, 4, 1, 2, 3, 1, 4, 6, 2], [4, 5, 1, 1, 6, 2, 6, 1, 2, 6], [2, 6, 5, 2, 4, 6, 1, 2, 1, 3], [4, 1, 2, 5, 1, 4, 4, 1, 3, 2], [3, 2, 1, 3, 5, 4, 1, 2, 6, 3], [1, 2, 2, 3, 1, 2, 5, 1, 2, 4], [1, 3, 2, 6, 3, 2, 2, 1, 6, 4], [6, 3, 6, 1, 1, 6, 2, 3, 6, 3], [6, 3, 4, 4, 6, 2, 3, 1, 2, 1]]) == False\n assert candidate(grid = [[2, 3, 6, 5, 5, 4, 5, 1, 1, 4], [2, 1, 5, 5, 2, 1, 5, 5, 1, 3], [1, 5, 4, 2, 4, 3, 3, 4, 5, 4], [3, 6, 5, 6, 4, 1, 3, 3, 2, 2], [5, 2, 4, 1, 4, 2, 5, 5, 6, 6], [1, 2, 4, 6, 6, 4, 5, 5, 4, 4], [4, 1, 2, 4, 1, 4, 5, 6, 4, 6], [3, 5, 5, 6, 3, 4, 5, 4, 1, 1], [3, 5, 3, 2, 3, 2, 4, 1, 6, 5], [4, 1, 4, 1, 5, 3, 3, 5, 3, 3]]) == False\n assert candidate(grid = [[2, 3, 4, 1, 2, 5, 3, 6, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\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, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [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]]) == False\n assert candidate(grid = [[2, 3, 4, 5, 6, 1, 3, 2, 4, 1], [1, 4, 2, 3, 5, 6, 1, 2, 3, 4], [5, 6, 1, 4, 2, 3, 4, 1, 2, 3], [6, 1, 2, 3, 4, 5, 6, 1, 4, 2], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 4, 5, 2], [6, 4, 3, 1], [5, 3, 2, 4], [2, 1, 4, 3]]) == False\n assert candidate(grid = [[1, 4, 2, 3, 6, 5, 4, 1, 2, 6], [5, 3, 1, 2, 1, 1, 4, 2, 3, 5], [4, 2, 1, 5, 4, 2, 1, 3, 6, 1], [1, 6, 2, 3, 1, 5, 4, 1, 2, 4], [2, 5, 1, 2, 6, 3, 1, 6, 4, 1], [5, 3, 4, 1, 6, 1, 2, 5, 1, 3], [1, 2, 6, 3, 1, 4, 1, 6, 2, 1], [4, 2, 1, 5, 4, 2, 3, 1, 6, 5], [3, 6, 1, 2, 4, 1, 5, 4, 2, 3], [2, 1, 5, 4, 1, 3, 1, 6, 2, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\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, 3, 3, 3, 3, 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(grid = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 6], [3, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1], [1, 6, 1, 4, 2], [2, 1, 2, 1, 1], [2, 6, 1, 1, 1], [1, 1, 1, 6, 4]]) == False\n assert candidate(grid = [[6, 4, 5, 2, 1, 3, 3, 1, 4, 6], [2, 4, 6, 5, 1, 1, 4, 3, 3, 2], [5, 5, 5, 4, 3, 2, 1, 4, 1, 3], [1, 1, 5, 2, 4, 4, 1, 4, 3, 5], [6, 1, 2, 1, 6, 3, 2, 2, 5, 3], [1, 4, 6, 3, 3, 4, 2, 4, 1, 3], [4, 4, 1, 2, 5, 1, 5, 3, 5, 2], [2, 3, 1, 1, 1, 1, 5, 4, 5, 5], [4, 2, 2, 3, 5, 5, 5, 4, 6, 6], [2, 4, 3, 6, 3, 2, 3, 5, 6, 5]]) == False\n assert candidate(grid = [[2, 1, 2, 3, 6, 5, 6, 4, 5, 1], [3, 1, 6, 1, 3, 3, 1, 1, 5, 6], [5, 1, 4, 2, 5, 2, 2, 5, 4, 3], [6, 6, 6, 3, 2, 5, 3, 2, 6, 5], [1, 4, 4, 6, 3, 4, 5, 6, 6, 1], [3, 2, 4, 2, 1, 5, 3, 1, 4, 3], [6, 2, 1, 4, 6, 4, 4, 4, 5, 3], [2, 3, 2, 6, 6, 1, 3, 1, 5, 4], [6, 6, 5, 4, 3, 2, 1, 2, 4, 3], [2, 5, 4, 3, 1, 1, 4, 5, 5, 1]]) == False\n assert candidate(grid = [[6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [6, 5, 5, 5, 5, 5, 5, 5, 5, 6], [6, 5, 4, 4, 4, 4, 4, 4, 5, 6], [6, 5, 4, 3, 3, 3, 3, 4, 5, 6], [6, 5, 4, 3, 2, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 6], [6, 5, 4, 3, 2, 1, 6, 5, 6, 6], [6, 5, 4, 3, 2, 1, 6, 6, 6, 6]]) == False\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]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4]]) == False\n assert candidate(grid = [[6, 1, 3, 5, 2, 4, 3, 1, 5, 1], [4, 2, 5, 4, 1, 6, 4, 2, 3, 4], [1, 5, 2, 4, 6, 2, 6, 3, 2, 6], [3, 6, 2, 1, 5, 4, 6, 2, 4, 4], [1, 2, 4, 4, 3, 3, 4, 6, 2, 5], [2, 5, 5, 6, 1, 3, 5, 4, 4, 6], [5, 4, 4, 6, 2, 3, 1, 6, 1, 3], [5, 5, 2, 4, 1, 4, 3, 2, 6, 1], [5, 6, 2, 1, 3, 2, 4, 2, 3, 5], [4, 5, 5, 1, 3, 4, 2, 5, 1, 2]]) == False\n assert candidate(grid = [[6, 2, 1, 3, 5, 4], [4, 5, 6, 1, 2, 3], [3, 2, 1, 6, 5, 4], [2, 1, 4, 3, 5, 6], [5, 6, 3, 2, 4, 1], [1, 4, 2, 5, 3, 6]]) == False\n assert candidate(grid = [[5, 1, 6, 1, 3, 2, 5, 4, 1, 3], [4, 2, 1, 5, 6, 3, 1, 2, 4, 5], [1, 6, 2, 3, 1, 5, 6, 1, 3, 2], [6, 3, 1, 2, 4, 1, 5, 4, 2, 1], [2, 1, 5, 4, 1, 3, 2, 1, 5, 6], [4, 2, 1, 5, 6, 3, 1, 2, 4, 1], [1, 6, 2, 3, 1, 5, 4, 2, 1, 5], [2, 1, 5, 4, 1, 3, 2, 1, 6, 3], [5, 4, 2, 1, 6, 1, 3, 5, 4, 2], [1, 3, 2, 5, 4, 1, 6, 3, 2, 1]]) == False\n assert candidate(grid = [[2, 5, 3, 6, 1, 4], [1, 4, 2, 5, 3, 6], [3, 6, 1, 4, 2, 5], [2, 5, 3, 6, 1, 4], [1, 4, 2, 5, 3, 6]]) == False\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]]) == False\n assert candidate(grid = [[4, 6, 1, 3, 5, 2], [5, 2, 4, 6, 1, 3], [3, 5, 2, 4, 6, 1], [6, 1, 3, 5, 2, 4], [2, 4, 6, 1, 3, 5], [1, 3, 5, 2, 4, 6]]) == False\n assert candidate(grid = [[2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2]]) == False\n assert candidate(grid = [[1, 5, 1, 2, 6, 4, 1, 3, 2, 5], [5, 4, 2, 1, 1, 3, 4, 1, 6, 2], [1, 3, 5, 4, 2, 6, 1, 2, 5, 1], [3, 4, 6, 1, 1, 2, 6, 4, 1, 2], [5, 1, 2, 4, 1, 1, 4, 1, 2, 6], [4, 6, 5, 2, 1, 6, 2, 3, 5, 4], [1, 2, 4, 5, 2, 1, 6, 1, 4, 3], [2, 5, 1, 4, 2, 1, 1, 4, 1, 6], [4, 1, 6, 1, 4, 2, 3, 2, 6, 1], [5, 4, 2, 3, 1, 4, 1, 1, 4, 2]]) == False\n assert candidate(grid = [[5, 4, 3, 6, 1, 2], [2, 1, 4, 3, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3], [3, 2, 1, 6, 5, 4]]) == False\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]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1]]) == False\n assert candidate(grid = [[1, 6, 5, 4, 3, 2, 1, 2, 3, 4], [6, 5, 4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5, 6, 1], [3, 2, 1, 2, 3, 4, 5, 6, 1, 2], [2, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1]]) == False\n assert candidate(grid = [[2, 6, 2, 5, 4, 3, 5, 1, 6, 5], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4], [3, 5, 4, 3, 5, 4, 3, 5, 4, 3], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4]]) == False\n assert candidate(grid = [[1, 2, 5, 6, 3, 4], [4, 3, 2, 1, 6, 5], [5, 6, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 3, 4, 5, 6], [6, 5, 2, 1, 4, 3]]) == False\n assert candidate(grid = [[1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3]]) == False\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]]) == False\n assert candidate(grid = [[5, 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, 1, 1, 1], [1, 1, 1, 1, 1, 5]]) == False\n", "comparison": "exact"}, "public_tests": ["[[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],[2],[2],[2],[2],[2],[2],[2],[2],[2]]", "[[6,2],[3,2],[2,3],[5,6],[4,4],[3,2],[4,4],[2,2],[1,3],[3,5],[6,6],[3,5],[6,1],[6,2],[1,1],[3,6],[5,1],[3,5],[1,4],[1,1],[1,5],[5,5],[3,1],[4,3],[6,3],[3,2],[5,1],[3,5],[4,4],[3,5],[2,5],[6,5],[5,2],[2,6],[6,2],[4,4],[5,5],[3,3],[3,1],[1,4],[5,3],[3,3],[6,3],[4,4],[3,3],[1,5],[4,5],[2,5],[3,2],[5,3],[4,2],[3,1],[1,1],[4,1],[3,2],[5,5],[3,4],[5,3],[2,5],[1,5]]", "[[3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,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,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[6,5,6,5,6,5,6,5,6,5,6,5,6,5,6,5,6,5,6,5,6,5,6,5]]"], "hints": ["Start DFS from the node (0, 0) and follow the path till you stop.", "When you reach a cell and cannot move anymore check that this cell is (m - 1, n - 1) or not."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().hasValidPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:47+00:00", "tests_total": 77, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def hasValidPath(self, grid: list[list[int]]) -> bool:", "container": "Solution", "callable": "hasValidPath", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1392, "task_id": "longest-happy-prefix", "difficulty": "Hard", "problem_description": "A string is called a happy prefix if it is a non-empty prefix which is also a suffix (excluding itself).\n\nGiven a string s, return the longest happy prefix of s. Return an empty string \"\" if no such prefix exists.\n\nExample 1:\n\nInput: s = \"level\"\nOutput: \"l\"\nExplanation: s contains 4 prefix excluding itself (\"l\", \"le\", \"lev\", \"leve\"), and suffix (\"l\", \"el\", \"vel\", \"evel\"). The largest prefix which is also suffix is given by \"l\".\n\nExample 2:\n\nInput: s = \"ababab\"\nOutput: \"abab\"\nExplanation: \"abab\" is the largest prefix which is also suffix. They can overlap in the original string.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"prefixprefix\") == \"prefix\"\n assert candidate(s = \"abcdef\") == \"\"\n assert candidate(s = \"aaaaa\") == \"aaaa\"\n assert candidate(s = \"aaaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"a\") == \"\"\n assert candidate(s = \"abacabadabacaba\") == \"abacaba\"\n assert candidate(s = \"abcabcabc\") == \"abcabc\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabc\"\n assert candidate(s = \"aaaaaabbbaaaa\") == \"aaaa\"\n assert candidate(s = \"happy\") == \"\"\n assert candidate(s = \"noon\") == \"n\"\n assert candidate(s = \"banana\") == \"\"\n assert candidate(s = \"abc\") == \"\"\n assert candidate(s = \"aabbccddeeaabbccdd\") == \"aabbccdd\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"aabbccddeeffgg\") == \"\"\n assert candidate(s = \"suffix\") == \"\"\n assert candidate(s = \"aaaa\") == \"aaa\"\n assert candidate(s = \"mississippi\") == \"\"\n assert candidate(s = \"abcdabc\") == \"abc\"\n assert candidate(s = \"ababab\") == \"abab\"\n assert candidate(s = \"level\") == \"l\"\n assert candidate(s = \"abacababacab\") == \"abacab\"\n assert candidate(s = \"ababababcababab\") == \"ababab\"\n assert candidate(s = \"abacabadabacabadabacaba\") == \"abacabadabacaba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == \"abcdefghijabcdefghijabcdefghij\"\n assert candidate(s = \"bananaananabay\") == \"\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abracadabra\") == \"abra\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdefabcdefabcdef\") == \"abcdefabcdef\"\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabad\"\n assert candidate(s = \"abcabcabcabcabcd\") == \"\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"aababaabaababaaba\") == \"aababaaba\"\n assert candidate(s = \"aaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"zazazazazazazazazazaz\") == \"zazazazazazazazazaz\"\n assert candidate(s = \"abcabcabcabcabcabca\") == \"abcabcabcabcabca\"\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\") == \"abbaabbaabbaabbaabba\"\n assert candidate(s = \"aabaaabaabaaabaabaabaaabaabaab\") == \"aab\"\n assert candidate(s = \"mississippimississippimississippimis\") == \"mississippimississippimis\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"abcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcba\") == \"abcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaabaaaaaab\") == \"\"\n assert candidate(s = \"aaaaabbbbbccccdddd\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"acacacacac\") == \"acacacac\"\n assert candidate(s = \"xyzxyzxyzxyz\") == \"xyzxyzxyz\"\n assert candidate(s = \"mississippimississippi\") == \"mississippi\"\n assert candidate(s = \"aaaaaabbbaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaabbbbbbbaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaananabanana\") == \"banana\"\n assert candidate(s = \"mississippimississippimiss\") == \"mississippimiss\"\n assert candidate(s = \"aabbaabbaabbaabb\") == \"aabbaabbaabb\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacaba\") == \"abacabadabacabadabacabadabacaba\"\n assert candidate(s = \"abcabcabcabcabcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(s = \"zazazazazazaz\") == \"zazazazazaz\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"ababcabababa\") == \"aba\"\n assert candidate(s = \"aaabaaaab\") == \"aaab\"\n assert candidate(s = \"aaaaaaaab\") == \"\"\n assert candidate(s = \"abacabacabac\") == \"abacabac\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"mississippimississippimississippi\") == \"mississippimississippi\"\n assert candidate(s = \"xyzxyzzxyzxyz\") == \"xyzxyz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdabcde\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"ababbababbababbabab\") == \"ababbababbabab\"\n assert candidate(s = \"abcabcabcabcab\") == \"abcabcabcab\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"ababababababab\") == \"abababababab\"\n assert candidate(s = \"abcdeedcba\") == \"a\"\n assert candidate(s = \"aaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abababababababab\") == \"ababababababab\"\n assert candidate(s = \"ababababababababab\") == \"abababababababab\"\n assert candidate(s = \"abcabcabcabcabcabc\") == \"abcabcabcabcabc\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaa\") == \"aaaaaaaaa\"\n assert candidate(s = \"aaaaabaaaabaaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"abababababababababababababab\") == \"ababababababababababababab\"\n assert candidate(s = \"racecaracecarace\") == \"racecarace\"\n assert candidate(s = \"abcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcd\"\n assert candidate(s = \"racecaracecaracecar\") == \"racecaracecar\"\n assert candidate(s = \"abcdeedcbaedcbaedcba\") == \"a\"\n assert candidate(s = \"racecaracecaracecarace\") == \"racecaracecarace\"\n assert candidate(s = \"ababababababababababababa\") == \"abababababababababababa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"racecaracecaracecaracecaracecarace\") == \"racecaracecaracecaracecarace\"\n assert candidate(s = \"aaaaaabaaaaaab\") == \"aaaaaab\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxy\") == \"xyxyxyxyxyxyxyxyxy\"\n assert candidate(s = \"xyxxyxyxyxxyx\") == \"xyxxyx\"\n assert candidate(s = \"zazazazazazaza\") == \"zazazazazaza\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyz\"\n assert candidate(s = \"aabbccddeeffggaabbccddeeffgg\") == \"aabbccddeeffgg\"\n assert candidate(s = \"abcdabcabc\") == \"abc\"\n assert candidate(s = \"aaaaaaaaaab\") == \"\"\n assert candidate(s = \"aaaaaaabaaaaaaaa\") == \"aaaaaaa\"\n assert candidate(s = \"mnopqrstuvutsrqponm\") == \"m\"\n assert candidate(s = \"ababababc\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdefgabcdefg\") == \"abcdefg\"\n assert candidate(s = \"abcdabcabcabcd\") == \"abcd\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == \"abcdeabcdeabcde\"\n assert candidate(s = \"aaaaaaabcabcabc\") == \"\"\n assert candidate(s = \"abcdabcdabcdabcdabcda\") == \"abcdabcdabcdabcda\"\n assert candidate(s = \"abcdabcabcabc\") == \"abc\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaaa\") == \"aaaaaaaaaa\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == \"aabbccddeeff\"\n assert candidate(s = \"aaaaaabaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcdabcabcabcabcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcd\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcab\") == \"abcabcabcabcabcabcab\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababab\") == \"abababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == \"aabbaabbaabbaabb\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"bananaananabananaananaba\") == \"bananaananaba\"\n assert candidate(s = \"aabaaabaabaaabaab\") == \"aabaaabaab\"\n assert candidate(s = \"abcdefghijkllkjihgfedcba\") == \"a\"\n assert candidate(s = \"aabaaab\") == \"aab\"\n assert candidate(s = \"aaaaaaabaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abcdeabcdeabcde\") == \"abcdeabcde\"\n assert candidate(s = \"abcdabcabcde\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"zxyxzyxyzxyxzyxzyz\") == \"z\"\n assert candidate(s = \"ababababab\") == \"abababab\"\n assert candidate(s = \"abababababababababababab\") == \"ababababababababababab\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"axbyczdxcyzbyxa\") == \"a\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == \"abcdefgabcdefg\"\n assert candidate(s = \"abcxyzabcxyzabcxyz\") == \"abcxyzabcxyz\"\n assert candidate(s = \"abcdefghihgfedcba\") == \"a\"\n assert candidate(s = \"racecar\") == \"r\"\n assert candidate(s = \"abcdefghijabcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == \"ababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaabanana\") == \"banana\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"aabaaabaabaaabaabaab\") == \"aab\"\n assert candidate(s = \"ababcabcababc\") == \"ababc\"\n assert candidate(s = \"abababcabababc\") == \"abababc\"\n assert candidate(s = \"abcabcabcabcabc\") == \"abcabcabcabc\"\n assert candidate(s = \"abracadabracadabrac\") == \"abracadabrac\"\n assert candidate(s = \"ababababababababababababababababababab\") == \"abababababababababababababababababab\"\n assert candidate(s = \"xyzxyzyzyzxzyzyzyzyzyz\") == \"\"\n assert candidate(s = \"papapapapapap\") == \"papapapapap\"\n", "comparison": "exact"}, "public_tests": ["\"level\"", "\"ababab\""], "hints": ["Use Longest Prefix Suffix (KMP-table) or String Hashing."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestPrefix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:50+00:00", "tests_total": 162, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "rolling-hash", "string-matching", "hash-function", "z-algorithm", "knuth-morris-pratt-algorithm"]}, "language": "python", "interface": {"raw_signature": "def longestPrefix(self, s: str) -> str:", "container": "Solution", "callable": "longestPrefix", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1394, "task_id": "find-lucky-integer-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.\n\nReturn the largest lucky integer in the array. If there is no lucky integer return -1.\n\nExample 1:\n\nInput: arr = [2,2,3,4]\nOutput: 2\nExplanation: The only lucky number in the array is 2 because frequency[2] == 2.\n\nExample 2:\n\nInput: arr = [1,2,2,3,3,3]\nOutput: 3\nExplanation: 1, 2 and 3 are all lucky numbers, return the largest of them.\n\nExample 3:\n\nInput: arr = [2,2,2,3,3]\nOutput: -1\nExplanation: There are no lucky numbers in the array.\n\nConstraints:\n\n- 1 <= arr.length <= 500\n- 1 <= arr[i] <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1]) == -1\n assert candidate(arr = [5, 5, 4, 4, 4]) == -1\n assert candidate(arr = [5]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [2, 2, 3, 4]) == 2\n assert candidate(arr = [300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(arr = [4, 4, 4, 4]) == 4\n assert candidate(arr = [2, 2, 2, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3]) == 3\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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(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, 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(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [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]) == -1\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\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -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]) == 6\n assert candidate(arr = [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]) == -1\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(arr = [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, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\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, 5]) == -1\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\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, 10]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == -1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [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(arr = [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]) == -1\n assert candidate(arr = [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, 9, 9, 9, 9]) == -1\n assert candidate(arr = [200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == -1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == -1\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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 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(arr = [4, 4, 4, 4, 4, 4, 4, 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(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == -1\n assert candidate(arr = [3, 3, 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\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -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]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -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]) == -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, 7, 7, 7]) == 6\n", "comparison": "exact"}, "public_tests": ["[2,2,3,4]", "[1,2,2,3,3,3]", "[2,2,2,3,3]"], "hints": ["Count the frequency of each integer in the array.", "Get all lucky numbers and return the largest of them."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findLucky", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:52+00:00", "tests_total": 61, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def findLucky(self, arr: list[int]) -> int:", "container": "Solution", "callable": "findLucky", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1395, "task_id": "count-number-of-teams", "difficulty": "Medium", "problem_description": "There are n soldiers standing in a line. Each soldier is assigned a unique rating value.\n\nYou have to form a team of 3 soldiers amongst them under the following rules:\n\n- Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).\n- A team is valid if: (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).\n\nReturn the number of teams you can form given the conditions. (soldiers can be part of multiple teams).\n\nExample 1:\n\nInput: rating = [2,5,3,4,1]\nOutput: 3\nExplanation: We can form three teams given the conditions. (2,3,4), (5,4,1), (5,3,1).\n\nExample 2:\n\nInput: rating = [2,1,3]\nOutput: 0\nExplanation: We can't form any team given the conditions.\n\nExample 3:\n\nInput: rating = [1,2,3,4]\nOutput: 4\n\nConstraints:\n\n- n == rating.length\n- 3 <= n <= 1000\n- 1 <= rating[i] <= 10^5\n- All the integers in rating are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rating = [2, 1, 3]) == 0\n assert candidate(rating = [3, 1, 2, 5, 4]) == 2\n assert candidate(rating = [1, 5, 2, 4, 3]) == 3\n assert candidate(rating = [10, 6, 5, 8]) == 1\n assert candidate(rating = [5, 4, 3, 2, 1]) == 10\n assert candidate(rating = [7, 9, 1, 10, 4, 8]) == 2\n assert candidate(rating = [5, 3, 2, 1, 4]) == 4\n assert candidate(rating = [5, 3, 1, 2, 4]) == 3\n assert candidate(rating = [3, 6, 7, 5, 10, 8]) == 9\n assert candidate(rating = [2, 5, 3, 4, 1]) == 3\n assert candidate(rating = [6, 3, 8, 1, 2, 9, 7]) == 6\n assert candidate(rating = [1, 3, 2, 4, 5]) == 7\n assert candidate(rating = [6, 9, 1, 3, 5, 7, 8, 2, 4]) == 23\n assert candidate(rating = [100, 200, 300, 400, 500]) == 10\n assert candidate(rating = [3, 2, 1, 5, 4]) == 1\n assert candidate(rating = [1, 2, 3, 4]) == 4\n assert candidate(rating = [5, 1, 4, 2, 3]) == 3\n assert candidate(rating = [100, 200, 150, 300, 250, 400, 350]) == 20\n assert candidate(rating = [4, 1, 5, 3, 2, 7, 6, 8, 10, 9]) == 66\n assert candidate(rating = [1, 5, 2, 6, 3, 7, 4, 8, 9]) == 50\n assert candidate(rating = [3, 6, 1, 5, 9, 2, 8, 4, 7, 10]) == 41\n assert candidate(rating = [5, 3, 8, 1, 7, 2, 6, 4]) == 9\n assert candidate(rating = [1, 5, 3, 7, 9, 2, 4, 8, 6, 10]) == 50\n assert candidate(rating = [7, 1, 3, 5, 9, 6, 2, 8, 4]) == 24\n assert candidate(rating = [9, 5, 7, 3, 8, 1, 6, 4, 2, 10]) == 41\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 455\n assert candidate(rating = [100, 200, 150, 250, 300, 10, 50, 350]) == 19\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\n assert candidate(rating = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == 600\n assert candidate(rating = [15, 12, 14, 11, 13, 10, 16, 17, 9, 8, 7, 6]) == 122\n assert candidate(rating = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 88\n assert candidate(rating = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 60, 70, 80, 90, 100, 110]) == 594\n assert candidate(rating = [50, 25, 75, 100, 60, 30, 80, 40, 90]) == 25\n assert candidate(rating = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 40\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 84\n assert candidate(rating = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 120\n assert candidate(rating = [3, 1, 2, 6, 5, 4, 9, 8, 7, 10, 12, 11, 14, 13, 15, 16, 17]) == 537\n assert candidate(rating = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 980\n assert candidate(rating = [2, 1, 3, 6, 5, 4, 8, 7, 9]) == 52\n assert candidate(rating = [3, 1, 2, 4, 6, 5]) == 9\n assert candidate(rating = [5, 7, 9, 3, 6, 2, 8, 4, 1]) == 28\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(rating = [10, 20, 30, 40, 50, 15, 25, 35, 45, 55, 5, 1, 6, 2, 7, 3, 8, 4, 9, 11]) == 320\n assert candidate(rating = [5, 2, 1, 7, 3, 8, 4, 6, 9, 10]) == 57\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 50\n assert candidate(rating = [1, 5, 2, 8, 3, 7, 4, 6]) == 19\n assert candidate(rating = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 430\n assert candidate(rating = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1]) == 525\n assert candidate(rating = [2, 5, 1, 6, 3, 4]) == 3\n assert candidate(rating = [3, 1, 2, 6, 5, 4, 9, 8, 7, 10]) == 63\n assert candidate(rating = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11]) == 170\n assert candidate(rating = [5, 3, 1, 7, 9, 6, 10, 2, 4, 8]) == 30\n assert candidate(rating = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]) == 570\n assert candidate(rating = [15, 25, 10, 20, 5, 30, 35, 50, 45, 40]) == 57\n assert candidate(rating = [5, 1, 2, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 398\n assert candidate(rating = [5, 1, 6, 2, 7, 3, 8, 4, 9, 10]) == 60\n assert candidate(rating = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5]) == 40\n assert candidate(rating = [8, 1, 2, 7, 4, 3, 6, 5]) == 21\n assert candidate(rating = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 60\n assert candidate(rating = [3, 1, 5, 2, 8, 4, 6, 7, 9, 10]) == 71\n assert candidate(rating = [10, 15, 20, 25, 30, 5, 12, 18, 24, 35]) == 44\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 239\n assert candidate(rating = [2, 10, 4, 3, 8, 1, 6, 5]) == 15\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(rating = [15, 18, 12, 19, 21, 14, 22, 20, 23, 24, 25]) == 104\n assert candidate(rating = [7, 6, 9, 10, 5, 8, 2, 1, 4, 3]) == 43\n assert candidate(rating = [5, 2, 8, 3, 1, 9, 4, 6, 7]) == 20\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(rating = [100, 101, 99, 98, 102, 103, 97, 96, 104, 105, 95, 94]) == 98\n assert candidate(rating = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(rating = [5, 50, 15, 40, 25, 35, 10, 20, 30, 45]) == 47\n assert candidate(rating = [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]) == 1350\n assert candidate(rating = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 120\n assert candidate(rating = [5, 3, 7, 1, 9, 4, 6, 8, 2, 10, 11]) == 67\n assert candidate(rating = [20, 50, 40, 60, 10, 70, 30]) == 9\n assert candidate(rating = [20, 30, 10, 40, 50, 15, 25, 35, 45, 5]) == 36\n assert candidate(rating = [30, 20, 10, 50, 40, 60, 80, 70]) == 29\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 455\n assert candidate(rating = [9, 6, 7, 3, 8, 2, 5, 4, 10, 1]) == 47\n assert candidate(rating = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 50\n assert candidate(rating = [8, 1, 2, 3, 4, 5, 6, 7]) == 35\n assert candidate(rating = [5, 3, 7, 1, 9, 2, 8, 4, 6, 10]) == 34\n assert candidate(rating = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]) == 203\n assert candidate(rating = [1, 3, 5, 2, 4, 6, 7]) == 22\n assert candidate(rating = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 444\n assert candidate(rating = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(rating = [2, 1, 3, 6, 5, 7, 4, 8, 9, 10]) == 85\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 84\n assert candidate(rating = [8, 5, 12, 9, 15, 6, 13, 7, 14, 4, 11, 3, 10, 2, 1]) == 179\n assert candidate(rating = [7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(rating = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 978\n assert candidate(rating = [10, 20, 30, 15, 25, 35, 5, 12, 18, 28, 50]) == 56\n assert candidate(rating = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 70\n assert candidate(rating = [1, 2, 10, 4, 3, 8, 7, 9, 6, 5]) == 50\n assert candidate(rating = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 560\n assert candidate(rating = [1, 9, 3, 6, 5, 8, 4, 7, 2]) == 32\n assert candidate(rating = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 21\n assert candidate(rating = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 355\n assert candidate(rating = [1, 2, 3, 5, 4, 6, 8, 7, 9, 10]) == 104\n assert candidate(rating = [50, 25, 75, 10, 40, 60, 90, 5, 30, 65, 80, 100, 15, 45, 70, 85, 95]) == 238\n assert candidate(rating = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(rating = [13, 11, 9, 7, 5, 3, 1]) == 35\n assert candidate(rating = [9, 5, 3, 7, 2, 8, 1, 6, 4, 10]) == 37\n assert candidate(rating = [20, 18, 19, 15, 17, 13, 16, 12, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1036\n assert candidate(rating = [100, 200, 150, 300, 50, 400, 250, 350, 10, 20]) == 35\n", "comparison": "exact"}, "public_tests": ["[2,5,3,4,1]", "[2,1,3]", "[1,2,3,4]"], "hints": ["BruteForce, check all possibilities."], "metadata": {"canonical_parameter_names": ["rating"], "leetcode_dataset_entry_point": "Solution().numTeams", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:54+00:00", "tests_total": 114, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "dynamic-programming", "binary-indexed-tree", "segment-tree"]}, "language": "python", "interface": {"raw_signature": "def numTeams(self, rating: list[int]) -> int:", "container": "Solution", "callable": "numTeams", "parameters": [{"name": "rating", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1397, "task_id": "find-all-good-strings", "difficulty": "Hard", "problem_description": "Given the strings s1 and s2 of size n and the string evil, return the number of good strings.\n\nA good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 2, s1 = \"aa\", s2 = \"da\", evil = \"b\"\nOutput: 51\nExplanation: There are 25 good strings starting with 'a': \"aa\",\"ac\",\"ad\",...,\"az\". Then there are 25 good strings starting with 'c': \"ca\",\"cc\",\"cd\",...,\"cz\" and finally there is one good string starting with 'd': \"da\".\n\nExample 2:\n\nInput: n = 8, s1 = \"leetcode\", s2 = \"leetgoes\", evil = \"leet\"\nOutput: 0\nExplanation: All strings greater than or equal to s1 and smaller than or equal to s2 start with the prefix \"leet\", therefore, there is not any good string.\n\nExample 3:\n\nInput: n = 2, s1 = \"gx\", s2 = \"gz\", evil = \"x\"\nOutput: 2\n\nConstraints:\n\n- s1.length == n\n- s2.length == n\n- s1 <= s2\n- 1 <= n <= 500\n- 1 <= evil.length <= 50\n- All strings consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"app\") == 11220078\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"abc\") == 17575\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"abc\") == 11879348\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"abcdefghij\",evil = \"ghij\") == 0\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"dog\") == 11219789\n assert candidate(n = 2,s1 = \"gx\",s2 = \"gz\",evil = \"x\") == 2\n assert candidate(n = 3,s1 = \"abc\",s2 = \"xyz\",evil = \"def\") == 16169\n assert candidate(n = 8,s1 = \"leetcode\",s2 = \"leetgoes\",evil = \"leet\") == 0\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"xyz\") == 17575\n assert candidate(n = 2,s1 = \"aa\",s2 = \"da\",evil = \"b\") == 51\n assert candidate(n = 3,s1 = \"abc\",s2 = \"xyz\",evil = \"de\") == 16120\n assert candidate(n = 10,s1 = \"aaaaaaaaaa\",s2 = \"zzzzzzzzzz\",evil = \"mnop\") == 932258852\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"zzzzzzzzzz\",evil = \"mnop\") == 67339166\n assert candidate(n = 6,s1 = \"aaaaaa\",s2 = \"zzzzzz\",evil = \"ab\") == 306634951\n assert candidate(n = 7,s1 = \"aaaaaaa\",s2 = \"zzzzzzz\",evil = \"abc\") == 29525318\n assert candidate(n = 20,s1 = \"abcdabcdabcdabcdabcd\",s2 = \"zzzzzzzzzzzzzzzzzzzz\",evil = \"zabcd\") == 426896930\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"abcdefghiz\",evil = \"ghi\") == 0\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"zjklmnopqr\",evil = \"mnop\") == 922212598\n assert candidate(n = 40,s1 = \"abcdefghijabcdefghijabcdefghijabcdefghij\",s2 = \"zjklmnopqrzjklmnopqrzjklmnopqrzjklmnopqr\",evil = \"mnopqr\") == 54391096\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"b\") == 9765625\n", "comparison": "exact"}, "public_tests": ["2\n\"aa\"\n\"da\"\n\"b\"", "8\n\"leetcode\"\n\"leetgoes\"\n\"leet\"", "2\n\"gx\"\n\"gz\"\n\"x\""], "hints": ["Use DP with 4 states (pos: Int, posEvil: Int, equalToS1: Bool, equalToS2: Bool) which compute the number of valid strings of size \"pos\" where the maximum common suffix with string \"evil\" has size \"posEvil\". When \"equalToS1\" is \"true\", the current valid string is equal to \"S1\" otherwise it is greater. In a similar way when equalToS2 is \"true\" the current valid string is equal to \"S2\" otherwise it is smaller.", "To update the maximum common suffix with string \"evil\" use KMP preprocessing."], "metadata": {"canonical_parameter_names": ["n", "s1", "s2", "evil"], "leetcode_dataset_entry_point": "Solution().findGoodStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:57+00:00", "tests_total": 29, "tests_dropped": 9, "flags": [], "topic_tags": ["string", "dynamic-programming", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def findGoodStrings(self, n: int, s1: str, s2: str, evil: str) -> int:", "container": "Solution", "callable": "findGoodStrings", "parameters": [{"name": "n", "type": "int"}, {"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}, {"name": "evil", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1399, "task_id": "count-largest-group", "difficulty": "Easy", "problem_description": "You are given an integer n.\n\nWe need to group the numbers from 1 to n according to the sum of its digits. For example, the numbers 14 and 5 belong to the same group, whereas 13 and 3 belong to different groups.\n\nReturn the number of groups that have the largest size, i.e. the maximum number of elements.\n\nExample 1:\n\nInput: n = 13\nOutput: 4\nExplanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:\n[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9].\nThere are 4 groups with largest size.\n\nExample 2:\n\nInput: n = 2\nOutput: 2\nExplanation: There are 2 groups [1], [2] of size 1.\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 200) == 2\n assert candidate(n = 10000) == 1\n assert candidate(n = 9) == 9\n assert candidate(n = 104) == 1\n assert candidate(n = 9999) == 1\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 1\n assert candidate(n = 1000) == 2\n assert candidate(n = 13) == 4\n assert candidate(n = 25) == 6\n assert candidate(n = 4000) == 1\n assert candidate(n = 2345) == 1\n assert candidate(n = 1111) == 1\n assert candidate(n = 7000) == 2\n assert candidate(n = 4096) == 1\n assert candidate(n = 7500) == 1\n assert candidate(n = 4567) == 1\n assert candidate(n = 2000) == 1\n assert candidate(n = 111) == 1\n assert candidate(n = 8888) == 1\n assert candidate(n = 300) == 1\n assert candidate(n = 333) == 2\n assert candidate(n = 3000) == 2\n assert candidate(n = 99) == 1\n assert candidate(n = 888) == 1\n assert candidate(n = 1024) == 2\n assert candidate(n = 8192) == 1\n assert candidate(n = 999) == 2\n assert candidate(n = 5555) == 1\n assert candidate(n = 8000) == 1\n assert candidate(n = 5000) == 2\n assert candidate(n = 6543) == 1\n assert candidate(n = 7865) == 1\n assert candidate(n = 7777) == 1\n assert candidate(n = 2222) == 1\n assert candidate(n = 2500) == 1\n assert candidate(n = 9000) == 2\n assert candidate(n = 4999) == 2\n assert candidate(n = 3999) == 1\n assert candidate(n = 1234) == 1\n assert candidate(n = 6000) == 1\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 1\n assert candidate(n = 10) == 1\n assert candidate(n = 1500) == 1\n", "comparison": "exact"}, "public_tests": ["13", "2"], "hints": ["Count the digit sum for each integer in the range and find out the largest groups."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countLargestGroup", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:18:59+00:00", "tests_total": 45, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "math", "counting"]}, "language": "python", "interface": {"raw_signature": "def countLargestGroup(self, n: int) -> int:", "container": "Solution", "callable": "countLargestGroup", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1400, "task_id": "construct-k-palindrome-strings", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.\n\nExample 1:\n\nInput: s = \"annabelle\", k = 2\nOutput: true\nExplanation: You can construct two palindromes using all characters in s.\nSome possible constructions \"anna\" + \"elble\", \"anbna\" + \"elle\", \"anellena\" + \"b\"\n\nExample 2:\n\nInput: s = \"leetcode\", k = 3\nOutput: false\nExplanation: It is impossible to construct 3 palindromes using all the characters of s.\n\nExample 3:\n\nInput: s = \"true\", k = 4\nOutput: true\nExplanation: The only possible solution is to put each character in a separate string.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n- 1 <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a\",k = 2) == False\n assert candidate(s = \"aabbcc\",k = 3) == True\n assert candidate(s = \"abcd\",k = 2) == False\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 17) == False\n assert candidate(s = \"true\",k = 4) == True\n assert candidate(s = \"aaaaa\",k = 2) == True\n assert candidate(s = \"racecar\",k = 1) == True\n assert candidate(s = \"abcd\",k = 1) == False\n assert candidate(s = \"abacabadabacaba\",k = 7) == True\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 2) == True\n assert candidate(s = \"aabbcc\",k = 6) == True\n assert candidate(s = \"annabelle\",k = 2) == True\n assert candidate(s = \"aabbc\",k = 4) == True\n assert candidate(s = \"leetcode\",k = 3) == False\n assert candidate(s = \"aabbccddeeffgghh\",k = 8) == True\n assert candidate(s = \"aaa\",k = 3) == True\n assert candidate(s = \"z\",k = 1) == True\n assert candidate(s = \"abcabcabc\",k = 3) == True\n assert candidate(s = \"aaaaaa\",k = 1) == True\n assert candidate(s = \"a\",k = 1) == True\n assert candidate(s = \"aabb\",k = 2) == True\n assert candidate(s = \"aabbcc\",k = 1) == True\n assert candidate(s = \"abcd\",k = 4) == True\n assert candidate(s = \"aabbc\",k = 3) == True\n assert candidate(s = \"palindrome\",k = 2) == False\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == True\n assert candidate(s = \"mississippi\",k = 4) == True\n assert candidate(s = \"abacabadabacabadabacabad\",k = 10) == True\n assert candidate(s = \"racecar\",k = 5) == True\n assert candidate(s = \"aaabbbccc\",k = 5) == True\n assert candidate(s = \"zyxzyxzyx\",k = 3) == True\n assert candidate(s = \"palindromicracecar\",k = 7) == False\n assert candidate(s = \"level\",k = 1) == True\n assert candidate(s = \"mamad\",k = 3) == True\n assert candidate(s = \"ababababab\",k = 5) == True\n assert candidate(s = \"amanaplanacanalpanama\",k = 13) == True\n assert candidate(s = \"aabbccddeeffgg\",k = 8) == True\n assert candidate(s = \"aabbccddeeffgghhiijj\",k = 10) == True\n assert candidate(s = \"aabaaaacaabbaaaacaaba\",k = 15) == True\n assert candidate(s = \"aabbccddeeefff\",k = 6) == True\n assert candidate(s = \"abcdefghij\",k = 10) == True\n assert candidate(s = \"aabaaa\",k = 3) == True\n assert candidate(s = \"xyxxyxyxyxyxyx\",k = 7) == True\n assert candidate(s = \"palindrome\",k = 5) == False\n assert candidate(s = \"racecarannakayak\",k = 5) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 16) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"noonnoonnoon\",k = 3) == True\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababab\",k = 100) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == True\n assert candidate(s = \"bananaananabananaananabanana\",k = 12) == True\n assert candidate(s = \"mississippi\",k = 5) == True\n assert candidate(s = \"neupq\",k = 5) == True\n assert candidate(s = \"babbabababababa\",k = 11) == True\n assert candidate(s = \"abcabcabcabcabcabc\",k = 9) == True\n assert candidate(s = \"aaaaaaaaaa\",k = 10) == True\n assert candidate(s = \"noonnoonnoon\",k = 6) == True\n assert candidate(s = \"racecarannakayak\",k = 3) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 52) == True\n assert candidate(s = \"abcabcabc\",k = 9) == True\n assert candidate(s = \"banana\",k = 3) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == True\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 26) == True\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\",k = 20) == True\n assert candidate(s = \"noon\",k = 2) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"palindrome\",k = 6) == False\n assert candidate(s = \"mississippiissim\",k = 6) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"abcdabcdeabcdabcdef\",k = 7) == True\n assert candidate(s = \"abababababababababababababab\",k = 12) == True\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 20) == True\n assert candidate(s = \"abcdabcdabcdabcd\",k = 8) == True\n assert candidate(s = \"aabbccccddeeeeffff\",k = 7) == True\n assert candidate(s = \"xyzzycba\",k = 6) == True\n assert candidate(s = \"aabbccddeeffgg\",k = 14) == True\n assert candidate(s = \"noonmoon\",k = 2) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 30) == True\n assert candidate(s = \"racecarr\",k = 2) == True\n assert candidate(s = \"aabaaabbbbccccddddd\",k = 11) == True\n assert candidate(s = \"zzzzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhhgggffeeddccbbaa\",k = 26) == True\n assert candidate(s = \"abracadabra\",k = 5) == True\n assert candidate(s = \"abababababababababababababababababababababab\",k = 20) == True\n assert candidate(s = \"mammamia\",k = 2) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == False\n assert candidate(s = \"zyxzyxzyxzyx\",k = 12) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == False\n assert candidate(s = \"abcdabcdbabcdbcdbabcdabcdabcd\",k = 10) == True\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 26) == True\n assert candidate(s = \"aaabbbcccdddeeefffggghhhhiiiiiijjjjjjjkkkkkkkkkllllllllll\",k = 25) == True\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",k = 10) == True\n assert candidate(s = \"thisisaverylongstringwithsomerepeatedcharacters\",k = 15) == True\n assert candidate(s = \"aabbbccccdddddeeeeeffffffgggggghhhhhiiiiijjjjjkkkkklllllm\",k = 14) == True\n assert candidate(s = \"xyzxyzxyz\",k = 9) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaaa\",k = 27) == True\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 26) == True\n", "comparison": "exact"}, "public_tests": ["\"annabelle\"\n2", "\"leetcode\"\n3", "\"true\"\n4"], "hints": ["If the s.length < k we cannot construct k strings from s and answer is false.", "If the number of characters that have odd counts is > k then the minimum number of palindrome strings we can construct is > k and answer is false.", "Otherwise you can construct exactly k palindrome strings and answer is true (why ?)."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().canConstruct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:01+00:00", "tests_total": 100, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "greedy", "counting"]}, "language": "python", "interface": {"raw_signature": "def canConstruct(self, s: str, k: int) -> bool:", "container": "Solution", "callable": "canConstruct", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1401, "task_id": "circle-and-rectangle-overlapping", "difficulty": "Medium", "problem_description": "You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.\n\nReturn true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (x_i, y_i) that belongs to the circle and the rectangle at the same time.\n\nExample 1:\n\nInput: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1\nOutput: true\nExplanation: Circle and rectangle share the point (1,0).\n\nExample 2:\n\nInput: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1\nOutput: false\n\nExample 3:\n\nInput: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1\nOutput: true\n\nConstraints:\n\n- 1 <= radius <= 2000\n- -10^4 <= xCenter, yCenter <= 10^4\n- -10^4 <= x1 < x2 <= 10^4\n- -10^4 <= y1 < y2 <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(radius = 3,xCenter = -3,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1 = -5,y1 = -5,x2 = 5,y2 = 5) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = -1,x2 = 3,y2 = 1) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = 0,x2 = 0,y2 = 1) == True\n assert candidate(radius = 2,xCenter = 3,yCenter = 4,x1 = 0,y1 = 0,x2 = 2,y2 = 2) == False\n assert candidate(radius = 3,xCenter = -3,yCenter = 4,x1 = -5,y1 = 1,x2 = -1,y2 = 8) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -4,y1 = -4,x2 = 0,y2 = 0) == True\n assert candidate(radius = 1,xCenter = 1,yCenter = 1,x1 = 1,y1 = -3,x2 = 2,y2 = -1) == False\n assert candidate(radius = 5,xCenter = 5,yCenter = 5,x1 = 0,y1 = 0,x2 = 10,y2 = 10) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = -10,x1 = -20,y1 = -20,x2 = -5,y2 = -5) == True\n assert candidate(radius = 8,xCenter = -20,yCenter = -20,x1 = -25,y1 = -25,x2 = -15,y2 = -15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = -1,x2 = 1,y2 = 1) == True\n assert candidate(radius = 25,xCenter = -30,yCenter = 30,x1 = -50,y1 = 10,x2 = -10,y2 = 50) == True\n assert candidate(radius = 100,xCenter = 1000,yCenter = 1000,x1 = 900,y1 = 900,x2 = 1050,y2 = 1050) == True\n assert candidate(radius = 4,xCenter = 1,yCenter = 1,x1 = -2,y1 = -2,x2 = 2,y2 = 2) == True\n assert candidate(radius = 3,xCenter = 0,yCenter = 0,x1 = -3,y1 = -3,x2 = 3,y2 = 3) == True\n assert candidate(radius = 1,xCenter = 10,yCenter = 10,x1 = 11,y1 = 11,x2 = 13,y2 = 13) == False\n assert candidate(radius = 1,xCenter = -4,yCenter = -4,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 20,xCenter = 50,yCenter = 50,x1 = 20,y1 = 20,x2 = 80,y2 = 80) == True\n assert candidate(radius = 7,xCenter = 2500,yCenter = -2500,x1 = 2490,y1 = -2510,x2 = 2510,y2 = -2490) == True\n assert candidate(radius = 12,xCenter = 18,yCenter = 18,x1 = 10,y1 = 10,x2 = 26,y2 = 26) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -20,y1 = -20,x2 = 20,y2 = 20) == True\n assert candidate(radius = 7,xCenter = 0,yCenter = 0,x1 = -8,y1 = -8,x2 = 8,y2 = 8) == True\n assert candidate(radius = 1,xCenter = 2,yCenter = 3,x1 = 1,y1 = 2,x2 = 3,y2 = 4) == True\n assert candidate(radius = 9,xCenter = 0,yCenter = -1,x1 = -5,y1 = -10,x2 = 5,y2 = -5) == True\n assert candidate(radius = 15,xCenter = 25,yCenter = -25,x1 = 15,y1 = -35,x2 = 35,y2 = -15) == True\n assert candidate(radius = 4,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 10,xCenter = -15,yCenter = -15,x1 = -25,y1 = -25,x2 = -5,y2 = -5) == True\n assert candidate(radius = 2,xCenter = 3,yCenter = 4,x1 = 2,y1 = 3,x2 = 4,y2 = 5) == True\n assert candidate(radius = 1,xCenter = 5,yCenter = 0,x1 = 4,y1 = -1,x2 = 6,y2 = 1) == True\n assert candidate(radius = 12,xCenter = -200,yCenter = 200,x1 = -220,y1 = 180,x2 = -180,y2 = 220) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = -1,x2 = 0,y2 = 0) == True\n assert candidate(radius = 100,xCenter = -500,yCenter = 500,x1 = -600,y1 = 400,x2 = -400,y2 = 600) == True\n assert candidate(radius = 4,xCenter = 0,yCenter = 0,x1 = 4,y1 = 4,x2 = 5,y2 = 5) == False\n assert candidate(radius = 10,xCenter = -10,yCenter = -10,x1 = -20,y1 = -20,x2 = 0,y2 = 0) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -5,y1 = -5,x2 = 5,y2 = 5) == True\n assert candidate(radius = 9,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 6,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = 0,y2 = 10) == True\n assert candidate(radius = 2,xCenter = 5,yCenter = 5,x1 = 3,y1 = 3,x2 = 7,y2 = 7) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -2001,y1 = -2001,x2 = 2001,y2 = 2001) == True\n assert candidate(radius = 3,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 2,y1 = 2,x2 = 3,y2 = 3) == False\n assert candidate(radius = 500,xCenter = 5000,yCenter = 5000,x1 = 4500,y1 = 4500,x2 = 5500,y2 = 5500) == True\n assert candidate(radius = 2,xCenter = -100,yCenter = 100,x1 = -110,y1 = 90,x2 = -90,y2 = 110) == True\n assert candidate(radius = 4,xCenter = -10,yCenter = 10,x1 = -15,y1 = 5,x2 = -5,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 500,yCenter = 500,x1 = 499,y1 = 499,x2 = 501,y2 = 501) == True\n assert candidate(radius = 20,xCenter = 0,yCenter = 0,x1 = -30,y1 = -30,x2 = 30,y2 = 30) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -2,y1 = -2,x2 = -1,y2 = -1) == False\n assert candidate(radius = 2,xCenter = 0,yCenter = 0,x1 = 0,y1 = 0,x2 = 4,y2 = 4) == True\n assert candidate(radius = 10,xCenter = 20,yCenter = 20,x1 = 15,y1 = 15,x2 = 25,y2 = 25) == True\n assert candidate(radius = 2,xCenter = -6,yCenter = -6,x1 = -10,y1 = -10,x2 = -5,y2 = -5) == True\n assert candidate(radius = 12,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 1,xCenter = -10,yCenter = -10,x1 = -13,y1 = -13,x2 = -11,y2 = -11) == False\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = 1,x2 = 2,y2 = 2) == False\n assert candidate(radius = 6,xCenter = -2,yCenter = 4,x1 = -6,y1 = 0,x2 = 0,y2 = 6) == True\n assert candidate(radius = 5,xCenter = 25,yCenter = 25,x1 = 20,y1 = 20,x2 = 30,y2 = 30) == True\n assert candidate(radius = 15,xCenter = 15,yCenter = 15,x1 = 20,y1 = 20,x2 = 30,y2 = 30) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -3,x1 = -4,y1 = -5,x2 = -3,y2 = -4) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -10000,y1 = -10000,x2 = 10000,y2 = 10000) == True\n assert candidate(radius = 8,xCenter = 12,yCenter = 12,x1 = 8,y1 = 8,x2 = 16,y2 = 16) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = 10,x1 = -20,y1 = -10,x2 = 0,y2 = 10) == True\n assert candidate(radius = 300,xCenter = -750,yCenter = 750,x1 = -1000,y1 = 500,x2 = -500,y2 = 1000) == True\n assert candidate(radius = 3,xCenter = 20,yCenter = -20,x1 = 15,y1 = -25,x2 = 25,y2 = -15) == True\n assert candidate(radius = 15,xCenter = 50,yCenter = 50,x1 = 40,y1 = 40,x2 = 60,y2 = 60) == True\n assert candidate(radius = 2000,xCenter = 5000,yCenter = 5000,x1 = 0,y1 = 0,x2 = 10000,y2 = 10000) == True\n assert candidate(radius = 5,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 4,xCenter = -4,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 15,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 3,xCenter = -3,yCenter = 3,x1 = -6,y1 = 0,x2 = 0,y2 = 6) == True\n assert candidate(radius = 8,xCenter = 100,yCenter = -100,x1 = 90,y1 = -110,x2 = 110,y2 = -90) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -3000,y1 = -3000,x2 = 3000,y2 = 3000) == True\n assert candidate(radius = 10,xCenter = 5,yCenter = 5,x1 = 0,y1 = 0,x2 = 10,y2 = 10) == True\n assert candidate(radius = 1500,xCenter = 5000,yCenter = 5000,x1 = 4500,y1 = 4500,x2 = 5500,y2 = 5500) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 0,y1 = 0,x2 = 2,y2 = 2) == True\n assert candidate(radius = 7,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = -2,y2 = 10) == True\n assert candidate(radius = 4,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = 0,y2 = 10) == True\n assert candidate(radius = 10,xCenter = -5,yCenter = -5,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == False\n assert candidate(radius = 500,xCenter = 2500,yCenter = -2500,x1 = 2000,y1 = -3000,x2 = 3000,y2 = -2000) == True\n assert candidate(radius = 5,xCenter = 1,yCenter = 1,x1 = -3,y1 = -3,x2 = 3,y2 = 3) == True\n assert candidate(radius = 2000,xCenter = 1000,yCenter = 1000,x1 = 900,y1 = 900,x2 = 1100,y2 = 1100) == True\n assert candidate(radius = 150,xCenter = 0,yCenter = 0,x1 = -200,y1 = -200,x2 = 200,y2 = 200) == True\n assert candidate(radius = 6,xCenter = -15,yCenter = -15,x1 = -20,y1 = -20,x2 = -10,y2 = -10) == True\n assert candidate(radius = 4,xCenter = 2,yCenter = 2,x1 = -1,y1 = -1,x2 = 3,y2 = 3) == True\n assert candidate(radius = 2,xCenter = 100,yCenter = 100,x1 = 101,y1 = 101,x2 = 103,y2 = 103) == True\n assert candidate(radius = 3,xCenter = 5,yCenter = 5,x1 = 8,y1 = 8,x2 = 12,y2 = 12) == False\n assert candidate(radius = 5,xCenter = -10,yCenter = -10,x1 = -15,y1 = -15,x2 = -5,y2 = -5) == True\n assert candidate(radius = 2,xCenter = 2,yCenter = 2,x1 = 1,y1 = 1,x2 = 3,y2 = 3) == True\n assert candidate(radius = 1,xCenter = 2,yCenter = 2,x1 = 3,y1 = 3,x2 = 5,y2 = 5) == False\n assert candidate(radius = 2,xCenter = -5,yCenter = -5,x1 = -10,y1 = -10,x2 = -2,y2 = -2) == True\n assert candidate(radius = 7,xCenter = -5,yCenter = -5,x1 = -10,y1 = -10,x2 = -2,y2 = -2) == True\n assert candidate(radius = 15,xCenter = -100,yCenter = -100,x1 = -120,y1 = -120,x2 = -80,y2 = -80) == True\n assert candidate(radius = 8,xCenter = 10,yCenter = -10,x1 = 5,y1 = -15,x2 = 15,y2 = -5) == True\n assert candidate(radius = 20,xCenter = -30,yCenter = 30,x1 = -40,y1 = 20,x2 = -20,y2 = 40) == True\n assert candidate(radius = 2,xCenter = 6,yCenter = 6,x1 = 0,y1 = 0,x2 = 5,y2 = 5) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = 10,x1 = -20,y1 = -20,x2 = 0,y2 = 0) == True\n assert candidate(radius = 7,xCenter = 5,yCenter = -5,x1 = 0,y1 = -10,x2 = 10,y2 = 0) == True\n assert candidate(radius = 2,xCenter = 0,yCenter = 0,x1 = -3,y1 = -3,x2 = -2,y2 = -2) == False\n assert candidate(radius = 7,xCenter = 3,yCenter = -3,x1 = 1,y1 = -5,x2 = 5,y2 = -1) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -15,y1 = -15,x2 = 15,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = 0,x2 = 2,y2 = 1) == True\n assert candidate(radius = 2000,xCenter = -5000,yCenter = -5000,x1 = -10000,y1 = -10000,x2 = 0,y2 = 0) == True\n assert candidate(radius = 4,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 50,xCenter = -100,yCenter = 100,x1 = -150,y1 = 50,x2 = -50,y2 = 150) == True\n", "comparison": "exact"}, "public_tests": ["1\n0\n0\n1\n-1\n3\n1", "1\n1\n1\n1\n-3\n2\n-1", "1\n0\n0\n-1\n0\n0\n1"], "hints": ["Locate the closest point of the square to the circle, you can then find the distance from this point to the center of the circle and check if this is less than or equal to the radius."], "metadata": {"canonical_parameter_names": ["radius", "xCenter", "yCenter", "x1", "y1", "x2", "y2"], "leetcode_dataset_entry_point": "Solution().checkOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:03+00:00", "tests_total": 114, "tests_dropped": 8, "flags": ["has_images"], "topic_tags": ["math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def checkOverlap(self, radius: int, xCenter: int, yCenter: int, x1: int, y1: int, x2: int, y2: int) -> bool:", "container": "Solution", "callable": "checkOverlap", "parameters": [{"name": "radius", "type": "int"}, {"name": "xCenter", "type": "int"}, {"name": "yCenter", "type": "int"}, {"name": "x1", "type": "int"}, {"name": "y1", "type": "int"}, {"name": "x2", "type": "int"}, {"name": "y2", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1402, "task_id": "reducing-dishes", "difficulty": "Hard", "problem_description": "A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.\n\nLike-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].\n\nReturn the maximum sum of like-time coefficient that the chef can obtain after preparing some amount of dishes.\n\nDishes can be prepared in any order and the chef can discard some dishes to get this maximum value.\n\nExample 1:\n\nInput: satisfaction = [-1,-8,0,5,-9]\nOutput: 14\nExplanation: After Removing the second and last dish, the maximum total like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14).\nEach dish is prepared in one unit of time.\n\nExample 2:\n\nInput: satisfaction = [4,3,2]\nOutput: 20\nExplanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)\n\nExample 3:\n\nInput: satisfaction = [-1,-4,-5]\nOutput: 0\nExplanation: People do not like the dishes. No dish is prepared.\n\nConstraints:\n\n- n == satisfaction.length\n- 1 <= n <= 500\n- -1000 <= satisfaction[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(satisfaction = [0]) == 0\n assert candidate(satisfaction = [-1]) == 0\n assert candidate(satisfaction = [-500, -500, -500, -500, -500]) == 0\n assert candidate(satisfaction = [0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-1000, 1000, -500, 500]) == 3500\n assert candidate(satisfaction = [0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [1000, -1000, 1000, -1000, 1000]) == 9000\n assert candidate(satisfaction = [-1, -8, 0, 5, -9]) == 14\n assert candidate(satisfaction = [-10, -20, -30, 10, 20, 30]) == 220\n assert candidate(satisfaction = [1, 2, 3, 4, 5]) == 55\n assert candidate(satisfaction = [100, 200, 300, 400, 500]) == 5500\n assert candidate(satisfaction = [-10, -20, -30, -40, -50]) == 0\n assert candidate(satisfaction = [4, 3, 2]) == 20\n assert candidate(satisfaction = [500, 500, 500, 500, 500]) == 7500\n assert candidate(satisfaction = [-1000, 1000]) == 1000\n assert candidate(satisfaction = [-1, -4, -5]) == 0\n assert candidate(satisfaction = [-5, -4, -3, -2, -1]) == 0\n assert candidate(satisfaction = [-500, -400, -300, -200, -100]) == 0\n assert candidate(satisfaction = [1000, -1000, 1000, -1000, 1000]) == 9000\n assert candidate(satisfaction = [1]) == 1\n assert candidate(satisfaction = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(satisfaction = [1000, -1000, 1000, -1000]) == 4000\n assert candidate(satisfaction = [5, -1, 3, 2, -2, 1]) == 52\n assert candidate(satisfaction = [10, 9, 8, 7, 6, 5, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 415\n assert candidate(satisfaction = [100, -90, 50, -40, 30, -20, 10, -5, 0]) == 1320\n assert candidate(satisfaction = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 13600\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 715\n assert candidate(satisfaction = [-500, -499, -498, -497, -496, -495, -494, -493, -492, -491, -490, -489, -488, -487, -486]) == 0\n assert candidate(satisfaction = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 155\n assert candidate(satisfaction = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995]) == 24945\n assert candidate(satisfaction = [999, 1000, 998, -1000, 500, 499, 501, -499, -501, 0, 1, -1, 2, -2, 3, -3]) == 59488\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 525\n assert candidate(satisfaction = [-1, -2, -3, 4, 5, 6, 7, 8]) == 180\n assert candidate(satisfaction = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 110\n assert candidate(satisfaction = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 1, 2, 3, 4, 5]) == 60\n assert candidate(satisfaction = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [-500, -400, -300, -200, -100, 100, 200, 300, 400, 500]) == 9500\n assert candidate(satisfaction = [-10, 0, 10, -20, 0, 20, -30, 0, 30, -40]) == 400\n assert candidate(satisfaction = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, 70, 80, 90, 100]) == 6250\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-500, 500, -250, 250, 0, 100, -100, 150]) == 5850\n assert candidate(satisfaction = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 95\n assert candidate(satisfaction = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 570\n assert candidate(satisfaction = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 950\n assert candidate(satisfaction = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 229460\n assert candidate(satisfaction = [-100, -200, -300, 50, 100, 150, 200, 250]) == 4000\n assert candidate(satisfaction = [50, 20, -10, 0, -30, 100, -200, 300, -400, 500]) == 8040\n assert candidate(satisfaction = [-100, -200, -300, -400, 100, 200, 300, 400, 500]) == 9500\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 110\n assert candidate(satisfaction = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486]) == 59440\n assert candidate(satisfaction = [500, -1, -2, -3, 0, 1, 2, 3, 4, 5]) == 5105\n assert candidate(satisfaction = [-999, -998, -997, -996, 999, 998, 997, 996]) == 15970\n assert candidate(satisfaction = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 95\n assert candidate(satisfaction = [5, -5, 15, -15, 25, -25, 35, -35]) == 420\n assert candidate(satisfaction = [5, -1, 3, -2, 4, -3, 2]) == 72\n assert candidate(satisfaction = [-100, 0, 100, -200, 200, -300, 300, -400, 400, -500, 500]) == 11000\n assert candidate(satisfaction = [999, 1000, -999, -1000, 998, 997, -998, -997, 996, -996]) == 24970\n assert candidate(satisfaction = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 0\n assert candidate(satisfaction = [10, -1, 2, 5, -7, 8, -2]) == 137\n assert candidate(satisfaction = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 100\n assert candidate(satisfaction = [-5, -2, 0, 1, 3, 6]) == 46\n assert candidate(satisfaction = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, -1, -2, -3, -4, -5]) == 6565\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(satisfaction = [-500, 500, -499, 499, -498, 498, -497, 497, -496, 496]) == 12470\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 100\n assert candidate(satisfaction = [9, -1, -2, 3, -4, 5, -6, 7, -8, 9]) == 235\n assert candidate(satisfaction = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 950\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [-5, -3, -2, 1, 4, 6]) == 43\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(satisfaction = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3850\n assert candidate(satisfaction = [900, 100, 200, -900, 50, -50, 300, -300, 400, -400]) == 14450\n assert candidate(satisfaction = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == 950\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 95\n assert candidate(satisfaction = [-100, -200, -300, -400, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 161\n assert candidate(satisfaction = [-999, -998, -997, -996, -995, 995, 996, 997, 998, 999]) == 24945\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 40\n assert candidate(satisfaction = [-1, 0, 1, -2, 0, 2, -3, 0, 3]) == 40\n assert candidate(satisfaction = [-5, -3, -1, 1, 3, 5]) == 35\n assert candidate(satisfaction = [-50, -50, 50, 50, -25, -25, 25, 25, -75, 75]) == 1375\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 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(satisfaction = [-10, -20, -30, -40, -50, 5, 15, 25, 35, 45]) == 775\n assert candidate(satisfaction = [-9, -8, -7, -6, -5, 1, 2, 3, 4, 5]) == 69\n assert candidate(satisfaction = [-100, -200, -300, 100, 200, 300, 400, 500]) == 9000\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 295\n assert candidate(satisfaction = [-100, -90, -80, 70, 80, 90, 100]) == 1400\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 110\n assert candidate(satisfaction = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(satisfaction = [50, 100, 150, 200, -10, -20, -30, -40, -50, -60]) == 3940\n assert candidate(satisfaction = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 715\n assert candidate(satisfaction = [100, 100, 100, -1, -1, -1, -1, -1, -1, -1]) == 2672\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, -990, -989, -988, -987, -986, -985, -984, -983, -982, -981, -980]) == 0\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(satisfaction = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 0\n assert candidate(satisfaction = [-1000, 1000, -999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994]) == 48909\n assert candidate(satisfaction = [-1, -2, -3, 4, 5, 6]) == 67\n assert candidate(satisfaction = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 780\n assert candidate(satisfaction = [-500, 500, -400, 400, -300, 300, -200, 200, -100, 100]) == 9500\n assert candidate(satisfaction = [500, -500, 250, -250, 125, -125, 62, -62, 31, -31]) == 7092\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(satisfaction = [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100]) == 0\n assert candidate(satisfaction = [5, 1, 3, 7, -5, -3, 2, 6, -2, 4]) == 207\n assert candidate(satisfaction = [-999, -998, -997, -996, 996, 997, 998, 999]) == 15970\n assert candidate(satisfaction = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994, -993, 993, -992, 992]) == 63796\n assert candidate(satisfaction = [500, -500, 400, -400, 300, -300, 200, -200, 100, -100, 0]) == 11000\n assert candidate(satisfaction = [-5, -3, -1, 2, 4, 6]) == 50\n assert candidate(satisfaction = [-999, -1000, 1000, 999, -998, 998, 0, 0, 0, 0, 0]) == 23980\n assert candidate(satisfaction = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1240\n", "comparison": "exact"}, "public_tests": ["[-1,-8,0,5,-7]", "[4,3,2]", "[-1,-4,-5]"], "hints": ["Use dynamic programming to find the optimal solution by saving the previous best like-time coefficient and its corresponding element sum.", "If adding the current element to the previous best like-time coefficient and its corresponding element sum would increase the best like-time coefficient, then go ahead and add it. Otherwise, keep the previous best like-time coefficient."], "metadata": {"canonical_parameter_names": ["satisfaction"], "leetcode_dataset_entry_point": "Solution().maxSatisfaction", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:06+00:00", "tests_total": 114, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "dynamic-programming", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxSatisfaction(self, satisfaction: list[int]) -> int:", "container": "Solution", "callable": "maxSatisfaction", "parameters": [{"name": "satisfaction", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1403, "task_id": "minimum-subsequence-in-non-increasing-order", "difficulty": "Easy", "problem_description": "Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.\n\nIf there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array.\n\nNote that the solution with the given constraints is guaranteed to be unique. Also return the answer sorted in non-increasing order.\n\nExample 1:\n\nInput: nums = [4,3,10,9,8]\nOutput: [10,9]\nExplanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence [10,9] has the maximum total sum of its elements.\n\nExample 2:\n\nInput: nums = [4,4,7,6,7]\nOutput: [7,7,6]\nExplanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-increasing order.\n\nConstraints:\n\n- 1 <= nums.length <= 500\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 4, 7, 6, 7]) == [7, 7, 6]\n assert candidate(nums = [100, 90, 80, 70, 60]) == [100, 90, 80]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100, 99, 98, 97, 96]) == [100, 99, 98]\n assert candidate(nums = [4, 3, 10, 9, 8]) == [10, 9]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [5, 5, 5]\n assert candidate(nums = [50, 50, 50, 50, 50]) == [50, 50, 50]\n assert candidate(nums = [5, 5, 5, 5, 5, 1]) == [5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [5, 4]\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 1]) == [33, 33, 33, 33, 33, 33]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [100, 90, 80, 70]\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, 10, 9, 9, 8, 8, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [99, 98, 97, 96, 95]\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [50, 45, 40, 35]\n assert candidate(nums = [50, 20, 10, 100, 30, 60, 40, 80, 70, 90]) == [100, 90, 80, 70]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\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, 20, 19, 18]\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 50]\n assert candidate(nums = [83, 54, 43, 21, 27, 48, 85, 96, 18, 33, 62, 59, 74, 95, 29, 72, 67, 44, 37, 52, 58, 49, 60, 88, 91, 25, 76, 87, 50, 41, 38, 94, 61, 92, 26, 34, 40, 71, 80, 63, 86, 90, 30, 77, 42, 55, 82, 57, 51, 36, 97, 84, 22, 39, 45, 56, 64, 73, 69, 81, 75, 68, 46, 70, 79, 89, 23, 53, 31, 32, 65, 35, 47, 78]) == [97, 96, 95, 94, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]\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, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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 = [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]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79]\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]\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, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 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, 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]\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]\n assert candidate(nums = [34, 34, 23, 23, 12, 12, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [34, 34, 23, 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]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 1]) == [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]\n assert candidate(nums = [34, 23, 12, 3, 45, 67, 89, 12, 34, 56, 78, 90, 23, 45, 67, 89]) == [90, 89, 89, 78, 67]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 90, 80, 70]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11]\n assert candidate(nums = [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [99, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 2, 3, 4, 5]) == [100, 95, 90, 85, 80, 75, 70]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 90, 80, 70]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [99, 98, 97, 96, 95, 94, 93, 92]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 1]) == [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 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, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]\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, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\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, 99, 98, 97, 96, 95]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [100, 99, 98, 97, 96]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, 100, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100]\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, 100]) == [100, 8, 8, 8, 8, 8, 8, 8, 8, 8]\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]\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]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\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, 49, 48, 47, 46, 45, 44, 43, 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]) == [20, 19, 18, 17, 16, 15, 14]\n assert candidate(nums = [99, 100, 1, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [100, 99, 98, 97, 96, 95]\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, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11]\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17]) == [30, 25, 20, 17, 16, 15]\n", "comparison": "exact"}, "public_tests": ["[4,3,10,9,8]", "[4,4,7,6,7]"], "hints": ["Sort elements and take each element from the largest until accomplish the conditions."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:08+00:00", "tests_total": 60, "tests_dropped": 6, "flags": ["multiple_answers"], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minSubsequence(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "minSubsequence", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1404, "task_id": "number-of-steps-to-reduce-a-number-in-binary-representation-to-one", "difficulty": "Medium", "problem_description": "Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:\n\n-\nIf the current number is even, you have to divide it by 2.\n-\nIf the current number is odd, you have to add 1 to it.\n\nIt is guaranteed that you can always reach one for all test cases.\n\nExample 1:\n\nInput: s = \"1101\"\nOutput: 6\nExplanation: \"1101\" corressponds to number 13 in their decimal representation.\nStep 1) 13 is odd, add 1 and obtain 14.\nStep 2) 14 is even, divide by 2 and obtain 7.\nStep 3) 7 is odd, add 1 and obtain 8.\nStep 4) 8 is even, divide by 2 and obtain 4.\nStep 5) 4 is even, divide by 2 and obtain 2.\nStep 6) 2 is even, divide by 2 and obtain 1.\n\nExample 2:\n\nInput: s = \"10\"\nOutput: 1\nExplanation: \"10\" corresponds to number 2 in their decimal representation.\nStep 1) 2 is even, divide by 2 and obtain 1.\n\nExample 3:\n\nInput: s = \"1\"\nOutput: 0\n\nConstraints:\n\n- 1 <= s.length <= 500\n- s consists of characters '0' or '1'\n- s[0] == '1'\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"11101110111\") == 14\n assert candidate(s = \"1111\") == 5\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == 95\n assert candidate(s = \"1100110\") == 10\n assert candidate(s = \"111\") == 4\n assert candidate(s = \"10010\") == 8\n assert candidate(s = \"100000\") == 5\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000000000000\") == 62\n assert candidate(s = \"1001001\") == 12\n assert candidate(s = \"1111111111\") == 11\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111\") == 64\n assert candidate(s = \"1111111\") == 8\n assert candidate(s = \"1101\") == 6\n assert candidate(s = \"11011011\") == 11\n assert candidate(s = \"10\") == 1\n assert candidate(s = \"10101010\") == 12\n assert candidate(s = \"10000000000\") == 10\n assert candidate(s = \"1010101010\") == 15\n assert candidate(s = \"1\") == 0\n assert candidate(s = \"1101001\") == 11\n assert candidate(s = \"101010\") == 9\n assert candidate(s = \"1110011\") == 10\n assert candidate(s = \"1100100\") == 10\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110\") == 94\n assert candidate(s = \"11010\") == 7\n assert candidate(s = \"100000000000000000000000000000000\") == 32\n assert candidate(s = \"1100100100100100100100100100100100\") == 55\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001\") == 132\n assert candidate(s = \"1011011011011011011011011011011011011011011\") == 58\n assert candidate(s = \"1000100010001\") == 23\n assert candidate(s = \"1011011011011011011011011011011011\") == 46\n assert candidate(s = \"1111111011111110111111101111111\") == 35\n assert candidate(s = \"11111111111111111111111111111111111111111\") == 42\n assert candidate(s = \"1000000000000000000000000000000\") == 30\n assert candidate(s = \"1010101010101010101\") == 29\n assert candidate(s = \"1111000011110000111100001111000\") == 44\n assert candidate(s = \"1010101010101010101010101010101\") == 47\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001\") == 107\n assert candidate(s = \"1101101101101101101101101101101101101101101\") == 58\n assert candidate(s = \"1110101010101010101010101010101\") == 46\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000001\") == 127\n assert candidate(s = \"11110101010101010101010101010101010101010101010101010101010101010\") == 96\n assert candidate(s = \"1101101011010110101101011010110\") == 43\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 74\n assert candidate(s = \"1001001001001001001001001001001001001\") == 62\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == 68\n assert candidate(s = \"1110111011101110111011101110111011101110111011101110111011101110\") == 80\n assert candidate(s = \"1101101101101101101101101101101101101101101101101101101101101101\") == 86\n assert candidate(s = \"10101010101010101010101\") == 35\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000001\") == 129\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100\") == 107\n assert candidate(s = \"110111011101110111011101110111011101110111011101110111011101110111011101\") == 91\n assert candidate(s = \"11110000111100001111000011110000111100001111\") == 65\n assert candidate(s = \"1001001001001001001001001001001\") == 52\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101\") == 107\n assert candidate(s = \"1011101010101010101010101010101\") == 46\n assert candidate(s = \"11101110111011101110111011101110111011101110111011101110111011101110111\") == 89\n assert candidate(s = \"1111111111111111111111111111111\") == 32\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\") == 93\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 80\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101\") == 98\n assert candidate(s = \"1011010110101101011010110101101011010110101101011\") == 69\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\") == 65\n assert candidate(s = \"101010101010101010101010101010101010101\") == 59\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101\") == 86\n assert candidate(s = \"1101010101010101010101010101010\") == 46\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\") == 108\n assert candidate(s = \"11101010101010101010101010101\") == 43\n assert candidate(s = \"1000011111111111111111111111111\") == 36\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\") == 69\n assert candidate(s = \"1010000000000000000000000000000000001\") == 72\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000111\") == 125\n assert candidate(s = \"1011011011011011011011011011011011011011011011011011011011011011011\") == 90\n assert candidate(s = \"1110111011101110111011101110111\") == 39\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111\") == 63\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001\") == 122\n assert candidate(s = \"11110000111100001111000011110000\") == 45\n assert candidate(s = \"1101101101101101101101101101101101101101\") == 54\n assert candidate(s = \"1100110011001100110011001100110011001100110011001\") == 74\n assert candidate(s = \"110101010101010101010101010101010101010101010101010101010101010101\") == 99\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010000\") == 96\n assert candidate(s = \"11111111111111111111111111111111\") == 33\n assert candidate(s = \"1101111111000000\") == 18\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 67\n assert candidate(s = \"10101010101010101010101010101010101010101\") == 62\n assert candidate(s = \"10000000000000000000000000000000000000000\") == 40\n assert candidate(s = \"11001100110011001100110011001100110011001100\") == 65\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111010\") == 66\n assert candidate(s = \"1111101010101010101010101010101\") == 45\n assert candidate(s = \"11010101010101010101\") == 30\n assert candidate(s = \"1011101001101001101001101001101\") == 46\n assert candidate(s = \"1100110011001100110011001100110\") == 46\n assert candidate(s = \"1100011000110001100011000110001\") == 50\n assert candidate(s = \"1111101111101111101111101111101111101111101111101\") == 58\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 82\n assert candidate(s = \"11001101100110110\") == 24\n assert candidate(s = \"1110111011101110111011101110111011101110111\") == 54\n assert candidate(s = \"111001000111001000111001000111001000\") == 54\n assert candidate(s = \"1000000000000000000000000000000000000000000000000\") == 48\n assert candidate(s = \"1011011011011011011011011011011011011011011011011011011011011011011011\") == 94\n assert candidate(s = \"1011101110111011101110111011101110111011101110111011101110111011\") == 81\n", "comparison": "exact"}, "public_tests": ["\"1101\"", "\"10\"", "\"1\""], "hints": ["Read the string from right to left, if the string ends in '0' then the number is even otherwise it is odd.", "Simulate the steps described in the binary string."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:10+00:00", "tests_total": 101, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "bit-manipulation", "simulation"]}, "language": "python", "interface": {"raw_signature": "def numSteps(self, s: str) -> int:", "container": "Solution", "callable": "numSteps", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1405, "task_id": "longest-happy-string", "difficulty": "Medium", "problem_description": "A string s is called happy if it satisfies the following conditions:\n\n- s only contains the letters 'a', 'b', and 'c'.\n- s does not contain any of \"aaa\", \"bbb\", or \"ccc\" as a substring.\n- s contains at most a occurrences of the letter 'a'.\n- s contains at most b occurrences of the letter 'b'.\n- s contains at most c occurrences of the letter 'c'.\n\nGiven three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string \"\".\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: a = 1, b = 1, c = 7\nOutput: \"ccaccbcc\"\nExplanation: \"ccbccacc\" would also be a correct answer.\n\nExample 2:\n\nInput: a = 7, b = 1, c = 0\nOutput: \"aabaa\"\nExplanation: It is the only correct answer in this case.\n\nConstraints:\n\n- 0 <= a, b, c <= 100\n- a + b + c > 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 7,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 100,b = 100,c = 100) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 33,c = 34) == \"cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 2,b = 2,c = 2) == \"abcabc\"\n assert candidate(a = 5,b = 5,c = 5) == \"abcabcabcabcabc\"\n assert candidate(a = 5,b = 3,c = 2) == \"aabaabcabc\"\n assert candidate(a = 50,b = 50,c = 0) == \"abababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 50,b = 30,c = 20) == \"aabaabaabaabaabaabaabaabaabaabaabaacaabaacaabaacaabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 7) == \"ccaccbcc\"\n assert candidate(a = 0,b = 0,c = 1) == \"c\"\n assert candidate(a = 100,b = 0,c = 0) == \"aa\"\n assert candidate(a = 0,b = 0,c = 3) == \"cc\"\n assert candidate(a = 40,b = 30,c = 30) == \"aabaacaabaacaabaacaabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 10,c = 10) == \"bcbcbcbcbcbcbcbcbcbc\"\n assert candidate(a = 10,b = 10,c = 1) == \"ababababababababababc\"\n assert candidate(a = 20,b = 10,c = 15) == \"aacaacaacaacaacabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 20,c = 10) == \"bbabbabbabbabababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 45,b = 10,c = 45) == \"acacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 6,b = 6,c = 6) == \"abcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 3) == \"abcabcabc\"\n assert candidate(a = 40,b = 20,c = 40) == \"acacacacacacacacacacacacacacacacacacacacabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 15,c = 15) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 34,c = 33) == \"babcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 5,b = 5,c = 4) == \"ababcabcabcabc\"\n assert candidate(a = 10,b = 10,c = 20) == \"ccaccbccaccbccaccbcabcabcabcabcabcabcabc\"\n assert candidate(a = 60,b = 40,c = 5) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabababababababababababababababababcabcabcabcabc\"\n assert candidate(a = 4,b = 4,c = 3) == \"ababcabcabc\"\n assert candidate(a = 15,b = 15,c = 5) == \"abababababababababababcabcabcabcabc\"\n assert candidate(a = 5,b = 4,c = 4) == \"aabcabcabcabc\"\n assert candidate(a = 5,b = 5,c = 0) == \"ababababab\"\n assert candidate(a = 10,b = 10,c = 5) == \"ababababababcabcabcabcabc\"\n assert candidate(a = 5,b = 0,c = 5) == \"acacacacac\"\n assert candidate(a = 20,b = 20,c = 10) == \"abababababababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 34,b = 33,c = 33) == \"aabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 0,c = 100) == \"cc\"\n assert candidate(a = 10,b = 20,c = 10) == \"bbabbcbbabbcbbabbcbabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 20,c = 10) == \"aabaabaabaabaabaabaabaabaabaababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 30,c = 20) == \"abababababababababababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 25,c = 20) == \"bbabbcbbabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 50,c = 50) == \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\"\n assert candidate(a = 90,b = 5,c = 5) == \"aabaacaabaacaabaacaabaacaabaacaa\"\n assert candidate(a = 20,b = 19,c = 18) == \"aababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 6,b = 7,c = 8) == \"cbcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 5) == \"ccaccbc\"\n assert candidate(a = 4,b = 4,c = 5) == \"cabcabcabcabc\"\n assert candidate(a = 2,b = 1,c = 1) == \"aabc\"\n assert candidate(a = 50,b = 50,c = 50) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 99,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 34,b = 34,c = 32) == \"abababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 10,b = 45,c = 45) == \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 2,b = 3,c = 5) == \"ccbcabcabc\"\n assert candidate(a = 15,b = 5,c = 10) == \"aacaacaacaacaacabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 2) == \"cabc\"\n assert candidate(a = 7,b = 8,c = 9) == \"cbcabcabcabcabcabcabcabc\"\n assert candidate(a = 8,b = 8,c = 8) == \"abcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 33,c = 33) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 25,b = 25,c = 24) == \"ababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 100,b = 50,c = 50) == \"aabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabacabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 5,b = 2,c = 2) == \"aabaacabc\"\n assert candidate(a = 25,b = 25,c = 25) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 99,b = 99,c = 99) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 15,c = 10) == \"ababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 9) == \"ccaccbccacbcabc\"\n assert candidate(a = 15,b = 15,c = 1) == \"abababababababababababababababc\"\n assert candidate(a = 10,b = 10,c = 10) == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 9,b = 8,c = 7) == \"aababcabcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 4) == \"cabcabcabc\"\n assert candidate(a = 1,b = 2,c = 1) == \"babc\"\n assert candidate(a = 3,b = 2,c = 1) == \"aababc\"\n assert candidate(a = 10,b = 1,c = 1) == \"aabaacaa\"\n assert candidate(a = 10,b = 5,c = 15) == \"ccaccaccaccacacabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 1) == \"abc\"\n assert candidate(a = 49,b = 50,c = 51) == \"cbcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 10,c = 10) == \"aabaacaabaacaabaacaabcabcabcabcabcabcabc\"\n assert candidate(a = 51,b = 50,c = 49) == \"aababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 30,c = 20) == \"bbabbcbbabbcbbabbcbabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 100,c = 1) == \"bbabbcbb\"\n assert candidate(a = 5,b = 5,c = 10) == \"ccaccbccabcabcabcabc\"\n assert candidate(a = 50,b = 50,c = 1) == \"ababababababababababababababababababababababababababababababababababababababababababababababababababc\"\n assert candidate(a = 0,b = 100,c = 0) == \"bb\"\n assert candidate(a = 24,b = 25,c = 25) == \"bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 10,b = 10,c = 15) == \"ccaccbccabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 100) == \"ccaccbcc\"\n assert candidate(a = 1,b = 2,c = 3) == \"cbcabc\"\n assert candidate(a = 20,b = 20,c = 19) == \"ababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 45,b = 45,c = 10) == \"ababababababababababababababababababababababababababababababababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 5,c = 5) == \"bcbcbcbcbc\"\n assert candidate(a = 60,b = 40,c = 0) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababababababababababababababababababababab\"\n assert candidate(a = 3,b = 7,c = 5) == \"bbcbbcabcabcabc\"\n assert candidate(a = 30,b = 30,c = 30) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 25,c = 45) == \"ccaccaccaccaccaccaccbccaccbccaccbcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n", "comparison": "exact"}, "public_tests": ["1\n1\n7", "7\n1\n0"], "hints": ["Use a greedy approach.", "Use the letter with the maximum current limit that can be added without breaking the condition."], "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().longestDiverseString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:12+00:00", "tests_total": 92, "tests_dropped": 1, "flags": ["multiple_answers"], "topic_tags": ["string", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def longestDiverseString(self, a: int, b: int, c: int) -> str:", "container": "Solution", "callable": "longestDiverseString", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1406, "task_id": "stone-game-iii", "difficulty": "Hard", "problem_description": "Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\n\nAlice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.\n\nThe score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.\n\nThe objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.\n\nAssume Alice and Bob play optimally.\n\nReturn \"Alice\" if Alice will win, \"Bob\" if Bob will win, or \"Tie\" if they will end the game with the same score.\n\nExample 1:\n\nInput: stoneValue = [1,2,3,7]\nOutput: \"Bob\"\nExplanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.\n\nExample 2:\n\nInput: stoneValue = [1,2,3,-9]\nOutput: \"Alice\"\nExplanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.\nIf Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose.\nIf Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose.\nRemember that both play optimally so here Alice will choose the scenario that makes her win.\n\nExample 3:\n\nInput: stoneValue = [1,2,3,6]\nOutput: \"Tie\"\nExplanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.\n\nConstraints:\n\n- 1 <= stoneValue.length <= 5 * 10^4\n- -1000 <= stoneValue[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1]) == \"Alice\"\n assert candidate(stoneValue = [1, -100, 1, 100]) == \"Tie\"\n assert candidate(stoneValue = [5, 3, 7, 1]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, 1, 4, 2]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == \"Tie\"\n assert candidate(stoneValue = [-1, -2, -3, -4]) == \"Tie\"\n assert candidate(stoneValue = [1, 2, 3, 6]) == \"Tie\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, -6, 7, 2, 8, -1, 4, 10]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"Bob\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 7]) == \"Bob\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, -9]) == \"Alice\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5]) == \"Bob\"\n assert candidate(stoneValue = [3, 2, 10, 4]) == \"Alice\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [5, 10, -5, 1]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == \"Alice\"\n assert candidate(stoneValue = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == \"Alice\"\n assert candidate(stoneValue = [3, -2, 5, 1, -4, 6, -3, 2, 5, -1, 4, -6, 3, 2, -5, 1, 4, -6, 3, 2, -5, 1, 4, -6, 3, 2, -5]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == \"Alice\"\n assert candidate(stoneValue = [1000, -999, 998, -997, 996, -995, 994, -993, 992, -991]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == \"Tie\"\n assert candidate(stoneValue = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == \"Alice\"\n assert candidate(stoneValue = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [5, 10, -5, 20, 25, -30, 35, -40, 45, 50]) == \"Alice\"\n assert candidate(stoneValue = [5, -1, 3, -4, 2, 10, -7, 8, -2, 6]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, 2, 4, 1, 3, 2, 1, 2, 3, 4, 5, 1, 2, 3]) == \"Alice\"\n assert candidate(stoneValue = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == \"Alice\"\n assert candidate(stoneValue = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == \"Alice\"\n assert candidate(stoneValue = [10, 15, -5, 20, -10, 25, -15, 30, -20, 35]) == \"Alice\"\n assert candidate(stoneValue = [100, -50, 200, -150, 300, -200, 400, -250, 500, -300, 600, -350, 700, -400, 800]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == \"Bob\"\n assert candidate(stoneValue = [3, 1, 5, 4, 2, 6, 7, 8, 9, 10]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == \"Tie\"\n assert candidate(stoneValue = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8]) == \"Alice\"\n assert candidate(stoneValue = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == \"Tie\"\n assert candidate(stoneValue = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == \"Bob\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0, 1, -3, 7, -15, 31, -62, 125, -250, 500, -1000]) == \"Alice\"\n assert candidate(stoneValue = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500]) == \"Alice\"\n assert candidate(stoneValue = [5, 7, -3, 12, 15, -10, 8, 11, -2, 6, 14, 1, -5, 9, -7]) == \"Alice\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25]) == \"Alice\"\n assert candidate(stoneValue = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == \"Tie\"\n assert candidate(stoneValue = [-100, -200, -300, 400, 500, 600, -700, -800, 900, 1000]) == \"Alice\"\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"Alice\"\n assert candidate(stoneValue = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"Alice\"\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == \"Bob\"\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == \"Alice\"\n assert candidate(stoneValue = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == \"Alice\"\n assert candidate(stoneValue = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, -1000, 500, 600, 700, -800, 900, 1000]) == \"Alice\"\n assert candidate(stoneValue = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"Alice\"\n assert candidate(stoneValue = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == \"Alice\"\n assert candidate(stoneValue = [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]) == \"Alice\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == \"Tie\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [-5, 10, -15, 20, -25, 30, -35, 40, -45, 50]) == \"Alice\"\n assert candidate(stoneValue = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == \"Tie\"\n assert candidate(stoneValue = [1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Alice\"\n assert candidate(stoneValue = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == \"Alice\"\n assert candidate(stoneValue = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -30]) == \"Alice\"\n assert candidate(stoneValue = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == \"Tie\"\n assert candidate(stoneValue = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == \"Tie\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == \"Alice\"\n assert candidate(stoneValue = [5, -2, 4, -1, 3, -3, 2, 1, -5, 6, 7, -8, 9]) == \"Alice\"\n assert candidate(stoneValue = [500, 250, -100, 200, -150, 300, -50, 100, -200, 300, 500]) == \"Alice\"\n assert candidate(stoneValue = [5, -3, 2, 7, -8, 10, -15, 20, -25, 30]) == \"Alice\"\n assert candidate(stoneValue = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == \"Alice\"\n assert candidate(stoneValue = [-5, 10, 20, -15, 30, 25, -20, 40, -35, 50, -45, 60, -55]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, -100, -200, -300, 400, 500, 600, -400, -500, -600]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == \"Tie\"\n assert candidate(stoneValue = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Tie\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [5, -2, 3, 1, 4, -1, 7, -3, 2, 6, -5]) == \"Alice\"\n assert candidate(stoneValue = [-999, 1000, -999, 1000, -999, 1000, -999, 1000, -999, 1000]) == \"Alice\"\n assert candidate(stoneValue = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == \"Alice\"\n", "comparison": "exact"}, "public_tests": ["[1,2,3,7]", "[1,2,3,-9]", "[1,2,3,6]"], "hints": ["The game can be mapped to minmax game. Alice tries to maximize the total score and Bob tries to minimize it.", "Use dynamic programming to simulate the game. If the total score was 0 the game is \"Tie\", and if it has positive value then \"Alice\" wins, otherwise \"Bob\" wins."], "metadata": {"canonical_parameter_names": ["stoneValue"], "leetcode_dataset_entry_point": "Solution().stoneGameIII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:14+00:00", "tests_total": 102, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "minimax-algorithm", "game-theory", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def stoneGameIII(self, stoneValue: list[int]) -> str:", "container": "Solution", "callable": "stoneGameIII", "parameters": [{"name": "stoneValue", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1408, "task_id": "string-matching-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.\n\nExample 1:\n\nInput: words = [\"mass\",\"as\",\"hero\",\"superhero\"]\nOutput: [\"as\",\"hero\"]\nExplanation: \"as\" is substring of \"mass\" and \"hero\" is substring of \"superhero\".\n[\"hero\",\"as\"] is also a valid answer.\n\nExample 2:\n\nInput: words = [\"leetcode\",\"et\",\"code\"]\nOutput: [\"et\",\"code\"]\nExplanation: \"et\", \"code\" are substring of \"leetcode\".\n\nExample 3:\n\nInput: words = [\"blue\",\"green\",\"bu\"]\nOutput: []\nExplanation: No string of words is substring of another string.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 30\n- words[i] contains only lowercase English letters.\n- All the strings of words are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(words=['leetcode', 'et', 'code']), ['et', 'code'])\n assert answers_match(candidate(words=['blue', 'green', 'bu']), [])\n assert answers_match(candidate(words=['mass', 'as', 'hero', 'superhero']), ['as', 'hero'])\n assert answers_match(candidate(words=['nested', 'nest', 'sted', 'stednested', 'nestedsted', 'st']), ['nested', 'nest', 'sted', 'st'])\n assert answers_match(candidate(words=['apple', 'pineapple', 'banana', 'app', 'pine']), ['apple', 'app', 'pine'])\n assert answers_match(candidate(words=['apple', 'app', 'pineapple', 'pie', 'pine']), ['apple', 'app', 'pine'])\n assert answers_match(candidate(words=['abcdefgh', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']), ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a'])\n assert answers_match(candidate(words=['one', 'once', 'only', 'no', 'on', 'o', 'onceuponatime', 'time', 'upon']), ['once', 'on', 'o', 'time', 'upon'])\n assert answers_match(candidate(words=['interview', 'view', 'terview', 'enter', 'viewer', 'inter']), ['view', 'terview', 'inter'])\n assert answers_match(candidate(words=['hello', 'hell', 'ello', 'lo', 'll', 'he', 'oh', 'el', 'le', 'hellos', 'los']), ['hello', 'hell', 'ello', 'lo', 'll', 'he', 'el', 'los'])\n assert answers_match(candidate(words=['adventure', 'venture', 'adven', 'advenu', 'tu', 'tre', 'ven', 'ure', 'enture', 'venu']), ['venture', 'adven', 'tu', 'ven', 'ure', 'enture', 'venu'])\n assert answers_match(candidate(words=['abcdef', 'def', 'ghij', 'jkl', 'ghijkl', 'defgh']), ['def', 'ghij', 'jkl'])\n assert answers_match(candidate(words=['abc', 'bca', 'cab', 'abcd', 'bcda', 'cdab', 'dabc']), ['abc'])\n assert answers_match(candidate(words=['amazing', 'zing', 'zinga', 'zingalingo']), ['zing', 'zinga'])\n assert answers_match(candidate(words=['xyz', 'zyx', 'xyzz', 'zzxy', 'yxz', 'zyxz', 'xyzzyx']), ['xyz', 'zyx', 'xyzz', 'yxz'])\n assert answers_match(candidate(words=['algorithms', 'algo', 'rithm', 'log', 'thm', 'gms']), ['algo', 'rithm', 'thm'])\n assert answers_match(candidate(words=['extraterrestrial', 'extra', 'terrestrial', 'restrial', 'estrial', 'trial', 'rial', 'ial', 'al', 'l']), ['extra', 'terrestrial', 'restrial', 'estrial', 'trial', 'rial', 'ial', 'al', 'l'])\n assert answers_match(candidate(words=['substring', 'super', 'sub', 'superstring', 'string', 'ingsub']), ['super', 'sub', 'string'])\n assert answers_match(candidate(words=['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']), ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg'])\n assert answers_match(candidate(words=['unique', 'unicorn', 'unicore', 'uniques', 'unicorns', 'unicornicorns']), ['unique', 'unicorn'])\n assert answers_match(candidate(words=['programming', 'gram', 'gramming', 'pro', 'ming']), ['gram', 'gramming', 'pro', 'ming'])\n assert answers_match(candidate(words=['one', 'two', 'three', 'onetwo', 'twothree', 'onetwothree', 'threeonetwo']), ['one', 'two', 'three', 'onetwo', 'twothree'])\n assert answers_match(candidate(words=['abc', 'bcd', 'abcd', 'ab', 'cde', 'def', 'abcdefg']), ['abc', 'bcd', 'abcd', 'ab', 'cde', 'def'])\n assert answers_match(candidate(words=['abcd', 'abcde', 'abcdef', 'def', 'cde', 'bcde']), ['abcd', 'abcde', 'def', 'cde', 'bcde'])\n assert answers_match(candidate(words=['substring', 'string', 'sub', 'str', 'st', 's']), ['string', 'sub', 'str', 'st', 's'])\n assert answers_match(candidate(words=['abc', 'def', 'abcdef', 'ghijkl', 'mnop', 'mnopqr', 'abcde']), ['abc', 'def', 'mnop', 'abcde'])\n assert answers_match(candidate(words=['python', 'java', 'javascript', 'pythonic', 'code', 'script']), ['python', 'java', 'script'])\n assert answers_match(candidate(words=['microcosm', 'micro', 'cosm', 'co', 'sm', 'microscopic', 'scop', 'scope', 'opic', 'pic']), ['micro', 'cosm', 'co', 'sm', 'scop', 'opic', 'pic'])\n assert answers_match(candidate(words=['elephant', 'elephantium', 'phant', 'phantom', 'ele', 'fantastic']), ['elephant', 'phant', 'ele'])\n assert answers_match(candidate(words=['incomprehensible', 'in', 'comprehensible', 'prehensible', 'prehens', 'hensible', 'ensible', 'sible', 'ible', 'ble']), ['in', 'comprehensible', 'prehensible', 'prehens', 'hensible', 'ensible', 'sible', 'ible', 'ble'])\n assert answers_match(candidate(words=['algorithm', 'log', 'arithm', 'rhythm', 'mthm', 'them']), [])\n assert answers_match(candidate(words=['repetition', 'petition', 'iteration', 'repeat', 'pet', 'tion', 'peti', 'petit', 'petiti', 'petitio']), ['petition', 'pet', 'tion', 'peti', 'petit', 'petiti', 'petitio'])\n assert answers_match(candidate(words=['substring', 'string', 'sub', 'substringing', 'ing']), ['substring', 'string', 'sub', 'ing'])\n assert answers_match(candidate(words=['substring', 'string', 'sub', 'ing', 'substr', 'str', 'ingstr', 'substrin']), ['string', 'sub', 'ing', 'substr', 'str', 'substrin'])\n assert answers_match(candidate(words=['hello', 'world', 'hel', 'lo', 'wor', 'rld', 'ldo']), ['hel', 'lo', 'wor', 'rld'])\n assert answers_match(candidate(words=['programming', 'gram', 'ming', 'pro', 'gramming']), ['gram', 'ming', 'pro', 'gramming'])\n assert answers_match(candidate(words=['aabbcc', 'bbaa', 'ccaa', 'aabb', 'bbcc', 'ccaabb', 'aabbccaa']), ['aabbcc', 'ccaa', 'aabb', 'bbcc'])\n assert answers_match(candidate(words=['tiny', 'tinier', 'tinytinier', 'tinytiny', 'tinieriny']), ['tiny', 'tinier'])\n assert answers_match(candidate(words=['apple', 'app', 'le', 'banana', 'nan', 'batman', 'man', 'at']), ['app', 'le', 'nan', 'man', 'at'])\n assert answers_match(candidate(words=['aabbcc', 'aabb', 'abbc', 'bbcc', 'abcc', 'aabc', 'bccc', 'ccaa', 'aacc', 'bbca']), ['aabb', 'abbc', 'bbcc'])\n assert answers_match(candidate(words=['random', 'rand', 'dom', 'ra', 'doma', 'mon', 'ndom', 'and', 'ran', 'domi']), ['rand', 'dom', 'ra', 'ndom', 'and', 'ran'])\n assert answers_match(candidate(words=['algorithm', 'logarithm', 'rhythm', 'algorithmic', 'logarithmic', 'rhythmic']), ['algorithm', 'logarithm', 'rhythm'])\n assert answers_match(candidate(words=['abcd', 'abc', 'ab', 'a', 'bcde', 'cde', 'de', 'e']), ['abc', 'ab', 'a', 'cde', 'de', 'e'])\n assert answers_match(candidate(words=['substring', 'string', 'sub', 'str', 'ing', 'sun', 'set', 'net', 'get', 'ten']), ['string', 'sub', 'str', 'ing'])\n assert answers_match(candidate(words=['subsequence', 'sequence', 'sub', 'ence', 'quen']), ['sequence', 'sub', 'ence', 'quen'])\n assert answers_match(candidate(words=['abcdefg', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn']), ['bcdef', 'cdefg'])\n assert answers_match(candidate(words=['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny', 'tinytinytinytinytiny']), ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny'])\n assert answers_match(candidate(words=['submarine', 'sub', 'marine', 'submar', 'in', 'a', 'mar', 'ne']), ['sub', 'marine', 'submar', 'in', 'a', 'mar', 'ne'])\n assert answers_match(candidate(words=['abcd', 'abc', 'ab', 'a', 'bcde', 'cde', 'de']), ['abc', 'ab', 'a', 'cde', 'de'])\n assert answers_match(candidate(words=['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f']), ['abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f'])\n assert answers_match(candidate(words=['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']), ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef'])\n assert answers_match(candidate(words=['programming', 'gram', 'ming', 'pro', 'am', 'ing', 'gramming', 'program']), ['gram', 'ming', 'pro', 'am', 'ing', 'gramming', 'program'])\n assert answers_match(candidate(words=['apple', 'plea', 'ple', 'applepie']), ['apple', 'ple'])\n assert answers_match(candidate(words=['fantastic', 'fant', 'ast', 'astic', 'tic']), ['fant', 'ast', 'astic', 'tic'])\n assert answers_match(candidate(words=['subsequence', 'sequence', 'sub', 'seq', 'subseq', 'quen', 'ence', 'quence', 'suben', 'queseq']), ['sequence', 'sub', 'seq', 'subseq', 'quen', 'ence', 'quence'])\n assert answers_match(candidate(words=['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']), ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg'])\n assert answers_match(candidate(words=['abcdabcd', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']), ['ab', 'abc', 'abcd', 'abcde'])\n assert answers_match(candidate(words=['banana', 'ana', 'nan', 'ban', 'an']), ['ana', 'nan', 'ban', 'an'])\n assert answers_match(candidate(words=['programming', 'gram', 'ming', 'pro', 'gramming', 'program']), ['gram', 'ming', 'pro', 'gramming', 'program'])\n assert answers_match(candidate(words=['interdisciplinary', 'inter', 'disciplinary', 'disci', 'plinary', 'sci', 'sciency', 'interdisci', 'plin', 'sciencyplin']), ['inter', 'disciplinary', 'disci', 'plinary', 'sci', 'sciency', 'interdisci', 'plin'])\n assert answers_match(candidate(words=['abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefgh', 'efg', 'hij', 'ijk']), ['abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'efg'])\n assert answers_match(candidate(words=['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny']), ['tiny', 'tinytiny', 'tinytinytiny'])\n assert answers_match(candidate(words=['overlap', 'lapping', 'lap', 'lappping', 'lapppinglap']), ['lap', 'lappping'])\n assert answers_match(candidate(words=['programming', 'program', 'ming', 'code', 'coding']), ['program', 'ming'])\n assert answers_match(candidate(words=['algorithm', 'algo', 'rhythm', 'rhythmic', 'algothm', 'rhyth', 'thm']), ['algo', 'rhythm', 'rhyth', 'thm'])\n assert answers_match(candidate(words=['substring', 'string', 'sub', 'substrings', 'str']), ['substring', 'string', 'sub', 'str'])\n assert answers_match(candidate(words=['abcdef', 'bcde', 'cde', 'de', 'e', 'f']), ['bcde', 'cde', 'de', 'e', 'f'])\n assert answers_match(candidate(words=['nested', 'nest', 'nestedword', 'word', 'edword', 'st', 'sted']), ['nested', 'nest', 'word', 'edword', 'st', 'sted'])\n assert answers_match(candidate(words=['photographically', 'photo', 'graphically', 'graphic', 'ically', 'ally', 'ly', 'y']), ['photo', 'graphically', 'graphic', 'ically', 'ally', 'ly', 'y'])\n assert answers_match(candidate(words=['xylophone', 'phone', 'lophone', 'xylo', 'loph', 'pho', 'hon', 'xyl', 'one', 'phe']), ['phone', 'lophone', 'xylo', 'loph', 'pho', 'hon', 'xyl', 'one'])\n assert answers_match(candidate(words=['programming', 'gram', 'ming', 'mingo', 'prog', 'ingram', 'program', 'gramming', 'programm', 'progr']), ['gram', 'ming', 'prog', 'program', 'gramming', 'programm', 'progr'])\n assert answers_match(candidate(words=['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'abcdefg', 'gh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']), ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'gh'])\n assert answers_match(candidate(words=['algorithm', 'log', 'rithm', 'algo', 'thm']), ['rithm', 'algo', 'thm'])\n assert answers_match(candidate(words=['unique', 'uni', 'ique', 'un', 'que', 'nique', 'niqe', 'neiq', 'uqei', 'inqeu']), ['uni', 'ique', 'un', 'que', 'nique'])\n assert answers_match(candidate(words=['programming', 'gram', 'pro', 'ming', 'ring']), ['gram', 'pro', 'ming'])\n assert answers_match(candidate(words=['water', 'watermelon', 'melon', 'wa', 'ter', 'melonade', 'ade']), ['water', 'melon', 'wa', 'ter', 'ade'])\n assert answers_match(candidate(words=['apple', 'pineapple', 'grape', 'pinegrape', 'grapefruit', 'pineapplegrape']), ['apple', 'pineapple', 'grape'])\n assert answers_match(candidate(words=['abc', 'def', 'abcd', 'abcde', 'abcdef']), ['abc', 'def', 'abcd', 'abcde'])\n assert answers_match(candidate(words=['unbelievable', 'un', 'believe', 'able', 'e', 'a', 'i', 'o', 'u']), ['un', 'able', 'e', 'a', 'i', 'u'])\n assert answers_match(candidate(words=['encyclopedia', 'encyclop', 'yclopedia', 'cloped', 'lopedia', 'pedia', 'dia', 'dialect', 'logic', 'encyclopediaic']), ['encyclopedia', 'encyclop', 'yclopedia', 'cloped', 'lopedia', 'pedia', 'dia'])\n assert answers_match(candidate(words=['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnop', 'qrstuvwxyz', 'mnopqrstu', 'vwxyz']), ['abcdefghijklmnop', 'qrstuvwxyz', 'mnopqrstu', 'vwxyz'])\n assert answers_match(candidate(words=['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']), ['a', 'ab', 'abc', 'abcd', 'abcde'])\n assert answers_match(candidate(words=['algorithm', 'algo', 'rhythm', 'thm', 'rthm', 'hythmthm']), ['algo', 'thm'])\n", "comparison": "unordered"}, "public_tests": ["[\"mass\",\"as\",\"hero\",\"superhero\"]", "[\"leetcode\",\"et\",\"code\"]", "[\"blue\",\"green\",\"bu\"]"], "hints": ["Bruteforce to find if one string is substring of another or use KMP algorithm."], "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().stringMatching", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:17+00:00", "tests_total": 97, "tests_dropped": 14, "flags": ["any_order"], "topic_tags": ["array", "string", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def stringMatching(self, words: list[str]) -> list[str]:", "container": "Solution", "callable": "stringMatching", "parameters": [{"name": "words", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1409, "task_id": "queries-on-a-permutation-with-key", "difficulty": "Medium", "problem_description": "Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:\n\n- In the beginning, you have the permutation P=[1,2,3,...,m].\n- For the current i, find the position of queries[i] in the permutation P (indexing from 0) and then move this at the beginning of the permutation P. Notice that the position of queries[i] in P is the result for queries[i].\n\nReturn an array containing the result for the given queries.\n\nExample 1:\n\nInput: queries = [3,1,2,1], m = 5\nOutput: [2,1,2,1]\nExplanation: The queries are processed as follow:\nFor i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is 2, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5].\nFor i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5].\nFor i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is 2, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5].\nFor i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5].\nTherefore, the array containing the result is [2,1,2,1].\n\nExample 2:\n\nInput: queries = [4,1,2,2], m = 4\nOutput: [3,1,2,0]\n\nExample 3:\n\nInput: queries = [7,5,5,8,3], m = 8\nOutput: [6,5,0,7,5]\n\nConstraints:\n\n- 1 <= m <= 10^3\n- 1 <= queries.length <= m\n- 1 <= queries[i] <= m\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = [3, 1, 2, 1],m = 5) == [2, 1, 2, 1]\n assert candidate(queries = [1, 2, 3],m = 3) == [0, 1, 2]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [7, 5, 5, 8, 3],m = 8) == [6, 5, 0, 7, 5]\n assert candidate(queries = [1, 2, 3, 4, 5],m = 5) == [0, 1, 2, 3, 4]\n assert candidate(queries = [5, 4, 3, 2, 1],m = 5) == [4, 4, 4, 4, 4]\n assert candidate(queries = [4, 1, 2, 2],m = 4) == [3, 1, 2, 0]\n assert candidate(queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 20) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]\n assert candidate(queries = [5, 3, 8, 6, 2, 7, 4, 1],m = 8) == [4, 3, 7, 6, 5, 7, 7, 7]\n assert candidate(queries = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5, 100, 6, 100, 7, 100, 8, 100, 9, 100, 10],m = 100) == [99, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(queries = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],m = 100) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]\n assert candidate(queries = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 10) == [1, 3, 5, 7, 9, 5, 6, 7, 8, 9]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [1, 5, 9, 3, 7, 2, 6, 4, 8, 10],m = 10) == [0, 4, 8, 4, 7, 5, 7, 7, 8, 9]\n assert candidate(queries = [100, 50, 25, 75, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 100) == [99, 50, 26, 75, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(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],m = 30) == [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]\n assert candidate(queries = [5, 3, 8, 9, 2, 10, 7, 1, 4, 6],m = 10) == [4, 3, 7, 8, 5, 9, 9, 7, 8, 9]\n assert candidate(queries = [1, 4, 3, 2, 5, 6, 7, 8, 9, 10],m = 10) == [0, 3, 3, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 20) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [7, 3, 7, 3, 5, 3, 7],m = 7) == [6, 3, 1, 1, 5, 1, 2]\n assert candidate(queries = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10],m = 10) == [4, 3, 7, 6, 5, 7, 7, 7, 8, 9]\n assert candidate(queries = [5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0]\n assert candidate(queries = [5, 3, 7, 1, 9, 2, 8, 4, 6],m = 10) == [4, 3, 6, 3, 8, 5, 8, 7, 8]\n assert candidate(queries = [8, 3, 1, 7, 10, 4, 6, 5, 9, 2],m = 10) == [7, 3, 2, 7, 9, 6, 8, 8, 9, 9]\n assert candidate(queries = [5, 3, 7, 1, 4, 2, 8, 6],m = 8) == [4, 3, 6, 3, 5, 5, 7, 7]\n assert candidate(queries = [15, 8, 2, 7, 12, 14, 4, 1, 13, 6, 9, 11, 10, 5, 3],m = 15) == [14, 8, 3, 8, 12, 14, 8, 7, 14, 11, 12, 14, 14, 14, 14]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 15) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(queries = [5, 3, 8, 2, 5, 3],m = 10) == [4, 3, 7, 4, 3, 3]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7],m = 10) == [6, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 15) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(queries = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5],m = 10) == [8, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(queries = [8, 6, 4, 2, 1, 3, 5, 7],m = 8) == [7, 6, 5, 4, 4, 5, 6, 7]\n assert candidate(queries = [2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 20) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],m = 25) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],m = 20) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["[3,1,2,1]\n5", "[4,1,2,2]\n4", "[7,5,5,8,3]\n8"], "hints": ["Create the permutation P=[1,2,...,m], it could be a list for example.", "For each i, find the position of queries[i] with a simple scan over P and then move this to the beginning."], "metadata": {"canonical_parameter_names": ["queries", "m"], "leetcode_dataset_entry_point": "Solution().processQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:19+00:00", "tests_total": 97, "tests_dropped": 51, "flags": [], "topic_tags": ["array", "binary-indexed-tree", "simulation", "sqrt-decomposition"]}, "language": "python", "interface": {"raw_signature": "def processQueries(self, queries: list[int], m: int) -> list[int]:", "container": "Solution", "callable": "processQueries", "parameters": [{"name": "queries", "type": "list[int]"}, {"name": "m", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1411, "task_id": "number-of-ways-to-paint-n-3-grid", "difficulty": "Hard", "problem_description": "You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).\n\nGiven n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 1\nOutput: 12\nExplanation: There are 12 possible way to paint the grid as shown.\n\nExample 2:\n\nInput: n = 5000\nOutput: 30228214\n\nConstraints:\n\n- n == grid.length\n- 1 <= n <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 246\n assert candidate(n = 1000) == 650420578\n assert candidate(n = 100) == 905790447\n assert candidate(n = 2500) == 80958521\n assert candidate(n = 4) == 1122\n assert candidate(n = 4999) == 134620719\n assert candidate(n = 5000) == 30228214\n assert candidate(n = 2) == 54\n assert candidate(n = 1) == 12\n assert candidate(n = 500) == 350959293\n assert candidate(n = 50) == 151149117\n assert candidate(n = 10) == 10107954\n assert candidate(n = 5) == 5118\n assert candidate(n = 4000) == 685933196\n assert candidate(n = 12) == 210323922\n assert candidate(n = 2000) == 897054912\n assert candidate(n = 3750) == 477003884\n assert candidate(n = 3500) == 28484708\n assert candidate(n = 3000) == 313837042\n assert candidate(n = 30) == 462032897\n assert candidate(n = 16) == 62485141\n assert candidate(n = 8) == 485778\n assert candidate(n = 250) == 601916395\n assert candidate(n = 999) == 672393158\n assert candidate(n = 32) == 554911778\n assert candidate(n = 20) == 690883140\n assert candidate(n = 11) == 46107966\n assert candidate(n = 15) == 963045241\n assert candidate(n = 200) == 693684710\n assert candidate(n = 1234) == 18988659\n assert candidate(n = 750) == 493513580\n assert candidate(n = 4500) == 471193061\n assert candidate(n = 6) == 23346\n assert candidate(n = 7) == 106494\n assert candidate(n = 25) == 676744457\n assert candidate(n = 1500) == 814277332\n", "comparison": "exact"}, "public_tests": ["1", "5000"], "hints": ["We will use Dynamic programming approach. we will try all possible configuration.", "Let dp[idx][prev1col][prev2col][prev3col] be the number of ways to color the rows of the grid from idx to n-1 keeping in mind that the previous row (idx - 1) has colors prev1col, prev2col and prev3col. Build the dp array to get the answer."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numOfWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:23+00:00", "tests_total": 37, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "graph-coloring"]}, "language": "python", "interface": {"raw_signature": "def numOfWays(self, n: int) -> int:", "container": "Solution", "callable": "numOfWays", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1413, "task_id": "minimum-value-to-get-positive-step-by-step-sum", "difficulty": "Easy", "problem_description": "Given an array of integers nums, you start with an initial positive value startValue.\n\nIn each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).\n\nReturn the minimum positive value of startValue such that the step by step sum is never less than 1.\n\nExample 1:\n\nInput: nums = [-3,2,-3,4,2]\nOutput: 5\nExplanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.\nstep by step sum\nstartValue = 4 | startValue = 5 | nums\n (4 -3 ) = 1 | (5 -3 ) = 2 | -3\n (1 +2 ) = 3 | (2 +2 ) = 4 | 2\n (3 -3 ) = 0 | (4 -3 ) = 1 | -3\n (0 +4 ) = 4 | (1 +4 ) = 5 | 4\n (4 +2 ) = 6 | (5 +2 ) = 7 | 2\n\nExample 2:\n\nInput: nums = [1,2]\nOutput: 1\nExplanation: Minimum start value should be positive.\n\nExample 3:\n\nInput: nums = [1,-2,-3]\nOutput: 5\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- -100 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 1, -1, 1]) == 2\n assert candidate(nums = [100, 100, 100]) == 1\n assert candidate(nums = [-3, 2, -3, 4, 2]) == 5\n assert candidate(nums = [1, -2, -3]) == 5\n assert candidate(nums = [-1]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100]) == 1\n assert candidate(nums = [-100, 100, -100, 100]) == 101\n assert candidate(nums = [50, 50, 50]) == 1\n assert candidate(nums = [-100, -50, -25, -12, -6, -3, -1]) == 198\n assert candidate(nums = [0, 0, 0]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 11\n assert candidate(nums = [-100]) == 101\n assert candidate(nums = [1, 2]) == 1\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1]) == 1\n assert candidate(nums = [50, -50, 50, -50]) == 1\n assert candidate(nums = [-50, -50, -50]) == 151\n assert candidate(nums = [-1, 0, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40]) == 1\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80]) == 21\n assert candidate(nums = [5, -3, -4, 2, 0, 1, -2, -3, 4, 5]) == 5\n assert candidate(nums = [10, -5, -15, 20, -10, 5]) == 11\n assert candidate(nums = [0, -1, -2, -3, -4, -5, 6]) == 16\n assert candidate(nums = [-1, -1, -1, -1, -1, 10]) == 6\n assert candidate(nums = [100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 51\n assert candidate(nums = [0, 0, 0, 0, 0, -1, 1]) == 2\n assert candidate(nums = [100, -50, 25, -12, 62, -31, 15, -7, 3, -1]) == 1\n assert candidate(nums = [5, -3, 2, -8, 6, -1, 4, -7]) == 5\n assert candidate(nums = [10, -20, 30, -40, 50, -60]) == 31\n assert candidate(nums = [100, -50, -50, 50, -25, 25, -12, 12]) == 1\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 946\n assert candidate(nums = [5, -15, 20, -25, 30, -35, 40]) == 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]) == 11\n assert candidate(nums = [1, -100, 100, -100, 100, -100, 100, -100]) == 100\n assert candidate(nums = [-50, 50, -25, 25, -12, 12, -6, 6, -3, 3]) == 51\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 6\n assert candidate(nums = [-10, 20, -30, 40, -50, 60]) == 31\n assert candidate(nums = [-50, 50, -50, 50, -50, 50]) == 51\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 16\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3]) == 4\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\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == 1\n assert candidate(nums = [5, 5, 5, 5, -20, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50]) == 26\n assert candidate(nums = [10, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 10]) == 41\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == 1\n assert candidate(nums = [0, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [-10, 0, 10, -20, 20, -30, 30]) == 31\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [-10, -20, -30, 40, 50, -15]) == 61\n assert candidate(nums = [0, 0, 0, 0, 0, 0, -1]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6]) == 7\n assert candidate(nums = [-1, -2, -3, -4, -5, 15, -1, -1, -1, -1]) == 16\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 1\n assert candidate(nums = [-20, 10, 0, -10, 20, 0, -10, 0, 20]) == 21\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80]) == 41\n assert candidate(nums = [-50, -20, -30, 100, -10, 20]) == 101\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == 51\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == 31\n assert candidate(nums = [-10, -20, -30, -40, -50, 100]) == 151\n assert candidate(nums = [30, -10, 20, -15, 5, -5, 10, -10, 15, -20]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 6\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 1\n assert candidate(nums = [10, 20, 30, -50, 40, -10, -20, -30, 50]) == 11\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, 1, 1, 1]) == 1\n assert candidate(nums = [3, -5, 2, -1, 4, -6]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3]) == 4\n assert candidate(nums = [-50, -50, -50, 50, 50]) == 151\n assert candidate(nums = [10, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 36\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 10, 20, -50, 100]) == 21\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 151\n assert candidate(nums = [0, -1, 0, -2, 0, -3, 0, -4, 0, -5]) == 16\n assert candidate(nums = [-5, -5, -5, -5, 20, -5, -5, -5, -5]) == 21\n assert candidate(nums = [100, -50, 25, -75, 10, -10, 5, -5]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [100, -50, 25, -20, 10, -5, 1]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 551\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 1]) == 46\n assert candidate(nums = [-5, -4, -3, -2, -1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 1\n", "comparison": "exact"}, "public_tests": ["[-3,2,-3,4,2]", "[1,2]", "[1,-2,-3]"], "hints": ["Find the minimum prefix sum."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minStartValue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:26+00:00", "tests_total": 95, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minStartValue(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minStartValue", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1414, "task_id": "find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k", "difficulty": "Medium", "problem_description": "Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.\n\nThe Fibonacci numbers are defined as:\n\n- F_1 = 1\n- F_2 = 1\n- F_n = F_{n-1} + F_{n-2} for n > 2.\n\nIt is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.\n\nExample 1:\n\nInput: k = 7\nOutput: 2\nExplanation: The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ...\nFor k = 7 we can use 2 + 5 = 7.\n\nExample 2:\n\nInput: k = 10\nOutput: 2\nExplanation: For k = 10 we can use 2 + 8 = 10.\n\nExample 3:\n\nInput: k = 19\nOutput: 3\nExplanation: For k = 19 we can use 1 + 5 + 13 = 19.\n\nConstraints:\n\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 433494437) == 1\n assert candidate(k = 377) == 1\n assert candidate(k = 6765) == 1\n assert candidate(k = 24157817) == 1\n assert candidate(k = 102334155) == 1\n assert candidate(k = 89) == 1\n assert candidate(k = 121393) == 1\n assert candidate(k = 500) == 3\n assert candidate(k = 514229) == 1\n assert candidate(k = 50) == 3\n assert candidate(k = 39088169) == 1\n assert candidate(k = 21) == 1\n assert candidate(k = 2584) == 1\n assert candidate(k = 2178309) == 1\n assert candidate(k = 100) == 3\n assert candidate(k = 46368) == 1\n assert candidate(k = 233) == 1\n assert candidate(k = 63245986) == 1\n assert candidate(k = 1000000000) == 14\n assert candidate(k = 7) == 2\n assert candidate(k = 13) == 1\n assert candidate(k = 144) == 1\n assert candidate(k = 701408733) == 1\n assert candidate(k = 55) == 1\n assert candidate(k = 5702887) == 1\n assert candidate(k = 196418) == 1\n assert candidate(k = 2) == 1\n assert candidate(k = 28657) == 1\n assert candidate(k = 14930352) == 1\n assert candidate(k = 4) == 2\n assert candidate(k = 4181) == 1\n assert candidate(k = 3524578) == 1\n assert candidate(k = 17711) == 1\n assert candidate(k = 34) == 1\n assert candidate(k = 10946) == 1\n assert candidate(k = 1) == 1\n assert candidate(k = 19) == 3\n assert candidate(k = 165580141) == 1\n assert candidate(k = 3) == 1\n assert candidate(k = 610) == 1\n assert candidate(k = 8) == 1\n assert candidate(k = 317811) == 1\n assert candidate(k = 1346269) == 1\n assert candidate(k = 10) == 2\n assert candidate(k = 9227465) == 1\n assert candidate(k = 832040) == 1\n assert candidate(k = 1597) == 1\n assert candidate(k = 1000000) == 5\n assert candidate(k = 75025) == 1\n assert candidate(k = 1000) == 2\n assert candidate(k = 267914296) == 1\n assert candidate(k = 5) == 1\n assert candidate(k = 987) == 1\n assert candidate(k = 35) == 2\n assert candidate(k = 123456789) == 12\n assert candidate(k = 1234567) == 10\n assert candidate(k = 863999999) == 13\n assert candidate(k = 555555555) == 11\n assert candidate(k = 340513) == 7\n assert candidate(k = 104941883) == 11\n assert candidate(k = 999999999) == 13\n assert candidate(k = 470001109) == 13\n assert candidate(k = 55555555) == 11\n assert candidate(k = 123456) == 4\n assert candidate(k = 987654321) == 15\n", "comparison": "exact"}, "public_tests": ["7", "10", "19"], "hints": ["Generate all Fibonacci numbers up to the limit (they are few).", "Use greedy solution, taking at every time the greatest Fibonacci number which is smaller than or equal to the current number. Subtract this Fibonacci number from the current number and repeat again the process."], "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().findMinFibonacciNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:28+00:00", "tests_total": 70, "tests_dropped": 5, "flags": [], "topic_tags": ["math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def findMinFibonacciNumbers(self, k: int) -> int:", "container": "Solution", "callable": "findMinFibonacciNumbers", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1415, "task_id": "the-k-th-lexicographical-string-of-all-happy-strings-of-length-n", "difficulty": "Medium", "problem_description": "A happy string is a string that:\n\n- consists only of letters of the set ['a', 'b', 'c'].\n- s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).\n\nFor example, strings \"abc\", \"ac\", \"b\" and \"abcbabcbcb\" are all happy strings and strings \"aa\", \"baa\" and \"ababbc\" are not happy strings.\n\nGiven two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.\n\nReturn the kth string of this list or return an empty string if there are less than k happy strings of length n.\n\nExample 1:\n\nInput: n = 1, k = 3\nOutput: \"c\"\nExplanation: The list [\"a\", \"b\", \"c\"] contains all happy strings of length 1. The third string is \"c\".\n\nExample 2:\n\nInput: n = 1, k = 4\nOutput: \"\"\nExplanation: There are only 3 happy strings of length 1.\n\nExample 3:\n\nInput: n = 3, k = 9\nOutput: \"cab\"\nExplanation: There are 12 different happy string of length 3 [\"aba\", \"abc\", \"aca\", \"acb\", \"bab\", \"bac\", \"bca\", \"bcb\", \"cab\", \"cac\", \"cba\", \"cbc\"]. You will find the 9^th string = \"cab\"\n\nConstraints:\n\n- 1 <= n <= 10\n- 1 <= k <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,k = 1) == \"ababa\"\n assert candidate(n = 10,k = 100) == \"abacbabacb\"\n assert candidate(n = 1,k = 4) == \"\"\n assert candidate(n = 2,k = 5) == \"ca\"\n assert candidate(n = 5,k = 25) == \"bcaba\"\n assert candidate(n = 5,k = 20) == \"babcb\"\n assert candidate(n = 1,k = 3) == \"c\"\n assert candidate(n = 3,k = 9) == \"cab\"\n assert candidate(n = 2,k = 6) == \"cb\"\n assert candidate(n = 4,k = 15) == \"bcba\"\n assert candidate(n = 2,k = 1) == \"ab\"\n assert candidate(n = 5,k = 15) == \"acbca\"\n assert candidate(n = 5,k = 30) == \"bcbac\"\n assert candidate(n = 3,k = 12) == \"cbc\"\n assert candidate(n = 2,k = 3) == \"ba\"\n assert candidate(n = 4,k = 20) == \"cacb\"\n assert candidate(n = 3,k = 1) == \"aba\"\n assert candidate(n = 4,k = 10) == \"babc\"\n assert candidate(n = 9,k = 30) == \"ababcbcac\"\n assert candidate(n = 8,k = 33) == \"abcababa\"\n assert candidate(n = 3,k = 13) == \"\"\n assert candidate(n = 7,k = 50) == \"acbabac\"\n assert candidate(n = 1,k = 1) == \"a\"\n assert candidate(n = 7,k = 1) == \"abababa\"\n assert candidate(n = 6,k = 27) == \"acbaca\"\n assert candidate(n = 10,k = 10) == \"abababcabc\"\n assert candidate(n = 10,k = 3) == \"ababababca\"\n assert candidate(n = 10,k = 1) == \"ababababab\"\n assert candidate(n = 4,k = 25) == \"\"\n assert candidate(n = 2,k = 7) == \"\"\n assert candidate(n = 3,k = 15) == \"\"\n assert candidate(n = 6,k = 70) == \"cabcac\"\n assert candidate(n = 6,k = 30) == \"acbcac\"\n assert candidate(n = 7,k = 100) == \"bcabacb\"\n assert candidate(n = 5,k = 10) == \"acabc\"\n assert candidate(n = 6,k = 64) == \"bcbcbc\"\n assert candidate(n = 7,k = 85) == \"bacacab\"\n assert candidate(n = 5,k = 31) == \"bcbca\"\n assert candidate(n = 6,k = 42) == \"bacabc\"\n assert candidate(n = 10,k = 64) == \"ababcbcbcb\"\n assert candidate(n = 6,k = 63) == \"bcbcba\"\n assert candidate(n = 1,k = 2) == \"b\"\n assert candidate(n = 9,k = 100) == \"abcbabacb\"\n assert candidate(n = 8,k = 100) == \"acbabacb\"\n assert candidate(n = 9,k = 50) == \"abacbabac\"\n assert candidate(n = 6,k = 5) == \"abacab\"\n assert candidate(n = 8,k = 64) == \"abcbcbcb\"\n", "comparison": "exact"}, "public_tests": ["1\n3", "1\n4", "3\n9"], "hints": ["Generate recursively all the happy strings of length n.", "Sort them in lexicographical order and return the kth string if it exists."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().getHappyString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:30+00:00", "tests_total": 78, "tests_dropped": 31, "flags": [], "topic_tags": ["string", "backtracking"]}, "language": "python", "interface": {"raw_signature": "def getHappyString(self, n: int, k: int) -> str:", "container": "Solution", "callable": "getHappyString", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1416, "task_id": "restore-the-array", "difficulty": "Hard", "problem_description": "A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.\n\nGiven the string s and the integer k, return the number of the possible arrays that can be printed as s using the mentioned program. Since the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: s = \"1000\", k = 10000\nOutput: 1\nExplanation: The only possible array is [1000]\n\nExample 2:\n\nInput: s = \"1000\", k = 10\nOutput: 0\nExplanation: There cannot be an array that was printed this way and has all integer >= 1 and <= 10.\n\nExample 3:\n\nInput: s = \"1317\", k = 2000\nOutput: 8\nExplanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7]\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of only digits and does not contain leading zeros.\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"237\",k = 50) == 3\n assert candidate(s = \"111111111111111111111\",k = 11) == 17711\n assert candidate(s = \"123123123\",k = 123) == 100\n assert candidate(s = \"1317\",k = 2000) == 8\n assert candidate(s = \"99999\",k = 99999) == 16\n assert candidate(s = \"1000\",k = 10) == 0\n assert candidate(s = \"1234567891011121314151617181920\",k = 20) == 1280\n assert candidate(s = \"1000\",k = 10000) == 1\n assert candidate(s = \"1111\",k = 1) == 1\n assert candidate(s = \"123456789\",k = 9) == 1\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 11) == 134903163\n assert candidate(s = \"123123123123123123123123123123123123123123123123\",k = 321) == 171507379\n assert candidate(s = \"112233445566778899101011121314151617181920\",k = 100) == 17480761\n assert candidate(s = \"11111111111111111111\",k = 11) == 10946\n assert candidate(s = \"12345678910111213141516171819202122232425\",k = 25) == 129792\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == 1\n assert candidate(s = \"1111111111111111111111111111111111111111111111111\",k = 11) == 586268941\n assert candidate(s = \"55555555555555555555\",k = 55) == 10946\n assert candidate(s = \"987654321098765432109876543210\",k = 987654321) == 64504063\n assert candidate(s = \"999999999999999999\",k = 1000000000) == 129792\n assert candidate(s = \"999999999999999999\",k = 999999999) == 129792\n assert candidate(s = \"1230123\",k = 123) == 8\n assert candidate(s = \"1\",k = 1) == 1\n assert candidate(s = \"101010101010101010\",k = 100) == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111\",k = 100) == 778742000\n assert candidate(s = \"9999999999999999999\",k = 999999999) == 259328\n assert candidate(s = \"123456789\",k = 999999999) == 256\n assert candidate(s = \"111111111111111111\",k = 11) == 4181\n assert candidate(s = \"102030405060708090\",k = 100) == 1\n assert candidate(s = \"311131\",k = 100) == 13\n assert candidate(s = \"123456789101112\",k = 15) == 10\n assert candidate(s = \"999999999\",k = 999999999) == 256\n assert candidate(s = \"12345678901234567890\",k = 123456789) == 125704\n assert candidate(s = \"123456789101112131415161718192021222324252627282930\",k = 30) == 2076672\n assert candidate(s = \"55555555555555555555555555555555555555555555\",k = 555) == 809181231\n assert candidate(s = \"111111111111111111111111111111111111\",k = 1) == 1\n assert candidate(s = \"11111111111111111111\",k = 10) == 1\n assert candidate(s = \"111111111111111111111111111111111111111111\",k = 111) == 641778114\n assert candidate(s = \"321321321321321321321321321321321321321321\",k = 321) == 641778114\n assert candidate(s = \"314159265358979323846264338327950288419716939937510\",k = 10000) == 578862353\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 111) == 809181231\n assert candidate(s = \"123456789012345678901234567890\",k = 50000) == 23834271\n assert candidate(s = \"30303030303030303030\",k = 30) == 1\n assert candidate(s = \"9999999999999999999999999999999999999999\",k = 1000000000) == 707881333\n assert candidate(s = \"1111111111111111111\",k = 11) == 6765\n assert candidate(s = \"222222222222222222222222222222222222222222\",k = 22) == 433494437\n assert candidate(s = \"31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\",k = 1000000000) == 893659449\n assert candidate(s = \"10101010101010101010\",k = 101) == 1\n assert candidate(s = \"32791623145341\",k = 2000) == 3480\n assert candidate(s = \"123123123123123123123123\",k = 123) == 312500\n assert candidate(s = \"111213141516171819202122232425262728293031323334353637383940\",k = 40) == 287913465\n assert candidate(s = \"32767327673276732767\",k = 32767) == 338744\n assert candidate(s = \"1234567891011121314151617181920\",k = 5000) == 51814885\n assert candidate(s = \"123451234512345123451234512345123451234512345\",k = 50000) == 820858001\n assert candidate(s = \"2222222222222222222\",k = 2) == 1\n assert candidate(s = \"327683276832768\",k = 65536) == 12208\n assert candidate(s = \"987654321987654321987654321\",k = 987654321) == 65866496\n assert candidate(s = \"123456789101112131415161718192021\",k = 25) == 4992\n assert candidate(s = \"10101010101010101010101010101010101010101010\",k = 100) == 1\n assert candidate(s = \"111111111111111111111111111111111111\",k = 111) == 82876089\n assert candidate(s = \"112233445566778899\",k = 112233) == 105312\n assert candidate(s = \"1111111111111111111\",k = 1) == 1\n assert candidate(s = \"22222222222222222222\",k = 222) == 121415\n assert candidate(s = \"3034558\",k = 1000) == 20\n assert candidate(s = \"121314151617181920\",k = 20) == 256\n assert candidate(s = \"3030303030303030303\",k = 30) == 1\n assert candidate(s = \"99999999999999999999\",k = 999999999) == 518145\n assert candidate(s = \"1010101010101010101\",k = 101) == 2\n assert candidate(s = \"987654321987654321987654321987654321987654321\",k = 987654321) == 840181650\n assert candidate(s = \"12312312312312312312\",k = 123) == 31250\n assert candidate(s = \"1234567890\",k = 1000) == 125\n assert candidate(s = \"123123123123123123123123123123123123123123123123123\",k = 123) == 351558230\n assert candidate(s = \"9999999999999999999999999999999999999999\",k = 999999999) == 707881333\n assert candidate(s = \"333333333333\",k = 3333) == 1490\n assert candidate(s = \"555555555555555555555555555555555555555555555555\",k = 555) == 171507379\n assert candidate(s = \"111111111111111111111111111111\",k = 111) == 53798080\n assert candidate(s = \"12345678910111213141516171819202122232425262728293031323334353637383940\",k = 50) == 100424031\n assert candidate(s = \"1213141516171819202122232425262728293031323334353637383940\",k = 40) == 492437504\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\",k = 10) == 1\n assert candidate(s = \"474747474747474747474747474747474747474747474747\",k = 4747) == 134502416\n assert candidate(s = \"1000000000000000000000000000000000000000000000000\",k = 1000000000) == 0\n assert candidate(s = \"22222222222222222222222222222222222222222\",k = 222) == 844048728\n assert candidate(s = \"999999999999999999999999999999999999999999999999\",k = 999) == 171507379\n assert candidate(s = \"5229458433423234234234\",k = 1000000) == 1825529\n assert candidate(s = \"112233445566778899\",k = 99) == 4181\n assert candidate(s = \"12345678910\",k = 10) == 1\n assert candidate(s = \"999999999999999999999999999999999999999999\",k = 999999999) == 634726928\n assert candidate(s = \"10101010101010101010\",k = 10) == 1\n assert candidate(s = \"999999999999999999999999999999999999999999\",k = 9) == 1\n assert candidate(s = \"12345123451234512345\",k = 5000) == 250625\n assert candidate(s = \"50505050505050505050\",k = 500) == 1\n assert candidate(s = \"12345678910\",k = 100) == 55\n assert candidate(s = \"123456789123456789123456789\",k = 10000) == 28074040\n assert candidate(s = \"1000000000100000000010000000001000000000\",k = 1000000000) == 1\n assert candidate(s = \"32791879\",k = 500) == 54\n assert candidate(s = \"222222222222222222222222222222222222222222222222\",k = 22) == 778742000\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\",k = 5000) == 712104623\n assert candidate(s = \"123456789\",k = 100) == 55\n assert candidate(s = \"987654321\",k = 100000) == 236\n assert candidate(s = \"33333333333333333333\",k = 3333) == 283953\n", "comparison": "exact"}, "public_tests": ["\"1000\"\n10000", "\"1000\"\n10", "\"1317\"\n2000"], "hints": ["Use dynamic programming. Build an array dp where dp[i] is the number of ways you can divide the string starting from index i to the end.", "Keep in mind that the answer is modulo 10^9 + 7 and take the mod for each operation."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().numberOfArrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:32+00:00", "tests_total": 104, "tests_dropped": 4, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def numberOfArrays(self, s: str, k: int) -> int:", "container": "Solution", "callable": "numberOfArrays", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1417, "task_id": "reformat-the-string", "difficulty": "Easy", "problem_description": "You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).\n\nYou have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.\n\nReturn the reformatted string or return an empty string if it is impossible to reformat the string.\n\nExample 1:\n\nInput: s = \"a0b1c2\"\nOutput: \"0a1b2c\"\nExplanation: No two adjacent characters have the same type in \"0a1b2c\". \"a0b1c2\", \"0a1b2c\", \"0c2a1b\" are also valid permutations.\n\nExample 2:\n\nInput: s = \"leetcode\"\nOutput: \"\"\nExplanation: \"leetcode\" has only characters so we cannot separate them by digits.\n\nExample 3:\n\nInput: s = \"1229857369\"\nOutput: \"\"\nExplanation: \"1229857369\" has only digits so we cannot separate them by characters.\n\nConstraints:\n\n- 1 <= s.length <= 500\n- s consists of only lowercase English letters and/or digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a1b1\") == \"a1b1\"\n assert candidate(s = \"1229857369\") == \"\"\n assert candidate(s = \"aa1\") == \"a1a\"\n assert candidate(s = \"abc123def456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"0123456789abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"111\") == \"\"\n assert candidate(s = \"ab123\") == \"1a2b3\"\n assert candidate(s = \"1a\") == \"a1\"\n assert candidate(s = \"aabbcc123\") == \"\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"1234\") == \"\"\n assert candidate(s = \"a0b1c2d3e4f5g6h7i8j9\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"ab12cd34\") == \"a1b2c3d4\"\n assert candidate(s = \"a1\") == \"a1\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1a2b3c4d\") == \"a1b2c3d4\"\n assert candidate(s = \"ab\") == \"\"\n assert candidate(s = \"a0b1c2\") == \"a0b1c2\"\n assert candidate(s = \"1a2b3c\") == \"a1b2c3\"\n assert candidate(s = \"a1b2c3\") == \"a1b2c3\"\n assert candidate(s = \"abcd1234\") == \"a1b2c3d4\"\n assert candidate(s = \"112233aabbcc\") == \"a1a1b2b2c3c3\"\n assert candidate(s = \"aaa\") == \"\"\n assert candidate(s = \"leetcode\") == \"\"\n assert candidate(s = \"a1b2c3d4\") == \"a1b2c3d4\"\n assert candidate(s = \"11a\") == \"1a1\"\n assert candidate(s = \"112233aabb\") == \"\"\n assert candidate(s = \"1a2b3c4d5e\") == \"a1b2c3d4e5\"\n assert candidate(s = \"abc\") == \"\"\n assert candidate(s = \"111222abc\") == \"\"\n assert candidate(s = \"12\") == \"\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0123456789\") == \"\"\n assert candidate(s = \"1\") == \"1\"\n assert candidate(s = \"aab\") == \"\"\n assert candidate(s = \"123abc\") == \"a1b2c3\"\n assert candidate(s = \"aabbcc112233\") == \"a1a1b2b2c3c3\"\n assert candidate(s = \"0a0b0c0d\") == \"a0b0c0d0\"\n assert candidate(s = \"123\") == \"\"\n assert candidate(s = \"1a1b\") == \"a1b1\"\n assert candidate(s = \"c0d1e2f3\") == \"c0d1e2f3\"\n assert candidate(s = \"1234abcd\") == \"a1b2c3d4\"\n assert candidate(s = \"zzzz1111\") == \"z1z1z1z1\"\n assert candidate(s = \"9a8b7c6d5e4f3g2h1i0\") == \"9a8b7c6d5e4f3g2h1i0\"\n assert candidate(s = \"0z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1\") == \"0z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"0000000000aaaaaaaaaa\") == \"a0a0a0a0a0a0a0a0a0a0\"\n assert candidate(s = \"abcdefghij123456789\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"0j9i8h7g6f5e4d3c2b1a\") == \"j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"9876543210qwerty\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"\n assert candidate(s = \"123abc456def789ghi0\") == \"1a2b3c4d5e6f7g8h9i0\"\n assert candidate(s = \"90ijkl5678efgh1234abcd\") == \"\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1\") == \"a1b1c1d1e1f1g1h1i1j1k1\"\n assert candidate(s = \"1z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\") == \"1z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\"\n assert candidate(s = \"9876543210zyxcba\") == \"\"\n assert candidate(s = \"abcde12345fghij67890\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5\") == \"a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5\"\n assert candidate(s = \"000aaa111bbb222ccc\") == \"a0a0a0b1b1b1c2c2c2\"\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"0a1b2c3d4e5f6g7h8i9j\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"aabbccddeeff11223344\") == \"\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0\") == \"a0b0c0d0e0f0g0h0i0j0\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9\"\n assert candidate(s = \"a1a1a1b2b2b2\") == \"a1a1a1b2b2b2\"\n assert candidate(s = \"9876543210zyxwvutsrqponmlkjihgfedcba\") == \"\"\n assert candidate(s = \"aabbccddeeff112233445566\") == \"a1a1b2b2c3c3d4d4e5e5f6f6\"\n assert candidate(s = \"abc123abc123abc123\") == \"a1b2c3a1b2c3a1b2c3\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\"\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq0987654321\") == \"\"\n assert candidate(s = \"1111aaaa\") == \"a1a1a1a1\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"1a2b3c4d5e6f\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"0123456789abcdefghij\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t\") == \"a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\"\n assert candidate(s = \"123456789abcdefghij\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p1234567890\") == \"\"\n assert candidate(s = \"abcd1234efgh5678ijkl0987\") == \"a1b2c3d4e5f6g7h8i0j9k8l7\"\n assert candidate(s = \"aaaaaaaaa11111111\") == \"a1a1a1a1a1a1a1a1a\"\n assert candidate(s = \"abcd0123efgh4567ijkl89\") == \"\"\n assert candidate(s = \"1234abcd5678abcd\") == \"a1b2c3d4a5b6c7d8\"\n assert candidate(s = \"0987654321abcdef\") == \"\"\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0\") == \"0a0b0c0d0e0f0g0h0i0j0\"\n assert candidate(s = \"12345abcde67890fghij\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"11223344556677889900\") == \"\"\n assert candidate(s = \"abcdefg123456\") == \"a1b2c3d4e5f6g\"\n assert candidate(s = \"abcdefghij0123456789\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"a0b1c2d3\") == \"a0b1c2d3\"\n assert candidate(s = \"0987654321jihgfedcba\") == \"j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"abcdef123456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k\") == \"a1b2c3d4e5f6g7h8i9j0k\"\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0k0\") == \"0a0b0c0d0e0f0g0h0i0j0k0\"\n assert candidate(s = \"abc123def456ghi789j0\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm\") == \"\"\n assert candidate(s = \"123456abcdef\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"112233445566778899aabbccddeeffgghhii\") == \"a1a1b2b2c3c3d4d4e5e5f6f6g7g7h8h8i9i9\"\n assert candidate(s = \"abcd1234abcd5678\") == \"a1b2c3d4a5b6c7d8\"\n assert candidate(s = \"abcd1234abcd1234\") == \"a1b2c3d4a1b2c3d4\"\n assert candidate(s = \"9876543210\") == \"\"\n assert candidate(s = \"121212abcabc\") == \"a1b2c1a2b1c2\"\n assert candidate(s = \"a1a1a1a1a1122334455\") == \"\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == \"a1b1c1d1e1f1g1h1i1j1\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == \"z9y8x7w6v5u4t3s2r1q0p\"\n assert candidate(s = \"abc123def456ghi789\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccdddddddd\") == \"\"\n assert candidate(s = \"0abcdefghij123456789\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"1a2a3a4a5a\") == \"a1a2a3a4a5\"\n assert candidate(s = \"abcdefghij1234567890\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"012345abcde67890fghij\") == \"0a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1a2b3c4d5\") == \"1a2b3c4d5\"\n assert candidate(s = \"1234abcd1234abcd\") == \"a1b2c3d4a1b2c3d4\"\n assert candidate(s = \"a1b2a1b2a1b2a1b2\") == \"a1b2a1b2a1b2a1b2\"\n assert candidate(s = \"000aaa111bbb222ccc333ddd\") == \"a0a0a0b1b1b1c2c2c2d3d3d3\"\n assert candidate(s = \"abcd1234efgh5678ijkl90\") == \"\"\n assert candidate(s = \"abcdefghij\") == \"\"\n assert candidate(s = \"abcdefghij12345678901\") == \"1a2b3c4d5e6f7g8h9i0j1\"\n assert candidate(s = \"aabbccddeeffgghhiijj\") == \"\"\n assert candidate(s = \"123abc456def789ghi0jkl\") == \"\"\n assert candidate(s = \"9a8b7c6d\") == \"a9b8c7d6\"\n assert candidate(s = \"1234567890\") == \"\"\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9\") == \"a1a2a3a4a5a6a7a8a9\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\") == \"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\"\n assert candidate(s = \"0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"00112233445566778899\") == \"\"\n assert candidate(s = \"1234567890abcdefghij\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"11111111111111111111aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"\"\n assert candidate(s = \"xyz987uvw654tsr321\") == \"x9y8z7u6v5w4t3s2r1\"\n assert candidate(s = \"zzzzzzzzz99999999\") == \"z9z9z9z9z9z9z9z9z\"\n assert candidate(s = \"abc123\") == \"a1b2c3\"\n assert candidate(s = \"abcdef1234567890\") == \"\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"0000aaaa\") == \"a0a0a0a0\"\n assert candidate(s = \"654321fedcba\") == \"f6e5d4c3b2a1\"\n", "comparison": "exact"}, "public_tests": ["\"a0b1c2\"", "\"leetcode\"", "\"1229857369\""], "hints": ["Count the number of letters and digits in the string. if cntLetters - cntDigits has any of the values [-1, 0, 1] we have an answer, otherwise we don't have any answer.", "Build the string anyway as you wish. Keep in mind that you need to start with the type that has more characters if cntLetters ≠ cntDigits."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().reformat", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:34+00:00", "tests_total": 136, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def reformat(self, s: str) -> str:", "container": "Solution", "callable": "reformat", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1418, "task_id": "display-table-of-food-orders-in-a-restaurant", "difficulty": "Medium", "problem_description": "Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerName_i,tableNumber_i,foodItem_i] where customerName_i is the name of the customer, tableNumber_i is the table customer sit at, and foodItem_i is the item customer orders.\n\nReturn the restaurant's “display table”. The “display table” is a table whose row entries denote how many of each food item each table ordered. The first column is the table number and the remaining columns correspond to each food item in alphabetical order. The first row should be a header whose first column is “Table”, followed by the names of the food items. Note that the customer names are not part of the table. Additionally, the rows should be sorted in numerically increasing order.\n\nExample 1:\n\nInput: orders = [[\"David\",\"3\",\"Ceviche\"],[\"Corina\",\"10\",\"Beef Burrito\"],[\"David\",\"3\",\"Fried Chicken\"],[\"Carla\",\"5\",\"Water\"],[\"Carla\",\"5\",\"Ceviche\"],[\"Rous\",\"3\",\"Ceviche\"]]\nOutput: [[\"Table\",\"Beef Burrito\",\"Ceviche\",\"Fried Chicken\",\"Water\"],[\"3\",\"0\",\"2\",\"1\",\"0\"],[\"5\",\"0\",\"1\",\"0\",\"1\"],[\"10\",\"1\",\"0\",\"0\",\"0\"]]\nExplanation:\nThe displaying table looks like:\nTable,Beef Burrito,Ceviche,Fried Chicken,Water\n3 ,0 ,2 ,1 ,0\n5 ,0 ,1 ,0 ,1\n10 ,1 ,0 ,0 ,0\nFor the table 3: David orders \"Ceviche\" and \"Fried Chicken\", and Rous orders \"Ceviche\".\nFor the table 5: Carla orders \"Water\" and \"Ceviche\".\nFor the table 10: Corina orders \"Beef Burrito\".\n\nExample 2:\n\nInput: orders = [[\"James\",\"12\",\"Fried Chicken\"],[\"Ratesh\",\"12\",\"Fried Chicken\"],[\"Amadeus\",\"12\",\"Fried Chicken\"],[\"Adam\",\"1\",\"Canadian Waffles\"],[\"Brianna\",\"1\",\"Canadian Waffles\"]]\nOutput: [[\"Table\",\"Canadian Waffles\",\"Fried Chicken\"],[\"1\",\"2\",\"0\"],[\"12\",\"0\",\"3\"]]\nExplanation:\nFor the table 1: Adam and Brianna order \"Canadian Waffles\".\nFor the table 12: James, Ratesh and Amadeus order \"Fried Chicken\".\n\nExample 3:\n\nInput: orders = [[\"Laura\",\"2\",\"Bean Burrito\"],[\"Jhon\",\"2\",\"Beef Burrito\"],[\"Melissa\",\"2\",\"Soda\"]]\nOutput: [[\"Table\",\"Bean Burrito\",\"Beef Burrito\",\"Soda\"],[\"2\",\"1\",\"1\",\"1\"]]\n\nConstraints:\n\n- 1 <= orders.length <= 5 * 10^4\n- orders[i].length == 3\n- 1 <= customerName_i.length, foodItem_i.length <= 20\n- customerName_i and foodItem_i consist of lowercase and uppercase English letters and the space character.\n- tableNumber_i is a valid integer between 1 and 500.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '1', '0'], ['2', '1', '1'], ['3', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '1'], ['2', '1', '0', '1']]\n assert candidate(orders = [['Laura', '2', 'Bean Burrito'], ['Jhon', '2', 'Beef Burrito'], ['Melissa', '2', 'Soda']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Soda'], ['2', '1', '1', '1']]\n assert candidate(orders = [['David', '3', 'Ceviche'], ['Corina', '10', 'Beef Burrito'], ['David', '3', 'Fried Chicken'], ['Carla', '5', 'Water'], ['Carla', '5', 'Ceviche'], ['Rous', '3', 'Ceviche']]) == [['Table', 'Beef Burrito', 'Ceviche', 'Fried Chicken', 'Water'], ['3', '0', '2', '1', '0'], ['5', '0', '1', '0', '1'], ['10', '1', '0', '0', '0']]\n assert candidate(orders = [['James', '12', 'Fried Chicken'], ['Ratesh', '12', 'Fried Chicken'], ['Amadeus', '12', 'Fried Chicken'], ['Adam', '1', 'Canadian Waffles'], ['Brianna', '1', 'Canadian Waffles']]) == [['Table', 'Canadian Waffles', 'Fried Chicken'], ['1', '2', '0'], ['12', '0', '3']]\n assert candidate(orders = [['Sam', '2', 'Chocolate Cake'], ['Anna', '4', 'Fried Chicken'], ['Elsa', '4', 'Chocolate Cake'], ['Olaf', '2', 'Fried Chicken'], ['Kristoff', '4', 'Veggie Delight'], ['Sven', '2', 'Beef Burrito'], ['Hans', '4', 'Beef Burrito'], ['Kristoff', '2', 'Beef Burrito'], ['Anna', '1', 'Spring Roll'], ['Kristoff', '1', 'Fried Chicken'], ['Sven', '1', 'Chocolate Cake'], ['Olaf', '3', 'Veggie Delight'], ['Hans', '3', 'Beef Burrito'], ['Kristoff', '3', 'Beef Burrito'], ['Anna', '3', 'Chocolate Cake'], ['Elsa', '3', 'Spring Roll'], ['Olaf', '1', 'Veggie Delight'], ['Hans', '2', 'Fried Chicken']]) == [['Table', 'Beef Burrito', 'Chocolate Cake', 'Fried Chicken', 'Spring Roll', 'Veggie Delight'], ['1', '0', '1', '1', '1', '1'], ['2', '2', '1', '2', '0', '0'], ['3', '2', '1', '0', '1', '1'], ['4', '1', '1', '1', '0', '1']]\n assert candidate(orders = [['Ella', '1', 'Egg Muffin'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Egg Muffin'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Bagel Sandwich'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Tomato Juice'], ['Ella', '1', 'Bagel Sandwich'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Chicken Salad'], ['Nathan', '2', 'Chicken Salad'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Chicken Salad'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Chicken Salad']]) == [['Table', 'Bagel Sandwich', 'Chicken Salad', 'Egg Muffin', 'Tomato Juice'], ['1', '2', '2', '2', '4'], ['2', '4', '2', '3', '1']]\n assert candidate(orders = [['Alice', '1', 'Beef Burrito'], ['Bob', '2', 'Chicken Curry'], ['Charlie', '3', 'Shrimp Fried Rice'], ['David', '4', 'Spicy Noodles'], ['Eve', '5', 'Vegetable Stir Fry'], ['Frank', '1', 'Beef Burrito'], ['Grace', '2', 'Chicken Curry'], ['Hank', '3', 'Shrimp Fried Rice'], ['Ivy', '4', 'Spicy Noodles'], ['Jack', '5', 'Vegetable Stir Fry'], ['Kathy', '1', 'Beef Burrito'], ['Leo', '2', 'Chicken Curry'], ['Mona', '3', 'Shrimp Fried Rice'], ['Nate', '4', 'Spicy Noodles'], ['Oscar', '5', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['1', '3', '0', '0', '0', '0'], ['2', '0', '3', '0', '0', '0'], ['3', '0', '0', '3', '0', '0'], ['4', '0', '0', '0', '3', '0'], ['5', '0', '0', '0', '0', '3']]\n assert candidate(orders = [['John', '1', 'Chocolate Cake'], ['Alice', '2', 'Vanilla Ice Cream'], ['Bob', '3', 'Strawberry Shake'], ['Charlie', '4', 'Chocolate Cake'], ['David', '5', 'Vanilla Ice Cream'], ['Eve', '6', 'Strawberry Shake'], ['Frank', '7', 'Chocolate Cake'], ['Grace', '8', 'Vanilla Ice Cream'], ['Hannah', '9', 'Strawberry Shake'], ['Ian', '10', 'Chocolate Cake'], ['Jack', '11', 'Vanilla Ice Cream'], ['Katherine', '12', 'Strawberry Shake'], ['Laura', '13', 'Chocolate Cake'], ['Michael', '14', 'Vanilla Ice Cream'], ['Nancy', '15', 'Strawberry Shake'], ['Oliver', '16', 'Chocolate Cake'], ['Penelope', '17', 'Vanilla Ice Cream'], ['Quinn', '18', 'Strawberry Shake'], ['Rachel', '19', 'Chocolate Cake'], ['Sam', '20', 'Vanilla Ice Cream'], ['Trent', '21', 'Strawberry Shake'], ['Uma', '22', 'Chocolate Cake'], ['Victor', '23', 'Vanilla Ice Cream'], ['Wendy', '24', 'Strawberry Shake'], ['Xander', '25', 'Chocolate Cake'], ['Yvonne', '26', 'Vanilla Ice Cream'], ['Zane', '27', 'Strawberry Shake']]) == [['Table', 'Chocolate Cake', 'Strawberry Shake', 'Vanilla Ice Cream'], ['1', '1', '0', '0'], ['2', '0', '0', '1'], ['3', '0', '1', '0'], ['4', '1', '0', '0'], ['5', '0', '0', '1'], ['6', '0', '1', '0'], ['7', '1', '0', '0'], ['8', '0', '0', '1'], ['9', '0', '1', '0'], ['10', '1', '0', '0'], ['11', '0', '0', '1'], ['12', '0', '1', '0'], ['13', '1', '0', '0'], ['14', '0', '0', '1'], ['15', '0', '1', '0'], ['16', '1', '0', '0'], ['17', '0', '0', '1'], ['18', '0', '1', '0'], ['19', '1', '0', '0'], ['20', '0', '0', '1'], ['21', '0', '1', '0'], ['22', '1', '0', '0'], ['23', '0', '0', '1'], ['24', '0', '1', '0'], ['25', '1', '0', '0'], ['26', '0', '0', '1'], ['27', '0', '1', '0']]\n assert candidate(orders = [['Laura', '10', 'Chocolate Cake'], ['Laura', '10', 'Chocolate Cake'], ['Laura', '10', 'Vanilla Ice Cream'], ['Laura', '20', 'Vanilla Ice Cream'], ['Laura', '20', 'Chocolate Cake'], ['Laura', '20', 'Chocolate Cake'], ['Laura', '30', 'Chocolate Cake'], ['Laura', '30', 'Vanilla Ice Cream'], ['Laura', '30', 'Vanilla Ice Cream'], ['Laura', '30', 'Vanilla Ice Cream']]) == [['Table', 'Chocolate Cake', 'Vanilla Ice Cream'], ['10', '2', '1'], ['20', '2', '1'], ['30', '1', '3']]\n assert candidate(orders = [['Zoe', '10', 'Ice Cream'], ['Chris', '15', 'Water'], ['Diana', '10', 'Ice Cream'], ['Eli', '20', 'Beef Burrito'], ['Finn', '15', 'Water'], ['George', '20', 'Beef Burrito'], ['Hannah', '10', 'Water'], ['Ian', '20', 'Ice Cream'], ['Jack', '15', 'Ice Cream'], ['Katie', '10', 'Beef Burrito'], ['Lucas', '20', 'Water'], ['Mia', '15', 'Ice Cream'], ['Noah', '10', 'Beef Burrito'], ['Oliver', '20', 'Water'], ['Penelope', '15', 'Ice Cream'], ['Quinn', '10', 'Beef Burrito'], ['Ryan', '20', 'Water'], ['Sophia', '15', 'Ice Cream'], ['Thomas', '10', 'Beef Burrito'], ['Uma', '20', 'Water'], ['Victor', '15', 'Ice Cream'], ['Will', '10', 'Beef Burrito'], ['Xander', '20', 'Water'], ['Yara', '15', 'Ice Cream'], ['Zane', '10', 'Beef Burrito']]) == [['Table', 'Beef Burrito', 'Ice Cream', 'Water'], ['10', '6', '2', '1'], ['15', '0', '6', '2'], ['20', '2', '1', '5']]\n assert candidate(orders = [['Emily', '1', 'Garden Salad'], ['Madison', '2', 'Grilled Cheese'], ['Emily', '3', 'Club Sandwich'], ['Madison', '1', 'Club Sandwich'], ['Emily', '2', 'Grilled Cheese'], ['Madison', '3', 'Garden Salad'], ['Avery', '1', 'Caesar Salad'], ['Chloe', '2', 'Chicken Salad'], ['Avery', '3', 'Grilled Cheese'], ['Chloe', '1', 'Club Sandwich'], ['Avery', '2', 'Garden Salad'], ['Chloe', '3', 'Caesar Salad'], ['Hannah', '1', 'Chicken Salad'], ['Ella', '2', 'Caesar Salad'], ['Hannah', '3', 'Grilled Cheese'], ['Ella', '1', 'Garden Salad'], ['Hannah', '2', 'Club Sandwich'], ['Ella', '3', 'Chicken Salad']]) == [['Table', 'Caesar Salad', 'Chicken Salad', 'Club Sandwich', 'Garden Salad', 'Grilled Cheese'], ['1', '1', '1', '2', '2', '0'], ['2', '1', '1', '1', '1', '2'], ['3', '1', '1', '1', '1', '2']]\n assert candidate(orders = [['Sophia', '15', 'Penne Arrabbiata'], ['Ava', '15', 'Margherita Pizza'], ['Mia', '15', 'Penne Arrabbiata'], ['Ella', '15', 'Margherita Pizza'], ['Olivia', '15', 'Margherita Pizza'], ['Sophia', '16', 'Caesar Salad'], ['Ava', '16', 'Caesar Salad'], ['Mia', '16', 'Penne Arrabbiata'], ['Ella', '16', 'Caesar Salad'], ['Olivia', '16', 'Penne Arrabbiata'], ['Sophia', '17', 'Tiramisu'], ['Ava', '17', 'Penne Arrabbiata'], ['Mia', '17', 'Caesar Salad'], ['Ella', '17', 'Tiramisu'], ['Olivia', '17', 'Margherita Pizza'], ['Sophia', '18', 'Vanilla Ice Cream'], ['Ava', '18', 'Tiramisu'], ['Mia', '18', 'Caesar Salad'], ['Ella', '18', 'Vanilla Ice Cream'], ['Olivia', '18', 'Margherita Pizza'], ['Sophia', '19', 'Penne Arrabbiata'], ['Ava', '19', 'Vanilla Ice Cream'], ['Mia', '19', 'Caesar Salad'], ['Ella', '19', 'Margherita Pizza'], ['Olivia', '19', 'Penne Arrabbiata']]) == [['Table', 'Caesar Salad', 'Margherita Pizza', 'Penne Arrabbiata', 'Tiramisu', 'Vanilla Ice Cream'], ['15', '0', '3', '2', '0', '0'], ['16', '3', '0', '2', '0', '0'], ['17', '1', '1', '1', '2', '0'], ['18', '1', '1', '0', '1', '2'], ['19', '1', '1', '2', '0', '1']]\n assert candidate(orders = [['Alice', '10', 'Beef Burrito'], ['Bob', '5', 'Spring Roll'], ['Charlie', '10', 'Spring Roll'], ['David', '3', 'Beef Burrito'], ['Eve', '3', 'Spring Roll'], ['Frank', '5', 'Veggie Delight'], ['Grace', '1', 'Beef Burrito'], ['Heidi', '5', 'Beef Burrito'], ['Ivy', '1', 'Spring Roll'], ['Jack', '3', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '0'], ['3', '1', '1', '1'], ['5', '1', '1', '1'], ['10', '1', '1', '0']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Jerry', '3', 'Spring Roll'], ['Anna', '3', 'Beef Burrito'], ['Tom', '3', 'Veggie Delight'], ['Jerry', '2', 'Spring Roll']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '1'], ['2', '1', '1', '1'], ['3', '1', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '5', '5', '5'], ['2', '5', '0', '5']]\n assert candidate(orders = [['Zach', '1', 'Spaghetti Carbonara'], ['Kyle', '2', 'Margherita Pizza'], ['Zach', '3', 'Caesar Salad'], ['Kyle', '1', 'Caesar Salad'], ['Zach', '2', 'Margherita Pizza'], ['Kyle', '3', 'Spaghetti Carbonara'], ['Mia', '1', 'Lasagna'], ['Noah', '2', 'Caesar Salad'], ['Mia', '3', 'Margherita Pizza'], ['Noah', '1', 'Spaghetti Carbonara'], ['Mia', '2', 'Lasagna'], ['Noah', '3', 'Caesar Salad'], ['Isabella', '1', 'Margherita Pizza'], ['Oliver', '2', 'Spaghetti Carbonara'], ['Isabella', '3', 'Caesar Salad'], ['Oliver', '1', 'Lasagna'], ['Isabella', '2', 'Margherita Pizza'], ['Oliver', '3', 'Spaghetti Carbonara']]) == [['Table', 'Caesar Salad', 'Lasagna', 'Margherita Pizza', 'Spaghetti Carbonara'], ['1', '1', '2', '1', '2'], ['2', '1', '1', '3', '1'], ['3', '3', '0', '1', '2']]\n assert candidate(orders = [['Amy', '5', 'Taco'], ['Brian', '4', 'Taco'], ['Chris', '5', 'Grilled Cheese'], ['Dan', '4', 'Taco'], ['Eli', '6', 'Grilled Cheese'], ['Fiona', '4', 'Salad'], ['George', '6', 'Salad'], ['Hannah', '4', 'Grilled Cheese'], ['Ian', '5', 'Salad']]) == [['Table', 'Grilled Cheese', 'Salad', 'Taco'], ['4', '1', '1', '2'], ['5', '1', '1', '1'], ['6', '1', '1', '0']]\n assert candidate(orders = [['Zoe', '1', 'Chicken Curry'], ['Jackson', '1', 'Prawn Curry'], ['Ava', '2', 'Chicken Curry'], ['Noah', '2', 'Prawn Curry'], ['James', '2', 'Chicken Curry'], ['Sophia', '3', 'Chicken Curry'], ['Mia', '3', 'Prawn Curry'], ['Emma', '3', 'Chicken Curry'], ['Olivia', '3', 'Chicken Curry'], ['Jackson', '4', 'Chicken Curry'], ['Zoe', '4', 'Prawn Curry'], ['Ava', '4', 'Chicken Curry'], ['Noah', '4', 'Prawn Curry'], ['James', '4', 'Chicken Curry'], ['Sophia', '4', 'Chicken Curry'], ['Mia', '4', 'Prawn Curry'], ['Emma', '4', 'Chicken Curry'], ['Olivia', '4', 'Chicken Curry'], ['Jackson', '5', 'Chicken Curry'], ['Zoe', '5', 'Prawn Curry'], ['Ava', '5', 'Chicken Curry'], ['Noah', '5', 'Prawn Curry'], ['James', '5', 'Chicken Curry'], ['Sophia', '5', 'Chicken Curry'], ['Mia', '5', 'Prawn Curry'], ['Emma', '5', 'Chicken Curry'], ['Olivia', '5', 'Chicken Curry']]) == [['Table', 'Chicken Curry', 'Prawn Curry'], ['1', '1', '1'], ['2', '2', '1'], ['3', '3', '1'], ['4', '6', '3'], ['5', '6', '3']]\n assert candidate(orders = [['Sam', '10', 'Steak'], ['Alex', '20', 'Pasta'], ['Chris', '10', 'Salmon'], ['Rachel', '20', 'Steak'], ['Mike', '30', 'Lasagna'], ['Liz', '10', 'Pasta'], ['Jake', '20', 'Salmon'], ['Amy', '30', 'Steak'], ['Tom', '10', 'Lasagna'], ['Jessica', '20', 'Pasta'], ['Scott', '30', 'Salmon'], ['Melissa', '10', 'Steak'], ['Chris', '20', 'Lasagna'], ['Samantha', '30', 'Pasta'], ['Neil', '10', 'Salmon'], ['James', '20', 'Steak'], ['Ava', '30', 'Lasagna'], ['Eric', '10', 'Pasta'], ['Sophia', '20', 'Salmon'], ['Daniel', '30', 'Steak'], ['Ella', '10', 'Lasagna'], ['Andrew', '20', 'Pasta'], ['Isabella', '30', 'Salmon'], ['Matthew', '10', 'Steak'], ['Olivia', '20', 'Lasagna'], ['William', '30', 'Pasta'], ['Ava', '10', 'Salmon'], ['Mia', '20', 'Steak'], ['Elijah', '30', 'Lasagna'], ['Emma', '10', 'Pasta'], ['Ethan', '20', 'Salmon'], ['Alexander', '30', 'Steak'], ['Sophia', '10', 'Lasagna'], ['Benjamin', '20', 'Pasta'], ['Abigail', '30', 'Salmon'], ['Daniel', '10', 'Steak']]) == [['Table', 'Lasagna', 'Pasta', 'Salmon', 'Steak'], ['10', '3', '3', '3', '4'], ['20', '2', '4', '3', '3'], ['30', '3', '2', '3', '3']]\n assert candidate(orders = [['Michael', '1', 'Margherita Pizza'], ['Emily', '1', 'Caesar Salad'], ['John', '2', 'Margherita Pizza'], ['John', '2', 'Caesar Salad'], ['Sarah', '3', 'Caesar Salad'], ['David', '4', 'Margherita Pizza'], ['David', '4', 'Caesar Salad'], ['David', '4', 'Tiramisu']]) == [['Table', 'Caesar Salad', 'Margherita Pizza', 'Tiramisu'], ['1', '1', '1', '0'], ['2', '1', '1', '0'], ['3', '1', '0', '0'], ['4', '1', '1', '1']]\n assert candidate(orders = [['Anna', '300', 'Eggplant Parmesan'], ['Bob', '300', 'Lasagna'], ['Charlie', '300', 'Eggplant Parmesan'], ['David', '299', 'Lasagna'], ['Eve', '299', 'Eggplant Parmesan'], ['Frank', '298', 'Eggplant Parmesan'], ['Grace', '298', 'Lasagna'], ['Heidi', '298', 'Eggplant Parmesan'], ['Ian', '297', 'Lasagna'], ['Jenny', '297', 'Eggplant Parmesan'], ['Katie', '297', 'Lasagna'], ['Leo', '297', 'Eggplant Parmesan'], ['Mandy', '296', 'Eggplant Parmesan'], ['Neil', '296', 'Lasagna'], ['Oliver', '296', 'Eggplant Parmesan'], ['Paul', '295', 'Eggplant Parmesan'], ['Quincy', '295', 'Lasagna'], ['Rachel', '295', 'Eggplant Parmesan'], ['Steve', '295', 'Lasagna'], ['Tina', '294', 'Eggplant Parmesan'], ['Uma', '294', 'Lasagna'], ['Victor', '294', 'Eggplant Parmesan'], ['Wanda', '294', 'Lasagna'], ['Xander', '293', 'Eggplant Parmesan'], ['Yvonne', '293', 'Lasagna'], ['Zane', '293', 'Eggplant Parmesan'], ['Aaron', '292', 'Eggplant Parmesan'], ['Ben', '292', 'Lasagna'], ['Charlie', '292', 'Eggplant Parmesan'], ['David', '292', 'Lasagna'], ['Eve', '291', 'Eggplant Parmesan'], ['Frank', '291', 'Lasagna'], ['Grace', '291', 'Eggplant Parmesan'], ['Hannah', '291', 'Eggplant Parmesan'], ['Ian', '290', 'Eggplant Parmesan'], ['Jack', '290', 'Lasagna'], ['Karen', '289', 'Eggplant Parmesan'], ['Leo', '289', 'Lasagna'], ['Maggie', '288', 'Eggplant Parmesan'], ['Nancy', '288', 'Lasagna'], ['Oscar', '287', 'Eggplant Parmesan'], ['Paul', '287', 'Lasagna'], ['Quinn', '286', 'Eggplant Parmesan'], ['Rachel', '286', 'Lasagna'], ['Steve', '285', 'Eggplant Parmesan'], ['Tina', '285', 'Lasagna'], ['Uma', '284', 'Eggplant Parmesan'], ['Victor', '284', 'Lasagna'], ['Wanda', '283', 'Eggplant Parmesan'], ['Xander', '283', 'Lasagna'], ['Yvonne', '282', 'Eggplant Parmesan'], ['Zane', '282', 'Lasagna']]) == [['Table', 'Eggplant Parmesan', 'Lasagna'], ['282', '1', '1'], ['283', '1', '1'], ['284', '1', '1'], ['285', '1', '1'], ['286', '1', '1'], ['287', '1', '1'], ['288', '1', '1'], ['289', '1', '1'], ['290', '1', '1'], ['291', '3', '1'], ['292', '2', '2'], ['293', '2', '1'], ['294', '2', '2'], ['295', '2', '2'], ['296', '2', '1'], ['297', '2', '2'], ['298', '2', '1'], ['299', '1', '1'], ['300', '2', '1']]\n assert candidate(orders = [['Sarah', '1', 'Steak'], ['Jessica', '2', 'Pasta'], ['Sarah', '3', 'Sushi'], ['Jessica', '1', 'Sushi'], ['Sarah', '2', 'Pasta'], ['Jessica', '3', 'Steak'], ['Emma', '1', 'Veggie Soup'], ['Olivia', '2', 'Steak'], ['Emma', '3', 'Pasta'], ['Olivia', '1', 'Sushi'], ['Emma', '2', 'Veggie Soup'], ['Olivia', '3', 'Steak'], ['Ava', '1', 'Sushi'], ['Sophia', '2', 'Veggie Soup'], ['Ava', '3', 'Steak'], ['Sophia', '1', 'Pasta'], ['Ava', '2', 'Sushi'], ['Sophia', '3', 'Veggie Soup']]) == [['Table', 'Pasta', 'Steak', 'Sushi', 'Veggie Soup'], ['1', '1', '1', '3', '1'], ['2', '2', '1', '1', '2'], ['3', '1', '3', '1', '1']]\n assert candidate(orders = [['Amy', '100', 'Lasagna'], ['Ben', '150', 'Pasta'], ['Cathy', '100', 'Salad'], ['Dan', '200', 'Lasagna'], ['Eve', '150', 'Pasta'], ['Frank', '200', 'Salad'], ['Grace', '100', 'Pasta'], ['Hank', '150', 'Salad'], ['Ivy', '200', 'Pasta'], ['Jack', '100', 'Salad'], ['Kara', '150', 'Pasta'], ['Liam', '200', 'Lasagna'], ['Mia', '100', 'Pasta'], ['Noam', '150', 'Salad'], ['Olivia', '200', 'Pasta'], ['Paul', '100', 'Salad'], ['Quinn', '150', 'Pasta'], ['Remy', '200', 'Lasagna'], ['Sara', '100', 'Pasta'], ['Tom', '150', 'Salad'], ['Ula', '200', 'Pasta'], ['Victor', '100', 'Salad'], ['Will', '150', 'Pasta'], ['Xena', '200', 'Lasagna'], ['Yara', '100', 'Pasta'], ['Zane', '150', 'Salad']]) == [['Table', 'Lasagna', 'Pasta', 'Salad'], ['100', '1', '4', '4'], ['150', '0', '5', '4'], ['200', '4', '3', '1']]\n assert candidate(orders = [['Jack', '1', 'Steak'], ['Karen', '2', 'Sushi'], ['Leo', '1', 'Sushi'], ['Maggie', '3', 'Steak'], ['Nancy', '2', 'Salmon'], ['Oscar', '3', 'Salmon'], ['Paul', '1', 'Sushi'], ['Quinn', '3', 'Salmon'], ['Rachel', '2', 'Steak'], ['Steve', '1', 'Steak'], ['Tina', '2', 'Salmon'], ['Uma', '3', 'Steak'], ['Victor', '1', 'Sushi'], ['Wanda', '3', 'Salmon'], ['Xander', '2', 'Steak'], ['Yvonne', '1', 'Salmon'], ['Zane', '3', 'Steak']]) == [['Table', 'Salmon', 'Steak', 'Sushi'], ['1', '1', '2', '3'], ['2', '2', '2', '1'], ['3', '3', '3', '0']]\n assert candidate(orders = [['Michael', '10', 'Pasta'], ['Emily', '10', 'Spaghetti Carbonara'], ['Noah', '20', 'Pasta'], ['Olivia', '20', 'Caesar Salad'], ['Daniel', '10', 'Caesar Salad'], ['Ava', '30', 'Spaghetti Carbonara'], ['James', '30', 'Pasta'], ['Sophia', '40', 'Caesar Salad'], ['Benjamin', '40', 'Pasta'], ['Isabella', '10', 'Pasta']]) == [['Table', 'Caesar Salad', 'Pasta', 'Spaghetti Carbonara'], ['10', '1', '2', '1'], ['20', '1', '1', '0'], ['30', '0', '1', '1'], ['40', '1', '1', '0']]\n assert candidate(orders = [['Aaron', '10', 'Fajitas'], ['Ben', '10', 'Margherita Pizza'], ['Charlie', '10', 'Fajitas'], ['Dan', '9', 'Margherita Pizza'], ['Eve', '9', 'Fajitas'], ['Frank', '8', 'Spaghetti Carbonara'], ['Grace', '8', 'Margherita Pizza'], ['Heidi', '8', 'Spaghetti Carbonara'], ['Ian', '7', 'Fajitas'], ['Jenny', '7', 'Margherita Pizza'], ['Katie', '7', 'Spaghetti Carbonara'], ['Leo', '7', 'Margherita Pizza'], ['Mandy', '6', 'Fajitas'], ['Neil', '6', 'Spaghetti Carbonara'], ['Oliver', '6', 'Margherita Pizza'], ['Paul', '5', 'Fajitas'], ['Quincy', '5', 'Margherita Pizza'], ['Rachel', '5', 'Spaghetti Carbonara'], ['Steve', '5', 'Margherita Pizza'], ['Tina', '4', 'Fajitas'], ['Uma', '4', 'Margherita Pizza'], ['Victor', '4', 'Spaghetti Carbonara'], ['Wanda', '4', 'Margherita Pizza'], ['Xander', '3', 'Fajitas'], ['Yvonne', '3', 'Margherita Pizza'], ['Zane', '3', 'Spaghetti Carbonara'], ['Aaron', '2', 'Fajitas'], ['Ben', '2', 'Margherita Pizza'], ['Charlie', '2', 'Spaghetti Carbonara'], ['Dan', '2', 'Margherita Pizza'], ['Eve', '2', 'Fajitas'], ['Frank', '1', 'Spaghetti Carbonara'], ['Grace', '1', 'Margherita Pizza'], ['Heidi', '1', 'Fajitas'], ['Ian', '1', 'Margherita Pizza']]) == [['Table', 'Fajitas', 'Margherita Pizza', 'Spaghetti Carbonara'], ['1', '1', '2', '1'], ['2', '2', '2', '1'], ['3', '1', '1', '1'], ['4', '1', '2', '1'], ['5', '1', '2', '1'], ['6', '1', '1', '1'], ['7', '1', '2', '1'], ['8', '0', '1', '2'], ['9', '1', '1', '0'], ['10', '2', '1', '0']]\n assert candidate(orders = [['Alice', '100', 'Beef Burrito'], ['Bob', '200', 'Chicken Curry'], ['Charlie', '300', 'Shrimp Fried Rice'], ['David', '400', 'Spicy Noodles'], ['Eve', '500', 'Vegetable Stir Fry'], ['Frank', '100', 'Beef Burrito'], ['Grace', '200', 'Chicken Curry'], ['Hank', '300', 'Shrimp Fried Rice'], ['Ivy', '400', 'Spicy Noodles'], ['Jack', '500', 'Vegetable Stir Fry'], ['Kathy', '100', 'Beef Burrito'], ['Leo', '200', 'Chicken Curry'], ['Mona', '300', 'Shrimp Fried Rice'], ['Nate', '400', 'Spicy Noodles'], ['Oscar', '500', 'Vegetable Stir Fry'], ['Paul', '100', 'Beef Burrito'], ['Quinn', '200', 'Chicken Curry'], ['Ruth', '300', 'Shrimp Fried Rice'], ['Steve', '400', 'Spicy Noodles'], ['Tina', '500', 'Vegetable Stir Fry'], ['Uma', '100', 'Beef Burrito'], ['Vera', '200', 'Chicken Curry'], ['Will', '300', 'Shrimp Fried Rice'], ['Xander', '400', 'Spicy Noodles'], ['Yara', '500', 'Vegetable Stir Fry'], ['Zane', '100', 'Beef Burrito']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['100', '6', '0', '0', '0', '0'], ['200', '0', '5', '0', '0', '0'], ['300', '0', '0', '5', '0', '0'], ['400', '0', '0', '0', '5', '0'], ['500', '0', '0', '0', '0', '5']]\n assert candidate(orders = [['Amy', '1', 'Spring Roll'], ['Brian', '1', 'Spring Roll'], ['Cathy', '1', 'Spring Roll'], ['David', '1', 'Spring Roll'], ['Eva', '1', 'Spring Roll'], ['Frank', '1', 'Spring Roll'], ['Grace', '1', 'Spring Roll'], ['Henry', '1', 'Spring Roll'], ['Isabella', '1', 'Spring Roll'], ['Jack', '1', 'Spring Roll'], ['Katie', '1', 'Spring Roll'], ['Leo', '1', 'Spring Roll'], ['Mona', '1', 'Spring Roll'], ['Nathan', '1', 'Spring Roll'], ['Olivia', '1', 'Spring Roll'], ['Paul', '1', 'Spring Roll'], ['Quinn', '1', 'Spring Roll'], ['Ryan', '1', 'Spring Roll'], ['Sara', '1', 'Spring Roll'], ['Tina', '1', 'Spring Roll'], ['Uma', '1', 'Spring Roll'], ['Victor', '1', 'Spring Roll'], ['Wendy', '1', 'Spring Roll'], ['Xander', '1', 'Spring Roll'], ['Yara', '1', 'Spring Roll'], ['Zane', '1', 'Spring Roll']]) == [['Table', 'Spring Roll'], ['1', '26']]\n assert candidate(orders = [['Alice', '1', 'Pizza'], ['Bob', '2', 'Pasta'], ['Charlie', '3', 'Pizza'], ['David', '4', 'Salad'], ['Eve', '5', 'Burger'], ['Frank', '1', 'Pasta'], ['Grace', '2', 'Pizza'], ['Hannah', '3', 'Salad'], ['Ian', '4', 'Burger'], ['Jack', '5', 'Pizza']]) == [['Table', 'Burger', 'Pasta', 'Pizza', 'Salad'], ['1', '0', '1', '1', '0'], ['2', '0', '1', '1', '0'], ['3', '0', '0', '1', '1'], ['4', '1', '0', '0', '1'], ['5', '1', '0', '1', '0']]\n assert candidate(orders = [['Aaron', '1', 'Coffee'], ['Aaron', '1', 'Tea'], ['Aaron', '1', 'Juice'], ['Ben', '2', 'Coffee'], ['Ben', '2', 'Tea'], ['Charlie', '3', 'Tea'], ['Charlie', '3', 'Juice'], ['David', '4', 'Coffee'], ['David', '4', 'Tea'], ['David', '4', 'Juice'], ['Eve', '5', 'Coffee'], ['Eve', '5', 'Tea'], ['Eve', '5', 'Juice'], ['Frank', '6', 'Coffee'], ['Frank', '6', 'Tea'], ['Frank', '6', 'Juice'], ['Grace', '7', 'Coffee'], ['Grace', '7', 'Tea'], ['Grace', '7', 'Juice'], ['Hannah', '8', 'Coffee'], ['Hannah', '8', 'Tea'], ['Hannah', '8', 'Juice'], ['Ian', '9', 'Coffee'], ['Ian', '9', 'Tea'], ['Ian', '9', 'Juice'], ['Jack', '10', 'Coffee'], ['Jack', '10', 'Tea'], ['Jack', '10', 'Juice'], ['Katherine', '11', 'Coffee'], ['Katherine', '11', 'Tea'], ['Katherine', '11', 'Juice'], ['Laura', '12', 'Coffee'], ['Laura', '12', 'Tea'], ['Laura', '12', 'Juice'], ['Michael', '13', 'Coffee'], ['Michael', '13', 'Tea'], ['Michael', '13', 'Juice'], ['Nancy', '14', 'Coffee'], ['Nancy', '14', 'Tea'], ['Nancy', '14', 'Juice'], ['Oliver', '15', 'Coffee'], ['Oliver', '15', 'Tea'], ['Oliver', '15', 'Juice'], ['Penelope', '16', 'Coffee'], ['Penelope', '16', 'Tea'], ['Penelope', '16', 'Juice'], ['Quinn', '17', 'Coffee'], ['Quinn', '17', 'Tea'], ['Quinn', '17', 'Juice'], ['Rachel', '18', 'Coffee'], ['Rachel', '18', 'Tea'], ['Rachel', '18', 'Juice'], ['Sam', '19', 'Coffee'], ['Sam', '19', 'Tea'], ['Sam', '19', 'Juice'], ['Trent', '20', 'Coffee'], ['Trent', '20', 'Tea'], ['Trent', '20', 'Juice'], ['Uma', '21', 'Coffee'], ['Uma', '21', 'Tea'], ['Uma', '21', 'Juice'], ['Victor', '22', 'Coffee'], ['Victor', '22', 'Tea'], ['Victor', '22', 'Juice'], ['Wendy', '23', 'Coffee'], ['Wendy', '23', 'Tea'], ['Wendy', '23', 'Juice'], ['Xander', '24', 'Coffee'], ['Xander', '24', 'Tea'], ['Xander', '24', 'Juice'], ['Yvonne', '25', 'Coffee'], ['Yvonne', '25', 'Tea'], ['Yvonne', '25', 'Juice'], ['Zane', '26', 'Coffee'], ['Zane', '26', 'Tea'], ['Zane', '26', 'Juice']]) == [['Table', 'Coffee', 'Juice', 'Tea'], ['1', '1', '1', '1'], ['2', '1', '0', '1'], ['3', '0', '1', '1'], ['4', '1', '1', '1'], ['5', '1', '1', '1'], ['6', '1', '1', '1'], ['7', '1', '1', '1'], ['8', '1', '1', '1'], ['9', '1', '1', '1'], ['10', '1', '1', '1'], ['11', '1', '1', '1'], ['12', '1', '1', '1'], ['13', '1', '1', '1'], ['14', '1', '1', '1'], ['15', '1', '1', '1'], ['16', '1', '1', '1'], ['17', '1', '1', '1'], ['18', '1', '1', '1'], ['19', '1', '1', '1'], ['20', '1', '1', '1'], ['21', '1', '1', '1'], ['22', '1', '1', '1'], ['23', '1', '1', '1'], ['24', '1', '1', '1'], ['25', '1', '1', '1'], ['26', '1', '1', '1']]\n assert candidate(orders = [['William', '1', 'Steak'], ['Harper', '1', 'Mashed Potatoes'], ['Mason', '1', 'Steak'], ['Zoe', '1', 'Mashed Potatoes'], ['Ella', '1', 'Grilled Salmon'], ['Sebastian', '2', 'Steak'], ['Olivia', '2', 'Grilled Salmon'], ['Avery', '2', 'Steak'], ['Isabella', '2', 'Mashed Potatoes'], ['Grayson', '3', 'Grilled Salmon'], ['Scarlett', '3', 'Steak'], ['Sophia', '3', 'Mashed Potatoes'], ['Benjamin', '3', 'Grilled Salmon'], ['Ava', '4', 'Steak'], ['Evelyn', '4', 'Mashed Potatoes'], ['Daniel', '4', 'Grilled Salmon'], ['Amelia', '4', 'Steak'], ['Mia', '5', 'Mashed Potatoes'], ['Ella', '5', 'Steak'], ['Logan', '5', 'Grilled Salmon'], ['Abigail', '5', 'Steak'], ['James', '5', 'Mashed Potatoes'], ['Olivia', '5', 'Grilled Salmon'], ['Avery', '5', 'Steak'], ['Isabella', '5', 'Mashed Potatoes'], ['Mia', '5', 'Grilled Salmon'], ['Ella', '5', 'Steak'], ['Logan', '5', 'Mashed Potatoes']]) == [['Table', 'Grilled Salmon', 'Mashed Potatoes', 'Steak'], ['1', '1', '2', '2'], ['2', '1', '1', '2'], ['3', '2', '1', '1'], ['4', '1', '1', '2'], ['5', '3', '4', '4']]\n assert candidate(orders = [['Eli', '1', 'Pasta'], ['Nina', '2', 'Steak'], ['Eli', '2', 'Salmon'], ['Nina', '1', 'Salmon'], ['Eli', '1', 'Pasta'], ['Nina', '2', 'Pasta'], ['Eli', '2', 'Steak'], ['Nina', '1', 'Pasta'], ['Eli', '1', 'Steak'], ['Nina', '2', 'Salmon'], ['Eli', '2', 'Pasta'], ['Nina', '1', 'Steak'], ['Eli', '1', 'Salmon'], ['Nina', '2', 'Pasta']]) == [['Table', 'Pasta', 'Salmon', 'Steak'], ['1', '3', '2', '2'], ['2', '3', '2', '2']]\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon'], ['Alice', '1', 'Salmon'], ['Bob', '2', 'Veggie Delight'], ['Charlie', '3', 'Salmon'], ['David', '2', 'Veggie Delight'], ['Eve', '1', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '3', '0'], ['2', '1', '3'], ['3', '2', '1']]\n assert candidate(orders = [['Sarah', '1', 'Grilled Cheese'], ['Tom', '2', 'Grilled Cheese'], ['Sarah', '1', 'Caesar Salad'], ['Tom', '2', 'Caesar Salad'], ['Sarah', '1', 'Spaghetti'], ['Tom', '2', 'Spaghetti'], ['Sarah', '1', 'Steak'], ['Tom', '2', 'Steak'], ['Sarah', '1', 'Lasagna'], ['Tom', '2', 'Lasagna'], ['Sarah', '1', 'Pasta'], ['Tom', '2', 'Pasta'], ['Sarah', '1', 'Pizza'], ['Tom', '2', 'Pizza'], ['Sarah', '1', 'Fried Rice'], ['Tom', '2', 'Fried Rice'], ['Sarah', '1', 'Chicken Curry'], ['Tom', '2', 'Chicken Curry'], ['Sarah', '1', 'Fish and Chips'], ['Tom', '2', 'Fish and Chips'], ['Sarah', '1', 'Tacos'], ['Tom', '2', 'Tacos'], ['Sarah', '1', 'Burrito'], ['Tom', '2', 'Burrito'], ['Sarah', '1', 'Sushi'], ['Tom', '2', 'Sushi'], ['Sarah', '1', 'Ramen'], ['Tom', '2', 'Ramen'], ['Sarah', '1', 'Pho'], ['Tom', '2', 'Pho'], ['Sarah', '1', 'Dim Sum'], ['Tom', '2', 'Dim Sum']]) == [['Table', 'Burrito', 'Caesar Salad', 'Chicken Curry', 'Dim Sum', 'Fish and Chips', 'Fried Rice', 'Grilled Cheese', 'Lasagna', 'Pasta', 'Pho', 'Pizza', 'Ramen', 'Spaghetti', 'Steak', 'Sushi', 'Tacos'], ['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']]\n assert candidate(orders = [['Laura', '5', 'Bean Burrito'], ['Jhon', '5', 'Beef Burrito'], ['Melissa', '5', 'Soda'], ['Laura', '15', 'Bean Burrito'], ['Jhon', '15', 'Beef Burrito'], ['Melissa', '15', 'Soda'], ['Laura', '25', 'Bean Burrito'], ['Jhon', '25', 'Beef Burrito'], ['Melissa', '25', 'Soda'], ['Laura', '35', 'Bean Burrito'], ['Jhon', '35', 'Beef Burrito'], ['Melissa', '35', 'Soda']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Soda'], ['5', '1', '1', '1'], ['15', '1', '1', '1'], ['25', '1', '1', '1'], ['35', '1', '1', '1']]\n assert candidate(orders = [['Laura', '1', 'Bean Burrito'], ['Jhon', '2', 'Beef Burrito'], ['Melissa', '2', 'Soda'], ['Chris', '3', 'Chocolate Cake'], ['Chris', '3', 'Soda'], ['Laura', '3', 'Beef Burrito'], ['Jhon', '1', 'Chocolate Cake'], ['Melissa', '1', 'Bean Burrito']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Chocolate Cake', 'Soda'], ['1', '2', '0', '1', '0'], ['2', '0', '1', '0', '1'], ['3', '0', '1', '1', '1']]\n assert candidate(orders = [['Alice', '1', 'Burger'], ['Bob', '1', 'Pasta'], ['Charlie', '2', 'Burger'], ['David', '2', 'Pasta'], ['Eve', '3', 'Burger'], ['Frank', '3', 'Pasta'], ['Grace', '4', 'Burger'], ['Hannah', '4', 'Pasta'], ['Ian', '5', 'Burger'], ['Jack', '5', 'Pasta'], ['Karen', '6', 'Burger'], ['Leo', '6', 'Pasta'], ['Maggie', '7', 'Burger'], ['Nancy', '7', 'Pasta'], ['Oscar', '8', 'Burger'], ['Paul', '8', 'Pasta'], ['Quinn', '9', 'Burger'], ['Rachel', '9', 'Pasta'], ['Steve', '10', 'Burger'], ['Tina', '10', 'Pasta'], ['Uma', '11', 'Burger'], ['Victor', '11', 'Pasta'], ['Wanda', '12', 'Burger'], ['Xander', '12', 'Pasta'], ['Yvonne', '13', 'Burger'], ['Zane', '13', 'Pasta'], ['Aaron', '14', 'Burger'], ['Ben', '14', 'Pasta'], ['Charlie', '15', 'Burger'], ['David', '15', 'Pasta'], ['Eve', '16', 'Burger'], ['Frank', '16', 'Pasta'], ['Grace', '17', 'Burger'], ['Hannah', '17', 'Pasta'], ['Ian', '18', 'Burger'], ['Jack', '18', 'Pasta'], ['Karen', '19', 'Burger'], ['Leo', '19', 'Pasta'], ['Maggie', '20', 'Burger'], ['Nancy', '20', 'Pasta']]) == [['Table', 'Burger', 'Pasta'], ['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']]\n assert candidate(orders = [['Daniel', '1', 'Sushi'], ['Julia', '2', 'Tempura'], ['Carlos', '1', 'Sashimi'], ['Sophie', '2', 'Sushi'], ['Christopher', '3', 'Sushi'], ['Mia', '3', 'Sashimi'], ['Nicole', '4', 'Tempura'], ['Alexander', '5', 'Sushi'], ['Oliver', '5', 'Sashimi'], ['Ella', '5', 'Tempura'], ['William', '6', 'Sushi'], ['Amelia', '6', 'Sashimi'], ['Ethan', '6', 'Tempura'], ['Grace', '7', 'Sushi'], ['Jack', '8', 'Tempura'], ['Hannah', '8', 'Sashimi']]) == [['Table', 'Sashimi', 'Sushi', 'Tempura'], ['1', '1', '1', '0'], ['2', '0', '1', '1'], ['3', '1', '1', '0'], ['4', '0', '0', '1'], ['5', '1', '1', '1'], ['6', '1', '1', '1'], ['7', '0', '1', '0'], ['8', '1', '0', '1']]\n assert candidate(orders = [['Michael', '5', 'Spaghetti'], ['John', '1', 'Chicken Wings'], ['Doe', '3', 'Nachos'], ['Michael', '1', 'Caesar Salad'], ['John', '5', 'Nachos'], ['Doe', '1', 'Caesar Salad'], ['Alice', '4', 'Veggie Platter'], ['Bob', '2', 'Caesar Salad'], ['Charlie', '2', 'Spaghetti'], ['David', '3', 'Chicken Wings'], ['Eve', '4', 'Nachos'], ['Frank', '5', 'Veggie Platter']]) == [['Table', 'Caesar Salad', 'Chicken Wings', 'Nachos', 'Spaghetti', 'Veggie Platter'], ['1', '2', '1', '0', '0', '0'], ['2', '1', '0', '0', '1', '0'], ['3', '0', '1', '1', '0', '0'], ['4', '0', '0', '1', '0', '1'], ['5', '0', '0', '1', '1', '1']]\n assert candidate(orders = [['Michael', '10', 'Tomato Soup'], ['Jessica', '10', 'Grilled Cheese'], ['Michael', '10', 'Tomato Soup'], ['Jessica', '10', 'Grilled Cheese'], ['Robert', '20', 'Chicken Salad'], ['Katherine', '20', 'Tomato Soup'], ['Robert', '20', 'Chicken Salad'], ['Katherine', '20', 'Tomato Soup'], ['Robert', '30', 'Grilled Cheese'], ['Katherine', '30', 'Chicken Salad'], ['Robert', '30', 'Grilled Cheese'], ['Katherine', '30', 'Chicken Salad'], ['Robert', '40', 'Tomato Soup'], ['Katherine', '40', 'Grilled Cheese'], ['Robert', '40', 'Tomato Soup'], ['Katherine', '40', 'Grilled Cheese']]) == [['Table', 'Chicken Salad', 'Grilled Cheese', 'Tomato Soup'], ['10', '0', '2', '2'], ['20', '2', '0', '2'], ['30', '2', '2', '0'], ['40', '0', '2', '2']]\n assert candidate(orders = [['Ella', '2', 'Grilled Cheese'], ['Ella', '2', 'Caesar Salad'], ['Finn', '2', 'Grilled Cheese'], ['Gwen', '3', 'Caesar Salad'], ['Hank', '4', 'Grilled Cheese'], ['Izzy', '4', 'Caesar Salad'], ['Jack', '4', 'Grilled Cheese'], ['Kai', '5', 'Caesar Salad'], ['Liam', '6', 'Grilled Cheese'], ['Mia', '6', 'Caesar Salad'], ['Nina', '7', 'Grilled Cheese'], ['Oscar', '7', 'Caesar Salad'], ['Paul', '8', 'Grilled Cheese'], ['Quinn', '8', 'Caesar Salad'], ['Ruth', '9', 'Grilled Cheese'], ['Sam', '9', 'Caesar Salad'], ['Tina', '10', 'Grilled Cheese'], ['Uma', '10', 'Caesar Salad'], ['Victor', '11', 'Grilled Cheese'], ['Wendy', '11', 'Caesar Salad'], ['Xander', '12', 'Grilled Cheese'], ['Yvonne', '12', 'Caesar Salad'], ['Zane', '13', 'Grilled Cheese'], ['Aaron', '13', 'Caesar Salad'], ['Ben', '14', 'Grilled Cheese'], ['Cathy', '14', 'Caesar Salad'], ['Dylan', '15', 'Grilled Cheese'], ['Eva', '15', 'Caesar Salad'], ['Frank', '16', 'Grilled Cheese'], ['Grace', '16', 'Caesar Salad'], ['Hannah', '17', 'Grilled Cheese'], ['Ian', '17', 'Caesar Salad'], ['Jack', '18', 'Grilled Cheese'], ['Kai', '18', 'Caesar Salad'], ['Liam', '19', 'Grilled Cheese'], ['Mia', '19', 'Caesar Salad'], ['Nina', '20', 'Grilled Cheese'], ['Oscar', '20', 'Caesar Salad'], ['Paul', '21', 'Grilled Cheese'], ['Quinn', '21', 'Caesar Salad'], ['Ruth', '22', 'Grilled Cheese'], ['Sam', '22', 'Caesar Salad'], ['Tina', '23', 'Grilled Cheese'], ['Uma', '23', 'Caesar Salad'], ['Victor', '24', 'Grilled Cheese'], ['Wendy', '24', 'Caesar Salad'], ['Xander', '25', 'Grilled Cheese'], ['Yvonne', '25', 'Caesar Salad'], ['Zane', '26', 'Grilled Cheese'], ['Aaron', '26', 'Caesar Salad'], ['Ben', '27', 'Grilled Cheese'], ['Cathy', '27', 'Caesar Salad'], ['Dylan', '28', 'Grilled Cheese'], ['Eva', '28', 'Caesar Salad'], ['Frank', '29', 'Grilled Cheese'], ['Grace', '29', 'Caesar Salad'], ['Hannah', '30', 'Grilled Cheese'], ['Ian', '30', 'Caesar Salad']]) == [['Table', 'Caesar Salad', 'Grilled Cheese'], ['2', '1', '2'], ['3', '1', '0'], ['4', '1', '2'], ['5', '1', '0'], ['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'], ['21', '1', '1'], ['22', '1', '1'], ['23', '1', '1'], ['24', '1', '1'], ['25', '1', '1'], ['26', '1', '1'], ['27', '1', '1'], ['28', '1', '1'], ['29', '1', '1'], ['30', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Jerry', '3', 'Spring Roll'], ['Anna', '4', 'Pasta'], ['Tom', '5', 'Pizza'], ['Jerry', '6', 'Salad'], ['Anna', '7', 'Burger'], ['Tom', '8', 'Fried Chicken'], ['Jerry', '9', 'Water'], ['Anna', '10', 'Ceviche'], ['Tom', '11', 'Beef Burrito'], ['Jerry', '12', 'Veggie Delight'], ['Anna', '13', 'Pizza'], ['Tom', '14', 'Salad'], ['Jerry', '15', 'Burger'], ['Anna', '16', 'Fried Chicken'], ['Tom', '17', 'Water'], ['Jerry', '18', 'Ceviche'], ['Anna', '19', 'Beef Burrito'], ['Tom', '20', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Burger', 'Ceviche', 'Fried Chicken', 'Pasta', 'Pizza', 'Salad', 'Spring Roll', 'Veggie Delight', 'Water'], ['1', '1', '0', '0', '0', '0', '0', '0', '1', '1', '0'], ['2', '1', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['3', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0'], ['4', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0'], ['5', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['6', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0'], ['7', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['8', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0'], ['9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'], ['10', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0'], ['11', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['12', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['13', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['14', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0'], ['15', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['16', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0'], ['17', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'], ['18', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0'], ['19', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['20', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0']]\n assert candidate(orders = [['Alice', '1', 'Beef Burrito'], ['Bob', '2', 'Chicken Curry'], ['Charlie', '3', 'Shrimp Fried Rice'], ['David', '4', 'Spicy Noodles'], ['Eve', '5', 'Vegetable Stir Fry'], ['Frank', '6', 'Beef Burrito'], ['Grace', '7', 'Chicken Curry'], ['Hank', '8', 'Shrimp Fried Rice'], ['Ivy', '9', 'Spicy Noodles'], ['Jack', '10', 'Vegetable Stir Fry'], ['Kathy', '1', 'Beef Burrito'], ['Leo', '2', 'Chicken Curry'], ['Mona', '3', 'Shrimp Fried Rice'], ['Nate', '4', 'Spicy Noodles'], ['Oscar', '5', 'Vegetable Stir Fry'], ['Paul', '6', 'Beef Burrito'], ['Quinn', '7', 'Chicken Curry'], ['Ruth', '8', 'Shrimp Fried Rice'], ['Steve', '9', 'Spicy Noodles'], ['Tina', '10', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['1', '2', '0', '0', '0', '0'], ['2', '0', '2', '0', '0', '0'], ['3', '0', '0', '2', '0', '0'], ['4', '0', '0', '0', '2', '0'], ['5', '0', '0', '0', '0', '2'], ['6', '2', '0', '0', '0', '0'], ['7', '0', '2', '0', '0', '0'], ['8', '0', '0', '2', '0', '0'], ['9', '0', '0', '0', '2', '0'], ['10', '0', '0', '0', '0', '2']]\n assert candidate(orders = [['John', '10', 'Lobster'], ['Paul', '12', 'Grilled Chicken'], ['John', '12', 'Lobster'], ['Paul', '10', 'Grilled Chicken'], ['John', '10', 'Grilled Chicken'], ['Paul', '12', 'Lobster'], ['John', '12', 'Grilled Chicken'], ['Paul', '10', 'Lobster'], ['John', '10', 'Lobster'], ['Paul', '12', 'Grilled Chicken']]) == [['Table', 'Grilled Chicken', 'Lobster'], ['10', '2', '3'], ['12', '3', '2']]\n assert candidate(orders = [['Emma', '5', 'Chicken Tikka Masala'], ['James', '5', 'Chicken Tikka Masala'], ['Oliver', '5', 'Chicken Tikka Masala'], ['Noah', '5', 'Chicken Tikka Masala'], ['Amelia', '5', 'Chicken Tikka Masala'], ['Olivia', '6', 'Chicken Tikka Masala'], ['Ava', '6', 'Chicken Tikka Masala'], ['Isabella', '6', 'Chicken Tikka Masala'], ['Sophia', '6', 'Chicken Tikka Masala'], ['Isaac', '6', 'Chicken Tikka Masala'], ['Oliver', '7', 'Chicken Tikka Masala'], ['Elijah', '7', 'Chicken Tikka Masala'], ['Noah', '7', 'Chicken Tikka Masala'], ['James', '7', 'Chicken Tikka Masala'], ['Olivia', '7', 'Chicken Tikka Masala'], ['Emma', '8', 'Chicken Tikka Masala'], ['Isabella', '8', 'Chicken Tikka Masala'], ['Amelia', '8', 'Chicken Tikka Masala'], ['Sophia', '8', 'Chicken Tikka Masala'], ['Isaac', '8', 'Chicken Tikka Masala'], ['Ava', '8', 'Chicken Tikka Masala'], ['Elijah', '8', 'Chicken Tikka Masala'], ['James', '8', 'Chicken Tikka Masala'], ['Oliver', '8', 'Chicken Tikka Masala'], ['Noah', '8', 'Chicken Tikka Masala'], ['Amelia', '8', 'Chicken Tikka Masala'], ['Olivia', '8', 'Chicken Tikka Masala']]) == [['Table', 'Chicken Tikka Masala'], ['5', '5'], ['6', '5'], ['7', '5'], ['8', '12']]\n assert candidate(orders = [['Will', '500', 'Mushroom Risotto'], ['Sam', '499', 'Steak'], ['Greg', '498', 'Salmon'], ['May', '497', 'Vegetable Lasagna'], ['Diana', '496', 'Mushroom Risotto'], ['Tom', '495', 'Steak'], ['Jenny', '494', 'Salmon'], ['Chris', '493', 'Vegetable Lasagna'], ['Lucas', '492', 'Mushroom Risotto'], ['Sarah', '491', 'Steak'], ['Joe', '490', 'Salmon'], ['Karen', '489', 'Vegetable Lasagna'], ['Matt', '488', 'Mushroom Risotto'], ['Lisa', '487', 'Steak'], ['Scott', '486', 'Salmon'], ['Rachel', '485', 'Vegetable Lasagna'], ['Mark', '484', 'Mushroom Risotto'], ['Beth', '483', 'Steak'], ['Dave', '482', 'Salmon'], ['Nancy', '481', 'Vegetable Lasagna'], ['Ken', '480', 'Mushroom Risotto'], ['Jan', '479', 'Steak'], ['Jill', '478', 'Salmon'], ['Gregory', '477', 'Vegetable Lasagna'], ['Christina', '476', 'Mushroom Risotto'], ['Kevin', '475', 'Steak'], ['Laura', '474', 'Salmon'], ['Megan', '473', 'Vegetable Lasagna'], ['Ryan', '472', 'Mushroom Risotto'], ['Amanda', '471', 'Steak'], ['Charles', '470', 'Salmon'], ['Rebecca', '469', 'Vegetable Lasagna'], ['Andrew', '468', 'Mushroom Risotto'], ['Jessica', '467', 'Steak'], ['Arthur', '466', 'Salmon'], ['Shirley', '465', 'Vegetable Lasagna'], ['Daniel', '464', 'Mushroom Risotto'], ['Emma', '463', 'Steak'], ['Christopher', '462', 'Salmon'], ['Nicole', '461', 'Vegetable Lasagna'], ['Scott', '460', 'Mushroom Risotto'], ['Melissa', '459', 'Steak'], ['Robert', '458', 'Salmon'], ['Michelle', '457', 'Vegetable Lasagna'], ['John', '456', 'Mushroom Risotto'], ['Brenda', '455', 'Steak'], ['Steve', '454', 'Salmon'], ['Anna', '453', 'Vegetable Lasagna']]) == [['Table', 'Mushroom Risotto', 'Salmon', 'Steak', 'Vegetable Lasagna'], ['453', '0', '0', '0', '1'], ['454', '0', '1', '0', '0'], ['455', '0', '0', '1', '0'], ['456', '1', '0', '0', '0'], ['457', '0', '0', '0', '1'], ['458', '0', '1', '0', '0'], ['459', '0', '0', '1', '0'], ['460', '1', '0', '0', '0'], ['461', '0', '0', '0', '1'], ['462', '0', '1', '0', '0'], ['463', '0', '0', '1', '0'], ['464', '1', '0', '0', '0'], ['465', '0', '0', '0', '1'], ['466', '0', '1', '0', '0'], ['467', '0', '0', '1', '0'], ['468', '1', '0', '0', '0'], ['469', '0', '0', '0', '1'], ['470', '0', '1', '0', '0'], ['471', '0', '0', '1', '0'], ['472', '1', '0', '0', '0'], ['473', '0', '0', '0', '1'], ['474', '0', '1', '0', '0'], ['475', '0', '0', '1', '0'], ['476', '1', '0', '0', '0'], ['477', '0', '0', '0', '1'], ['478', '0', '1', '0', '0'], ['479', '0', '0', '1', '0'], ['480', '1', '0', '0', '0'], ['481', '0', '0', '0', '1'], ['482', '0', '1', '0', '0'], ['483', '0', '0', '1', '0'], ['484', '1', '0', '0', '0'], ['485', '0', '0', '0', '1'], ['486', '0', '1', '0', '0'], ['487', '0', '0', '1', '0'], ['488', '1', '0', '0', '0'], ['489', '0', '0', '0', '1'], ['490', '0', '1', '0', '0'], ['491', '0', '0', '1', '0'], ['492', '1', '0', '0', '0'], ['493', '0', '0', '0', '1'], ['494', '0', '1', '0', '0'], ['495', '0', '0', '1', '0'], ['496', '1', '0', '0', '0'], ['497', '0', '0', '0', '1'], ['498', '0', '1', '0', '0'], ['499', '0', '0', '1', '0'], ['500', '1', '0', '0', '0']]\n assert candidate(orders = [['Alice', '1', 'Pizza'], ['Bob', '2', 'Burger'], ['Charlie', '3', 'Sushi'], ['David', '1', 'Salad'], ['Eve', '2', 'Pizza'], ['Frank', '3', 'Burger'], ['Grace', '1', 'Sushi'], ['Heidi', '2', 'Salad'], ['Ivy', '3', 'Pizza'], ['Jack', '1', 'Burger'], ['Kara', '2', 'Sushi'], ['Liam', '3', 'Salad'], ['Mia', '1', 'Pizza'], ['Nina', '2', 'Burger'], ['Oscar', '3', 'Sushi'], ['Paul', '1', 'Salad'], ['Quinn', '2', 'Pizza'], ['Rachel', '3', 'Burger'], ['Steve', '1', 'Sushi'], ['Tina', '2', 'Salad'], ['Uma', '3', 'Pizza'], ['Victor', '1', 'Burger'], ['Wendy', '2', 'Sushi'], ['Xavier', '3', 'Salad'], ['Yara', '1', 'Pizza'], ['Zane', '2', 'Burger']]) == [['Table', 'Burger', 'Pizza', 'Salad', 'Sushi'], ['1', '2', '3', '2', '2'], ['2', '3', '2', '2', '2'], ['3', '2', '2', '2', '2']]\n assert candidate(orders = [['Leo', '1', 'Fish and Chips'], ['Mia', '2', 'Fish and Chips'], ['Leo', '3', 'Caesar Salad'], ['Mia', '1', 'Caesar Salad'], ['Leo', '2', 'Fish and Chips'], ['Mia', '3', 'Caesar Salad'], ['Ava', '1', 'Club Sandwich'], ['Sophia', '2', 'Caesar Salad'], ['Ava', '3', 'Fish and Chips'], ['Sophia', '1', 'Club Sandwich'], ['Ava', '2', 'Caesar Salad'], ['Sophia', '3', 'Fish and Chips'], ['Isabella', '1', 'Fish and Chips'], ['Oliver', '2', 'Club Sandwich'], ['Isabella', '3', 'Caesar Salad'], ['Oliver', '1', 'Fish and Chips'], ['Isabella', '2', 'Caesar Salad'], ['Oliver', '3', 'Club Sandwich']]) == [['Table', 'Caesar Salad', 'Club Sandwich', 'Fish and Chips'], ['1', '1', '2', '3'], ['2', '3', '1', '2'], ['3', '3', '1', '2']]\n assert candidate(orders = [['David', '3', 'Ceviche'], ['Corina', '10', 'Beef Burrito'], ['David', '3', 'Fried Chicken'], ['Carla', '5', 'Water'], ['Carla', '5', 'Ceviche'], ['Rous', '3', 'Ceviche'], ['David', '5', 'Beef Burrito'], ['Carla', '3', 'Fried Chicken'], ['Rous', '5', 'Spring Roll']]) == [['Table', 'Beef Burrito', 'Ceviche', 'Fried Chicken', 'Spring Roll', 'Water'], ['3', '0', '2', '2', '0', '0'], ['5', '1', '1', '0', '1', '1'], ['10', '1', '0', '0', '0', '0']]\n assert candidate(orders = [['Alexander', '50', 'Fruit Salad'], ['Dominic', '51', 'Pancakes'], ['Alexander', '50', 'Fruit Salad'], ['Dominic', '51', 'Pancakes'], ['Elizabeth', '52', 'Tomato Soup'], ['Alexander', '50', 'Tomato Soup'], ['Dominic', '51', 'Tomato Soup'], ['Elizabeth', '52', 'Pancakes'], ['Alexander', '50', 'Pancakes'], ['Dominic', '51', 'Fruit Salad'], ['Elizabeth', '52', 'Fruit Salad'], ['Alexander', '50', 'Chicken Salad'], ['Dominic', '51', 'Chicken Salad'], ['Elizabeth', '52', 'Chicken Salad']]) == [['Table', 'Chicken Salad', 'Fruit Salad', 'Pancakes', 'Tomato Soup'], ['50', '1', '2', '1', '1'], ['51', '1', '1', '2', '1'], ['52', '1', '1', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Bob', '3', 'Chicken Curry'], ['Charlie', '4', 'Shrimp Fried Rice'], ['David', '5', 'Spicy Noodles'], ['Eve', '6', 'Vegetable Stir Fry'], ['Frank', '1', 'Spring Roll'], ['Grace', '2', 'Beef Burrito'], ['Hank', '3', 'Chicken Curry'], ['Ivy', '4', 'Shrimp Fried Rice'], ['Jack', '5', 'Spicy Noodles'], ['Kathy', '6', 'Vegetable Stir Fry'], ['Leo', '1', 'Spring Roll'], ['Mona', '2', 'Beef Burrito'], ['Nate', '3', 'Chicken Curry'], ['Oscar', '4', 'Shrimp Fried Rice'], ['Paul', '5', 'Spicy Noodles'], ['Quinn', '6', 'Vegetable Stir Fry'], ['Ruth', '1', 'Spring Roll'], ['Steve', '2', 'Beef Burrito'], ['Tina', '3', 'Chicken Curry'], ['Uma', '4', 'Shrimp Fried Rice'], ['Vera', '5', 'Spicy Noodles'], ['Will', '6', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Spring Roll', 'Vegetable Stir Fry', 'Veggie Delight'], ['1', '1', '0', '0', '0', '4', '0', '1'], ['2', '4', '0', '0', '0', '0', '0', '1'], ['3', '0', '4', '0', '0', '0', '0', '0'], ['4', '0', '0', '4', '0', '0', '0', '0'], ['5', '0', '0', '0', '4', '0', '0', '0'], ['6', '0', '0', '0', '0', '0', '4', '0']]\n assert candidate(orders = [['Sarah', '101', 'Spaghetti Carbonara'], ['John', '202', 'Caesar Salad'], ['Sarah', '101', 'Caesar Salad'], ['Alice', '303', 'Grilled Salmon'], ['Bob', '202', 'Grilled Salmon'], ['Sarah', '101', 'Spaghetti Carbonara'], ['Alice', '303', 'Caesar Salad'], ['Bob', '202', 'Spaghetti Carbonara'], ['Charlie', '404', 'Grilled Salmon'], ['Charlie', '404', 'Caesar Salad'], ['Charlie', '404', 'Spaghetti Carbonara']]) == [['Table', 'Caesar Salad', 'Grilled Salmon', 'Spaghetti Carbonara'], ['101', '1', '0', '2'], ['202', '1', '1', '1'], ['303', '1', '1', '0'], ['404', '1', '1', '1']]\n", "comparison": "exact"}, "public_tests": ["[[\"David\",\"3\",\"Ceviche\"],[\"Corina\",\"10\",\"Beef Burrito\"],[\"David\",\"3\",\"Fried Chicken\"],[\"Carla\",\"5\",\"Water\"],[\"Carla\",\"5\",\"Ceviche\"],[\"Rous\",\"3\",\"Ceviche\"]]", "[[\"James\",\"12\",\"Fried Chicken\"],[\"Ratesh\",\"12\",\"Fried Chicken\"],[\"Amadeus\",\"12\",\"Fried Chicken\"],[\"Adam\",\"1\",\"Canadian Waffles\"],[\"Brianna\",\"1\",\"Canadian Waffles\"]]", "[[\"Laura\",\"2\",\"Bean Burrito\"],[\"Jhon\",\"2\",\"Beef Burrito\"],[\"Melissa\",\"2\",\"Soda\"]]"], "hints": ["Keep the frequency of all pairs (tableNumber, foodItem) using a hashmap.", "Sort rows by tableNumber and columns by foodItem, then process the resulted table."], "metadata": {"canonical_parameter_names": ["orders"], "leetcode_dataset_entry_point": "Solution().displayTable", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:37+00:00", "tests_total": 53, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def displayTable(self, orders: List[List[str]]) -> List[List[str]]:", "container": "Solution", "callable": "displayTable", "parameters": [{"name": "orders", "type": "List[List[str]]"}], "return_type": "List[List[str]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1419, "task_id": "minimum-number-of-frogs-croaking", "difficulty": "Medium", "problem_description": "You are given the string croakOfFrogs, which represents a combination of the string \"croak\" from different frogs, that is, multiple frogs can croak at the same time, so multiple \"croak\" are mixed.\n\nReturn the minimum number of different frogs to finish all the croaks in the given string.\n\nA valid \"croak\" means a frog is printing five letters 'c', 'r', 'o', 'a', and 'k' sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid \"croak\" return -1.\n\nExample 1:\n\nInput: croakOfFrogs = \"croakcroak\"\nOutput: 1\nExplanation: One frog yelling \"croak\" twice.\n\nExample 2:\n\nInput: croakOfFrogs = \"crcoakroak\"\nOutput: 2\nExplanation: The minimum number of frogs is two.\nThe first frog could yell \"crcoakroak\".\nThe second frog could yell later \"crcoakroak\".\n\nExample 3:\n\nInput: croakOfFrogs = \"croakcrook\"\nOutput: -1\nExplanation: The given string is an invalid combination of \"croak\" from different frogs.\n\nConstraints:\n\n- 1 <= croakOfFrogs.length <= 10^5\n- croakOfFrogs is either 'c', 'r', 'o', 'a', or 'k'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(croakOfFrogs = \"croakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croak\") == 1\n assert candidate(croakOfFrogs = \"cccrroooaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crcoakroak\") == 2\n assert candidate(croakOfFrogs = \"crrcooakak\") == -1\n assert candidate(croakOfFrogs = \"k\") == -1\n assert candidate(croakOfFrogs = \"crocakroak\") == 2\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"crrrroooaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"ccroooakk\") == -1\n assert candidate(croakOfFrogs = \"ccroakroak\") == 2\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaaakkkkkk\") == -1\n assert candidate(croakOfFrogs = \"kakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakak\") == -1\n assert candidate(croakOfFrogs = \"ccccroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"kkkrrrooocccaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"croakcrook\") == -1\n assert candidate(croakOfFrogs = \"crorocroakakak\") == -1\n assert candidate(croakOfFrogs = \"crocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"c\") == -1\n assert candidate(croakOfFrogs = \"crorocakak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"kroac\") == -1\n assert candidate(croakOfFrogs = \"crocak\") == -1\n assert candidate(croakOfFrogs = \"crcroaoakk\") == 2\n assert candidate(croakOfFrogs = \"kraoc\") == -1\n assert candidate(croakOfFrogs = \"ccccrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"ccrroookkaak\") == -1\n assert candidate(croakOfFrogs = \"crocroakakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaaaaaaaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccccroooooorrrraaaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrrrroooooooooookkkkkkkkaaaaaaaaaacrrrrrrroooooooooookkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakccccrrroooookkkkroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"cccrroooakkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crocakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakccroakrrrooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrooookaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkroakkkkroakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrroookaaaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakro\") == -1\n assert candidate(croakOfFrogs = \"crocakroakcroakcroakcroakcroak\") == 2\n assert candidate(croakOfFrogs = \"crocroakcroakccccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooooookkkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccrrrrooooaaaakkkkccrrrrooooaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crcrccrooaaakk\") == -1\n assert candidate(croakOfFrogs = \"cccrrooookkkkraaacroak\") == -1\n assert candidate(croakOfFrogs = \"croakccroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"cccrooookkkkrrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrcroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakccroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcrocroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crocakrocakrocak\") == -1\n assert candidate(croakOfFrogs = \"croakcrocakcroakcrocakcrocak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcoakrcoak\") == -1\n assert candidate(croakOfFrogs = \"crrrrooooookkkkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkakkkakkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkakkk\") == -1\n assert candidate(croakOfFrogs = \"crorocokakak\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcrrooakroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakkaakrook\") == -1\n assert candidate(croakOfFrogs = \"crocakroakroakroakroakroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"ccccrooookaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakccrookraaaakkk\") == -1\n assert candidate(croakOfFrogs = \"ccccccccrrrrrroooooookkkkkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakrcoakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaaak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkrrroooooooaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"crcoakroakcrcoakroak\") == 2\n assert candidate(croakOfFrogs = \"crocrocrocrocrocroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocakroakcroakcroak\") == 2\n assert candidate(croakOfFrogs = \"crcrcooakokrakraokakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkkkkkroakroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccccroooooorrrraaaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"crcroakroakcrcoak\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcoakrcoakrcoak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaaakkkkroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccccccrrrrrrrrrrroooooooooookkkkkkkkaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccrooakrkkaocroakcraok\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crorarokkorakocraok\") == -1\n assert candidate(croakOfFrogs = \"croakroakroakcroakroakroakroakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"cccrroooraaakk\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccroooraaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcrorocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaarrrkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrrrrrrroooooooooookkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccrroooaakkccrooakaakk\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaacccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccroakcroakcroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakroccrooakakro\") == -1\n assert candidate(croakOfFrogs = \"croakcroakroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocrokakakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"ccroakccroakccroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkkk\") == -1\n assert candidate(croakOfFrogs = \"cccrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkac\") == -1\n assert candidate(croakOfFrogs = \"crorokokokakakc\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaacrrrooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccrroookkaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crocrokakakcroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccrroooaakkccrooakaakkccrroooaakk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaacrrroooookkkkaaaacrrroooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crcrrooookkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrcroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crrroookkkkrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocrokrocroakakak\") == -1\n assert candidate(croakOfFrogs = \"crrookkcraaacroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrcooakokrakraokak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcrocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakccroooaakk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrrrrooooooookkkkkkkaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakccroaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroakroakroakroakroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaakk\") == -1\n assert candidate(croakOfFrogs = \"crrcroakroakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakcrocakcroakcrocak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"croakcroakcrcoakroakcrocroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakroccrooakakroccrooakakro\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkcroak\") == -1\n assert candidate(croakOfFrogs = \"ccroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrooorkkkaa\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"cccroooraakk\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrroookkkkrrroooookkkkrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocrocrocrocrocrocrocrocrocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaaacrrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"cccroaaakkkkroooraak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcrocroakroak\") == -1\n assert candidate(croakOfFrogs = \"crcroakroakroakroakroakroak\") == -1\n", "comparison": "exact"}, "public_tests": ["\"croakcroak\"", "\"crcoakroak\"", "\"croakcrook\""], "hints": ["keep the frequency of all characters from \"croak\" using a hashmap.", "For each character in the given string, greedily match it to a possible \"croak\"."], "metadata": {"canonical_parameter_names": ["croakOfFrogs"], "leetcode_dataset_entry_point": "Solution().minNumberOfFrogs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:39+00:00", "tests_total": 197, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "counting"]}, "language": "python", "interface": {"raw_signature": "def minNumberOfFrogs(self, croakOfFrogs: str) -> int:", "container": "Solution", "callable": "minNumberOfFrogs", "parameters": [{"name": "croakOfFrogs", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1420, "task_id": "build-array-where-you-can-find-the-maximum-exactly-k-comparisons", "difficulty": "Hard", "problem_description": "You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:\n\nYou should build the array arr which has the following properties:\n\n- arr has exactly n integers.\n- 1 <= arr[i] <= m where (0 <= i < n).\n- After applying the mentioned algorithm to arr, the value search_cost is equal to k.\n\nReturn the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 2, m = 3, k = 1\nOutput: 6\nExplanation: The possible arrays are [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]\n\nExample 2:\n\nInput: n = 5, m = 2, k = 3\nOutput: 0\nExplanation: There are no possible arrays that satisfy the mentioned conditions.\n\nExample 3:\n\nInput: n = 9, m = 1, k = 1\nOutput: 1\nExplanation: The only possible array is [1, 1, 1, 1, 1, 1, 1, 1, 1]\n\nConstraints:\n\n- 1 <= n <= 50\n- 1 <= m <= 100\n- 0 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,m = 1,k = 1) == 1\n assert candidate(n = 4,m = 5,k = 2) == 305\n assert candidate(n = 3,m = 3,k = 0) == 0\n assert candidate(n = 3,m = 5,k = 2) == 60\n assert candidate(n = 5,m = 2,k = 3) == 0\n assert candidate(n = 4,m = 4,k = 2) == 125\n assert candidate(n = 1,m = 1,k = 0) == 0\n assert candidate(n = 50,m = 100,k = 50) == 538992043\n assert candidate(n = 10,m = 10,k = 5) == 282622725\n assert candidate(n = 4,m = 4,k = 0) == 0\n assert candidate(n = 2,m = 3,k = 1) == 6\n assert candidate(n = 50,m = 100,k = 0) == 0\n assert candidate(n = 9,m = 1,k = 1) == 1\n assert candidate(n = 40,m = 30,k = 20) == 620836495\n assert candidate(n = 25,m = 10,k = 15) == 0\n assert candidate(n = 45,m = 5,k = 2) == 741424886\n assert candidate(n = 40,m = 20,k = 15) == 992287753\n assert candidate(n = 50,m = 50,k = 25) == 60065601\n assert candidate(n = 10,m = 4,k = 3) == 241950\n assert candidate(n = 25,m = 10,k = 5) == 513807183\n assert candidate(n = 10,m = 1,k = 0) == 0\n assert candidate(n = 20,m = 15,k = 19) == 0\n assert candidate(n = 10,m = 5,k = 4) == 595775\n assert candidate(n = 6,m = 3,k = 3) == 90\n assert candidate(n = 40,m = 15,k = 7) == 487352486\n assert candidate(n = 30,m = 10,k = 10) == 967895731\n assert candidate(n = 35,m = 50,k = 15) == 67294554\n assert candidate(n = 15,m = 3,k = 2) == 7174452\n assert candidate(n = 25,m = 5,k = 5) == 957053963\n assert candidate(n = 50,m = 100,k = 25) == 34549172\n assert candidate(n = 35,m = 25,k = 5) == 706635531\n assert candidate(n = 50,m = 50,k = 50) == 1\n assert candidate(n = 30,m = 30,k = 15) == 153434023\n assert candidate(n = 5,m = 5,k = 3) == 585\n assert candidate(n = 15,m = 8,k = 4) == 997233503\n assert candidate(n = 25,m = 2,k = 1) == 16777217\n assert candidate(n = 35,m = 1,k = 1) == 1\n assert candidate(n = 15,m = 7,k = 5) == 128631420\n assert candidate(n = 35,m = 50,k = 20) == 604238599\n assert candidate(n = 30,m = 20,k = 10) == 91721467\n assert candidate(n = 15,m = 30,k = 7) == 115201714\n assert candidate(n = 25,m = 40,k = 9) == 701520657\n assert candidate(n = 40,m = 25,k = 6) == 775163810\n assert candidate(n = 40,m = 25,k = 20) == 121510237\n assert candidate(n = 5,m = 100,k = 3) == 874379186\n assert candidate(n = 42,m = 50,k = 15) == 300194714\n assert candidate(n = 15,m = 15,k = 7) == 687790825\n assert candidate(n = 30,m = 50,k = 10) == 467663134\n assert candidate(n = 45,m = 50,k = 18) == 362047302\n assert candidate(n = 20,m = 15,k = 10) == 836223400\n assert candidate(n = 5,m = 10,k = 3) == 24420\n assert candidate(n = 35,m = 40,k = 25) == 920448080\n assert candidate(n = 10,m = 10,k = 10) == 1\n assert candidate(n = 20,m = 2,k = 0) == 0\n assert candidate(n = 15,m = 1,k = 0) == 0\n assert candidate(n = 7,m = 6,k = 4) == 15435\n assert candidate(n = 20,m = 15,k = 5) == 290343834\n assert candidate(n = 40,m = 20,k = 20) == 494331990\n assert candidate(n = 10,m = 10,k = 3) == 141166029\n assert candidate(n = 30,m = 100,k = 29) == 66522256\n assert candidate(n = 45,m = 5,k = 10) == 0\n assert candidate(n = 5,m = 4,k = 2) == 500\n assert candidate(n = 50,m = 100,k = 10) == 329962470\n assert candidate(n = 50,m = 100,k = 20) == 90726602\n assert candidate(n = 20,m = 5,k = 5) == 206085257\n assert candidate(n = 45,m = 10,k = 5) == 505926106\n assert candidate(n = 45,m = 40,k = 25) == 391896760\n assert candidate(n = 25,m = 20,k = 4) == 983809007\n assert candidate(n = 50,m = 100,k = 30) == 724411167\n assert candidate(n = 30,m = 3,k = 0) == 0\n assert candidate(n = 20,m = 20,k = 10) == 802034327\n assert candidate(n = 10,m = 5,k = 3) == 2604825\n assert candidate(n = 10,m = 7,k = 3) == 84246120\n assert candidate(n = 30,m = 15,k = 10) == 934932290\n assert candidate(n = 5,m = 3,k = 2) == 120\n assert candidate(n = 50,m = 1,k = 1) == 1\n assert candidate(n = 40,m = 20,k = 1) == 615177897\n assert candidate(n = 15,m = 5,k = 4) == 319448936\n assert candidate(n = 50,m = 1,k = 0) == 0\n assert candidate(n = 35,m = 7,k = 7) == 888706682\n assert candidate(n = 50,m = 10,k = 0) == 0\n assert candidate(n = 20,m = 15,k = 4) == 581619126\n assert candidate(n = 8,m = 8,k = 4) == 1511559\n assert candidate(n = 25,m = 50,k = 15) == 576291422\n assert candidate(n = 25,m = 20,k = 6) == 286391446\n assert candidate(n = 40,m = 10,k = 5) == 403011874\n assert candidate(n = 30,m = 100,k = 10) == 182325231\n assert candidate(n = 30,m = 20,k = 6) == 661827822\n assert candidate(n = 40,m = 40,k = 20) == 387728551\n assert candidate(n = 45,m = 5,k = 0) == 0\n assert candidate(n = 45,m = 30,k = 8) == 208992079\n assert candidate(n = 20,m = 10,k = 5) == 650197027\n assert candidate(n = 15,m = 15,k = 15) == 1\n assert candidate(n = 20,m = 5,k = 3) == 982515902\n assert candidate(n = 40,m = 20,k = 10) == 728982973\n assert candidate(n = 45,m = 9,k = 9) == 102251773\n assert candidate(n = 45,m = 5,k = 1) == 675218148\n assert candidate(n = 30,m = 10,k = 15) == 0\n assert candidate(n = 15,m = 10,k = 5) == 483153304\n assert candidate(n = 45,m = 90,k = 40) == 920197928\n assert candidate(n = 7,m = 7,k = 5) == 5320\n assert candidate(n = 20,m = 50,k = 5) == 46582970\n assert candidate(n = 40,m = 15,k = 15) == 696143324\n assert candidate(n = 25,m = 25,k = 10) == 458548979\n assert candidate(n = 35,m = 15,k = 25) == 0\n assert candidate(n = 45,m = 25,k = 20) == 820427360\n assert candidate(n = 40,m = 25,k = 0) == 0\n assert candidate(n = 20,m = 3,k = 2) == 743392192\n assert candidate(n = 30,m = 20,k = 15) == 845454640\n", "comparison": "exact"}, "public_tests": ["2\n3\n1", "5\n2\n3", "9\n1\n1"], "hints": ["Use dynamic programming approach. Build dp table where dp[a][b][c] is the number of ways you can start building the array starting from index a where the search_cost = c and the maximum used integer was b.", "Recursively, solve the small sub-problems first. Optimize your answer by stopping the search if you exceeded k changes."], "metadata": {"canonical_parameter_names": ["n", "m", "k"], "leetcode_dataset_entry_point": "Solution().numOfArrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:41+00:00", "tests_total": 109, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numOfArrays(self, n: int, m: int, k: int) -> int:", "container": "Solution", "callable": "numOfArrays", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1422, "task_id": "maximum-score-after-splitting-a-string", "difficulty": "Easy", "problem_description": "Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).\n\nThe score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.\n\nExample 1:\n\nInput: s = \"011101\"\nOutput: 5\nExplanation:\nAll possible ways of splitting s into two non-empty substrings are:\nleft = \"0\" and right = \"11101\", score = 1 + 4 = 5\nleft = \"01\" and right = \"1101\", score = 1 + 3 = 4\nleft = \"011\" and right = \"101\", score = 1 + 2 = 3\nleft = \"0111\" and right = \"01\", score = 1 + 1 = 2\nleft = \"01110\" and right = \"1\", score = 2 + 1 = 3\n\nExample 2:\n\nInput: s = \"00111\"\nOutput: 5\nExplanation: When left = \"00\" and right = \"111\", we get the maximum score = 2 + 3 = 5\n\nExample 3:\n\nInput: s = \"1111\"\nOutput: 3\n\nConstraints:\n\n- 2 <= s.length <= 500\n- The string s consists of characters '0' and '1' only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 3\n assert candidate(s = \"00111\") == 5\n assert candidate(s = \"100100\") == 3\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"001001\") == 5\n assert candidate(s = \"11110000\") == 3\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1001001\") == 5\n assert candidate(s = \"1100\") == 1\n assert candidate(s = \"100001\") == 5\n assert candidate(s = \"00001111\") == 8\n assert candidate(s = \"000111\") == 6\n assert candidate(s = \"1001001001\") == 7\n assert candidate(s = \"001100\") == 4\n assert candidate(s = \"01010101\") == 5\n assert candidate(s = \"010101\") == 4\n assert candidate(s = \"101010\") == 3\n assert candidate(s = \"11001100\") == 4\n assert candidate(s = \"011101\") == 5\n assert candidate(s = \"000111000111000111000\") == 12\n assert candidate(s = \"101010101010101010\") == 9\n assert candidate(s = \"00000000000000000000000001\") == 26\n assert candidate(s = \"1000000000000000001\") == 18\n assert candidate(s = \"000000111111000000111111\") == 18\n assert candidate(s = \"01010101010101010101010101010101010101010\") == 21\n assert candidate(s = \"1000100010001\") == 10\n assert candidate(s = \"11111111110000000001111111111100000000\") == 20\n assert candidate(s = \"0110110110110110110110110110\") == 19\n assert candidate(s = \"0000000011111111111111\") == 22\n assert candidate(s = \"000011110000111100001111000011110000111100001111\") == 28\n assert candidate(s = \"1111111110\") == 8\n assert candidate(s = \"111110000011111000001111100000\") == 15\n assert candidate(s = \"10000000001111111111000000001111111111\") == 29\n assert candidate(s = \"010101010101010101010101\") == 13\n assert candidate(s = \"0110110110\") == 7\n assert candidate(s = \"10101010101010101010101010\") == 13\n assert candidate(s = \"00000000000000001111111111111111\") == 32\n assert candidate(s = \"111000111000111\") == 9\n assert candidate(s = \"111111111111111110\") == 16\n assert candidate(s = \"10011111000111\") == 10\n assert candidate(s = \"000111000111000111\") == 12\n assert candidate(s = \"101010101010101010101010\") == 12\n assert candidate(s = \"1010101010\") == 5\n assert candidate(s = \"010010010010010\") == 10\n assert candidate(s = \"0000000000\") == 9\n assert candidate(s = \"0000000000000000\") == 15\n assert candidate(s = \"1010101010101010\") == 8\n assert candidate(s = \"111100001111000011110000111100001111\") == 20\n assert candidate(s = \"111111000000111111000000\") == 12\n assert candidate(s = \"111100001111000011110000\") == 12\n assert candidate(s = \"000000000000001\") == 15\n assert candidate(s = \"011101110111011101\") == 14\n assert candidate(s = \"111100000000\") == 7\n assert candidate(s = \"101010010101001010100101010010101\") == 19\n assert candidate(s = \"11111000001111100000\") == 10\n assert candidate(s = \"000011110000111100001111000011110000\") == 20\n assert candidate(s = \"1111110000000001\") == 10\n assert candidate(s = \"111111100000001111111100000000111111\") == 21\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100\") == 36\n assert candidate(s = \"010101010101010101010101010\") == 14\n assert candidate(s = \"000000011111110000000011111111000000\") == 23\n assert candidate(s = \"0110110110110110\") == 11\n assert candidate(s = \"0000000001\") == 10\n assert candidate(s = \"11111111111111111110000000000000000\") == 18\n assert candidate(s = \"010100101001010010100101001\") == 17\n assert candidate(s = \"000001111111111111\") == 18\n assert candidate(s = \"101010101010\") == 6\n assert candidate(s = \"0001111000\") == 7\n assert candidate(s = \"1001001001001001001001001001001001001001001001\") == 31\n assert candidate(s = \"0000011111\") == 10\n assert candidate(s = \"11111111111111111111\") == 19\n assert candidate(s = \"1000000000\") == 8\n assert candidate(s = \"1111111111111111\") == 15\n assert candidate(s = \"000111000111000\") == 9\n assert candidate(s = \"0110110110110110110110110110110110110110110110\") == 31\n assert candidate(s = \"110001010101101010010101011110000101010101\") == 22\n assert candidate(s = \"111001010101010\") == 7\n assert candidate(s = \"01000110011001100110\") == 12\n assert candidate(s = \"101010101010101010101010101010101010101\") == 20\n assert candidate(s = \"0000001111111111\") == 16\n assert candidate(s = \"000111111110000\") == 11\n assert candidate(s = \"00000000001111111111\") == 20\n assert candidate(s = \"100100100100100100100100100100100100\") == 23\n assert candidate(s = \"00000000000000000001111111111111111\") == 35\n assert candidate(s = \"111111111111111111111111111111111111111111111\") == 44\n assert candidate(s = \"111000111000111000111\") == 12\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11111111110000000000\") == 9\n assert candidate(s = \"11100011100011100011\") == 11\n assert candidate(s = \"01010101010101010101010101010101\") == 17\n assert candidate(s = \"0000000001111111110000000001111111110000000000111111111\") == 37\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 21\n assert candidate(s = \"10010010010010010010\") == 13\n assert candidate(s = \"1010101010101010101010101010\") == 14\n assert candidate(s = \"00000000000000000000000000000000000000000000\") == 43\n assert candidate(s = \"111000111000\") == 6\n assert candidate(s = \"111000011111100\") == 10\n assert candidate(s = \"1000000000000000\") == 14\n assert candidate(s = \"000011111111\") == 12\n assert candidate(s = \"1100110011001100110011001100\") == 14\n assert candidate(s = \"0100101010101010\") == 9\n assert candidate(s = \"0101010101010101\") == 9\n assert candidate(s = \"1111111111111101\") == 14\n assert candidate(s = \"0101010101010101010\") == 10\n assert candidate(s = \"00010001000100010001\") == 16\n assert candidate(s = \"000011110000111100001111\") == 16\n assert candidate(s = \"0000111000111000\") == 10\n assert candidate(s = \"0101010101\") == 6\n assert candidate(s = \"11111111111111111111111110\") == 24\n assert candidate(s = \"00110011001100110011\") == 12\n assert candidate(s = \"0111111111000000\") == 10\n assert candidate(s = \"00000000000000000000\") == 19\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"10101010101010101010101010101010\") == 16\n assert candidate(s = \"1111100000\") == 4\n assert candidate(s = \"1111000000001111000000001111000000001111000000001111\") == 36\n assert candidate(s = \"0000000000000001\") == 16\n assert candidate(s = \"01010101010101\") == 8\n assert candidate(s = \"1101101101\") == 6\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 20\n assert candidate(s = \"1111111111\") == 9\n assert candidate(s = \"111110000011111\") == 10\n assert candidate(s = \"00011100011100011100\") == 12\n assert candidate(s = \"11101110111011101110\") == 14\n assert candidate(s = \"000100010001000100\") == 13\n assert candidate(s = \"01010101010101010101\") == 11\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == 36\n assert candidate(s = \"1001001001001001001001001001\") == 19\n assert candidate(s = \"000001111100000111110000011111\") == 20\n assert candidate(s = \"0010100101001010010100101001010010\") == 21\n assert candidate(s = \"010101010101010\") == 8\n assert candidate(s = \"00011110001111\") == 11\n assert candidate(s = \"01101101101101101101\") == 14\n assert candidate(s = \"10101010101010101010\") == 10\n assert candidate(s = \"11111111111111110000000000000000\") == 15\n assert candidate(s = \"0001100110\") == 7\n assert candidate(s = \"0000000000011111111111\") == 22\n assert candidate(s = \"11111111111111110000000000\") == 15\n assert candidate(s = \"001100110011001100110011001100\") == 16\n assert candidate(s = \"001100110011\") == 8\n assert candidate(s = \"0111000001\") == 7\n assert candidate(s = \"0000111100001111\") == 12\n", "comparison": "exact"}, "public_tests": ["\"011101\"", "\"00111\"", "\"1111\""], "hints": ["Precompute a prefix sum of ones ('1').", "Iterate from left to right counting the number of zeros ('0'), then use the precomputed prefix sum for counting ones ('1'). Update the answer."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:43+00:00", "tests_total": 143, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxScore(self, s: str) -> int:", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1423, "task_id": "maximum-points-you-can-obtain-from-cards", "difficulty": "Medium", "problem_description": "There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.\n\nIn one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.\n\nYour score is the sum of the points of the cards you have taken.\n\nGiven the integer array cardPoints and the integer k, return the maximum score you can obtain.\n\nExample 1:\n\nInput: cardPoints = [1,2,3,4,5,6,1], k = 3\nOutput: 12\nExplanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.\n\nExample 2:\n\nInput: cardPoints = [2,2,2], k = 2\nOutput: 4\nExplanation: Regardless of which two cards you take, your score will always be 4.\n\nExample 3:\n\nInput: cardPoints = [9,7,7,9,7,7,9], k = 7\nOutput: 55\nExplanation: You have to take all the cards. Your score is the sum of points of all cards.\n\nConstraints:\n\n- 1 <= cardPoints.length <= 10^5\n- 1 <= cardPoints[i] <= 10^4\n- 1 <= k <= cardPoints.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cardPoints = [5, 2, 1, 2, 5],k = 3) == 12\n assert candidate(cardPoints = [9, 7, 7, 9, 7, 7, 9],k = 7) == 55\n assert candidate(cardPoints = [1, 1000, 1],k = 1) == 1\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(cardPoints = [2, 2, 2],k = 2) == 4\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 1],k = 3) == 12\n assert candidate(cardPoints = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 90\n assert candidate(cardPoints = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5) == 5000\n assert candidate(cardPoints = [100, 400, 300, 100, 200, 500, 600, 300, 400],k = 4) == 1800\n assert candidate(cardPoints = [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(cardPoints = [5, 2, 1, 2, 5, 5, 5, 5, 5, 2, 1, 2, 5],k = 8) == 30\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10) == 100000\n assert candidate(cardPoints = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n assert candidate(cardPoints = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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) == 50\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 195\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 19\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(cardPoints = [3, 1, 2, 7, 4, 5, 6],k = 3) == 15\n assert candidate(cardPoints = [10, 1, 1, 10, 1, 1, 10, 1, 1],k = 3) == 12\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 4],k = 5) == 21\n assert candidate(cardPoints = [8, 9, 10, 4, 10, 1, 1, 1, 5, 9],k = 4) == 36\n assert candidate(cardPoints = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 10) == 5000\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 5],k = 3) == 15\n assert candidate(cardPoints = [5, 6, 4, 2, 7, 8, 3, 1, 9],k = 4) == 24\n assert candidate(cardPoints = [1000, 100, 10, 1, 10000, 1000, 100, 10],k = 4) == 11110\n assert candidate(cardPoints = [1, 2, 100, 3, 4, 100, 5, 6, 100, 7, 8, 100, 9, 10, 100, 11, 12, 100, 13, 14],k = 7) == 260\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 34\n assert candidate(cardPoints = [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(cardPoints = [5, 3, 8, 7, 6, 2, 9, 1, 4, 10],k = 4) == 26\n assert candidate(cardPoints = [10, 4, 5, 1, 7, 12, 3, 8, 6],k = 4) == 29\n assert candidate(cardPoints = [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(cardPoints = [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(cardPoints = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 6) == 39\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 195\n assert candidate(cardPoints = [5, 2, 1, 3, 4, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 8) == 51\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 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(cardPoints = [8, 9, 10, 4, 10, 4, 2, 2, 10, 10, 8, 6, 5, 1, 5, 9, 1, 6, 10, 8],k = 6) == 51\n assert candidate(cardPoints = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == 15\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 49\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 57\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 1550\n assert candidate(cardPoints = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 10) == 20\n assert candidate(cardPoints = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 25\n assert candidate(cardPoints = [10000, 1, 10000, 1, 10000, 1],k = 3) == 20001\n assert candidate(cardPoints = [100, 40, 17, 9, 73, 75, 36, 21, 14, 92, 58],k = 5) == 307\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 1, 2, 1, 2, 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) == 23\n assert candidate(cardPoints = [8, 9, 7, 6, 5, 4, 3, 2, 1],k = 3) == 24\n assert candidate(cardPoints = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 18) == 90\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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 = 20) == 810\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == 84\n assert candidate(cardPoints = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],k = 5) == 49990\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],k = 15) == 405\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 84\n assert candidate(cardPoints = [2, 3, 1, 2, 4, 3, 1, 5, 4],k = 5) == 17\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 1],k = 3) == 11\n assert candidate(cardPoints = [5, 3, 1, 2, 6, 4, 8, 9, 10, 7, 2, 1, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 193\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 209\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(cardPoints = [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(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 400\n assert candidate(cardPoints = [3, 2, 6, 7, 5, 4, 8, 1, 9],k = 4) == 22\n assert candidate(cardPoints = [3, 2, 7, 4, 1],k = 2) == 5\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 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(cardPoints = [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(cardPoints = [3, 1, 3, 100, 100, 100, 3, 1, 3],k = 5) == 207\n assert candidate(cardPoints = [3, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 5) == 28\n assert candidate(cardPoints = [5, 2, 1, 7, 3, 4, 6],k = 4) == 20\n assert candidate(cardPoints = [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(cardPoints = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == 270\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 27\n assert candidate(cardPoints = [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 = 15) == 3450\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 65\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6,1]\n3", "[2,2,2]\n2", "[9,7,7,9,7,7,9]\n7"], "hints": ["Let the sum of all points be total_pts. You need to remove a sub-array from cardPoints with length n - k.", "Keep a window of size n - k over the array. The answer is max(answer, total_pts - sumOfCurrentWindow)"], "metadata": {"canonical_parameter_names": ["cardPoints", "k"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:46+00:00", "tests_total": 78, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "sliding-window", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxScore(self, cardPoints: list[int], k: int) -> int:", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "cardPoints", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1424, "task_id": "diagonal-traverse-ii", "difficulty": "Medium", "problem_description": "Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.\n\nExample 1:\n\nInput: nums = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [1,4,2,7,5,3,8,6,9]\n\nExample 2:\n\nInput: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]\nOutput: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i].length <= 10^5\n- 1 <= sum(nums[i].length) <= 10^5\n- 1 <= nums[i][j] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[1]]) == [1]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [1, 4, 2, 7, 5, 3, 8, 6, 9]\n assert candidate(nums = [[1, 2, 3], [4, 5], [6]]) == [1, 4, 2, 6, 5, 3]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7], [8], [9, 10, 11], [12, 13, 14, 15, 16]]) == [1, 6, 2, 8, 7, 3, 9, 4, 12, 10, 5, 13, 11, 14, 15, 16]\n assert candidate(nums = [[1, 2], [3, 4], [5, 6]]) == [1, 3, 2, 5, 4, 6]\n assert candidate(nums = [[1, 2, 3], [4], [5, 6, 7], [8, 9]]) == [1, 4, 2, 5, 3, 8, 6, 9, 7]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 2, 6, 4, 7, 5, 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, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31], [32, 33, 34], [35, 36], [37]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 32, 28, 22, 14, 5, 35, 33, 29, 23, 15, 6, 37, 36, 34, 30, 24, 16, 7, 31, 25, 17, 8, 26, 18, 9, 19, 10]\n assert candidate(nums = [[100, 200], [300, 400, 500, 600], [700], [800, 900, 1000, 1100, 1200, 1300], [1400, 1500]]) == [100, 300, 200, 700, 400, 800, 500, 1400, 900, 600, 1500, 1000, 1100, 1200, 1300]\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, 5, 2, 8, 6, 3, 9, 7, 4, 13, 10, 15, 14, 11, 16, 12, 17, 18, 19, 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, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 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, 51]]) == [1, 21, 2, 31, 22, 3, 37, 32, 23, 4, 41, 38, 33, 24, 5, 43, 42, 39, 34, 25, 6, 44, 40, 35, 26, 7, 47, 45, 36, 27, 8, 48, 46, 28, 9, 49, 29, 10, 50, 30, 11, 51, 12, 13, 14, 15, 16, 17, 18, 19, 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]]) == [1, 3, 2, 6, 4, 10, 7, 5, 15, 11, 8, 21, 16, 12, 9, 22, 17, 13, 23, 18, 14, 24, 19, 25, 20, 26, 27]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18], [19, 20], [21], [22, 23, 24], [25, 26, 27, 28]]) == [1, 11, 2, 16, 12, 3, 19, 17, 13, 4, 21, 20, 18, 14, 5, 22, 15, 6, 25, 23, 7, 26, 24, 8, 27, 9, 28, 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, 2, 11, 3, 26, 12, 4, 32, 27, 13, 5, 33, 28, 14, 6, 34, 29, 15, 7, 35, 30, 16, 8, 36, 31, 17, 9, 37, 18, 10, 38, 19, 39, 20, 40, 21, 22, 23, 24, 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, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35, 36]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 22, 17, 13, 10, 29, 23, 18, 14, 30, 24, 19, 15, 31, 25, 20, 32, 26, 21, 33, 27, 34, 28, 35, 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], [28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38], [39, 40, 41, 42], [43, 44, 45], [46, 47], [48, 49], [50]]) == [1, 11, 2, 20, 12, 3, 28, 21, 13, 4, 34, 29, 22, 14, 5, 39, 35, 30, 23, 15, 6, 43, 40, 36, 31, 24, 16, 7, 46, 44, 41, 37, 32, 25, 17, 8, 48, 47, 45, 42, 38, 33, 26, 18, 9, 50, 49, 27, 19, 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]]) == [1, 2, 5, 3, 9, 6, 4, 14, 10, 7, 20, 15, 11, 8, 27, 21, 16, 12, 35, 28, 22, 17, 13, 36, 29, 23, 18, 37, 30, 24, 19, 38, 31, 25, 39, 32, 26, 40, 33, 41, 34, 42, 43]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6], [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, 5, 2, 7, 6, 3, 10, 8, 4, 11, 9, 16, 12, 19, 17, 13, 21, 20, 18, 14, 25, 22, 15, 28, 26, 23, 29, 27, 24, 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]]) == [1, 6, 2, 9, 7, 3, 11, 10, 8, 4, 12, 5, 18, 13, 22, 19, 14, 20, 15, 21, 16, 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, 41], [42, 43, 44], [45, 46], [47]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 33, 28, 22, 14, 5, 38, 34, 29, 23, 15, 6, 42, 39, 35, 30, 24, 16, 7, 45, 43, 40, 36, 31, 25, 17, 8, 47, 46, 44, 41, 37, 32, 26, 18, 9, 19, 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]]) == [1, 4, 2, 11, 5, 3, 14, 12, 6, 15, 13, 7, 16, 8, 17, 9, 18, 10, 19, 20, 21, 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]]) == [1, 3, 2, 8, 4, 11, 9, 5, 13, 12, 10, 6, 14, 7, 18, 15, 21, 19, 16, 23, 22, 20, 17, 24, 25, 26, 27, 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]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 17, 13, 10, 18, 14, 19, 15, 20, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]]) == [1, 4, 2, 9, 5, 3, 19, 10, 6, 28, 20, 11, 7, 29, 21, 12, 8, 30, 22, 13, 31, 23, 14, 32, 24, 15, 33, 25, 16, 34, 26, 17, 35, 27, 18, 36, 37, 38, 39, 40, 41, 42, 43]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 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, 11, 2, 20, 12, 3, 27, 21, 13, 4, 33, 28, 22, 14, 5, 38, 34, 29, 23, 15, 6, 42, 39, 35, 30, 24, 16, 7, 45, 43, 40, 36, 31, 25, 17, 8, 47, 46, 44, 41, 37, 32, 26, 18, 9, 48, 19, 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, 7, 2, 10, 8, 3, 12, 11, 9, 4, 16, 13, 5, 17, 14, 6, 18, 15, 19, 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]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15], [16]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 14, 12, 9, 16, 15, 13, 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]]) == [1, 11, 2, 20, 12, 3, 25, 21, 13, 4, 28, 26, 22, 14, 5, 29, 27, 23, 15, 6, 30, 24, 16, 7, 31, 17, 8, 32, 18, 9, 33, 19, 10, 34, 35, 36]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8], [9, 10, 11], [12, 13, 14], [15], [16, 17, 18, 19]]) == [1, 7, 2, 9, 8, 3, 12, 10, 4, 15, 13, 11, 5, 16, 14, 6, 17, 18, 19]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8], [9, 10, 11, 12], [13, 14]]) == [1, 5, 2, 8, 6, 3, 9, 7, 4, 13, 10, 14, 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, 21], [22]]) == [1, 4, 2, 8, 5, 3, 13, 9, 6, 17, 14, 10, 7, 20, 18, 15, 11, 22, 21, 19, 16, 12]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9], [10, 11, 12, 13], [14, 15], [16]]) == [1, 7, 2, 10, 8, 3, 14, 11, 9, 4, 16, 15, 12, 5, 13, 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, 41, 42]]) == [1, 11, 2, 19, 12, 3, 25, 20, 13, 4, 29, 26, 21, 14, 5, 32, 30, 27, 22, 15, 6, 34, 33, 31, 28, 23, 16, 7, 35, 24, 17, 8, 38, 36, 18, 9, 39, 37, 10, 40, 41, 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, 21], [22, 23, 24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35, 36, 37, 38]]) == [1, 4, 2, 9, 5, 3, 15, 10, 6, 22, 16, 11, 7, 30, 23, 17, 12, 8, 31, 24, 18, 13, 32, 25, 19, 14, 33, 26, 20, 34, 27, 21, 35, 28, 36, 29, 37, 38]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34]]) == [1, 2, 5, 3, 9, 6, 4, 14, 10, 7, 20, 15, 11, 8, 27, 21, 16, 12, 28, 22, 17, 13, 29, 23, 18, 30, 24, 19, 31, 25, 32, 26, 33, 34]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 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, 6, 2, 12, 7, 3, 19, 13, 8, 4, 25, 20, 14, 9, 5, 30, 26, 21, 15, 10, 34, 31, 27, 22, 16, 11, 37, 35, 32, 28, 23, 17, 39, 38, 36, 33, 29, 24, 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, 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]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16]]) == [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, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 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, 11, 2, 20, 12, 3, 27, 21, 13, 4, 28, 22, 14, 5, 29, 23, 15, 6, 30, 24, 16, 7, 31, 25, 17, 8, 32, 26, 18, 9, 33, 19, 10, 34, 35, 36, 37, 38, 39, 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, 7, 2, 11, 8, 3, 14, 12, 9, 4, 16, 15, 13, 10, 5, 17, 6, 18, 19, 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]\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 = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [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, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]\n 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, 4, 2, 10, 5, 3, 15, 11, 6, 17, 16, 12, 7, 21, 18, 13, 8, 19, 14, 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]]) == [1, 6, 2, 9, 7, 3, 11, 10, 8, 4, 12, 5, 16, 13, 19, 17, 14, 20, 18, 15, 21, 22, 23, 24, 25, 26, 27, 28, 29, 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]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 12, 9, 13, 10, 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, 20]]) == [1, 3, 2, 6, 4, 10, 7, 5, 15, 11, 8, 16, 12, 9, 17, 13, 18, 14, 19, 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, 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, 16, 2, 30, 17, 3, 42, 31, 18, 4, 53, 43, 32, 19, 5, 63, 54, 44, 33, 20, 6, 72, 64, 55, 45, 34, 21, 7, 79, 73, 65, 56, 46, 35, 22, 8, 85, 80, 74, 66, 57, 47, 36, 23, 9, 90, 86, 81, 75, 67, 58, 48, 37, 24, 10, 94, 91, 87, 82, 76, 68, 59, 49, 38, 25, 11, 97, 95, 92, 88, 83, 77, 69, 60, 50, 39, 26, 12, 99, 98, 96, 93, 89, 84, 78, 70, 61, 51, 40, 27, 13, 71, 62, 52, 41, 28, 14, 29, 15]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 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]]) == [1, 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, 4], [5, 6, 7], [8, 9], [10], [11, 12, 13, 14, 15], [16, 17, 18, 19]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4, 11, 16, 12, 17, 13, 18, 14, 19, 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]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 22, 17, 13, 10, 23, 18, 14, 24, 19, 15, 25, 20, 26, 21, 27, 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]]) == [1, 3, 2, 4, 8, 5, 10, 9, 6, 13, 11, 7, 18, 14, 12, 19, 15, 20, 16, 21, 17, 22, 23]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10], [11, 12, 13, 14], [15, 16]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4, 11, 15, 12, 16, 13, 14]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15, 16, 17, 18]]) == [1, 2, 5, 3, 7, 6, 4, 11, 8, 14, 12, 9, 15, 13, 10, 16, 17, 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]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5, 16, 21, 17, 22, 18, 23, 19, 24, 20, 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, 26, 27, 28], [29, 30, 31], [32, 33], [34]]) == [1, 11, 2, 19, 12, 3, 25, 20, 13, 4, 29, 26, 21, 14, 5, 32, 30, 27, 22, 15, 6, 34, 33, 31, 28, 23, 16, 7, 24, 17, 8, 18, 9, 10]\n assert candidate(nums = [[100, 200, 300], [400, 500], [600], [700, 800, 900, 1000], [1100, 1200, 1300], [1400, 1500, 1600, 1700, 1800]]) == [100, 400, 200, 600, 500, 300, 700, 1100, 800, 1400, 1200, 900, 1500, 1300, 1000, 1600, 1700, 1800]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45]]) == [1, 6, 2, 11, 7, 3, 16, 12, 8, 4, 21, 17, 13, 9, 5, 26, 22, 18, 14, 10, 31, 27, 23, 19, 15, 36, 32, 28, 24, 20, 41, 37, 33, 29, 25, 42, 38, 34, 30, 43, 39, 35, 44, 40, 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]]) == [1, 10, 2, 17, 11, 3, 22, 18, 12, 4, 26, 23, 19, 13, 5, 28, 27, 24, 20, 14, 6, 25, 21, 15, 7, 16, 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, 21, 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, 16, 2, 31, 17, 3, 32, 18, 4, 33, 19, 5, 34, 20, 6, 35, 21, 7, 36, 22, 8, 37, 23, 9, 38, 24, 10, 39, 25, 11, 40, 26, 12, 41, 27, 13, 42, 28, 14, 43, 29, 15, 44, 30, 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]]) == [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]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 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, 11, 2, 20, 12, 3, 28, 21, 13, 4, 35, 29, 22, 14, 5, 36, 30, 23, 15, 6, 37, 31, 24, 16, 7, 38, 32, 25, 17, 8, 39, 33, 26, 18, 9, 40, 34, 27, 19, 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]]) == [1, 12, 2, 21, 13, 3, 28, 22, 14, 4, 33, 29, 23, 15, 5, 37, 34, 30, 24, 16, 6, 40, 38, 35, 31, 25, 17, 7, 42, 41, 39, 36, 32, 26, 18, 8, 43, 27, 19, 9, 20, 10, 11]\n", "comparison": "exact"}, "public_tests": ["[[1,2,3],[4,5,6],[7,8,9]]", "[[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]"], "hints": ["Notice that numbers with equal sums of row and column indexes belong to the same diagonal.", "Store them in tuples (sum, row, val), sort them, and then regroup the answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findDiagonalOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:48+00:00", "tests_total": 70, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def findDiagonalOrder(self, nums: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findDiagonalOrder", "parameters": [{"name": "nums", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1425, "task_id": "constrained-subsequence-sum", "difficulty": "Hard", "problem_description": "Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.\n\nA subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.\n\nExample 1:\n\nInput: nums = [10,2,-10,5,20], k = 2\nOutput: 37\nExplanation: The subsequence is [10, 2, 5, 20].\n\nExample 2:\n\nInput: nums = [-1,-2,-3], k = 1\nOutput: -1\nExplanation: The subsequence must be non-empty, so we choose the largest number.\n\nExample 3:\n\nInput: nums = [10,-2,-10,-5,20], k = 2\nOutput: 23\nExplanation: The subsequence is [10, -2, -5, 20].\n\nConstraints:\n\n- 1 <= k <= nums.length <= 10^5\n- -10^4 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 7, -3, 5],k = 1) == 14\n assert candidate(nums = [10, 2, -10, 5, 20],k = 2) == 37\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 15\n assert candidate(nums = [3, -1, 4, -2, 2, 1],k = 2) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 4) == -1\n assert candidate(nums = [5, -1, 5],k = 2) == 10\n assert candidate(nums = [-1, -2, -3],k = 1) == -1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 5) == 15\n assert candidate(nums = [5, 3, -5, -10, -3, 7],k = 4) == 15\n assert candidate(nums = [1, -1, 5, -2, 3],k = 3) == 9\n assert candidate(nums = [10, -2, -10, -5, 20],k = 2) == 23\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 2) == 15\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 2) == 150\n assert candidate(nums = [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, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = 5) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70],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 = 20) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 4) == 150\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == 5500\n assert candidate(nums = [1000, -500, 200, -300, 400, -200, 600, -100, 700, -300],k = 5) == 2900\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],k = 4) == 50000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [-10, -3, -5, -1, -6, -2, -4, -8, -9],k = 2) == -1\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 = 5) == 19810\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [10, -2, 3, 5, -1, 2, 0, 8, -5, 10],k = 4) == 38\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100],k = 2) == 500\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 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],k = 7) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [100, -200, 300, -400, 500, 600, -700, 800, -900, 1000],k = 3) == 3300\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],k = 2) == 15000\n assert candidate(nums = [1, 2, 3, -4, 5, 6, -7, 8, 9, -10],k = 3) == 34\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 = 7) == 400\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, 5000, 4000, 3000, 2000, 1000],k = 4) == 15000\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 = [-1, -2, -3, -4, -5, -6, -7, -8, -9],k = 4) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 550\n assert candidate(nums = [5, 2, 3, 1, 6, 4, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 65\n assert candidate(nums = [100, -300, 200, 50, -150, 400, 300],k = 3) == 1050\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3) == 30\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == 1500\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) == 400\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1) == -1\n assert candidate(nums = [-10, 2, -3, -4, 5, 6, -1, 2, 3, -10, 100, -200, 300],k = 4) == 418\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 5) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 6) == 64\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 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 = 15) == 50\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, -5000, -4000, -3000, -2000, -1000],k = 5) == 15000\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 7) == 8000\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) == 50\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 4) == 1045\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 600, 700, 800, 900, 1000],k = 7) == 5500\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 50\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 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],k = 9) == 90\n assert candidate(nums = [100, -50, 200, -250, 300, -350, 400, -450, 500],k = 5) == 1500\n assert candidate(nums = [1, -2, 3, 5, -1, 2, 4, -3, 7],k = 3) == 22\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10],k = 6) == 550\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 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1) == 5500\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 5) == 105\n assert candidate(nums = [3, -1, 4, -1, 5, -9, 2, 6, -5, 3, 5, -7, 8, -2, 6],k = 5) == 42\n assert candidate(nums = [100, 50, 20, 10, -10, -20, -50, -100, 30, 40],k = 4) == 240\n assert candidate(nums = [-10, 2, -3, 4, -1, 5, -6, 7, -8, 9],k = 4) == 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],k = 7) == 325\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) == 2100\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 5) == 6\n assert candidate(nums = [10, -2, -10, 5, 20, -30, 40, -50, 60, -70],k = 3) == 135\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 7) == 550\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91],k = 5) == -91\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) == -1\n assert candidate(nums = [1, 2, 3, -6, 4, 5, -7, 6, 7, -8, 8, 9],k = 3) == 45\n assert candidate(nums = [3, -2, 5, -1, 6, 2, -5, 10],k = 3) == 26\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120],k = 6) == 360\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 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 = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 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 = 10) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 1\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == 2500\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1],k = 6) == 197\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 = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 5\n assert candidate(nums = [3, -1, -10, 4, 13, -5, 12, -3, 15, -10, 7, 8],k = 3) == 62\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 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) == 210\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000],k = 3) == 15000\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 5) == 2500\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -2, -3, -4, -5, 60, 70, 80, 90, 100],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],k = 10) == 100\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 4) == -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 = 10) == 210\n assert candidate(nums = [-10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000],k = 2) == -1000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 7) == 64\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 3) == 55\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 4) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 120\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [10, -5, 20, -10, 5, 15, -3],k = 3) == 50\n assert candidate(nums = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5],k = 1) == -5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [-1, 3, -2, 5, -6, 4, 2, -3, 5, -4],k = 3) == 19\n", "comparison": "exact"}, "public_tests": ["[10,2,-10,5,20]\n2", "[-1,-2,-3]\n1", "[10,-2,-10,-5,20]\n2"], "hints": ["Use dynamic programming.", "Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence.", "dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1])", "Use a heap with the sliding window technique to optimize the dp."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().constrainedSubsetSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:50+00:00", "tests_total": 115, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "dynamic-programming", "queue", "sliding-window", "heap-priority-queue", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def constrainedSubsetSum(self, nums: list[int], k: int) -> int:", "container": "Solution", "callable": "constrainedSubsetSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1431, "task_id": "kids-with-the-greatest-number-of-candies", "difficulty": "Easy", "problem_description": "There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the i^th kid has, and an integer extraCandies, denoting the number of extra candies that you have.\n\nReturn a boolean array result of length n, where result[i] is true if, after giving the i^th kid all the extraCandies, they will have the greatest number of candies among all the kids, or false otherwise.\n\nNote that multiple kids can have the greatest number of candies.\n\nExample 1:\n\nInput: candies = [2,3,5,1,3], extraCandies = 3\nOutput: [true,true,true,false,true]\nExplanation: If you give all extraCandies to:\n- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids.\n- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids.\n- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids.\n- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids.\n- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids.\n\nExample 2:\n\nInput: candies = [4,2,1,1,2], extraCandies = 1\nOutput: [true,false,false,false,false]\nExplanation: There is only 1 extra candy.\nKid 1 will always have the greatest number of candies, even if a different kid is given the extra candy.\n\nExample 3:\n\nInput: candies = [12,1,12], extraCandies = 10\nOutput: [true,false,true]\n\nConstraints:\n\n- n == candies.length\n- 2 <= n <= 100\n- 1 <= candies[i] <= 100\n- 1 <= extraCandies <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candies = [4, 2, 1, 1, 2],extraCandies = 1) == [True, False, False, False, False]\n assert candidate(candies = [12, 1, 12],extraCandies = 10) == [True, False, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 50) == [True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5],extraCandies = 2) == [False, False, True, True, True]\n assert candidate(candies = [2, 3, 5, 1, 3],extraCandies = 3) == [True, True, True, False, True]\n assert candidate(candies = [5, 8, 7],extraCandies = 5) == [True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],extraCandies = 10) == [False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],extraCandies = 10) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 20) == [True, True, True, False, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 5) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [5, 5, 5, 5, 5],extraCandies = 5) == [True, True, True, True, True]\n assert candidate(candies = [5, 5, 5, 5, 5],extraCandies = 1) == [True, True, True, True, True]\n assert candidate(candies = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],extraCandies = 50) == [False, True, False, True, False, True, False, True, False, True]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 20) == [False, False, True, True, True]\n assert candidate(candies = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 24) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],extraCandies = 50) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],extraCandies = 50) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 10) == [True, True, True, True, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10],extraCandies = 10) == [True, True, False, False, False, False, False, False, False]\n assert candidate(candies = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5],extraCandies = 50) == [True, False, True, False, True, False, True, False, True, False]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],extraCandies = 10) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 40) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [23, 45, 12, 67, 34, 89, 10, 56],extraCandies = 20) == [False, False, False, False, False, True, False, False]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 9) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 5) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],extraCandies = 5) == [False, False, False, False, False, False, False, True, True, True]\n assert candidate(candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],extraCandies = 25) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 50) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],extraCandies = 5) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 15) == [False, False, False, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10],extraCandies = 15) == [True, True, False, False, False, False, False, False, False]\n assert candidate(candies = [30, 40, 20, 50, 10],extraCandies = 10) == [False, True, False, True, False]\n assert candidate(candies = [1, 50, 25, 75, 35],extraCandies = 25) == [False, True, False, True, False]\n assert candidate(candies = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5],extraCandies = 7) == [True, False, True, False, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [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],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],extraCandies = 50) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [50, 20, 20, 10, 30],extraCandies = 20) == [True, False, False, False, True]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 25) == [False, False, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 10) == [True, True, False, False, False]\n assert candidate(candies = [50, 25, 75, 25, 50, 100, 75, 50, 25, 75],extraCandies = 25) == [False, False, True, False, False, True, True, False, False, True]\n assert candidate(candies = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],extraCandies = 9) == [False, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 25) == [True, True, True, False, False]\n assert candidate(candies = [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],extraCandies = 25) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 10, 20, 30, 40],extraCandies = 20) == [True, False, False, True, True]\n assert candidate(candies = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],extraCandies = 5) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(candies = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],extraCandies = 50) == [True, False, True, False, True, False, True, False, True, False]\n assert candidate(candies = [80, 80, 80, 80, 80],extraCandies = 20) == [True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 4) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 30) == [True, True, True, True, False]\n assert candidate(candies = [100, 100, 100, 100, 100],extraCandies = 50) == [True, True, True, True, True]\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],extraCandies = 15) == [False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 10) == [False, False, False, False, False, False, False, False, True, True]\n assert candidate(candies = [3, 3, 3, 3, 3],extraCandies = 3) == [True, True, True, True, True]\n assert candidate(candies = [7, 5, 9, 10, 2],extraCandies = 5) == [True, True, True, True, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],extraCandies = 50) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],extraCandies = 49) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 45) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 1) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candies = [20, 15, 20, 10, 30],extraCandies = 10) == [True, False, True, False, True]\n assert candidate(candies = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 10, 10, 10, 10],extraCandies = 1) == [True, True, True, True, True]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],extraCandies = 8) == [False, False, False, False, False, True, True, True, True, True]\n", "comparison": "exact"}, "public_tests": ["[2,3,5,1,3]\n3", "[4,2,1,1,2]\n1", "[12,1,12]\n10"], "hints": ["For each kid check if candies[i] + extraCandies ≥ maximum in Candies[i]."], "metadata": {"canonical_parameter_names": ["candies", "extraCandies"], "leetcode_dataset_entry_point": "Solution().kidsWithCandies", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:19:59+00:00", "tests_total": 81, "tests_dropped": 10, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def kidsWithCandies(self, candies: list[int], extraCandies: int) -> list[bool]:", "container": "Solution", "callable": "kidsWithCandies", "parameters": [{"name": "candies", "type": "list[int]"}, {"name": "extraCandies", "type": "int"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1432, "task_id": "max-difference-you-can-get-from-changing-an-integer", "difficulty": "Medium", "problem_description": "You are given an integer num. You will apply the following steps to num two separate times:\n\n- Pick a digit x (0 <= x <= 9).\n- Pick another digit y (0 <= y <= 9). Note y can be equal to x.\n- Replace all the occurrences of x in the decimal representation of num by y.\n\nLet a and b be the two results from applying the operation to num independently.\n\nReturn the max difference between a and b.\n\nNote that neither a nor b may have any leading zeros, and must not be 0.\n\nExample 1:\n\nInput: num = 555\nOutput: 888\nExplanation: The first time pick x = 5 and y = 9 and store the new integer in a.\nThe second time pick x = 5 and y = 1 and store the new integer in b.\nWe have now a = 999 and b = 111 and max difference = 888\n\nExample 2:\n\nInput: num = 9\nOutput: 8\nExplanation: The first time pick x = 9 and y = 9 and store the new integer in a.\nThe second time pick x = 9 and y = 1 and store the new integer in b.\nWe have now a = 9 and b = 1 and max difference = 8\n\nConstraints:\n\n- 1 <= num <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 1001100) == 8008800\n assert candidate(num = 9) == 8\n assert candidate(num = 98789) == 81018\n assert candidate(num = 123456) == 820000\n assert candidate(num = 1000000) == 8000000\n assert candidate(num = 1221) == 8228\n assert candidate(num = 1111111) == 8888888\n assert candidate(num = 987789) == 810018\n assert candidate(num = 1001001) == 8008008\n assert candidate(num = 12321) == 82028\n assert candidate(num = 555) == 888\n assert candidate(num = 9999999) == 8888888\n assert candidate(num = 123321) == 820028\n assert candidate(num = 99100099) == 88800088\n assert candidate(num = 100000000) == 800000000\n assert candidate(num = 12212212) == 82282282\n assert candidate(num = 10000000) == 80000000\n assert candidate(num = 90000009) == 89999998\n assert candidate(num = 1234321) == 8200028\n assert candidate(num = 20202020) == 80808080\n assert candidate(num = 44440000) == 88880000\n assert candidate(num = 3330333) == 8880888\n assert candidate(num = 10000001) == 80000008\n assert candidate(num = 9191919) == 8888888\n assert candidate(num = 122121) == 822828\n assert candidate(num = 8998) == 8008\n assert candidate(num = 77777777) == 88888888\n assert candidate(num = 88888888) == 88888888\n assert candidate(num = 19000000) == 89000000\n assert candidate(num = 1919191) == 8989898\n assert candidate(num = 11001100) == 88008800\n assert candidate(num = 59595959) == 80808080\n assert candidate(num = 999000) == 888999\n assert candidate(num = 90000000) == 89999999\n assert candidate(num = 57575757) == 80808080\n assert candidate(num = 90009) == 89998\n assert candidate(num = 99999999) == 88888888\n assert candidate(num = 100000) == 800000\n assert candidate(num = 1000100) == 8000800\n assert candidate(num = 19191919) == 89898989\n assert candidate(num = 1000001) == 8000008\n assert candidate(num = 44444444) == 88888888\n assert candidate(num = 8880888) == 8880888\n assert candidate(num = 1230123) == 8200820\n", "comparison": "exact"}, "public_tests": ["555", "9"], "hints": ["We need to get the max and min value after changing num and the answer is max - min.", "Use brute force, try all possible changes and keep the minimum and maximum values."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().maxDiff", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:01+00:00", "tests_total": 81, "tests_dropped": 37, "flags": [], "topic_tags": ["math", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxDiff(self, num: int) -> int:", "container": "Solution", "callable": "maxDiff", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1433, "task_id": "check-if-a-string-can-break-another-string", "difficulty": "Medium", "problem_description": "Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.\n\nA string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.\n\nExample 1:\n\nInput: s1 = \"abc\", s2 = \"xya\"\nOutput: true\nExplanation: \"ayx\" is a permutation of s2=\"xya\" which can break to string \"abc\" which is a permutation of s1=\"abc\".\n\nExample 2:\n\nInput: s1 = \"abe\", s2 = \"acd\"\nOutput: false\nExplanation: All permutations for s1=\"abe\" are: \"abe\", \"aeb\", \"bae\", \"bea\", \"eab\" and \"eba\" and all permutation for s2=\"acd\" are: \"acd\", \"adc\", \"cad\", \"cda\", \"dac\" and \"dca\". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.\n\nExample 3:\n\nInput: s1 = \"leetcodee\", s2 = \"interview\"\nOutput: true\n\nConstraints:\n\n- s1.length == n\n- s2.length == n\n- 1 <= n <= 10^5\n- All strings consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abc\",s2 = \"bca\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == True\n assert candidate(s1 = \"aazz\",s2 = \"zzaa\") == True\n assert candidate(s1 = \"abac\",s2 = \"baca\") == True\n assert candidate(s1 = \"xyz\",s2 = \"wvu\") == True\n assert candidate(s1 = \"abc\",s2 = \"xya\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"abcabc\") == True\n assert candidate(s1 = \"pqrs\",s2 = \"rstu\") == True\n assert candidate(s1 = \"zyx\",s2 = \"wvu\") == True\n assert candidate(s1 = \"abcd\",s2 = \"adcb\") == True\n assert candidate(s1 = \"aaa\",s2 = \"bbb\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == True\n assert candidate(s1 = \"abe\",s2 = \"acd\") == False\n assert candidate(s1 = \"leetcodee\",s2 = \"interview\") == True\n assert candidate(s1 = \"python\",s2 = \"typhon\") == True\n assert candidate(s1 = \"abcdxyz\",s2 = \"zyxwvut\") == True\n assert candidate(s1 = \"zzzz\",s2 = \"zzzz\") == True\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"logarithm\") == True\n assert candidate(s1 = \"longerstringwithvariouscharacters\",s2 = \"variouscharacterswithlongerstring\") == True\n assert candidate(s1 = \"zzzzzz\",s2 = \"aaaaaa\") == True\n assert candidate(s1 = \"unbreakable\",s2 = \"rebreakable\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pippiimissi\") == True\n assert candidate(s1 = \"almostsame\",s2 = \"almostsane\") == True\n assert candidate(s1 = \"racecar\",s2 = \"carrace\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zyzxzyzyzxzyzyz\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"cadabrabara\") == True\n assert candidate(s1 = \"zyxwvutsrqponmlkjihgfedcba\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s1 = \"randomstringhere\",s2 = \"somestringrandom\") == True\n assert candidate(s1 = \"uniquechars\",s2 = \"distinctset\") == False\n assert candidate(s1 = \"zzzzzzzz\",s2 = \"zzzzzzzz\") == True\n assert candidate(s1 = \"zzzzzzzzzz\",s2 = \"zzzzzzzzzz\") == True\n assert candidate(s1 = \"complex\",s2 = \"lexicom\") == True\n assert candidate(s1 = \"abcdxyzabcdxyz\",s2 = \"xyzabcdxyzabcd\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == True\n assert candidate(s1 = \"pppppppppp\",s2 = \"qqqqqqqqqq\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"fedcbaghij\") == True\n assert candidate(s1 = \"programming\",s2 = \"gnimmargorp\") == True\n assert candidate(s1 = \"permutation\",s2 = \"reupmttinao\") == True\n assert candidate(s1 = \"aabbccddeeffgghhii\",s2 = \"iihhggeeffddccbbaa\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"jihgfedcbaa\") == True\n assert candidate(s1 = \"xyzzzz\",s2 = \"zzzzxy\") == True\n assert candidate(s1 = \"medium\",s2 = \"median\") == True\n assert candidate(s1 = \"mnopqr\",s2 = \"qrstuv\") == True\n assert candidate(s1 = \"xyzyzyzyzyzyzyzyz\",s2 = \"zyxzyxzyxzyxzyxzy\") == True\n assert candidate(s1 = \"aaaabbbbccccdddd\",s2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"thmalogri\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"yyzz\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"bbccaa\") == True\n assert candidate(s1 = \"aaaaabbbbbcccccc\",s2 = \"bbbbbaaaaacccccb\") == True\n assert candidate(s1 = \"abcdefghijklmnop\",s2 = \"ponmlkjihgfedcba\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"ghijkl\") == True\n assert candidate(s1 = \"aaaabbbbcccc\",s2 = \"ccccbbbbaaaa\") == True\n assert candidate(s1 = \"aabcc\",s2 = \"bbdda\") == True\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"dcbaabcddcba\") == True\n assert candidate(s1 = \"permutation\",s2 = \"nutationspr\") == True\n assert candidate(s1 = \"aaaaaaab\",s2 = \"baaaaaaa\") == True\n assert candidate(s1 = \"equalstring\",s2 = \"equalstring\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"zyxwvutsrqz\") == True\n assert candidate(s1 = \"aaaaaa\",s2 = \"bbbbbb\") == True\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"jihgfedcba\") == True\n assert candidate(s1 = \"optimization\",s2 = \"nttimzpiaoos\") == True\n assert candidate(s1 = \"optimization\",s2 = \"izationoptim\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pississippi\") == True\n assert candidate(s1 = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",s2 = \"ccccccccccbbbbbbbbbbaaaaaaaaaa\") == True\n assert candidate(s1 = \"longerstringexample\",s2 = \"examplelongerstring\") == True\n assert candidate(s1 = \"abcabcabc\",s2 = \"xyzxyzxyz\") == True\n assert candidate(s1 = \"pqrstuvw\",s2 = \"qrstuvwp\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == True\n assert candidate(s1 = \"pqrsrpqrsrpqrsr\",s2 = \"zyxwzyxwzyxwzyx\") == True\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == True\n assert candidate(s1 = \"abcdefghijklnmopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"abcdefghijabcdefghijabcdefghij\",s2 = \"zyxwvutsrqzyxwvutsrqzyxwvutsrq\") == True\n assert candidate(s1 = \"interview\",s2 = \"terviewin\") == True\n assert candidate(s1 = \"mnopqr\",s2 = \"rstuvw\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"break\",s2 = \"maker\") == True\n assert candidate(s1 = \"qrstuv\",s2 = \"vwxyza\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"zyxcbaa\") == True\n assert candidate(s1 = \"zzzzz\",s2 = \"aaaaa\") == True\n assert candidate(s1 = \"aabbbccc\",s2 = \"cccbbbaa\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"ghijklm\") == True\n assert candidate(s1 = \"leetcode\",s2 = \"docodele\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"wxyz\") == True\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzz\",s2 = \"aaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s1 = \"banana\",s2 = \"anabna\") == True\n", "comparison": "exact"}, "public_tests": ["\"abc\"\n\"xya\"", "\"abe\"\n\"acd\"", "\"leetcodee\"\n\"interview\""], "hints": ["Sort both strings and then check if one of them can break the other."], "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().checkIfCanBreak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:04+00:00", "tests_total": 120, "tests_dropped": 26, "flags": [], "topic_tags": ["string", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def checkIfCanBreak(self, s1: str, s2: str) -> bool:", "container": "Solution", "callable": "checkIfCanBreak", "parameters": [{"name": "s1", "type": "str"}, {"name": "s2", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1434, "task_id": "number-of-ways-to-wear-different-hats-to-each-other", "difficulty": "Hard", "problem_description": "There are n people and 40 types of hats labeled from 1 to 40.\n\nGiven a 2D integer array hats, where hats[i] is a list of all hats preferred by the i^th person.\n\nReturn the number of ways that n people can wear different hats from each other.\n\nSince the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: hats = [[3,4],[4,5],[5]]\nOutput: 1\nExplanation: There is only one way to choose hats given the conditions.\nFirst person chooses hat 3, Second person chooses hat 4 and last one hat 5.\n\nExample 2:\n\nInput: hats = [[3,5,1],[3,5]]\nOutput: 4\nExplanation: There are 4 ways to choose hats:\n(3,5), (5,3), (1,3) and (1,5)\n\nExample 3:\n\nInput: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]\nOutput: 24\nExplanation: Each person can choose hats labeled from 1 to 4.\nNumber of Permutations of (1,2,3,4) = 24.\n\nConstraints:\n\n- n == hats.length\n- 1 <= n <= 10\n- 1 <= hats[i].length <= 40\n- 1 <= hats[i][j] <= 40\n- hats[i] contains a list of unique integers.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hats = [[1, 2], [3, 4], [5, 6]]) == 8\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n assert candidate(hats = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 16\n assert candidate(hats = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]) == 1\n assert candidate(hats = [[1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == 25\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 100\n assert candidate(hats = [[1], [2], [3], [4], [5]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 90\n assert candidate(hats = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]) == 0\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 26\n assert candidate(hats = [[3], [5], [1], [2]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 90\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 10000\n assert candidate(hats = [[3, 5, 1], [3, 5]]) == 4\n assert candidate(hats = [[3, 4], [4, 5], [5]]) == 1\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 14\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29]]) == 625\n assert candidate(hats = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]) == 24\n assert candidate(hats = [[1, 4, 7, 10, 13], [2, 5, 8, 11, 14], [3, 6, 9, 12, 15], [1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]]) == 38130\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 2250\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]) == 7600\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 90000\n assert candidate(hats = [[3, 4, 5], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 20\n assert candidate(hats = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 1024\n assert candidate(hats = [[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], [6, 7, 8, 9, 10]]) == 2108\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 10000\n assert candidate(hats = [[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]]) == 0\n assert candidate(hats = [[3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 9580\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n assert candidate(hats = [[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 28196\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 2193360\n assert candidate(hats = [[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]]) == 30240\n assert candidate(hats = [[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]]) == 10000\n assert candidate(hats = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 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, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 1712256\n assert candidate(hats = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 0\n assert candidate(hats = [[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]]) == 720\n assert candidate(hats = [[3, 5, 10], [3, 7, 11], [5, 9, 12], [8, 11, 15], [10, 13, 17]]) == 141\n assert candidate(hats = [[3, 4, 5, 6], [1, 2, 3, 4], [2, 3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9]]) == 315\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 11400\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 900\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 23, 25, 27, 29]]) == 3125\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 144400\n assert candidate(hats = [[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]]) == 596\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 243\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [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]]) == 473100\n assert candidate(hats = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [1, 3, 5], [5, 7, 9], [9, 11, 13], [13, 15, 17], [17, 19, 21]]) == 2723\n assert candidate(hats = [[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\n assert candidate(hats = [[1, 10, 19, 28, 37], [2, 11, 20, 29, 38], [3, 12, 21, 30, 39], [4, 13, 22, 31, 40], [5, 14, 23, 32], [6, 15, 24, 33], [7, 16, 25, 34], [8, 17, 26, 35], [9, 18, 27, 36]]) == 640000\n assert candidate(hats = [[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]]) == 120\n assert candidate(hats = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]) == 390625\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 1000\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 300\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 4, 7, 10], [2, 5, 8], [3, 6, 9]]) == 416\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 59049\n assert candidate(hats = [[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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 3628800\n assert candidate(hats = [[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], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 308055528\n assert candidate(hats = [[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]]) == 738\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 1560\n assert candidate(hats = [[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]]) == 720\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 3125\n assert candidate(hats = [[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]]) == 30240\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 880\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 400\n assert candidate(hats = [[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]]) == 40688\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 221\n assert candidate(hats = [[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]]) == 5766\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 7600\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]) == 390625\n assert candidate(hats = [[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]]) == 5040\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 1560\n assert candidate(hats = [[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]]) == 596\n", "comparison": "exact"}, "public_tests": ["[[3,4],[4,5],[5]]", "[[3,5,1],[3,5]]", "[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]"], "hints": ["Dynamic programming + bitmask.", "dp(peopleMask, idHat) number of ways to wear different hats given a bitmask (people visited) and used hats from 1 to idHat-1."], "metadata": {"canonical_parameter_names": ["hats"], "leetcode_dataset_entry_point": "Solution().numberWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:06+00:00", "tests_total": 83, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "bitmask", "bipartite-graph", "matching-graph", "perfect-matching"]}, "language": "python", "interface": {"raw_signature": "def numberWays(self, hats: list[list[int]]) -> int:", "container": "Solution", "callable": "numberWays", "parameters": [{"name": "hats", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1436, "task_id": "destination-city", "difficulty": "Easy", "problem_description": "You are given the array paths, where paths[i] = [cityA_i, cityB_i] means there exists a direct path going from cityA_i to cityB_i. Return the destination city, that is, the city without any path outgoing to another city.\n\nIt is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.\n\nExample 1:\n\nInput: paths = [[\"London\",\"New York\"],[\"New York\",\"Lima\"],[\"Lima\",\"Sao Paulo\"]]\nOutput: \"Sao Paulo\"\nExplanation: Starting at \"London\" city you will reach \"Sao Paulo\" city which is the destination city. Your trip consist of: \"London\" -> \"New York\" -> \"Lima\" -> \"Sao Paulo\".\n\nExample 2:\n\nInput: paths = [[\"B\",\"C\"],[\"D\",\"B\"],[\"C\",\"A\"]]\nOutput: \"A\"\nExplanation: All possible trips are:\n\"D\" -> \"B\" -> \"C\" -> \"A\".\n\"B\" -> \"C\" -> \"A\".\n\"C\" -> \"A\".\n\"A\".\nClearly the destination city is \"A\".\n\nExample 3:\n\nInput: paths = [[\"A\",\"Z\"]]\nOutput: \"Z\"\n\nConstraints:\n\n- 1 <= paths.length <= 100\n- paths[i].length == 2\n- 1 <= cityA_i.length, cityB_i.length <= 10\n- cityA_i != cityB_i\n- All strings consist of lowercase and uppercase English letters and the space character.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W']]) == \"W\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid'], ['Madrid', 'Rome']]) == \"Rome\"\n assert candidate(paths = [['B', 'C'], ['D', 'B'], ['C', 'A']]) == \"A\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid']]) == \"Madrid\"\n assert candidate(paths = [['A', 'Z']]) == \"Z\"\n assert candidate(paths = [['London', 'New York'], ['New York', 'Lima'], ['Lima', 'Sao Paulo']]) == \"Sao Paulo\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Beta', 'Gamma'], ['Gamma', 'Delta'], ['Delta', 'Epsilon'], ['Epsilon', 'Zeta'], ['Zeta', 'Eta']]) == \"Eta\"\n assert candidate(paths = [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E'], ['E', 'F'], ['F', 'G'], ['G', 'H'], ['H', 'I'], ['I', 'J'], ['J', 'K']]) == \"K\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Copenhagen'], ['Copenhagen', 'Stockholm'], ['Stockholm', 'Oslo'], ['Oslo', 'Trondheim']]) == \"Trondheim\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Gamma', 'Delta'], ['Delta', 'Epsilon'], ['Epsilon', 'Zeta'], ['Zeta', 'Eta'], ['Eta', 'Theta']]) == \"Beta\"\n assert candidate(paths = [['Mars', 'Venus'], ['Venus', 'Earth'], ['Earth', 'Mars2'], ['Mars2', 'Jupiter'], ['Jupiter', 'Saturn'], ['Saturn', 'Uranus'], ['Uranus', 'Neptune']]) == \"Neptune\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Munich'], ['Munich', 'Stuttgart'], ['Stuttgart', 'Frankfurt'], ['Frankfurt', 'Düsseldorf'], ['Düsseldorf', 'Cologne'], ['Cologne', 'Dortmund'], ['Dortmund', 'Wuppertal']]) == \"Wuppertal\"\n assert candidate(paths = [['Delhi', 'Agra'], ['Agra', 'Jaipur'], ['Jaipur', 'Jodhpur'], ['Jodhpur', 'Jaisalmer'], ['Jaisalmer', 'Bikaner'], ['Bikaner', 'Ajmer'], ['Ajmer', 'Udaipur'], ['Udaipur', 'Rajkot'], ['Rajkot', 'Surat']]) == \"Surat\"\n assert candidate(paths = [['Beijing', 'Tokyo'], ['Tokyo', 'Seoul'], ['Seoul', 'Osaka'], ['Osaka', 'Fukuoka'], ['Fukuoka', 'Nagoya'], ['Nagoya', 'Kyoto'], ['Kyoto', 'Sapporo']]) == \"Sapporo\"\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W'], ['W', 'V'], ['V', 'U'], ['U', 'T'], ['T', 'S'], ['S', 'R'], ['R', 'Q']]) == \"Q\"\n assert candidate(paths = [['Casablanca', 'Tangier'], ['Tangier', 'Fes'], ['Fes', 'Meknes'], ['Meknes', 'Fez'], ['Fez', 'Rabat'], ['Rabat', 'Agadir'], ['Agadir', 'Essaouira'], ['Essaouira', 'Marrakesh']]) == \"Marrakesh\"\n assert candidate(paths = [['Toronto', 'Ottawa'], ['Ottawa', 'Montreal'], ['Montreal', 'Quebec'], ['Quebec', 'Halifax'], ['Halifax', \"St. John's\"], [\"St. John's\", 'Gander']]) == \"Gander\"\n assert candidate(paths = [['Rome', 'Florence'], ['Florence', 'Venice'], ['Venice', 'Milan'], ['Milan', 'Turin'], ['Turin', 'Genoa'], ['Genoa', 'Pisa'], ['Pisa', 'Lyon']]) == \"Lyon\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Munich'], ['Munich', 'Frankfurt'], ['Frankfurt', 'Stuttgart'], ['Stuttgart', 'Dortmund'], ['Dortmund', 'Cologne']]) == \"Cologne\"\n assert candidate(paths = [['Oslo', 'Stockholm'], ['Stockholm', 'Helsinki'], ['Helsinki', 'Riga'], ['Riga', 'Vilnius'], ['Vilnius', 'Warsaw'], ['Warsaw', 'Krakow'], ['Krakow', 'Berlin'], ['Berlin', 'Hamburg']]) == \"Hamburg\"\n assert candidate(paths = [['Istanbul', 'Ankara'], ['Ankara', 'Eskisehir'], ['Eskisehir', 'Konya'], ['Konya', 'Gaziantep'], ['Gaziantep', 'Sanliurfa'], ['Sanliurfa', 'Mardin'], ['Mardin', 'Diyarbakir'], ['Diyarbakir', 'Siirt'], ['Siirt', 'Elazig'], ['Elazig', 'Malatya']]) == \"Malatya\"\n assert candidate(paths = [['Vienna', 'Innsbruck'], ['Innsbruck', 'Graz'], ['Graz', 'Linz'], ['Linz', 'Salzburg'], ['Salzburg', 'Wien'], ['Wien', 'Graz'], ['Graz', 'Ljubljana'], ['Ljubljana', 'Zagreb'], ['Zagreb', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Bucharest'], ['Bucharest', 'Bucuresti']]) == \"Bucuresti\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Nagoya'], ['Nagoya', 'Fukuoka'], ['Fukuoka', 'Sapporo']]) == \"Sapporo\"\n assert candidate(paths = [['New York', 'Boston'], ['Boston', 'Chicago'], ['Chicago', 'Houston'], ['Houston', 'Miami'], ['Miami', 'Orlando']]) == \"Orlando\"\n assert candidate(paths = [['Miami', 'Orlando'], ['Orlando', 'Atlanta'], ['Atlanta', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Las Vegas'], ['Las Vegas', 'Seattle']]) == \"Seattle\"\n assert candidate(paths = [['Hyderabad', 'Bangalore'], ['Bangalore', 'Mysuru'], ['Mysuru', 'Mangalore'], ['Mangalore', 'Udupi'], ['Udupi', 'Karwar']]) == \"Karwar\"\n assert candidate(paths = [['Mumbai', 'Delhi'], ['Delhi', 'Chennai'], ['Chennai', 'Bangalore'], ['Bangalore', 'Hyderabad'], ['Hyderabad', 'Ahmedabad'], ['Ahmedabad', 'Kolkata']]) == \"Kolkata\"\n assert candidate(paths = [['Vienna', 'Salzburg'], ['Salzburg', 'Innsbruck'], ['Innsbruck', 'Linz'], ['Linz', 'Graz'], ['Graz', 'Steyr'], ['Steyr', 'Klagenfurt']]) == \"Klagenfurt\"\n assert candidate(paths = [['M', 'N'], ['O', 'M'], ['P', 'O'], ['Q', 'P'], ['R', 'Q'], ['S', 'R'], ['T', 'S']]) == \"N\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Darwin']]) == \"Darwin\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Frankfurt'], ['Frankfurt', 'Munich'], ['Munich', 'Stuttgart'], ['Stuttgart', 'Zurich'], ['Zurich', 'Geneva'], ['Geneva', 'Lyon']]) == \"Lyon\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Darwin'], ['Darwin', 'Canberra']]) == \"Canberra\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Vienna'], ['Vienna', 'Budapest'], ['Budapest', 'Prague'], ['Prague', 'Warsaw'], ['Warsaw', 'Krakow']]) == \"Krakow\"\n assert candidate(paths = [['Vienna', 'Prague'], ['Prague', 'Bratislava'], ['Bratislava', 'Budapest'], ['Budapest', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Istanbul'], ['Istanbul', 'Athens'], ['Athens', 'Delhi'], ['Delhi', 'Mumbai']]) == \"Mumbai\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Gamma', 'Alpha'], ['Delta', 'Gamma'], ['Epsilon', 'Delta'], ['Zeta', 'Epsilon']]) == \"Beta\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Fukuoka'], ['Fukuoka', 'Sapporo'], ['Sapporo', 'Hokkaido'], ['Hokkaido', 'Nagoya'], ['Nagoya', 'Yokohama']]) == \"Yokohama\"\n assert candidate(paths = [['NodeA', 'NodeB'], ['NodeB', 'NodeC'], ['NodeC', 'NodeD'], ['NodeD', 'NodeE'], ['NodeE', 'NodeF'], ['NodeF', 'NodeG'], ['NodeG', 'NodeH'], ['NodeH', 'NodeI'], ['NodeI', 'NodeJ'], ['NodeJ', 'NodeK'], ['NodeK', 'NodeL'], ['NodeL', 'NodeM'], ['NodeM', 'NodeN'], ['NodeN', 'NodeO'], ['NodeO', 'NodeP'], ['NodeP', 'NodeQ'], ['NodeQ', 'NodeR'], ['NodeR', 'NodeS'], ['NodeS', 'NodeT']]) == \"NodeT\"\n assert candidate(paths = [['Oslo', 'Helsinki'], ['Helsinki', 'Stockholm'], ['Stockholm', 'Reykjavik'], ['Reykjavik', 'Vilnius'], ['Vilnius', 'Riga']]) == \"Riga\"\n assert candidate(paths = [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E'], ['E', 'F'], ['F', 'G'], ['G', 'H']]) == \"H\"\n assert candidate(paths = [['New Delhi', 'Bangalore'], ['Bangalore', 'Chennai'], ['Chennai', 'Hyderabad'], ['Hyderabad', 'Mumbai'], ['Mumbai', 'Pune'], ['Pune', 'Kochi'], ['Kochi', 'Trivandrum']]) == \"Trivandrum\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Nagoya'], ['Nagoya', 'Fukuoka'], ['Fukuoka', 'Sapporo'], ['Sapporo', 'Hokkaido']]) == \"Hokkaido\"\n assert candidate(paths = [['Cairo', 'Luxor'], ['Luxor', 'Aswan'], ['Aswan', 'Assiut'], ['Assiut', 'Ismailia'], ['Ismailia', 'Suez'], ['Suez', 'Port Said'], ['Port Said', 'Alexandria'], ['Alexandria', 'Damietta'], ['Damietta', 'Mansoura'], ['Mansoura', 'Tanta'], ['Tanta', 'Qena']]) == \"Qena\"\n", "comparison": "exact"}, "public_tests": ["[[\"London\",\"New York\"],[\"New York\",\"Lima\"],[\"Lima\",\"Sao Paulo\"]]", "[[\"B\",\"C\"],[\"D\",\"B\"],[\"C\",\"A\"]]", "[[\"A\",\"Z\"]]"], "hints": ["Start in any city and use the path to move to the next city.", "Eventually, you will reach a city with no path outgoing, this is the destination city."], "metadata": {"canonical_parameter_names": ["paths"], "leetcode_dataset_entry_point": "Solution().destCity", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:08+00:00", "tests_total": 74, "tests_dropped": 32, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def destCity(self, paths: list[list[str]]) -> str:", "container": "Solution", "callable": "destCity", "parameters": [{"name": "paths", "type": "list[list[str]]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1437, "task_id": "check-if-all-1s-are-at-least-length-k-places-away", "difficulty": "Easy", "problem_description": "Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.\n\nExample 1:\n\nInput: nums = [1,0,0,0,1,0,0,1], k = 2\nOutput: true\nExplanation: Each of the 1s are at least 2 places away from each other.\n\nExample 2:\n\nInput: nums = [1,0,0,1,0,1], k = 2\nOutput: false\nExplanation: The second 1 and third 1 are only one apart from each other.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= k <= nums.length\n- nums[i] is 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],k = 2) == True\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == True\n assert candidate(nums = [1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 1) == True\n assert candidate(nums = [1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 0) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 3) == True\n assert candidate(nums = [1, 1, 0, 1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 150) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == False\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 5) == True\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, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 4) == True\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, 1],k = 20) == True\n assert candidate(nums = [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],k = 1) == False\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 70) == True\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],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\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],k = 10) == True\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],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\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],k = 15) == True\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],k = 15) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 1],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],k = 10) == True\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 100) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 3) == True\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, 1],k = 20) == True\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],k = 20) == True\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, 0, 0, 0, 0, 0, 0, 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 = 60) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3) == True\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],k = 3) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 5) == False\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],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 10) == False\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == True\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) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 0) == True\n assert candidate(nums = [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, 1],k = 1) == False\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [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 = 4) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [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],k = 10) == True\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 30) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 1, 0, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 4) == False\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == True\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],k = 2) == 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, 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],k = 10) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 6) == True\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, 0, 0, 0, 0, 0, 0, 1],k = 40) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\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],k = 19) == True\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 50) == True\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],k = 9) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1],k = 2) == False\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, 1],k = 5) == True\n assert candidate(nums = [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],k = 7) == 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, 1],k = 20) == True\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, 1],k = 30) == 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = 0) == 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],k = 10) == True\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, 1],k = 25) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 2) == True\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, 1],k = 10) == True\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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == False\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],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 2) == True\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, 1],k = 10) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\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, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == False\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 9) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 18) == True\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 2) == True\n", "comparison": "exact"}, "public_tests": ["[1,0,0,0,1,0,0,1]\n2", "[1,0,0,1,0,1]\n2"], "hints": ["Each time you find a number 1, check whether or not it is K or more places away from the next one. If it's not, return false."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kLengthApart", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:10+00:00", "tests_total": 104, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def kLengthApart(self, nums: list[int], k: int) -> bool:", "container": "Solution", "callable": "kLengthApart", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1438, "task_id": "longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit", "difficulty": "Medium", "problem_description": "Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.\n\nExample 1:\n\nInput: nums = [8,2,4,7], limit = 4\nOutput: 2\nExplanation: All subarrays are:\n[8] with maximum absolute diff |8-8| = 0 <= 4.\n[8,2] with maximum absolute diff |8-2| = 6 > 4.\n[8,2,4] with maximum absolute diff |8-2| = 6 > 4.\n[8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.\n[2] with maximum absolute diff |2-2| = 0 <= 4.\n[2,4] with maximum absolute diff |2-4| = 2 <= 4.\n[2,4,7] with maximum absolute diff |2-7| = 5 > 4.\n[4] with maximum absolute diff |4-4| = 0 <= 4.\n[4,7] with maximum absolute diff |4-7| = 3 <= 4.\n[7] with maximum absolute diff |7-7| = 0 <= 4.\nTherefore, the size of the longest subarray is 2.\n\nExample 2:\n\nInput: nums = [10,1,2,4,7,2], limit = 5\nOutput: 4\nExplanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.\n\nExample 3:\n\nInput: nums = [4,2,2,2,4,4,2,2], limit = 0\nOutput: 3\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n- 0 <= limit <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [100, 101, 102, 103, 104],limit = 3) == 4\n assert candidate(nums = [4, 2, 2, 2, 4, 4, 2, 2],limit = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [1, 2],limit = 1) == 2\n assert candidate(nums = [1],limit = 1) == 1\n assert candidate(nums = [1, 3, 6, 8, 10, 15],limit = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],limit = 0) == 7\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 4) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 10],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 9) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 0) == 5\n assert candidate(nums = [10, 1, 2, 4, 7, 2],limit = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 0) == 1\n assert candidate(nums = [8, 2, 4, 7],limit = 4) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2) == 3\n assert candidate(nums = [1, 5, 6, 7, 8, 10, 6, 5, 6],limit = 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, 21, 22, 23, 24, 25],limit = 3) == 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, 11, 11, 12, 12, 13, 13, 14, 14],limit = 4) == 10\n assert candidate(nums = [5, 1, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 6\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],limit = 2) == 5\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],limit = 3) == 4\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1],limit = 99) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 5) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],limit = 2) == 6\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],limit = 2) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 5) == 10\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5],limit = 1) == 6\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],limit = 2) == 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],limit = 2) == 6\n assert candidate(nums = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 4) == 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],limit = 15) == 16\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],limit = 50) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],limit = 20) == 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],limit = 3) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 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],limit = 5) == 6\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 10\n assert candidate(nums = [8, 2, 4, 7, 1, 3, 6, 5, 9, 11, 10],limit = 4) == 3\n assert candidate(nums = [25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 6) == 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],limit = 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],limit = 4) == 5\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 12\n assert candidate(nums = [10, 1, 2, 4, 7, 2, 9, 3, 5, 6],limit = 5) == 4\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 2) == 2\n assert candidate(nums = [5, 8, 8, 8, 8, 5, 5, 5, 5, 8, 8, 8, 5, 5],limit = 3) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 0) == 1\n assert candidate(nums = [10, 10, 10, 10, 1, 1, 1, 1, 10, 10, 10, 10, 1, 1, 1, 1],limit = 9) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 1) == 2\n assert candidate(nums = [5, 1, 3, 5, 9, 11, 9, 7, 5, 3, 1],limit = 2) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],limit = 1000000000) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 8) == 5\n assert candidate(nums = [5, 9, 1, 3, 7, 6, 2, 8, 4, 10],limit = 3) == 2\n assert candidate(nums = [10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2],limit = 5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 10) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],limit = 10) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 12\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 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],limit = 0) == 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],limit = 1) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 5) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 15\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],limit = 0) == 15\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50) == 6\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 4) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],limit = 100) == 2\n assert candidate(nums = [7, 7, 7, 1, 1, 1, 7, 7, 7, 1, 1, 1, 7, 7, 7],limit = 6) == 15\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],limit = 3) == 8\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 10) == 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],limit = 10) == 6\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],limit = 0) == 10\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999],limit = 1) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],limit = 100) == 2\n assert candidate(nums = [100, 100, 100, 100, 101, 102, 103, 104, 105],limit = 5) == 9\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14],limit = 5) == 6\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 7) == 8\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 18\n assert candidate(nums = [8, 6, 5, 7, 2, 3, 10, 12, 15, 1],limit = 5) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],limit = 4) == 3\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],limit = 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],limit = 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 0) == 30\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],limit = 100) == 2\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 4) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 10\n assert candidate(nums = [8, 2, 4, 7, 10, 15, 1, 3, 6, 9],limit = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 4) == 5\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],limit = 3) == 10\n assert candidate(nums = [2, 3, 1, 1, 5, 7, 5, 10, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],limit = 5) == 13\n assert candidate(nums = [1, 3, 3, 1, 2, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1],limit = 2) == 20\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 1) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],limit = 6) == 4\n assert candidate(nums = [5, 2, 3, 4, 1, 5, 2],limit = 3) == 4\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],limit = 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 2) == 3\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],limit = 1) == 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],limit = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 5) == 6\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],limit = 1) == 9\n assert candidate(nums = [10, 15, 10, 20, 15, 10, 25, 30, 25],limit = 5) == 3\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],limit = 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],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],limit = 2) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 4) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],limit = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 1) == 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],limit = 1) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 3) == 10\n assert candidate(nums = [100, 1, 2, 3, 4, 100, 2, 3, 4, 100],limit = 99) == 10\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 6) == 4\n assert candidate(nums = [1, 2, 3, 1, 5, 6, 7, 8, 9, 10],limit = 2) == 4\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],limit = 2) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],limit = 1) == 10\n assert candidate(nums = [1, 3, 6, 8, 9, 10, 12, 15],limit = 3) == 3\n assert candidate(nums = [5, 4, 3, 2, 1],limit = 4) == 5\n assert candidate(nums = [1, 2, 3, 1, 5],limit = 2) == 4\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4],limit = 3) == 1\n assert candidate(nums = [1000000000, 1, 1000000000, 1],limit = 1) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5],limit = 0) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 100, 101],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == 4\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 0) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 10) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 5) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10, 10, 10],limit = 2) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == 2\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],limit = 1) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 15) == 2\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13],limit = 4) == 6\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5],limit = 100) == 4\n assert candidate(nums = [1000000000, 1000000000, 1000000000],limit = 0) == 3\n assert candidate(nums = [1],limit = 10) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 0) == 1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],limit = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],limit = 2) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10],limit = 4) == 6\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 9],limit = 2) == 3\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000],limit = 1000000000) == 11\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 4) == 4\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 5) == 4\n assert candidate(nums = [1, 2, 3],limit = 10) == 3\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 2) == 2\n assert candidate(nums = [1, 5, 6, 7, 8, 10],limit = 4) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == 3\n assert candidate(nums = [1, 3, 6, 8, 10],limit = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 1) == 2\n assert candidate(nums = [1, 3, 6, 8, 10, 15],limit = 5) == 3\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 10) == 10\n assert candidate(nums = [1, 3, 6, 2, 7, 8, 4, 5, 9],limit = 3) == 2\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],limit = 3) == 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],limit = 0) == 20\n assert candidate(nums = [1],limit = 0) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 9\n", "comparison": "exact"}, "public_tests": ["[8,2,4,7]\n4", "[10,1,2,4,7,2]\n5", "[4,2,2,2,4,4,2,2]\n0"], "hints": ["Use a sliding window approach keeping the maximum and minimum value using a data structure like a multiset from STL in C++.", "More specifically, use the two pointer technique, moving the right pointer as far as possible to the right until the subarray is not valid (maxValue - minValue > limit), then moving the left pointer until the subarray is valid again (maxValue - minValue <= limit). Keep repeating this process."], "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:13+00:00", "tests_total": 184, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "queue", "sliding-window", "heap-priority-queue", "ordered-set", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def longestSubarray(self, nums: list[int], limit: int) -> int:", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1439, "task_id": "find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows", "difficulty": "Hard", "problem_description": "You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.\n\nYou are allowed to choose exactly one element from each row to form an array.\n\nReturn the k^th smallest array sum among all possible arrays.\n\nExample 1:\n\nInput: mat = [[1,3,11],[2,4,6]], k = 5\nOutput: 7\nExplanation: Choosing one element from each row, the first k smallest sum are:\n[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.\n\nExample 2:\n\nInput: mat = [[1,3,11],[2,4,6]], k = 9\nOutput: 17\n\nExample 3:\n\nInput: mat = [[1,10,10],[1,4,5],[2,3,6]], k = 7\nOutput: 9\nExplanation: Choosing one element from each row, the first k smallest sum are:\n[1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.\n\nConstraints:\n\n- m == mat.length\n- n == mat.length[i]\n- 1 <= m, n <= 40\n- 1 <= mat[i][j] <= 5000\n- 1 <= k <= min(200, n^m)\n- mat[i] is a non-decreasing array.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 10, 10], [1, 4, 5], [2, 3, 6]],k = 7) == 9\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 9) == 9\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 5) == 7\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 9) == 17\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 1) == 5\n assert candidate(mat = [[1, 5, 9], [10, 11, 13], [12, 13, 15]],k = 8) == 27\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]],k = 100) == 69\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 100) == 4\n assert candidate(mat = [[1, 7, 10, 15], [2, 8, 12, 16], [3, 9, 13, 17], [4, 10, 14, 18]],k = 15) == 22\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],k = 100) == 68\n assert candidate(mat = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]],k = 160) == 15\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]],k = 180) == 42\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]],k = 200) == 24\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 100) == 33\n assert candidate(mat = [[500, 1000, 1500], [550, 1050, 1550], [600, 1100, 1600], [650, 1150, 1650]],k = 10) == 3300\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 = 200) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 11, 12, 13, 14], [20, 21, 22, 23, 24], [30, 31, 32, 33, 34]],k = 50) == 65\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],k = 100) == 22\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45], [30, 40, 50]],k = 50) == 130\n assert candidate(mat = [[5, 10, 15], [6, 11, 16], [7, 12, 17], [8, 13, 18]],k = 25) == 41\n assert candidate(mat = [[5, 10, 15, 20, 25], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],k = 100) == 32\n assert candidate(mat = [[100, 200, 300, 400, 500], [101, 201, 301, 401, 501], [102, 202, 302, 402, 502], [103, 203, 303, 403, 503]],k = 20) == 706\n assert candidate(mat = [[1, 100, 200], [5, 150, 250], [9, 190, 290], [13, 230, 330]],k = 80) == 970\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14]],k = 50) == 18\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 150) == 27\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46]],k = 50) == 62\n assert candidate(mat = [[5, 8, 12, 18], [1, 3, 7, 11], [2, 4, 6, 10], [9, 13, 15, 17]],k = 100) == 33\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 = 250) == 61\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]],k = 50) == 35\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 = 150) == 46\n assert candidate(mat = [[1, 5, 9, 12], [2, 6, 10, 13], [3, 7, 11, 14], [4, 8, 15, 16]],k = 15) == 21\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],k = 15) == 90\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], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]],k = 150) == 16\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 30) == 25\n assert candidate(mat = [[5, 9, 14], [4, 12, 18], [2, 8, 10], [1, 3, 6]],k = 25) == 26\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 = 50) == 102\n assert candidate(mat = [[100, 200, 300, 400, 500], [50, 100, 150, 200, 250], [25, 50, 75, 100, 125], [1, 2, 3, 4, 5]],k = 80) == 328\n assert candidate(mat = [[10, 20, 30, 40, 50], [11, 22, 33, 44, 55], [12, 24, 36, 48, 60], [13, 26, 39, 52, 65]],k = 100) == 104\n assert candidate(mat = [[500, 1000, 1500], [100, 200, 300], [250, 500, 750], [50, 100, 150], [200, 400, 600]],k = 60) == 1800\n assert candidate(mat = [[1, 10, 100], [1, 4, 50], [2, 3, 60]],k = 20) == 107\n assert candidate(mat = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]],k = 175) == 76\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40]],k = 30) == 74\n assert candidate(mat = [[2, 6, 10, 14], [1, 5, 9, 13], [3, 7, 11, 15], [4, 8, 12, 16]],k = 15) == 18\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 50) == 4\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 = 50) == 38\n assert candidate(mat = [[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 = 300) == 11\n assert candidate(mat = [[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 = 199) == 10\n assert candidate(mat = [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]],k = 20) == 5\n assert candidate(mat = [[1, 1000, 5000], [500, 2000, 4000], [100, 3000, 4500], [200, 2500, 3500]],k = 100) == 17000\n assert candidate(mat = [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16], [5, 9, 13, 17]],k = 200) == 35\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 120) == 16\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16]],k = 70) == 18\n assert candidate(mat = [[1000, 2000, 3000, 4000], [500, 1500, 2500, 3500], [100, 1100, 2100, 3100], [50, 1050, 2050, 3050]],k = 10) == 3650\n assert candidate(mat = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500]],k = 18) == 2100\n assert candidate(mat = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]],k = 60) == 27\n assert candidate(mat = [[100, 200, 300], [50, 150, 250], [10, 110, 210], [5, 105, 205], [1, 101, 201]],k = 80) == 566\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 = 125) == 15\n assert candidate(mat = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]],k = 10) == 8\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27], [29, 31, 33, 35, 37, 39, 41]],k = 180) == 59\n assert candidate(mat = [[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 = 150) == 11\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]],k = 120) == 69\n assert candidate(mat = [[1, 7, 12, 22], [5, 8, 9, 13], [6, 12, 15, 18]],k = 15) == 24\n assert candidate(mat = [[3, 6, 9, 12], [2, 5, 8, 11], [1, 4, 7, 10]],k = 24) == 18\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 60) == 39\n assert candidate(mat = [[5, 10, 15, 20, 25], [6, 11, 16, 21, 26], [7, 12, 17, 22, 27], [8, 13, 18, 23, 28], [9, 14, 19, 24, 29]],k = 50) == 50\n assert candidate(mat = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],k = 150) == 34\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 120) == 40\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],k = 60) == 20\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 100) == 55\n assert candidate(mat = [[1, 100, 500, 1000], [2, 200, 600, 1100], [3, 300, 700, 1200], [4, 400, 800, 1300]],k = 120) == 1904\n assert candidate(mat = [[10, 20, 30, 40], [11, 22, 33, 44], [12, 24, 36, 48], [13, 26, 39, 52]],k = 150) == 121\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 = 150) == 60\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 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 = 32) == 30\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13]],k = 50) == 20\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 = 100) == 59\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14, 16], [3, 5, 7, 9, 11, 13, 15, 17], [4, 6, 8, 10, 12, 14, 16, 18]],k = 100) == 20\n assert candidate(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, 21]],k = 50) == 30\n assert candidate(mat = [[1, 100, 200, 300, 400], [2, 200, 300, 400, 500], [3, 300, 400, 500, 600], [4, 400, 500, 600, 700], [5, 500, 600, 700, 800]],k = 150) == 910\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 = 200) == 41\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]],k = 100) == 5\n assert candidate(mat = [[1, 100, 1000], [2, 200, 2000], [3, 300, 3000]],k = 20) == 3201\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]],k = 200) == 42\n", "comparison": "exact"}, "public_tests": ["[[1,3,11],[2,4,6]]\n5", "[[1,3,11],[2,4,6]]\n9", "[[1,10,10],[1,4,5],[2,3,6]]\n7"], "hints": ["Save all visited sums and corresponding indexes in a priority queue. Then, once you pop the smallest sum so far, you can quickly identify the next m candidates for smallest sum by incrementing each row index by 1."], "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:15+00:00", "tests_total": 85, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search", "heap-priority-queue", "matrix"]}, "language": "python", "interface": {"raw_signature": "def kthSmallest(self, mat: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "kthSmallest", "parameters": [{"name": "mat", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1441, "task_id": "build-an-array-with-stack-operations", "difficulty": "Medium", "problem_description": "You are given an integer array target and an integer n.\n\nYou have an empty stack with the two following operations:\n\n- \"Push\": pushes an integer to the top of the stack.\n- \"Pop\": removes the integer on the top of the stack.\n\nYou also have a stream of the integers in the range [1, n].\n\nUse the two stack operations to make the numbers in the stack (from the bottom to the top) equal to target. You should follow the following rules:\n\n- If the stream of the integers is not empty, pick the next integer from the stream and push it to the top of the stack.\n- If the stack is not empty, pop the integer at the top of the stack.\n- If, at any moment, the elements in the stack (from the bottom to the top) are equal to target, do not read new integers from the stream and do not do more operations on the stack.\n\nReturn the stack operations needed to build target following the mentioned rules. If there are multiple valid answers, return any of them.\n\nExample 1:\n\nInput: target = [1,3], n = 3\nOutput: [\"Push\",\"Push\",\"Pop\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nPop the integer on the top of the stack. s = [1].\nRead 3 from the stream and push it to the stack. s = [1,3].\n\nExample 2:\n\nInput: target = [1,2,3], n = 3\nOutput: [\"Push\",\"Push\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nRead 3 from the stream and push it to the stack. s = [1,2,3].\n\nExample 3:\n\nInput: target = [1,2], n = 4\nOutput: [\"Push\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nSince the stack (from the bottom to the top) is equal to target, we stop the stack operations.\nThe answers that read integer 3 from the stream are not accepted.\n\nConstraints:\n\n- 1 <= target.length <= 100\n- 1 <= n <= 100\n- 1 <= target[i] <= n\n- target is strictly increasing.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [3, 4, 5],n = 5) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 4, 6],n = 7) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 9],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2],n = 4) == ['Push', 'Push']\n assert candidate(target = [1, 2, 3, 4, 5],n = 5) == ['Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [2, 3, 5],n = 5) == ['Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 3, 4],n = 5) == ['Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [2, 4, 6, 8],n = 10) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 3, 4],n = 4) == ['Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [1],n = 1) == ['Push']\n assert candidate(target = [1, 2, 3],n = 3) == ['Push', 'Push', 'Push']\n assert candidate(target = [4, 5, 6],n = 6) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 3, 5],n = 5) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 6, 7, 8],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 3],n = 3) == ['Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6],n = 7) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 7, 10],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 6, 7, 8, 9, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 4, 6, 9],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 9, 13, 17, 21],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 8, 16],n = 20) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 5, 7, 8, 10],n = 12) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 9, 11, 13, 15],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 8, 16, 32, 64],n = 100) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 8, 10, 12, 14],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 8, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15],n = 20) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 7, 9],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11, 13, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13, 16, 19, 22, 25],n = 30) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 8, 11, 14],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 7, 11, 15, 19, 23, 27, 31, 35],n = 40) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 7, 10, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [10, 12, 15, 19, 20],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [3, 5, 7, 9, 11, 13, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 10, 15, 20, 25, 30],n = 30) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 10, 15, 20, 25, 30, 35],n = 40) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 7, 10, 13, 16, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 8, 9, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 7, 9, 10],n = 10) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 5, 6, 8, 11, 12],n = 15) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 7, 9, 10],n = 10) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 2, 5, 7, 11, 13],n = 20) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 55) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 8],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 11, 13, 17, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12],n = 15) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 25) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28, 35, 42],n = 42) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13],n = 13) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 9, 13, 17, 21],n = 25) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11, 13],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 7, 11, 15, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17, 20],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 9, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [3, 6, 8, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 12, 18, 24, 30],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 4, 7, 10, 12],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 7, 10, 13],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17, 20],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 15, 20, 25],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 12, 14],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 8, 10, 12],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 6, 8, 10],n = 12) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],n = 15) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [11, 22, 33, 44, 55, 66, 77, 88, 99],n = 100) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9, 10],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [5, 7, 9, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9, 11],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 8, 10],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 8, 12, 16, 20, 24, 28],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 7, 8, 10, 12, 14, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 9, 13, 17],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18, 22, 26],n = 30) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 11, 12],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n", "comparison": "exact"}, "public_tests": ["[1,3]\n3", "[1,2,3]\n3", "[1,2]\n4"], "hints": ["Use “Push” for numbers to be kept in target array and [“Push”, “Pop”] for numbers to be discarded."], "metadata": {"canonical_parameter_names": ["target", "n"], "leetcode_dataset_entry_point": "Solution().buildArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:17+00:00", "tests_total": 113, "tests_dropped": 1, "flags": ["multiple_answers"], "topic_tags": ["array", "stack", "simulation"]}, "language": "python", "interface": {"raw_signature": "def buildArray(self, target: list[int], n: int) -> list[str]:", "container": "Solution", "callable": "buildArray", "parameters": [{"name": "target", "type": "list[int]"}, {"name": "n", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1442, "task_id": "count-triplets-that-can-form-two-arrays-of-equal-xor", "difficulty": "Medium", "problem_description": "Given an array of integers arr.\n\nWe want to select three indices i, j and k where (0 <= i < j <= k < arr.length).\n\nLet's define a and b as follows:\n\n- a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]\n- b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]\n\nNote that ^ denotes the bitwise-xor operation.\n\nReturn the number of triplets (i, j and k) Where a == b.\n\nExample 1:\n\nInput: arr = [2,3,1,6,7]\nOutput: 4\nExplanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4)\n\nExample 2:\n\nInput: arr = [1,1,1,1,1]\nOutput: 10\n\nConstraints:\n\n- 1 <= arr.length <= 300\n- 1 <= arr[i] <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 17\n assert candidate(arr = [5, 5, 5, 5, 5, 5]) == 19\n assert candidate(arr = [8, 12, 3, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 24\n assert candidate(arr = [3, 3, 3, 3, 3, 3]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [2, 3, 1, 6, 7]) == 4\n assert candidate(arr = [2, 3, 4, 5, 6, 7]) == 6\n assert candidate(arr = [8, 1, 6, 2, 1]) == 0\n assert candidate(arr = [5, 1, 4, 1, 5]) == 4\n assert candidate(arr = [1, 1, 1, 1, 1]) == 10\n assert candidate(arr = [7, 11, 1, 2, 9, 5]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 285\n assert candidate(arr = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 10\n assert candidate(arr = [15, 3, 9, 7, 11, 6, 2, 8, 14, 5]) == 8\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(arr = [7, 5, 3, 2, 6, 8, 4, 3, 5, 2, 9, 1, 5]) == 21\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 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]) == 245\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 47\n assert candidate(arr = [29, 17, 23, 29, 17, 23, 29, 17, 23, 29, 17, 23, 29]) == 62\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]) == 2255\n assert candidate(arr = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 41\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 62790\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == 0\n assert candidate(arr = [2, 5, 3, 2, 1, 4, 7, 8, 9, 6]) == 8\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, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2870\n assert candidate(arr = [15, 13, 14, 11, 8, 7, 5, 2, 3, 4]) == 19\n assert candidate(arr = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000]) == 0\n assert candidate(arr = [23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 0\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1]) == 97\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 100\n assert candidate(arr = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 10, 20]) == 0\n assert candidate(arr = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 2736\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 0\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200]) == 15\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]) == 2255\n assert candidate(arr = [10, 15, 3, 7, 8, 5, 2, 1]) == 0\n assert candidate(arr = [1, 3, 2, 3, 1, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15]) == 97\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 25\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]) == 2736\n assert candidate(arr = [13, 17, 11, 14, 13, 14, 12, 11, 17, 13, 15, 16, 18, 14, 12, 15]) == 11\n assert candidate(arr = [12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 54\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 390\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 100\n assert candidate(arr = [15, 9, 8, 3, 6, 1, 1, 1, 1, 2]) == 6\n assert candidate(arr = [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]) == 2255\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 670\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]) == 1156\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445, 464748, 495051, 525354, 555657, 585960, 616263, 646566, 676869, 707172, 737475, 767778, 798081, 828384, 858687, 888990, 919293]) == 0\n assert candidate(arr = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 344\n assert candidate(arr = [23, 35, 47, 59, 71, 83, 95, 107, 119, 131, 143, 155, 167, 179, 191]) == 13\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 385\n assert candidate(arr = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 104\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(arr = [99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [100000000, 99999999, 100000000, 99999999, 100000000, 99999999, 100000000]) == 12\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 8\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606]) == 0\n assert candidate(arr = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 110\n assert candidate(arr = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 384\n assert candidate(arr = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 19\n assert candidate(arr = [101, 203, 307, 409, 511, 613, 719, 821, 923, 1027, 1131, 1237, 1349, 1451, 1553, 1657, 1763, 1867, 1979, 2083]) == 0\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 3\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1127\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 670\n assert candidate(arr = [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 136\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 0\n assert candidate(arr = [17, 17, 34, 34, 68, 68, 136, 136, 272, 272, 544, 544]) == 91\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == 0\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 5\n", "comparison": "exact"}, "public_tests": ["[2,3,1,6,7]", "[1,1,1,1,1]"], "hints": ["We are searching for sub-array of length ≥ 2 and we need to split it to 2 non-empty arrays so that the xor of the first array is equal to the xor of the second array. This is equivalent to searching for sub-array with xor = 0.", "Keep the prefix xor of arr in another array, check the xor of all sub-arrays in O(n^2), if the xor of sub-array of length x is 0 add x-1 to the answer."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().countTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:19+00:00", "tests_total": 93, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "hash-table", "math", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def countTriplets(self, arr: list[int]) -> int:", "container": "Solution", "callable": "countTriplets", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1444, "task_id": "number-of-ways-of-cutting-a-pizza", "difficulty": "Hard", "problem_description": "Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to cut the pizza into k pieces using k-1 cuts.\n\nFor each cut you choose the direction: vertical or horizontal, then you choose a cut position at the cell boundary and cut the pizza into two pieces. If you cut the pizza vertically, give the left part of the pizza to a person. If you cut the pizza horizontally, give the upper part of the pizza to a person. Give the last piece of pizza to the last person.\n\nReturn the number of ways of cutting the pizza such that each piece contains at least one apple. Since the answer can be a huge number, return this modulo 10^9 + 7.\n\nExample 1:\n\nInput: pizza = [\"A..\",\"AAA\",\"...\"], k = 3\nOutput: 3\nExplanation: The figure above shows the three ways to cut the pizza. Note that pieces must contain at least one apple.\n\nExample 2:\n\nInput: pizza = [\"A..\",\"AA.\",\"...\"], k = 3\nOutput: 1\n\nExample 3:\n\nInput: pizza = [\"A..\",\"A..\",\"...\"], k = 1\nOutput: 1\n\nConstraints:\n\n- 1 <= rows, cols <= 50\n- rows == pizza.length\n- cols == pizza[i].length\n- 1 <= k <= 10\n- pizza consists of characters 'A' and '.' only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pizza = ['A', 'A', 'A'],k = 3) == 1\n assert candidate(pizza = ['AA', 'AA'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 4) == 6\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 5) == 0\n assert candidate(pizza = ['...', '...', '...', '...', '...', '...', 'AAA'],k = 4) == 0\n assert candidate(pizza = ['AAA', '...', 'AAA'],k = 2) == 4\n assert candidate(pizza = ['A..', 'A..', '...'],k = 1) == 1\n assert candidate(pizza = ['AAA', 'AAA', 'AAA'],k = 4) == 12\n assert candidate(pizza = ['AA.', 'AA.', '..A'],k = 2) == 4\n assert candidate(pizza = ['AAA', 'AAA', 'AAA'],k = 2) == 4\n assert candidate(pizza = ['A..', 'AA.', '...'],k = 3) == 1\n assert candidate(pizza = ['A.A', '.A.', 'A.A'],k = 2) == 4\n assert candidate(pizza = ['A..', 'A..'],k = 2) == 1\n assert candidate(pizza = ['A.A', 'A.A'],k = 2) == 3\n assert candidate(pizza = ['...', '...', '...'],k = 1) == 0\n assert candidate(pizza = ['A..', 'AAA', '...'],k = 3) == 3\n assert candidate(pizza = ['AAAAA', 'AA.AA', 'AA.AA', 'AA.AA', 'AAAAA'],k = 5) == 346\n assert candidate(pizza = ['AAAA', 'A.AA', 'AA.A', 'AAAA'],k = 4) == 56\n assert candidate(pizza = ['A.A.A', 'A....', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 3) == 9\n assert candidate(pizza = ['A...A', '.....', 'A...A', '.....', 'A...A'],k = 3) == 36\n assert candidate(pizza = ['...A', '...A', '...A'],k = 2) == 2\n assert candidate(pizza = ['A...', '....', '....', 'A...'],k = 2) == 3\n assert candidate(pizza = ['A...A', '.A.A.', 'A...A', '.A.A.', 'A...A'],k = 5) == 198\n assert candidate(pizza = ['A.A', '.A.', 'A.A'],k = 3) == 10\n assert candidate(pizza = ['A.A', '.A.', 'A.A', '.A.', 'A.A'],k = 3) == 23\n assert candidate(pizza = ['A..A.', 'A..A.', 'A..A.', 'A..A.', 'A..A.'],k = 3) == 30\n assert candidate(pizza = ['AAAAAA', 'A...A.', 'A...A.', 'A...A.', 'AAAAAA'],k = 4) == 212\n assert candidate(pizza = ['AAAAA', '.....', 'AAAAA', '.....', 'AAAAA'],k = 3) == 42\n assert candidate(pizza = ['A...A', '.....', '.....', 'A...A'],k = 3) == 24\n assert candidate(pizza = ['A.A.A.A.A', '.A.A.A.A.', 'A.A.A.A.A', '.A.A.A.A.', 'A.A.A.A.A'],k = 5) == 1955\n assert candidate(pizza = ['AAAA', 'AAAA', 'AAAA', 'AAAA'],k = 5) == 78\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A'],k = 2) == 6\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A.A.A.A', 'A.A.A.A', 'A.A.A.A'],k = 4) == 98\n assert candidate(pizza = ['AAAA', 'AAAA', 'AAAA'],k = 3) == 16\n assert candidate(pizza = ['A', 'A', 'A', 'A', 'A'],k = 3) == 6\n assert candidate(pizza = ['A..', '...', 'A..', '...', 'A..'],k = 3) == 4\n assert candidate(pizza = ['AA.AA', 'A...A', 'A...A', 'AA.AA'],k = 3) == 32\n assert candidate(pizza = ['A.....A', 'A.....A', 'A.....A', 'A.....A', 'A.....A'],k = 2) == 10\n assert candidate(pizza = ['AA.', 'A..', '.AA'],k = 2) == 4\n assert candidate(pizza = ['A.A.A', 'A...A', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A....A', '......', '......', 'A....A'],k = 4) == 0\n assert candidate(pizza = ['AAA..', 'AAA..', 'AAA..'],k = 3) == 10\n assert candidate(pizza = ['...A', '...A', 'A...', 'A...'],k = 2) == 6\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A', 'A.A.A', 'A.A.A'],k = 4) == 124\n assert candidate(pizza = ['A....', '.....', '.....', '.....', 'A....'],k = 2) == 4\n assert candidate(pizza = ['A...', '.A..', '..A.', '...A'],k = 4) == 8\n assert candidate(pizza = ['.A.A.', 'A.A.A', '.A.A.', 'A.A.A', '.A.A.'],k = 6) == 256\n assert candidate(pizza = ['AAAAA', 'A...A', 'A...A', 'A...A', 'AAAAA'],k = 5) == 346\n assert candidate(pizza = ['A....', '.....', '.....', '.....', '.....'],k = 4) == 0\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A'],k = 3) == 40\n assert candidate(pizza = ['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'],k = 8) == 15387\n assert candidate(pizza = ['A...', '.A.A', '....', 'A...'],k = 2) == 6\n assert candidate(pizza = ['........', '...A....', '........', '........', '........', '........', '........', '........'],k = 2) == 0\n assert candidate(pizza = ['.A..A.', 'A..A..', '.A..A.', 'A..A..', '.A..A.'],k = 3) == 42\n assert candidate(pizza = ['A..A', '....', 'A..A', '....'],k = 3) == 12\n assert candidate(pizza = ['A.A.A', '.A.A.', 'A.A.A'],k = 3) == 23\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.'],k = 3) == 51\n assert candidate(pizza = ['AAAAA', 'A...A', 'A...A', 'A...A', 'AAAAA'],k = 4) == 152\n assert candidate(pizza = ['A......', 'A......', 'A......', '.......', '.......', '.......'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A', 'A.A', 'A.A'],k = 4) == 40\n assert candidate(pizza = ['A.A.A', 'A...A', 'A...A', 'A...A', 'A.A.A'],k = 5) == 209\n assert candidate(pizza = ['AAAAA', 'AAAAA', '.....', '.....', '.....'],k = 3) == 14\n assert candidate(pizza = ['A.A.A', '.A.A.', 'A.A.A'],k = 4) == 46\n assert candidate(pizza = ['A.A.A', '.....', 'A.A.A', '.....', 'A.A.A'],k = 5) == 96\n assert candidate(pizza = ['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.'],k = 6) == 8692\n assert candidate(pizza = ['A.A..', '.A.A.', '..A.A'],k = 3) == 17\n assert candidate(pizza = ['A....', '.A...', '..A..'],k = 3) == 4\n assert candidate(pizza = ['A....', '..A..', '....A', '.....', '.....'],k = 4) == 0\n", "comparison": "exact"}, "public_tests": ["[\"A..\",\"AAA\",\"...\"]\n3", "[\"A..\",\"AA.\",\"...\"]\n3", "[\"A..\",\"A..\",\"...\"]\n1"], "hints": ["Note that after each cut the remaining piece of pizza always has the lower right coordinate at (rows-1,cols-1).", "Use dynamic programming approach with states (row1, col1, c) which computes the number of ways of cutting the pizza using \"c\" cuts where the current piece of pizza has upper left coordinate at (row1,col1) and lower right coordinate at (rows-1,cols-1).", "For the transitions try all vertical and horizontal cuts such that the piece of pizza you have to give a person must contain at least one apple. The base case is when c=k-1.", "Additionally use a 2D dynamic programming to respond in O(1) if a piece of pizza contains at least one apple."], "metadata": {"canonical_parameter_names": ["pizza", "k"], "leetcode_dataset_entry_point": "Solution().ways", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:21+00:00", "tests_total": 72, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "memoization", "matrix", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def ways(self, pizza: list[str], k: int) -> int:", "container": "Solution", "callable": "ways", "parameters": [{"name": "pizza", "type": "list[str]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1446, "task_id": "consecutive-characters", "difficulty": "Easy", "problem_description": "The power of the string is the maximum length of a non-empty substring that contains only one unique character.\n\nGiven a string s, return the power of s.\n\nExample 1:\n\nInput: s = \"leetcode\"\nOutput: 2\nExplanation: The substring \"ee\" is of length 2 with the character 'e' only.\n\nExample 2:\n\nInput: s = \"abbcccddddeeeeedcba\"\nOutput: 5\nExplanation: The substring \"eeeee\" is of length 5 with the character 'e' only.\n\nConstraints:\n\n- 1 <= s.length <= 500\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"tourist\") == 1\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"aabbbbccc\") == 4\n assert candidate(s = \"cccccaaaa\") == 5\n assert candidate(s = \"bbaaaaacccddddeeeefffggghhhiiijjjkkkllmmnnnooopppqqrrssttuuvvwwwxxxyyyzzz\") == 5\n assert candidate(s = \"leetcode\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 10\n assert candidate(s = \"hooray\") == 2\n assert candidate(s = \"ccbccbbbaaaa\") == 4\n assert candidate(s = \"triplepilloooooo\") == 6\n assert candidate(s = \"aabbbcccccdd\") == 5\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"ccbccbb\") == 2\n assert candidate(s = \"aabbcc\") == 2\n assert candidate(s = \"cc\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"abbcccddddeeeeedcba\") == 5\n assert candidate(s = \"abcdeffffffffghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\") == 4\n assert candidate(s = \"pppppqqqqqrrrrrsssss\") == 5\n assert candidate(s = \"aaabbaaabbbaaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaa\") == 4\n assert candidate(s = \"ababababababababababab\") == 1\n assert candidate(s = \"aaaaaaaaaaa\") == 11\n assert candidate(s = \"mmmmmmnnnnnnooooooppppppqqqqqqrrrrrrssssssttttttuuuuuuvvvvvvwwwwwwxxxxxxxxxyyyyyyzzzzzz\") == 9\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhiiijjjkkklllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 28\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 96\n assert candidate(s = \"aaaaaaabbbbbbcccccc\") == 7\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abcdefffffffffghijklmnopqrstuvwxyz\") == 9\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 4\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"aabbbccccdddddeeeeeeeeefffffffffggggggggggg\") == 11\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 188\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"abcdddddddddddabcdddddddddddabcddddddddddd\") == 11\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 88\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 202\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 180\n assert candidate(s = \"aabaaaaccaaaaabbb\") == 5\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 10\n assert candidate(s = \"mnopqrstuvwxyzaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccdddddddddddddddddddd\") == 26\n assert candidate(s = \"aabcccccaaaaddddddeeeeffffggggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"zzzzzyyyyyzzzzzzzzz\") == 9\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"aabbaabbccbbccddeeffggffhhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 3\n assert candidate(s = \"aabbccddeeeefffbbbccc\") == 4\n assert candidate(s = \"aabbaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaa\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 152\n assert candidate(s = \"aaaaabbbbbccccccdddddeeeeeeffffffgggggghhhhhiiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == 2\n assert candidate(s = \"aabbbcccdddeeefffggghhh\") == 3\n assert candidate(s = \"zzzzzyyyyxxwwwwvvvuuutttsssrqqpponnmmllkkjjiihhggffeeddccbbaa\") == 5\n assert candidate(s = \"aaabbbcccddddeeeeffffggggg\") == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 34\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzz\") == 6\n assert candidate(s = \"pppppaaaabbbbccccdddddeeeeeeeeeffffffggggggggggghhhhhhhhhiiiiiiiijjjjjjjkkkkkkllllllmmmmmmnnnnnoooooopppppqqqqrrrrsssttttuuuuuuuuuuuuvvvvvvvvvvvvvvvwwwwwwwwwwwxxxxxyyyyyyyyyyyyyzzzzzzzzzzzzzzzzz\") == 17\n assert candidate(s = \"aabbbccccdddddeeeee\") == 5\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"sssssssqqqqqqqqqqppppppooooonnnnnnmmmmmmm\") == 10\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 1\n assert candidate(s = \"mnonononoqpqrstuvwxyzzzzzzzz\") == 8\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 2\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggg\") == 6\n", "comparison": "exact"}, "public_tests": ["\"leetcode\"", "\"abbcccddddeeeeedcba\""], "hints": ["Keep an array power where power[i] is the maximum power of the i-th character.", "The answer is max(power[i])."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxPower", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:23+00:00", "tests_total": 70, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def maxPower(self, s: str) -> int:", "container": "Solution", "callable": "maxPower", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1447, "task_id": "simplified-fractions", "difficulty": "Medium", "problem_description": "Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order.\n\nExample 1:\n\nInput: n = 2\nOutput: [\"1/2\"]\nExplanation: \"1/2\" is the only unique fraction with a denominator less-than-or-equal-to 2.\n\nExample 2:\n\nInput: n = 3\nOutput: [\"1/2\",\"1/3\",\"2/3\"]\n\nExample 3:\n\nInput: n = 4\nOutput: [\"1/2\",\"1/3\",\"1/4\",\"2/3\",\"3/4\"]\nExplanation: \"2/4\" is not a simplified fraction because it can be simplified to \"1/2\".\n\nConstraints:\n\n- 1 <= n <= 100\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=3), ['1/2', '1/3', '2/3'])\n assert answers_match(candidate(n=4), ['1/2', '1/3', '1/4', '2/3', '3/4'])\n assert answers_match(candidate(n=2), ['1/2'])\n assert answers_match(candidate(n=20), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '6/7', '6/11', '6/13', '6/17', '6/19', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '10/11', '10/13', '10/17', '10/19', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '12/13', '12/17', '12/19', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '14/15', '14/17', '14/19', '15/16', '15/17', '15/19', '16/17', '16/19', '17/18', '17/19', '17/20', '18/19', '19/20'])\n assert answers_match(candidate(n=100), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '2/99', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '3/98', '3/100', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '4/99', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '5/98', '5/99', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '7/99', '7/100', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '8/99', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '9/98', '9/100', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '10/99', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '11/98', '11/100', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '13/98', '13/99', '13/100', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '14/99', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '15/98', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '16/99', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '17/98', '17/99', '17/100', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '19/98', '19/99', '19/100', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '20/99', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '21/100', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '23/98', '23/99', '23/100', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '25/98', '25/99', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '26/99', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '27/98', '27/100', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '28/99', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '29/98', '29/99', '29/100', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '31/98', '31/99', '31/100', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '32/99', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '33/98', '33/100', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '34/99', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '35/99', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '37/98', '37/99', '37/100', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '38/99', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '39/98', '39/100', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '40/99', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '41/98', '41/99', '41/100', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '43/98', '43/99', '43/100', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '45/98', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '46/99', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '47/98', '47/99', '47/100', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '49/99', '49/100', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '50/99', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '51/98', '51/100', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '52/99', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '53/98', '53/99', '53/100', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '55/98', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '56/99', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '57/98', '57/100', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '58/99', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '59/98', '59/99', '59/100', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '61/98', '61/99', '61/100', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '62/99', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '63/100', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '64/99', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '65/98', '65/99', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '67/98', '67/99', '67/100', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '68/99', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '69/98', '69/100', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '70/99', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '71/98', '71/99', '71/100', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '73/98', '73/99', '73/100', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '74/99', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '75/98', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '76/99', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '77/100', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '79/98', '79/99', '79/100', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '80/99', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '81/98', '81/100', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '82/99', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '83/98', '83/99', '83/100', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '85/98', '85/99', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '86/99', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '87/98', '87/100', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '89/98', '89/99', '89/100', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '91/99', '91/100', '92/93', '92/95', '92/97', '92/99', '93/94', '93/95', '93/97', '93/98', '93/100', '94/95', '94/97', '94/99', '95/96', '95/97', '95/98', '95/99', '96/97', '97/98', '97/99', '97/100', '98/99', '99/100'])\n assert answers_match(candidate(n=50), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '36/37', '36/41', '36/43', '36/47', '36/49', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '40/41', '40/43', '40/47', '40/49', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '42/43', '42/47', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '44/45', '44/47', '44/49', '45/46', '45/47', '45/49', '46/47', '46/49', '47/48', '47/49', '47/50', '48/49', '49/50'])\n assert answers_match(candidate(n=10), ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '2/3', '2/5', '2/7', '2/9', '3/4', '3/5', '3/7', '3/8', '3/10', '4/5', '4/7', '4/9', '5/6', '5/7', '5/8', '5/9', '6/7', '7/8', '7/9', '7/10', '8/9', '9/10'])\n assert answers_match(candidate(n=5), ['1/2', '1/3', '1/4', '1/5', '2/3', '2/5', '3/4', '3/5', '4/5'])\n assert answers_match(candidate(n=97), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '92/93', '92/95', '92/97', '93/94', '93/95', '93/97', '94/95', '94/97', '95/96', '95/97', '96/97'])\n assert answers_match(candidate(n=60), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '42/43', '42/47', '42/53', '42/55', '42/59', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '48/49', '48/53', '48/55', '48/59', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '50/51', '50/53', '50/57', '50/59', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '52/53', '52/55', '52/57', '52/59', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '54/55', '54/59', '55/56', '55/57', '55/58', '55/59', '56/57', '56/59', '57/58', '57/59', '58/59', '59/60'])\n assert answers_match(candidate(n=30), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '18/19', '18/23', '18/25', '18/29', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '20/21', '20/23', '20/27', '20/29', '21/22', '21/23', '21/25', '21/26', '21/29', '22/23', '22/25', '22/27', '22/29', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '24/25', '24/29', '25/26', '25/27', '25/28', '25/29', '26/27', '26/29', '27/28', '27/29', '28/29', '29/30'])\n assert answers_match(candidate(n=99), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '2/99', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '3/98', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '4/99', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '5/98', '5/99', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '7/99', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '8/99', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '9/98', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '10/99', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '11/98', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '13/98', '13/99', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '14/99', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '15/98', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '16/99', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '17/98', '17/99', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '19/98', '19/99', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '20/99', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '23/98', '23/99', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '25/98', '25/99', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '26/99', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '27/98', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '28/99', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '29/98', '29/99', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '31/98', '31/99', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '32/99', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '33/98', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '34/99', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '35/99', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '37/98', '37/99', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '38/99', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '39/98', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '40/99', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '41/98', '41/99', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '43/98', '43/99', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '45/98', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '46/99', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '47/98', '47/99', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '49/99', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '50/99', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '51/98', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '52/99', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '53/98', '53/99', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '55/98', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '56/99', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '57/98', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '58/99', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '59/98', '59/99', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '61/98', '61/99', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '62/99', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '64/99', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '65/98', '65/99', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '67/98', '67/99', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '68/99', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '69/98', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '70/99', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '71/98', '71/99', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '73/98', '73/99', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '74/99', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '75/98', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '76/99', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '79/98', '79/99', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '80/99', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '81/98', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '82/99', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '83/98', '83/99', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '85/98', '85/99', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '86/99', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '87/98', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '89/98', '89/99', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '91/99', '92/93', '92/95', '92/97', '92/99', '93/94', '93/95', '93/97', '93/98', '94/95', '94/97', '94/99', '95/96', '95/97', '95/98', '95/99', '96/97', '97/98', '97/99', '98/99'])\n assert answers_match(candidate(n=80), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '66/67', '66/71', '66/73', '66/79', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '70/71', '70/73', '70/79', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '72/73', '72/77', '72/79', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '74/75', '74/77', '74/79', '75/76', '75/77', '75/79', '76/77', '76/79', '77/78', '77/79', '77/80', '78/79', '79/80'])\n assert answers_match(candidate(n=8), ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '2/3', '2/5', '2/7', '3/4', '3/5', '3/7', '3/8', '4/5', '4/7', '5/6', '5/7', '5/8', '6/7', '7/8'])\n assert answers_match(candidate(n=75), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '60/61', '60/67', '60/71', '60/73', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '66/67', '66/71', '66/73', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '68/69', '68/71', '68/73', '68/75', '69/70', '69/71', '69/73', '69/74', '70/71', '70/73', '71/72', '71/73', '71/74', '71/75', '72/73', '73/74', '73/75', '74/75'])\n assert answers_match(candidate(n=81), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '66/67', '66/71', '66/73', '66/79', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '70/71', '70/73', '70/79', '70/81', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '72/73', '72/77', '72/79', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '74/75', '74/77', '74/79', '74/81', '75/76', '75/77', '75/79', '76/77', '76/79', '76/81', '77/78', '77/79', '77/80', '77/81', '78/79', '79/80', '79/81', '80/81'])\n assert answers_match(candidate(n=15), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '6/7', '6/11', '6/13', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '8/9', '8/11', '8/13', '8/15', '9/10', '9/11', '9/13', '9/14', '10/11', '10/13', '11/12', '11/13', '11/14', '11/15', '12/13', '13/14', '13/15', '14/15'])\n assert answers_match(candidate(n=85), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '70/71', '70/73', '70/79', '70/81', '70/83', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '72/73', '72/77', '72/79', '72/83', '72/85', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '75/76', '75/77', '75/79', '75/82', '75/83', '76/77', '76/79', '76/81', '76/83', '76/85', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '78/79', '78/83', '78/85', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '80/81', '80/83', '81/82', '81/83', '81/85', '82/83', '82/85', '83/84', '83/85', '84/85'])\n assert answers_match(candidate(n=1), [])\n assert answers_match(candidate(n=55), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '42/43', '42/47', '42/53', '42/55', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '44/45', '44/47', '44/49', '44/51', '44/53', '45/46', '45/47', '45/49', '45/52', '45/53', '46/47', '46/49', '46/51', '46/53', '46/55', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '48/49', '48/53', '48/55', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '50/51', '50/53', '51/52', '51/53', '51/55', '52/53', '52/55', '53/54', '53/55', '54/55'])\n assert answers_match(candidate(n=90), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '78/79', '78/83', '78/85', '78/89', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '80/81', '80/83', '80/87', '80/89', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '82/83', '82/85', '82/87', '82/89', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '84/85', '84/89', '85/86', '85/87', '85/88', '85/89', '86/87', '86/89', '87/88', '87/89', '88/89', '89/90'])\n assert answers_match(candidate(n=25), ['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', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '12/13', '12/17', '12/19', '12/23', '12/25', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '14/15', '14/17', '14/19', '14/23', '14/25', '15/16', '15/17', '15/19', '15/22', '15/23', '16/17', '16/19', '16/21', '16/23', '16/25', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '18/19', '18/23', '18/25', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '20/21', '20/23', '21/22', '21/23', '21/25', '22/23', '22/25', '23/24', '23/25', '24/25'])\n", "comparison": "unordered"}, "public_tests": ["2", "3", "4"], "hints": ["A fraction is fully simplified if there is no integer that divides cleanly into the numerator and denominator.", "In other words the greatest common divisor of the numerator and the denominator of a simplified fraction is 1."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().simplifiedFractions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:26+00:00", "tests_total": 22, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["math", "string", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "python", "interface": {"raw_signature": "def simplifiedFractions(self, n: int) -> list[str]:", "container": "Solution", "callable": "simplifiedFractions", "parameters": [{"name": "n", "type": "int"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1449, "task_id": "form-largest-integer-with-digits-that-add-up-to-target", "difficulty": "Hard", "problem_description": "Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:\n\n- The cost of painting a digit (i + 1) is given by cost[i] (0-indexed).\n- The total cost used must be equal to target.\n- The integer does not have 0 digits.\n\nSince the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return \"0\".\n\nExample 1:\n\nInput: cost = [4,3,2,5,6,7,2,5,5], target = 9\nOutput: \"7772\"\nExplanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost(\"7772\") = 2*3+ 3*1 = 9. You could also paint \"977\", but \"7772\" is the largest number.\nDigit cost\n 1 -> 4\n 2 -> 3\n 3 -> 2\n 4 -> 5\n 5 -> 6\n 6 -> 7\n 7 -> 2\n 8 -> 5\n 9 -> 5\n\nExample 2:\n\nInput: cost = [7,6,5,5,5,6,8,7,8], target = 12\nOutput: \"85\"\nExplanation: The cost to paint the digit '8' is 7, and the digit '5' is 5. Then cost(\"85\") = 7 + 5 = 12.\n\nExample 3:\n\nInput: cost = [2,4,6,2,4,6,4,4,4], target = 5\nOutput: \"0\"\nExplanation: It is impossible to paint any integer with total cost equal to target.\n\nConstraints:\n\n- cost.length == 9\n- 1 <= cost[i], target <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [5, 3, 7, 5, 2, 6, 8, 9, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == \"99999\"\n assert candidate(cost = [2, 4, 6, 2, 4, 6, 4, 4, 4],target = 5) == \"0\"\n assert candidate(cost = [7, 6, 5, 5, 5, 6, 8, 7, 8],target = 12) == \"85\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == \"999\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 45) == \"9999999999999999999998\"\n assert candidate(cost = [9, 9, 9, 9, 9, 9, 9, 9, 9],target = 5) == \"0\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 9) == \"999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 18) == \"999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 10) == \"1111111111\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 30) == \"999999999999999\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 4) == \"9999\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 9) == \"7772\"\n assert candidate(cost = [7, 3, 2, 1, 5, 8, 4, 6, 9],target = 36) == \"444444444444444444444444444444444444\"\n assert candidate(cost = [5, 3, 9, 1, 7, 6, 2, 8, 4],target = 30) == \"444444444444444444444444444444\"\n assert candidate(cost = [4, 4, 4, 4, 4, 4, 4, 4, 4],target = 200) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [8, 7, 6, 5, 4, 3, 2, 1, 9],target = 50) == \"88888888888888888888888888888888888888888888888888\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 35) == \"99999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 45) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 100) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 15) == \"111111111111111\"\n assert candidate(cost = [8, 5, 2, 6, 4, 3, 9, 7, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 1, 2, 1, 2, 1, 2, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 450) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == \"999999\"\n assert candidate(cost = [5, 4, 3, 2, 1, 9, 8, 7, 6],target = 30) == \"555555555555555555555555555555\"\n assert candidate(cost = [4, 5, 6, 1, 2, 3, 7, 8, 9],target = 24) == \"444444444444444444444444\"\n assert candidate(cost = [2, 3, 2, 2, 3, 3, 2, 3, 2],target = 18) == \"999999999\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [1, 1, 2, 3, 5, 8, 13, 21, 34],target = 50) == \"22222222222222222222222222222222222222222222222222\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 9, 2, 7, 3, 6, 8, 1, 4],target = 150) == \"888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\"\n assert candidate(cost = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 30) == \"555555555555555555555555555555\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 1800) == \"111111111111111111\"\n assert candidate(cost = [1, 9, 1, 9, 1, 9, 1, 9, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == \"211111111111\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 4500) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 20) == \"7777777777\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 3, 5, 7, 9, 11, 13, 15, 17],target = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 250) == \"1111111111111111111111111\"\n assert candidate(cost = [8, 8, 8, 8, 8, 8, 8, 8, 8],target = 72) == \"999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [4, 4, 4, 4, 4, 4, 4, 4, 4],target = 36) == \"999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 45) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 11, 12, 13, 14, 15, 16, 17, 18],target = 150) == \"111111111111111\"\n assert candidate(cost = [1, 2, 3, 1, 2, 3, 1, 2, 3],target = 20) == \"77777777777777777777\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 100) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 2500) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 50) == \"44444444444444444444444444444444444444444444444444\"\n assert candidate(cost = [9, 18, 27, 36, 45, 54, 63, 72, 81],target = 162) == \"111111111111111111\"\n assert candidate(cost = [3, 3, 2, 1, 4, 5, 6, 7, 8],target = 25) == \"4444444444444444444444444\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 30) == \"999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 500) == \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 20) == \"9999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 1500) == \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [7, 6, 5, 5, 5, 6, 8, 7, 8],target = 24) == \"9655\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 300) == \"111111111111111111111111111111\"\n assert candidate(cost = [10, 10, 10, 10, 10, 10, 10, 10, 10],target = 45) == \"0\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 18) == \"777777777\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == \"211111111111111111111111111\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == \"999999\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == \"1111111111111111111111111\"\n assert candidate(cost = [7, 3, 3, 6, 2, 5, 5, 5, 5],target = 25) == \"555555555553\"\n assert candidate(cost = [9, 9, 9, 9, 9, 9, 9, 9, 9],target = 27) == \"999\"\n assert candidate(cost = [1, 3, 1, 3, 1, 3, 1, 3, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 20) == \"11111111111111111111\"\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23],target = 50) == \"1111111111111111111111111\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 20) == \"7777777777\"\n assert candidate(cost = [1, 1, 2, 2, 3, 3, 4, 4, 5],target = 20) == \"22222222222222222222\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 30) == \"444444444444444444444444444444\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1000) == \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 60) == \"999999999999999999999999999999\"\n assert candidate(cost = [3, 5, 7, 9, 11, 13, 15, 17, 19],target = 50) == \"2111111111111111\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 100) == \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 27) == \"0\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 1000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 18) == \"999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == \"99999\"\n assert candidate(cost = [1, 3, 1, 3, 1, 3, 1, 3, 1],target = 25) == \"9999999999999999999999999\"\n assert candidate(cost = [1, 2, 1, 2, 1, 2, 1, 2, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23],target = 100) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 3000) == \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 6, 7, 8, 9, 10, 11, 12, 13],target = 30) == \"111111\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 99) == \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 2, 1, 1, 2, 2, 1, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [2, 3, 3, 4, 4, 4, 5, 5, 5],target = 36) == \"111111111111111111\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 25) == \"0\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 100) == \"1111111111\"\n assert candidate(cost = [2, 4, 6, 8, 10, 12, 14, 16, 18],target = 5000) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [50, 50, 50, 50, 50, 50, 50, 50, 50],target = 100) == \"99\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 2700) == \"111111111111111111111111111\"\n assert candidate(cost = [5, 3, 5, 3, 5, 3, 5, 3, 5],target = 20) == \"988888\"\n assert candidate(cost = [20, 19, 18, 17, 16, 15, 14, 13, 12],target = 100) == \"99999995\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == \"2111111111111111111111\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 1000) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 2, 5, 7, 9, 4, 8, 6, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [3, 5, 2, 3, 9, 7, 5, 4, 2],target = 15) == \"9999994\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 450) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == \"999999999\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 27) == \"444444444444444444444444444\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 81) == \"999999999999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 1],target = 30) == \"999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 30) == \"111111111111111111111111111111\"\n assert candidate(cost = [1, 3, 2, 1, 2, 1, 3, 2, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 6, 7, 8, 9, 10, 11, 12, 13],target = 100) == \"11111111111111111111\"\n", "comparison": "exact"}, "public_tests": ["[4,3,2,5,6,7,2,5,5]\n9", "[7,6,5,5,5,6,8,7,8]\n12", "[2,4,6,2,4,6,4,4,4]\n5"], "hints": ["Use dynamic programming to find the maximum digits to paint given a total cost.", "Build the largest number possible using this DP table."], "metadata": {"canonical_parameter_names": ["cost", "target"], "leetcode_dataset_entry_point": "Solution().largestNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:30+00:00", "tests_total": 110, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "knapsack-problem", "complete-knapsack"]}, "language": "python", "interface": {"raw_signature": "def largestNumber(self, cost: list[int], target: int) -> str:", "container": "Solution", "callable": "largestNumber", "parameters": [{"name": "cost", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1450, "task_id": "number-of-students-doing-homework-at-a-given-time", "difficulty": "Easy", "problem_description": "Given two integer arrays startTime and endTime and given an integer queryTime.\n\nThe ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].\n\nReturn the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.\n\nExample 1:\n\nInput: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4\nOutput: 1\nExplanation: We have 3 students where:\nThe first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.\nThe second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.\nThe third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.\n\nExample 2:\n\nInput: startTime = [4], endTime = [4], queryTime = 4\nOutput: 1\nExplanation: The only student was doing their homework at the queryTime.\n\nConstraints:\n\n- startTime.length == endTime.length\n- 1 <= startTime.length <= 100\n- 1 <= startTime[i] <= endTime[i] <= 1000\n- 1 <= queryTime <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startTime = [9, 8, 7, 6],endTime = [10, 9, 8, 7],queryTime = 8) == 2\n assert candidate(startTime = [5, 5, 5, 5],endTime = [10, 10, 10, 10],queryTime = 7) == 4\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 5) == 2\n assert candidate(startTime = [4],endTime = [4],queryTime = 4) == 1\n assert candidate(startTime = [1, 2, 3],endTime = [3, 2, 7],queryTime = 4) == 1\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 3, 6, 7, 9],endTime = [2, 5, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 6) == 2\n assert candidate(startTime = [1, 1, 1, 1],endTime = [2, 2, 2, 2],queryTime = 1) == 4\n assert candidate(startTime = [1, 3, 5, 7],endTime = [2, 4, 6, 8],queryTime = 5) == 1\n assert candidate(startTime = [10, 20, 30],endTime = [15, 25, 35],queryTime = 22) == 1\n assert candidate(startTime = [5, 5, 5, 5],endTime = [6, 6, 6, 6],queryTime = 5) == 4\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [2, 2, 2, 2, 2],queryTime = 1) == 5\n assert candidate(startTime = [100, 200, 300, 400],endTime = [199, 299, 399, 499],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queryTime = 500) == 6\n assert candidate(startTime = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950],endTime = [550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],queryTime = 725) == 1\n assert candidate(startTime = [10, 15, 20, 25, 30, 35, 40, 45, 50],endTime = [14, 19, 24, 29, 34, 39, 44, 49, 54],queryTime = 22) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [75, 125, 175, 225, 275],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60],queryTime = 5) == 6\n assert candidate(startTime = [250, 500, 750],endTime = [260, 510, 760],queryTime = 255) == 1\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 55) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [19, 29, 39, 49, 59, 69, 79, 89, 99, 109],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 28) == 0\n assert candidate(startTime = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],endTime = [55, 105, 155, 205, 255, 305, 355, 405, 455, 505],queryTime = 102) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [5, 5, 5, 5, 5],queryTime = 3) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 10) == 1\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 33) == 1\n assert candidate(startTime = [300, 300, 300, 300],endTime = [600, 600, 600, 600],queryTime = 400) == 4\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50],queryTime = 10) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 11, 12, 13, 14],queryTime = 8) == 5\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [6, 7, 8, 9, 10, 11],queryTime = 5) == 6\n assert candidate(startTime = [1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000],queryTime = 500) == 4\n assert candidate(startTime = [5, 10, 15, 20, 25],endTime = [14, 19, 24, 29, 34],queryTime = 22) == 2\n assert candidate(startTime = [100, 200, 300, 400],endTime = [150, 250, 350, 450],queryTime = 225) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 1) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 5) == 10\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],queryTime = 10) == 2\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [100, 200, 300, 400, 500],queryTime = 100) == 1\n assert candidate(startTime = [10, 20, 30, 40],endTime = [100, 200, 300, 400],queryTime = 150) == 3\n assert candidate(startTime = [900, 905, 910, 915],endTime = [909, 914, 919, 924],queryTime = 907) == 2\n assert candidate(startTime = [1, 3, 6, 8, 10],endTime = [2, 5, 7, 10, 12],queryTime = 4) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1, 1, 1, 1, 1],queryTime = 1) == 5\n assert candidate(startTime = [2, 2, 2, 2, 2],endTime = [10, 10, 10, 10, 10],queryTime = 6) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 350) == 1\n assert candidate(startTime = [1, 3, 5, 7, 9],endTime = [2, 4, 6, 8, 10],queryTime = 5) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 275) == 0\n assert candidate(startTime = [100, 200, 300, 400],endTime = [101, 201, 301, 401],queryTime = 200) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 63) == 1\n assert candidate(startTime = [100, 150, 200, 250],endTime = [149, 199, 249, 299],queryTime = 175) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [99, 199, 299, 399, 499],queryTime = 100) == 1\n assert candidate(startTime = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],endTime = [14, 24, 34, 44, 54, 64, 74, 84, 94, 104],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 50) == 6\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queryTime = 10) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queryTime = 5) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 9, 8, 7, 6],queryTime = 6) == 5\n assert candidate(startTime = [200, 200, 300, 300],endTime = [200, 400, 400, 500],queryTime = 200) == 2\n assert candidate(startTime = [10, 10, 10, 10, 10],endTime = [15, 15, 15, 15, 15],queryTime = 12) == 5\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 25) == 1\n assert candidate(startTime = [999, 998, 997, 996, 995],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 999) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 325) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 10, 15, 20, 25],queryTime = 3) == 3\n assert candidate(startTime = [9, 10, 11, 12, 13],endTime = [10, 12, 14, 16, 18],queryTime = 12) == 3\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 25) == 3\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [199, 299, 399, 499, 599],queryTime = 450) == 1\n assert candidate(startTime = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],endTime = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31],queryTime = 15) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [100, 110, 120, 130, 140],queryTime = 60) == 5\n assert candidate(startTime = [1, 3, 5, 7, 9, 11],endTime = [2, 4, 6, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 400) == 1\n assert candidate(startTime = [500, 501, 502, 503, 504, 505],endTime = [500, 501, 502, 503, 504, 505],queryTime = 505) == 1\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 7) == 10\n assert candidate(startTime = [500, 600, 700, 800],endTime = [599, 699, 799, 899],queryTime = 750) == 1\n assert candidate(startTime = [1, 100, 200, 300, 400],endTime = [100, 200, 300, 400, 500],queryTime = 150) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queryTime = 15) == 6\n assert candidate(startTime = [500, 550, 600, 650],endTime = [501, 551, 601, 651],queryTime = 550) == 1\n assert candidate(startTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],endTime = [5, 6, 6, 7, 7, 8, 8, 9, 9, 10],queryTime = 6) == 9\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [10, 20, 30, 40],endTime = [15, 25, 35, 45],queryTime = 22) == 1\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n[3,2,7]\n4", "[4]\n[4]\n4"], "hints": ["Imagine that startTime[i] and endTime[i] form an interval (i.e. [startTime[i], endTime[i]]).", "The answer is how many times the queryTime laid in those mentioned intervals."], "metadata": {"canonical_parameter_names": ["startTime", "endTime", "queryTime"], "leetcode_dataset_entry_point": "Solution().busyStudent", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:32+00:00", "tests_total": 95, "tests_dropped": 12, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def busyStudent(self, startTime: list[int], endTime: list[int], queryTime: int) -> int:", "container": "Solution", "callable": "busyStudent", "parameters": [{"name": "startTime", "type": "list[int]"}, {"name": "endTime", "type": "list[int]"}, {"name": "queryTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1451, "task_id": "rearrange-words-in-a-sentence", "difficulty": "Medium", "problem_description": "Given a sentence text (A sentence is a string of space-separated words) in the following format:\n\n- First letter is in upper case.\n- Each word in text are separated by a single space.\n\nYour task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.\n\nReturn the new text following the format shown above.\n\nExample 1:\n\nInput: text = \"Leetcode is cool\"\nOutput: \"Is cool leetcode\"\nExplanation: There are 3 words, \"Leetcode\" of length 8, \"is\" of length 2 and \"cool\" of length 4.\nOutput is ordered by length and the new first word starts with capital letter.\n\nExample 2:\n\nInput: text = \"Keep calm and code on\"\nOutput: \"On and keep calm code\"\nExplanation: Output is ordered as follows:\n\"On\" 2 letters.\n\"and\" 3 letters.\n\"keep\" 4 letters in case of tie order by position in original text.\n\"calm\" 4 letters.\n\"code\" 4 letters.\n\nExample 3:\n\nInput: text = \"To be or not to be\"\nOutput: \"To be or to be not\"\n\nConstraints:\n\n- text begins with a capital letter and then contains lowercase letters and single space between words.\n- 1 <= text.length <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"A quick brown fox jumps over the lazy dog\") == \"A fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a simple test case\") == \"A is this test case simple\"\n assert candidate(text = \"The weather is sunny\") == \"Is the sunny weather\"\n assert candidate(text = \"A\") == \"A\"\n assert candidate(text = \"A B C D E\") == \"A B C D E\"\n assert candidate(text = \"Pack my box with five dozen liquor jugs\") == \"My box pack with five jugs dozen liquor\"\n assert candidate(text = \"Sorting words by length is fun\") == \"By is fun words length sorting\"\n assert candidate(text = \"I love programming in Python\") == \"I in love Python programming\"\n assert candidate(text = \"How vexingly quick daft zebras jump\") == \"How daft jump quick zebras vexingly\"\n assert candidate(text = \"Every good boy does fine\") == \"Boy good does fine every\"\n assert candidate(text = \"To be or not to be\") == \"To be or to be not\"\n assert candidate(text = \"Leetcode is cool\") == \"Is cool leetcode\"\n assert candidate(text = \"The quick brown fox jumps over the lazy dog\") == \"The fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a test sentence with various word lengths\") == \"A is this test with word various lengths sentence\"\n assert candidate(text = \"Keep calm and code on\") == \"On and keep calm code\"\n assert candidate(text = \"This is a test sentence for the function\") == \"A is for the this test sentence function\"\n assert candidate(text = \"In computer science algorithms often require creative solutions\") == \"In often science require computer creative solutions algorithms\"\n assert candidate(text = \"Silent nights filled with the promise of new beginnings\") == \"Of the new with silent nights filled promise beginnings\"\n assert candidate(text = \"Beautiful sentences flow rhythmically and gracefully\") == \"And flow beautiful sentences gracefully rhythmically\"\n assert candidate(text = \"Health and happiness are the most valuable possessions\") == \"And are the most health valuable happiness possessions\"\n assert candidate(text = \"Exploring the mysteries of the universe is a lifelong journey\") == \"A of is the the journey universe lifelong exploring mysteries\"\n assert candidate(text = \"Understanding these concepts is crucial for programming\") == \"Is for these crucial concepts programming understanding\"\n assert candidate(text = \"Repeating words like test test test should stay in order\") == \"In like test test test stay words order should repeating\"\n assert candidate(text = \"Programming challenges are a great way to improve your skills\") == \"A to are way your great skills improve challenges programming\"\n assert candidate(text = \"The smallest words often hide the deepest meanings\") == \"The the hide words often deepest smallest meanings\"\n assert candidate(text = \"You are never too old to set another goal or to dream a new dream\") == \"A to or to you are too old set new goal never dream dream another\"\n assert candidate(text = \"Sorting algorithms like quicksort and mergesort\") == \"And like sorting quicksort mergesort algorithms\"\n assert candidate(text = \"Learning never stops no matter how much one knows\") == \"No how one much never stops knows matter learning\"\n assert candidate(text = \"Despite its simplicity Unix is a powerful and flexible operating system\") == \"A is its and Unix system despite powerful flexible operating simplicity\"\n assert candidate(text = \"A journey of a thousand miles begins with a single step\") == \"A a a of with step miles begins single journey thousand\"\n assert candidate(text = \"Problem-solving skills are highly valued in the tech industry\") == \"In are the tech skills highly valued industry problem-solving\"\n assert candidate(text = \"Complexity arises when multiple words share the same length\") == \"The when same words share arises length multiple complexity\"\n assert candidate(text = \"In the midst of winter I found there was, within me, an invincible summer\") == \"I in of an the me, was, midst found there winter within summer invincible\"\n assert candidate(text = \"Happiness is not something ready made. It comes from your own actions\") == \"Is It not own from your ready made. comes actions happiness something\"\n assert candidate(text = \"Small steps lead to big progress\") == \"To big lead small steps progress\"\n assert candidate(text = \"With unwavering determination, she embarked on the perilous journey\") == \"On she the with journey embarked perilous unwavering determination,\"\n assert candidate(text = \"BeautifulSoup lxml html parser are widely used for web scraping\") == \"Are for web lxml html used parser widely scraping beautifulsoup\"\n assert candidate(text = \"Sorting words by length while maintaining original order\") == \"By words while order length sorting original maintaining\"\n assert candidate(text = \"We may encounter many defeats but we must not be defeated\") == \"We we be may but not many must defeats defeated encounter\"\n assert candidate(text = \"To achieve great things, we must not only act, but also dream; not only plan, but also believe\") == \"To we not but not but must only act, also only also great plan, dream; achieve things, believe\"\n assert candidate(text = \"A beautiful butterfly gracefully flutters among the colorful flowers\") == \"A the among flowers flutters colorful beautiful butterfly gracefully\"\n assert candidate(text = \"The greatest glory in living lies not in never falling, but in rising every time we fall\") == \"In in in we the not but lies time fall glory never every living rising greatest falling,\"\n assert candidate(text = \"The only way to do great work is to love what you do\") == \"To do is to do the way you only work love what great\"\n assert candidate(text = \"Innovative solutions can be achieved through collaborative efforts\") == \"Be can through efforts achieved solutions innovative collaborative\"\n assert candidate(text = \"Documentation plays a vital role in software development\") == \"A in role plays vital software development documentation\"\n assert candidate(text = \"In the heart of the city stood a magnificent gothic cathedral\") == \"A in of the the city heart stood gothic cathedral magnificent\"\n assert candidate(text = \"In the realm of competitive programming challenges are vast\") == \"In of the are vast realm challenges competitive programming\"\n assert candidate(text = \"In the heart of the city, amidst towering skyscrapers, lies a hidden gem\") == \"A in of the the gem lies heart city, amidst hidden towering skyscrapers,\"\n assert candidate(text = \"Continuous integration and deployment practices improve software quality\") == \"And improve quality software practices continuous deployment integration\"\n assert candidate(text = \"When words are of equal length they should remain in order\") == \"Of in are when they words equal order length should remain\"\n assert candidate(text = \"Understanding the nuances of human behavior is crucial\") == \"Of is the human nuances crucial behavior understanding\"\n assert candidate(text = \"Sometimes simplicity is the ultimate sophistication\") == \"Is the ultimate sometimes simplicity sophistication\"\n assert candidate(text = \"Beautiful scenery can uplift one's spirits\") == \"Can one's uplift scenery spirits beautiful\"\n assert candidate(text = \"If you want to live a happy life, tie it to a goal, not to people or things\") == \"A a if to it to to or you tie not want live happy life, goal, people things\"\n assert candidate(text = \"Consistency is the key to achieving long-term success\") == \"Is to the key success achieving long-term consistency\"\n assert candidate(text = \"The rapid expansion of cloud computing services has transformed many industries\") == \"Of the has many rapid cloud services expansion computing industries transformed\"\n assert candidate(text = \"Data structures and algorithms form the backbone of software\") == \"Of and the data form backbone software structures algorithms\"\n assert candidate(text = \"When faced with difficult problems persistence is key\") == \"Is key when with faced problems difficult persistence\"\n assert candidate(text = \"The sound of crashing waves soothed his restless mind\") == \"Of the his mind sound waves soothed crashing restless\"\n assert candidate(text = \"Effective communication skills are crucial in software engineering\") == \"In are skills crucial software effective engineering communication\"\n assert candidate(text = \"Can you solve this complex rearrangement problem\") == \"Can you this solve complex problem rearrangement\"\n assert candidate(text = \"Keep smiling because life is a beautiful journey not a destination\") == \"A a is not keep life smiling because journey beautiful destination\"\n assert candidate(text = \"Given a string containing multiple words of different lengths\") == \"A of given words string lengths multiple different containing\"\n assert candidate(text = \"A quick brown fox jumps over the lazy dog in an unexpected manner\") == \"A in an fox the dog over lazy quick brown jumps manner unexpected\"\n assert candidate(text = \"Programming challenges often require deep understanding and patience\") == \"And deep often require patience challenges programming understanding\"\n assert candidate(text = \"Adapting to new technologies and methodologies is important\") == \"To is new and adapting important technologies methodologies\"\n assert candidate(text = \"Handling edge cases is important for robust code\") == \"Is for edge code cases robust handling important\"\n assert candidate(text = \"Understanding data structures is crucial for computer scientists\") == \"Is for data crucial computer structures scientists understanding\"\n assert candidate(text = \"Programming challenges are intellectually stimulating\") == \"Are challenges programming stimulating intellectually\"\n assert candidate(text = \"Efficient algorithms can significantly reduce computation time\") == \"Can time reduce efficient algorithms computation significantly\"\n assert candidate(text = \"Believe you can and you're halfway there\") == \"You can and there you're believe halfway\"\n assert candidate(text = \"Actions speak louder than words\") == \"Than speak words louder actions\"\n assert candidate(text = \"Complex algorithms often require sophisticated data structures\") == \"Data often complex require algorithms structures sophisticated\"\n assert candidate(text = \"Python programming language is powerful and versatile\") == \"Is and python language powerful versatile programming\"\n assert candidate(text = \"In the realm of possibilities, anything is achievable\") == \"In of is the realm anything achievable possibilities,\"\n assert candidate(text = \"Learning to code is one of the most empowering experiences\") == \"To is of one the code most learning empowering experiences\"\n assert candidate(text = \"Crafting intricate designs in wood requires both skill and creativity\") == \"In and wood both skill designs crafting requires intricate creativity\"\n assert candidate(text = \"Despite the odds being stacked against him, he never gave up hope\") == \"He up the odds him, gave hope being never despite stacked against\"\n assert candidate(text = \"Those who dare to fail miserably can achieve greatly\") == \"To who can dare fail those achieve greatly miserably\"\n assert candidate(text = \"May the Force be with you\") == \"Be may the you with Force\"\n assert candidate(text = \"Every problem has a unique solution waiting to be discovered\") == \"A to be has every unique problem waiting solution discovered\"\n assert candidate(text = \"Consider various scenarios when testing your solution\") == \"When your various testing consider solution scenarios\"\n assert candidate(text = \"Despite the harsh conditions, the resilient hikers forged ahead\") == \"The the harsh ahead hikers forged despite resilient conditions,\"\n assert candidate(text = \"The ancient ruins whispered tales of forgotten civilizations\") == \"Of the ruins tales ancient whispered forgotten civilizations\"\n assert candidate(text = \"Python programming can be quite challenging indeed\") == \"Be can quite python indeed programming challenging\"\n assert candidate(text = \"Resilience and determination are the keys to success\") == \"To and are the keys success resilience determination\"\n assert candidate(text = \"A very very long sentence that needs to be properly rearranged\") == \"A to be very very long that needs sentence properly rearranged\"\n assert candidate(text = \"When sorting algorithms fail gracefully\") == \"When fail sorting algorithms gracefully\"\n assert candidate(text = \"Adventure and exploration are essential for personal growth\") == \"And are for growth personal adventure essential exploration\"\n assert candidate(text = \"Python Java JavaScript and C are popular programming languages\") == \"C and are Java python popular languages JavaScript programming\"\n assert candidate(text = \"Algorithms and data structures are fundamental to computer science\") == \"To and are data science computer algorithms structures fundamental\"\n assert candidate(text = \"In the heart of autumn leaves change their colors\") == \"In of the heart their autumn leaves change colors\"\n assert candidate(text = \"If life were predictable it would cease to be life, and be without flavor\") == \"If it to be be and life were would cease life, flavor without predictable\"\n assert candidate(text = \"A storm of emotions surged through her heart\") == \"A of her storm heart surged through emotions\"\n assert candidate(text = \"Continuous improvement is the hallmark of excellence\") == \"Is of the hallmark continuous excellence improvement\"\n assert candidate(text = \"The rain in Spain stays mainly in the plain\") == \"In in the the rain Spain stays plain mainly\"\n assert candidate(text = \"Do not watch the clock; do what it does. Keep going\") == \"Do do it not the what Keep watch does. going clock;\"\n assert candidate(text = \"The rapid expansion of artificial intelligence is fascinating\") == \"Of is the rapid expansion artificial fascinating intelligence\"\n assert candidate(text = \"An extraordinary journey through the magical lands\") == \"An the lands journey through magical extraordinary\"\n assert candidate(text = \"The early morning light illuminated the dew-kissed grass\") == \"The the early light grass morning dew-kissed illuminated\"\n assert candidate(text = \"Python is an interpreted high level programming language\") == \"Is an high level python language interpreted programming\"\n assert candidate(text = \"Understanding the intricacies of quantum mechanics requires patience\") == \"Of the quantum requires patience mechanics intricacies understanding\"\n assert candidate(text = \"A bird in the hand is worth two in the bush\") == \"A in is in the two the bird hand bush worth\"\n assert candidate(text = \"XMLHttpRequest allows clients to send and receive data asynchronously without reloading the web page\") == \"To and the web send data page allows clients receive without reloading xmlhttprequest asynchronously\"\n assert candidate(text = \"An overwhelming sense of serenity filled the quaint village\") == \"An of the sense filled quaint village serenity overwhelming\"\n assert candidate(text = \"Beautiful minds think in unpredictable ways\") == \"In ways minds think beautiful unpredictable\"\n assert candidate(text = \"Artificial intelligence and machine learning are transforming industries\") == \"And are machine learning artificial industries intelligence transforming\"\n assert candidate(text = \"It is during our darkest moments that we must focus the light\") == \"It is we our the that must focus light during darkest moments\"\n assert candidate(text = \"Do what you can with all you have, wherever you are\") == \"Do you can all you you are what with have, wherever\"\n assert candidate(text = \"Python is an interpreted high-level general-purpose programming language\") == \"Is an python language high-level interpreted programming general-purpose\"\n assert candidate(text = \"Sometimes life gives you lemons and you make lemonade\") == \"You and you life make gives lemons lemonade sometimes\"\n assert candidate(text = \"Creativity is the key to solving complex problems\") == \"Is to the key solving complex problems creativity\"\n assert candidate(text = \"Even seemingly simple tasks can be complex\") == \"Be can even tasks simple complex seemingly\"\n assert candidate(text = \"Data structures like arrays and linked lists\") == \"And data like lists arrays linked structures\"\n assert candidate(text = \"In computer science algorithms are fundamental\") == \"In are science computer algorithms fundamental\"\n assert candidate(text = \"Wherever you go, go with all your heart\") == \"Go you go, all with your heart wherever\"\n assert candidate(text = \"The magic of books lies in the stories they hold\") == \"Of in the the lies they hold magic books stories\"\n assert candidate(text = \"The children laughed joyfully in the sunlit playground\") == \"In the the sunlit laughed children joyfully playground\"\n assert candidate(text = \"The best time to plant a tree was 20 years ago. The second best time is now\") == \"A to 20 is the was The now best time tree ago. best time plant years second\"\n assert candidate(text = \"This is a test to see if the function handles ties correctly\") == \"A is to if see the this test ties handles function correctly\"\n assert candidate(text = \"Nature's beauty is a constant source of inspiration\") == \"A is of beauty source nature's constant inspiration\"\n assert candidate(text = \"Despite its simplicity quicksort is incredibly effective\") == \"Is its despite quicksort effective simplicity incredibly\"\n assert candidate(text = \"Programming challenges are a great way to improve skills\") == \"A to are way great skills improve challenges programming\"\n assert candidate(text = \"Check if the function can handle sentences with repeated words\") == \"If the can with check words handle function repeated sentences\"\n assert candidate(text = \"In every day, there are 1440 minutes, 86400 seconds and 5184000 milliseconds, so live every second\") == \"In so are and day, 1440 live every there 86400 every second seconds 5184000 minutes, milliseconds,\"\n assert candidate(text = \"Somebody once told me the world is gonna roll me\") == \"Me is me the once told roll world gonna somebody\"\n assert candidate(text = \"Many software projects involve working with multiple programming languages\") == \"Many with involve working software projects multiple languages programming\"\n assert candidate(text = \"Version control systems are essential for software development\") == \"Are for version control systems software essential development\"\n assert candidate(text = \"Writing clean and maintainable code is beneficial\") == \"Is and code clean writing beneficial maintainable\"\n assert candidate(text = \"Understanding the complexities of software development requires patience\") == \"Of the software requires patience development complexities understanding\"\n assert candidate(text = \"Debugging is twice as hard as writing the code in the first place\") == \"Is as as in the the hard code twice first place writing debugging\"\n assert candidate(text = \"Handling large datasets efficiently is a common requirement\") == \"A is large common handling datasets efficiently requirement\"\n assert candidate(text = \"Sometimes simple sentences are the most powerful\") == \"Are the most simple powerful sometimes sentences\"\n assert candidate(text = \"Algorithms data structures and programming languages\") == \"And data languages algorithms structures programming\"\n assert candidate(text = \"Some programmers prefer to use snake_case others CamelCase\") == \"To use some prefer others CamelCase snake_case programmers\"\n assert candidate(text = \"Exploring new cultures broadens one's horizons immensely\") == \"New one's cultures broadens horizons exploring immensely\"\n assert candidate(text = \"This is a simple example to demonstrate the functionality\") == \"A is to the this simple example demonstrate functionality\"\n assert candidate(text = \"Efficient algorithms can significantly reduce processing time\") == \"Can time reduce efficient algorithms processing significantly\"\n assert candidate(text = \"Python programming challenges are incredibly rewarding\") == \"Are python rewarding challenges incredibly programming\"\n assert candidate(text = \"Do not judge each day by the harvest you reap but by the seeds that you plant\") == \"Do by by not day the you but the you each reap that judge seeds plant harvest\"\n assert candidate(text = \"The quick movement of the enemy will jeopardize six gunboats\") == \"Of the the six will quick enemy movement gunboats jeopardize\"\n assert candidate(text = \"Contrary to popular belief Lorem Ipsum is not simply random text\") == \"To is not text Lorem Ipsum belief simply random popular contrary\"\n assert candidate(text = \"Every small victory is a stepping stone to greatness\") == \"A is to every small stone victory stepping greatness\"\n assert candidate(text = \"A mix of long and short words challenges the function greatly\") == \"A of mix and the long short words greatly function challenges\"\n assert candidate(text = \"Innovative solutions require creative thinking processes\") == \"Require creative thinking solutions processes innovative\"\n assert candidate(text = \"Consistency is the bridge between goals and accomplishment\") == \"Is the and goals bridge between consistency accomplishment\"\n assert candidate(text = \"An apple a day keeps the doctor away\") == \"A an day the away apple keeps doctor\"\n assert candidate(text = \"The scent of blooming roses filled the tranquil garden\") == \"Of the the scent roses filled garden blooming tranquil\"\n assert candidate(text = \"In the end we will remember not the words of our enemies but the silence of our friends\") == \"In we of of the end not the our but the our will words enemies silence friends remember\"\n assert candidate(text = \"Edge cases like very long words or many short ones\") == \"Or edge like very long many ones cases words short\"\n assert candidate(text = \"The future belongs to those who believe in the beauty of their dreams\") == \"To in of the who the those their future beauty dreams belongs believe\"\n assert candidate(text = \"Innovative solutions drive technological advancement\") == \"Drive solutions innovative advancement technological\"\n", "comparison": "exact"}, "public_tests": ["\"Leetcode is cool\"", "\"Keep calm and code on\"", "\"To be or not to be\""], "hints": ["Store each word and their relative position. Then, sort them by length of words in case of tie by their original order."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().arrangeWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:35+00:00", "tests_total": 152, "tests_dropped": 0, "flags": ["figure_reference"], "topic_tags": ["string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def arrangeWords(self, text: str) -> str:", "container": "Solution", "callable": "arrangeWords", "parameters": [{"name": "text", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1452, "task_id": "people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list", "difficulty": "Medium", "problem_description": "Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).\n\nReturn the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.\n\nExample 1:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]\nOutput: [0,1,4]\nExplanation:\nPerson with index=2 has favoriteCompanies[2]=[\"google\",\"facebook\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] corresponding to the person with index 0.\nPerson with index=3 has favoriteCompanies[3]=[\"google\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] and favoriteCompanies[1]=[\"google\",\"microsoft\"].\nOther lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].\n\nExample 2:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]\nOutput: [0,1]\nExplanation: In this case favoriteCompanies[2]=[\"facebook\",\"google\"] is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"], therefore, the answer is [0,1].\n\nExample 3:\n\nInput: favoriteCompanies = [[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]\nOutput: [0,1,2,3]\n\nConstraints:\n\n- 1 <= favoriteCompanies.length <= 100\n- 1 <= favoriteCompanies[i].length <= 500\n- 1 <= favoriteCompanies[i][j].length <= 20\n- All strings in favoriteCompanies[i] are distinct.\n- All lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].\n- All strings consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon']]) == [0, 1, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['apple', 'facebook', 'google']]) == [3]\n assert candidate(favoriteCompanies = [['tech', 'innovation'], ['startup', 'tech'], ['innovation', 'startup', 'tech']]) == [2]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['leetcode', 'amazon'], ['facebook', 'google']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['facebook', 'microsoft']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['google', 'microsoft'], ['google', 'facebook'], ['google'], ['amazon']]) == [0, 1, 4]\n assert candidate(favoriteCompanies = [['apple', 'microsoft'], ['google'], ['apple', 'google', 'microsoft'], ['google', 'microsoft']]) == [2]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['banana'], ['apple', 'banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana'], ['apple', 'orange'], ['banana', 'orange'], ['apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry']]) == [0, 1, 2, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'google'], ['google'], ['apple', 'microsoft'], ['facebook']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry']]) == [1, 2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'kiwi']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google', 'microsoft'], ['google'], ['amazon', 'facebook'], ['apple', 'google', 'microsoft'], ['amazon', 'google', 'microsoft', 'apple', 'facebook']]) == []\n assert candidate(favoriteCompanies = [['airbnb', 'expedia', 'booking'], ['expedia', 'tripadvisor', 'kayak'], ['booking', 'tripadvisor', 'kayak'], ['airbnb', 'tripadvisor', 'kayak'], ['expedia', 'booking', 'tripadvisor'], ['airbnb', 'expedia', 'booking', 'tripadvisor', 'kayak']]) == [5]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'amazon'], ['google', 'facebook', 'apple'], ['amazon', 'google', 'microsoft', 'facebook'], ['google'], ['microsoft', 'facebook']]) == [0, 1, 2]\n assert candidate(favoriteCompanies = [['leetcode', 'google'], ['google'], ['google', 'facebook'], ['google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft', 'amazon'], ['amazon'], ['amazon', 'google'], ['amazon', 'facebook'], ['amazon', 'microsoft'], ['amazon', 'google', 'facebook', 'microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['linkedin', 'facebook', 'twitter'], ['linkedin', 'google', 'instagram'], ['facebook', 'instagram'], ['google', 'twitter'], ['facebook'], ['google'], ['twitter'], ['instagram'], ['linkedin'], ['facebook', 'google', 'instagram', 'twitter', 'linkedin']]) == [9]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date'], ['banana', 'date', 'apple'], ['apple', 'banana']]) == [3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini'], ['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon'], ['kiwi', 'lemon', 'mango'], ['lemon', 'mango', 'nectarine'], ['mango', 'nectarine', 'orange'], ['nectarine', 'orange', 'papaya'], ['orange', 'papaya', 'quince'], ['papaya', 'quince', 'raspberry'], ['quince', 'raspberry', 'strawberry'], ['raspberry', 'strawberry', 'tangerine'], ['strawberry', 'tangerine', 'ugli'], ['tangerine', 'ugli', 'vanilla'], ['ugli', 'vanilla', 'watermelon'], ['vanilla', 'watermelon', 'xigua'], ['watermelon', 'xigua', 'yam'], ['xigua', 'yam', 'zucchini']]) == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['a', 'b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h'], ['i'], ['j']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry'], ['apple', 'cherry'], ['banana', 'cherry', 'date', 'fig'], ['date', 'fig']]) == [0, 4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'careem'], ['careem', 'grab', 'gojek'], ['grab', 'uber', 'gojek'], ['gojek', 'grab'], ['careem', 'uber', 'lyft', 'grab', 'gojek']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'google'], ['google', 'microsoft'], ['facebook', 'google'], ['amazon', 'google', 'facebook'], ['microsoft', 'amazon'], ['amazon', 'facebook', 'google', 'microsoft'], ['apple', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['tech', 'science', 'arts'], ['science', 'arts', 'literature'], ['tech', 'science'], ['science'], ['tech'], ['arts'], ['literature'], ['arts', 'literature'], ['tech', 'arts', 'literature'], ['tech', 'science', 'literature']]) == [0, 1, 8, 9]\n assert candidate(favoriteCompanies = [['tesla', 'toyota', 'ford'], ['toyota', 'ford', 'gm'], ['tesla', 'toyota', 'gm'], ['ford', 'gm'], ['tesla', 'toyota', 'ford', 'gm'], ['tesla', 'gm']]) == [4]\n assert candidate(favoriteCompanies = [['p', 'q', 'r'], ['q', 'r', 's'], ['r', 's', 't'], ['s', 't', 'u'], ['t', 'u', 'v'], ['u', 'v', 'w'], ['v', 'w', 'x'], ['w', 'x', 'y'], ['x', 'y', 'z'], ['y', 'z', 'p'], ['z', 'p', 'q'], ['p', 'q', 'r', 's'], ['q', 'r', 's', 't'], ['r', 's', 't', 'u'], ['s', 't', 'u', 'v'], ['t', 'u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['v', 'w', 'x', 'y'], ['w', 'x', 'y', 'z'], ['x', 'y', 'z', 'p']]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon'], ['apple'], ['twitter'], ['youtube'], ['instagram'], ['snapchat'], ['linkedin']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook', 'amazon'], ['google', 'facebook', 'microsoft'], ['google', 'amazon'], ['amazon'], ['google'], ['facebook']]) == [0, 1]\n assert candidate(favoriteCompanies = [['netflix', 'amazon', 'hulu'], ['amazon', 'hbo', 'crunchyroll'], ['netflix', 'hbo', 'crunchyroll'], ['hulu', 'hbo', 'crunchyroll'], ['netflix', 'amazon', 'hbo', 'crunchyroll'], ['amazon', 'hbo']]) == [0, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'apple'], ['grape', 'apple', 'banana'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'apple', 'google', 'facebook'], ['google', 'microsoft'], ['facebook', 'apple'], ['apple', 'google', 'facebook'], ['microsoft', 'apple'], ['google', 'amazon'], ['amazon', 'facebook'], ['microsoft', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['twitter'], ['twitter', 'instagram'], ['twitter', 'facebook'], ['instagram', 'facebook'], ['twitter', 'instagram', 'facebook'], ['twitter', 'google'], ['google', 'facebook'], ['instagram', 'google'], ['twitter', 'instagram', 'google', 'facebook']]) == [8]\n assert candidate(favoriteCompanies = [['leetcode'], ['leetcode', 'google'], ['google', 'facebook'], ['leetcode', 'facebook'], ['facebook', 'amazon'], ['google', 'amazon', 'facebook'], ['leetcode', 'amazon', 'google', 'facebook']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['fig'], ['grape'], ['kiwi'], ['lemon'], ['mango'], ['orange']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['google', 'apple'], ['google', 'apple', 'facebook'], ['google', 'facebook'], ['apple', 'facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['google', 'amazon'], ['apple', 'amazon'], ['facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple', 'microsoft']]) == [9]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'google'], ['apple', 'google', 'amazon'], ['google', 'microsoft', 'apple'], ['facebook', 'google', 'amazon'], ['twitter', 'google', 'apple'], ['spotify', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['google', 'amazon', 'microsoft'], ['twitter', 'facebook', 'microsoft'], ['google', 'apple', 'facebook', 'microsoft', 'amazon', 'twitter', 'spotify']]) == [9]\n assert candidate(favoriteCompanies = [['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook'], ['google', 'amazon'], ['google', 'apple'], ['google', 'microsoft'], ['facebook', 'amazon'], ['facebook', 'apple'], ['facebook', 'microsoft'], ['amazon', 'apple'], ['amazon', 'microsoft'], ['apple', 'microsoft'], ['google'], ['facebook'], ['amazon'], ['apple'], ['microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech1', 'tech2'], ['tech2', 'tech3', 'tech4'], ['tech3', 'tech4', 'tech1'], ['tech4', 'tech1', 'tech2'], ['tech1', 'tech2', 'tech3']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['apple', 'banana'], ['banana', 'cherry'], ['apple', 'cherry'], ['date', 'fig', 'grape']]) == [0, 4]\n assert candidate(favoriteCompanies = [['x', 'y', 'z', 'w', 'v'], ['y', 'z'], ['z', 'w'], ['w', 'v'], ['v', 'x'], ['x', 'y'], ['y', 'z', 'w'], ['z', 'w', 'v'], ['w', 'v', 'x'], ['v', 'x', 'y'], ['x', 'y', 'z']]) == [0]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'deez', 'pandora'], ['apple', 'soundcloud', 'tidal'], ['deez', 'pandora', 'soundcloud'], ['spotify', 'soundcloud', 'tidal'], ['spotify', 'apple', 'deez', 'pandora', 'soundcloud', 'tidal']]) == [4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'grubhub'], ['grubhub', 'doorDash', 'postmates'], ['lyft', 'postmates', 'uber'], ['uber', 'lyft', 'grubhub', 'doorDash', 'postmates'], ['postmates', 'grubhub'], ['uber', 'grubhub', 'doorDash'], ['grubhub', 'lyft', 'uber', 'postmates'], ['doorDash', 'lyft']]) == [3]\n assert candidate(favoriteCompanies = [['pinterest', 'quora', 'reddit'], ['quora', 'snapchat', 'twitter'], ['facebook', 'google', 'instagram'], ['linkedin', 'pinterest', 'quora', 'reddit'], ['facebook', 'google', 'instagram', 'linkedin', 'pinterest'], ['pinterest', 'quora', 'reddit', 'snapchat', 'twitter'], ['instagram', 'linkedin', 'pinterest', 'quora', 'reddit']]) == [4, 5, 6]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech1', 'tech2'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech2', 'tech4'], ['tech1', 'tech3'], ['tech1', 'tech2', 'tech3'], ['tech2', 'tech3', 'tech4'], ['tech1', 'tech2', 'tech4']]) == [0]\n assert candidate(favoriteCompanies = [['techcrunch', 'theverge'], ['theverge', 'recode'], ['techcrunch', 'recode', 'theverge'], ['theverge', 'cnet'], ['recode', 'cnet', 'theverge'], ['techcrunch', 'cnet'], ['recode', 'cnet'], ['techcrunch', 'recode', 'theverge', 'cnet'], ['cnet', 'theverge'], ['recode', 'theverge', 'cnet'], ['techcrunch', 'theverge', 'cnet', 'recode'], ['cnet'], ['techcrunch'], ['recode']]) == []\n assert candidate(favoriteCompanies = [['xbox', 'playstation', 'nintendo'], ['nintendo', 'sega'], ['playstation', 'nintendo', 'sega'], ['xbox', 'nintendo'], ['playstation', 'sega'], ['xbox', 'playstation', 'nintendo', 'sega'], ['xbox', 'playstation'], ['nintendo']]) == [5]\n assert candidate(favoriteCompanies = [['microsoft', 'amazon', 'google'], ['google'], ['amazon'], ['microsoft'], ['google', 'amazon'], ['google', 'microsoft'], ['microsoft', 'amazon'], ['amazon', 'google'], ['google', 'microsoft', 'amazon'], ['google', 'microsoft', 'amazon', 'facebook']]) == [9]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['b', 'c'], ['c', 'd', 'e'], ['d', 'e', 'f'], ['e', 'f', 'g'], ['f', 'g', 'h'], ['g', 'h'], ['h']]) == [0]\n assert candidate(favoriteCompanies = [['amazon', 'ebay', 'google'], ['google', 'microsoft'], ['ebay', 'microsoft'], ['amazon', 'microsoft'], ['amazon', 'ebay', 'google', 'microsoft']]) == [4]\n assert candidate(favoriteCompanies = [['ibm', 'apple', 'microsoft'], ['apple', 'google', 'amazon'], ['ibm', 'google', 'amazon'], ['microsoft', 'amazon'], ['ibm', 'apple', 'google', 'amazon'], ['apple', 'microsoft', 'google'], ['ibm', 'google']]) == [0, 3, 4, 5]\n assert candidate(favoriteCompanies = [['facebook', 'instagram'], ['instagram', 'snapchat'], ['facebook', 'snapchat'], ['facebook', 'instagram', 'snapchat'], ['facebook'], ['snapchat'], ['instagram']]) == [3]\n assert candidate(favoriteCompanies = [['amazon', 'google', 'apple'], ['google', 'facebook', 'microsoft'], ['amazon', 'facebook', 'apple'], ['google', 'amazon', 'facebook', 'microsoft'], ['google', 'apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'elderberry'], ['elderberry', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'apple']]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry'], ['apple', 'banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry'], ['fig'], ['grape'], ['honeydew'], ['kiwi'], ['lemon'], ['mango'], ['nectarine'], ['orange'], ['papaya'], ['quince'], ['raspberry'], ['strawberry'], ['tangerine'], ['ugli'], ['vanilla'], ['watermelon'], ['xigua'], ['yam'], ['zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'date', 'elderberry'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'cherry', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango', 'nectarine']]) == [14, 15]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date']]) == [4]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['a', 'b'], ['b', 'c'], ['c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'c'], ['b', 'd'], ['c', 'e'], ['d', 'a'], ['e', 'b'], ['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e'], ['d', 'e', 'a'], ['e', 'a', 'b']]) == [0]\n assert candidate(favoriteCompanies = [['company1'], ['company2'], ['company3'], ['company4'], ['company5'], ['company6'], ['company7'], ['company8'], ['company9'], ['company10'], ['company11'], ['company12'], ['company13'], ['company14'], ['company15'], ['company16'], ['company17'], ['company18'], ['company19'], ['company20'], ['company21'], ['company22'], ['company23'], ['company24'], ['company25'], ['company26'], ['company27'], ['company28'], ['company29'], ['company30']]) == [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]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(favoriteCompanies = [['one', 'two', 'three'], ['two', 'three', 'four'], ['three', 'four', 'five'], ['four', 'five', 'six'], ['five', 'six', 'seven'], ['six', 'seven', 'eight'], ['seven', 'eight', 'nine'], ['eight', 'nine', 'ten'], ['nine', 'ten', 'one'], ['ten', 'one', 'two']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['honda', 'toyota', 'mazda'], ['toyota', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'nissan', 'mitsubishi'], ['mazda', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'mazda', 'nissan', 'mitsubishi']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google'], ['apple', 'facebook'], ['amazon', 'google'], ['facebook', 'google'], ['amazon', 'facebook', 'google'], ['apple', 'google']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [0, 1, 2, 3, 4, 5]\n assert candidate(favoriteCompanies = [['alibaba', 'tencent', 'jd'], ['tencent', 'xiami', 'sina'], ['jd', 'xiami', 'sina'], ['alibaba', 'tencent', 'jd', 'sina'], ['xiami', 'sina'], ['alibaba', 'jd']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date'], ['banana', 'cherry'], ['apple', 'cherry', 'date'], ['cherry', 'date'], ['apple', 'banana', 'cherry'], ['banana', 'date'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [6, 7, 8, 9, 10, 11]\n assert candidate(favoriteCompanies = [['google'], ['google', 'facebook'], ['google', 'facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple'], ['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix', 'spotify']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'google'], ['google', 'facebook'], ['leetcode', 'google', 'facebook'], ['google'], ['amazon'], ['microsoft', 'amazon'], ['amazon', 'google']]) == [0, 2, 5, 6]\n assert candidate(favoriteCompanies = [['apple', 'google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft'], ['apple', 'facebook', 'microsoft'], ['apple', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['apple', 'google'], ['apple', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['netflix', 'hulu'], ['hulu', 'crunchyroll'], ['netflix', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll', 'disney'], ['disney'], ['netflix'], ['hulu'], ['crunchyroll'], ['netflix', 'hulu', 'disney'], ['hulu', 'crunchyroll', 'disney'], ['netflix', 'crunchyroll', 'disney']]) == [4]\n assert candidate(favoriteCompanies = [['google', 'amazon', 'facebook'], ['google', 'amazon'], ['google'], ['amazon'], ['facebook'], ['google', 'facebook'], ['amazon', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['apple', 'cherry'], ['cherry'], ['apple', 'banana'], ['banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'google'], ['amazon', 'apple', 'microsoft'], ['apple', 'google'], ['google', 'microsoft'], ['facebook', 'google', 'microsoft', 'amazon'], ['apple', 'banana', 'cherry']]) == [0, 1, 4, 5]\n", "comparison": "exact"}, "public_tests": ["[[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]", "[[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]", "[[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]"], "hints": ["Use hashing to convert company names in numbers and then for each list check if this is a subset of any other list.", "In order to check if a list is a subset of another list, use two pointers technique to get a linear solution for this task. The total complexity will be O(n^2 * m) where n is the number of lists and m is the maximum number of elements in a list."], "metadata": {"canonical_parameter_names": ["favoriteCompanies"], "leetcode_dataset_entry_point": "Solution().peopleIndexes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:37+00:00", "tests_total": 79, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def peopleIndexes(self, favoriteCompanies: list[list[str]]) -> list[int]:", "container": "Solution", "callable": "peopleIndexes", "parameters": [{"name": "favoriteCompanies", "type": "list[list[str]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1453, "task_id": "maximum-number-of-darts-inside-of-a-circular-dartboard", "difficulty": "Hard", "problem_description": "Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [x_i, y_i] is the position of the i^th dart that Alice threw on the wall.\n\nBob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lie on the dartboard.\n\nGiven the integer r, return the maximum number of darts that can lie on the dartboard.\n\nExample 1:\n\nInput: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2\nOutput: 4\nExplanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.\n\nExample 2:\n\nInput: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5\nOutput: 5\nExplanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).\n\nConstraints:\n\n- 1 <= darts.length <= 100\n- darts[i].length == 2\n- -10^4 <= x_i, y_i <= 10^4\n- All the darts are unique\n- 1 <= r <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(darts = [[100, 100], [-100, -100], [0, 0]],r = 150) == 3\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3]],r = 1) == 3\n assert candidate(darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]],r = 5) == 5\n assert candidate(darts = [[-10000, 10000], [10000, -10000]],r = 5000) == 1\n assert candidate(darts = [[-1, -1], [1, 1], [-1, 1], [1, -1]],r = 2) == 4\n assert candidate(darts = [[-2, 2], [-3, 3], [-1, 1], [0, 0]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 1], [1.4, 1.4]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 0], [0, 10000], [10000, 10000]],r = 5000) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]],r = 1) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 1) == 2\n assert candidate(darts = [[1000, -1000], [-1000, 1000], [0, 0]],r = 1500) == 3\n assert candidate(darts = [[-5, 0], [5, 0], [0, 5], [0, -5]],r = 5) == 4\n assert candidate(darts = [[0, 0], [10, 0], [0, 10], [10, 10]],r = 7) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]],r = 1) == 3\n assert candidate(darts = [[-5, -5], [5, 5], [-5, 5], [5, -5]],r = 7) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 3) == 4\n assert candidate(darts = [[-1, 0], [0, 1], [1, 0], [0, -1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]],r = 2) == 5\n assert candidate(darts = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],r = 1) == 2\n assert candidate(darts = [[-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2]],r = 1) == 2\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [0, 1]],r = 1) == 3\n assert candidate(darts = [[-2, 0], [2, 0], [0, 2], [0, -2]],r = 2) == 4\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5]],r = 1) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1) == 2\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, -5000], [0, 5000], [2500, 2500]],r = 5000) == 5\n assert candidate(darts = [[-2, -2], [-2, 0], [-2, 2], [0, -2], [0, 0], [0, 2], [2, -2], [2, 0], [2, 2]],r = 2) == 5\n assert candidate(darts = [[-200, 200], [-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100], [200, -200], [50, 150], [150, 50], [-150, -50], [-50, -150]],r = 150) == 7\n assert candidate(darts = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]],r = 5) == 2\n assert candidate(darts = [[-10000, 10000], [10000, -10000], [0, 0], [5000, 5000], [-5000, -5000]],r = 5000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 5) == 4\n assert candidate(darts = [[-1, 0], [1, 0], [0, -1], [0, 1], [0.5, 0.5], [-0.5, -0.5], [0.5, -0.5], [-0.5, 0.5]],r = 1) == 8\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],r = 2) == 5\n assert candidate(darts = [[-2, 2], [-2, -2], [2, 2], [2, -2], [0, 0], [0, 4], [4, 0], [4, 4]],r = 4) == 7\n assert candidate(darts = [[100, 100], [200, 200], [150, 150], [50, 50], [300, 300]],r = 150) == 4\n assert candidate(darts = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],r = 5) == 4\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [5, 5], [5, 7], [7, 5], [7, 7], [9, 9], [9, 11]],r = 2.83) == 5\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],r = 10) == 3\n assert candidate(darts = [[-1000, -1000], [1000, 1000], [1000, -1000], [-1000, 1000], [0, 0]],r = 1414) == 3\n assert candidate(darts = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]],r = 500) == 4\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 150) == 3\n assert candidate(darts = [[0, 0], [5000, 0], [0, 5000], [5000, 5000], [2500, 2500]],r = 3000) == 3\n assert candidate(darts = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],r = 4) == 6\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, -1000], [1000, 1000], [0, 0]],r = 1500) == 5\n assert candidate(darts = [[-500, -500], [-250, -250], [0, 0], [250, 250], [500, 500], [-500, 500], [500, -500]],r = 500) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],r = 4) == 9\n assert candidate(darts = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3]],r = 2) == 7\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 150) == 4\n assert candidate(darts = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],r = 5) == 5\n assert candidate(darts = [[0, 0], [10, 0], [5, 5]],r = 10) == 3\n assert candidate(darts = [[100, 100], [200, 100], [100, 200], [200, 200], [150, 150], [125, 125], [175, 175]],r = 50) == 4\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[0, 0], [50, 0], [100, 0], [150, 0], [200, 0], [250, 0], [300, 0], [350, 0], [400, 0], [450, 0], [500, 0]],r = 200) == 9\n assert candidate(darts = [[100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [100, 200], [200, 300]],r = 100) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 5000) == 5\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 0], [0, 1], [1, 1], [0.5, 0.5]],r = 1) == 5\n assert candidate(darts = [[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0]],r = 1) == 3\n assert candidate(darts = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0]],r = 10) == 3\n assert candidate(darts = [[-2000, -2000], [-1000, -1000], [0, 0], [1000, 1000], [2000, 2000], [1000, 0], [0, 1000]],r = 1414) == 4\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-4500, -4500], [-3000, -3000], [-5500, -5500]],r = 1000) == 3\n assert candidate(darts = [[-1, -1], [0, -1], [1, -1], [-1, 0], [0, 0], [1, 0], [-1, 1], [0, 1], [1, 1]],r = 1) == 5\n assert candidate(darts = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],r = 8) == 3\n assert candidate(darts = [[-100, -100], [-100, 100], [100, -100], [100, 100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10], [-6, -12], [-7, -14]],r = 3) == 3\n assert candidate(darts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000], [500, 500], [-500, 500], [500, -500], [-500, -500]],r = 1000) == 8\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, 1000], [1000, -1000], [0, 0], [500, 500]],r = 1000) == 4\n assert candidate(darts = [[-10, 0], [0, -10], [10, 0], [0, 10], [0, 0], [5, 5], [-5, -5], [-5, 5], [5, -5]],r = 15) == 9\n assert candidate(darts = [[-10, -10], [-10, 0], [-10, 10], [0, -10], [0, 0], [0, 10], [10, -10], [10, 0], [10, 10]],r = 15) == 9\n assert candidate(darts = [[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5]],r = 10) == 6\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [0, 0]],r = 10) == 5\n assert candidate(darts = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],r = 50) == 8\n assert candidate(darts = [[0, 0], [0, 100], [0, 200], [0, 300], [0, 400], [0, 500], [0, 600], [0, 700], [0, 800], [0, 900]],r = 150) == 4\n assert candidate(darts = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],r = 15) == 3\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50]],r = 15) == 5\n assert candidate(darts = [[-2000, -2000], [-2000, 2000], [2000, -2000], [2000, 2000], [0, 0]],r = 2500) == 3\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, 5000], [0, -5000]],r = 5000) == 4\n assert candidate(darts = [[-2, -2], [-2, 2], [2, -2], [2, 2], [0, 0], [-1, 1], [1, -1], [-1, -1], [1, 1]],r = 3) == 9\n assert candidate(darts = [[1, 1], [1, 5], [5, 5], [5, 1], [3, 3], [2, 2], [4, 4], [2, 3], [3, 2], [4, 3], [3, 4]],r = 2) == 8\n assert candidate(darts = [[-500, 0], [-400, 0], [-300, 0], [-200, 0], [-100, 0], [0, 0], [100, 0], [200, 0], [300, 0], [400, 0]],r = 100) == 3\n assert candidate(darts = [[-10, 10], [10, -10], [-10, -10], [10, 10], [0, 0]],r = 20) == 5\n assert candidate(darts = [[1000, 1000], [1500, 1000], [1000, 1500], [1500, 1500], [2500, 2500]],r = 1000) == 4\n assert candidate(darts = [[-1000, 1000], [-500, 500], [0, 0], [500, -500], [1000, -1000]],r = 1500) == 5\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],r = 150) == 3\n assert candidate(darts = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],r = 5) == 4\n assert candidate(darts = [[-20, 20], [-20, -20], [20, 20], [20, -20], [0, 0], [0, 40], [40, 0], [40, 40], [50, 50]],r = 50) == 9\n assert candidate(darts = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]],r = 1) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 1000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],r = 5) == 4\n assert candidate(darts = [[-5000, 5000], [5000, -5000], [-5000, -5000], [5000, 5000], [0, 0]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 100) == 3\n assert candidate(darts = [[1000, -1000], [1500, -1000], [2000, -1000], [1000, -1500], [1000, -2000]],r = 500) == 3\n assert candidate(darts = [[1000, 1000], [1001, 1001], [1002, 1002], [1003, 1003], [1004, 1004], [1005, 1005], [1006, 1006], [1007, 1007], [1008, 1008], [1009, 1009]],r = 1) == 2\n assert candidate(darts = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3]],r = 2) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],r = 3) == 7\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1, 1]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [0, 10], [10, 0], [10, 10]],r = 7) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],r = 2) == 3\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 1) == 1\n assert candidate(darts = [[-1000, 1000], [1000, -1000], [500, 500], [-500, -500]],r = 1000) == 3\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [2, 2], [4, 4], [4, 5], [5, 4]],r = 1) == 3\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-3000, -3000], [-2000, -2000], [-1000, -1000]],r = 1000) == 2\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]],r = 2) == 5\n assert candidate(darts = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15]],r = 7) == 2\n assert candidate(darts = [[-100, -100], [100, 100], [-100, 100], [100, -100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],r = 1) == 5\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 100) == 2\n assert candidate(darts = [[100, 100], [101, 100], [102, 102], [102, 101], [101, 102]],r = 2) == 5\n assert candidate(darts = [[0, 0], [5, 0], [5, 5], [0, 5], [2.5, 2.5]],r = 3) == 3\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]],r = 1) == 4\n assert candidate(darts = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]],r = 3) == 3\n assert candidate(darts = [[-1000, 1000], [-900, 1100], [-800, 1200], [-700, 1300], [-600, 1400], [-500, 1500], [-400, 1600], [-300, 1700]],r = 200) == 3\n assert candidate(darts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],r = 50) == 4\n assert candidate(darts = [[-2000, -2000], [2000, 2000], [0, 0], [1000, -1000], [-1000, 1000]],r = 2500) == 4\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]],r = 100) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1.5) == 3\n assert candidate(darts = [[500, 500], [500, 600], [600, 500], [600, 600], [300, 300], [300, 400], [400, 300], [400, 400]],r = 141) == 4\n assert candidate(darts = [[-5, 5], [5, 5], [5, -5], [-5, -5], [0, 0]],r = 5) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],r = 1) == 4\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2]],r = 1.5) == 9\n", "comparison": "exact"}, "public_tests": ["[[-2,0],[2,0],[0,2],[0,-2]]\n2", "[[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]]\n5"], "hints": ["If there is an optimal solution, you can always move the circle so that two points lie on the boundary of the circle.", "When the radius is fixed, you can find either 0 or 1 or 2 circles that pass two given points at the same time.", "Loop for each pair of points and find the center of the circle, after that count the number of points inside the circle."], "metadata": {"canonical_parameter_names": ["darts", "r"], "leetcode_dataset_entry_point": "Solution().numPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:39+00:00", "tests_total": 130, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "python", "interface": {"raw_signature": "def numPoints(self, darts: list[list[int]], r: int) -> int:", "container": "Solution", "callable": "numPoints", "parameters": [{"name": "darts", "type": "list[list[int]]"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1455, "task_id": "check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence", "difficulty": "Easy", "problem_description": "Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.\n\nReturn the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.\n\nA prefix of a string s is any leading contiguous substring of s.\n\nExample 1:\n\nInput: sentence = \"i love eating burger\", searchWord = \"burg\"\nOutput: 4\nExplanation: \"burg\" is prefix of \"burger\" which is the 4th word in the sentence.\n\nExample 2:\n\nInput: sentence = \"this problem is an easy problem\", searchWord = \"pro\"\nOutput: 2\nExplanation: \"pro\" is prefix of \"problem\" which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.\n\nExample 3:\n\nInput: sentence = \"i am tired\", searchWord = \"you\"\nOutput: -1\nExplanation: \"you\" is not a prefix of any word in the sentence.\n\nConstraints:\n\n- 1 <= sentence.length <= 100\n- 1 <= searchWord.length <= 10\n- sentence consists of lowercase English letters and spaces.\n- searchWord consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"a ab abc abd\",searchWord = \"a\") == 1\n assert candidate(sentence = \"abcde fghij klmno\",searchWord = \"mnop\") == -1\n assert candidate(sentence = \"find prefix quickly\",searchWord = \"qui\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix test\",searchWord = \"testprefix\") == -1\n assert candidate(sentence = \"hello world\",searchWord = \"he\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"coding in python is fun\",searchWord = \"py\") == 3\n assert candidate(sentence = \"i love eating burger\",searchWord = \"burg\") == 4\n assert candidate(sentence = \"prefix prefixation prefixed pre\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"i am tired\",searchWord = \"you\") == -1\n assert candidate(sentence = \"example test case\",searchWord = \"exa\") == 1\n assert candidate(sentence = \"start end\",searchWord = \"sta\") == 1\n assert candidate(sentence = \"no match here\",searchWord = \"none\") == -1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qui\") == 2\n assert candidate(sentence = \"coding in python\",searchWord = \"py\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"fix\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"test\") == 2\n assert candidate(sentence = \"abc def ghi\",searchWord = \"def\") == 2\n assert candidate(sentence = \"no matches here\",searchWord = \"match\") == 2\n assert candidate(sentence = \"all words unique\",searchWord = \"word\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaa\") == 3\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"a\") == 1\n assert candidate(sentence = \"unique words only here\",searchWord = \"word\") == 2\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"one two three\",searchWord = \"four\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"tes\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aa\") == 2\n assert candidate(sentence = \"make america great again\",searchWord = \"am\") == 2\n assert candidate(sentence = \"prefix is the start\",searchWord = \"start\") == 4\n assert candidate(sentence = \"a b c d e f g\",searchWord = \"g\") == 7\n assert candidate(sentence = \"find the prefix\",searchWord = \"pre\") == 3\n assert candidate(sentence = \"this problem is an easy problem\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"last word match\",searchWord = \"match\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a ab abc abcd abcde\",searchWord = \"abc\") == 3\n assert candidate(sentence = \"mississippi missouri\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaaa\") == -1\n assert candidate(sentence = \"multiple matches match matcher matching\",searchWord = \"mat\") == 2\n assert candidate(sentence = \"introduction to the world of algorithms and datastructures\",searchWord = \"data\") == 8\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\",searchWord = \"abc\") == 1\n assert candidate(sentence = \"mississippi missouri missing\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"prefix is present in the prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"unique words only unique\",searchWord = \"uniq\") == 1\n assert candidate(sentence = \"look at these examples\",searchWord = \"these\") == 3\n assert candidate(sentence = \"unique words only here\",searchWord = \"only\") == 3\n assert candidate(sentence = \"prefix suffix prefixsuffix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"testing for edge cases with different words\",searchWord = \"dif\") == 6\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"ten\") == 10\n assert candidate(sentence = \"aaaaa aaaaa aaaaa aaaaa\",searchWord = \"aaaa\") == 1\n assert candidate(sentence = \"algorithm datastructure code compiler bytecode\",searchWord = \"byte\") == 5\n assert candidate(sentence = \"finding exact match in the sentence\",searchWord = \"exac\") == 2\n assert candidate(sentence = \"hello world from the other side\",searchWord = \"from\") == 3\n assert candidate(sentence = \"singleword\",searchWord = \"single\") == 1\n assert candidate(sentence = \"this is a very very long sentence to test the code properly\",searchWord = \"very\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix\",searchWord = \"same\") == 5\n assert candidate(sentence = \"prefix testing with prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"overlap overlapping overlapped overlap\",searchWord = \"overl\") == 1\n assert candidate(sentence = \"find the correct index\",searchWord = \"cor\") == 3\n assert candidate(sentence = \"python programming is powerful\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"boundary conditions need testing\",searchWord = \"test\") == 4\n assert candidate(sentence = \"algorithm and data structures are important\",searchWord = \"and\") == 2\n assert candidate(sentence = \"substring matching problem\",searchWord = \"match\") == 2\n assert candidate(sentence = \"pneumonoultramicroscopicsilicovolcanoconiosis pneumonoultramicroscopicsilicovolcanoconiosis\",searchWord = \"pneumono\") == 1\n assert candidate(sentence = \"hello world hello universe\",searchWord = \"he\") == 1\n assert candidate(sentence = \"algorithm datastructure programming language compiler\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"uniquewordsinthesentence\",searchWord = \"words\") == -1\n assert candidate(sentence = \"prefixprefixprefixprefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 1\n assert candidate(sentence = \"continuous conversation connection component\",searchWord = \"con\") == 1\n assert candidate(sentence = \"small big medium small\",searchWord = \"sm\") == 1\n assert candidate(sentence = \"algorithm and data structures\",searchWord = \"alg\") == 1\n assert candidate(sentence = \"prefix problem prefixing prefixer\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"short longword reallylongword evenlongerword\",searchWord = \"long\") == 2\n assert candidate(sentence = \"binary search quicksort mergesort heapsort\",searchWord = \"sort\") == -1\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"aaaaa aaaa aa a\",searchWord = \"a\") == 1\n assert candidate(sentence = \"prefix search in a list of words\",searchWord = \"sea\") == 2\n assert candidate(sentence = \"testing boundary conditions\",searchWord = \"boundary\") == 2\n assert candidate(sentence = \"testing edgecases with variouslengthwords\",searchWord = \"var\") == 4\n assert candidate(sentence = \"very very long sentence with many words to test the function\",searchWord = \"very\") == 1\n assert candidate(sentence = \"repeated repeated repeated\",searchWord = \"rep\") == 1\n assert candidate(sentence = \"searching for a longprefixword\",searchWord = \"longprefix\") == 4\n assert candidate(sentence = \"an apple a day keeps the doctor away\",searchWord = \"app\") == 2\n assert candidate(sentence = \"sun moon stars planets galaxies blackholes nebulas\",searchWord = \"black\") == 6\n assert candidate(sentence = \"every good boy does fine great boys deserve fine gifts\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"abcdefgh abcdefghij abcdefghijk abcdefghijkl\",searchWord = \"abcdefg\") == 1\n assert candidate(sentence = \"another example to check\",searchWord = \"to\") == 3\n assert candidate(sentence = \"this is a simple test to check for prefix matching\",searchWord = \"tes\") == 5\n assert candidate(sentence = \"searching for exact prefix\",searchWord = \"sea\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"this is a simple sentence for testing\",searchWord = \"simple\") == 4\n assert candidate(sentence = \"hiddenprefixword is here\",searchWord = \"hidden\") == 1\n assert candidate(sentence = \"banana apple banana apple banana\",searchWord = \"ba\") == 1\n assert candidate(sentence = \"words with multiple spaces\",searchWord = \"mul\") == 3\n assert candidate(sentence = \"algorithm datastructure programming language\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"prefixprefixprefixprefixprefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"complex problem requiring careful thought\",searchWord = \"com\") == 1\n assert candidate(sentence = \"random words with no match\",searchWord = \"nomatch\") == -1\n assert candidate(sentence = \"python programming py pyth pytho\",searchWord = \"py\") == 1\n assert candidate(sentence = \"abcd efgh ijkl mnop qrst uvwx yz\",searchWord = \"yz\") == 7\n assert candidate(sentence = \"findingprefixsinthesentence\",searchWord = \"finding\") == 1\n assert candidate(sentence = \"prefix matching is important for search engines\",searchWord = \"search\") == 6\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abra\") == 1\n assert candidate(sentence = \"nonmatchingprefix prefix\",searchWord = \"non\") == 1\n assert candidate(sentence = \"finding the first occurrence firstness\",searchWord = \"fir\") == 3\n assert candidate(sentence = \"prefix matching problem prefixing preposition\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"none of these should match\",searchWord = \"non\") == 1\n assert candidate(sentence = \"prefix prefixing prefixation prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"multiple occurrences of a word word\",searchWord = \"word\") == 5\n assert candidate(sentence = \"all words are different\",searchWord = \"dif\") == 4\n assert candidate(sentence = \"prefixes are important in computer science\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"mismatch mismatching mismatches\",searchWord = \"mis\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"xy xxy xxxy xxxxy xxxxyy xxxxyyy\",searchWord = \"xxxxy\") == 4\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"dog\") == 9\n assert candidate(sentence = \"repeated repeated repeated repeated\",searchWord = \"repeat\") == 1\n assert candidate(sentence = \"quick brown fox jumps over lazy dog\",searchWord = \"quic\") == 1\n assert candidate(sentence = \"prefixprefixprefix prefixprefix prefix pre prefixing\",searchWord = \"prefixp\") == 1\n assert candidate(sentence = \"ab ac ad ae af ag ah ai aj\",searchWord = \"a\") == 1\n assert candidate(sentence = \"this is a simple test case\",searchWord = \"sim\") == 4\n assert candidate(sentence = \"prefixprefix prefixprefixer prefixprefixing\",searchWord = \"prefixpre\") == 1\n assert candidate(sentence = \"unique words with no match\",searchWord = \"xyz\") == -1\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abrac\") == 1\n assert candidate(sentence = \"continuous integration and continuous delivery\",searchWord = \"cont\") == 1\n assert candidate(sentence = \"searching for the prefix within\",searchWord = \"with\") == 5\n assert candidate(sentence = \"consecutive words with same start\",searchWord = \"con\") == 1\n assert candidate(sentence = \"short long longer longest\",searchWord = \"long\") == 2\n assert candidate(sentence = \"consistent consistent consistency consistently\",searchWord = \"consist\") == 1\n assert candidate(sentence = \"a short simple sentence\",searchWord = \"shor\") == 2\n assert candidate(sentence = \"searching for a unique prefix\",searchWord = \"uniq\") == 4\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"fox\") == 4\n assert candidate(sentence = \"programming is fun and educational\",searchWord = \"edu\") == 5\n assert candidate(sentence = \"finding the veryfirst occurrence\",searchWord = \"ver\") == 3\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 2\n assert candidate(sentence = \"prefix prefixing prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"boundary conditions are tricky\",searchWord = \"tri\") == 4\n assert candidate(sentence = \"complexity of the problem\",searchWord = \"com\") == 1\n assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"searching for a specific word\",searchWord = \"spec\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix prefix prefix\",searchWord = \"pre\") == 6\n assert candidate(sentence = \"ab abc abcd abcde abcdef abcdefg abcdefgh abcdefghi abcdefghij\",searchWord = \"abcde\") == 4\n assert candidate(sentence = \"partial match is not allowed\",searchWord = \"parti\") == 1\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\",searchWord = \"z\") == 26\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"nine\") == 9\n assert candidate(sentence = \"prefixes prefixing prefix pre prefixed\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"prefix prefixing prefixed pre prefixable\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a a aa aa aaa\",searchWord = \"aaa\") == 5\n assert candidate(sentence = \"looking for a specific starting sequence\",searchWord = \"spe\") == 4\n assert candidate(sentence = \"algorithm data structure and algorithm\",searchWord = \"algo\") == 1\n assert candidate(sentence = \"overlapwording overlapword overlap\",searchWord = \"overlap\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"the\") == 1\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"shorter is better\",searchWord = \"short\") == 1\n assert candidate(sentence = \"algorithms and data structures\",searchWord = \"and\") == 2\n assert candidate(sentence = \"interview question with multiple prefixes prefix\",searchWord = \"pre\") == 5\n assert candidate(sentence = \"banana bandana band breadth\",searchWord = \"ban\") == 1\n assert candidate(sentence = \"algorithms and data structures are fundamental\",searchWord = \"data\") == 3\n assert candidate(sentence = \"practice makes perfect in programming\",searchWord = \"per\") == 3\n assert candidate(sentence = \"verylongwordthatwilltesttheboundariesofthisfunction\",searchWord = \"verylong\") == 1\n assert candidate(sentence = \"longerprefix longerpre long pre\",searchWord = \"longerpre\") == 1\n assert candidate(sentence = \"this is a simple sentence with repeated words repeated words\",searchWord = \"repe\") == 7\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"multiple occurrences of words words\",searchWord = \"words\") == 4\n assert candidate(sentence = \"double double double trouble\",searchWord = \"double\") == 1\n assert candidate(sentence = \"complicated complex complication\",searchWord = \"comp\") == 1\n assert candidate(sentence = \"banana bandana bandanna banana bandana\",searchWord = \"band\") == 2\n", "comparison": "exact"}, "public_tests": ["\"i love eating burger\"\n\"burg\"", "\"this problem is an easy problem\"\n\"pro\"", "\"i am tired\"\n\"you\""], "hints": ["First extract the words of the sentence.", "Check for each word if searchWord occurs at index 0, if so return the index of this word (1-indexed)", "If searchWord doesn't exist as a prefix of any word return the default value (-1)."], "metadata": {"canonical_parameter_names": ["sentence", "searchWord"], "leetcode_dataset_entry_point": "Solution().isPrefixOfWord", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:42+00:00", "tests_total": 172, "tests_dropped": 3, "flags": [], "topic_tags": ["two-pointers", "string", "string-matching"]}, "language": "python", "interface": {"raw_signature": "def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:", "container": "Solution", "callable": "isPrefixOfWord", "parameters": [{"name": "sentence", "type": "str"}, {"name": "searchWord", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1456, "task_id": "maximum-number-of-vowels-in-a-substring-of-given-length", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.\n\nVowel letters in English are 'a', 'e', 'i', 'o', and 'u'.\n\nExample 1:\n\nInput: s = \"abciiidef\", k = 3\nOutput: 3\nExplanation: The substring \"iii\" contains 3 vowel letters.\n\nExample 2:\n\nInput: s = \"aeiou\", k = 2\nOutput: 2\nExplanation: Any substring of length 2 contains 2 vowels.\n\nExample 3:\n\nInput: s = \"leetcode\", k = 3\nOutput: 2\nExplanation: \"lee\", \"eet\" and \"ode\" contain 2 vowels.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n- 1 <= k <= s.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aooiiieeec\",k = 6) == 6\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"happy\",k = 2) == 1\n assert candidate(s = \"rhythms\",k = 5) == 0\n assert candidate(s = \"fluffy\",k = 2) == 1\n assert candidate(s = \"leetcode\",k = 3) == 2\n assert candidate(s = \"aeiou\",k = 2) == 2\n assert candidate(s = \"beautiful\",k = 4) == 3\n assert candidate(s = \"rhythms\",k = 4) == 0\n assert candidate(s = \"bbbb\",k = 2) == 0\n assert candidate(s = \"aaaaaa\",k = 5) == 5\n assert candidate(s = \"abciiidef\",k = 3) == 3\n assert candidate(s = \"aabbccddeeff\",k = 4) == 2\n assert candidate(s = \"quartz\",k = 3) == 2\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 5) == 5\n assert candidate(s = \"eiuaooeiuaooeiuaooeiuaoo\",k = 8) == 8\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 3) == 0\n assert candidate(s = \"understanding\",k = 4) == 2\n assert candidate(s = \"abacabadabacaba\",k = 5) == 3\n assert candidate(s = \"aeiouaeiou\",k = 1) == 1\n assert candidate(s = \"bbbbbbaaaaa\",k = 5) == 5\n assert candidate(s = \"bbaeixixixixxxeiiixieeiix\",k = 15) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"uoieaouieaouieaouieaouieaouieao\",k = 15) == 15\n assert candidate(s = \"mississippi\",k = 4) == 2\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiou\",k = 20) == 20\n assert candidate(s = \"iouaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == 50\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 12) == 4\n assert candidate(s = \"xyzvowelsabcdefg\",k = 5) == 2\n assert candidate(s = \"leetcodeisawesome\",k = 5) == 3\n assert candidate(s = \"lovelaceeinstein\",k = 7) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13) == 3\n assert candidate(s = \"thisisaverylongstringwithsomevowelsinside\",k = 20) == 8\n assert candidate(s = \"aaaaaaaabbbbbbbbcccccccc\",k = 12) == 8\n assert candidate(s = \"bbaeiooacaioiiceiue\",k = 11) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 6\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiou\",k = 10) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"uvvwxyz\",k = 3) == 1\n assert candidate(s = \"abcdeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouieaouieaouieaouieaouiea\",k = 7) == 7\n assert candidate(s = \"mnoabcdeioufghijkl\",k = 7) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 15) == 4\n assert candidate(s = \"leetcodeisaverygoodplatform\",k = 10) == 6\n assert candidate(s = \"ababababab\",k = 5) == 3\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 30) == 30\n assert candidate(s = \"bcdafg\",k = 6) == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaa\",k = 10) == 10\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 1) == 0\n assert candidate(s = \"thisisaverylongstringwithseveralvowelsinside\",k = 15) == 6\n assert candidate(s = \"aiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioiei\",k = 20) == 20\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouioeaouioeaouioe\",k = 12) == 12\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 7) == 7\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbc\",k = 7) == 0\n assert candidate(s = \"uqeiouqeiouqeiouqeiouqeiouqe\",k = 11) == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 3\n assert candidate(s = \"qqqwwweee\",k = 4) == 3\n assert candidate(s = \"bbaeixoubb\",k = 5) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == 5\n assert candidate(s = \"aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiioooooooouuuuuuuuuuuaaaaaaaa\",k = 25) == 25\n assert candidate(s = \"bvflkqmbvkjgnqmfqlqjflvngqnvfkvnqjvfbvmqjbfvmlkjbfnvqjgbfnvqjbngfjkqnvbmfkqjbgfnjkbv\",k = 10) == 0\n assert candidate(s = \"vowelsarebeautiful\",k = 10) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 15) == 0\n assert candidate(s = \"bcbcbcbcbcbaaaaaa\",k = 10) == 6\n assert candidate(s = \"aeiaaioaaaaeiiiiiiooooaauuaeiu\",k = 15) == 15\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 8) == 0\n assert candidate(s = \"thisisaverylongstringwithlotsofvowelsandconsonants\",k = 18) == 7\n assert candidate(s = \"environmentally\",k = 10) == 4\n assert candidate(s = \"leetcodeisacommunityforcoders\",k = 8) == 5\n assert candidate(s = \"leetcodeisfun\",k = 7) == 4\n assert candidate(s = \"leetcodeisawesome\",k = 7) == 4\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 10) == 0\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 5) == 3\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 3) == 0\n assert candidate(s = \"uoieaooooieau\",k = 7) == 7\n assert candidate(s = \"abecidofugihanukleomnonuopqrstuvwxyz\",k = 20) == 10\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuu\",k = 12) == 12\n", "comparison": "exact"}, "public_tests": ["\"abciiidef\"\n3", "\"aeiou\"\n2", "\"leetcode\"\n3"], "hints": ["Keep a window of size k and maintain the number of vowels in it.", "Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxVowels", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:44+00:00", "tests_total": 80, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def maxVowels(self, s: str, k: int) -> int:", "container": "Solution", "callable": "maxVowels", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1458, "task_id": "max-dot-product-of-two-subsequences", "difficulty": "Hard", "problem_description": "Given two arrays nums1 and nums2.\n\nReturn the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.\n\nA subsequence of an array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, [2,3,5] is a subsequence of [1,2,3,4,5] while [1,5,3] is not).\n\nExample 1:\n\nInput: nums1 = [2,1,-2,5], nums2 = [3,0,-6]\nOutput: 18\nExplanation: Take subsequence [2,-2] from nums1 and subsequence [3,-6] from nums2.\nTheir dot product is (2*3 + (-2)*(-6)) = 18.\n\nExample 2:\n\nInput: nums1 = [3,-2], nums2 = [2,-6,7]\nOutput: 21\nExplanation: Take subsequence [3] from nums1 and subsequence [7] from nums2.\nTheir dot product is (3*7) = 21.\n\nExample 3:\n\nInput: nums1 = [-1,-1], nums2 = [1,1]\nOutput: -1\nExplanation: Take subsequence [-1] from nums1 and subsequence [1] from nums2.\nTheir dot product is -1.\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 500\n- -1000 <= nums1[i], nums2[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1]) == 2\n assert candidate(nums1 = [2, 1, -2, 5],nums2 = [3, 0, -6]) == 18\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 3, -5, 4],nums2 = [-2, -4, 0, 3]) == 32\n assert candidate(nums1 = [-1, -1],nums2 = [1, 1]) == -1\n assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == 1000000\n assert candidate(nums1 = [-1000, 1000],nums2 = [-1000, 1000]) == 2000000\n assert candidate(nums1 = [5, 4, -3],nums2 = [4, -1, -2]) == 26\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1000],nums2 = [-1000]) == -1000000\n assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [5, 6, 7, 8, 9]) == 80\n assert candidate(nums1 = [-1000],nums2 = [1000]) == -1000000\n assert candidate(nums1 = [3, -2],nums2 = [2, -6, 7]) == 21\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [-3, -2, -1, 0]) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 12\n assert candidate(nums1 = [1, 2, 3],nums2 = [-5, -4, -3]) == -3\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 32\n assert candidate(nums1 = [5, 4, 3],nums2 = [1, 2, 3]) == 22\n assert candidate(nums1 = [5, 5, 2, 1, 5],nums2 = [1, 2, 4, 2, 5]) == 59\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [999, -999, 999, -999, 999],nums2 = [-999, 999, -999, 999, -999]) == 3992004\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums1 = [5, 2, -4, 7, -8],nums2 = [3, -1, 6, -3, 2]) == 85\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4]) == 0\n assert candidate(nums1 = [1, -1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [5, 3, -4, 2, 1],nums2 = [-2, 6, 3, -5, 4]) == 67\n assert candidate(nums1 = [5, 3, -2, 4],nums2 = [1, 2, 3, 4, 5]) == 47\n assert candidate(nums1 = [100, -100, 200, -200, 300],nums2 = [1, -1, 2, -2, 3]) == 1900\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]) == 90\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [-100, 100, -200, 200]) == 70000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-1, -2, -3, -4, -5]) == -10\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [1, 2, 3, 4, 5]) == -10\n assert candidate(nums1 = [999, 1000, -999, -1000],nums2 = [-999, 999, -1000, 1000]) == 1999000\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]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-10, -20, -30, -40, -50]) == -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]) == 320\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]) == 81\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums1 = [5, -10, 15, -20, 25],nums2 = [-5, 10, -15, 20]) == 1000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [100, -100, 200, -200, 300, -300],nums2 = [10, -10, 20, -20, 30, -30]) == 28000\n assert candidate(nums1 = [0, 1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1, 0]) == 24\n assert candidate(nums1 = [5, -3, 10, 2, -7],nums2 = [8, 4, -2, 6, 1]) == 108\n assert candidate(nums1 = [-500, -400, -300, -200, -100],nums2 = [100, 200, 300, 400, 500]) == -10000\n assert candidate(nums1 = [-5, -3, -2, -4],nums2 = [-1, -2, -3, -4, -5]) == 47\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]) == 1029\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 74\n assert candidate(nums1 = [100, 0, 200, 0, 300, 0, 400, 0, 500, 0],nums2 = [0, 500, 0, 400, 0, 300, 0, 200, 0, 100]) == 460000\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9]) == 190\n assert candidate(nums1 = [10, -10, 20, -20, 30],nums2 = [30, -30, 20, -20, 10]) == 1800\n assert candidate(nums1 = [-1, 0, 1, 0, -1],nums2 = [-1, 0, 1, 0, -1]) == 3\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [5, -3, 8, -1, 7],nums2 = [-2, 4, 1, -5, 3]) == 64\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3]) == 56\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [-100, -200, -300, -400, -500]) == -10000\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [10, 20, 30, 40, 50]) == 114000\n assert candidate(nums1 = [5, -3, 2, 1, 6],nums2 = [-1, 2, -3, 4, 5]) == 57\n assert candidate(nums1 = [1, 2, 3],nums2 = [100, 200, 300, 400, 500]) == 2600\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1]) == 46\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -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],nums2 = [-5, 4, -3, 2, -1]) == 44\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]) == 385\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3]) == 2600\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]) == 38500\n assert candidate(nums1 = [999, -999, 888, -888, 777, -777],nums2 = [-666, 666, -555, 555, -444, 444, -333, 333]) == 2710620\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [-1, 1, -1, 1, -1]) == 4\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 4750\n assert candidate(nums1 = [1000, 999, 998, 997, 996],nums2 = [1, 2, 3, 4, 5]) == 14960\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [100, 200, 300]) == 2200\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [300, -300, 400, -400]) == 220000\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(nums1 = [1, 2, 3],nums2 = [-1, -2, -3, 4, 5]) == 23\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 = [5, -3, 8, 1],nums2 = [-7, 4, 6, -2]) == 69\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-9, 7, -5, 3, 1]) == 139\n assert candidate(nums1 = [1, 3, -5, 7, -9, 11],nums2 = [11, -9, 7, -5, 3, -1]) == 235\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-2, 4, -6, 8, -10]) == 188\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 1200\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]) == 3850\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 190\n assert candidate(nums1 = [-5, -5, -5, -5, -5],nums2 = [-5, -5, -5, -5, -5]) == 125\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [0, 1, 0, -1, 0]) == 2\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 460000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 55\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [-50, -40, -30, -20, -10],nums2 = [-10, -20, -30, -40, -50]) == 4600\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(nums1 = [100, 200, 300],nums2 = [1, 2, 3, 4, 5]) == 2600\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1]) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10]) == 1000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-50, -40, -30, -20, -10]) == -100\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [10, 20, 30, 40, 50]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 4600\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [1, 0, -1, 0, 1]) == 3\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 504\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, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [-1, 0, 1, -2, 0, 2],nums2 = [2, 0, -2, 0, 1, -1]) == 8\n", "comparison": "exact"}, "public_tests": ["[2,1,-2,5]\n[3,0,-6]", "[3,-2]\n[2,-6,7]", "[-1,-1]\n[1,1]"], "hints": ["Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDotProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:46+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "longest-common-subsequence"]}, "language": "python", "interface": {"raw_signature": "def maxDotProduct(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxDotProduct", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1460, "task_id": "make-two-arrays-equal-by-reversing-subarrays", "difficulty": "Easy", "problem_description": "You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.\n\nReturn true if you can make arr equal to target or false otherwise.\n\nExample 1:\n\nInput: target = [1,2,3,4], arr = [2,4,1,3]\nOutput: true\nExplanation: You can follow the next steps to convert arr to target:\n1- Reverse subarray [2,4,1], arr becomes [1,4,2,3]\n2- Reverse subarray [4,2], arr becomes [1,2,4,3]\n3- Reverse subarray [4,3], arr becomes [1,2,3,4]\nThere are multiple ways to convert arr to target, this is not the only way to do so.\n\nExample 2:\n\nInput: target = [7], arr = [7]\nOutput: true\nExplanation: arr is equal to target without any reverses.\n\nExample 3:\n\nInput: target = [3,7,9], arr = [3,7,11]\nOutput: false\nExplanation: arr does not have value 9 and it can never be converted to target.\n\nConstraints:\n\n- target.length == arr.length\n- 1 <= target.length <= 1000\n- 1 <= target[i] <= 1000\n- 1 <= arr[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [4, 3, 2, 1],arr = [1, 2, 3, 4]) == True\n assert candidate(target = [5, 6, 7, 8],arr = [8, 7, 6, 5]) == True\n assert candidate(target = [1, 1, 1, 1],arr = [1, 1, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7],arr = [7, 5, 3, 1]) == True\n assert candidate(target = [1000, 1000, 1000],arr = [1000, 1000, 1000]) == True\n assert candidate(target = [10, 20, 30, 40],arr = [40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3],arr = [3, 2, 1]) == True\n assert candidate(target = [5, 4, 3, 2, 1],arr = [1, 2, 3, 4, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30],arr = [30, 20, 10]) == True\n assert candidate(target = [5, 1, 3, 2],arr = [2, 1, 3, 5]) == True\n assert candidate(target = [1000, 1, 1000],arr = [1, 1000, 1000]) == True\n assert candidate(target = [1, 2, 2, 3],arr = [2, 1, 3, 2]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 3, 5, 7, 9],arr = [9, 7, 5, 3, 1]) == True\n assert candidate(target = [3, 7, 9],arr = [3, 7, 11]) == False\n assert candidate(target = [5, 3, 1],arr = [1, 3, 5]) == True\n assert candidate(target = [1, 2, 3, 4],arr = [2, 4, 1, 3]) == True\n assert candidate(target = [1, 2, 2, 3],arr = [3, 2, 2, 1]) == True\n assert candidate(target = [4, 4, 4, 4],arr = [4, 4, 4, 4]) == True\n assert candidate(target = [1000, 1, 1000, 1],arr = [1, 1000, 1, 1000]) == True\n assert candidate(target = [10, 9, 8, 7],arr = [7, 8, 9, 10]) == True\n assert candidate(target = [1, 3, 2],arr = [2, 1, 3]) == True\n assert candidate(target = [1, 2, 3],arr = [4, 5, 6]) == False\n assert candidate(target = [7],arr = [7]) == True\n assert candidate(target = [999, 998, 997],arr = [997, 998, 999]) == True\n assert candidate(target = [5, 6, 7],arr = [7, 6, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(target = [5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3],arr = [3, 2, 1, 3, 1, 2]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],arr = [6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],arr = [991, 992, 993, 994, 995, 996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [500, 400, 300, 200, 100],arr = [100, 200, 300, 400, 500]) == True\n assert candidate(target = [5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 2, 8, 4, 6, 5, 9, 7, 3, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == True\n assert candidate(target = [5, 10, 15, 20, 25],arr = [25, 20, 15, 10, 5]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 4, 4],arr = [4, 4, 3, 3, 2, 2, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [999, 1000, 999, 1000, 999, 1000, 999, 1000],arr = [1000, 999, 1000, 999, 1000, 999, 1000, 999]) == True\n assert candidate(target = [4, 4, 4, 4, 4, 4, 4],arr = [4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(target = [5, 1, 4, 3, 2],arr = [2, 3, 1, 5, 4]) == True\n assert candidate(target = [5, 3, 1, 4, 2],arr = [2, 1, 4, 3, 5]) == True\n assert candidate(target = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 1, 2, 3]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 1, 2]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 1, 2, 3, 4, 5]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],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]) == True\n assert candidate(target = [3, 3, 3, 3, 3],arr = [3, 3, 3, 3, 3]) == True\n assert candidate(target = [1000, 500, 250, 125],arr = [125, 250, 500, 1000]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3],arr = [3, 2, 1, 3, 2, 1, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(target = [100, 200, 100, 200, 100],arr = [200, 100, 200, 100, 200]) == False\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],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]) == True\n assert candidate(target = [5, 5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(target = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(target = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 1, 2, 3, 4]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 2, 3, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [100, 200, 300, 400, 500],arr = [500, 400, 300, 200, 100]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(target = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 1]) == True\n assert candidate(target = [1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500],arr = [500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000]) == True\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],arr = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [7, 8, 9, 10, 11],arr = [11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],arr = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5],arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7, 9],arr = [9, 7, 5, 3, 1]) == True\n assert candidate(target = [234, 234, 234, 234, 234, 234, 234, 234, 234, 234],arr = [234, 234, 234, 234, 234, 234, 234, 234, 234, 234]) == True\n assert candidate(target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(target = [1000, 999, 998, 997, 996],arr = [996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 10, 9, 8, 7, 6, 5, 4]) == True\n assert candidate(target = [300, 200, 100, 400, 500, 600, 700, 800, 900, 1000],arr = [1000, 900, 800, 700, 600, 500, 400, 100, 200, 300]) == True\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],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]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 10, 30, 20, 40]) == True\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == True\n assert candidate(target = [1000, 999, 998, 997, 996, 995],arr = [995, 996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],arr = [4, 4, 3, 3, 4, 3, 2, 1, 2, 4]) == True\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8]) == False\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],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]) == True\n assert candidate(target = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(target = [5, 3, 4, 1, 2],arr = [2, 1, 4, 3, 5]) == True\n assert candidate(target = [1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [10, 20, 30, 40, 50, 60, 70, 100, 90, 80]) == True\n assert candidate(target = [1, 3, 2, 4, 5],arr = [2, 1, 4, 5, 3]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1],arr = [1, 2, 3, 4, 3, 2, 1]) == True\n assert candidate(target = [200, 300, 100, 400, 500, 600],arr = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == True\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],arr = [9, 5, 3, 5, 2, 6, 9, 5, 1, 4, 1, 3]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4],arr = [4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3],arr = [3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n[2,4,1,3]", "[7]\n[7]", "[3,7,9]\n[3,7,11]"], "hints": ["Each element of target should have a corresponding element in arr, and if it doesn't have a corresponding element, return false.", "To solve it easiely you can sort the two arrays and check if they are equal."], "metadata": {"canonical_parameter_names": ["target", "arr"], "leetcode_dataset_entry_point": "Solution().canBeEqual", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:48+00:00", "tests_total": 122, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "hash-table", "sorting"]}, "language": "python", "interface": {"raw_signature": "def canBeEqual(self, target: list[int], arr: list[int]) -> bool:", "container": "Solution", "callable": "canBeEqual", "parameters": [{"name": "target", "type": "list[int]"}, {"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1461, "task_id": "check-if-a-string-contains-all-binary-codes-of-size-k", "difficulty": "Medium", "problem_description": "Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.\n\nExample 1:\n\nInput: s = \"00110110\", k = 2\nOutput: true\nExplanation: The binary codes of length 2 are \"00\", \"01\", \"10\" and \"11\". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.\n\nExample 2:\n\nInput: s = \"0110\", k = 1\nOutput: true\nExplanation: The binary codes of length 1 are \"0\" and \"1\", it is clear that both exist as a substring.\n\nExample 3:\n\nInput: s = \"0110\", k = 2\nOutput: false\nExplanation: The binary code \"00\" is of length 2 and does not exist in the array.\n\nConstraints:\n\n- 1 <= s.length <= 5 * 10^5\n- s[i] is either '0' or '1'.\n- 1 <= k <= 20\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1010101010\",k = 5) == False\n assert candidate(s = \"1010101010\",k = 3) == False\n assert candidate(s = \"0000000\",k = 3) == False\n assert candidate(s = \"00110110\",k = 2) == True\n assert candidate(s = \"00000000\",k = 4) == False\n assert candidate(s = \"11110000\",k = 3) == False\n assert candidate(s = \"1111111\",k = 2) == False\n assert candidate(s = \"0110\",k = 2) == False\n assert candidate(s = \"0110\",k = 1) == True\n assert candidate(s = \"00001111000011110000111100001111000011110000111100\",k = 8) == False\n assert candidate(s = \"0110011001100110011001100110\",k = 5) == False\n assert candidate(s = \"0100100100100100100100100100\",k = 7) == False\n assert candidate(s = \"10100101101001011010\",k = 4) == False\n assert candidate(s = \"11001100110011001100\",k = 5) == False\n assert candidate(s = \"01101101101101101101\",k = 4) == False\n assert candidate(s = \"01010101010101010101\",k = 7) == False\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\",k = 15) == False\n assert candidate(s = \"0001010111001100101010110111\",k = 4) == False\n assert candidate(s = \"1100110011001100110011001100\",k = 8) == False\n assert candidate(s = \"1010010100101001010010100101001010010100101001\",k = 6) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 7) == False\n assert candidate(s = \"10101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 5) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",k = 6) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001\",k = 7) == False\n assert candidate(s = \"01001100111000011001\",k = 3) == False\n assert candidate(s = \"0101010101010101010101010101\",k = 3) == False\n assert candidate(s = \"110011001100\",k = 4) == False\n assert candidate(s = \"1001101001101001101001101001101001101001\",k = 6) == False\n assert candidate(s = \"00010010100101110110\",k = 3) == True\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 3) == False\n assert candidate(s = \"1100101001110010110011000111001111001111110011111100\",k = 8) == False\n assert candidate(s = \"100110101110100011001010001110001001\",k = 8) == False\n assert candidate(s = \"0000000000000000000000000000000000000000\",k = 10) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 15) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",k = 10) == False\n assert candidate(s = \"1001001001001001001001001001001001001001\",k = 4) == False\n assert candidate(s = \"0101010101010101\",k = 5) == False\n assert candidate(s = \"00101011110100101010100101010010101010\",k = 5) == False\n assert candidate(s = \"11111111111111111111\",k = 10) == False\n assert candidate(s = \"00101110011011001011\",k = 3) == False\n assert candidate(s = \"11100100110101110100010111010010100011000101110001011101001010001011101000101110100\",k = 5) == False\n assert candidate(s = \"1101010101101010101\",k = 5) == False\n assert candidate(s = \"000000000111111111000000001111111100000000\",k = 8) == False\n assert candidate(s = \"110010011110000110\",k = 3) == False\n assert candidate(s = \"110010110110011010001011\",k = 3) == False\n assert candidate(s = \"1111111111111111111111111111\",k = 5) == False\n assert candidate(s = \"1111111110000000001111111110000000011111\",k = 9) == False\n assert candidate(s = \"0011001100110011001100110011\",k = 6) == False\n assert candidate(s = \"1010001110011101001010101010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"1110010011010111010001011101001010001100010111000101110100101000101110100010111010010100100010001000100010001000100010001000100010001000100010001000100\",k = 10) == False\n assert candidate(s = \"0011001100110011001100110011\",k = 7) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 20) == False\n assert candidate(s = \"00001111000011110000\",k = 4) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\",k = 10) == False\n assert candidate(s = \"0110100111000101000110110001101101101001010111011100011111000011011111010011101001110\",k = 19) == False\n assert candidate(s = \"0110100101101001011010010110100101101001\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 9) == False\n assert candidate(s = \"11110000111100001111000011110000\",k = 4) == False\n assert candidate(s = \"1111111111\",k = 2) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 6) == False\n assert candidate(s = \"1010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"00010110111100010111\",k = 4) == False\n assert candidate(s = \"0001110001110001110001110001110001110001\",k = 4) == False\n assert candidate(s = \"11111111111111111111\",k = 19) == False\n assert candidate(s = \"01001001001001001001001001001001\",k = 4) == False\n assert candidate(s = \"11001100110011001100\",k = 6) == False\n assert candidate(s = \"0110110110110110110110110110110110110110\",k = 6) == False\n assert candidate(s = \"11101011110001011010\",k = 4) == False\n assert candidate(s = \"10000011110000111110001101110011100110011111110000001001001011000110010011001011110101\",k = 15) == False\n assert candidate(s = \"01101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 12) == False\n assert candidate(s = \"0001010001010110001010001010101010101010101010101010\",k = 7) == False\n assert candidate(s = \"0001011000110000111110101011011110011110101001101100100100011111100100000011111010101101110001101010110111010010101110100011011101001101110100\",k = 7) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111\",k = 20) == False\n assert candidate(s = \"10000000001\",k = 5) == False\n assert candidate(s = \"10010010010010010010\",k = 5) == False\n assert candidate(s = \"0100101011100111001010110111110000001111001110\",k = 5) == False\n assert candidate(s = \"1100101011100010011000011111000000111111\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010\",k = 6) == False\n assert candidate(s = \"01010101010101010101\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 12) == False\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",k = 15) == False\n assert candidate(s = \"1111111111111111111111111111111111111111\",k = 15) == False\n assert candidate(s = \"1111000011110000\",k = 6) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 8) == False\n assert candidate(s = \"01010101010101010101\",k = 6) == False\n assert candidate(s = \"10010010010010010010010010010010010010010010010010\",k = 7) == False\n assert candidate(s = \"00110011001100110011001100110011001100110011001100\",k = 4) == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\",k = 6) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"1110001110001110001110001110001110001110\",k = 7) == False\n assert candidate(s = \"00000000000000000000\",k = 2) == False\n assert candidate(s = \"10101010101010101010\",k = 6) == False\n assert candidate(s = \"00000000000000000000\",k = 5) == False\n assert candidate(s = \"1000100010001000100010001000\",k = 4) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001\",k = 18) == False\n assert candidate(s = \"0000000000000000000000000000000000000000000000\",k = 20) == False\n assert candidate(s = \"11111111111111111111\",k = 5) == False\n assert candidate(s = \"01100110011001100110011001100110011001100110011001100110\",k = 9) == False\n assert candidate(s = \"1100011001110100101000101101010001101110100110\",k = 7) == False\n", "comparison": "exact"}, "public_tests": ["\"00110110\"\n2", "\"0110\"\n1", "\"0110\"\n2"], "hints": ["We need only to check all sub-strings of length k.", "The number of distinct sub-strings should be exactly 2^k."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().hasAllCodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:51+00:00", "tests_total": 102, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation", "rolling-hash", "hash-function", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def hasAllCodes(self, s: str, k: int) -> bool:", "container": "Solution", "callable": "hasAllCodes", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1462, "task_id": "course-schedule-iv", "difficulty": "Medium", "problem_description": "There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [a_i, b_i] indicates that you must take course a_i first if you want to take course b_i.\n\n- For example, the pair [0, 1] indicates that you have to take course 0 before you can take course 1.\n\nPrerequisites can also be indirect. If course a is a prerequisite of course b, and course b is a prerequisite of course c, then course a is a prerequisite of course c.\n\nYou are also given an array queries where queries[j] = [u_j, v_j]. For the j^th query, you should answer whether course u_j is a prerequisite of course v_j or not.\n\nReturn a boolean array answer, where answer[j] is the answer to the j^th query.\n\nExample 1:\n\nInput: numCourses = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]\nOutput: [false,true]\nExplanation: The pair [1, 0] indicates that you have to take course 1 before you can take course 0.\nCourse 0 is not a prerequisite of course 1, but the opposite is true.\n\nExample 2:\n\nInput: numCourses = 2, prerequisites = [], queries = [[1,0],[0,1]]\nOutput: [false,false]\nExplanation: There are no prerequisites, and each course is independent.\n\nExample 3:\n\nInput: numCourses = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]\nOutput: [true,true]\n\nConstraints:\n\n- 2 <= numCourses <= 100\n- 0 <= prerequisites.length <= (numCourses * (numCourses - 1) / 2)\n- prerequisites[i].length == 2\n- 0 <= a_i, b_i <= numCourses - 1\n- a_i != b_i\n- All the pairs [a_i, b_i] are unique.\n- The prerequisites graph has no cycles.\n- 1 <= queries.length <= 10^4\n- 0 <= u_i, v_i <= numCourses - 1\n- u_i != v_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0]]) == [True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [0, 2]]) == [True, True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4]],queries = [[0, 3], [1, 4], [2, 3]]) == [True, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2]],queries = [[0, 2], [2, 0]]) == [True, False]\n assert candidate(numCourses = 2,prerequisites = [],queries = [[1, 0], [0, 1]]) == [False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [3, 4]]) == [True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 4], [2, 3]]) == [True, True, True, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [1, 0], [2, 0]],queries = [[1, 0], [1, 2]]) == [True, True]\n assert candidate(numCourses = 2,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0]]) == [False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 2], [2, 0], [3, 0]]) == [True, True, False, False]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 5], [0, 4], [1, 2]]) == [True, True, True, False, False, True, False]\n assert candidate(numCourses = 15,prerequisites = [[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]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 11], [1, 12], [2, 7], [2, 8]]) == [True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 15,prerequisites = [[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]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],queries = [[0, 7], [1, 5], [2, 4], [3, 6], [5, 7]]) == [True, False, False, False, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4]]) == [True, True, True, True, True, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [1, 2]]) == [True, True, False, False, False, True, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 10], [6, 11], [7, 11], [8, 11], [9, 11]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 10], [1, 11], [2, 10], [2, 11], [3, 11], [4, 11]]) == [True, True, True, True, True, False, True, True, True, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]],queries = [[0, 7], [0, 8], [1, 7], [1, 8], [2, 7], [2, 8], [0, 3], [0, 4]]) == [True, True, True, True, False, False, True, True]\n assert candidate(numCourses = 10,prerequisites = [[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]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [5, 7], [6, 8]],queries = [[0, 7], [0, 8], [1, 5], [1, 6], [2, 7], [2, 8], [3, 7], [3, 8], [4, 7], [5, 7], [6, 8]]) == [True, True, False, False, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2]]) == [True, True, True, True]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 5], [1, 2]]) == [True, False, False, True, False, False, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 6], [5, 6]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 5], [0, 4], [0, 3]]) == [True, True, True, True, True, True, False, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],queries = [[0, 3], [0, 7], [1, 8], [2, 6], [3, 5]]) == [True, True, True, True, False]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0]]) == [True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6]],queries = [[0, 3], [1, 5], [2, 6], [3, 6]]) == [True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [2, 5], [4, 6], [5, 6]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 5]]) == [True, True, True, False, True, True, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3]]) == [True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5]],queries = [[0, 5], [1, 4], [2, 4], [3, 5], [1, 3], [2, 3]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],queries = [[0, 3], [0, 4], [0, 5], [1, 2], [1, 5], [2, 3], [2, 4]]) == [True, True, True, False, False, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 5], [3, 6], [4, 6], [5, 6], [6, 7]],queries = [[0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 6], [2, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 2], [1, 2], [2, 3], [3, 5], [3, 6], [6, 7], [7, 5]],queries = [[0, 5], [0, 7], [1, 5], [1, 7], [2, 5], [2, 7], [3, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [2, 7], [2, 6], [2, 5], [3, 6], [3, 5], [4, 6], [4, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, False, True, False, False, True, False, True, True, False, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 10], [8, 11]],queries = [[0, 10], [0, 11], [1, 10], [1, 11], [2, 10], [2, 11], [3, 10], [3, 11], [4, 10], [4, 11]]) == [True, True, True, True, True, True, True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3]]) == [True, True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2], [3, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5], [0, 4], [1, 4], [2, 4]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 6], [2, 5], [3, 4]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [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]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [1, 5], [1, 6]]) == [True, True, True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 2], [1, 3]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 6]]) == [True, True, True, True, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6], [4, 6]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 11,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [0, 4], [1, 4], [2, 5]]) == [True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [0, 2], [2, 4], [3, 4], [4, 5]],queries = [[0, 5], [2, 5], [3, 5], [0, 3], [5, 0]]) == [True, True, True, False, False]\n assert candidate(numCourses = 15,prerequisites = [[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]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 10], [10, 0]]) == [True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8]],queries = [[0, 9], [2, 8], [4, 7], [6, 5], [0, 8]]) == [True, True, True, False, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 8]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 5], [1, 6], [1, 7], [1, 8], [2, 3], [2, 4], [2, 7], [2, 8], [3, 8], [4, 8], [5, 6], [6, 7]]) == [True, True, True, True, True, True, False, False, True, True, False, False, False, True, False, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7]],queries = [[0, 5], [0, 6], [0, 7], [1, 5], [1, 6], [1, 7], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5], [0, 4]]) == [True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [0, 8], [1, 7], [2, 6], [3, 5]]) == [True, True, True, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 7], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6]],queries = [[0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [0, 8], [1, 6], [3, 9], [5, 4]]) == [True, True, True, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 3], [1, 4], [2, 5]],queries = [[0, 6], [1, 5], [2, 4], [0, 5], [3, 4], [0, 4], [4, 6], [1, 3]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 15,prerequisites = [[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]],queries = [[0, 13], [0, 14], [1, 13], [1, 14], [2, 13], [2, 14], [3, 13], [3, 14], [4, 13], [4, 14]]) == [True, True, True, True, False, False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 4], [1, 2], [1, 3], [2, 4], [3, 4]],queries = [[0, 2], [0, 3], [1, 4], [2, 3], [3, 2]]) == [True, True, True, False, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9]],queries = [[0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 9], [2, 9], [3, 5], [3, 6], [4, 7]]) == [True, True, True, True, True, False, False, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[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, 11], [8, 11], [9, 11], [10, 11]],queries = [[0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]]) == [True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, False, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [2, 6]],queries = [[0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11], [6, 12], [7, 13], [8, 13], [9, 13], [10, 14], [11, 14], [12, 14]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [5, 6]],queries = [[0, 4], [0, 5], [0, 6], [1, 3], [1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [4, 6]]) == [True, True, True, True, False, False, True, True, False, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7], [6, 8], [7, 9]],queries = [[0, 5], [1, 6], [2, 8], [3, 9], [4, 7], [5, 8]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],queries = [[0, 3], [0, 5], [1, 6], [3, 5], [4, 6]]) == [True, True, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 2], [1, 0], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [3, 0], [1, 2]]) == [True, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 2], [3, 4]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [0, 3], [3, 4], [1, 4]],queries = [[0, 2], [2, 0], [0, 4], [4, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [5, 0], [1, 4], [4, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 0]],queries = [[0, 1], [2, 1], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 3], [2, 3]]) == [False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 0], [0, 2], [2, 3], [3, 4]],queries = [[1, 4], [0, 4], [0, 3], [0, 2]]) == [True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 2]],queries = [[0, 1], [1, 2], [0, 2], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],queries = [[1, 5], [1, 4], [2, 5], [3, 5], [4, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 3], [1, 3], [0, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [0, 3], [1, 3], [2, 3]]) == [False, False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 2]]) == [True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [3, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [2, 3], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 4], [2, 4], [3, 5], [4, 5]],queries = [[1, 5], [2, 5], [3, 4]]) == [True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3]]) == [True, False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [5, 3]],queries = [[5, 0], [5, 1], [4, 2], [4, 3], [2, 1]]) == [True, True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[0, 1]],queries = [[0, 1], [1, 0], [1, 2]]) == [True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[0, 3], [3, 0], [1, 2], [2, 1]]) == [True, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 2]]) == [True, True, False]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 2], [1, 3], [0, 3], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [0, 2], [1, 3], [2, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [5, 3]],queries = [[0, 1], [0, 3], [0, 5], [1, 2], [2, 3], [3, 4]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1]],queries = [[0, 3], [1, 3], [2, 3]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0], [1, 2], [0, 2]]) == [False, True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [0, 3]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [2, 3], [3, 4], [4, 5]],queries = [[1, 5], [2, 4], [3, 5], [0, 5]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [1, 0], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 0], [2, 3], [3, 2]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 2]],queries = [[0, 1], [1, 2], [0, 2], [2, 0], [1, 0], [2, 1]]) == [True, True, True, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 2], [2, 3], [3, 4], [1, 3], [1, 4]],queries = [[0, 1], [1, 0], [2, 4]]) == [False, False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2], [0, 2]]) == [False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 3], [1, 3], [2, 3]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5]]) == [True, True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 4], [2, 4], [3, 4]],queries = [[0, 4], [1, 4], [2, 4], [3, 4], [4, 0]]) == [True, True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [3, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [5, 0], [2, 3], [3, 2]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 1], [0, 4], [1, 3], [2, 4], [4, 0]]) == [True, True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[0, 5], [1, 4], [2, 5], [0, 3], [3, 2]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [1, 4], [0, 3], [1, 3], [0, 2], [1, 2], [2, 4], [0, 1], [2, 3], [4, 0]]) == [True, True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[0, 1]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [True, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [2, 3]]) == [True, False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [3, 0], [1, 2], [0, 2]]) == [True, False, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[0, 3], [1, 3], [2, 3], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [2, 5]]) == [True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[1, 0], [0, 1], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [2, 0], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 0]],queries = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 0]]) == [False, True, False, False, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 3], [3, 2]],queries = [[0, 2], [1, 3], [2, 0], [0, 1]]) == [True, False, False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 4], [1, 5], [2, 3], [3, 4], [3, 5]],queries = [[1, 3], [1, 4], [2, 5], [3, 1]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 5]],queries = [[1, 4], [2, 5], [3, 4], [0, 5]]) == [True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2], [2, 0]]) == [False, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [3, 4]],queries = [[0, 2], [3, 4]]) == [True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [0, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [2, 4]]) == [True, False, True, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2], [4, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5]]) == [False, False, False, False]\n assert candidate(numCourses = 7,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [6, 5]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[2, 0], [2, 1]]) == [False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [0, 2]]) == [False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [2, 3], [1, 3], [2, 4], [3, 5]],queries = [[0, 3], [2, 5], [0, 5], [1, 2]]) == [True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],queries = [[0, 4], [1, 4], [2, 4]]) == [True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],queries = [[0, 3], [0, 4], [1, 5], [2, 3]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 2], [2, 3], [3, 4], [4, 0]],queries = [[1, 4], [4, 1], [0, 3], [3, 2]]) == [True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [2, 0]],queries = [[1, 0], [2, 0], [0, 1]]) == [True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [0, 2], [1, 0]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0]]) == [False, True]\n assert candidate(numCourses = 3,prerequisites = [[0, 1], [0, 2]],queries = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 0], [0, 2]]) == [True, False, False, False, False, True]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [0, 3], [3, 0]]) == [False, False, False, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2], [3, 1]]) == [True, True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 2], [1, 0], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[1, 3], [2, 3], [3, 0], [3, 1]]) == [True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 0]]) == [False, False, False, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 4], [2, 4], [3, 4]],queries = [[0, 4], [1, 2], [2, 0], [3, 1]]) == [True, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 0]]) == [False, False, False, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4]],queries = [[0, 3], [0, 4]]) == [True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4]],queries = [[0, 4], [0, 3], [1, 4], [2, 3], [3, 4]]) == [True, True, True, False, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 2], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [1, 0]],queries = [[0, 1], [1, 0], [2, 0]]) == [False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 1]],queries = [[0, 1], [1, 2], [0, 2]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2]]) == [False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [2, 3], [3, 0]]) == [False, False, False, True]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 0]],queries = [[0, 1], [0, 2], [0, 3], [1, 2]]) == [False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 4], [2, 0]]) == [True, True, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 5]],queries = [[1, 4], [4, 1], [1, 5], [5, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [1, 2]]) == [False, True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 1], [1, 3], [0, 3]]) == [True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [2, 3], [4, 5]],queries = [[0, 1], [2, 3], [4, 5], [3, 4]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5]]) == [False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[3, 0], [5, 0], [4, 2], [1, 2]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [1, 4], [2, 4]],queries = [[0, 4], [1, 4], [2, 3], [3, 4]]) == [True, True, True, False]\n assert candidate(numCourses = 4,prerequisites = [[2, 0], [1, 0], [3, 1], [3, 2]],queries = [[0, 1], [2, 0], [0, 3], [3, 0], [2, 3]]) == [False, True, False, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [0, 2], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 1], [1, 3], [0, 4], [2, 3], [4, 2]]) == [True, True, True, True, False]\n", "comparison": "exact"}, "public_tests": ["6\n[[4,5],[3,4],[2,3],[1,2],[0,1]]\n[[0,5]]", "3\n[[0,1],[1,2]]\n[[0,2]]", "4\n[[0,1],[2,3]]\n[[0,3]]"], "hints": ["Imagine if the courses are nodes of a graph. We need to build an array isReachable[i][j].", "Start a bfs from each course i and assign for each course j you visit isReachable[i][j] = True.", "Answer the queries from the isReachable array."], "metadata": {"canonical_parameter_names": ["numCourses", "prerequisites", "queries"], "leetcode_dataset_entry_point": "Solution().checkIfPrerequisite", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:53+00:00", "tests_total": 181, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph", "topological-sort"]}, "language": "python", "interface": {"raw_signature": "def checkIfPrerequisite(self, numCourses: int, prerequisites: list[list[int]], queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "checkIfPrerequisite", "parameters": [{"name": "numCourses", "type": "int"}, {"name": "prerequisites", "type": "list[list[int]]"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1463, "task_id": "cherry-pickup-ii", "difficulty": "Hard", "problem_description": "You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.\n\nYou have two robots that can collect cherries for you:\n\n- Robot #1 is located at the top-left corner (0, 0), and\n- Robot #2 is located at the top-right corner (0, cols - 1).\n\nReturn the maximum number of cherries collection using both robots by following the rules below:\n\n- From a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).\n- When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.\n- When both robots stay in the same cell, only one takes the cherries.\n- Both robots cannot move outside of the grid at any moment.\n- Both robots should reach the bottom row in grid.\n\nExample 1:\n\nInput: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]\nOutput: 24\nExplanation: Path of robot #1 and #2 are described in color green and blue respectively.\nCherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.\nCherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.\nTotal of cherries: 12 + 12 = 24.\n\nExample 2:\n\nInput: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]\nOutput: 28\nExplanation: Path of robot #1 and #2 are described in color green and blue respectively.\nCherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.\nCherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.\nTotal of cherries: 17 + 11 = 28.\n\nConstraints:\n\n- rows == grid.length\n- cols == grid[i].length\n- 2 <= rows, cols <= 70\n- 0 <= grid[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3], [0, 1, 0], [3, 0, 1], [1, 2, 3]]) == 14\n assert candidate(grid = [[5, 0, 0, 5], [0, 4, 4, 0], [0, 4, 4, 0], [5, 0, 0, 5]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 1, 4, 3, 2], [3, 2, 1, 4, 3]]) == 35\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[10, 0, 0, 10], [0, 0, 0, 0], [0, 10, 10, 0], [10, 0, 0, 10]]) == 60\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]]) == 10\n assert candidate(grid = [[3, 1, 1], [2, 5, 1], [1, 5, 5], [2, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [2, 0, 0, 0, 0, 3, 0], [2, 0, 9, 0, 0, 0, 0], [0, 3, 0, 5, 4, 0, 0], [1, 0, 2, 3, 0, 0, 6]]) == 28\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 32\n assert candidate(grid = [[1, 1], [1, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == 120\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 16\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, 100, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 100, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 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], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 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], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 159\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70]]) == 440\n assert candidate(grid = [[5, 5, 5], [5, 0, 5], [5, 5, 5]]) == 30\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0]]) == 13\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 26\n assert candidate(grid = [[5, 3, 2, 1, 4, 0], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10]]) == 55\n assert candidate(grid = [[100, 0, 0, 0, 0, 0, 100], [0, 90, 0, 0, 0, 90, 0], [0, 0, 80, 0, 80, 0, 0], [0, 0, 0, 70, 0, 0, 0], [0, 0, 0, 0, 60, 0, 0], [0, 0, 0, 0, 0, 50, 0], [0, 0, 0, 0, 0, 0, 40]]) == 760\n assert candidate(grid = [[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], [1, 2, 1, 2, 1, 2]]) == 23\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]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == 43\n assert candidate(grid = [[3, 0, 0, 2, 1, 0, 1], [0, 4, 3, 0, 0, 0, 0], [2, 1, 5, 0, 1, 0, 1], [0, 0, 0, 5, 0, 0, 0], [1, 2, 3, 0, 1, 2, 1], [0, 0, 0, 0, 0, 0, 5], [0, 3, 4, 3, 0, 0, 2]]) == 35\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]]) == 8\n assert candidate(grid = [[10, 15, 10], [15, 0, 15], [10, 15, 10], [15, 0, 15]]) == 105\n assert candidate(grid = [[10, 0, 0, 0, 10], [0, 10, 0, 10, 0], [0, 0, 10, 0, 0], [0, 10, 0, 10, 0], [10, 0, 0, 0, 10]]) == 90\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]]) == 154\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[50, 100, 50], [100, 50, 100], [50, 100, 50], [100, 50, 100]]) == 650\n assert candidate(grid = [[0, 0, 0, 0], [0, 100, 100, 0], [0, 100, 100, 0], [0, 0, 0, 0]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1]]) == 111\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]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 50], [0, 0, 50, 0, 0], [50, 0, 0, 0, 0], [0, 50, 0, 50, 0]]) == 200\n assert candidate(grid = [[3, 1, 2, 1, 3], [2, 1, 3, 1, 2], [1, 2, 1, 2, 1], [3, 1, 2, 1, 3], [2, 1, 3, 1, 2]]) == 24\n assert candidate(grid = [[100, 0, 0, 0, 100], [0, 50, 50, 0, 0], [0, 0, 0, 50, 50], [50, 50, 0, 0, 0], [0, 0, 100, 0, 0]]) == 450\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, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 14\n assert candidate(grid = [[3, 0, 0, 0, 0, 0, 0, 4], [0, 2, 0, 0, 0, 0, 5, 0], [0, 0, 1, 0, 0, 6, 0, 0], [0, 0, 0, 7, 8, 0, 0, 0], [0, 0, 9, 0, 0, 10, 0, 0], [0, 11, 0, 0, 0, 0, 12, 0], [13, 0, 0, 0, 0, 0, 0, 14]]) == 105\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 10, 0, 10, 0, 10, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0]]) == 21\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [100, 100, 100, 100, 100, 100, 100, 100, 100]]) == 200\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 1, 0, 1, 0, 1, 0], [1, 0, 9, 0, 9, 0, 1], [0, 3, 0, 5, 0, 3, 0], [1, 0, 2, 3, 0, 2, 1]]) == 53\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]]) == 67\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, 3, 3, 3, 2, 1, 0], [0, 1, 2, 3, 4, 3, 2, 1, 0], [0, 1, 2, 3, 3, 3, 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]]) == 31\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 0, 0, 5], [0, 5, 0, 0, 0, 0, 0, 5, 0], [0, 0, 5, 0, 0, 0, 5, 0, 0], [0, 0, 0, 5, 0, 5, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 5, 0, 5, 0, 0, 0], [0, 0, 5, 0, 0, 0, 5, 0, 0], [0, 5, 0, 0, 0, 0, 0, 5, 0], [5, 0, 0, 0, 0, 0, 0, 0, 5]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 18\n assert candidate(grid = [[3, 0, 0, 0, 0, 0, 3], [0, 2, 0, 0, 0, 2, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 5, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 2, 0, 0, 0, 2, 0], [3, 0, 0, 0, 0, 0, 3]]) == 29\n assert candidate(grid = [[30, 10, 0, 10, 30], [10, 20, 0, 20, 10], [0, 0, 30, 0, 0], [10, 20, 0, 20, 10], [30, 10, 0, 10, 30]]) == 230\n assert candidate(grid = [[10, 0, 0, 10, 0], [0, 10, 0, 10, 0], [0, 0, 10, 0, 0], [0, 10, 0, 10, 0], [10, 0, 0, 10, 0]]) == 80\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 20, 0, 0, 0, 20, 0], [0, 0, 30, 0, 30, 0, 0], [0, 0, 0, 40, 0, 0, 0], [0, 0, 30, 0, 30, 0, 0], [0, 20, 0, 0, 0, 20, 0], [10, 0, 0, 0, 0, 0, 10]]) == 280\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 5]]) == 30\n assert candidate(grid = [[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]]) == 52\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, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 14\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 10, 0, 0, 0, 10, 0], [0, 0, 10, 0, 10, 0, 0], [0, 0, 0, 20, 0, 0, 0], [10, 0, 0, 0, 0, 0, 10]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 26\n assert candidate(grid = [[10, 0, 0, 10], [0, 20, 20, 0], [0, 20, 20, 0], [10, 0, 0, 10]]) == 120\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 0, 0, 0, 10], [0, 10, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 10, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 10, 0, 0, 10, 0, 0, 0], [0, 0, 0, 0, 10, 10, 0, 0, 0, 0], [0, 0, 0, 10, 0, 0, 10, 0, 0, 0], [0, 0, 10, 0, 0, 0, 0, 10, 0, 0], [0, 10, 0, 0, 0, 0, 0, 0, 10, 0], [10, 0, 0, 0, 0, 0, 0, 0, 0, 10]]) == 180\n assert candidate(grid = [[5, 1, 1, 1], [1, 1, 1, 5], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\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, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 3, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 4, 4, 0, 0, 0, 0], [0, 0, 0, 0, 4, 4, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 3, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 40\n assert candidate(grid = [[5, 0, 0, 5, 0, 0, 5], [0, 5, 5, 0, 5, 5, 0], [5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0], [5, 5, 5, 5, 5, 5, 5], [0, 0, 0, 0, 0, 0, 0]]) == 50\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]]) == 45\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]]) == 22\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 4, 4, 4, 5], [5, 4, 3, 3, 3, 3, 3, 4, 5], [5, 4, 3, 2, 2, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 2, 2, 3, 4, 5], [5, 4, 3, 3, 3, 3, 3, 4, 5], [5, 4, 4, 4, 4, 4, 4, 4, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 90\n", "comparison": "exact"}, "public_tests": ["[[3,1,1],[2,5,1],[1,5,5],[2,1,1]]", "[[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]"], "hints": ["Use dynamic programming, define DP[i][j][k]: The maximum cherries that both robots can take starting on the ith row, and column j and k of Robot 1 and 2 respectively."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().cherryPickup", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:55+00:00", "tests_total": 74, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def cherryPickup(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "cherryPickup", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1464, "task_id": "maximum-product-of-two-elements-in-an-array", "difficulty": "Easy", "problem_description": "You are given an array of integers nums.\n\nChoose two different indices i and j of that array.\n\nReturn the maximum value of (nums[i] - 1) * (nums[j] - 1).\n\nExample 1:\n\nInput: nums = [3,4,5,2]\nOutput: 12\nExplanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*(nums[2]-1) = (4-1)*(5-1) = 3*4 = 12.\n\nExample 2:\n\nInput: nums = [1,5,4,5]\nOutput: 16\nExplanation: Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)*(5-1) = 16.\n\nExample 3:\n\nInput: nums = [3,7]\nOutput: 12\n\nConstraints:\n\n- 2 <= nums.length <= 500\n- 1 <= nums[i] <= 10^3\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 81\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [1, 1000, 2, 999, 3, 998]) == 997002\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1911\n assert candidate(nums = [5, 6, 7, 8, 9]) == 56\n assert candidate(nums = [5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5]) == 12\n assert candidate(nums = [500, 500, 500, 500, 500]) == 249001\n assert candidate(nums = [999, 1000]) == 997002\n assert candidate(nums = [1, 5, 4, 5]) == 16\n assert candidate(nums = [10, 2, 3, 8]) == 63\n assert candidate(nums = [1, 1000, 1, 1000]) == 998001\n assert candidate(nums = [2, 3, 100, 101, 99]) == 9900\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 616\n assert candidate(nums = [100, 100]) == 9801\n assert candidate(nums = [500, 500, 1, 1]) == 249001\n assert candidate(nums = [3, 7]) == 12\n assert candidate(nums = [3, 4, 5, 2]) == 12\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496]) == 249001\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]) == 14112\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 898101\n assert candidate(nums = [500, 500, 500, 500, 499, 499, 499, 499, 498, 498]) == 249001\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420]) == 157963\n assert candidate(nums = [500, 250, 125, 625, 312, 156, 78, 39, 19, 9, 4, 2]) == 311376\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10]) == 199101\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1]) == 199101\n assert candidate(nums = [333, 666, 999, 334, 667, 998, 335, 668, 997]) == 995006\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8]) == 997002\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 997002\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 1000]) == 997002\n assert candidate(nums = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309]) == 94556\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997]) == 998001\n assert candidate(nums = [300, 300, 300, 300, 300, 300, 299, 299, 299, 299]) == 89401\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 754\n assert candidate(nums = [500, 500, 450, 450, 400, 400, 350, 350, 300, 300]) == 249001\n assert candidate(nums = [250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265]) == 69432\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997, 996, 996]) == 998001\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000]) == 998001\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 1932\n assert candidate(nums = [500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 224051\n assert candidate(nums = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491]) == 248502\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 17982\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 4620\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 6\n assert candidate(nums = [300, 300, 300, 300, 300, 300, 300, 300, 300, 1]) == 89401\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 9702\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78]) == 6776\n assert candidate(nums = [100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 99]) == 9702\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 249001\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 997002\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 1000]) == 997002\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8811\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 995006\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 498501\n assert candidate(nums = [500, 500, 500, 1, 2, 3, 4, 5]) == 249001\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 288\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 = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5]) == 996004\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 182\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 616\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 37611\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509]) == 257556\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 323\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 997002\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 12971\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 997002\n assert candidate(nums = [500, 501, 499, 502, 498, 503, 497, 504, 496, 505]) == 253512\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 11556\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 342\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 100]) == 4851\n assert candidate(nums = [1000, 999, 998, 1, 2, 3]) == 997002\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == 995006\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 998001\n assert candidate(nums = [1, 10, 100, 1000, 100, 10, 1]) == 98901\n assert candidate(nums = [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, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1368\n assert candidate(nums = [333, 666, 999, 222, 555, 888, 111, 444, 777, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 885226\n assert candidate(nums = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4]) == 199101\n assert candidate(nums = [3, 3, 3, 3, 3, 1000, 1000, 1000, 1000, 1000]) == 998001\n assert candidate(nums = [1, 2, 3, 1000, 4, 5, 6, 7, 8, 9]) == 7992\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8811\n assert candidate(nums = [999, 999, 998, 998, 997, 997, 996, 996, 995, 995]) == 996004\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 1000]) == 997002\n assert candidate(nums = [999, 1000, 1, 2, 3, 4, 5, 6, 7, 8]) == 997002\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 81\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, 1000]) == 8991\n assert candidate(nums = [250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269]) == 71556\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 20711\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 25\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7992\n assert candidate(nums = [999, 1000, 998, 1000, 997]) == 998001\n", "comparison": "exact"}, "public_tests": ["[3,4,5,2]", "[1,5,4,5]", "[3,7]"], "hints": ["Use brute force: two loops to select i and j, then select the maximum value of (nums[i]-1)*(nums[j]-1)."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:57+00:00", "tests_total": 96, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "sorting", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def maxProduct(self, nums: list[int]) -> int:", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1465, "task_id": "maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts", "difficulty": "Medium", "problem_description": "You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:\n\n- horizontalCuts[i] is the distance from the top of the rectangular cake to the i^th horizontal cut and similarly, and\n- verticalCuts[j] is the distance from the left of the rectangular cake to the j^th vertical cut.\n\nReturn the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCuts. Since the answer can be a large number, return this modulo 10^9 + 7.\n\nExample 1:\n\nInput: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]\nOutput: 4\nExplanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.\n\nExample 2:\n\nInput: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]\nOutput: 6\nExplanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.\n\nExample 3:\n\nInput: h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3]\nOutput: 9\n\nConstraints:\n\n- 2 <= h, w <= 10^9\n- 1 <= horizontalCuts.length <= min(h - 1, 10^5)\n- 1 <= verticalCuts.length <= min(w - 1, 10^5)\n- 1 <= horizontalCuts[i] < h\n- 1 <= verticalCuts[i] < w\n- All the elements in horizontalCuts are distinct.\n- All the elements in verticalCuts are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [2, 5, 7]) == 9\n assert candidate(h = 5,w = 4,horizontalCuts = [3, 1],verticalCuts = [1]) == 6\n assert candidate(h = 5,w = 4,horizontalCuts = [1, 2, 4],verticalCuts = [1, 3]) == 4\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [3, 6, 9]) == 9\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 4, 6, 8],verticalCuts = [2, 4, 6, 8]) == 4\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 500000000],verticalCuts = [1, 500000000]) == 250000014\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 999999999],verticalCuts = [1, 999999999]) == 81\n assert candidate(h = 5,w = 4,horizontalCuts = [3],verticalCuts = [3]) == 9\n assert candidate(h = 7,w = 7,horizontalCuts = [1, 2, 3, 4, 5, 6],verticalCuts = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(h = 6,w = 4,horizontalCuts = [1, 2, 5],verticalCuts = [1, 3]) == 6\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [3, 6, 8]) == 9\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [500000000],verticalCuts = [500000000]) == 250000014\n assert candidate(h = 6,w = 6,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 1\n assert candidate(h = 600,w = 800,horizontalCuts = [100, 200, 300, 400, 500],verticalCuts = [120, 240, 360, 480, 600, 720]) == 12000\n assert candidate(h = 100,w = 200,horizontalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 2, 999999998, 999999999],verticalCuts = [1, 2, 999999998, 999999999]) == 121\n assert candidate(h = 50000,w = 100000,horizontalCuts = [25000, 37500],verticalCuts = [50000]) == 249999993\n assert candidate(h = 200,w = 150,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],verticalCuts = [15, 45, 75, 105, 135]) == 600\n assert candidate(h = 7,w = 13,horizontalCuts = [1, 3, 5],verticalCuts = [2, 4, 6, 8, 10, 12]) == 4\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [500000000, 250000000, 750000000, 100000000],verticalCuts = [500000000, 250000000, 750000000, 100000000]) == 562500007\n assert candidate(h = 100,w = 50,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 50\n assert candidate(h = 500,w = 400,horizontalCuts = [100, 200, 300],verticalCuts = [80, 160, 240, 320]) == 16000\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 30, 50, 70, 90],verticalCuts = [20, 40, 60, 80]) == 400\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [100, 200, 300, 400, 500],verticalCuts = [150, 250, 350, 450, 550]) == 282399\n assert candidate(h = 1000,w = 1000,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 828100\n assert candidate(h = 1000,w = 1000,horizontalCuts = [250, 500, 750],verticalCuts = [250, 500, 750]) == 62500\n assert candidate(h = 1000,w = 1000,horizontalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],verticalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 819025\n assert candidate(h = 8,w = 12,horizontalCuts = [2, 3, 5, 7],verticalCuts = [2, 4, 6, 8, 10]) == 4\n assert candidate(h = 8,w = 8,horizontalCuts = [2, 4, 6],verticalCuts = [2, 4, 6]) == 4\n assert candidate(h = 1000,w = 1000,horizontalCuts = [1, 2, 3, 997, 998, 999],verticalCuts = [1, 2, 3, 997, 998, 999]) == 988036\n assert candidate(h = 500,w = 500,horizontalCuts = [25, 125, 225, 325, 425],verticalCuts = [25, 125, 225, 325, 425]) == 10000\n assert candidate(h = 50,w = 60,horizontalCuts = [10, 20, 30, 40],verticalCuts = [12, 24, 36, 48]) == 120\n assert candidate(h = 1000,w = 500,horizontalCuts = [200, 400, 600, 800],verticalCuts = [100, 200, 300, 400]) == 20000\n assert candidate(h = 50000,w = 30000,horizontalCuts = [10000, 20000, 30000, 40000],verticalCuts = [5000, 10000, 15000, 25000, 28000]) == 100000000\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [1, 999999],verticalCuts = [1, 999999]) == 995993011\n assert candidate(h = 200,w = 300,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],verticalCuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285]) == 150\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 100\n assert candidate(h = 500,w = 300,horizontalCuts = [50, 100, 150, 200, 250, 450],verticalCuts = [30, 60, 90, 120, 150, 180, 210, 240, 270]) == 6000\n assert candidate(h = 1000,w = 1000,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 10000\n assert candidate(h = 50,w = 50,horizontalCuts = [25],verticalCuts = [25]) == 625\n assert candidate(h = 30,w = 40,horizontalCuts = [5, 15, 25],verticalCuts = [8, 16, 24, 32]) == 80\n assert candidate(h = 100,w = 150,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [15, 30, 45, 60, 75, 90, 120, 135]) == 300\n assert candidate(h = 150,w = 200,horizontalCuts = [25, 50, 75, 100, 125],verticalCuts = [30, 60, 90, 120, 150, 180]) == 750\n assert candidate(h = 100000,w = 50000,horizontalCuts = [50000],verticalCuts = [25000, 37500]) == 249999993\n assert candidate(h = 1000,w = 1000,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10000\n assert candidate(h = 1000,w = 500,horizontalCuts = [10, 20, 30, 40, 50],verticalCuts = [25, 50, 75, 100, 125]) == 356250\n assert candidate(h = 2000,w = 3000,horizontalCuts = [500, 1000, 1500],verticalCuts = [750, 1500, 2250]) == 375000\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [500000],verticalCuts = [500000]) == 999998257\n assert candidate(h = 15,w = 20,horizontalCuts = [1, 3, 5, 7, 9, 11, 13],verticalCuts = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 4\n assert candidate(h = 10,w = 10,horizontalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(h = 100,w = 100,horizontalCuts = [1, 99],verticalCuts = [1, 99]) == 9604\n assert candidate(h = 500000000,w = 300000000,horizontalCuts = [100000000, 200000000, 300000000, 400000000],verticalCuts = [50000000, 150000000, 250000000]) == 930000007\n assert candidate(h = 1000,w = 2000,horizontalCuts = [250, 500, 750],verticalCuts = [500, 1000, 1500]) == 125000\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [20, 40, 60, 80, 100, 120, 140, 160, 180]) == 200\n assert candidate(h = 10,w = 10,horizontalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(h = 100000,w = 100000,horizontalCuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],verticalCuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 99999944\n assert candidate(h = 20,w = 30,horizontalCuts = [3, 6, 9, 12, 15, 18],verticalCuts = [4, 8, 12, 16, 24, 28]) == 24\n assert candidate(h = 800,w = 600,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],verticalCuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 315000\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 500000000, 999999999],verticalCuts = [1, 500000000, 999999999]) == 250000022\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 169\n assert candidate(h = 800,w = 600,horizontalCuts = [50, 150, 250, 350, 450, 550, 650, 750],verticalCuts = [30, 130, 230, 330, 430, 530, 590]) == 10000\n assert candidate(h = 200,w = 100,horizontalCuts = [20, 180],verticalCuts = [10, 90]) == 12800\n assert candidate(h = 150,w = 200,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 140],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 200\n assert candidate(h = 999,w = 999,horizontalCuts = [1, 998],verticalCuts = [1, 998]) == 994009\n assert candidate(h = 200,w = 200,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],verticalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 400\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000],verticalCuts = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 999999937\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [500000000],verticalCuts = [500000000]) == 250000014\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 144\n assert candidate(h = 999999,w = 999999,horizontalCuts = [1, 999998],verticalCuts = [1, 999998]) == 993993016\n assert candidate(h = 500,w = 600,horizontalCuts = [100, 200, 300, 400],verticalCuts = [150, 250, 350, 450, 550]) == 15000\n assert candidate(h = 10000,w = 10000,horizontalCuts = [2500, 5000, 7500],verticalCuts = [2500, 5000, 7500]) == 6250000\n assert candidate(h = 30,w = 20,horizontalCuts = [2, 5, 8, 12, 16, 25],verticalCuts = [2, 4, 6, 10, 14]) == 54\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 90],verticalCuts = [20, 180]) == 12800\n assert candidate(h = 1000,w = 1500,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [150, 300, 450, 600, 750, 900, 1200, 1350]) == 30000\n assert candidate(h = 25,w = 30,horizontalCuts = [5, 10, 15, 20],verticalCuts = [5, 10, 15, 20, 25]) == 25\n assert candidate(h = 50,w = 50,horizontalCuts = [1, 5, 10, 25, 49],verticalCuts = [2, 10, 20, 30, 45]) == 360\n assert candidate(h = 1000,w = 1000,horizontalCuts = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10000\n assert candidate(h = 20,w = 15,horizontalCuts = [1, 5, 10, 15],verticalCuts = [2, 6, 10, 14]) == 20\n assert candidate(h = 500,w = 500,horizontalCuts = [100, 150, 200, 250, 300, 350, 400, 450],verticalCuts = [100, 150, 200, 250, 300, 350, 400, 450]) == 10000\n assert candidate(h = 100,w = 100,horizontalCuts = [1, 50, 99],verticalCuts = [1, 50, 99]) == 2401\n assert candidate(h = 50,w = 200,horizontalCuts = [5, 15, 25, 35, 45],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 100\n assert candidate(h = 300,w = 300,horizontalCuts = [50, 100, 150, 200, 250],verticalCuts = [50, 100, 150, 200, 250]) == 2500\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n", "comparison": "exact"}, "public_tests": ["5\n4\n[1,2,4]\n[1,3]", "5\n4\n[3,1]\n[1]", "5\n4\n[3]\n[3]"], "hints": ["Sort the arrays, then compute the maximum difference between two consecutive elements for horizontal cuts and vertical cuts.", "The answer is the product of these maximum values in horizontal cuts and vertical cuts."], "metadata": {"canonical_parameter_names": ["h", "w", "horizontalCuts", "verticalCuts"], "leetcode_dataset_entry_point": "Solution().maxArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:00+00:00", "tests_total": 92, "tests_dropped": 7, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxArea(self, h: int, w: int, horizontalCuts: list[int], verticalCuts: list[int]) -> int:", "container": "Solution", "callable": "maxArea", "parameters": [{"name": "h", "type": "int"}, {"name": "w", "type": "int"}, {"name": "horizontalCuts", "type": "list[int]"}, {"name": "verticalCuts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1466, "task_id": "reorder-routes-to-make-all-paths-lead-to-the-city-zero", "difficulty": "Medium", "problem_description": "There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.\n\nRoads are represented by connections where connections[i] = [a_i, b_i] represents a road from city a_i to city b_i.\n\nThis year, there will be a big event in the capital (city 0), and many people want to travel to this city.\n\nYour task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.\n\nIt's guaranteed that each city can reach city 0 after reorder.\n\nExample 1:\n\nInput: n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]\nOutput: 3\nExplanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).\n\nExample 2:\n\nInput: n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]\nOutput: 2\nExplanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).\n\nExample 3:\n\nInput: n = 3, connections = [[1,0],[2,0]]\nOutput: 0\n\nConstraints:\n\n- 2 <= n <= 5 * 10^4\n- connections.length == n - 1\n- connections[i].length == 2\n- 0 <= a_i, b_i <= n - 1\n- a_i != b_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,connections = [[1, 0], [2, 0], [3, 1], [4, 0], [5, 0], [6, 4]]) == 0\n assert candidate(n = 6,connections = [[0, 1], [1, 3], [2, 3], [4, 0], [4, 5]]) == 3\n assert candidate(n = 5,connections = [[1, 0], [1, 2], [3, 2], [3, 4]]) == 2\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [3, 2], [4, 2], [5, 4], [6, 4]]) == 2\n assert candidate(n = 4,connections = [[2, 0], [3, 0], [1, 2]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [2, 0], [3, 2], [4, 2], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == 1\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 6\n assert candidate(n = 3,connections = [[1, 0], [2, 0]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [3, 2], [4, 3], [5, 4], [6, 5]]) == 2\n assert candidate(n = 7,connections = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]]) == 0\n assert candidate(n = 20,connections = [[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(n = 12,connections = [[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(n = 30,connections = [[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]]) == 29\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [0, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 18,connections = [[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]]) == 17\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [13, 14]]) == 14\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 11,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [5, 10]]) == 10\n assert candidate(n = 15,connections = [[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]]) == 14\n assert candidate(n = 13,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == 12\n assert candidate(n = 18,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == 17\n assert candidate(n = 15,connections = [[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]]) == 14\n assert candidate(n = 16,connections = [[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], [8, 15]]) == 15\n assert candidate(n = 16,connections = [[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(n = 9,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]]) == 8\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [7, 5]]) == 6\n assert candidate(n = 12,connections = [[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(n = 12,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 20,connections = [[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(n = 10,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]]) == 11\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 11\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 14,connections = [[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]]) == 13\n assert candidate(n = 20,connections = [[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, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 19\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 11\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [12, 13]]) == 13\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 8\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(n = 20,connections = [[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]]) == 19\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [6, 9]]) == 9\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [0, 3], [3, 4], [2, 5], [5, 6], [4, 7], [7, 8]]) == 8\n assert candidate(n = 18,connections = [[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]]) == 17\n assert candidate(n = 13,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [11, 12]]) == 12\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [8, 9]]) == 9\n assert candidate(n = 25,connections = [[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]]) == 24\n assert candidate(n = 18,connections = [[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, 15], [15, 16], [16, 17]]) == 17\n assert candidate(n = 21,connections = [[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]]) == 20\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [2, 7], [7, 8], [8, 9], [0, 10], [10, 11]]) == 11\n assert candidate(n = 15,connections = [[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]]) == 14\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 14\n assert candidate(n = 14,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 13\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 9\n", "comparison": "exact"}, "public_tests": ["6\n[[0,1],[1,3],[2,3],[4,0],[4,5]]", "5\n[[1,0],[1,2],[3,2],[3,4]]", "3\n[[1,0],[2,0]]"], "hints": ["Treat the graph as undirected. Start a dfs from the root, if you come across an edge in the forward direction, you need to reverse the edge."], "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().minReorder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:02+00:00", "tests_total": 57, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["depth-first-search", "breadth-first-search", "graph"]}, "language": "python", "interface": {"raw_signature": "def minReorder(self, n: int, connections: list[list[int]]) -> int:", "container": "Solution", "callable": "minReorder", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1467, "task_id": "probability-of-a-two-boxes-having-the-same-number-of-distinct-balls", "difficulty": "Hard", "problem_description": "Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i.\n\nAll the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).\n\nPlease note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).\n\nReturn the probability that the two boxes have the same number of distinct balls. Answers within 10^-5 of the actual value will be accepted as correct.\n\nExample 1:\n\nInput: balls = [1,1]\nOutput: 1.00000\nExplanation: Only 2 ways to divide the balls equally:\n- A ball of color 1 to box 1 and a ball of color 2 to box 2\n- A ball of color 2 to box 1 and a ball of color 1 to box 2\nIn both ways, the number of distinct colors in each box is equal. The probability is 2/2 = 1\n\nExample 2:\n\nInput: balls = [2,1,1]\nOutput: 0.66667\nExplanation: We have the set of balls [1, 1, 2, 3]\nThis set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equal probability (i.e. 1/12):\n[1,1 / 2,3], [1,1 / 3,2], [1,2 / 1,3], [1,2 / 3,1], [1,3 / 1,2], [1,3 / 2,1], [2,1 / 1,3], [2,1 / 3,1], [2,3 / 1,1], [3,1 / 1,2], [3,1 / 2,1], [3,2 / 1,1]\nAfter that, we add the first two balls to the first box and the second two balls to the second box.\nWe can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box.\nProbability is 8/12 = 0.66667\n\nExample 3:\n\nInput: balls = [1,2,1,2]\nOutput: 0.60000\nExplanation: The set of balls is [1, 2, 2, 3, 4, 4]. It is hard to display all the 180 possible random shuffles of this set but it is easy to check that 108 of them will have the same number of distinct colors in each box.\nProbability = 108 / 180 = 0.6\n\nConstraints:\n\n- 1 <= balls.length <= 8\n- 1 <= balls[i] <= 6\n- sum(balls) is even.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(balls=[6, 6]), 1.0)\n assert answers_match(candidate(balls=[4, 4, 4, 4]), 0.820979020979021)\n assert answers_match(candidate(balls=[2, 1, 1]), 0.6666666666666666)\n assert answers_match(candidate(balls=[1, 2, 1, 2]), 0.6)\n assert answers_match(candidate(balls=[2, 2, 2, 2]), 1.0)\n assert answers_match(candidate(balls=[6]), 1.0)\n assert answers_match(candidate(balls=[3, 3]), 1.0)\n assert answers_match(candidate(balls=[2, 2, 2]), 1.0)\n assert answers_match(candidate(balls=[1, 1, 1, 1, 1, 1, 1, 1]), 1.0)\n assert answers_match(candidate(balls=[2, 1, 1, 1, 1]), 0.6)\n assert answers_match(candidate(balls=[1, 1]), 1.0)\n assert answers_match(candidate(balls=[3, 2, 1]), 0.3)\n assert answers_match(candidate(balls=[1, 2, 3]), 0.3)\n assert answers_match(candidate(balls=[6, 6, 6, 6, 6, 6, 6, 6]), 0.8557108876701283)\n assert answers_match(candidate(balls=[1, 1, 1, 1]), 1.0)\n assert answers_match(candidate(balls=[1, 1, 2, 2, 3, 3]), 0.38311688311688313)\n assert answers_match(candidate(balls=[4, 2]), 0.6)\n assert answers_match(candidate(balls=[4, 3, 2, 1]), 0.30952380952380953)\n assert answers_match(candidate(balls=[5, 5, 1, 1]), 0.5454545454545454)\n assert answers_match(candidate(balls=[1, 2, 3, 4]), 0.30952380952380953)\n assert answers_match(candidate(balls=[6, 2, 2, 2]), 0.4329004329004329)\n assert answers_match(candidate(balls=[6, 4, 2, 2, 2]), 0.40792540792540793)\n assert answers_match(candidate(balls=[2, 2, 2, 1, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[2, 2, 2, 2, 2, 2]), 1.0)\n assert answers_match(candidate(balls=[6, 6]), 1.0)\n assert answers_match(candidate(balls=[3, 2, 1, 1, 1]), 0.2571428571428571)\n assert answers_match(candidate(balls=[3, 3, 3, 1]), 0.21428571428571427)\n assert answers_match(candidate(balls=[3, 2, 2, 1]), 0.37142857142857144)\n assert answers_match(candidate(balls=[1, 1, 1, 1, 1, 1]), 1.0)\n assert answers_match(candidate(balls=[1, 1, 1, 1, 1, 1]), 1.0)\n assert answers_match(candidate(balls=[6, 6, 6]), 0.9777869189633895)\n assert answers_match(candidate(balls=[1, 2, 3, 4]), 0.30952380952380953)\n assert answers_match(candidate(balls=[3, 2, 2, 1, 1, 1]), 0.30952380952380953)\n assert answers_match(candidate(balls=[5, 3, 2]), 0.5555555555555556)\n assert answers_match(candidate(balls=[6, 1, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[4, 2, 1, 1]), 0.34285714285714286)\n assert answers_match(candidate(balls=[6, 3, 3]), 0.7251082251082251)\n assert answers_match(candidate(balls=[4, 2, 2]), 0.5142857142857142)\n assert answers_match(candidate(balls=[3, 3, 1, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[3, 3, 3, 3, 3, 3]), 0.6334841628959276)\n assert answers_match(candidate(balls=[4, 3, 2, 1]), 0.30952380952380953)\n assert answers_match(candidate(balls=[2, 3, 2, 1]), 0.37142857142857144)\n assert answers_match(candidate(balls=[2, 2, 2, 2]), 1.0)\n assert answers_match(candidate(balls=[4, 4, 4, 2]), 0.5664335664335665)\n assert answers_match(candidate(balls=[2, 2, 1, 1, 1, 1]), 0.5142857142857142)\n assert answers_match(candidate(balls=[1, 1, 1, 1, 1, 1, 1, 1]), 1.0)\n assert answers_match(candidate(balls=[6, 2, 1, 1]), 0.31746031746031744)\n assert answers_match(candidate(balls=[4, 3, 1]), 0.11428571428571428)\n assert answers_match(candidate(balls=[5, 1, 1, 1, 1, 1]), 0.0)\n assert answers_match(candidate(balls=[4, 4, 1, 1]), 0.5555555555555556)\n assert answers_match(candidate(balls=[6, 2, 2]), 0.47619047619047616)\n assert answers_match(candidate(balls=[1, 3, 3, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[5, 1, 1, 1]), 0.0)\n assert answers_match(candidate(balls=[3, 3, 1, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[3, 3, 3, 3]), 0.7662337662337663)\n assert answers_match(candidate(balls=[3, 3, 3, 3]), 0.7662337662337663)\n assert answers_match(candidate(balls=[4, 2]), 0.6)\n assert answers_match(candidate(balls=[5, 1, 1, 1]), 0.0)\n assert answers_match(candidate(balls=[4, 2, 2]), 0.5142857142857142)\n assert answers_match(candidate(balls=[2, 2, 1, 1, 1, 1]), 0.5142857142857142)\n assert answers_match(candidate(balls=[4, 4, 4, 4]), 0.820979020979021)\n assert answers_match(candidate(balls=[1, 1, 2, 2, 3, 3]), 0.38311688311688313)\n assert answers_match(candidate(balls=[4, 4, 2, 2]), 0.5238095238095238)\n assert answers_match(candidate(balls=[6, 1, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[6, 6, 1, 1]), 0.5384615384615384)\n assert answers_match(candidate(balls=[4, 4, 2]), 0.6190476190476191)\n assert answers_match(candidate(balls=[6, 2, 2, 2, 2, 2, 2]), 0.38009049773755654)\n assert answers_match(candidate(balls=[4, 4, 3, 2, 1]), 0.30186480186480186)\n assert answers_match(candidate(balls=[3, 2, 1, 1, 1]), 0.2571428571428571)\n assert answers_match(candidate(balls=[4, 4, 4]), 0.8961038961038961)\n assert answers_match(candidate(balls=[2, 2, 2, 2, 2, 2]), 1.0)\n assert answers_match(candidate(balls=[1, 2, 3, 2]), 0.37142857142857144)\n assert answers_match(candidate(balls=[5, 2, 2, 1]), 0.31746031746031744)\n assert answers_match(candidate(balls=[3, 2, 1]), 0.3)\n assert answers_match(candidate(balls=[2, 2, 2, 1, 1]), 0.5714285714285714)\n assert answers_match(candidate(balls=[3, 2, 2, 1]), 0.37142857142857144)\n", "comparison": "float"}, "public_tests": ["[1,1]", "[2,1,1]", "[1,2,1,2]"], "hints": ["Check how many ways you can distribute the balls between the boxes.", "Consider that one way you will use (x1, x2, x3, ..., xk) where xi is the number of balls from colour i. The probability of achieving this way randomly is ( (ball1 C x1) * (ball2 C x2) * (ball3 C x3) * ... * (ballk C xk)) / (2n C n).", "The probability of a draw is the sigma of probabilities of different ways to achieve draw.", "Can you use Dynamic programming to solve this problem in a better complexity ?"], "metadata": {"canonical_parameter_names": ["balls"], "leetcode_dataset_entry_point": "Solution().getProbability", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:04+00:00", "tests_total": 102, "tests_dropped": 26, "flags": ["decimal_answer"], "topic_tags": ["array", "math", "dynamic-programming", "backtracking", "combinatorics", "probability-and-statistics"]}, "language": "python", "interface": {"raw_signature": "def getProbability(self, balls: list[int]) -> float:", "container": "Solution", "callable": "getProbability", "parameters": [{"name": "balls", "type": "list[int]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1470, "task_id": "shuffle-the-array", "difficulty": "Easy", "problem_description": "Given the array nums consisting of 2n elements in the form [x_1,x_2,...,x_n,y_1,y_2,...,y_n].\n\nReturn the array in the form [x_1,y_1,x_2,y_2,...,x_n,y_n].\n\nExample 1:\n\nInput: nums = [2,5,1,3,4,7], n = 3\nOutput: [2,3,5,4,1,7]\nExplanation: Since x_1=2, x_2=5, x_3=1, y_1=3, y_2=4, y_3=7 then the answer is [2,3,5,4,1,7].\n\nExample 2:\n\nInput: nums = [1,2,3,4,4,3,2,1], n = 4\nOutput: [1,4,2,3,3,2,4,1]\n\nExample 3:\n\nInput: nums = [1,1,2,2], n = 2\nOutput: [1,2,1,2]\n\nConstraints:\n\n- 1 <= n <= 500\n- nums.length == 2n\n- 1 <= nums[i] <= 10^3\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],n = 6) == [5, 11, 6, 12, 7, 13, 8, 14, 9, 15, 10, 16]\n assert candidate(nums = [2, 5, 1, 3, 4, 7],n = 3) == [2, 3, 5, 4, 1, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],n = 4) == [10, 50, 20, 60, 30, 70, 40, 80]\n assert candidate(nums = [7, 11, 3, 4, 8, 10],n = 3) == [7, 4, 11, 8, 3, 10]\n assert candidate(nums = [6, 2, 3, 4, 5, 1],n = 3) == [6, 4, 2, 5, 3, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 8) == [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, 11, 12],n = 6) == [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]\n assert candidate(nums = [5, 3, 2, 4, 1, 6],n = 3) == [5, 4, 3, 1, 2, 6]\n assert candidate(nums = [1, 1, 2, 2],n = 2) == [1, 2, 1, 2]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 3) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203],n = 4) == [100, 102, 200, 202, 101, 103, 201, 203]\n assert candidate(nums = [100, 200, 101, 201, 102, 202],n = 3) == [100, 201, 200, 102, 101, 202]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],n = 10) == [999, 2, 888, 3, 777, 4, 666, 5, 555, 6, 444, 7, 333, 8, 222, 9, 111, 10, 1, 11]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14],n = 4) == [7, 11, 8, 12, 9, 13, 10, 14]\n assert candidate(nums = [1, 2, 3, 4, 4, 3, 2, 1],n = 4) == [1, 4, 2, 3, 3, 2, 4, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30],n = 8) == [1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 30]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],n = 17) == [5, 22, 6, 23, 7, 24, 8, 25, 9, 26, 10, 27, 11, 28, 12, 29, 13, 30, 14, 31, 15, 32, 16, 33, 17, 34]\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],n = 20) == [1, 11, 1, 11, 2, 12, 2, 12, 3, 13, 3, 13, 4, 14, 4, 14, 5, 15, 5, 15, 6, 16, 6, 16, 7, 17, 7, 17, 8, 18, 8, 18, 9, 19, 9, 19, 10, 20, 10, 20]\n assert candidate(nums = [500, 1, 499, 2, 498, 3, 497, 4, 496, 5, 495, 6, 494, 7, 493, 8, 492, 9, 491, 10, 490, 11, 489, 12, 488, 13, 487, 14, 486, 15, 485, 16, 484, 17, 483, 18, 482, 19, 481, 20],n = 25) == [500, 13, 1, 487, 499, 14, 2, 486, 498, 15, 3, 485, 497, 16, 4, 484, 496, 17, 5, 483, 495, 18, 6, 482, 494, 19, 7, 481, 493, 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],n = 15) == [1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 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, 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],n = 25) == [10, 260, 20, 270, 30, 280, 40, 290, 50, 300, 60, 310, 70, 320, 80, 330, 90, 340, 100, 350, 110, 360, 120, 370, 130, 380, 140, 390, 150, 400, 160, 410, 170, 420, 180, 430, 190, 440, 200, 450, 210, 460, 220, 470, 230, 480, 240, 490, 250, 500]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10) == [999, 2, 888, 3, 777, 4, 666, 5, 555, 6, 444, 7, 333, 8, 222, 9, 111, 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],n = 15) == [2, 32, 4, 34, 6, 36, 8, 38, 10, 40, 12, 42, 14, 44, 16, 46, 18, 48, 20, 50, 22, 52, 24, 54, 26, 56, 28, 58, 30, 60]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 10) == [5, 55, 10, 60, 15, 65, 20, 70, 25, 75, 30, 80, 35, 85, 40, 90, 45, 95, 50, 100]\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],n = 15) == [1000, 985, 999, 984, 998, 983, 997, 982, 996, 981, 995, 980, 994, 979, 993, 978, 992, 977, 991, 976, 990, 975, 989, 974, 988, 973, 987, 972, 986, 971]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 10) == [9, 11, 8, 12, 7, 13, 6, 14, 5, 15, 4, 16, 3, 17, 2, 18, 1, 19, 10, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],n = 10) == [10, 20, 9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11]\n assert candidate(nums = [99, 100, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60],n = 32) == [99, 68, 100, 67, 98, 66, 97, 65, 96, 64, 95, 63, 94, 62, 93, 61, 92, 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],n = 25) == [1, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]\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],n = 25) == [300, 275, 299, 274, 298, 273, 297, 272, 296, 271, 295, 270, 294, 269, 293, 268, 292, 267, 291, 266, 290, 265, 289, 264, 288, 263, 287, 262, 286, 261, 285, 260, 284, 259, 283, 258, 282, 257, 281, 256, 280, 255, 279, 254, 278, 253, 277, 252, 276, 251]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 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 = 15) == [100, 6, 200, 7, 300, 8, 400, 9, 500, 10, 600, 11, 700, 12, 800, 13, 900, 14, 1000, 15, 1, 16, 2, 17, 3, 18, 4, 19, 5, 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],n = 17) == [5, 90, 10, 95, 15, 100, 20, 105, 25, 110, 30, 115, 35, 120, 40, 125, 45, 130, 50, 135, 55, 140, 60, 145, 65, 150, 70, 155, 75, 160, 80, 165, 85, 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, 32],n = 16) == [1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31, 16, 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],n = 10) == [5, 55, 10, 60, 15, 65, 20, 70, 25, 75, 30, 80, 35, 85, 40, 90, 45, 95, 50, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],n = 15) == [5, 80, 10, 85, 15, 90, 20, 95, 25, 100, 30, 105, 35, 110, 40, 115, 45, 120, 50, 125, 55, 130, 60, 135, 65, 140, 70, 145, 75, 150]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],n = 8) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\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, 1, 2, 3, 4, 5, 6, 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 = 30) == [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, 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],n = 10) == [10, 110, 20, 120, 30, 130, 40, 140, 50, 150, 60, 160, 70, 170, 80, 180, 90, 190, 100, 200]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],n = 8) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80, 160]\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 = 10) == [1, 6, 1, 6, 2, 7, 2, 7, 3, 8, 3, 8, 4, 9, 4, 9, 5, 10, 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, 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],n = 75) == [1, 76, 2, 77, 3, 78, 4, 79, 5, 80, 6, 81, 7, 82, 8, 83, 9, 84, 10, 85, 11, 86, 12, 87, 13, 88, 14, 89, 15, 90, 16, 91, 17, 92, 18, 93, 19, 94, 20, 95, 21, 96, 22, 97, 23, 98, 24, 99, 25, 100, 26, 101, 27, 102, 28, 103, 29, 104, 30, 105, 31, 106, 32, 107, 33, 108, 34, 109, 35, 110, 36, 111, 37, 112, 38, 113, 39, 114, 40, 115, 41, 116, 42, 117, 43, 118, 44, 119, 45, 120, 46, 121, 47, 122, 48, 123, 49, 124, 50, 125, 51, 126, 52, 127, 53, 128, 54, 129, 55, 130, 56, 131, 57, 132, 58, 133, 59, 134, 60, 135, 61, 136, 62, 137, 63, 138, 64, 139, 65, 140, 66, 141, 67, 142, 68, 143, 69, 144, 70, 145, 71, 146, 72, 147, 73, 148, 74, 149, 75, 150]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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 = 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, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 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, 21, 22, 23, 24, 25, 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 = 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, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 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, 41, 43, 45, 47, 49],n = 12) == [1, 25, 3, 27, 5, 29, 7, 31, 9, 33, 11, 35, 13, 37, 15, 39, 17, 41, 19, 43, 21, 45, 23, 47]\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],n = 15) == [10, 160, 20, 170, 30, 180, 40, 190, 50, 200, 60, 210, 70, 220, 80, 230, 90, 240, 100, 250, 110, 260, 120, 270, 130, 280, 140, 290, 150, 300]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],n = 8) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(nums = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104, 6, 105, 7, 106, 8, 107, 9, 108, 10, 109, 11, 110, 12, 111, 13, 112, 14, 113, 15, 114, 16, 115, 17, 116, 18, 117, 19, 118, 20, 119, 21, 120, 22, 121, 23, 122, 24, 123, 25, 124, 26, 125, 27, 126, 28, 127, 29, 128, 30, 129],n = 15) == [1, 107, 100, 9, 2, 108, 101, 10, 3, 109, 102, 11, 4, 110, 103, 12, 5, 111, 104, 13, 6, 112, 105, 14, 7, 113, 106, 15, 8, 114]\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],n = 25) == [1000, 975, 999, 974, 998, 973, 997, 972, 996, 971, 995, 970, 994, 969, 993, 968, 992, 967, 991, 966, 990, 965, 989, 964, 988, 963, 987, 962, 986, 961, 985, 960, 984, 959, 983, 958, 982, 957, 981, 956, 980, 955, 979, 954, 978, 953, 977, 952, 976, 951]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 20) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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(nums = [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, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410],n = 10) == [101, 201, 102, 202, 103, 203, 104, 204, 105, 205, 106, 206, 107, 207, 108, 208, 109, 209, 110, 210]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 400],n = 20) == [5, 205, 15, 215, 25, 225, 35, 235, 45, 245, 55, 255, 65, 265, 75, 275, 85, 285, 95, 295, 105, 305, 115, 315, 125, 325, 135, 335, 145, 345, 155, 355, 165, 365, 175, 375, 185, 385, 195, 395]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],n = 8) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80, 160]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 16) == [1, 2, 3, 4, 5, 6, 7, 8, 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, 5, 5, 5, 5, 5, 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 = 15) == [5, 5, 5, 5, 5, 5, 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, 10, 11, 12, 13, 14, 15, 16, 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 = 20) == [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]\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, 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, 929, 928, 927, 926, 925, 924, 923, 922, 921, 920, 919, 918, 917, 916, 915, 914, 913, 912, 911, 910],n = 50) == [999, 949, 998, 948, 997, 947, 996, 946, 995, 945, 994, 944, 993, 943, 992, 942, 991, 941, 990, 940, 989, 939, 988, 938, 987, 937, 986, 936, 985, 935, 984, 934, 983, 933, 982, 932, 981, 931, 980, 930, 979, 929, 978, 928, 977, 927, 976, 926, 975, 925, 974, 924, 973, 923, 972, 922, 971, 921, 970, 920, 969, 919, 968, 918, 967, 917, 966, 916, 965, 915, 964, 914, 963, 913, 962, 912, 961, 911, 960, 910]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],n = 10) == [1, 6, 3, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15, 20, 2, 22, 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, 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 = 30) == [1, 16, 1, 16, 2, 17, 2, 17, 3, 18, 3, 18, 4, 19, 4, 19, 5, 20, 5, 20, 6, 21, 6, 21, 7, 22, 7, 22, 8, 23, 8, 23, 9, 24, 9, 24, 10, 25, 10, 25, 11, 26, 11, 26, 12, 27, 12, 27, 13, 28, 13, 28, 14, 29, 14, 29, 15, 30, 15, 30]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295],n = 15) == [5, 155, 15, 165, 25, 175, 35, 185, 45, 195, 55, 205, 65, 215, 75, 225, 85, 235, 95, 245, 105, 255, 115, 265, 125, 275, 135, 285, 145, 295]\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, 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],n = 50) == [999, 949, 998, 948, 997, 947, 996, 946, 995, 945, 994, 944, 993, 943, 992, 942, 991, 941, 990, 940, 989, 939, 988, 938, 987, 937, 986, 936, 985, 935, 984, 934, 983, 933, 982, 932, 981, 931, 980, 930]\n", "comparison": "exact"}, "public_tests": ["[2,5,1,3,4,7]\n3", "[1,2,3,4,4,3,2,1]\n4", "[1,1,2,2]\n2"], "hints": ["Use two pointers to create the new array of 2n elements. The first starting at the beginning and the other starting at (n+1)th position. Alternate between them and create the new array."], "metadata": {"canonical_parameter_names": ["nums", "n"], "leetcode_dataset_entry_point": "Solution().shuffle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:08+00:00", "tests_total": 71, "tests_dropped": 11, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def shuffle(self, nums: List[int], n: int) -> List[int]:", "container": "Solution", "callable": "shuffle", "parameters": [{"name": "nums", "type": "List[int]"}, {"name": "n", "type": "int"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1471, "task_id": "the-k-strongest-values-in-an-array", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k.\n\nA value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the centre of the array.\nIf |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].\n\nReturn a list of the strongest k values in the array. Return the answer in any arbitrary order.\n\nThe centre is the middle value in an ordered integer list. More formally, if the length of the list is n, the centre is the element in position ((n - 1) / 2) in the sorted list (0-indexed).\n\n- For arr = [6, -3, 7, 2, 11], n = 5 and the centre is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the centre is arr[m] where m = ((5 - 1) / 2) = 2. The centre is 6.\n- For arr = [-7, 22, 17, 3], n = 4 and the centre is obtained by sorting the array arr = [-7, 3, 17, 22] and the centre is arr[m] where m = ((4 - 1) / 2) = 1. The centre is 3.\n\nExample 1:\n\nInput: arr = [1,2,3,4,5], k = 2\nOutput: [5,1]\nExplanation: Centre is 3, the elements of the array sorted by the strongest are [5,1,4,2,3]. The strongest 2 elements are [5, 1]. [1, 5] is also accepted answer.\nPlease note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 > 1.\n\nExample 2:\n\nInput: arr = [1,1,3,5,5], k = 2\nOutput: [5,5]\nExplanation: Centre is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].\n\nExample 3:\n\nInput: arr = [6,7,11,7,6,8], k = 5\nOutput: [11,8,6,6,7]\nExplanation: Centre is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].\nAny permutation of [11,8,6,6,7] is accepted.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- -10^5 <= arr[i] <= 10^5\n- 1 <= k <= arr.length\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(arr=[1, 2, 3, 4, 5], k=2), [5, 1])\n assert answers_match(candidate(arr=[100000, -100000, 50000, -50000, 0], k=3), [100000, -100000, 50000])\n assert answers_match(candidate(arr=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], k=3), [9, 8, 0])\n assert answers_match(candidate(arr=[1, 1, 3, 5, 5], k=2), [5, 5])\n assert answers_match(candidate(arr=[1, 3, 2, 4, 5], k=3), [5, 1, 4])\n assert answers_match(candidate(arr=[-100000, 100000], k=1), [100000])\n assert answers_match(candidate(arr=[6, -3, 7, 2, 11], k=4), [-3, 11, 2, 7])\n assert answers_match(candidate(arr=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=4), [10, 9, 1, 8])\n assert answers_match(candidate(arr=[-7, 22, 17, 3], k=2), [22, 17])\n assert answers_match(candidate(arr=[6, 7, 11, 7, 6, 8], k=5), [11, 8, 6, 6, 7])\n assert answers_match(candidate(arr=[5, 3, 1, 2, 4], k=3), [5, 1, 4])\n assert answers_match(candidate(arr=[0, 0, 0, 0, 0], k=1), [0])\n assert answers_match(candidate(arr=[-7, 22, 17, 3], k=3), [22, 17, -7])\n assert answers_match(candidate(arr=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=3), [10, 9, 1])\n assert answers_match(candidate(arr=[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15], k=6), [-1, -15, -2, -14, -3, -13])\n assert answers_match(candidate(arr=[-99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990], k=5), [-99990, -99991, -99999, -99992, -99998])\n assert answers_match(candidate(arr=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110], k=7), [110, 10, 100, 20, 90, 30, 80])\n assert answers_match(candidate(arr=[-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35], k=6), [35, 30, 25, -35, 20, -30])\n assert answers_match(candidate(arr=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=3), [1, 1, 1])\n assert answers_match(candidate(arr=[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], k=5), [-1, -2, -10, -3, -9])\n assert answers_match(candidate(arr=[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], k=4), [-1, -2, -10, -3])\n assert answers_match(candidate(arr=[1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10], k=10), [1, 10, 10, 10, 2, 2, 9, 9, 3, 8])\n assert answers_match(candidate(arr=[1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91], k=8), [100, 99, 98, 97, 96, 95, 94, 93])\n assert answers_match(candidate(arr=[-5, -3, -1, 1, 3, 5, -4, -2, 0, 2, 4, 6], k=5), [6, 5, -5, 4, -4])\n assert answers_match(candidate(arr=[1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000], k=7), [10000, 9000, 1000, 8000, 2000, 7000, 3000])\n assert answers_match(candidate(arr=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=5), [1, 1, 1, 1, 1])\n assert answers_match(candidate(arr=[-10, -5, 0, 5, 10, 15], k=3), [15, 10, -10])\n assert answers_match(candidate(arr=[1, 3, 2, 4, 6, 5, 7, 8, 10, 9, 11], k=8), [11, 1, 10, 2, 9, 3, 8, 4])\n assert answers_match(candidate(arr=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=5), [100, 90, 10, 80, 20])\n assert answers_match(candidate(arr=[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], k=6), [100, 90, 10, 80, 20, 70])\n assert answers_match(candidate(arr=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], k=8), [29, 1, 27, 3, 25, 5, 23, 7])\n assert answers_match(candidate(arr=[1000, 900, 800, 700, 600, 500, 400, 300, 200, 100], k=3), [1000, 900, 100])\n assert answers_match(candidate(arr=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000], k=10), [1000, 900, 800, -1000, 700, -900, 600, -800, 500, -700])\n assert answers_match(candidate(arr=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=5), [1000, 900, 100, 800, 200])\n assert answers_match(candidate(arr=[9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], k=10), [9, -9, 8, -8, 7, -7, 6, -6, 5, -5])\n assert answers_match(candidate(arr=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130], k=8), [130, 10, 120, 20, 110, 30, 100, 40])\n assert answers_match(candidate(arr=[1000, -1000, 500, -500, 250, -250, 750, -750, 375, -375], k=5), [1000, 750, 500, -1000, 375])\n assert answers_match(candidate(arr=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=5), [5, 5, 5, 5, 5])\n assert answers_match(candidate(arr=[1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000], k=6), [13000, 1000, 12000, 2000, 11000, 3000])\n assert answers_match(candidate(arr=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=3), [5, 5, 5])\n assert answers_match(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], k=10), [5, 5, 5, 5, 5, 5, 5, 5, 5, 5])\n assert answers_match(candidate(arr=[100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991], k=5), [100000, 99999, 99991, 99998, 99992])\n assert answers_match(candidate(arr=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=5), [1, 1, 1, 1, 1])\n assert answers_match(candidate(arr=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], k=6), [19, 17, 1, 15, 3, 13])\n assert answers_match(candidate(arr=[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], k=8), [99, 98, 90, 97, 91, 96, 92, 95])\n assert answers_match(candidate(arr=[1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5], k=8), [1, 2, 2, 5, 5, 5, 5, 5])\n assert answers_match(candidate(arr=[100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250], k=7), [100000, -100000, 50000, -50000, 25000, 12500, -25000])\n assert answers_match(candidate(arr=[-10, -20, 15, 10, 0, 5, -5], k=4), [-20, 15, 10, -10])\n assert answers_match(candidate(arr=[-1, 1, -2, 2, -3, 3, -4, 4, -5, 5], k=4), [5, 4, 3, -5])\n assert answers_match(candidate(arr=[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5], k=9), [5, 5, 5, 1, 1, 1, 4, 4, 4])\n assert answers_match(candidate(arr=[-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000, -11000, -12000, -13000], k=7), [-1000, -13000, -2000, -12000, -3000, -11000, -4000])\n assert answers_match(candidate(arr=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=10), [1, 1, 1, 1, 1, 1, 1, 1, 1, 1])\n assert answers_match(candidate(arr=[1, 10, 100, 1000, 10000, 100000, -1, -10, -100, -1000, -10000, -100000], k=6), [100000, -100000, 10000, -10000, 1000, -1000])\n assert answers_match(candidate(arr=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=6), [10, 9, 1, 8, 2, 7])\n assert answers_match(candidate(arr=[-500, -300, -100, 100, 300, 500, 700, 900, 1100, 1300], k=8), [1300, 1100, -500, 900, -300, 700, -100, 500])\n assert answers_match(candidate(arr=[-5, -5, -5, -5, -5, 5, 5, 5, 5, 5], k=8), [5, 5, 5, 5, 5, -5, -5, -5])\n assert answers_match(candidate(arr=[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], k=7), [-1, -2, -10, -3, -9, -4, -8])\n assert answers_match(candidate(arr=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=10), [20, 19, 1, 18, 2, 17, 3, 16, 4, 15])\n assert answers_match(candidate(arr=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], k=5), [19, 17, 1, 15, 3])\n assert answers_match(candidate(arr=[23, 45, 12, 67, 34, 89, 90, 21, 56, 78, 9, 34, 56, 78, 90], k=10), [9, 12, 21, 90, 90, 89, 23, 78, 78, 34])\n assert answers_match(candidate(arr=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=7), [1000, 900, 100, 800, 200, 700, 300])\n assert answers_match(candidate(arr=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=4), [5, 5, 5, 5])\n assert answers_match(candidate(arr=[-10, -5, 0, 5, 10, 15, 20, 25, 30], k=5), [30, -10, 25, -5, 20])\n assert answers_match(candidate(arr=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], k=5), [0, 0, 0, 0, 0])\n assert answers_match(candidate(arr=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=7), [15, 1, 14, 2, 13, 3, 12])\n assert answers_match(candidate(arr=[39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1], k=8), [39, 37, 1, 35, 3, 33, 5, 31])\n assert answers_match(candidate(arr=[9, 3, 7, -1, 2, 5, 8, -4, 6], k=5), [-4, -1, 9, 8, 2])\n assert answers_match(candidate(arr=[-100, 100, -50, 50, 0], k=3), [100, -100, 50])\n assert answers_match(candidate(arr=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], k=10), [150, 10, 140, 20, 130, 30, 120, 40, 110, 50])\n assert answers_match(candidate(arr=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], k=7), [29, 1, 27, 3, 25, 5, 23])\n assert answers_match(candidate(arr=[-20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40], k=6), [40, -20, 35, -15, 30, -10])\n assert answers_match(candidate(arr=[-50, -40, -30, -20, -10, 10, 20, 30, 40, 50], k=6), [50, 40, 30, -50, 20, -40])\n assert answers_match(candidate(arr=[10, -20, 30, -40, 50, -60, 70], k=5), [-60, 70, -40, 50, -20])\n assert answers_match(candidate(arr=[-1, -2, -3, -4, -5, 5, 4, 3, 2, 1], k=5), [5, 4, 3, -5, 2])\n assert answers_match(candidate(arr=[5, 3, 1, 2, 4, 6, 8, 7, 9, 10], k=4), [10, 9, 1, 8])\n assert answers_match(candidate(arr=[-1, 1, -2, 2, -3, 3, -4, 4, -5, 5], k=6), [5, 4, 3, -5, 2, -4])\n assert answers_match(candidate(arr=[100000, -100000, 99999, -99999, 0, 1, -1], k=4), [100000, -100000, 99999, -99999])\n assert answers_match(candidate(arr=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=4), [1000, 900, 100, 800])\n assert answers_match(candidate(arr=[-29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1], k=5), [-1, -29, -3, -27, -5])\n assert answers_match(candidate(arr=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=10), [15, 1, 14, 2, 13, 3, 12, 4, 11, 5])\n assert answers_match(candidate(arr=[-100, 0, 50, 100, 200], k=3), [200, -100, 100])\n assert answers_match(candidate(arr=[-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10], k=10), [10, -10, 9, -9, 8, -8, 7, -7, 6, -6])\n assert answers_match(candidate(arr=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], k=7), [150, 10, 140, 20, 130, 30, 120])\n assert answers_match(candidate(arr=[-100000, 100000, 0, 50000, -50000], k=3), [100000, -100000, 50000])\n assert answers_match(candidate(arr=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], k=5), [0, 0, 0, 0, 0])\n assert answers_match(candidate(arr=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500], k=12), [1500, 100, 1400, 200, 1300, 300, 1200, 400, 1100, 500, 1000, 600])\n assert answers_match(candidate(arr=[-10, -20, -30, 0, 10, 20, 30, 40, 50, 60], k=4), [60, 50, -30, 40])\n assert answers_match(candidate(arr=[10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40], k=15), [40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 10, 10, 10, 10, 10])\n assert answers_match(candidate(arr=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], k=10), [29, 1, 27, 3, 25, 5, 23, 7, 21, 9])\n assert answers_match(candidate(arr=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], k=15), [39, 37, 1, 35, 3, 33, 5, 31, 7, 29, 9, 27, 11, 25, 13])\n assert answers_match(candidate(arr=[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], k=7), [9, 8, -10, 7, -9, 6, -8])\n", "comparison": "unordered"}, "public_tests": ["[1,2,3,4,5]\n2", "[1,1,3,5,5]\n2", "[6,7,11,7,6,8]\n5"], "hints": ["Calculate the centre of the array as defined in the statement.", "Use custom sort function to sort values (Strongest first), then slice the first k."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().getStrongest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:11+00:00", "tests_total": 91, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["array", "two-pointers", "sorting"]}, "language": "python", "interface": {"raw_signature": "def getStrongest(self, arr: list[int], k: int) -> list[int]:", "container": "Solution", "callable": "getStrongest", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1473, "task_id": "paint-house-iii", "difficulty": "Hard", "problem_description": "There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted again.\n\nA neighborhood is a maximal group of continuous houses that are painted with the same color.\n\n- For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].\n\nGiven an array houses, an m x n matrix cost and an integer target where:\n\n- houses[i]: is the color of the house i, and 0 if the house is not painted yet.\n- cost[i][j]: is the cost of paint the house i with the color j + 1.\n\nReturn the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods. If it is not possible, return -1.\n\nExample 1:\n\nInput: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3\nOutput: 9\nExplanation: Paint houses of this way [1,2,2,1,1]\nThis array contains target = 3 neighborhoods, [{1}, {2,2}, {1,1}].\nCost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.\n\nExample 2:\n\nInput: houses = [0,2,1,2,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3\nOutput: 11\nExplanation: Some houses are already painted, Paint the houses of this way [2,2,1,2,2]\nThis array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}].\nCost of paint the first and last house (10 + 1) = 11.\n\nExample 3:\n\nInput: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3\nOutput: -1\nExplanation: Houses are already painted with a total of 4 neighborhoods [{3},{1},{2},{3}] different of target = 3.\n\nConstraints:\n\n- m == houses.length == cost.length\n- n == cost[i].length\n- 1 <= m <= 100\n- 1 <= n <= 20\n- 1 <= target <= m\n- 0 <= houses[i] <= n\n- 1 <= cost[i][j] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [1, 0, 0, 0, 0],cost = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],m = 5,n = 2,target = 2) == 15\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70], [50, 60, 70, 80]],m = 5,n = 4,target = 3) == 160\n assert candidate(houses = [1, 2, 3, 4, 5],cost = [[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,n = 5,target = 5) == 0\n assert candidate(houses = [3, 1, 2, 3],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 4,n = 3,target = 3) == -1\n assert candidate(houses = [1, 0, 1, 0, 0],cost = [[1, 2], [3, 4], [1, 2], [3, 4], [1, 2]],m = 5,n = 2,target = 2) == 8\n assert candidate(houses = [0, 2, 1, 2, 0],cost = [[1, 10], [10, 1], [10, 1], [1, 10], [5, 1]],m = 5,n = 2,target = 3) == 11\n assert candidate(houses = [0, 1, 0, 0, 0],cost = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],m = 5,n = 2,target = 2) == 5\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],m = 5,n = 3,target = 2) == 36\n assert candidate(houses = [0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 6,n = 2,target = 1) == 6\n assert candidate(houses = [1, 0, 2, 0, 3],cost = [[5, 8, 6], [19, 14, 13], [7, 5, 5], [3, 6, 14], [2, 11, 1]],m = 5,n = 3,target = 3) == 20\n assert candidate(houses = [1, 0, 3, 0, 2],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 5,n = 3,target = 3) == 2\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 10], [10, 1], [10, 1], [1, 10], [5, 1]],m = 5,n = 2,target = 3) == 9\n assert candidate(houses = [0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],m = 3,n = 3,target = 2) == 13\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]],m = 5,n = 4,target = 2) == 16\n assert candidate(houses = [0, 2, 0, 0, 0, 1, 0, 0, 0, 0],cost = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]],m = 10,n = 3,target = 5) == 100\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],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]],m = 7,n = 5,target = 7) == 7\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 4, 7, 2, 8, 6], [5, 9, 1, 3, 4, 7], [9, 3, 5, 6, 2, 8], [8, 6, 9, 1, 7, 4], [7, 5, 8, 9, 3, 2], [6, 8, 4, 5, 9, 1], [3, 7, 9, 8, 6, 5], [2, 9, 6, 7, 4, 8], [8, 1, 4, 2, 9, 6], [6, 2, 8, 3, 1, 9]],m = 10,n = 6,target = 5) == 22\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6]],m = 8,n = 3,target = 4) == 31\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5]],m = 11,n = 3,target = 5) == 19\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 5, 5, 5, 5], [1, 1, 1, 1, 1], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2], [1, 1, 1, 1, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 6, 9, 12, 15], [15, 12, 9, 6, 3], [3, 2, 1, 4, 5], [5, 4, 3, 2, 1]],m = 15,n = 5,target = 7) == 53\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 4, 3], [3, 2, 1], [2, 1, 4], [1, 3, 2], [4, 3, 1], [2, 1, 3], [3, 2, 4]],m = 7,n = 3,target = 4) == 10\n assert candidate(houses = [1, 0, 0, 2, 0, 0, 0, 0, 0, 3],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]],m = 10,n = 3,target = 6) == 9\n assert candidate(houses = [0, 3, 0, 1, 0, 2, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]],m = 8,n = 4,target = 5) == 6\n assert candidate(houses = [0, 0, 1, 0, 0, 0, 0, 0],cost = [[1, 9, 3, 5], [3, 4, 1, 10], [7, 8, 4, 5], [3, 2, 8, 5], [2, 6, 3, 7], [7, 1, 8, 3], [4, 2, 1, 4], [1, 4, 3, 9]],m = 8,n = 4,target = 5) == 11\n assert candidate(houses = [0, 2, 0, 2, 0, 2],cost = [[10, 20, 30, 40], [20, 30, 10, 40], [30, 10, 20, 40], [10, 40, 20, 30], [20, 30, 40, 10], [30, 40, 10, 20]],m = 6,n = 4,target = 3) == 40\n assert candidate(houses = [1, 0, 0, 0, 0, 0, 0, 0, 0, 2],cost = [[10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4]],m = 10,n = 4,target = 4) == 45\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[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], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]],m = 10,n = 10,target = 5) == 57\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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]],m = 11,n = 11,target = 3) == 11\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[5, 3, 2, 1, 4], [3, 2, 1, 4, 5], [2, 1, 4, 5, 3], [1, 4, 5, 3, 2], [4, 5, 3, 2, 1], [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]],m = 10,n = 5,target = 4) == 16\n assert candidate(houses = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2],cost = [[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, 10, 11], [9, 10, 11, 12], [10, 11, 12, 13]],m = 10,n = 4,target = 5) == 28\n assert candidate(houses = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[10, 10, 10], [1, 2, 3], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],m = 10,n = 3,target = 3) == 90\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[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]],m = 15,n = 2,target = 7) == 19\n assert candidate(houses = [0, 0, 0, 2, 0, 0, 0, 0],cost = [[4, 3, 1, 2], [9, 1, 4, 8], [5, 7, 9, 6], [1, 1, 5, 2], [8, 5, 3, 3], [4, 6, 1, 9], [2, 3, 7, 7], [7, 4, 8, 5]],m = 8,n = 4,target = 4) == 20\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0],cost = [[2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1]],m = 7,n = 3,target = 4) == 8\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[10, 15], [15, 10], [20, 25], [25, 20], [30, 35], [35, 30], [40, 45], [45, 40]],m = 8,n = 2,target = 6) == 205\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[4, 8, 2], [1, 10, 9], [6, 4, 8], [10, 2, 9], [3, 7, 5], [8, 3, 2], [1, 6, 5], [2, 4, 3]],m = 8,n = 3,target = 3) == 24\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[7, 5, 9], [9, 7, 5], [5, 9, 7], [7, 5, 9], [9, 7, 5], [5, 9, 7], [7, 5, 9], [9, 7, 5]],m = 8,n = 3,target = 5) == 46\n assert candidate(houses = [0, 3, 0, 2, 0, 1, 0, 0],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]],m = 8,n = 4,target = 4) == 5\n assert candidate(houses = [2, 0, 2, 0, 2, 0, 2, 0],cost = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 2, 1]],m = 8,n = 3,target = 3) == 6\n assert candidate(houses = [0, 0, 2, 1, 0, 0, 3],cost = [[10, 8, 6, 4, 2], [9, 7, 5, 3, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [5, 10, 15, 20, 25], [100, 90, 80, 70, 60], [30, 25, 20, 15, 10]],m = 7,n = 5,target = 4) == 80\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]],m = 7,n = 3,target = 4) == 30\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[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]],m = 7,n = 4,target = 4) == 30\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[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, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 20,n = 2,target = 10) == 25\n assert candidate(houses = [0, 0, 1, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2]],m = 6,n = 3,target = 4) == 6\n assert candidate(houses = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2],cost = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],m = 10,n = 2,target = 5) == 28\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 10,n = 2,target = 5) == 13\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1], [1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1]],m = 8,n = 4,target = 5) == 9\n assert candidate(houses = [0, 0, 3, 0, 0, 0, 0],cost = [[1, 3, 2], [3, 1, 4], [1, 2, 3], [3, 2, 1], [1, 3, 2], [3, 2, 1], [1, 2, 3]],m = 7,n = 3,target = 3) == 9\n assert candidate(houses = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0],cost = [[100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50]],m = 10,n = 3,target = 5) == 250\n assert candidate(houses = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[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], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],m = 11,n = 10,target = 6) == 66\n assert candidate(houses = [1, 0, 2, 0, 3, 0, 4, 0],cost = [[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]],m = 8,n = 5,target = 4) == 10\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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]],m = 20,n = 2,target = 10) == 20\n assert candidate(houses = [0, 1, 2, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [4, 5, 6], [5, 6, 4], [6, 4, 5], [7, 8, 9]],m = 7,n = 3,target = 5) == 21\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[3, 2, 1, 8, 9], [7, 8, 6, 4, 5], [2, 4, 3, 1, 8], [9, 1, 5, 7, 3], [4, 9, 2, 3, 7], [5, 3, 8, 1, 4], [1, 7, 2, 8, 6], [8, 6, 4, 9, 2], [3, 1, 7, 2, 5]],m = 9,n = 5,target = 4) == 24\n assert candidate(houses = [1, 0, 2, 0, 3, 0, 1, 0, 2],cost = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],m = 9,n = 3,target = 6) == 40\n assert candidate(houses = [0, 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]],m = 20,n = 4,target = 12) == 23\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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]],m = 10,n = 3,target = 10) == 10\n assert candidate(houses = [0, 2, 0, 0, 0, 2, 0],cost = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]],m = 7,n = 3,target = 3) == 25\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9, 9, 9, 9]],m = 9,n = 9,target = 6) == 41\n assert candidate(houses = [1, 0, 1, 0, 1, 0, 1],cost = [[10, 20, 30], [30, 10, 20], [20, 30, 10], [10, 20, 30], [30, 10, 20], [20, 30, 10], [10, 20, 30]],m = 7,n = 3,target = 3) == 40\n assert candidate(houses = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],cost = [[1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1]],m = 10,n = 2,target = 5) == 32\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[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]],m = 10,n = 3,target = 5) == 57\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 10,n = 2,target = 5) == 13\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],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]],m = 15,n = 2,target = 8) == 15\n assert candidate(houses = [0, 2, 0, 1, 0, 3, 0],cost = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, 2], [1, 4, 3, 2], [2, 3, 4, 1], [4, 1, 2, 3]],m = 7,n = 4,target = 5) == 4\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[7, 2, 1, 9, 5, 6, 3, 8], [8, 7, 6, 3, 9, 1, 5, 4], [2, 1, 8, 7, 6, 9, 4, 3], [5, 6, 7, 8, 2, 1, 9, 4], [9, 4, 5, 6, 7, 8, 2, 1], [3, 9, 4, 5, 6, 7, 8, 2], [1, 3, 9, 4, 5, 6, 7, 8], [6, 1, 3, 9, 4, 5, 6, 7], [7, 6, 1, 3, 9, 4, 5, 6], [8, 7, 6, 1, 3, 9, 4, 5], [5, 8, 7, 6, 1, 3, 9, 4]],m = 11,n = 8,target = 6) == 21\n", "comparison": "exact"}, "public_tests": ["[0,0,0,0,0]\n[[1,10],[10,1],[10,1],[1,10],[5,1]]\n5\n2\n3", "[0,2,1,2,0]\n[[1,10],[10,1],[10,1],[1,10],[5,1]]\n5\n2\n3", "[3,1,2,3]\n[[1,1,1],[1,1,1],[1,1,1],[1,1,1]]\n4\n3\n3"], "hints": ["Use Dynamic programming.", "Define dp[i][j][k] as the minimum cost where we have k neighborhoods in the first i houses and the i-th house is painted with the color j."], "metadata": {"canonical_parameter_names": ["houses", "cost", "m", "n", "target"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:13+00:00", "tests_total": 67, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, houses: list[int], cost: list[list[int]], m: int, n: int, target: int) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "houses", "type": "list[int]"}, {"name": "cost", "type": "list[list[int]]"}, {"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1475, "task_id": "final-prices-with-a-special-discount-in-a-shop", "difficulty": "Easy", "problem_description": "You are given an integer array prices where prices[i] is the price of the i^th item in a shop.\n\nThere is a special discount for items in the shop. If you buy the i^th item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all.\n\nReturn an integer array answer where answer[i] is the final price you will pay for the i^th item of the shop, considering the special discount.\n\nExample 1:\n\nInput: prices = [8,4,6,2,3]\nOutput: [4,2,4,2,3]\nExplanation:\nFor item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.\nFor item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2.\nFor item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4.\nFor items 3 and 4 you will not receive any discount at all.\n\nExample 2:\n\nInput: prices = [1,2,3,4,5]\nOutput: [1,2,3,4,5]\nExplanation: In this case, for all items, you will not receive any discount at all.\n\nExample 3:\n\nInput: prices = [10,1,1,6]\nOutput: [9,0,1,6]\n\nConstraints:\n\n- 1 <= prices.length <= 500\n- 1 <= prices[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [5, 5, 5, 5, 5]) == [0, 0, 0, 0, 5]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [8, 4, 6, 2, 3]) == [4, 2, 4, 2, 3]\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(prices = [9, 8, 7, 6, 5]) == [1, 1, 1, 1, 5]\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(prices = [60, 70, 80, 90, 100]) == [60, 70, 80, 90, 100]\n assert candidate(prices = [10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 10]\n assert candidate(prices = [5, 1, 4, 2, 3]) == [4, 1, 2, 2, 3]\n assert candidate(prices = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1]) == [50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [10, 1, 1, 6]) == [9, 0, 1, 6]\n assert candidate(prices = [1, 2, 3, 2, 1]) == [0, 0, 1, 1, 1]\n assert candidate(prices = [5, 1, 3, 4, 6, 2]) == [4, 1, 1, 2, 4, 2]\n assert candidate(prices = [3, 3, 3, 2, 2, 1]) == [0, 0, 1, 0, 1, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [100, 90, 80, 70, 60]) == [10, 10, 10, 10, 60]\n assert candidate(prices = [100, 200, 300, 200, 100]) == [0, 0, 100, 100, 100]\n assert candidate(prices = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1]\n assert candidate(prices = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(prices = [2, 3, 1]) == [1, 2, 1]\n assert candidate(prices = [100, 50, 50, 100, 50, 25, 25, 100]) == [50, 0, 0, 50, 25, 0, 25, 100]\n assert candidate(prices = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]\n assert candidate(prices = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6]) == [1, 0, 1, 2, 3, 0, 1, 4, 5, 6]\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2]\n assert candidate(prices = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 98, 2, 96, 3, 94, 4, 92, 5, 96]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [10, 5, 15, 5, 20, 10, 25, 15, 30, 20]) == [5, 0, 10, 5, 10, 10, 10, 15, 10, 20]\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == [1, 1, 1, 1, 1, 1, 1, 2, 3, 4]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [7, 5, 6, 4, 3, 2, 1, 8, 9, 10]) == [2, 1, 2, 1, 1, 1, 1, 8, 9, 10]\n assert candidate(prices = [2, 3, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(prices = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [0, 8, 1, 6, 2, 4, 3, 2, 4, 5, 1, 8, 2, 6, 3, 4, 4, 2, 5, 6]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000]\n assert candidate(prices = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5]\n assert candidate(prices = [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]) == [0, 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]\n assert candidate(prices = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 63, 31, 16, 8, 4, 2, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == [0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [0, 10, 0, 10, 0, 10, 0, 10, 10, 20]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 1, 1, 1]\n assert candidate(prices = [30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == [10, 10, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 1, 2, 3, 4, 5]\n assert candidate(prices = [8, 6, 7, 6, 5, 4, 3, 2, 1]) == [2, 0, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100, 50, 25, 13, 6, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 4, 6, 2, 3, 8, 4, 6, 2, 3]) == [4, 2, 4, 0, 1, 4, 2, 4, 2, 3]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 7]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(prices = [15, 10, 5, 10, 15, 5, 10, 15, 20, 10]) == [5, 5, 0, 5, 10, 5, 0, 5, 10, 10]\n assert candidate(prices = [10, 20, 30, 10, 20, 30, 10, 20, 30]) == [0, 10, 20, 0, 10, 20, 10, 20, 30]\n assert candidate(prices = [3, 6, 5, 1, 8, 7, 9, 2, 4, 10]) == [2, 1, 4, 1, 1, 5, 7, 2, 4, 10]\n assert candidate(prices = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [0, 1, 0, 1, 0, 1, 0, 1, 2, 3]\n assert candidate(prices = [8, 5, 7, 6, 4, 5, 3, 2, 1]) == [3, 1, 1, 2, 1, 2, 1, 1, 1]\n assert candidate(prices = [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, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 20, 30, 10, 20, 30, 40, 50, 60, 70]) == [30, 10, 20, 10, 20, 30, 40, 50, 60, 70]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [500, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == [400, 100, 200, 300, 400, 500, 600, 700, 800, 900]\n assert candidate(prices = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [99, 1, 198, 2, 297, 3, 396, 4, 495, 5]\n assert candidate(prices = [999, 1000, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 980]\n assert candidate(prices = [100, 200, 150, 250, 300, 220, 180, 160, 170]) == [100, 50, 150, 30, 80, 40, 20, 160, 170]\n assert candidate(prices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(prices = [5, 10, 15, 20, 15, 10, 5, 10, 15, 20, 15, 10, 5]) == [0, 0, 0, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5]\n assert candidate(prices = [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5]) == [0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 5]\n assert candidate(prices = [5, 15, 25, 10, 20, 5, 30, 25, 40, 10]) == [0, 5, 15, 5, 15, 5, 5, 15, 30, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 1000]\n assert candidate(prices = [5, 1, 4, 3, 2, 6, 7, 8, 10, 9]) == [4, 1, 1, 1, 2, 6, 7, 8, 1, 9]\n assert candidate(prices = [8, 4, 6, 2, 3, 5, 7, 1, 9, 10]) == [4, 2, 4, 1, 2, 4, 6, 1, 9, 10]\n assert candidate(prices = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [100, 100, 100, 100, 50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [250, 200, 150, 100, 50, 100, 150, 200, 250, 300]) == [50, 50, 50, 50, 50, 100, 150, 200, 250, 300]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [30, 25, 20, 15, 10, 5, 10, 15, 20, 25]) == [5, 5, 5, 5, 5, 5, 10, 15, 20, 25]\n assert candidate(prices = [4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == [1, 1, 1, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(prices = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0, 1, 2, 3, 4, 5]\n assert candidate(prices = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 50]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [1, 2, 2, 1, 1, 2, 2, 1, 1]) == [0, 0, 1, 0, 0, 0, 1, 0, 1]\n assert candidate(prices = [100, 50, 25, 200, 100, 50, 25, 200]) == [50, 25, 0, 100, 50, 25, 25, 200]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 3]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 2]\n assert candidate(prices = [1, 3, 2, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == [0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5]) == [0, 0, 0, 0, 10, 10, 10, 10, 5, 5]\n assert candidate(prices = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]\n assert candidate(prices = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [10, 10, 10, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]\n assert candidate(prices = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 25, 75, 100, 50, 75, 100, 125]) == [25, 25, 25, 50, 50, 75, 100, 125]\n assert candidate(prices = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == [0, 0, 0, 0, 100, 100, 100, 100, 100]\n", "comparison": "exact"}, "public_tests": ["[8,4,6,2,3]", "[1,2,3,4,5]", "[10,1,1,6]"], "hints": ["Use brute force: For the ith item in the shop with a loop find the first position j satisfying the conditions and apply the discount, otherwise, the discount is 0."], "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().finalPrices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:18+00:00", "tests_total": 117, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "stack", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def finalPrices(self, prices: list[int]) -> list[int]:", "container": "Solution", "callable": "finalPrices", "parameters": [{"name": "prices", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1477, "task_id": "find-two-non-overlapping-sub-arrays-each-with-target-sum", "difficulty": "Medium", "problem_description": "You are given an array of integers arr and an integer target.\n\nYou have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.\n\nReturn the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.\n\nExample 1:\n\nInput: arr = [3,2,2,4,3], target = 3\nOutput: 2\nExplanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.\n\nExample 2:\n\nInput: arr = [7,3,4,7], target = 7\nOutput: 2\nExplanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.\n\nExample 3:\n\nInput: arr = [4,3,2,6,2,3,4], target = 6\nOutput: -1\nExplanation: We have only one sub-array of sum = 6.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 1000\n- 1 <= target <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 6\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 6) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],target = 9) == -1\n assert candidate(arr = [3, 2, 2, 4, 3],target = 3) == 2\n assert candidate(arr = [5, 5, 4, 4, 5],target = 9) == 4\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 4) == 4\n assert candidate(arr = [1000, 1000, 1000],target = 2000) == -1\n assert candidate(arr = [7, 3, 4, 7],target = 7) == 2\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 2000) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 3) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 4\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 5000) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5],target = 10) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 60) == -1\n assert candidate(arr = [1, 4, 4, 4, 4, 4, 4, 4, 4, 1],target = 8) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [4, 3, 2, 6, 2, 3, 4],target = 6) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 90) == -1\n assert candidate(arr = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1],target = 1000) == 4\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],target = 50) == 4\n assert candidate(arr = [3, 1, 2, 4, 3, 2, 1, 3, 4, 2, 1, 3, 5, 2, 1, 3, 4, 2, 1, 3],target = 6) == 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, 26, 27, 28, 29, 30],target = 30) == 4\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 500) == -1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 300) == 8\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],target = 100) == 13\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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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 = 20) == 8\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],target = 20) == -1\n assert candidate(arr = [1, 3, 2, 1, 5, 2, 3, 1, 4, 2, 3, 1, 5, 2, 3, 1, 4, 2, 3, 1],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(arr = [1, 4, 2, 3, 5, 7, 9, 11, 13, 15],target = 15) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8, 6],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [1, 4, 4, 1, 1, 2, 3, 5, 3, 2, 3, 4, 1],target = 8) == 4\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],target = 5) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 30) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],target = 60) == 4\n assert candidate(arr = [9, 1, 2, 3, 9, 4, 5, 9, 6, 7, 8, 9],target = 9) == 2\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 6) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1],target = 10) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3],target = 9) == -1\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [7, 8, 3, 4, 7, 6, 5, 4, 3, 2, 1],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == -1\n assert candidate(arr = [7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1],target = 10) == 10\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 21) == 5\n assert candidate(arr = [1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3],target = 8) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 600) == 5\n assert candidate(arr = [2, 3, 2, 2, 3, 3, 2, 2, 2, 3],target = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300],target = 600) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 4, 8, 6, 3, 7],target = 10) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\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],target = 10) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 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],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3],target = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 2) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 400) == -1\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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 40\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 100) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 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],target = 20) == 6\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, 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 = 2) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8],target = 15) == 5\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],target = 3) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 4) == 6\n assert candidate(arr = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600],target = 300) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 1000) == 8\n", "comparison": "exact"}, "public_tests": ["[3,2,2,4,3]\n3", "[7,3,4,7]\n7", "[4,3,2,6,2,3,4]\n6"], "hints": ["Let's create two arrays prefix and suffix where prefix[i] is the minimum length of sub-array ends before i and has sum = k, suffix[i] is the minimum length of sub-array starting at or after i and has sum = k.", "The answer we are searching for is min(prefix[i] + suffix[i]) for all values of i from 0 to n-1 where n == arr.length.", "If you are still stuck with how to build prefix and suffix, you can store for each index i the length of the sub-array starts at i and has sum = k or infinity otherwise, and you can use it to build both prefix and suffix."], "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().minSumOfLengths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:20+00:00", "tests_total": 85, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "dynamic-programming", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def minSumOfLengths(self, arr: list[int], target: int) -> int:", "container": "Solution", "callable": "minSumOfLengths", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1478, "task_id": "allocate-mailboxes", "difficulty": "Hard", "problem_description": "Given the array houses where houses[i] is the location of the i^th house along a street and an integer k, allocate k mailboxes in the street.\n\nReturn the minimum total distance between each house and its nearest mailbox.\n\nThe test cases are generated so that the answer fits in a 32-bit integer.\n\nExample 1:\n\nInput: houses = [1,4,8,10,20], k = 3\nOutput: 5\nExplanation: Allocate mailboxes in position 3, 9 and 20.\nMinimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5\n\nExample 2:\n\nInput: houses = [2,3,5,12,18], k = 2\nOutput: 9\nExplanation: Allocate mailboxes in position 3 and 14.\nMinimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.\n\nConstraints:\n\n- 1 <= k <= houses.length <= 100\n- 1 <= houses[i] <= 10^4\n- All the integers of houses are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [10, 5, 17, 1, 18, 2, 12, 9],k = 3) == 8\n assert candidate(houses = [5, 10, 15, 20, 25],k = 2) == 15\n assert candidate(houses = [3, 6, 14, 10],k = 4) == 0\n assert candidate(houses = [3, 6, 14, 16, 25, 28, 30],k = 2) == 26\n assert candidate(houses = [1, 4, 8, 10, 20],k = 3) == 5\n assert candidate(houses = [1, 10000],k = 1) == 9999\n assert candidate(houses = [1, 2, 3, 4, 5],k = 1) == 6\n assert candidate(houses = [2, 3, 5, 12, 18],k = 2) == 9\n assert candidate(houses = [7, 4, 6, 1],k = 1) == 8\n assert candidate(houses = [5, 7, 10, 11, 12, 16],k = 3) == 4\n assert candidate(houses = [5, 10, 15, 20, 25, 30],k = 2) == 20\n assert candidate(houses = [8, 5, 2, 9, 6],k = 2) == 5\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 5) == 200\n assert candidate(houses = [1, 6, 9, 12, 17, 23, 30],k = 4) == 12\n assert candidate(houses = [2, 5, 7, 12, 16, 22, 26, 30, 35],k = 3) == 24\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22],k = 4) == 10\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],k = 6) == 70\n assert candidate(houses = [2, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 28\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],k = 4) == 18\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 5) == 42\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22, 25, 28, 30, 33, 36, 39, 42, 45, 48],k = 6) == 32\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [1, 5, 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 = 15) == 159\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990],k = 15) == 633\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 20) == 0\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 599\n assert candidate(houses = [1, 10, 100, 1000, 10000],k = 2) == 1089\n assert candidate(houses = [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(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(houses = [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(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 3) == 225\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 999\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 100\n assert candidate(houses = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157, 163, 169, 175],k = 15) == 90\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 89\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 60\n assert candidate(houses = [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],k = 15) == 45\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [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],k = 10) == 60\n assert candidate(houses = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 200],k = 8) == 85\n assert candidate(houses = [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 = 16) == 40\n assert candidate(houses = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27],k = 3) == 23\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56],k = 5) == 30\n assert candidate(houses = [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],k = 12) == 539\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 5) == 220\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 109\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 10\n assert candidate(houses = [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) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 5) == 16\n assert candidate(houses = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 11) == 48\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 8) == 40\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == 36\n assert candidate(houses = [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 = 10) == 30\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225],k = 13) == 100\n assert candidate(houses = [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 = 8) == 80\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 5) == 199\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 5) == 35\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 6) == 90\n assert candidate(houses = [1, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],k = 3) == 189\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 7) == 139\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 34\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [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 = 15) == 20\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 100\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 2) == 131\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],k = 6) == 44\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 24\n assert candidate(houses = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 6) == 154\n assert candidate(houses = [1, 3, 6, 8, 14, 15, 20, 25],k = 4) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == 60\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 24\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45],k = 4) == 24\n assert candidate(houses = [2, 8, 15, 20, 26, 32, 40, 45, 50],k = 4) == 27\n assert candidate(houses = [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77],k = 3) == 90\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(houses = [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],k = 20) == 300\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 8) == 120\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 7) == 130\n assert candidate(houses = [1, 2, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 4) == 1697\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 4) == 33\n assert candidate(houses = [3, 7, 11, 15, 19, 23, 27, 31],k = 3) == 20\n assert candidate(houses = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90],k = 6) == 39\n assert candidate(houses = [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],k = 25) == 50\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6) == 9\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 20\n assert candidate(houses = [1, 5, 9, 14, 20, 25, 30, 35, 40],k = 4) == 23\n", "comparison": "exact"}, "public_tests": ["[1,4,8,10,20]\n3", "[2,3,5,12,18]\n2"], "hints": ["If k =1, the minimum distance is obtained allocating the mailbox in the median of the array houses.", "Generalize this idea, using dynamic programming allocating k mailboxes."], "metadata": {"canonical_parameter_names": ["houses", "k"], "leetcode_dataset_entry_point": "Solution().minDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:22+00:00", "tests_total": 108, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "math", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minDistance(self, houses: list[int], k: int) -> int:", "container": "Solution", "callable": "minDistance", "parameters": [{"name": "houses", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1480, "task_id": "running-sum-of-1d-array", "difficulty": "Easy", "problem_description": "Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).\n\nReturn the running sum of nums.\n\nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [1,3,6,10]\nExplanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: [1,2,3,4,5]\nExplanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].\n\nExample 3:\n\nInput: nums = [3,1,2,10,1]\nOutput: [3,4,6,16,17]\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^6 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == [-1, 1, -2, 2, -3]\n assert candidate(nums = [-5]) == [-5]\n assert candidate(nums = [0, -1, 2, -3, 4]) == [0, -1, 1, -2, 2]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [1, 2, 3, 4]) == [1, 3, 6, 10]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4]) == [-1, -3, -6, -10]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [-1000000]) == [-1000000]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [5]) == [5]\n assert candidate(nums = [1000000]) == [1000000]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [3, 1, 2, 10, 1]) == [3, 4, 6, 16, 17]\n assert candidate(nums = [1000, -500, 250, -125, 62.5, -31.25, 15.625, -7.8125, 3.90625, -1.953125, 0.9765625, -0.48828125, 0.244140625, -0.1220703125, 0.06103515625]) == [1000, 500, 750, 625, 687.5, 656.25, 671.875, 664.0625, 667.96875, 666.015625, 666.9921875, 666.50390625, 666.748046875, 666.6259765625, 666.68701171875]\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, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525, 600, 680, 765, 855, 950, 1050]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 11, 111, 1111, 11111, 111111, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120, -136, -153, -171, -190, -210]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 20, 45, 80, 125, 180, 245, 320, 405, 500, 605]\n assert candidate(nums = [100, 50, -50, -100, 150, 200, -250, 300, -350, 400]) == [100, 150, 100, 0, 150, 350, 100, 400, 50, 450]\n assert candidate(nums = [-1000000, 500000, -250000, 125000, -62500]) == [-1000000, -500000, -750000, -625000, -687500]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120]\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, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000]) == [1000, 0, 2000, 0, 3000, 0, 4000, 0, 5000, 0]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\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, 2, 3, 4, 5, 6, 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, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == [10, 0, 20, 0, 30, 0, 40, 0, 50, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [999999, 1888887, 2666664, 3333330, 3888885, 4333329, 4666662, 4888884, 4999995]\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, 39, 57, 74, 90, 105, 119, 132, 144, 155, 165, 174, 182, 189, 195, 200, 204, 207, 209, 210]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, 0, 20, 0, 30, 0]\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000]) == [-1000, -3000, -6000, -10000, -15000, -21000, -28000, -36000, -45000, -55000]\n assert candidate(nums = [500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000]) == [500000, 0, 500000, 0, 500000, 0, 500000, 0, 500000, 0]\n assert candidate(nums = [5, -5, 15, -15, 25, -25]) == [5, 0, 15, 0, 25, 0]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000]) == [1000000, 500000, 1000000, 750000, 1000000]\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [10000, 30000, 60000, 100000, 150000, 210000, 280000, 360000, 450000, 550000]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 29, 42, 54, 65, 75, 84, 92, 99, 105, 110, 114, 117, 119, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n assert candidate(nums = [-1000000, -999999, -999998, -999997, -999996, -999995]) == [-1000000, -1999999, -2999997, -3999994, -4999990, -5999985]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000]) == [1000000, 0, 500000, 0, 250000, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == [10, -10, 20, -20, 30, -30, 40]\n assert candidate(nums = [1000000, -500000, 250000, -125000, 62500]) == [1000000, 500000, 750000, 625000, 687500]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [999999, 1, -999998, 2, -999997, 3]) == [999999, 1000000, 2, 4, -999993, -999990]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000, -9000, 10000]) == [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000]\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890, -678901, 789012, -890123, 901234]) == [123456, -111111, 234567, -222222, 345668, -333233, 455779, -434344, 466890]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == [999999, 1999997, 2999994, 3999990, 4999985, 5999979, 6999972, 7999964, 8999955, 9999945]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == [100, 199, 297, 394, 490, 585, 679, 772, 864, 955, 1045, 1134, 1222, 1309, 1395, 1480, 1564, 1647, 1729, 1810]\n assert candidate(nums = [1, 0, -1, 0, 1, 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]\n assert candidate(nums = [-999999, -888888, -777777, -666666, -555555, -444444, -333333, -222222, -111111]) == [-999999, -1888887, -2666664, -3333330, -3888885, -4333329, -4666662, -4888884, -4999995]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953]) == [500000, 750000, 625000, 687500, 656250, 671875, 664063, 667969, 666016]\n assert candidate(nums = [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]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000]) == [-1000000, -2000000, -3000000, -4000000]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, 0, 2, 0, 3, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900]) == [100, 300, 600, 1000, 1500, 0, 600, 1300, 2100, 3000]\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 2, 4, 7, 12, 20, 33, 54, 88, 143, 232, 376, 609, 986, 1596, 2583, 4180, 6764, 10945, 17710]\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999]) == [999999, 0, 999999, 0, 999999, 0, 999999, 0, 999999, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == [-10, -30, -60, -100, -150, -210, -280, -360, -450, -550, -660, -780, -910, -1050, -1200]\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500]) == [500, 900, 1200, 1400, 1500, 1500, 1400, 1200, 900, 500, 0]\n assert candidate(nums = [100, -50, 25, -12, 6, -3, 1, 0, -1, 3, -6, 12, -24, 48, -96, 192, -384, 768, -1536, 3072]) == [100, 50, 75, 63, 69, 66, 67, 67, 66, 69, 63, 75, 51, 99, 3, 195, -189, 579, -957, 2115]\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3]) == [1, 1, 0, 2, 2, 0, 3, 3, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991, -999990]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [-10, -19, -27, -34, -40, -45, -49, -52, -54, -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]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[1,1,1,1,1]", "[3,1,2,10,1]"], "hints": ["Think about how we can calculate the i-th number in the running sum from the (i-1)-th number."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().runningSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:24+00:00", "tests_total": 95, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def runningSum(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "runningSum", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1481, "task_id": "least-number-of-unique-integers-after-k-removals", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.\n\nExample 1:\n\nInput: arr = [5,5,4], k = 1\nOutput: 1\nExplanation: Remove the single 4, only 5 is left.\n\nExample 2:\n\nInput: arr = [4,3,1,1,3,3,2], k = 3\nOutput: 2\nExplanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^9\n- 0 <= k <= arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1, 1, 1, 1],k = 3) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 4) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60],k = 0) == 6\n assert candidate(arr = [4, 3, 1, 1, 3, 3, 2],k = 3) == 2\n assert candidate(arr = [1, 2, 3, 4, 5],k = 0) == 5\n assert candidate(arr = [10, 10, 10, 20, 20, 30],k = 3) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 4) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(arr = [5, 5, 4],k = 1) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 2) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3],k = 2) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 5) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],k = 10) == 1\n assert candidate(arr = [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, 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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 2\n assert candidate(arr = [100, 100, 200, 200, 200, 300, 300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 15) == 1\n assert candidate(arr = [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],k = 15) == 2\n assert candidate(arr = [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, 6, 6],k = 20) == 2\n assert candidate(arr = [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, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 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, 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 = 50) == 8\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 = 15) == 5\n assert candidate(arr = [29, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35],k = 25) == 1\n assert candidate(arr = [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, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9],k = 20) == 3\n assert candidate(arr = [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, 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, 10, 10, 10, 10, 10, 10, 10],k = 30) == 4\n assert candidate(arr = [6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10],k = 8) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 80, 80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 100],k = 25) == 3\n assert candidate(arr = [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, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 25) == 5\n assert candidate(arr = [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 = 18) == 2\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, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [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],k = 20) == 2\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, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 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, 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 = 25) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 7) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 1\n assert candidate(arr = [7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13],k = 10) == 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],k = 20) == 20\n assert candidate(arr = [11, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16],k = 8) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14],k = 15) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 5) == 3\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],k = 10) == 1\n assert candidate(arr = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 10) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [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, 6, 6, 6, 6, 6, 6],k = 40) == 1\n assert candidate(arr = [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, 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 = 30) == 1\n assert candidate(arr = [6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 10) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 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, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20) == 4\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, 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],k = 30) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 10) == 3\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 12) == 2\n assert candidate(arr = [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, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 25) == 2\n assert candidate(arr = [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 = 15) == 2\n assert candidate(arr = [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, 6, 6],k = 15) == 2\n assert candidate(arr = [22, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28],k = 20) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 15) == 4\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],k = 10) == 1\n assert candidate(arr = [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],k = 20) == 1\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) == 10\n assert candidate(arr = [1, 1, 1, 1, 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, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 2\n assert candidate(arr = [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],k = 25) == 1\n assert candidate(arr = [36, 37, 37, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 30) == 1\n assert candidate(arr = [17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 15) == 1\n", "comparison": "exact"}, "public_tests": ["[5,5,4]\n1", "[4,3,1,1,3,3,2]\n3"], "hints": ["Use a map to count the frequencies of the numbers in the array.", "An optimal strategy is to remove the numbers with the smallest count first."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findLeastNumOfUniqueInts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:27+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "counting"]}, "language": "python", "interface": {"raw_signature": "def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:", "container": "Solution", "callable": "findLeastNumOfUniqueInts", "parameters": [{"name": "arr", "type": "List[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1482, "task_id": "minimum-number-of-days-to-make-m-bouquets", "difficulty": "Medium", "problem_description": "You are given an integer array bloomDay, an integer m and an integer k.\n\nYou want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.\n\nThe garden consists of n flowers, the i^th flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.\n\nReturn the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.\n\nExample 1:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 1\nOutput: 3\nExplanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.\nWe need 3 bouquets each should contain 1 flower.\nAfter day 1: [x, _, _, _, _] // we can only make one bouquet.\nAfter day 2: [x, _, _, _, x] // we can only make two bouquets.\nAfter day 3: [x, _, x, _, x] // we can make 3 bouquets. The answer is 3.\n\nExample 2:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 2\nOutput: -1\nExplanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.\n\nExample 3:\n\nInput: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3\nOutput: 12\nExplanation: We need 2 bouquets each should have 3 flowers.\nHere is the garden after the 7 and 12 days:\nAfter day 7: [x, x, x, x, _, x, x]\nWe can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.\nAfter day 12: [x, x, x, x, x, x, x]\nIt is obvious that we can make two bouquets in different ways.\n\nConstraints:\n\n- bloomDay.length == n\n- 1 <= n <= 10^5\n- 1 <= bloomDay[i] <= 10^9\n- 1 <= m <= 10^6\n- 1 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 1) == 3\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 2) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 1) == 5\n assert candidate(bloomDay = [1],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 3) == 1000000000\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 2) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 2) == 10\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 2) == 1000000000\n assert candidate(bloomDay = [7, 7, 7, 7, 12, 7, 7],m = 2,k = 3) == 12\n assert candidate(bloomDay = [1, 3, 2],m = 1,k = 2) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [1, 2, 4, 9, 3, 4, 1],m = 2,k = 2) == 4\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 5) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 3, 2, 7, 4],m = 3,k = 2) == 8\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5],m = 2,k = 3) == 5\n assert candidate(bloomDay = [5, 8, 6, 9, 7],m = 2,k = 2) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 2) == 10\n assert candidate(bloomDay = [2, 1, 3, 1, 2],m = 3,k = 1) == 2\n assert candidate(bloomDay = [100, 100, 100, 100],m = 1,k = 4) == 100\n assert candidate(bloomDay = [1, 2, 3, 4, 5],m = 1,k = 5) == 5\n assert candidate(bloomDay = [1000000000],m = 1,k = 1) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 5, 9, 1, 1, 5, 1, 8, 9, 1, 8],m = 3,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 4, 7, 1, 3, 10],m = 4,k = 2) == 9\n assert candidate(bloomDay = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 10,k = 2) == 20\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 7) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [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 = 5,k = 3) == 6\n assert candidate(bloomDay = [30, 10, 20, 30, 20, 10, 30, 20, 10, 30],m = 3,k = 3) == 30\n assert candidate(bloomDay = [9, 1, 2, 3, 4, 5, 6, 7, 8, 1000000000],m = 1,k = 1) == 1\n assert candidate(bloomDay = [3, 5, 1, 5, 9, 6, 2, 10, 8, 7],m = 3,k = 3) == 10\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 1, 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 = 5,k = 5) == 1\n assert candidate(bloomDay = [2, 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],m = 8,k = 2) == 10\n assert candidate(bloomDay = [5, 3, 8, 1, 9, 2, 4, 6, 7],m = 3,k = 2) == 7\n assert candidate(bloomDay = [5, 1, 10, 2, 8, 3, 5, 10],m = 2,k = 2) == 5\n assert candidate(bloomDay = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],m = 4,k = 2) == 1000000000\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2,k = 5) == 10\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1,k = 10) == 1\n assert candidate(bloomDay = [5, 8, 4, 3, 7, 1, 9],m = 3,k = 2) == 8\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 1) == 1\n assert candidate(bloomDay = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 4,k = 3) == 3\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 2) == 6\n assert candidate(bloomDay = [3, 1, 5, 1, 3, 2, 5, 7, 5, 8, 4, 3],m = 3,k = 2) == 4\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 4) == 1000000000\n assert candidate(bloomDay = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 3,k = 4) == 2\n assert candidate(bloomDay = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],m = 5,k = 3) == -1\n assert candidate(bloomDay = [6, 5, 8, 10, 6, 11, 5, 3],m = 4,k = 1) == 6\n assert candidate(bloomDay = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],m = 3,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 2, 1, 2, 1, 1, 2, 2, 1],m = 2,k = 3) == 2\n assert candidate(bloomDay = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 4) == 20\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 2) == 8\n assert candidate(bloomDay = [5, 3, 3, 3, 5, 5, 2, 2, 2, 5],m = 3,k = 3) == 5\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 100,k = 5) == -1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 5,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 9, 6, 4, 3, 7, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10,k = 2) == 20\n assert candidate(bloomDay = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [2, 4, 1, 1, 1, 1, 2, 3, 3],m = 2,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 3) == -1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 8) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 10, 11, 12, 13, 14, 15],m = 4,k = 2) == 13\n assert candidate(bloomDay = [7, 7, 7, 12, 7, 7, 7, 12, 7, 7, 7, 12],m = 4,k = 3) == 12\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 5,k = 3) == 2\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 5,k = 2) == 20\n assert candidate(bloomDay = [5, 5, 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,k = 5) == -1\n assert candidate(bloomDay = [1, 1, 2, 2, 3, 3, 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 = 5,k = 4) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 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 = 2) == 30\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],m = 5,k = 3) == 30\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 2) == 1\n assert candidate(bloomDay = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 10,k = 1) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [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],m = 15,k = 5) == 10\n assert candidate(bloomDay = [1, 10, 3, 10, 2, 1, 10, 3, 10, 2],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 3, 5, 7, 2, 8, 10, 6, 4],m = 2,k = 3) == 9\n assert candidate(bloomDay = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 4) == 7\n assert candidate(bloomDay = [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, 5, 1, 3, 1, 5, 1, 3, 1, 5],m = 10,k = 2) == 3\n assert candidate(bloomDay = [5, 8, 6, 9, 7, 2, 4, 3, 10, 1],m = 2,k = 4) == 9\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,k = 3) == 9\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5,k = 3) == 5\n assert candidate(bloomDay = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 5,k = 4) == 200\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 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 = 5,k = 5) == 25\n assert candidate(bloomDay = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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 = 10,k = 3) == 3\n", "comparison": "exact"}, "public_tests": ["[1,10,3,10,2]\n3\n1", "[1,10,3,10,2]\n3\n2", "[7,7,7,7,12,7,7]\n2\n3"], "hints": ["If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x.", "We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x."], "metadata": {"canonical_parameter_names": ["bloomDay", "m", "k"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:29+00:00", "tests_total": 93, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def minDays(self, bloomDay: list[int], m: int, k: int) -> int:", "container": "Solution", "callable": "minDays", "parameters": [{"name": "bloomDay", "type": "list[int]"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1486, "task_id": "xor-operation-in-an-array", "difficulty": "Easy", "problem_description": "You are given an integer n and an integer start.\n\nDefine an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.\n\nReturn the bitwise XOR of all elements of nums.\n\nExample 1:\n\nInput: n = 5, start = 0\nOutput: 8\nExplanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.\nWhere \"^\" corresponds to bitwise XOR operator.\n\nExample 2:\n\nInput: n = 4, start = 3\nOutput: 8\nExplanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.\n\nConstraints:\n\n- 1 <= n <= 1000\n- 0 <= start <= 1000\n- n == nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,start = 3) == 8\n assert candidate(n = 8,start = 12) == 0\n assert candidate(n = 7,start = 2) == 0\n assert candidate(n = 3,start = 2) == 0\n assert candidate(n = 10,start = 1) == 2\n assert candidate(n = 5,start = 0) == 8\n assert candidate(n = 1,start = 7) == 7\n assert candidate(n = 10,start = 5) == 2\n assert candidate(n = 8,start = 2) == 16\n assert candidate(n = 7,start = 5) == 19\n assert candidate(n = 1,start = 5) == 5\n assert candidate(n = 10,start = 999) == 30\n assert candidate(n = 50,start = 25) == 2\n assert candidate(n = 100,start = 200) == 0\n assert candidate(n = 15,start = 2) == 0\n assert candidate(n = 33,start = 17) == 81\n assert candidate(n = 12,start = 8) == 0\n assert candidate(n = 750,start = 10) == 1518\n assert candidate(n = 750,start = 50) == 1598\n assert candidate(n = 3,start = 333) == 339\n assert candidate(n = 666,start = 333) == 2\n assert candidate(n = 500,start = 250) == 1048\n assert candidate(n = 12,start = 3) == 24\n assert candidate(n = 9,start = 1) == 17\n assert candidate(n = 50,start = 10) == 102\n assert candidate(n = 6,start = 999) == 22\n assert candidate(n = 8,start = 11) == 16\n assert candidate(n = 64,start = 42) == 128\n assert candidate(n = 15,start = 7) == 5\n assert candidate(n = 80,start = 600) == 0\n assert candidate(n = 250,start = 100) == 2\n assert candidate(n = 20,start = 10) == 56\n assert candidate(n = 30,start = 42) == 78\n assert candidate(n = 7,start = 25) == 39\n assert candidate(n = 256,start = 128) == 0\n assert candidate(n = 400,start = 400) == 0\n assert candidate(n = 11,start = 8) == 30\n assert candidate(n = 100,start = 250) == 312\n assert candidate(n = 20,start = 11) == 56\n assert candidate(n = 500,start = 750) == 1080\n assert candidate(n = 500,start = 500) == 0\n assert candidate(n = 700,start = 600) == 0\n assert candidate(n = 60,start = 8) == 0\n assert candidate(n = 100,start = 999) == 1864\n assert candidate(n = 250,start = 250) == 534\n assert candidate(n = 8,start = 15) == 16\n assert candidate(n = 18,start = 4) == 2\n assert candidate(n = 1000,start = 0) == 0\n assert candidate(n = 333,start = 256) == 920\n assert candidate(n = 75,start = 300) == 450\n assert candidate(n = 128,start = 99) == 256\n assert candidate(n = 500,start = 999) == 1064\n assert candidate(n = 100,start = 50) == 200\n assert candidate(n = 50,start = 50) == 166\n assert candidate(n = 250,start = 123) == 534\n assert candidate(n = 999,start = 0) == 1998\n assert candidate(n = 999,start = 500) == 2498\n assert candidate(n = 25,start = 6) == 6\n assert candidate(n = 64,start = 32) == 0\n assert candidate(n = 20,start = 12) == 0\n assert candidate(n = 50,start = 100) == 2\n assert candidate(n = 8,start = 1) == 0\n assert candidate(n = 30,start = 15) == 70\n assert candidate(n = 9,start = 7) == 7\n assert candidate(n = 13,start = 11) == 11\n assert candidate(n = 20,start = 3) == 40\n assert candidate(n = 100,start = 25) == 0\n assert candidate(n = 500,start = 0) == 0\n assert candidate(n = 120,start = 750) == 304\n assert candidate(n = 7,start = 1) == 15\n assert candidate(n = 15,start = 12) == 42\n assert candidate(n = 50,start = 0) == 2\n assert candidate(n = 1000,start = 1) == 0\n assert candidate(n = 333,start = 222) == 222\n assert candidate(n = 20,start = 15) == 56\n assert candidate(n = 7,start = 14) == 12\n assert candidate(n = 1000,start = 1000) == 0\n assert candidate(n = 800,start = 150) == 1600\n assert candidate(n = 300,start = 300) == 0\n assert candidate(n = 8,start = 100) == 0\n assert candidate(n = 7,start = 17) == 31\n assert candidate(n = 7,start = 10) == 8\n assert candidate(n = 666,start = 128) == 2\n assert candidate(n = 20,start = 2) == 40\n assert candidate(n = 300,start = 600) == 0\n assert candidate(n = 12,start = 42) == 104\n assert candidate(n = 40,start = 0) == 0\n assert candidate(n = 20,start = 0) == 0\n assert candidate(n = 80,start = 12) == 0\n assert candidate(n = 300,start = 450) == 1496\n assert candidate(n = 999,start = 1) == 1999\n assert candidate(n = 600,start = 300) == 0\n", "comparison": "exact"}, "public_tests": ["5\n0", "4\n3"], "hints": ["Simulate the process, create an array nums and return the Bitwise XOR of all elements of it."], "metadata": {"canonical_parameter_names": ["n", "start"], "leetcode_dataset_entry_point": "Solution().xorOperation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:33+00:00", "tests_total": 92, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def xorOperation(self, n: int, start: int) -> int:", "container": "Solution", "callable": "xorOperation", "parameters": [{"name": "n", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1487, "task_id": "making-file-names-unique", "difficulty": "Medium", "problem_description": "Given an array of strings names of size n. You will create n folders in your file system such that, at the i^th minute, you will create a folder with the name names[i].\n\nSince two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.\n\nReturn an array of strings of length n where ans[i] is the actual name the system will assign to the i^th folder when you create it.\n\nExample 1:\n\nInput: names = [\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]\nOutput: [\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]\nExplanation: Let's see how the file system creates folder names:\n\"pes\" --> not assigned before, remains \"pes\"\n\"fifa\" --> not assigned before, remains \"fifa\"\n\"gta\" --> not assigned before, remains \"gta\"\n\"pes(2019)\" --> not assigned before, remains \"pes(2019)\"\n\nExample 2:\n\nInput: names = [\"gta\",\"gta(1)\",\"gta\",\"avalon\"]\nOutput: [\"gta\",\"gta(1)\",\"gta(2)\",\"avalon\"]\nExplanation: Let's see how the file system creates folder names:\n\"gta\" --> not assigned before, remains \"gta\"\n\"gta(1)\" --> not assigned before, remains \"gta(1)\"\n\"gta\" --> the name is reserved, system adds (k), since \"gta(1)\" is also reserved, systems put k = 2. it becomes \"gta(2)\"\n\"avalon\" --> not assigned before, remains \"avalon\"\n\nExample 3:\n\nInput: names = [\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece\"]\nOutput: [\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece(4)\"]\nExplanation: When the last folder is created, the smallest positive valid k is 4, and it becomes \"onepiece(4)\".\n\nConstraints:\n\n- 1 <= names.length <= 5 * 10^4\n- 1 <= names[i].length <= 20\n- names[i] consists of lowercase English letters, digits, and/or round brackets.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(names = ['doc', 'doc(1)', 'image', 'doc(1)', 'doc']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)']\n assert candidate(names = ['abcd', 'abcde', 'abcd(1)', 'abcd', 'abcd(2)', 'abcd(1)(1)']) == ['abcd', 'abcde', 'abcd(1)', 'abcd(2)', 'abcd(2)(1)', 'abcd(1)(1)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)']\n assert candidate(names = ['pes', 'fifa', 'gta', 'pes(2019)']) == ['pes', 'fifa', 'gta', 'pes(2019)']\n assert candidate(names = ['gta', 'gta(1)', 'gta', 'avalon']) == ['gta', 'gta(1)', 'gta(2)', 'avalon']\n assert candidate(names = ['doc', 'doc', 'image', 'doc(1)', 'doc']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)', 'a(5)', 'a(6)', 'a(7)', 'a(8)', 'a(9)']\n assert candidate(names = ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(3)', 'doc(1)(3)', 'doc(2)(1)']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(3)', 'doc(1)(3)', 'doc(2)(1)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)', 'a(5)']\n assert candidate(names = ['onepiece', 'onepiece(1)', 'onepiece(2)', 'onepiece(3)', 'onepiece']) == ['onepiece', 'onepiece(1)', 'onepiece(2)', 'onepiece(3)', 'onepiece(4)']\n assert candidate(names = ['a', 'a', 'a', 'a(1)', 'a(2)', 'a(1)(1)']) == ['a', 'a(1)', 'a(2)', 'a(1)(1)', 'a(2)(1)', 'a(1)(1)(1)']\n assert candidate(names = ['game', 'game(1)', 'game', 'game(2)', 'game(1)', 'game(3)', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(2)(1)', 'game(1)(1)', 'game(3)', 'game(1)(1)(1)']\n assert candidate(names = ['project', 'project', 'project', 'project', 'project(1)', 'project(1)', 'project(2)', 'project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(1)(3)', 'project(1)', 'project(2)', 'project(3)', 'project(4)', 'project', 'project(1)', 'project(2)', 'project(3)', 'project(4)', 'project(5)']) == ['project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(2)(1)', 'project(4)', 'project(1)(3)', 'project(2)(2)', 'project(3)(1)', 'project(1)(1)(1)', 'project(1)(2)(1)', 'project(1)(3)(1)', 'project(1)(4)', 'project(2)(3)', 'project(3)(2)', 'project(4)(1)', 'project(5)', 'project(1)(5)', 'project(2)(4)', 'project(3)(3)', 'project(4)(2)', 'project(5)(1)']\n assert candidate(names = ['file1', 'file1(1)', 'file1', 'file1(2)', 'file1', 'file1(1)', 'file1(2)', 'file1(1)(1)', 'file1(1)(2)', 'file1(1)(1)(1)', 'file1(1)(1)(2)', 'file1(1)(1)(1)(1)', 'file1(3)', 'file1(4)', 'file1(5)', 'file1(1)(3)', 'file1(1)(4)', 'file1(2)(1)', 'file1(2)(2)', 'file1(2)(1)(1)']) == ['file1', 'file1(1)', 'file1(2)', 'file1(2)(1)', 'file1(3)', 'file1(1)(1)', 'file1(2)(2)', 'file1(1)(1)(1)', 'file1(1)(2)', 'file1(1)(1)(1)(1)', 'file1(1)(1)(2)', 'file1(1)(1)(1)(1)(1)', 'file1(3)(1)', 'file1(4)', 'file1(5)', 'file1(1)(3)', 'file1(1)(4)', 'file1(2)(1)(1)', 'file1(2)(2)(1)', 'file1(2)(1)(1)(1)']\n assert candidate(names = ['album', 'album', 'album', 'album(1)', 'album(2)', 'album', 'album(1)(1)', 'album(1)', 'album(1)(2)', 'album(1)(3)', 'album(1)(4)', 'album(1)(5)', 'album(1)(6)', 'album(1)(7)', 'album(1)(8)', 'album(1)(9)', 'album(1)(10)']) == ['album', 'album(1)', 'album(2)', 'album(1)(1)', 'album(2)(1)', 'album(3)', 'album(1)(1)(1)', 'album(1)(2)', 'album(1)(2)(1)', 'album(1)(3)', 'album(1)(4)', 'album(1)(5)', 'album(1)(6)', 'album(1)(7)', 'album(1)(8)', 'album(1)(9)', 'album(1)(10)']\n assert candidate(names = ['data', 'data', 'data(1)', 'data(2)', 'data', 'data(1)(1)', 'data(1)', 'data(2)', 'data(3)', 'data(2)(1)', 'data(2)(2)', 'data(2)(3)', 'data(2)(1)(1)']) == ['data', 'data(1)', 'data(1)(1)', 'data(2)', 'data(3)', 'data(1)(1)(1)', 'data(1)(2)', 'data(2)(1)', 'data(3)(1)', 'data(2)(1)(1)', 'data(2)(2)', 'data(2)(3)', 'data(2)(1)(1)(1)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(2)', 'photo(3)', 'photo(1)(1)', 'photo(1)(2)', 'photo(1)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(2)(1)', 'photo(3)', 'photo(1)(1)(1)', 'photo(1)(2)', 'photo(1)(3)']\n assert candidate(names = ['video', 'video', 'video(1)', 'video(2)', 'video', 'video(1)', 'video', 'video(1)(1)', 'video(3)', 'video(4)', 'video(2)(2)', 'video(5)', 'video(2)', 'video(6)', 'video(7)', 'video', 'video(8)', 'video(9)', 'video(10)']) == ['video', 'video(1)', 'video(1)(1)', 'video(2)', 'video(3)', 'video(1)(2)', 'video(4)', 'video(1)(1)(1)', 'video(3)(1)', 'video(4)(1)', 'video(2)(2)', 'video(5)', 'video(2)(1)', 'video(6)', 'video(7)', 'video(8)', 'video(8)(1)', 'video(9)', 'video(10)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report', 'report(1)', 'report(2)', 'report(2)', 'report(3)', 'report(3)', 'report(4)', 'report(4)', 'report(5)', 'report(5)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(1)(2)', 'report(2)(1)', 'report(2)(2)', 'report(3)', 'report(3)(1)', 'report(4)', 'report(4)(1)', 'report(5)', 'report(5)(1)']\n assert candidate(names = ['image', 'image', 'image', 'image', 'image(1)', 'image(1)', 'image(2)', 'image', 'image(1)', 'image(2)', 'image(3)', 'image(1)(1)', 'image(1)(2)', 'image(1)(3)', 'image(1)', 'image(2)', 'image(3)', 'image(4)', 'image', 'image(1)', 'image(2)', 'image(3)', 'image(4)', 'image(5)', 'image(1)(1)', 'image(1)(2)', 'image(1)(3)', 'image(1)(4)', 'image(1)(5)', 'image(1)(6)', 'image(1)(7)', 'image(1)(8)', 'image(1)(9)', 'image(1)(10)', 'image(1)(11)', 'image(1)(12)', 'image(1)(13)', 'image(1)(14)', 'image(1)(15)']) == ['image', 'image(1)', 'image(2)', 'image(3)', 'image(1)(1)', 'image(1)(2)', 'image(2)(1)', 'image(4)', 'image(1)(3)', 'image(2)(2)', 'image(3)(1)', 'image(1)(1)(1)', 'image(1)(2)(1)', 'image(1)(3)(1)', 'image(1)(4)', 'image(2)(3)', 'image(3)(2)', 'image(4)(1)', 'image(5)', 'image(1)(5)', 'image(2)(4)', 'image(3)(3)', 'image(4)(2)', 'image(5)(1)', 'image(1)(1)(2)', 'image(1)(2)(2)', 'image(1)(3)(2)', 'image(1)(4)(1)', 'image(1)(5)(1)', 'image(1)(6)', 'image(1)(7)', 'image(1)(8)', 'image(1)(9)', 'image(1)(10)', 'image(1)(11)', 'image(1)(12)', 'image(1)(13)', 'image(1)(14)', 'image(1)(15)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(1)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(1)(2)', 'photo(2)(1)', 'photo(1)(1)(1)', 'photo(1)(3)']\n assert candidate(names = ['data', 'data', 'data(1)', 'data', 'data(1)', 'data(2)', 'data', 'data(1)', 'data(2)', 'data(3)', 'data(1)(1)', 'data(1)(2)', 'data(1)(3)', 'data(1)', 'data(2)', 'data(3)', 'data']) == ['data', 'data(1)', 'data(1)(1)', 'data(2)', 'data(1)(2)', 'data(2)(1)', 'data(3)', 'data(1)(3)', 'data(2)(2)', 'data(3)(1)', 'data(1)(1)(1)', 'data(1)(2)(1)', 'data(1)(3)(1)', 'data(1)(4)', 'data(2)(3)', 'data(3)(2)', 'data(4)']\n assert candidate(names = ['project', 'project', 'project', 'project(1)', 'project', 'project(1)', 'project(2)', 'project(3)']) == ['project', 'project(1)', 'project(2)', 'project(1)(1)', 'project(3)', 'project(1)(2)', 'project(2)(1)', 'project(3)(1)']\n assert candidate(names = ['record', 'record', 'record', 'record(1)', 'record(2)', 'record(3)', 'record', 'record(1)(1)', 'record(1)(2)', 'record(2)(1)', 'record(4)', 'record', 'record(5)', 'record(6)', 'record(1)(1)', 'record(7)', 'record', 'record(2)', 'record(8)', 'record(9)', 'record(10)', 'record(11)']) == ['record', 'record(1)', 'record(2)', 'record(1)(1)', 'record(2)(1)', 'record(3)', 'record(4)', 'record(1)(1)(1)', 'record(1)(2)', 'record(2)(1)(1)', 'record(4)(1)', 'record(5)', 'record(5)(1)', 'record(6)', 'record(1)(1)(2)', 'record(7)', 'record(8)', 'record(2)(2)', 'record(8)(1)', 'record(9)', 'record(10)', 'record(11)']\n assert candidate(names = ['document', 'document', 'document', 'document(1)', 'document', 'document(1)', 'document', 'document(2)', 'document(1)(1)', 'document(1)', 'document(2)', 'document', 'document(1)', 'document(1)(1)', 'document(1)(2)', 'document(1)(3)', 'document(1)(4)', 'document(1)(5)', 'document(1)(6)', 'document(1)(7)', 'document(1)(8)', 'document(1)(9)', 'document(1)(10)', 'document(1)(11)', 'document(1)(12)', 'document(1)(13)', 'document(1)(14)', 'document(1)(15)', 'document(1)(16)', 'document(1)(17)', 'document(1)(18)', 'document(1)(19)', 'document(1)(20)']) == ['document', 'document(1)', 'document(2)', 'document(1)(1)', 'document(3)', 'document(1)(2)', 'document(4)', 'document(2)(1)', 'document(1)(1)(1)', 'document(1)(3)', 'document(2)(2)', 'document(5)', 'document(1)(4)', 'document(1)(1)(2)', 'document(1)(2)(1)', 'document(1)(3)(1)', 'document(1)(4)(1)', 'document(1)(5)', 'document(1)(6)', 'document(1)(7)', 'document(1)(8)', 'document(1)(9)', 'document(1)(10)', 'document(1)(11)', 'document(1)(12)', 'document(1)(13)', 'document(1)(14)', 'document(1)(15)', 'document(1)(16)', 'document(1)(17)', 'document(1)(18)', 'document(1)(19)', 'document(1)(20)']\n assert candidate(names = ['project', 'project', 'project(1)', 'project', 'project(2)', 'project(1)(1)', 'project(1)', 'project(2)(2)', 'project(1)(2)', 'project(2)(1)']) == ['project', 'project(1)', 'project(1)(1)', 'project(2)', 'project(2)(1)', 'project(1)(1)(1)', 'project(1)(2)', 'project(2)(2)', 'project(1)(2)(1)', 'project(2)(1)(1)']\n assert candidate(names = ['game', 'game(1)', 'game', 'game(1)', 'game(2)', 'game', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)']\n assert candidate(names = ['music', 'music', 'music(1)', 'music', 'music(2)', 'music(3)', 'music', 'music(1)(1)', 'music(4)']) == ['music', 'music(1)', 'music(1)(1)', 'music(2)', 'music(2)(1)', 'music(3)', 'music(4)', 'music(1)(1)(1)', 'music(4)(1)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie(1)', 'movie', 'movie(1)', 'movie', 'movie(2)', 'movie(1)(1)', 'movie(1)', 'movie(2)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(1)(1)', 'movie(3)', 'movie(1)(2)', 'movie(4)', 'movie(2)(1)', 'movie(1)(1)(1)', 'movie(1)(3)', 'movie(2)(2)']\n assert candidate(names = ['document', 'document(1)', 'document(2)', 'document', 'document(1)', 'document', 'document(3)', 'document(1)(1)', 'document(2)(1)', 'document(4)']) == ['document', 'document(1)', 'document(2)', 'document(3)', 'document(1)(1)', 'document(4)', 'document(3)(1)', 'document(1)(1)(1)', 'document(2)(1)', 'document(4)(1)']\n assert candidate(names = ['data', 'data', 'data', 'data(1)', 'data(2)', 'data(3)', 'data', 'data(1)(1)', 'data(1)(2)', 'data(2)(1)', 'data(4)', 'data', 'data(5)', 'data(6)', 'data(1)(1)', 'data(7)']) == ['data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(2)(1)', 'data(3)', 'data(4)', 'data(1)(1)(1)', 'data(1)(2)', 'data(2)(1)(1)', 'data(4)(1)', 'data(5)', 'data(5)(1)', 'data(6)', 'data(1)(1)(2)', 'data(7)']\n assert candidate(names = ['doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(1)(1)', 'doc(1)(2)', 'doc(1)(1)']) == ['doc', 'doc(1)', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(2)(1)', 'doc(3)', 'doc(1)(1)(1)', 'doc(1)(2)(1)', 'doc(1)(1)(2)']\n assert candidate(names = ['test', 'test', 'test', 'test(1)', 'test', 'test(1)', 'test(2)', 'test(1)(1)', 'test(1)(2)', 'test(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)']) == ['test', 'test(1)', 'test(2)', 'test(1)(1)', 'test(3)', 'test(1)(2)', 'test(2)(1)', 'test(1)(1)(1)', 'test(1)(2)(1)', 'test(1)(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)(1)']\n assert candidate(names = ['file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(3)', 'file(2)', 'file(1)(1)']) == ['file', 'file(1)', 'file(1)(1)', 'file(1)(2)', 'file(2)', 'file(3)', 'file(2)(1)', 'file(1)(1)(1)']\n assert candidate(names = ['file', 'file', 'file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(1)(1)', 'file(1)(2)', 'file(1)', 'file(2)']) == ['file', 'file(1)', 'file(2)', 'file(3)', 'file(1)(1)', 'file(1)(2)', 'file(2)(1)', 'file(1)(1)(1)', 'file(1)(2)(1)', 'file(1)(3)', 'file(2)(2)']\n assert candidate(names = ['project', 'project', 'project', 'project', 'project(1)', 'project(1)', 'project', 'project(2)', 'project(1)(1)', 'project(1)', 'project(2)', 'project', 'project(1)', 'project(1)(1)', 'project(1)(2)']) == ['project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(4)', 'project(2)(1)', 'project(1)(1)(1)', 'project(1)(3)', 'project(2)(2)', 'project(5)', 'project(1)(4)', 'project(1)(1)(2)', 'project(1)(2)(1)']\n assert candidate(names = ['file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(2)', 'file(3)']) == ['file', 'file(1)', 'file(1)(1)', 'file(1)(2)', 'file(2)', 'file(2)(1)', 'file(3)']\n assert candidate(names = ['app', 'app', 'app', 'app(1)', 'app(1)', 'app(2)', 'app', 'app(1)(1)', 'app(1)(2)', 'app(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)', 'app(3)', 'app(4)', 'app(5)', 'app(1)(3)', 'app(1)(4)', 'app(2)(1)', 'app(2)(2)', 'app(2)(1)(1)', 'app(5)', 'app(1)', 'app(2)', 'app(3)', 'app(1)(1)', 'app(1)(2)', 'app(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)', 'app(6)', 'app(7)', 'app(8)', 'app(1)(5)', 'app(1)(6)', 'app(2)(3)', 'app(2)(4)', 'app(2)(1)(2)']) == ['app', 'app(1)', 'app(2)', 'app(1)(1)', 'app(1)(2)', 'app(2)(1)', 'app(3)', 'app(1)(1)(1)', 'app(1)(2)(1)', 'app(1)(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)(1)', 'app(3)(1)', 'app(4)', 'app(5)', 'app(1)(3)', 'app(1)(4)', 'app(2)(1)(1)', 'app(2)(2)', 'app(2)(1)(1)(1)', 'app(5)(1)', 'app(1)(5)', 'app(2)(3)', 'app(3)(2)', 'app(1)(1)(3)', 'app(1)(2)(2)', 'app(1)(1)(1)(2)', 'app(1)(1)(2)(1)', 'app(1)(1)(1)(1)(2)', 'app(6)', 'app(7)', 'app(8)', 'app(1)(5)(1)', 'app(1)(6)', 'app(2)(3)(1)', 'app(2)(4)', 'app(2)(1)(2)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report(2)', 'report(1)(1)', 'report', 'report(1)', 'report(2)', 'report(1)(1)', 'report(1)(2)', 'report(2)(1)', 'report(2)(2)', 'report(2)(3)', 'report(1)(2)(1)', 'report(1)(1)(1)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(1)(1)(1)', 'report(3)', 'report(1)(2)', 'report(2)(1)', 'report(1)(1)(2)', 'report(1)(2)(1)', 'report(2)(1)(1)', 'report(2)(2)', 'report(2)(3)', 'report(1)(2)(1)(1)', 'report(1)(1)(1)(1)']\n assert candidate(names = ['test', 'test', 'test(1)', 'test(2)', 'test', 'test(1)(1)', 'test(1)', 'test(2)', 'test(3)', 'test(2)(1)', 'test(2)(2)', 'test(2)(3)', 'test(1)(2)(1)', 'test(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)', 'test(1)(1)(1)(2)']) == ['test', 'test(1)', 'test(1)(1)', 'test(2)', 'test(3)', 'test(1)(1)(1)', 'test(1)(2)', 'test(2)(1)', 'test(3)(1)', 'test(2)(1)(1)', 'test(2)(2)', 'test(2)(3)', 'test(1)(2)(1)', 'test(1)(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)(1)', 'test(1)(1)(1)(2)']\n assert candidate(names = ['example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example']) == ['example', 'example(1)', 'example(2)', 'example(3)', 'example(4)', 'example(5)', 'example(6)', 'example(7)', 'example(8)', 'example(9)', 'example(10)', 'example(11)', 'example(12)', 'example(13)', 'example(14)', 'example(15)', 'example(16)', 'example(17)', 'example(18)', 'example(19)', 'example(20)', 'example(21)', 'example(22)', 'example(23)', 'example(24)', 'example(25)', 'example(26)', 'example(27)', 'example(28)', 'example(29)', 'example(30)', 'example(31)', 'example(32)', 'example(33)', 'example(34)', 'example(35)', 'example(36)', 'example(37)', 'example(38)', 'example(39)', 'example(40)', 'example(41)', 'example(42)', 'example(43)', 'example(44)', 'example(45)', 'example(46)', 'example(47)', 'example(48)', 'example(49)', 'example(50)', 'example(51)', 'example(52)', 'example(53)', 'example(54)', 'example(55)', 'example(56)', 'example(57)']\n assert candidate(names = ['file', 'file', 'file', 'file(1)', 'file(2)', 'file', 'file(3)', 'file(1)(1)', 'file(2)(1)', 'file(1)', 'file(4)', 'file(1)(2)', 'file(5)', 'file(2)', 'file(6)']) == ['file', 'file(1)', 'file(2)', 'file(1)(1)', 'file(2)(1)', 'file(3)', 'file(3)(1)', 'file(1)(1)(1)', 'file(2)(1)(1)', 'file(1)(2)', 'file(4)', 'file(1)(2)(1)', 'file(5)', 'file(2)(2)', 'file(6)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie(1)', 'movie(2)', 'movie(3)', 'movie', 'movie(1)(1)', 'movie(1)(2)', 'movie(2)(1)', 'movie(4)', 'movie', 'movie(5)', 'movie(6)', 'movie(1)(1)', 'movie(7)', 'movie', 'movie(2)', 'movie(8)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(1)(1)', 'movie(2)(1)', 'movie(3)', 'movie(4)', 'movie(1)(1)(1)', 'movie(1)(2)', 'movie(2)(1)(1)', 'movie(4)(1)', 'movie(5)', 'movie(5)(1)', 'movie(6)', 'movie(1)(1)(2)', 'movie(7)', 'movie(8)', 'movie(2)(2)', 'movie(8)(1)']\n assert candidate(names = ['file', 'file', 'file', 'file', 'file', 'file', 'file', 'file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(2)']) == ['file', 'file(1)', 'file(2)', 'file(3)', 'file(4)', 'file(5)', 'file(6)', 'file(7)', 'file(8)', 'file(1)(1)', 'file(1)(2)', 'file(2)(1)', 'file(2)(2)']\n assert candidate(names = ['alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha']) == ['alpha', 'alpha(1)', 'alpha(2)', 'alpha(3)', 'alpha(4)', 'alpha(5)', 'alpha(6)', 'alpha(7)', 'alpha(8)', 'alpha(9)', 'alpha(10)', 'alpha(11)', 'alpha(12)', 'alpha(13)', 'alpha(14)', 'alpha(15)', 'alpha(16)', 'alpha(17)', 'alpha(18)', 'alpha(19)']\n assert candidate(names = ['doc', 'doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc(1)(1)', 'doc(1)(1)', 'doc(1)(2)']) == ['doc', 'doc(1)', 'doc(2)', 'doc(1)(1)', 'doc(3)', 'doc(1)(2)', 'doc(2)(1)', 'doc(1)(1)(1)', 'doc(1)(1)(2)', 'doc(1)(2)(1)']\n assert candidate(names = ['report', 'report', 'report', 'report(1)', 'report', 'report(1)', 'report', 'report(2)', 'report(1)(1)', 'report(1)', 'report(2)', 'report', 'report(1)', 'report(1)(1)', 'report(1)(2)', 'report(1)(3)', 'report(1)(4)', 'report(1)(5)', 'report(1)(6)', 'report(1)(7)', 'report(1)(8)', 'report(1)(9)', 'report(1)(10)', 'report(1)(11)', 'report(1)(12)', 'report(1)(13)', 'report(1)(14)', 'report(1)(15)']) == ['report', 'report(1)', 'report(2)', 'report(1)(1)', 'report(3)', 'report(1)(2)', 'report(4)', 'report(2)(1)', 'report(1)(1)(1)', 'report(1)(3)', 'report(2)(2)', 'report(5)', 'report(1)(4)', 'report(1)(1)(2)', 'report(1)(2)(1)', 'report(1)(3)(1)', 'report(1)(4)(1)', 'report(1)(5)', 'report(1)(6)', 'report(1)(7)', 'report(1)(8)', 'report(1)(9)', 'report(1)(10)', 'report(1)(11)', 'report(1)(12)', 'report(1)(13)', 'report(1)(14)', 'report(1)(15)']\n assert candidate(names = ['doc', 'doc(1)', 'image', 'image', 'doc', 'doc(1)', 'doc(2)', 'doc(2)', 'image(1)', 'image(1)']) == ['doc', 'doc(1)', 'image', 'image(1)', 'doc(2)', 'doc(1)(1)', 'doc(2)(1)', 'doc(2)(2)', 'image(1)(1)', 'image(1)(2)']\n assert candidate(names = ['video', 'video', 'video', 'video', 'video(1)', 'video(1)', 'video(2)', 'video', 'video(1)', 'video(2)', 'video(3)', 'video(1)(1)', 'video(1)(2)', 'video(1)(3)', 'video(1)', 'video(2)', 'video(3)', 'video(4)', 'video', 'video(1)', 'video(2)', 'video(3)', 'video(4)', 'video(5)', 'video(1)(1)', 'video(1)(2)', 'video(1)(3)', 'video(1)(4)', 'video(1)(5)', 'video(1)(6)']) == ['video', 'video(1)', 'video(2)', 'video(3)', 'video(1)(1)', 'video(1)(2)', 'video(2)(1)', 'video(4)', 'video(1)(3)', 'video(2)(2)', 'video(3)(1)', 'video(1)(1)(1)', 'video(1)(2)(1)', 'video(1)(3)(1)', 'video(1)(4)', 'video(2)(3)', 'video(3)(2)', 'video(4)(1)', 'video(5)', 'video(1)(5)', 'video(2)(4)', 'video(3)(3)', 'video(4)(2)', 'video(5)(1)', 'video(1)(1)(2)', 'video(1)(2)(2)', 'video(1)(3)(2)', 'video(1)(4)(1)', 'video(1)(5)(1)', 'video(1)(6)']\n assert candidate(names = ['game', 'game', 'game', 'game(1)', 'game(1)', 'game(2)', 'game', 'game(1)(1)', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(1)(2)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)', 'game(1)(1)(2)']\n assert candidate(names = ['photo', 'photo(1)', 'photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(2)(1)']) == ['photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(2)(1)', 'photo(1)(1)(1)', 'photo(2)(1)(1)']\n assert candidate(names = ['test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test']) == ['test', 'test(1)', 'test(2)', 'test(3)', 'test(4)', 'test(5)', 'test(6)', 'test(7)', 'test(8)', 'test(9)', 'test(10)', 'test(11)', 'test(12)', 'test(13)', 'test(14)', 'test(15)', 'test(16)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report(2)', 'report', 'report(1)', 'report', 'report(1)(1)', 'report(3)', 'report(4)', 'report(2)(2)', 'report(5)', 'report(2)', 'report(6)', 'report(7)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(3)', 'report(1)(2)', 'report(4)', 'report(1)(1)(1)', 'report(3)(1)', 'report(4)(1)', 'report(2)(2)', 'report(5)', 'report(2)(1)', 'report(6)', 'report(7)']\n assert candidate(names = ['report', 'report', 'report', 'report', 'report(1)', 'report(1)', 'report(2)', 'report', 'report(1)(1)', 'report(1)(2)', 'report(1)', 'report(2)', 'report(3)', 'report']) == ['report', 'report(1)', 'report(2)', 'report(3)', 'report(1)(1)', 'report(1)(2)', 'report(2)(1)', 'report(4)', 'report(1)(1)(1)', 'report(1)(2)(1)', 'report(1)(3)', 'report(2)(2)', 'report(3)(1)', 'report(5)']\n assert candidate(names = ['file', 'file(1)', 'file', 'file(2)', 'file', 'file(1)', 'file', 'file(1)(1)', 'file(3)', 'file(4)', 'file(2)(2)']) == ['file', 'file(1)', 'file(2)', 'file(2)(1)', 'file(3)', 'file(1)(1)', 'file(4)', 'file(1)(1)(1)', 'file(3)(1)', 'file(4)(1)', 'file(2)(2)']\n assert candidate(names = ['log', 'log', 'log(1)', 'log(2)', 'log', 'log(1)(1)', 'log(1)', 'log(2)', 'log(3)', 'log(2)(1)', 'log(2)(2)', 'log(2)(3)', 'log(1)(2)(1)', 'log(1)(1)(1)', 'log(1)(1)(2)', 'log(1)(1)(1)(1)', 'log(1)(1)(1)(2)', 'log(3)(1)', 'log(3)(2)', 'log(3)(3)', 'log(3)(2)(1)']) == ['log', 'log(1)', 'log(1)(1)', 'log(2)', 'log(3)', 'log(1)(1)(1)', 'log(1)(2)', 'log(2)(1)', 'log(3)(1)', 'log(2)(1)(1)', 'log(2)(2)', 'log(2)(3)', 'log(1)(2)(1)', 'log(1)(1)(1)(1)', 'log(1)(1)(2)', 'log(1)(1)(1)(1)(1)', 'log(1)(1)(1)(2)', 'log(3)(1)(1)', 'log(3)(2)', 'log(3)(3)', 'log(3)(2)(1)']\n assert candidate(names = ['game', 'game(1)', 'game(2)', 'game(3)', 'game', 'game(1)', 'game(4)']) == ['game', 'game(1)', 'game(2)', 'game(3)', 'game(4)', 'game(1)(1)', 'game(4)(1)']\n assert candidate(names = ['image', 'image', 'image', 'image(1)', 'image(2)', 'image(3)', 'image', 'image(1)(1)', 'image(1)(2)', 'image(2)(1)', 'image(4)', 'image', 'image(5)', 'image(6)', 'image(1)(1)', 'image(7)', 'image', 'image(2)', 'image(8)', 'image(9)', 'image(10)', 'image(11)', 'image', 'image(12)', 'image', 'image(13)', 'image', 'image(14)', 'image', 'image(15)', 'image', 'image(16)', 'image', 'image(17)']) == ['image', 'image(1)', 'image(2)', 'image(1)(1)', 'image(2)(1)', 'image(3)', 'image(4)', 'image(1)(1)(1)', 'image(1)(2)', 'image(2)(1)(1)', 'image(4)(1)', 'image(5)', 'image(5)(1)', 'image(6)', 'image(1)(1)(2)', 'image(7)', 'image(8)', 'image(2)(2)', 'image(8)(1)', 'image(9)', 'image(10)', 'image(11)', 'image(12)', 'image(12)(1)', 'image(13)', 'image(13)(1)', 'image(14)', 'image(14)(1)', 'image(15)', 'image(15)(1)', 'image(16)', 'image(16)(1)', 'image(17)', 'image(17)(1)']\n assert candidate(names = ['game', 'game', 'game(1)', 'game', 'game(1)', 'game(2)', 'game(2)']) == ['game', 'game(1)', 'game(1)(1)', 'game(2)', 'game(1)(2)', 'game(2)(1)', 'game(2)(2)']\n assert candidate(names = ['data', 'data', 'data', 'data(1)', 'data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(1)(2)', 'data(1)(1)(1)']) == ['data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(3)', 'data(1)(2)', 'data(2)(1)', 'data(1)(1)(1)', 'data(1)(2)(1)', 'data(1)(1)(1)(1)']\n assert candidate(names = ['music', 'music', 'music', 'music', 'music(1)', 'music(1)', 'music(2)', 'music', 'music(1)', 'music(2)', 'music(3)', 'music(1)(1)', 'music(1)(2)', 'music(1)(3)', 'music(1)', 'music(2)', 'music(3)', 'music(4)', 'music', 'music(1)', 'music(2)', 'music(3)', 'music(4)', 'music(5)', 'music(1)(1)', 'music(1)(2)', 'music(1)(3)', 'music(1)(4)', 'music(1)(5)', 'music(1)(6)', 'music(1)(7)', 'music(1)(8)', 'music(1)(9)', 'music(1)(10)']) == ['music', 'music(1)', 'music(2)', 'music(3)', 'music(1)(1)', 'music(1)(2)', 'music(2)(1)', 'music(4)', 'music(1)(3)', 'music(2)(2)', 'music(3)(1)', 'music(1)(1)(1)', 'music(1)(2)(1)', 'music(1)(3)(1)', 'music(1)(4)', 'music(2)(3)', 'music(3)(2)', 'music(4)(1)', 'music(5)', 'music(1)(5)', 'music(2)(4)', 'music(3)(3)', 'music(4)(2)', 'music(5)(1)', 'music(1)(1)(2)', 'music(1)(2)(2)', 'music(1)(3)(2)', 'music(1)(4)(1)', 'music(1)(5)(1)', 'music(1)(6)', 'music(1)(7)', 'music(1)(8)', 'music(1)(9)', 'music(1)(10)']\n assert candidate(names = ['doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(1)', 'doc(2)', 'doc(3)', 'doc']) == ['doc', 'doc(1)', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(2)(1)', 'doc(3)', 'doc(1)(3)', 'doc(2)(2)', 'doc(3)(1)', 'doc(4)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie', 'movie(1)', 'movie(1)', 'movie(2)', 'movie(2)', 'movie(3)', 'movie(3)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(3)', 'movie(1)(1)', 'movie(1)(2)', 'movie(2)(1)', 'movie(2)(2)', 'movie(3)(1)', 'movie(3)(2)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(2)', 'photo(1)', 'photo(3)', 'photo(4)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(2)(1)', 'photo(1)(2)', 'photo(3)', 'photo(4)']\n assert candidate(names = ['game', 'game', 'game', 'game(1)', 'game(2)', 'game', 'game(1)(1)', 'game(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)', 'game(1)(2)']\n assert candidate(names = ['doc', 'doc', 'doc', 'doc', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(3)', 'doc(1)(1)']) == ['doc', 'doc(1)', 'doc(2)', 'doc(3)', 'doc(4)', 'doc(1)(1)', 'doc(2)(1)', 'doc(5)', 'doc(3)(1)', 'doc(1)(1)(1)']\n", "comparison": "exact"}, "public_tests": ["[\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]", "[\"gta\",\"gta(1)\",\"gta\",\"avalon\"]", "[\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece\"]"], "hints": ["Keep a map of each name and the smallest valid integer that can be appended as a suffix to it.", "If the name is not present in the map, you can use it without adding any suffixes.", "If the name is present in the map, append the smallest proper suffix, and add the new name to the map."], "metadata": {"canonical_parameter_names": ["names"], "leetcode_dataset_entry_point": "Solution().getFolderNames", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:36+00:00", "tests_total": 66, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def getFolderNames(self, names: list[str]) -> list[str]:", "container": "Solution", "callable": "getFolderNames", "parameters": [{"name": "names", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1488, "task_id": "avoid-flood-in-the-city", "difficulty": "Medium", "problem_description": "Your country has 10^9 lakes. Initially, all the lakes are empty, but when it rains over the n^th lake, the n^th lake becomes full of water. If it rains over a lake that is full of water, there will be a flood. Your goal is to avoid floods in any lake.\n\nGiven an integer array rains where:\n\n- rains[i] > 0 means there will be rains over the rains[i] lake.\n- rains[i] == 0 means there are no rains this day and you must choose one lake this day and dry it.\n\nReturn an array ans where:\n\n- ans.length == rains.length\n- ans[i] == -1 if rains[i] > 0.\n- ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.\n\nIf there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.\n\nNotice that if you chose to dry a full lake, it becomes empty, but if you chose to dry an empty lake, nothing changes.\n\nExample 1:\n\nInput: rains = [1,2,3,4]\nOutput: [-1,-1,-1,-1]\nExplanation: After the first day full lakes are [1]\nAfter the second day full lakes are [1,2]\nAfter the third day full lakes are [1,2,3]\nAfter the fourth day full lakes are [1,2,3,4]\nThere's no day to dry any lake and there is no flood in any lake.\n\nExample 2:\n\nInput: rains = [1,2,0,0,2,1]\nOutput: [-1,-1,2,1,-1,-1]\nExplanation: After the first day full lakes are [1]\nAfter the second day full lakes are [1,2]\nAfter the third day, we dry lake 2. Full lakes are [1]\nAfter the fourth day, we dry lake 1. There is no full lakes.\nAfter the fifth day, full lakes are [2].\nAfter the sixth day, full lakes are [1,2].\nIt is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another acceptable scenario.\n\nExample 3:\n\nInput: rains = [1,2,0,1,2]\nOutput: []\nExplanation: After the second day, full lakes are [1,2]. We have to dry one lake in the third day.\nAfter that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood.\n\nConstraints:\n\n- 1 <= rains.length <= 10^5\n- 0 <= rains[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rains = [0, 1, 1, 0, 2, 0, 1]) == []\n assert candidate(rains = [1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1]) == [-1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 2, 1]) == [-1, 1, -1, 2, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 1, 2, 3]) == []\n assert candidate(rains = [2, 3, 0, 0, 3, 1, 0, 1, 0, 1]) == [-1, -1, 3, 1, -1, -1, 1, -1, 1, -1]\n assert candidate(rains = [0, 1, 0, 2, 0, 1, 0, 2]) == [1, -1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 2, 1, 0, 1, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0]) == [-1, -1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4]) == [-1, -1, -1, -1]\n assert candidate(rains = [0, 1, 1]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 2]) == [-1, -1, 1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 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(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 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, 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, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [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(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == []\n assert candidate(rains = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == []\n assert candidate(rains = [0, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [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]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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(rains = [1, 2, 0, 0, 3, 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]) == [-1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -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(rains = [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]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 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(rains = [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]) == []\n assert candidate(rains = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(rains = [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]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(rains = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 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(rains = [1, 0, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, 2, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1]\n assert candidate(rains = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 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]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == [-1, -1, 2, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 2, 0, 2, 0, 3, 0, 3, 0, 4, 0, 4, 0, 5, 0, 5, 0]) == [-1, 1, -1, 1, -1, 2, -1, 1, -1, 3, -1, 1, -1, 4, -1, 1, -1, 5, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 6, 7, 0, 8, 9, 0, 10, 11, 0, 12, 13, 0, 14, 15, 0, 16, 17, 0, 18, 19, 0, 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]\n assert candidate(rains = [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, 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]\n assert candidate(rains = [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, 1]) == [-1, 1, -1, 1, -1, 1, -1, 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(rains = [1, 2, 3, 4, 5, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [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, 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]\n assert candidate(rains = [1, 2, 0, 1, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 7, 0, 7, 8, 0, 8, 9, 0, 9, 10, 0, 10]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 0, 4, 5]) == []\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 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, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [3, 0, 4, 0, 5, 0, 3, 0, 4, 0, 5]) == [-1, 3, -1, 4, -1, 5, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 5, 6, 7, 8, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [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(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [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(rains = [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]) == [-1, 1, -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(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == []\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 5, 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]) == [-1, 1, 1, 1, 1, -1, 2, 1, 1, -1, 3, 1, 1, 1, -1, 4, 1, 1, 1, -1, 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]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 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]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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(rains = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 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(rains = [0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == [-1, -1, 2, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 2, 0, 3, 0, 0, 3, 0, 0, 4, 0, 0, 4, 0, 0, 5, 0, 0, 5]) == [-1, 1, 1, -1, 2, 1, -1, 1, -1, 3, 1, -1, 1, 1, -1, 4, 1, -1, 1, 1, -1, 5, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 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]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 0, 2, 0, 3, 0, 4]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [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]) == [-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(rains = [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]) == [-1, 1, -1, 1, -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(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == [-1, 1, -1, 2, -1, 3, -1, 2, -1, 1, -1, 3, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == [-1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 4, 5, 6, 0, 0, 0, 7, 8, 9, 0, 0, 0, 1, 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]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 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]\n assert candidate(rains = [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, 0, 0, 0, 0, 0, 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(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 1]\n assert candidate(rains = [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, 10, 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]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 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, 1, 1, 1, 1, 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(rains = [1, 2, 3, 4, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == [-1, -1, -1, -1, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1]\n assert candidate(rains = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0, 11, 12, 0, 13, 14]) == [-1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0]) == [-1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 2, 0, 3, 0, 0, 1, 0, 2, 0, 3]) == [-1, 1, 1, -1, 2, -1, 3, 1, -1, 1, -1, 2, -1, 3, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 1, 0, 0, 0, 2, 2, 0, 0, 3, 3, 0, 0, 4, 4, 0, 0, 5, 5, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == [-1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 0, 3, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, 1, -1, 2, 1, 1, 1, 1, -1, 3, -1, 4, 1, 1, -1, 5, 1, 1, -1, 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]\n assert candidate(rains = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == []\n assert candidate(rains = [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, 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]\n assert candidate(rains = [1, 2, 0, 0, 0, 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, 10, 0, 0, 0]) == [-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]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0]) == [-1, 1, 1, -1, 2, 1, -1, 1, 1, -1, 2, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [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]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 3, 0, 4, 0, 5, 0, 4]) == [-1, 1, -1, 2, -1, 1, -1, -1, 1, -1, 4, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [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, 1]) == []\n assert candidate(rains = [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]) == [-1, -1, -1, -1, -1, -1, -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(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0, 1, 0, 2, 0]) == [-1, 1, -1, 2, -1, 2, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == [-1, 1000000000, -1, 1000000000, -1, 1000000000, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 1, 2, 3, 4, 5, 0, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 1, 2, 3, 4]) == [-1, -1, -1, -1, 1, 2, 3, 4, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 2, 0, 3, 4, 0, 5, 4, 0, 3, 2, 1, 0]) == []\n assert candidate(rains = [1, 1, 0, 0]) == []\n assert candidate(rains = [0, 1, 2, 3, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1]) == [-1, -1, 1, 2, 1, -1, -1, 1, 1, -1]\n assert candidate(rains = [1, 1, 0, 2, 0, 2, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [0]) == [1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 2]) == [-1, 1, -1, 2, 1, 1, 1, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 1, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, -1, -1, -1]\n assert candidate(rains = [1, 1, 2, 2, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 1, 2, 3, 4, 5, 6]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 3, 0, 2, 0, 1]) == [-1, -1, -1, 3, 2, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 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]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 2]) == [-1, 1, -1, -1, 2, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0, 2]) == [-1, 1, -1, 2, -1, 2, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 3, 2, 1]) == [-1, -1, -1, 3, 2, 1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1]) == [-1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 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]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 2]) == [-1, 1, 1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2]) == []\n assert candidate(rains = [1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 0, 2, 3]) == [-1, 1, -1, -1, 2, -1, 3, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 0, 1, 2]) == [-1, 1, -1, -1, 2, 1, -1, -1]\n assert candidate(rains = [2, 3, 0, 0, 2, 1, 0, 1, 2]) == []\n assert candidate(rains = [1, 1, 0, 0, 2, 2]) == []\n assert candidate(rains = [0, 1, 0, 2, 0, 3, 0, 1, 2, 3]) == [1, -1, 1, -1, 2, -1, 3, -1, -1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 1]) == [-1, 1, 1, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 0, 2]) == [-1, 1, 1, 1, 1, -1, 2, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 2, 3, 4, 0, 5]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, -1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, 1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 1, 2, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 1, 2]) == [-1, 1, -1, 2, -1, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2]) == []\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1]\n assert candidate(rains = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 1, 0]) == [-1, 1, 1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, 1, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 0, 1]) == [-1, 1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 3, 3]) == []\n assert candidate(rains = [0, 0, 0, 0, 1, 1, 1, 1]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, 1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1]) == [-1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1000000000, 0, 1000000000, 0]) == [-1, 1000000000, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 0, 3]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 1]) == [-1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0, 1, 0, 2]) == [-1, -1, 2, 1, -1, -1, 1, -1, 2, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 4, 5, 0, 6, 7, 0, 8, 9, 0, 10, 11, 0, 12, 13, 0]) == [-1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 1]) == []\n assert candidate(rains = [0, 1, 1, 0, 2, 0, 1, 0, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2, 0]) == [-1, -1, 1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 2]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 2, 1, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2]) == [-1, -1, 1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 4]) == [-1, -1, -1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 2, 0, 3, 0, 1]) == [-1, -1, -1, 2, -1, 3, -1, 1, -1]\n assert candidate(rains = [10, 20, 20]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 1, 2]) == [-1, 1, -1, 2, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 4, 0, 2, 0, 1, 0, 2, 0, 1, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 3, 0]) == [-1, -1, -1, 3, -1, -1, -1, 1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 2, 1]) == [-1, -1, 2, 1, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1]) == [-1]\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 3, 0, 2, 0, 4, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 0, 1, 0, 2, 0, 1]) == [-1, -1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 0, 0]) == [-1, -1, -1, -1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0, 0]) == [-1, -1, 2, 1, -1, -1, 1, 1]\n assert candidate(rains = [1, 1, 1, 1, 1]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 3, 2]) == [-1, -1, 2, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 0, 0, 0, 2]) == [-1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 0, 2, 3, 4, 5]) == []\n assert candidate(rains = [3, 3, 0, 0, 0, 2, 0, 0, 3, 2, 1, 0, 0, 1]) == []\n assert candidate(rains = [1, 1, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 2]) == [-1, 1, 1, 1, -1, 2, 1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0]) == [-1, -1, 2, 1, -1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 3]) == []\n assert candidate(rains = [1, 2, 0, 2, 3, 0, 1]) == [-1, -1, 2, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 2, 2, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 3, 0, 2, 1, 0]) == [-1, 1, -1, 2, 1, -1, 1, -1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4]) == [-1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, -1, 2, -1, 3, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 1]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2]) == [-1, -1, 1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1]) == [-1, -1, -1, 1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 2, 0, 1, 0]) == [-1, -1, -1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [0, 1, 0, 2, 0, 1, 0]) == [1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 1]) == [-1, 1, 1, 1, -1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == []\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[1,2,0,0,2,1]", "[1,2,0,1,2]"], "hints": ["Keep An array of the last day there was rains over each city.", "Keep an array of the days you can dry a lake when you face one.", "When it rains over a lake, check the first possible day you can dry this lake and assign this day to this lake."], "metadata": {"canonical_parameter_names": ["rains"], "leetcode_dataset_entry_point": "Solution().avoidFlood", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:38+00:00", "tests_total": 242, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "binary-search", "greedy", "heap-priority-queue"]}, "language": "python", "interface": {"raw_signature": "def avoidFlood(self, rains: list[int]) -> list[int]:", "container": "Solution", "callable": "avoidFlood", "parameters": [{"name": "rains", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1489, "task_id": "find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree", "difficulty": "Hard", "problem_description": "Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [a_i, b_i, weight_i] represents a bidirectional and weighted edge between nodes a_i and b_i. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.\n\nFind all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST). An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.\n\nNote that you can return the indices of the edges in any order.\n\nExample 1:\n\nInput: n = 5, edges = [[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]]\nOutput: [[0,1],[2,3,4,5]]\nExplanation: The figure above describes the graph.\nThe following figure shows all the possible MSTs:\n\nNotice that the two edges 0 and 1 appear in all MSTs, therefore they are critical edges, so we return them in the first list of the output.\nThe edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are considered pseudo-critical edges. We add them to the second list of the output.\n\nExample 2:\n\nInput: n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]]\nOutput: [[],[0,1,2,3]]\nExplanation: We can observe that since all 4 edges have equal weight, choosing any 3 edges from the given 4 will yield an MST. Therefore all 4 edges are pseudo-critical.\n\nConstraints:\n\n- 2 <= n <= 100\n- 1 <= edges.length <= min(200, n * (n - 1) / 2)\n- edges[i].length == 3\n- 0 <= a_i < b_i < n\n- 1 <= weight_i <= 1000\n- All pairs (a_i, b_i) are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 1], [0, 2, 2]]) == [[0, 1], []]\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [0, 3, 2], [0, 4, 3], [3, 4, 3], [1, 4, 6]]) == [[0, 1], [2, 3, 4, 5]]\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7]]) == [[0, 1, 3, 5, 6], []]\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [0, 3, 1]]) == [[], [0, 1, 2, 3]]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 2], [0, 2, 3]]) == [[0, 1], []]\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 3, 6], [1, 2, 5], [1, 3, 8], [1, 4, 9], [2, 4, 7], [3, 4, 4]]) == [[0, 6, 2, 1], []]\n assert candidate(n = 6,edges = [[0, 1, 4], [0, 2, 4], [1, 2, 2], [1, 3, 3], [1, 4, 2], [2, 3, 1], [3, 4, 2], [3, 5, 3], [4, 5, 3]]) == [[5], [2, 4, 6, 7, 8, 0, 1]]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15], [0, 4, 16], [0, 5, 17], [0, 6, 18], [1, 5, 19], [1, 6, 20], [2, 6, 21]]) == [[0, 1, 2, 5, 8, 11], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 10], [1, 3, 20], [1, 4, 30], [2, 3, 10], [2, 4, 20], [2, 5, 30], [3, 4, 10], [3, 5, 20], [3, 6, 30], [4, 5, 10], [4, 6, 20], [4, 7, 30], [5, 6, 10], [5, 7, 20], [5, 8, 30], [6, 7, 10], [6, 8, 20], [6, 9, 30], [7, 8, 10], [7, 9, 20], [8, 9, 10]]) == [[0, 3, 6, 9, 12, 15, 18, 21, 23], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [2, 3, 6], [2, 4, 7], [3, 4, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17]]) == [[0, 1, 2, 6, 8, 9, 11, 13, 15], []]\n assert candidate(n = 12,edges = [[0, 1, 3], [0, 2, 4], [0, 3, 5], [1, 2, 2], [1, 3, 6], [1, 4, 7], [2, 3, 8], [2, 4, 9], [2, 5, 10], [3, 4, 11], [3, 5, 12], [3, 6, 13], [4, 5, 14], [4, 6, 15], [4, 7, 16], [5, 6, 17], [5, 7, 18], [5, 8, 19], [6, 7, 20], [6, 8, 21], [6, 9, 22], [7, 8, 23], [7, 9, 24], [7, 10, 25], [8, 9, 26], [8, 10, 27], [8, 11, 28], [9, 10, 29], [9, 11, 30], [10, 11, 31]]) == [[3, 0, 2, 5, 8, 11, 14, 17, 20, 23, 26], []]\n assert candidate(n = 9,edges = [[0, 1, 100], [0, 2, 90], [0, 3, 95], [1, 2, 85], [1, 3, 80], [1, 4, 75], [2, 3, 65], [2, 4, 60], [2, 5, 55], [3, 4, 50], [3, 5, 45], [3, 6, 40], [4, 5, 35], [4, 6, 30], [4, 7, 25], [5, 6, 20], [5, 7, 15], [5, 8, 10], [6, 7, 5], [6, 8, 1], [7, 8, 50]]) == [[19, 18, 17, 14, 11, 8, 5, 1], []]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [3, 7, 70], [3, 8, 80], [4, 9, 90], [4, 10, 100], [5, 11, 110], [6, 11, 120], [7, 8, 130], [8, 9, 140], [9, 10, 150], [10, 11, 160], [0, 3, 170], [1, 5, 180], [2, 7, 190], [3, 9, 200], [4, 11, 210]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 25], [1, 4, 35], [2, 3, 40], [2, 5, 45], [3, 4, 50], [3, 6, 55], [4, 5, 60], [5, 6, 65], [6, 7, 70], [6, 8, 75], [7, 8, 80], [7, 9, 85], [8, 9, 90], [9, 10, 95], [9, 11, 100], [10, 11, 105], [10, 12, 110], [11, 12, 115], [12, 13, 120], [12, 14, 125], [13, 14, 130]]) == [[0, 1, 2, 4, 6, 8, 11, 12, 14, 16, 17, 19, 21, 22], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [0, 7, 8], [1, 3, 9], [2, 4, 10], [3, 5, 11], [4, 6, 12], [5, 7, 13], [0, 3, 14], [1, 4, 15], [2, 5, 16], [3, 6, 17], [4, 7, 18]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 20], [0, 3, 30], [1, 2, 15], [1, 4, 10], [2, 3, 10], [2, 4, 25], [2, 5, 35], [3, 4, 5], [3, 6, 15], [4, 5, 20], [4, 6, 10], [4, 7, 25], [5, 6, 30], [5, 7, 15], [6, 7, 20]]) == [[0, 8, 4, 5, 11, 14], [10, 15]]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [0, 7, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10], [4, 6, 11]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 6,edges = [[0, 1, 100], [0, 2, 50], [0, 3, 20], [1, 2, 60], [1, 3, 40], [1, 4, 70], [2, 3, 30], [2, 4, 80], [2, 5, 90], [3, 4, 5], [3, 5, 10], [4, 5, 100]]) == [[9, 10, 2, 6, 4], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18]]) == [[0, 1, 2, 5, 8, 11, 14], []]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 6], [0, 3, 5], [1, 3, 15], [2, 3, 4], [2, 4, 11], [3, 4, 9], [3, 5, 10], [4, 5, 13], [4, 6, 14], [5, 6, 16], [5, 7, 7], [6, 7, 18]]) == [[4, 2, 11, 6, 0, 7, 9], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 15], [2, 3, 25], [2, 4, 10], [3, 4, 30], [3, 5, 15], [4, 5, 5], [4, 6, 20], [5, 6, 25], [5, 7, 10], [6, 7, 30], [6, 8, 15], [7, 8, 5], [7, 9, 20], [8, 9, 25]]) == [[2, 8, 14, 0, 5, 11, 13, 15], [3, 7]]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 2, 8], [1, 3, 9], [2, 3, 10], [2, 4, 11], [3, 4, 12], [3, 5, 13], [4, 5, 14], [4, 6, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18], [6, 8, 19], [7, 8, 20], [0, 4, 21], [1, 5, 22], [2, 6, 23], [3, 7, 24], [4, 8, 25]]) == [[0, 1, 2, 6, 8, 10, 12, 14], []]\n assert candidate(n = 15,edges = [[0, 1, 5], [0, 2, 7], [0, 3, 9], [1, 2, 3], [1, 3, 2], [1, 4, 6], [2, 3, 1], [2, 4, 4], [2, 5, 8], [3, 4, 11], [3, 5, 13], [3, 6, 15], [4, 5, 12], [4, 6, 14], [5, 6, 16], [5, 7, 18], [5, 8, 20], [6, 7, 21], [6, 8, 22], [7, 8, 23], [7, 9, 25], [7, 10, 27], [8, 9, 24], [8, 10, 26], [9, 10, 28], [9, 11, 29], [9, 12, 31], [10, 11, 30], [10, 12, 32], [11, 12, 33], [11, 13, 35], [11, 14, 37], [12, 13, 34], [12, 14, 36], [13, 14, 38]]) == [[6, 4, 7, 0, 8, 13, 15, 16, 22, 23, 25, 26, 32, 33], []]\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, 6, 7], [3, 7, 8], [4, 7, 9], [5, 7, 10], [0, 3, 11], [1, 5, 12], [2, 4, 13], [6, 7, 14]]) == [[0, 1, 2, 3, 4, 5, 7], []]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 2, 8], [1, 3, 9], [1, 4, 10], [2, 3, 11], [2, 4, 12], [2, 5, 13], [3, 4, 14], [3, 5, 15], [3, 6, 16], [4, 5, 17], [4, 6, 18], [4, 7, 19], [5, 6, 20], [5, 7, 21], [5, 8, 22], [6, 7, 23], [7, 8, 24]]) == [[0, 1, 2, 5, 8, 11, 14, 17], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15], [6, 7, 16], [6, 8, 17], [7, 8, 18], [7, 9, 19], [8, 9, 20], [8, 10, 21], [9, 10, 22], [9, 11, 23], [10, 11, 24]]) == [[0, 1, 2, 5, 8, 11, 15, 16, 18, 20, 22], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 9, 11], [0, 9, 15], [2, 8, 12], [4, 7, 13]]) == [[0, 1, 3, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 11,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 2, 6], [1, 3, 7], [1, 4, 8], [1, 5, 9], [2, 3, 10], [2, 4, 11], [2, 5, 12], [2, 6, 13], [3, 4, 14], [3, 5, 15], [3, 6, 16], [3, 7, 17], [4, 5, 18], [4, 6, 19], [4, 7, 20], [4, 8, 21], [5, 6, 22], [5, 7, 23], [5, 8, 24], [5, 9, 25], [6, 7, 26], [6, 8, 27], [6, 9, 28], [6, 10, 29], [7, 8, 30], [7, 9, 31], [7, 10, 32], [8, 9, 33], [8, 10, 34], [9, 10, 35]]) == [[0, 1, 2, 3, 7, 11, 15, 19, 23, 27], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 4, 1], [2, 6, 1], [3, 5, 1], [3, 6, 1], [4, 7, 1], [5, 7, 1], [6, 7, 1], [7, 8, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [1, 6, 1], [1, 7, 1], [2, 5, 1], [2, 7, 1], [3, 4, 1], [3, 7, 1], [4, 6, 1], [5, 6, 1], [4, 8, 1], [5, 8, 1], [6, 8, 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]]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 8, 8], [3, 9, 9], [4, 10, 10], [5, 11, 11], [6, 11, 12], [7, 10, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 1], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18]]) == [[3, 0, 2, 5, 8, 11, 14], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [0, 4, 16], [1, 5, 17], [2, 6, 18], [3, 7, 19], [0, 5, 20], [1, 6, 21], [2, 7, 22], [3, 8, 23], [0, 6, 24], [1, 7, 25], [2, 8, 26]]) == [[0, 1, 3, 5, 7, 9, 11, 13], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 10], [0, 3, 10], [1, 2, 10], [1, 3, 10], [2, 3, 10], [2, 4, 1], [2, 5, 10], [3, 4, 10], [3, 5, 10], [4, 5, 1], [4, 6, 10], [4, 7, 10], [5, 6, 10], [5, 7, 10], [6, 7, 1], [6, 8, 10], [7, 8, 10]]) == [[0, 6, 10, 15], [1, 2, 3, 4, 5, 8, 9, 11, 12, 13, 14, 16, 17]]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [5, 8, 18], [6, 7, 19], [6, 8, 20], [6, 9, 21], [7, 8, 22], [7, 9, 23], [7, 10, 24], [8, 9, 25], [8, 10, 26], [8, 11, 27], [9, 10, 28], [9, 11, 29], [10, 11, 30]]) == [[0, 1, 2, 5, 8, 11, 14, 17, 20, 23, 26], []]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [5, 8, 18], [6, 7, 19], [6, 8, 20], [6, 9, 21], [7, 8, 22], [7, 9, 23], [7, 10, 24], [8, 9, 25], [8, 10, 26], [8, 11, 27], [9, 10, 28], [9, 11, 29], [10, 11, 30], [11, 12, 31], [11, 13, 32], [11, 14, 33], [12, 13, 34], [12, 14, 35], [13, 14, 36]]) == [[0, 1, 2, 5, 8, 11, 14, 17, 20, 23, 26, 30, 31, 32], []]\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 1], [1, 4, 5], [1, 5, 6], [2, 3, 2], [2, 5, 3], [3, 6, 7], [3, 7, 8], [4, 5, 2], [4, 8, 9], [5, 6, 4], [5, 9, 10], [6, 7, 5], [7, 8, 6], [8, 9, 7]]) == [[3, 0, 6, 10, 7, 12, 14, 15, 16], []]\n", "comparison": "exact"}, "public_tests": ["5\n[[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]]", "4\n[[0,1,1],[1,2,1],[2,3,1],[0,3,1]]"], "hints": ["Use the Kruskal algorithm to find the minimum spanning tree by sorting the edges and picking edges from ones with smaller weights.", "Use a disjoint set to avoid adding redundant edges that result in a cycle.", "To find if one edge is critical, delete that edge and re-run the MST algorithm and see if the weight of the new MST increases.", "To find if one edge is non-critical (in any MST), include that edge to the accepted edge list and continue the MST algorithm, then see if the resulting MST has the same weight of the initial MST of the entire graph."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findCriticalAndPseudoCriticalEdges", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:40+00:00", "tests_total": 55, "tests_dropped": 19, "flags": ["figure_reference", "has_images"], "topic_tags": ["union-find", "graph", "sorting", "minimum-spanning-tree", "strongly-connected-component", "prims-algorithm", "kruskals-algorithm", "boruvkas-algorithm"]}, "language": "python", "interface": {"raw_signature": "def findCriticalAndPseudoCriticalEdges(self, n: int, edges: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "findCriticalAndPseudoCriticalEdges", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1491, "task_id": "average-salary-excluding-the-minimum-and-maximum-salary", "difficulty": "Easy", "problem_description": "You are given an array of unique integers salary where salary[i] is the salary of the i^th employee.\n\nReturn the average salary of employees excluding the minimum and maximum salary. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: salary = [4000,3000,1000,2000]\nOutput: 2500.00000\nExplanation: Minimum salary and maximum salary are 1000 and 4000 respectively.\nAverage salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500\n\nExample 2:\n\nInput: salary = [1000,2000,3000]\nOutput: 2000.00000\nExplanation: Minimum salary and maximum salary are 1000 and 3000 respectively.\nAverage salary excluding minimum and maximum salary is (2000) / 1 = 2000\n\nConstraints:\n\n- 3 <= salary.length <= 100\n- 1000 <= salary[i] <= 10^6\n- All the integers of salary are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(salary=[54000, 25000, 75000, 30000, 45000]), 43000.0)\n assert answers_match(candidate(salary=[7500, 8500, 6500, 9500, 7000]), 7666.666666666667)\n assert answers_match(candidate(salary=[5000, 6000, 7000, 8000, 9000, 10000]), 7500.0)\n assert answers_match(candidate(salary=[12000, 11000, 13000, 9000, 10000, 14000]), 11500.0)\n assert answers_match(candidate(salary=[4000, 3000, 1000, 2000]), 2500.0)\n assert answers_match(candidate(salary=[8000, 9000, 2000, 3000, 6000, 10000, 5000]), 6200.0)\n assert answers_match(candidate(salary=[1500, 2500, 3500, 4500, 5500]), 3500.0)\n assert answers_match(candidate(salary=[5000, 10000, 15000, 20000, 25000]), 15000.0)\n assert answers_match(candidate(salary=[15000, 25000, 35000, 45000, 55000]), 35000.0)\n assert answers_match(candidate(salary=[100000, 120000, 110000]), 110000.0)\n assert answers_match(candidate(salary=[1000, 2000, 3000]), 2000.0)\n assert answers_match(candidate(salary=[7500, 8200, 9000, 12000, 6000]), 8233.333333333334)\n assert answers_match(candidate(salary=[6000, 5000, 4000, 3000, 2000, 1000]), 3500.0)\n assert answers_match(candidate(salary=[9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]), 5000.0)\n assert answers_match(candidate(salary=[999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]), 999994.5)\n assert answers_match(candidate(salary=[100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]), 550000.0)\n assert answers_match(candidate(salary=[1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1012]), 5107.5)\n assert answers_match(candidate(salary=[9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010]), 10004.5)\n assert answers_match(candidate(salary=[45000, 55000, 65000, 35000, 25000, 75000, 85000, 95000, 105000, 115000, 125000, 135000]), 80000.0)\n assert answers_match(candidate(salary=[10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000]), 60000.0)\n assert answers_match(candidate(salary=[123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 12345, 54321]), 460081.8888888889)\n assert answers_match(candidate(salary=[1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981]), 999990.5)\n assert answers_match(candidate(salary=[1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10010, 11011, 12012, 13013]), 7007.0)\n assert answers_match(candidate(salary=[10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200]), 10600.0)\n assert answers_match(candidate(salary=[888888, 888889, 888890, 888891, 888892, 888893, 888894, 888895, 888896, 888897, 888898, 888899, 888900, 888901, 888902, 888903, 888904]), 888896.0)\n assert answers_match(candidate(salary=[555555, 555556, 555557, 555558, 555559, 555560, 555561, 555562, 555563, 555564, 555565]), 555560.0)\n assert answers_match(candidate(salary=[123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234, 212345, 321234, 432123, 543212, 654321, 765432]), 501077.35714285716)\n assert answers_match(candidate(salary=[1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]), 1005.5)\n assert answers_match(candidate(salary=[50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000]), 72500.0)\n assert answers_match(candidate(salary=[3500, 4500, 5500, 6500, 7500, 8500, 9500, 10500, 11500, 12500, 13500]), 8500.0)\n assert answers_match(candidate(salary=[9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007]), 10003.0)\n assert answers_match(candidate(salary=[1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000]), 7000.0)\n assert answers_match(candidate(salary=[15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]), 8000.0)\n assert answers_match(candidate(salary=[10500, 20500, 30500, 40500, 50500, 60500, 70500, 80500, 90500, 100500]), 55500.0)\n assert answers_match(candidate(salary=[555555, 444444, 333333, 222222, 111111, 999999, 888888, 777777, 666666, 123456, 789012, 345678, 901234, 567890, 234567, 890123, 456789, 678901, 101234, 987654]), 554183.3333333334)\n assert answers_match(candidate(salary=[500000, 490000, 480000, 470000, 460000, 450000, 440000, 430000, 420000, 410000, 400000]), 450000.0)\n assert answers_match(candidate(salary=[5000, 3000, 4000, 6000, 7000, 8000, 9000, 10000, 11000]), 7000.0)\n assert answers_match(candidate(salary=[8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 72000, 80000, 88000, 96000, 104000, 112000, 120000, 128000]), 68000.0)\n assert answers_match(candidate(salary=[123456, 654321, 111111, 999999, 555555, 333333, 777777, 888888, 222222, 444444, 666666, 100000, 900000]), 516161.1818181818)\n assert answers_match(candidate(salary=[5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000]), 52500.0)\n assert answers_match(candidate(salary=[250000, 225000, 200000, 175000, 150000, 125000, 100000, 75000, 50000, 25000]), 137500.0)\n assert answers_match(candidate(salary=[150000, 250000, 140000, 160000, 130000, 170000, 120000, 180000, 110000, 190000, 100000, 200000, 210000]), 160000.0)\n assert answers_match(candidate(salary=[150000, 150001, 150002, 150003, 150004, 150005, 150006, 150007, 150008, 150009, 150010, 150011, 150012]), 150006.0)\n assert answers_match(candidate(salary=[123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234]), 510802.0)\n assert answers_match(candidate(salary=[1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013]), 1007.0)\n assert answers_match(candidate(salary=[1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]), 999995.5)\n assert answers_match(candidate(salary=[999999, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100001, 100000]), 450000.125)\n assert answers_match(candidate(salary=[100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010]), 100005.5)\n assert answers_match(candidate(salary=[1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4000]), 2500.0)\n assert answers_match(candidate(salary=[30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]), 90000.0)\n assert answers_match(candidate(salary=[50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000]), 120000.0)\n assert answers_match(candidate(salary=[1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1012, 2123, 3234, 4345, 5456, 6567, 7678, 8789, 9890, 8989, 7989]), 5835.666666666667)\n assert answers_match(candidate(salary=[500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015, 500016, 500017, 500018, 500019, 500020, 500021, 500022, 500023, 500024, 500025]), 500013.0)\n assert answers_match(candidate(salary=[250000, 260000, 270000, 280000, 290000, 300000, 310000, 320000, 330000, 340000, 350000, 360000, 370000, 380000, 390000]), 320000.0)\n assert answers_match(candidate(salary=[100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010]), 100005.0)\n assert answers_match(candidate(salary=[100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]), 500000.0)\n assert answers_match(candidate(salary=[100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010, 100011, 100012, 100013, 100014, 100015]), 100008.0)\n assert answers_match(candidate(salary=[500000, 400000, 300000, 200000, 100000, 150000, 250000, 350000, 450000, 550000]), 325000.0)\n assert answers_match(candidate(salary=[123456, 789012, 345678, 901234, 567890, 234567, 890123]), 565454.0)\n assert answers_match(candidate(salary=[5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011]), 5005.5)\n assert answers_match(candidate(salary=[1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]), 1008.0)\n assert answers_match(candidate(salary=[1000, 999999, 500000, 250000, 750000, 375000, 625000]), 500000.0)\n assert answers_match(candidate(salary=[1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011]), 1006.0)\n assert answers_match(candidate(salary=[100000, 200000, 150000, 180000, 170000, 160000, 130000, 120000, 110000]), 145714.2857142857)\n assert answers_match(candidate(salary=[987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987, 9876, 8765]), 245198.38888888888)\n assert answers_match(candidate(salary=[999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]), 999995.0)\n assert answers_match(candidate(salary=[500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015]), 500007.5)\n assert answers_match(candidate(salary=[987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432, 54321, 43210, 32109]), 309964.35714285716)\n assert answers_match(candidate(salary=[987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432]), 379685.2727272727)\n assert answers_match(candidate(salary=[1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]), 5500.0)\n assert answers_match(candidate(salary=[200000, 150000, 180000, 170000, 190000, 160000, 210000, 220000, 230000, 240000]), 195000.0)\n assert answers_match(candidate(salary=[23456, 34567, 45678, 56789, 67890, 78901, 89012, 90123, 101234, 111234, 121234, 131234, 141234, 151234]), 89094.16666666667)\n assert answers_match(candidate(salary=[3456, 6543, 1234, 4321, 9876, 6789, 2345, 5432, 8765, 7654, 1111, 2222, 3333]), 4735.818181818182)\n assert answers_match(candidate(salary=[999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984]), 999991.0)\n assert answers_match(candidate(salary=[1000, 2500, 5000, 7500, 10000, 12500, 15000]), 7500.0)\n assert answers_match(candidate(salary=[120000, 95000, 110000, 90000, 105000, 85000, 100000, 80000, 115000]), 100000.0)\n assert answers_match(candidate(salary=[95000, 96000, 97000, 98000, 99000, 100000, 101000, 102000, 103000, 104000, 105000, 106000, 107000, 108000, 109000]), 102000.0)\n assert answers_match(candidate(salary=[12000, 15000, 13000, 10000, 9000, 11000, 14000]), 12000.0)\n assert answers_match(candidate(salary=[80000, 75000, 100000, 65000, 90000, 55000, 60000, 70000]), 73333.33333333333)\n", "comparison": "float"}, "public_tests": ["[4000,3000,1000,2000]", "[1000,2000,3000]"], "hints": ["Get the total sum and subtract the minimum and maximum value in the array. Finally divide the result by n - 2."], "metadata": {"canonical_parameter_names": ["salary"], "leetcode_dataset_entry_point": "Solution().average", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:43+00:00", "tests_total": 99, "tests_dropped": 20, "flags": ["decimal_answer"], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def average(self, salary: list[int]) -> float:", "container": "Solution", "callable": "average", "parameters": [{"name": "salary", "type": "list[int]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1492, "task_id": "the-kth-factor-of-n", "difficulty": "Medium", "problem_description": "You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.\n\nConsider a list of all factors of n sorted in ascending order, return the k^th factor in this list or return -1 if n has less than k factors.\n\nExample 1:\n\nInput: n = 12, k = 3\nOutput: 3\nExplanation: Factors list is [1, 2, 3, 4, 6, 12], the 3^rd factor is 3.\n\nExample 2:\n\nInput: n = 7, k = 2\nOutput: 7\nExplanation: Factors list is [1, 7], the 2^nd factor is 7.\n\nExample 3:\n\nInput: n = 4, k = 4\nOutput: -1\nExplanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1.\n\nConstraints:\n\n- 1 <= k <= n <= 1000\n\nFollow up:\n\nCould you solve this problem in less than O(n) complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 49,k = 3) == 49\n assert candidate(n = 100,k = 5) == 10\n assert candidate(n = 7,k = 2) == 7\n assert candidate(n = 17,k = 2) == 17\n assert candidate(n = 1000,k = 15) == 500\n assert candidate(n = 30,k = 5) == 6\n assert candidate(n = 12,k = 3) == 3\n assert candidate(n = 30,k = 1) == 1\n assert candidate(n = 100,k = 10) == -1\n assert candidate(n = 36,k = 6) == 9\n assert candidate(n = 1000,k = 10) == 50\n assert candidate(n = 84,k = 5) == 6\n assert candidate(n = 500,k = 7) == 25\n assert candidate(n = 999,k = 9) == -1\n assert candidate(n = 97,k = 2) == 97\n assert candidate(n = 17,k = 1) == 1\n assert candidate(n = 4,k = 4) == -1\n assert candidate(n = 50,k = 5) == 25\n assert candidate(n = 37,k = 1) == 1\n assert candidate(n = 60,k = 8) == 12\n assert candidate(n = 81,k = 4) == 27\n assert candidate(n = 60,k = 6) == 6\n assert candidate(n = 100,k = 11) == -1\n assert candidate(n = 120,k = 12) == 24\n assert candidate(n = 144,k = 9) == 16\n assert candidate(n = 841,k = 3) == 841\n assert candidate(n = 49,k = 2) == 7\n assert candidate(n = 36,k = 8) == 18\n assert candidate(n = 121,k = 3) == 121\n assert candidate(n = 100,k = 7) == 25\n assert candidate(n = 256,k = 7) == 64\n assert candidate(n = 360,k = 15) == 30\n assert candidate(n = 999,k = 20) == -1\n assert candidate(n = 64,k = 7) == 64\n assert candidate(n = 504,k = 8) == 9\n assert candidate(n = 625,k = 5) == 625\n assert candidate(n = 15,k = 3) == 5\n assert candidate(n = 120,k = 7) == 8\n assert candidate(n = 997,k = 2) == 997\n assert candidate(n = 256,k = 8) == 128\n assert candidate(n = 999,k = 15) == -1\n assert candidate(n = 500,k = 15) == -1\n assert candidate(n = 810,k = 16) == 135\n assert candidate(n = 841,k = 7) == -1\n assert candidate(n = 45,k = 5) == 15\n assert candidate(n = 441,k = 4) == 9\n assert candidate(n = 200,k = 1) == 1\n assert candidate(n = 999,k = 3) == 9\n assert candidate(n = 25,k = 3) == 25\n assert candidate(n = 1000,k = 18) == -1\n assert candidate(n = 1000,k = 16) == 1000\n assert candidate(n = 450,k = 15) == 90\n assert candidate(n = 600,k = 15) == 40\n assert candidate(n = 6,k = 4) == 6\n assert candidate(n = 225,k = 8) == 75\n assert candidate(n = 500,k = 8) == 50\n assert candidate(n = 9,k = 3) == 9\n assert candidate(n = 729,k = 6) == 243\n assert candidate(n = 504,k = 10) == 14\n assert candidate(n = 500,k = 12) == 500\n assert candidate(n = 96,k = 10) == 32\n assert candidate(n = 999,k = 5) == 37\n assert candidate(n = 343,k = 3) == 49\n assert candidate(n = 72,k = 9) == 18\n assert candidate(n = 450,k = 20) == -1\n assert candidate(n = 1000,k = 1) == 1\n assert candidate(n = 36,k = 11) == -1\n assert candidate(n = 441,k = 5) == 21\n assert candidate(n = 729,k = 12) == -1\n assert candidate(n = 999,k = 10) == -1\n assert candidate(n = 36,k = 7) == 12\n assert candidate(n = 50,k = 3) == 5\n assert candidate(n = 225,k = 5) == 15\n assert candidate(n = 200,k = 20) == -1\n assert candidate(n = 100,k = 9) == 100\n assert candidate(n = 16,k = 5) == 16\n assert candidate(n = 625,k = 6) == -1\n assert candidate(n = 840,k = 10) == 12\n", "comparison": "exact"}, "public_tests": ["12\n3", "7\n2", "4\n4"], "hints": ["The factors of n will be always in the range [1, n].", "Keep a list of all factors sorted. Loop i from 1 to n and add i if n % i == 0. Return the kth factor if it exist in this list."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().kthFactor", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:45+00:00", "tests_total": 81, "tests_dropped": 2, "flags": [], "topic_tags": ["math", "number-theory", "prime-factorization"]}, "language": "python", "interface": {"raw_signature": "def kthFactor(self, n: int, k: int) -> int:", "container": "Solution", "callable": "kthFactor", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1493, "task_id": "longest-subarray-of-1s-after-deleting-one-element", "difficulty": "Medium", "problem_description": "Given a binary array nums, you should delete one element from it.\n\nReturn the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray.\n\nExample 1:\n\nInput: nums = [1,1,0,1]\nOutput: 3\nExplanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.\n\nExample 2:\n\nInput: nums = [0,1,1,1,0,1,1,0,1]\nOutput: 5\nExplanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].\n\nExample 3:\n\nInput: nums = [1,1,1]\nOutput: 2\nExplanation: You must delete one element.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- nums[i] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 1, 0]) == 5\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 1, 1]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1]) == 6\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]) == 7\n assert candidate(nums = [1, 1, 0, 1]) == 3\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 0, 1]) == 5\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 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 = [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, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 24\n assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1]) == 9\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 = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]) == 2\n assert candidate(nums = [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]) == 2\n assert candidate(nums = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 38\n assert candidate(nums = [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]) == 24\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\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]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\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, 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]) == 23\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [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, 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, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 10\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 9\n assert candidate(nums = [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]) == 33\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\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, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 3\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 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, 0, 0]) == 20\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]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 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]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 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, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1]) == 6\n assert candidate(nums = [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, 0]) == 24\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]) == 6\n assert candidate(nums = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 19\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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 31\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1]) == 8\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\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]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 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]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1]) == 9\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]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 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]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 1\n assert candidate(nums = [1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [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]) == 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]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 43\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]) == 2\n", "comparison": "exact"}, "public_tests": ["[1,1,0,1]", "[0,1,1,1,0,1,1,0,1]", "[1,1,1]"], "hints": ["Maintain a sliding window where there is at most one zero in it."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:47+00:00", "tests_total": 92, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "sliding-window"]}, "language": "python", "interface": {"raw_signature": "def longestSubarray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1494, "task_id": "parallel-courses-ii", "difficulty": "Hard", "problem_description": "You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCourse_i, nextCourse_i], representing a prerequisite relationship between course prevCourse_i and course nextCourse_i: course prevCourse_i has to be taken before course nextCourse_i. Also, you are given the integer k.\n\nIn one semester, you can take at most k courses as long as you have taken all the prerequisites in the previous semesters for the courses you are taking.\n\nReturn the minimum number of semesters needed to take all courses. The testcases will be generated such that it is possible to take every course.\n\nExample 1:\n\nInput: n = 4, relations = [[2,1],[3,1],[1,4]], k = 2\nOutput: 3\nExplanation: The figure above represents the given graph.\nIn the first semester, you can take courses 2 and 3.\nIn the second semester, you can take course 1.\nIn the third semester, you can take course 4.\n\nExample 2:\n\nInput: n = 5, relations = [[2,1],[3,1],[4,1],[1,5]], k = 2\nOutput: 4\nExplanation: The figure above represents the given graph.\nIn the first semester, you can only take courses 2 and 3 since you cannot take more than two per semester.\nIn the second semester, you can take course 4.\nIn the third semester, you can take course 1.\nIn the fourth semester, you can take course 5.\n\nConstraints:\n\n- 1 <= n <= 15\n- 1 <= k <= n\n- 0 <= relations.length <= n * (n-1) / 2\n- relations[i].length == 2\n- 1 <= prevCourse_i, nextCourse_i <= n\n- prevCourse_i != nextCourse_i\n- All the pairs [prevCourse_i, nextCourse_i] are unique.\n- The given graph is a directed acyclic graph.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,relations = [[2, 1], [3, 1], [1, 4]],k = 2) == 3\n assert candidate(n = 5,relations = [],k = 3) == 2\n assert candidate(n = 5,relations = [[2, 1], [3, 1], [4, 1], [1, 5]],k = 2) == 4\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],k = 2) == 2\n assert candidate(n = 3,relations = [],k = 3) == 1\n assert candidate(n = 4,relations = [[2, 1], [3, 1]],k = 1) == 4\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [4, 5], [5, 6]],k = 2) == 3\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [7, 15]],k = 4) == 5\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [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 = 3) == 15\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [9, 11], [10, 12], [11, 12], [12, 13], [12, 14], [13, 15], [14, 15]],k = 3) == 10\n assert candidate(n = 3,relations = [],k = 2) == 2\n assert candidate(n = 15,relations = [[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 = 4) == 5\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 3], [1, 5], [1, 7], [1, 9]],k = 4) == 10\n assert candidate(n = 7,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 4], [2, 5], [3, 6]],k = 2) == 7\n assert candidate(n = 14,relations = [[1, 2], [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 = 2) == 14\n assert candidate(n = 15,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [1, 6], [2, 6], [3, 6], [4, 6], [1, 7], [2, 7], [3, 7], [4, 7]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8]],k = 2) == 5\n assert candidate(n = 8,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 3) == 8\n assert candidate(n = 15,relations = [[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], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 5) == 5\n assert candidate(n = 7,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],k = 2) == 7\n assert candidate(n = 10,relations = [[1, 5], [1, 6], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10]],k = 3) == 4\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],k = 2) == 7\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 4) == 12\n assert candidate(n = 12,relations = [[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, 12], [10, 12]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],k = 4) == 4\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],k = 4) == 5\n assert candidate(n = 13,relations = [[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]],k = 5) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],k = 2) == 6\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 14], [12, 14], [13, 14]],k = 5) == 6\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [7, 9]],k = 2) == 6\n assert candidate(n = 10,relations = [[1, 5], [1, 6], [2, 6], [2, 7], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]],k = 3) == 4\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10], [7, 11], [7, 12], [8, 13], [8, 14], [9, 13], [10, 14]],k = 4) == 6\n assert candidate(n = 15,relations = [[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], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 2) == 9\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 12], [8, 13], [9, 12], [9, 13], [10, 13], [11, 13]],k = 4) == 5\n assert candidate(n = 9,relations = [[1, 3], [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 7], [5, 8], [6, 9], [7, 9], [8, 9]],k = 3) == 4\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10]],k = 4) == 4\n assert candidate(n = 12,relations = [[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, 12], [10, 12]],k = 4) == 5\n assert candidate(n = 14,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 10], [9, 10], [10, 11], [11, 12], [11, 13], [11, 14]],k = 4) == 6\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 13], [11, 13]],k = 4) == 5\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 14]],k = 3) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 12]],k = 2) == 7\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [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 = 2) == 14\n assert candidate(n = 10,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10]],k = 2) == 5\n assert candidate(n = 14,relations = [[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]],k = 3) == 6\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [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 = 5) == 15\n assert candidate(n = 12,relations = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 12], [11, 12]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],k = 4) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 6], [4, 7], [5, 8], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 13,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],k = 4) == 13\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 3) == 12\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 2) == 8\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 1) == 10\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],k = 2) == 5\n assert candidate(n = 15,relations = [[1, 6], [1, 7], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]],k = 5) == 4\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [7, 10], [8, 11], [9, 11]],k = 3) == 5\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],k = 2) == 5\n assert candidate(n = 15,relations = [[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], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 4) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 3) == 11\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],k = 3) == 6\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]],k = 2) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],k = 3) == 6\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 3) == 10\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 10], [9, 10]],k = 3) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12]],k = 2) == 7\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6], [7, 8], [8, 9], [7, 9], [2, 4], [3, 5]],k = 3) == 5\n assert candidate(n = 15,relations = [[1, 3], [2, 3], [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 = 5) == 14\n assert candidate(n = 14,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],k = 3) == 11\n assert candidate(n = 10,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10]],k = 3) == 7\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [8, 10], [9, 11]],k = 3) == 6\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [9, 11], [10, 12], [11, 12]],k = 3) == 8\n assert candidate(n = 14,relations = [[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]],k = 3) == 6\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],k = 1) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10], [7, 10], [8, 10]],k = 2) == 6\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [8, 10]],k = 3) == 7\n assert candidate(n = 15,relations = [[1, 2], [1, 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, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]],k = 5) == 5\n assert candidate(n = 15,relations = [[1, 4], [1, 5], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11], [10, 12], [11, 13], [12, 13], [13, 14], [13, 15], [14, 15]],k = 4) == 8\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],k = 2) == 5\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 11], [9, 10]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 10], [7, 10]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 6], [2, 7], [3, 8], [4, 9]],k = 4) == 10\n assert candidate(n = 15,relations = [[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 = 3) == 6\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],k = 2) == 6\n assert candidate(n = 11,relations = [[1, 3], [1, 4], [2, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [2, 6], [3, 7]],k = 2) == 6\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13]],k = 2) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],k = 1) == 10\n assert candidate(n = 15,relations = [[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]],k = 5) == 4\n", "comparison": "exact"}, "public_tests": ["4\n[[2,1],[3,1],[1,4]]\n2", "5\n[[2,1],[3,1],[4,1],[1,5]]\n2"], "hints": ["Use backtracking with states (bitmask, degrees) where bitmask represents the set of courses, if the ith bit is 1 then the ith course was taken, otherwise, you can take the ith course. Degrees represent the degree for each course (nodes in the graph).", "Note that you can only take nodes (courses) with degree = 0 and it is optimal at every step in the backtracking take the maximum number of courses limited by k."], "metadata": {"canonical_parameter_names": ["n", "relations", "k"], "leetcode_dataset_entry_point": "Solution().minNumberOfSemesters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:50+00:00", "tests_total": 92, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming", "bit-manipulation", "graph", "bitmask", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def minNumberOfSemesters(self, n: int, relations: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "minNumberOfSemesters", "parameters": [{"name": "n", "type": "int"}, {"name": "relations", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1496, "task_id": "path-crossing", "difficulty": "Easy", "problem_description": "Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.\n\nReturn true if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false otherwise.\n\nExample 1:\n\nInput: path = \"NES\"\nOutput: false\nExplanation: Notice that the path doesn't cross any point more than once.\n\nExample 2:\n\nInput: path = \"NESWW\"\nOutput: true\nExplanation: Notice that the path visits the origin twice.\n\nConstraints:\n\n- 1 <= path.length <= 10^4\n- path[i] is either 'N', 'S', 'E', or 'W'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(path = \"NEESWNWWSNNWNSSSWEWEWEWE\") == True\n assert candidate(path = \"NNNSSSSSSEEEEEEEWWWWWWWWW\") == True\n assert candidate(path = \"NEWSNEWS\") == True\n assert candidate(path = \"EWEWEWEW\") == True\n assert candidate(path = \"NESWW\") == True\n assert candidate(path = \"NSSS\") == True\n assert candidate(path = \"N\") == False\n assert candidate(path = \"NNSSEEEWWS\") == True\n assert candidate(path = \"NSSSWEWNNEE\") == True\n assert candidate(path = \"NSNSNSNS\") == True\n assert candidate(path = \"NNNSSSSS\") == True\n assert candidate(path = \"NESWNE\") == True\n assert candidate(path = \"NNESSEWSWNWNWSSSNW\") == True\n assert candidate(path = \"NS\") == True\n assert candidate(path = \"NNESSWW\") == True\n assert candidate(path = \"NENESSWW\") == True\n assert candidate(path = \"EWE\") == True\n assert candidate(path = \"NES\") == False\n assert candidate(path = \"NEWS\") == True\n assert candidate(path = \"NNNNSSSSWWWWEEEE\") == True\n assert candidate(path = \"WEWEWEWE\") == True\n assert candidate(path = \"NWSWEWNWNW\") == True\n assert candidate(path = \"NNEESSWW\") == True\n assert candidate(path = \"NNEEESSWWNNNEEESSWWNNNESSWWN\") == True\n assert candidate(path = \"EEEE\") == False\n assert candidate(path = \"EESSEENN\") == False\n assert candidate(path = \"WEWN\") == True\n assert candidate(path = \"EENW\") == False\n assert candidate(path = \"NEEEEWWWWSSSSNNN\") == True\n assert candidate(path = \"ENWSWNESWSWNESWS\") == True\n assert candidate(path = \"NENWSEWSWESWESWESW\") == True\n assert candidate(path = \"NNEWSSEESSEENNNWNNNW\") == True\n assert candidate(path = \"NNNSSSWEWEWESWNWNWNWWSWSWENENE\") == True\n assert candidate(path = \"ENWNENWENW\") == True\n assert candidate(path = \"NWSNWSNWSNWSNWS\") == True\n assert candidate(path = \"EEEEEWWWWWSSSSSNNNNN\") == True\n assert candidate(path = \"NWNWNWNWNWSWSWSWSW\") == False\n assert candidate(path = \"NESWWNESWWNESWW\") == True\n assert candidate(path = \"EESWWNNESWNESESW\") == True\n assert candidate(path = \"WENWENWENW\") == True\n assert candidate(path = \"NSEENWNNWSSSWEE\") == True\n assert candidate(path = \"NNSSEEEWWW\") == True\n assert candidate(path = \"NEWSNEWSNEWSNEWSNEWS\") == True\n assert candidate(path = \"SSNNEEWW\") == True\n assert candidate(path = \"NNWNWSSSWNEEEEEN\") == True\n assert candidate(path = \"NNESWSWNWNWS\") == True\n assert candidate(path = \"NNNNSSSSWWWW\") == True\n assert candidate(path = \"EENWNWSS\") == True\n assert candidate(path = \"NNNNEEESSEWWNNNNEE\") == True\n assert candidate(path = \"NESEWNESEWNESEW\") == True\n assert candidate(path = \"EENNWWSSNNSSEE\") == True\n assert candidate(path = \"SSSSNNNNEEEEWWWW\") == True\n assert candidate(path = \"EEEEEEEEEEEEEEEWWWWWWWWWWWWWWWSSSSSSSSSSSSSSSNNNNNNNNNNNNNNN\") == True\n assert candidate(path = \"NNNSSSNNNSSS\") == True\n assert candidate(path = \"NEWSNEWSNEWS\") == True\n assert candidate(path = \"ENSNWNWNWN\") == True\n assert candidate(path = \"ESSNNWWSSEN\") == True\n assert candidate(path = \"SWENSWENSWENSWEN\") == True\n assert candidate(path = \"WESSNNESWWSE\") == True\n assert candidate(path = \"NENWSWSENENW\") == True\n assert candidate(path = \"WSEWSEWSEWSEW\") == True\n assert candidate(path = \"NNNSSSSSSEEWWWW\") == True\n assert candidate(path = \"WENSNWSWES\") == True\n assert candidate(path = \"NWWWSSENNE\") == True\n assert candidate(path = \"NEESWNESWSWN\") == True\n assert candidate(path = \"WEWNSWESWESWESW\") == True\n assert candidate(path = \"NNWESWSWSEENW\") == True\n assert candidate(path = \"WNWSSNSSWEEENEEN\") == True\n assert candidate(path = \"EWEWEWEWEEWWEWEEWWSWWSW\") == True\n assert candidate(path = \"NSSSSEEEEWWWNNSNWEEE\") == True\n assert candidate(path = \"SSENNWESSW\") == True\n assert candidate(path = \"NEEEEESWWWWNSSSSS\") == True\n assert candidate(path = \"NESWNEESWW\") == True\n assert candidate(path = \"NENWSEWSWENWSEWSW\") == True\n assert candidate(path = \"NNNNNNNNSSSSSSSSWWWWWWWWEEEEEEEE\") == True\n assert candidate(path = \"ENENEWNWNWSWSW\") == True\n assert candidate(path = \"NENENENENESESESESESWSWSWSWSW\") == False\n assert candidate(path = \"ENEWWNNEWSWE\") == True\n assert candidate(path = \"NNNNNNNNNN\") == False\n assert candidate(path = \"ENWESWNESEENWSWEN\") == True\n assert candidate(path = \"NESESWWSSWNE\") == True\n assert candidate(path = \"NENENENENEWWWWWW\") == True\n assert candidate(path = \"NNNEEEESSSNNNWWSW\") == True\n assert candidate(path = \"NENENENENNENESESWSWWSW\") == True\n assert candidate(path = \"ENSWNESWNESEWS\") == True\n assert candidate(path = \"ENWSESWNESWENSWE\") == True\n assert candidate(path = \"ENEENWNNWSSSSNE\") == True\n assert candidate(path = \"EEESSSNNNW\") == True\n assert candidate(path = \"NNNSSSSSSEEEWWWW\") == True\n assert candidate(path = \"EESNNWWSSEEN\") == True\n assert candidate(path = \"NNNEEESSEESWWNN\") == True\n assert candidate(path = \"EENWNNWSSNNWEE\") == True\n assert candidate(path = \"NEWWNWSSWSEWSSN\") == True\n assert candidate(path = \"NESESWNESESWNESESW\") == True\n assert candidate(path = \"NENWSWNWNWSWNWNW\") == True\n assert candidate(path = \"NENWSESWNESWNES\") == True\n assert candidate(path = \"NENENNENNE\") == False\n assert candidate(path = \"NEWSNEWSNEWSNEWS\") == True\n assert candidate(path = \"NSEWSSEEEWWWNNEENW\") == True\n assert candidate(path = \"NNWESSSWNE\") == True\n assert candidate(path = \"ESSSWWNNEEEWWNNSSEEE\") == True\n assert candidate(path = \"NESWNESWNESW\") == True\n assert candidate(path = \"NESESWWSWN\") == False\n assert candidate(path = \"NESWNESESWNESESW\") == True\n assert candidate(path = \"NENWSEWSWNNWSEWSW\") == True\n assert candidate(path = \"ENWNNWSSNWNWEE\") == True\n assert candidate(path = \"NNWSENNWWSSSEEE\") == True\n assert candidate(path = \"WNWSSNSSWEEENEENE\") == True\n assert candidate(path = \"NSEWNSSEWW\") == True\n assert candidate(path = \"ENWSENWSENWSENWS\") == True\n assert candidate(path = \"SSSSWWWWNNEE\") == False\n assert candidate(path = \"NSSSWWNEEENNEESSE\") == True\n assert candidate(path = \"ENWSWWSESNWEN\") == True\n assert candidate(path = \"NSSSNWWNEEEE\") == True\n assert candidate(path = \"NNSESSWWNE\") == True\n assert candidate(path = \"NESWENSWEWNENSWSEWNESW\") == True\n assert candidate(path = \"WESSNNWESSNNWESSNN\") == True\n assert candidate(path = \"SSWWSSENNE\") == True\n assert candidate(path = \"ESWENSWENSWENSWENSWEN\") == True\n assert candidate(path = \"NESWNSWENSWE\") == True\n assert candidate(path = \"NESWWSEN\") == True\n assert candidate(path = \"EWEWNEWEWN\") == True\n assert candidate(path = \"EENNWWNSSSNEEE\") == True\n assert candidate(path = \"EESWWNNEWSNEWSNEWS\") == True\n assert candidate(path = \"WEWNENEWNWNWSWSNEN\") == True\n assert candidate(path = \"NESWNSWENWEWSWEWNSWEWENWSWEN\") == True\n assert candidate(path = \"NENWSEWNENWSEWNENWSEW\") == True\n assert candidate(path = \"WNESSWNESSWNE\") == True\n assert candidate(path = \"WENWNNWENWSE\") == True\n assert candidate(path = \"NSEWNNNSSSWEWEWEWWE\") == True\n assert candidate(path = \"NENWNWNWSENW\") == True\n assert candidate(path = \"WNEEESSNWWWEN\") == True\n assert candidate(path = \"EEENNWWWWNEESSS\") == True\n assert candidate(path = \"SSSSNNNNWWEEEE\") == True\n assert candidate(path = \"EEENNNEEWWSSSWWN\") == True\n assert candidate(path = \"EEEEEEEWWWWWWSSSSSSNNNNNN\") == True\n assert candidate(path = \"EEEEEENNNNNNSSSSSWEWE\") == True\n assert candidate(path = \"NSSSSWWWWEEEEEENNN\") == True\n assert candidate(path = \"SSSSEEEEWWWWNNNN\") == True\n assert candidate(path = \"SSSSSSSSSS\") == False\n assert candidate(path = \"NSSSWWEENNSSSWWEEN\") == True\n assert candidate(path = \"EENNWWSSNWNWEEWN\") == True\n assert candidate(path = \"NENENENE\") == False\n assert candidate(path = \"NENESWNESE\") == True\n assert candidate(path = \"ENWSWEWNWSWEWNWS\") == True\n assert candidate(path = \"NENWSEWSWNESWESW\") == True\n assert candidate(path = \"WWEENNWEES\") == True\n assert candidate(path = \"EWEWNEWNWSWE\") == True\n assert candidate(path = \"NNNSSSSSSSWWWWWWWWWEEEEE\") == True\n assert candidate(path = \"NWSWNWSWNW\") == False\n assert candidate(path = \"NNSSWWEENN\") == True\n assert candidate(path = \"NSEENWNNWSSSWEEE\") == True\n assert candidate(path = \"NENWSNWSNESW\") == True\n assert candidate(path = \"NNSWESWESWESWESW\") == True\n assert candidate(path = \"NESNESNESNESNES\") == True\n assert candidate(path = \"NESWNNNWWWEES\") == True\n assert candidate(path = \"SSNNSSNNSS\") == True\n assert candidate(path = \"NEWSWNNWSSNWNWEE\") == True\n assert candidate(path = \"NNWNWSSSWNEEE\") == True\n assert candidate(path = \"NENWNSNS\") == True\n assert candidate(path = \"EWSWNWESWE\") == True\n assert candidate(path = \"NNEEWWSS\") == True\n assert candidate(path = \"SEENENENEWSWSWNENE\") == True\n assert candidate(path = \"WNWSSNSSSENEEN\") == True\n assert candidate(path = \"NESESWSEWN\") == True\n assert candidate(path = \"NNEWSWSEWSSNENW\") == True\n assert candidate(path = \"EWEWEWEWEW\") == True\n assert candidate(path = \"SSEWEEWEEE\") == True\n assert candidate(path = \"NSSSSEEEEEWWWWNNNN\") == True\n assert candidate(path = \"NNNWWWSSSE\") == False\n assert candidate(path = \"NSSSNEEEWNWSS\") == True\n assert candidate(path = \"NESWNESW\") == True\n assert candidate(path = \"ESESWNEWSWSWNENESE\") == True\n assert candidate(path = \"NNNWWSSSNE\") == True\n assert candidate(path = \"NEWSWNESWESWNES\") == True\n assert candidate(path = \"NNESSEWW\") == True\n assert candidate(path = \"WEEWEEWEEE\") == True\n assert candidate(path = \"NENENWENWENWENWENW\") == True\n assert candidate(path = \"NNSSEEEWWWS\") == True\n assert candidate(path = \"SWSWSWSWNENENENENE\") == True\n assert candidate(path = \"SSSEEESSSWWNNN\") == True\n assert candidate(path = \"NNSSNNSS\") == True\n assert candidate(path = \"NNSEESSWNW\") == True\n assert candidate(path = \"NNNSSSWEWEWESWNWNWNWWSWSWENENESESESESNESWENSWEWNENSWSEWNESW\") == True\n", "comparison": "exact"}, "public_tests": ["\"NES\"", "\"NESWW\""], "hints": ["Simulate the process while keeping track of visited points.", "Use a set to store previously visited points."], "metadata": {"canonical_parameter_names": ["path"], "leetcode_dataset_entry_point": "Solution().isPathCrossing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:52+00:00", "tests_total": 186, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def isPathCrossing(self, path: str) -> bool:", "container": "Solution", "callable": "isPathCrossing", "parameters": [{"name": "path", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1497, "task_id": "check-if-array-pairs-are-divisible-by-k", "difficulty": "Medium", "problem_description": "Given an array of integers arr of even length n and an integer k.\n\nWe want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.\n\nReturn true If you can find a way to do that or false otherwise.\n\nExample 1:\n\nInput: arr = [1,2,3,4,5,10,6,7,8,9], k = 5\nOutput: true\nExplanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).\n\nExample 2:\n\nInput: arr = [1,2,3,4,5,6], k = 7\nOutput: true\nExplanation: Pairs are (1,6),(2,5) and(3,4).\n\nExample 3:\n\nInput: arr = [1,2,3,4,5,6], k = 10\nOutput: false\nExplanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.\n\nConstraints:\n\n- arr.length == n\n- 1 <= n <= 10^5\n- n is even.\n- -10^9 <= arr[i] <= 10^9\n- 1 <= k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == True\n assert candidate(arr = [0, 0, 0, 0],k = 1) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 10) == False\n assert candidate(arr = [-1, 1, -2, 2, -3, 3],k = 2) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3],k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 7) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9],k = 5) == True\n assert candidate(arr = [0, 0, 0, 0],k = 3) == True\n assert candidate(arr = [0, 0, 0, 0],k = 2) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 6) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 8) == True\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, 59],k = 10) == True\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 = 7) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == False\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],k = 20) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == True\n assert candidate(arr = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230],k = 123) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == True\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 = 25) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 10) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 3) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\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 = 17) == False\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 = 13) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 10) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 7) == True\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, 16, 16],k = 6) == False\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],k = 50) == True\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 = 7) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, 6, 6],k = 5) == False\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 15) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == False\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == True\n assert candidate(arr = [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 = 15) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == True\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 = 20) == True\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 = 13) == False\n assert candidate(arr = [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 = 15) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 100000) == True\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 = 19) == False\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 = 2) == True\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],k = 7) == False\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 = 31) == True\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 20) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == True\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],k = 4) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 2) == True\n assert candidate(arr = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],k = 6) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 2) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 10) == True\n assert candidate(arr = [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 = 25) == False\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 11) == True\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 13) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16],k = 5) == False\n assert candidate(arr = [1, 3, 2, 4, 6, 8, 5, 7, 9, 11],k = 3) == False\n assert candidate(arr = [7, 3, 2, 6, 8, 10, 9, 5, 1, 4],k = 7) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],k = 5) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 5) == False\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12],k = 5) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],k = 20) == True\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 = 9) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 8) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 13) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 5) == False\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == True\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],k = 2) == True\n assert candidate(arr = [-1, -2, -3, -4, 1, 2, 3, 4],k = 3) == True\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 = 15) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 20) == False\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 3) == True\n assert candidate(arr = [-10, 10, 20, -20, 30, -30, 40, -40],k = 10) == True\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 8) == True\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == True\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],k = 19) == False\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],k = 39) == False\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) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,10,6,7,8,9]\n5", "[1,2,3,4,5,6]\n7", "[1,2,3,4,5,6]\n10"], "hints": ["Keep an array of the frequencies of ((x % k) + k) % k for each x in arr.", "for each i in [0, k - 1] we need to check if freq[i] == freq[k - i]", "Take care of the case when i == k - i and when i == 0"], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().canArrange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:54+00:00", "tests_total": 93, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "python", "interface": {"raw_signature": "def canArrange(self, arr: list[int], k: int) -> bool:", "container": "Solution", "callable": "canArrange", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1498, "task_id": "number-of-subsequences-that-satisfy-the-given-sum-condition", "difficulty": "Medium", "problem_description": "You are given an array of integers nums and an integer target.\n\nReturn the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nums = [3,5,6,7], target = 9\nOutput: 4\nExplanation: There are 4 subsequences that satisfy the condition.\n[3] -> Min value + max value <= target (3 + 3 <= 9)\n[3,5] -> (3 + 5 <= 9)\n[3,5,6] -> (3 + 6 <= 9)\n[3,6] -> (3 + 6 <= 9)\n\nExample 2:\n\nInput: nums = [3,3,6,8], target = 10\nOutput: 6\nExplanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).\n[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]\n\nExample 3:\n\nInput: nums = [2,3,3,4,6,7], target = 12\nOutput: 61\nExplanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).\nNumber of valid subsequences (63 - 2 = 61).\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^6\n- 1 <= target <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 10) == 31\n assert candidate(nums = [10, 10, 10, 10],target = 20) == 15\n assert candidate(nums = [1, 3, 5, 7],target = 8) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 341\n assert candidate(nums = [9, 7, 5, 3, 1],target = 10) == 21\n assert candidate(nums = [1, 2, 3],target = 5) == 6\n assert candidate(nums = [5, 2, 4, 1, 7, 6, 8],target = 12) == 117\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1023\n assert candidate(nums = [1],target = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 10) == 31\n assert candidate(nums = [1000000],target = 1000000) == 0\n assert candidate(nums = [3, 3, 6, 8],target = 10) == 6\n assert candidate(nums = [2, 3, 3, 4, 6, 7],target = 12) == 61\n assert candidate(nums = [3, 5, 6, 7],target = 9) == 4\n assert candidate(nums = [5, 2, 4, 1, 7, 6, 8],target = 10) == 101\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == 21\n assert candidate(nums = [1, 2, 4, 8, 16],target = 24) == 30\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == 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],target = 20) == 349525\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1023\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 = 250) == 1026730\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 10) == 341\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 20) == 682\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 = 2) == 1048575\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1023\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 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 = 30) == 357913941\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 1023\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 = 200) == 349525\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],target = 30) == 21845\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],target = 10) == 191690598\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 = 25) == 1026730\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 = 40) == 699050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 10922\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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) == 966320448\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 = 200) == 873813\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == 341\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) == 699050\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1200) == 853\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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 = 100) == 898961330\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 1000000) == 511\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 1002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 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 = 30) == 357913941\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 341\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],target = 1000000) == 1023\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 = 300) == 1047893\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\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) == 1047893\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 = 300) == 1047893\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],target = 2) == 986564552\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 = 150) == 1047893\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12],target = 15) == 986316\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],target = 1000000) == 341\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 20) == 1048575\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 1002\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) == 1048574\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],target = 1000000) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4],target = 6) == 967\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 2500) == 32746\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 = 10) == 209715\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) == 349525\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],target = 200000) == 1023\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 30) == 21845\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],target = 10) == 985115752\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 32085\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],target = 10) == 18641351\n", "comparison": "exact"}, "public_tests": ["[3,5,6,7]\n9", "[3,3,6,8]\n10", "[2,3,3,4,6,7]\n12"], "hints": ["Sort the array nums.", "Use two pointers approach: Given an index i (choose it as the minimum in a subsequence) find the maximum j where j ≥ i and nums[i] +nums[j] ≤ target.", "Count the number of subsequences."], "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().numSubseq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:56+00:00", "tests_total": 81, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def numSubseq(self, nums: list[int], target: int) -> int:", "container": "Solution", "callable": "numSubseq", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1499, "task_id": "max-value-of-equation", "difficulty": "Hard", "problem_description": "You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [x_i, y_i] such that x_i < x_j for all 1 <= i < j <= points.length. You are also given an integer k.\n\nReturn the maximum value of the equation y_i + y_j + |x_i - x_j| where |x_i - x_j| <= k and 1 <= i < j <= points.length.\n\nIt is guaranteed that there exists at least one pair of points that satisfy the constraint |x_i - x_j| <= k.\n\nExample 1:\n\nInput: points = [[1,3],[2,0],[5,10],[6,-10]], k = 1\nOutput: 4\nExplanation: The first two points satisfy the condition |x_i - x_j| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1.\nNo other pairs satisfy the condition, so we return the max of 4 and 1.\n\nExample 2:\n\nInput: points = [[0,0],[3,0],[9,2]], k = 3\nOutput: 3\nExplanation: Only the first two points have an absolute difference of 3 or less in the x-values, and give the value of 0 + 0 + |0 - 3| = 3.\n\nConstraints:\n\n- 2 <= points.length <= 10^5\n- points[i].length == 2\n- -10^8 <= x_i, y_i <= 10^8\n- 0 <= k <= 2 * 10^8\n- x_i < x_j for all 1 <= i < j <= points.length\n- x_i form a strictly increasing sequence.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10]],k = 1) == 4\n assert candidate(points = [[1, 5], [2, 3], [4, 7], [8, 10]],k = 6) == 21\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10], [7, 5]],k = 4) == 17\n assert candidate(points = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],k = 15) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 2) == 8\n assert candidate(points = [[-1, 1], [-2, 2], [-3, 3]],k = 1) == 4\n assert candidate(points = [[-10, 5], [0, 0], [10, 10], [20, -5]],k = 25) == 35\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 10\n assert candidate(points = [[-10, -10], [0, 0], [10, 10]],k = 20) == 20\n assert candidate(points = [[1, 100000000], [100000000, 1]],k = 200000000) == 200000000\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 4) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5]],k = 4) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 2) == 10\n assert candidate(points = [[0, 0], [3, 0], [9, 2]],k = 3) == 3\n assert candidate(points = [[-1, 2], [-3, 3], [1, 3], [2, 4]],k = 4) == 10\n assert candidate(points = [[-1, 20], [-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5], [15, -10]],k = 12) == 30\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995]],k = 4) == 200000000\n assert candidate(points = [[1, 1], [2, 100000000], [3, 1], [4, 100000000], [5, 1]],k = 1) == 100000002\n assert candidate(points = [[1, 1], [3, 4], [5, 7], [8, 10], [12, 13], [15, 14], [18, 15], [20, 16], [25, 17], [30, 18]],k = 15) == 47\n assert candidate(points = [[1, 3], [4, 1], [8, 5], [15, 10], [20, 6], [25, 3]],k = 15) == 27\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 9) == 11\n assert candidate(points = [[1, 3], [4, 5], [7, 8], [10, 12], [13, 15], [16, 18]],k = 5) == 36\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, -1], [8, -2], [9, -3], [10, -4]],k = 4) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],k = 2) == 30\n assert candidate(points = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700]],k = 3) == 1301\n assert candidate(points = [[1, 3], [5, 10], [8, 15], [10, 7], [12, 20], [16, 5], [20, 25]],k = 10) == 53\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10], [11, -11], [12, -12], [13, -13], [14, -14], [15, -15], [16, -16], [17, -17], [18, -18], [19, -19], [20, -20]],k = 5) == -2\n assert candidate(points = [[-1, 1], [0, 0], [1, -1], [2, 2], [3, -3], [4, 4], [5, -5], [6, 6]],k = 2) == 12\n assert candidate(points = [[1, 100], [5, 200], [10, 300], [15, 400], [20, 500], [25, 600], [30, 700]],k = 10) == 1305\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10], [7, 2], [8, -5], [10, 4]],k = 3) == 14\n assert candidate(points = [[1, 1], [2, 3], [4, 2], [5, 3], [6, 5], [8, 6], [9, 7], [10, 8]],k = 5) == 17\n assert candidate(points = [[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(points = [[1, 100000000], [2, -100000000], [3, 100000000], [4, -100000000], [5, 100000000], [6, -100000000], [7, 100000000], [8, -100000000], [9, 100000000], [10, -100000000]],k = 1) == 1\n assert candidate(points = [[1, 1], [3, 5], [5, 3], [7, 9], [9, 4], [11, 10], [13, 6], [15, 8], [17, 2], [19, 12]],k = 4) == 24\n assert candidate(points = [[100000, -100000], [100005, 100000], [100010, -100000], [100015, 100000]],k = 10) == 200010\n assert candidate(points = [[1, 10], [3, 20], [5, 15], [7, 5], [9, 25], [11, 30], [13, 10], [15, 35]],k = 15) == 69\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == 3\n assert candidate(points = [[-5, 10], [-2, 3], [0, 0], [3, -5], [7, 2], [8, -1], [10, 6]],k = 4) == 16\n assert candidate(points = [[1, 1], [3, 4], [6, 7], [8, 10], [11, 13], [15, 16], [18, 19]],k = 7) == 39\n assert candidate(points = [[-5, -5], [-3, -3], [0, 0], [4, 4], [6, 6], [10, 10]],k = 6) == 20\n assert candidate(points = [[-20, 20], [-18, 18], [-16, 16], [-14, 14], [-12, 12], [-10, 10], [-8, 8], [-6, 6], [-4, 4], [-2, 2]],k = 4) == 40\n assert candidate(points = [[-100000000, -100000000], [-90000000, -90000000], [-80000000, -80000000], [-70000000, -70000000], [-60000000, -60000000], [-50000000, -50000000], [-40000000, -40000000], [-30000000, -30000000], [-20000000, -20000000], [-10000000, -10000000]],k = 20000000) == -20000000\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996]],k = 1) == 200000000\n assert candidate(points = [[1, 100000000], [2, 50000000], [5, 10000000], [10, 5000000], [20, 1000000], [50, 500000], [100, 100000]],k = 99) == 150000001\n assert candidate(points = [[-5, -10], [-3, -7], [-1, -2], [1, 3], [4, 9]],k = 4) == 15\n assert candidate(points = [[1, 5], [4, 3], [6, 7], [8, 2], [10, 8]],k = 5) == 19\n assert candidate(points = [[1, 5], [3, 4], [7, 10], [8, 2], [10, 1]],k = 5) == 18\n assert candidate(points = [[1, 2], [4, 5], [6, 7], [8, 9], [10, 12], [12, 15], [14, 17], [16, 19], [18, 21], [20, 23]],k = 10) == 46\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 15) == 29\n assert candidate(points = [[1, 100000000], [-50000000, -100000000], [100000000, -100000000], [-100000000, 100000000]],k = 200000000) == 99999999\n assert candidate(points = [[1, 1], [3, 5], [6, 2], [8, 8], [10, 4], [15, 7], [20, 1]],k = 5) == 18\n assert candidate(points = [[-1000000, -1000000], [-900000, -900000], [-800000, -800000], [-700000, -700000], [-600000, -600000]],k = 100000) == -1200000\n assert candidate(points = [[-5, 5], [0, 0], [1, 3], [3, -1], [5, 10], [6, -10], [8, 2], [10, 3], [15, 0]],k = 5) == 18\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9]],k = 2) == -2\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]],k = 50000000) == 20000000\n assert candidate(points = [[100000, -100000], [100001, -99999], [100002, -99998], [100003, -99997], [100004, -99996]],k = 4) == -199992\n assert candidate(points = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],k = 2) == -2\n assert candidate(points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],k = 3) == 200\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 20\n assert candidate(points = [[1, 5], [3, 7], [6, 8], [8, 6], [10, 9], [15, 1]],k = 5) == 21\n assert candidate(points = [[-50, -50], [-25, -100], [0, 0], [25, 100], [50, 50]],k = 75) == 175\n assert candidate(points = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],k = 3) == 1901\n assert candidate(points = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32]],k = 4) == 49\n assert candidate(points = [[1, 10], [2, 15], [5, 20], [8, 25], [10, 30], [15, 35], [20, 40], [25, 45], [30, 50], [35, 55]],k = 15) == 110\n assert candidate(points = [[-5, -5], [-3, -1], [0, 0], [2, 4], [3, 6], [8, 8]],k = 5) == 19\n assert candidate(points = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]],k = 15) == 29\n assert candidate(points = [[-100000000, 100000000], [-90000000, 90000000], [0, -50000000], [100000000, 50000000]],k = 110000000) == 200000000\n assert candidate(points = [[1, -1], [3, -2], [5, -3], [7, -4], [9, -5], [11, -6], [13, -7], [15, -8], [17, -9], [19, -10]],k = 18) == 7\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 1) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == 20\n assert candidate(points = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15]],k = 3) == 30\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 1) == 18\n assert candidate(points = [[1, -100000000], [2, 100000000], [3, -100000000], [4, 100000000], [5, -100000000], [6, 100000000], [7, -100000000]],k = 2) == 200000002\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],k = 1) == 20\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995], [7, 99999994], [8, 99999993], [9, 99999992], [10, 99999991]],k = 1) == 200000000\n assert candidate(points = [[1, 10], [2, 3], [3, 5], [4, 7], [5, 2], [6, 8]],k = 4) == 20\n assert candidate(points = [[10, 50], [20, 30], [30, 20], [40, 10], [50, 0], [60, -10], [70, -20], [80, -30], [90, -40]],k = 25) == 90\n assert candidate(points = [[1, 100000000], [2, 90000000], [3, 80000000], [4, 70000000], [5, 60000000]],k = 3) == 190000001\n assert candidate(points = [[5, 5], [15, 10], [25, 3], [35, 15], [45, 10], [55, 20], [65, 5], [75, 25]],k = 20) == 65\n assert candidate(points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],k = 30) == 180\n assert candidate(points = [[1, 1], [2, 10], [3, 3], [4, 15], [5, 5], [6, 20], [7, 7], [8, 25], [9, 9], [10, 30]],k = 10) == 57\n assert candidate(points = [[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], [31, 31], [33, 33], [35, 35], [37, 37], [39, 39]],k = 2) == 78\n assert candidate(points = [[-100000000, 100000000], [0, 0], [100000000, -100000000]],k = 200000000) == 200000000\n assert candidate(points = [[-100, 100], [-90, 90], [-80, 80], [-70, 70], [-60, 60], [-50, 50], [-40, 40], [-30, 30], [-20, 20], [-10, 10]],k = 20) == 200\n assert candidate(points = [[-5, -5], [-2, 3], [-1, 2], [0, 0], [1, 5], [2, 1], [4, -2], [6, 3]],k = 4) == 11\n assert candidate(points = [[-10, 0], [-9, 1], [-8, 2], [-7, 3], [-6, 4], [-5, 5], [-4, 6], [-3, 7], [-2, 8], [-1, 9]],k = 3) == 18\n assert candidate(points = [[10, 20], [15, 10], [20, 20], [25, 30], [30, 5], [35, 25], [40, 30]],k = 10) == 65\n assert candidate(points = [[1, 5], [3, 4], [6, 7], [8, 2], [10, 10]],k = 4) == 21\n assert candidate(points = [[-5, 10], [0, -1], [4, 3], [7, -2], [12, 5]],k = 5) == 14\n assert candidate(points = [[-100, 100], [-90, -80], [-80, 80], [-70, -70], [-60, 60], [-50, -50]],k = 20) == 200\n assert candidate(points = [[1, 10], [2, 5], [3, -5], [4, -10], [5, -15], [6, -20], [7, -25], [8, -30]],k = 3) == 16\n assert candidate(points = [[1, 3], [2, 1], [3, 2], [4, 4], [5, 1], [6, 3], [7, 2], [8, 5], [9, 4]],k = 4) == 13\n assert candidate(points = [[-5, -5], [-3, -2], [-1, 0], [2, 3], [5, 5], [8, 8], [11, 11]],k = 7) == 22\n assert candidate(points = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9]],k = 8) == 22\n assert candidate(points = [[1, 2], [3, 5], [5, 7], [7, 10], [9, 15], [11, 20], [13, 25], [15, 30], [17, 35], [19, 40]],k = 10) == 77\n assert candidate(points = [[-50, 10], [-30, 20], [-10, 30], [10, 40], [30, 50], [50, 60], [70, 70], [90, 80], [110, 90]],k = 30) == 190\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 20\n assert candidate(points = [[-100000000, 100000000], [0, -100000000], [100000000, 100000000]],k = 200000000) == 400000000\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 2) == 40\n assert candidate(points = [[-100000000, 100000000], [-99999999, 99999999], [-99999998, 99999998], [-99999997, 99999997], [-99999996, 99999996], [-99999995, 99999995]],k = 4) == 200000000\n assert candidate(points = [[-100000, 100000], [-90000, 50000], [-80000, 0], [-70000, -50000], [-60000, -100000], [-50000, 100000], [-40000, 50000], [-30000, 0], [-20000, -50000], [-10000, -100000], [0, 100000], [10000, 50000], [20000, 0], [30000, -50000], [40000, -100000], [50000, 100000], [60000, 50000], [70000, 0], [80000, -50000], [90000, -100000], [100000, 100000]],k = 20000) == 160000\n assert candidate(points = [[1, 100], [2, 50], [3, 75], [4, 25], [5, 150]],k = 4) == 254\n", "comparison": "exact"}, "public_tests": ["[[1,3],[2,0],[5,10],[6,-10]]\n1", "[[0,0],[3,0],[9,2]]\n3"], "hints": ["Use a priority queue to store for each point i, the tuple [yi-xi, xi]", "Loop through the array and pop elements from the heap if the condition xj - xi > k, where j is the current index and i is the point on top the queue.", "After popping elements from the queue. If the queue is not empty, calculate the equation with the current point and the point on top of the queue and maximize the answer."], "metadata": {"canonical_parameter_names": ["points", "k"], "leetcode_dataset_entry_point": "Solution().findMaxValueOfEquation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:59+00:00", "tests_total": 108, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "queue", "sliding-window", "heap-priority-queue", "monotonic-queue"]}, "language": "python", "interface": {"raw_signature": "def findMaxValueOfEquation(self, points: list[list[int]], k: int) -> int:", "container": "Solution", "callable": "findMaxValueOfEquation", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1502, "task_id": "can-make-arithmetic-progression-from-sequence", "difficulty": "Easy", "problem_description": "A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.\n\nGiven an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.\n\nExample 1:\n\nInput: arr = [3,5,1]\nOutput: true\nExplanation: We can reorder the elements as [1,3,5] or [5,3,1] with differences 2 and -2 respectively, between each consecutive elements.\n\nExample 2:\n\nInput: arr = [1,2,4]\nOutput: false\nExplanation: There is no way to reorder the elements to obtain an arithmetic progression.\n\nConstraints:\n\n- 2 <= arr.length <= 1000\n- -10^6 <= arr[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [-1, 1, 0]) == True\n assert candidate(arr = [5, 3, 1, 4, 2]) == True\n assert candidate(arr = [10, 20, 30, 40, 50]) == True\n assert candidate(arr = [10, 5, 15]) == True\n assert candidate(arr = [5, 3, 1, 2, 4]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [5, 3, 1, 4]) == False\n assert candidate(arr = [1, 2, 3, 5]) == False\n assert candidate(arr = [100, -100, 0]) == True\n assert candidate(arr = [-5, -3, -1, 1, 3, 5]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [5, 3, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [10, 5, 0, -5, -10]) == True\n assert candidate(arr = [1, 1, 1, 1]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 2, 4]) == False\n assert candidate(arr = [-1, 1, 3]) == True\n assert candidate(arr = [100, 50, 0, -50, -100]) == True\n assert candidate(arr = [3, 5, 1]) == True\n assert candidate(arr = [0, 0, 0]) == True\n assert candidate(arr = [-1, 0, 1, 2]) == True\n assert candidate(arr = [1, 2, 2, 3, 3, 4]) == False\n assert candidate(arr = [10, 10, 10, 10]) == True\n assert candidate(arr = [1000000, -1000000, 0]) == True\n assert candidate(arr = [10, 0, 20, 10]) == False\n assert candidate(arr = [-5, 0, 5, 10, 15, 20, 25]) == True\n assert candidate(arr = [5, 8, 11, 14, 17, 20]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [5, 5, 5, 5, 5]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16]) == True\n assert candidate(arr = [1, 2, 2, 3, 4]) == False\n assert candidate(arr = [1, 6, 3, 11, 9, 5]) == False\n assert candidate(arr = [-1000000, -999998, -999996, -999994]) == True\n assert candidate(arr = [1000000, -1000000, 500000, -500000, 0]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(arr = [1000000, 999998, 999996, 999994]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == False\n assert candidate(arr = [1, 2, 3, 4, 6, 8, 10]) == False\n assert candidate(arr = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10, -12, -14, -16]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [38, 34, 30, 26, 22, 18, 14, 10, 6, 2]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(arr = [-5, 0, 5, 10, 15]) == True\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == False\n assert candidate(arr = [1000000, 1000000, 1000000, 1000000, 1000000]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == True\n assert candidate(arr = [1000, 1001, 1002, 1003, 1004, 1005]) == True\n assert candidate(arr = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [100, 50, 0, -50, -100]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -3, -7, -15, -31, -62, -125, -250, -500, -1000]) == False\n assert candidate(arr = [1000000, 500000, 0, -500000, -1000000]) == True\n assert candidate(arr = [100, 50, 25, 0, -25, -50, -100]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [-1000000, -999999, -999998, -999997, -999996]) == True\n assert candidate(arr = [9, 3, 15, 6, 12, 0, 18, 21, 24, 27]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [1, 3, 6, 10, 15]) == False\n assert candidate(arr = [-3, -1, 1, 3, 5, 7, 9, 11, 13]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700]) == True\n assert candidate(arr = [1, 6, 11, 16, 21, 26]) == True\n assert candidate(arr = [7, 3, 11, 5, 9, 1]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(arr = [7, 14, 21, 28, 35]) == True\n assert candidate(arr = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == True\n assert candidate(arr = [1, 2, 3, 4, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [7, 7, 7, 7, 7]) == True\n assert candidate(arr = [-1000, 1000, 0, 500, -500, 250, -250, 750, -750]) == True\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [23, 19, 15, 11, 7, 3, -1, -5]) == True\n assert candidate(arr = [10, 20, 30, 40, 50]) == True\n assert candidate(arr = [10, 5, 0, -5, -10, -15, -20, -25, -30]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(arr = [10, 20, 40, 50, 60]) == False\n assert candidate(arr = [42, 42]) == True\n assert candidate(arr = [-1000000, 1000000, 0, 500000, -500000]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 101]) == False\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [3, -1, 1, 5, -3, 7]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == False\n assert candidate(arr = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == True\n assert candidate(arr = [0, 1, 3, 6, 10, 15, 21]) == False\n assert candidate(arr = [100, 99, 97, 94, 90, 85, 79, 72, 64, 55, 45]) == False\n assert candidate(arr = [5, 1, 7, 3, 9]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == True\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(arr = [1000000, 999999, 999998, 999997]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == True\n assert candidate(arr = [1, 2, 3, 6, 5, 4]) == True\n assert candidate(arr = [100, 200, 150, 50, 250, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]) == True\n assert candidate(arr = [-3, -2, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6]) == False\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120]) == True\n assert candidate(arr = [2, 4, 8, 16, 32]) == False\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == True\n assert candidate(arr = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25]) == True\n assert candidate(arr = [12, 18, 24, 30, 36, 42, 48]) == True\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21]) == False\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == True\n assert candidate(arr = [100, 200, 150, 250, 300, 350, 400]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1]) == True\n assert candidate(arr = [10, 70, 30, 50, 90]) == True\n assert candidate(arr = [1, 100, 50, 75, 25]) == False\n assert candidate(arr = [500000, 499998, 499996, 499994, 499992]) == True\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25]) == True\n assert candidate(arr = [10, 5, 0, -5, -10]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == True\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n assert candidate(arr = [-1000, -500, 0, 500, 1000]) == True\n assert candidate(arr = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13]) == True\n assert candidate(arr = [1000000, -1000000, 0, 500000, -500000]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [10, 0, -10, -20, -30]) == True\n assert candidate(arr = [-5, 0, 5, 10, 15, 20]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30]) == True\n assert candidate(arr = [5, 10, 15, 20, 25]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == False\n assert candidate(arr = [3, 1, 5, 7, 9]) == True\n", "comparison": "exact"}, "public_tests": ["[3,5,1]", "[1,2,4]"], "hints": ["Consider that any valid arithmetic progression will be in sorted order.", "Sort the array, then check if the differences of all consecutive elements are equal."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().canMakeArithmeticProgression", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:01+00:00", "tests_total": 161, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def canMakeArithmeticProgression(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "canMakeArithmeticProgression", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1503, "task_id": "last-moment-before-all-ants-fall-out-of-a-plank", "difficulty": "Medium", "problem_description": "We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.\n\nWhen two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.\n\nWhen an ant reaches one end of the plank at a time t, it falls out of the plank immediately.\n\nGiven an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.\n\nExample 1:\n\nInput: n = 4, left = [4,3], right = [0,1]\nOutput: 4\nExplanation: In the image above:\n-The ant at index 0 is named A and going to the right.\n-The ant at index 1 is named B and going to the right.\n-The ant at index 3 is named C and going to the left.\n-The ant at index 4 is named D and going to the left.\nThe last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).\n\nExample 2:\n\nInput: n = 7, left = [], right = [0,1,2,3,4,5,6,7]\nOutput: 7\nExplanation: All ants are going to the right, the ant at index 0 needs 7 seconds to fall.\n\nExample 3:\n\nInput: n = 7, left = [0,1,2,3,4,5,6,7], right = []\nOutput: 7\nExplanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall.\n\nConstraints:\n\n- 1 <= n <= 10^4\n- 0 <= left.length <= n + 1\n- 0 <= left[i] <= n\n- 0 <= right.length <= n + 1\n- 0 <= right[i] <= n\n- 1 <= left.length + right.length <= n + 1\n- All values of left and right are unique, and each value can appear only in one of the two arrays.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,left = [10, 11, 12],right = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(n = 1,left = [],right = [0]) == 1\n assert candidate(n = 5,left = [5],right = [0]) == 5\n assert candidate(n = 1,left = [1],right = []) == 1\n assert candidate(n = 5,left = [1, 2],right = [3, 4]) == 2\n assert candidate(n = 1,left = [0],right = [1]) == 0\n assert candidate(n = 7,left = [0, 1, 2, 3, 4, 5, 6, 7],right = []) == 7\n assert candidate(n = 4,left = [4, 3],right = [0, 1]) == 4\n assert candidate(n = 10,left = [2, 6, 7],right = [1, 3, 5, 8]) == 9\n assert candidate(n = 100,left = [10, 20, 30, 40, 50],right = [60, 70, 80, 90, 100]) == 50\n assert candidate(n = 10,left = [2, 6],right = [3, 7]) == 7\n assert candidate(n = 7,left = [],right = [0, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(n = 100,left = [],right = [0, 100]) == 100\n assert candidate(n = 1000,left = [500, 501, 502],right = [497, 498, 499]) == 503\n assert candidate(n = 100,left = [50],right = [50]) == 50\n assert candidate(n = 1,left = [0],right = []) == 0\n assert candidate(n = 7,left = [],right = [0, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(n = 7,left = [0, 1, 2, 3, 4, 5, 6],right = []) == 6\n assert candidate(n = 100,left = [0, 100],right = []) == 100\n assert candidate(n = 10,left = [5],right = [5]) == 5\n assert candidate(n = 10000,left = [1, 2, 3],right = [9997, 9998, 9999]) == 3\n assert candidate(n = 10,left = [1, 2, 3],right = [5, 6, 7]) == 5\n assert candidate(n = 200,left = [100, 150],right = [50, 100]) == 150\n assert candidate(n = 7000,left = [0, 7000],right = [3500]) == 7000\n assert candidate(n = 10000,left = [],right = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 9000\n assert candidate(n = 1000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [990, 991, 992, 993, 994, 995, 996, 997, 998, 999]) == 10\n assert candidate(n = 3000,left = [100, 200, 300, 400, 500, 600],right = [2400, 2500, 2600, 2700, 2800, 2900]) == 600\n assert candidate(n = 8000,left = [100, 200, 300, 400, 500],right = [7900, 7800, 7700, 7600, 7500]) == 500\n assert candidate(n = 3000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990]) == 10\n assert candidate(n = 10000,left = [1000, 3000, 5000],right = [2000, 4000, 6000, 8000, 9000]) == 8000\n assert candidate(n = 5000,left = [1234, 2345, 3456, 4567],right = [1000, 2000, 3000, 4000]) == 4567\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000],right = [6000, 7000, 8000, 9000]) == 4000\n assert candidate(n = 10000,left = [9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999],right = []) == 9999\n assert candidate(n = 6000,left = [1500, 2000, 2500, 3000],right = [3500, 4000, 4500, 5000, 5500]) == 3000\n assert candidate(n = 8000,left = [1, 100, 200, 300, 400, 500, 600, 700],right = [7999, 7899, 7799, 7699, 7599, 7499, 7399, 7299]) == 701\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [1500, 2500, 3500, 4500, 5500]) == 5000\n assert candidate(n = 3000,left = [300, 600, 900, 1200, 1500],right = [2700, 2400, 2100, 1800, 1500]) == 1500\n assert candidate(n = 9000,left = [9000],right = [0]) == 9000\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == 10\n assert candidate(n = 4000,left = [0, 800, 1600, 2400, 3200],right = [0, 800, 1600, 2400, 3200]) == 4000\n assert candidate(n = 8000,left = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],right = [7900, 7910, 7920, 7930, 7940, 7950, 7960, 7970, 7980, 7990]) == 100\n assert candidate(n = 10000,left = [5000, 6000, 7000, 8000, 9000],right = [1000, 2000, 3000, 4000]) == 9000\n assert candidate(n = 9999,left = [9998, 9997, 9996],right = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9998\n assert candidate(n = 7000,left = [1000, 2000, 3000, 4000, 5000, 6000],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 6999\n assert candidate(n = 2000,left = [1000, 1500, 1600, 1700],right = [400, 500, 600, 700]) == 1700\n assert candidate(n = 6000,left = [3000],right = [3000]) == 3000\n assert candidate(n = 6000,left = [0, 1000, 2000, 3000, 4000, 5000],right = [1500, 2500, 3500, 4500, 5500]) == 5000\n assert candidate(n = 9000,left = [1000, 3000, 5000, 7000],right = [2000, 4000, 6000, 8000]) == 7000\n assert candidate(n = 6000,left = [50, 150, 250, 350, 450, 550],right = [5450, 5550, 5650, 5750, 5850, 5950]) == 550\n assert candidate(n = 8000,left = [1000, 2000, 3000, 4000, 5000],right = [3000, 4000, 5000, 6000, 7000]) == 5000\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800],right = [8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900]) == 800\n assert candidate(n = 2000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],right = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 1400, 1500, 1600, 1700, 1800, 1900, 1000, 100]) == 1900\n assert candidate(n = 10000,left = [1, 10, 100, 1000, 10000],right = [2, 20, 200, 2000, 9999]) == 10000\n assert candidate(n = 2000,left = [500, 1500],right = [100, 1900, 1600]) == 1900\n assert candidate(n = 10000,left = [1, 2, 3, 5000, 9999],right = [4, 6, 5002, 9997]) == 9999\n assert candidate(n = 8000,left = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000],right = [8000]) == 7000\n assert candidate(n = 4000,left = [2000],right = [2000]) == 2000\n assert candidate(n = 10000,left = [],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9999\n assert candidate(n = 7500,left = [100, 200, 300, 400, 500, 600, 700],right = [7400, 7300, 7200, 7100, 7000, 6900, 6800]) == 700\n assert candidate(n = 9000,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500],right = [8500, 8000, 7500, 7000, 6500, 6000, 5500, 5000, 4500]) == 4500\n assert candidate(n = 7000,left = [100, 200, 300, 400],right = [6600, 6700, 6800, 6900]) == 400\n assert candidate(n = 5000,left = [2500, 2501, 2502, 2503],right = [2499, 2498, 2497, 2496]) == 2504\n assert candidate(n = 500,left = [10, 20, 30, 40, 50],right = [450, 460, 470, 480, 490]) == 50\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [7990, 7991, 7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999]) == 10\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [8100, 8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900]) == 900\n assert candidate(n = 5000,left = [1000, 2000, 3000, 4000, 5000],right = [1, 2, 3, 4]) == 5000\n assert candidate(n = 2000,left = [500, 1000, 1500],right = [100, 600, 1100, 1600]) == 1900\n assert candidate(n = 1500,left = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],right = [1400, 1390, 1380, 1370, 1360, 1350, 1340, 1330, 1320, 1310]) == 190\n assert candidate(n = 5000,left = [10, 20, 30, 40, 50],right = [4950, 4960, 4970, 4980, 4990]) == 50\n assert candidate(n = 5000,left = [1, 2, 3, 4, 5],right = [4995, 4996, 4997, 4998, 4999]) == 5\n assert candidate(n = 10000,left = [2000, 4000, 6000, 8000],right = [1000, 3000, 5000, 7000, 9000]) == 9000\n assert candidate(n = 10000,left = [1, 100, 1000, 10000],right = [2, 200, 2000, 9999]) == 10000\n assert candidate(n = 1000,left = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],right = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 990\n assert candidate(n = 2000,left = [500, 1000, 1500, 2000],right = [10, 20, 30, 40, 50]) == 2000\n assert candidate(n = 4500,left = [500, 1500, 2500, 3500],right = [1000, 2000, 3000, 4000]) == 3500\n assert candidate(n = 10000,left = [0, 2500, 5000, 7500, 10000],right = [10000, 7500, 5000, 2500, 0]) == 10000\n assert candidate(n = 9500,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500],right = [1, 2, 3, 4, 5]) == 9500\n assert candidate(n = 10000,left = [1, 3, 5, 7, 9],right = [2, 4, 6, 8, 10]) == 9998\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [500, 1500, 2500, 3500, 4500]) == 5500\n assert candidate(n = 7500,left = [1000, 2000, 3000],right = [5000, 6000, 7000, 7499]) == 3000\n assert candidate(n = 7500,left = [3000, 4000, 5000],right = [2000, 3000, 4000]) == 5500\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],right = []) == 9000\n assert candidate(n = 10000,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500],right = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500]) == 9500\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5900\n assert candidate(n = 10000,left = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],right = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 9998\n assert candidate(n = 1000,left = [500, 600, 700, 800, 900],right = [100, 200, 300, 400]) == 900\n assert candidate(n = 7000,left = [0, 7000],right = [0, 7000]) == 7000\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5, 6, 7, 8],right = [7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999]) == 8\n assert candidate(n = 10000,left = [5000],right = [5000]) == 5000\n assert candidate(n = 1000,left = [999],right = [0]) == 1000\n assert candidate(n = 1000,left = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],right = [499, 498, 497, 496, 495, 494, 493, 492, 491, 490]) == 510\n assert candidate(n = 5000,left = [100, 200, 300, 400, 500],right = [4500, 4600, 4700, 4800, 4900]) == 500\n assert candidate(n = 5000,left = [0, 1250, 2500, 3750, 5000],right = [1249, 2499, 3749, 4998]) == 5000\n assert candidate(n = 4000,left = [100, 200, 300, 400],right = [3600, 3700, 3800, 3900]) == 400\n assert candidate(n = 9000,left = [1000, 2000, 3000, 4000, 5000],right = [6000, 7000, 8000, 9000]) == 5000\n assert candidate(n = 9999,left = [1, 2, 3, 4, 5, 6, 7, 8, 9],right = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 9\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [8900, 8800, 8700, 8600, 8500, 8400, 8300, 8200, 8100]) == 900\n assert candidate(n = 7000,left = [100, 1000, 2000, 3000, 4000],right = [300, 1300, 2300, 3300, 4300]) == 6700\n assert candidate(n = 5000,left = [2500, 2501, 2502, 2503, 2504],right = [2495, 2496, 2497, 2498, 2499]) == 2505\n assert candidate(n = 1000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 950\n assert candidate(n = 9999,left = [500, 1500, 2500, 3500, 4500],right = [5500, 6500, 7500, 8500, 9500]) == 4500\n assert candidate(n = 1000,left = [100, 200, 300, 400, 500],right = [600, 700, 800, 900]) == 500\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999, 10000]) == 10\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5],right = [9996, 9995, 9994, 9993, 9992]) == 8\n assert candidate(n = 8500,left = [8500],right = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 7500]) == 8500\n assert candidate(n = 6000,left = [0, 6000],right = [3000]) == 6000\n assert candidate(n = 5000,left = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],right = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4998\n assert candidate(n = 5000,left = [4999, 4998, 4997, 4996],right = [1, 2, 3, 4]) == 4999\n assert candidate(n = 5000,left = [1000, 2000, 3000, 4000],right = [500, 1500, 2500, 3500, 4500]) == 4500\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000],right = [7000, 8000, 9000]) == 4000\n assert candidate(n = 500,left = [0, 250, 500],right = [0, 250, 500]) == 500\n assert candidate(n = 9999,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == 10\n assert candidate(n = 10000,left = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9999\n assert candidate(n = 500,left = [0, 100, 200, 300, 400],right = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 490\n assert candidate(n = 7000,left = [500, 1000, 1500, 2000, 2500],right = [6500, 7000, 6000, 6500, 7000]) == 2500\n assert candidate(n = 5000,left = [100, 200, 300, 400],right = [4600, 4700, 4800, 4900]) == 400\n assert candidate(n = 10000,left = [1, 100, 1000, 10000],right = [50, 500, 5000, 9950]) == 10000\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5],right = [7995, 7996, 7997, 7998, 7999]) == 5\n assert candidate(n = 2000,left = [100, 200, 300, 400, 500],right = [1500, 1600, 1700, 1800, 1900]) == 500\n assert candidate(n = 3000,left = [500, 1000, 1500, 2000, 2500],right = [100, 600, 1100, 1600, 2100]) == 2900\n", "comparison": "exact"}, "public_tests": ["4\n[4,3]\n[0,1]", "7\n[]\n[0,1,2,3,4,5,6,7]", "7\n[0,1,2,3,4,5,6,7]\n[]"], "hints": ["The ants change their way when they meet is equivalent to continue moving without changing their direction.", "Answer is the max distance for one ant to reach the end of the plank in the facing direction."], "metadata": {"canonical_parameter_names": ["n", "left", "right"], "leetcode_dataset_entry_point": "Solution().getLastMoment", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:03+00:00", "tests_total": 126, "tests_dropped": 6, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "brainteaser", "simulation"]}, "language": "python", "interface": {"raw_signature": "def getLastMoment(self, n: int, left: list[int], right: list[int]) -> int:", "container": "Solution", "callable": "getLastMoment", "parameters": [{"name": "n", "type": "int"}, {"name": "left", "type": "list[int]"}, {"name": "right", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1504, "task_id": "count-submatrices-with-all-ones", "difficulty": "Medium", "problem_description": "Given an m x n binary matrix mat, return the number of submatrices that have all ones.\n\nExample 1:\n\nInput: mat = [[1,0,1],[1,1,0],[1,1,0]]\nOutput: 13\nExplanation:\nThere are 6 rectangles of side 1x1.\nThere are 2 rectangles of side 1x2.\nThere are 3 rectangles of side 2x1.\nThere is 1 rectangle of side 2x2.\nThere is 1 rectangle of side 3x1.\nTotal number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.\n\nExample 2:\n\nInput: mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]\nOutput: 24\nExplanation:\nThere are 8 rectangles of side 1x1.\nThere are 5 rectangles of side 1x2.\nThere are 2 rectangles of side 1x3.\nThere are 4 rectangles of side 2x1.\nThere are 2 rectangles of side 2x2.\nThere are 2 rectangles of side 3x1.\nThere is 1 rectangle of side 3x2.\nTotal number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.\n\nConstraints:\n\n- 1 <= m, n <= 150\n- mat[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[0, 0], [0, 0]]) == 0\n assert candidate(mat = [[1, 0, 1], [1, 1, 0], [1, 1, 0]]) == 13\n assert candidate(mat = [[1, 0], [0, 1]]) == 2\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 60\n assert candidate(mat = [[0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 36\n assert candidate(mat = [[0, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 0]]) == 24\n assert candidate(mat = [[1, 1], [1, 1]]) == 9\n assert candidate(mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1]]) == 28\n assert candidate(mat = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 89\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 36\n assert candidate(mat = [[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]]) == 15\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 32\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == 29\n assert candidate(mat = [[1, 1, 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, 1, 1]]) == 126\n assert candidate(mat = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 69\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, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 18\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 0]]) == 43\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0], [1, 0, 1, 0], [0, 1, 1, 1]]) == 40\n assert candidate(mat = [[1, 1, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 59\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 0], [0, 1, 1, 1], [1, 0, 1, 1]]) == 31\n assert candidate(mat = [[1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1]]) == 85\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 50\n assert candidate(mat = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == 50\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\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]]) == 420\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 28\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == 25\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 1]]) == 105\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, 0, 1]]) == 13\n assert candidate(mat = [[1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1]]) == 105\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]]) == 30\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 0, 1, 0]]) == 36\n assert candidate(mat = [[1, 0, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [1, 0, 1]]) == 37\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0]]) == 60\n assert candidate(mat = [[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]]) == 48\n assert candidate(mat = [[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]]) == 128\n assert candidate(mat = [[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], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 270\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 141\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]) == 93\n assert candidate(mat = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 0, 0, 1], [0, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == 71\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, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 21\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 0, 0, 1]]) == 114\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 1], [0, 1, 0, 1]]) == 41\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 1, 0], [1, 1, 0, 1], [0, 1, 1, 1]]) == 29\n assert candidate(mat = [[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]]) == 233\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 44\n assert candidate(mat = [[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]]) == 9\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 34\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1]]) == 36\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 57\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0]]) == 76\n assert candidate(mat = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1]]) == 51\n assert candidate(mat = [[1, 1, 1], [0, 0, 0], [1, 1, 1], [0, 0, 0], [1, 1, 1], [0, 0, 0]]) == 18\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], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 196\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]]) == 210\n assert candidate(mat = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]]) == 23\n assert candidate(mat = [[1, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 62\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 54\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 540\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1]]) == 25\n assert candidate(mat = [[0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1, 0, 0]]) == 74\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 112\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]]) == 315\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(mat = [[1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 0, 1, 1, 1], [0, 1, 1, 1, 1, 0]]) == 52\n assert candidate(mat = [[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]]) == 56\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 71\n assert candidate(mat = [[1, 1, 1, 1, 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]]) == 87\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 89\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [1, 1, 1, 1, 0]]) == 45\n assert candidate(mat = [[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]]) == 30\n assert candidate(mat = [[1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [1, 0, 0, 1, 1, 1]]) == 51\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(mat = [[1, 1, 0, 0, 1, 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], [1, 1, 0, 0, 1, 1]]) == 45\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0]]) == 67\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 68\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, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 110\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 45\n assert candidate(mat = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 1, 1, 1, 1]]) == 91\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0], [1, 0, 1, 1]]) == 28\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) == 56\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1]]) == 50\n assert candidate(mat = [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 58\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 117\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1]]) == 56\n", "comparison": "exact"}, "public_tests": ["[[1,0,1],[1,1,0],[1,1,0]]", "[[0,1,1,0],[0,1,1,1],[1,1,1,0]]"], "hints": ["For each row i, create an array nums where: if mat[i][j] == 0 then nums[j] = 0 else nums[j] = nums[j-1] +1.", "In the row i, number of rectangles between column j and k(inclusive) and ends in row i, is equal to SUM(min(nums[j, .. idx])) where idx go from j to k. Expected solution is O(n^3)."], "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().numSubmat", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:05+00:00", "tests_total": 90, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "stack", "matrix", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def numSubmat(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "numSubmat", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1505, "task_id": "minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits", "difficulty": "Hard", "problem_description": "You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.\n\nReturn the minimum integer you can obtain also as a string.\n\nExample 1:\n\nInput: num = \"4321\", k = 4\nOutput: \"1342\"\nExplanation: The steps to obtain the minimum integer from 4321 with 4 adjacent swaps are shown.\n\nExample 2:\n\nInput: num = \"100\", k = 1\nOutput: \"010\"\nExplanation: It's ok for the output to have leading zeros, but the input is guaranteed not to have any leading zeros.\n\nExample 3:\n\nInput: num = \"36789\", k = 1000\nOutput: \"36789\"\nExplanation: We can keep the number without any swaps.\n\nConstraints:\n\n- 1 <= num.length <= 3 * 10^4\n- num consists of only digits and does not contain leading zeros.\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"36789\",k = 1000) == \"36789\"\n assert candidate(num = \"100\",k = 1) == \"010\"\n assert candidate(num = \"9876543210\",k = 9) == \"0987654321\"\n assert candidate(num = \"9876543210\",k = 100) == \"0123456789\"\n assert candidate(num = \"222111333\",k = 10) == \"111222333\"\n assert candidate(num = \"4321\",k = 4) == \"1342\"\n assert candidate(num = \"3452345\",k = 3) == \"2345345\"\n assert candidate(num = \"111222333\",k = 5) == \"111222333\"\n assert candidate(num = \"9876543210\",k = 5) == \"4987653210\"\n assert candidate(num = \"102030405060708090\",k = 20) == \"000001023456708090\"\n assert candidate(num = \"29431\",k = 2) == \"23941\"\n assert candidate(num = \"59585756555453525150\",k = 100) == \"01234555555556987555\"\n assert candidate(num = \"9999999999\",k = 50) == \"9999999999\"\n assert candidate(num = \"9487653210\",k = 10) == \"0498765321\"\n assert candidate(num = \"1234567890\",k = 9) == \"0123456789\"\n assert candidate(num = \"5397268410\",k = 15) == \"0235796841\"\n assert candidate(num = \"111222333444555\",k = 25) == \"111222333444555\"\n assert candidate(num = \"98765432101234567890\",k = 50) == \"00112987654323456789\"\n assert candidate(num = \"5432109876\",k = 10) == \"0145329876\"\n assert candidate(num = \"1234321\",k = 5) == \"1123432\"\n assert candidate(num = \"9999999999888888888877777777776666666666\",k = 100) == \"6668999999999988888888877777777776666666\"\n assert candidate(num = \"0000000000000000000000001\",k = 1) == \"0000000000000000000000001\"\n assert candidate(num = \"198765432\",k = 20) == \"123479865\"\n assert candidate(num = \"54321098765432109876543210\",k = 50) == \"00012453987654321987654321\"\n assert candidate(num = \"98765432101234567890\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"5432109876\",k = 30) == \"0123456789\"\n assert candidate(num = \"5943281760\",k = 15) == \"0159432876\"\n assert candidate(num = \"19876543210\",k = 10) == \"01987654321\"\n assert candidate(num = \"77665544332211009988\",k = 100) == \"00112233447766559988\"\n assert candidate(num = \"543210987654321098765432109876543210\",k = 200) == \"000011112222345498765398765439876543\"\n assert candidate(num = \"5946132780\",k = 15) == \"0145963278\"\n assert candidate(num = \"987654321012345678909876543210\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"342134213421\",k = 15) == \"112234343421\"\n assert candidate(num = \"9876543210\",k = 30) == \"0123987654\"\n assert candidate(num = \"1234567890\",k = 10) == \"0123456789\"\n assert candidate(num = \"1234567890\",k = 15) == \"0123456789\"\n assert candidate(num = \"999999999999999999999999\",k = 1000000) == \"999999999999999999999999\"\n assert candidate(num = \"44444444444444444444\",k = 1000) == \"44444444444444444444\"\n assert candidate(num = \"87654321098765432109\",k = 200) == \"00112233445566778899\"\n assert candidate(num = \"999888777666555444333222111000\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"9876543210987654321098765432109876543210\",k = 200) == \"0000111122369875498765439876543298765432\"\n assert candidate(num = \"5555555555\",k = 100) == \"5555555555\"\n assert candidate(num = \"98765432109876543210\",k = 25) == \"01289765439876543210\"\n assert candidate(num = \"9876543210\",k = 45) == \"0123456789\"\n assert candidate(num = \"1234567890123456789012345678901234567890\",k = 500) == \"0000111122223333444455556666777788889999\"\n assert candidate(num = \"55555555555555555555555555555555\",k = 10000) == \"55555555555555555555555555555555\"\n assert candidate(num = \"12345678901234567890\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"1010101010101010101010101010101010101010\",k = 50) == \"0000000001111101111110101010101010101010\"\n assert candidate(num = \"9438527610\",k = 10) == \"0493852761\"\n assert candidate(num = \"987654321098765432109876543210\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"5432198760\",k = 20) == \"0123458976\"\n assert candidate(num = \"9876543210123456789098765432101234567890\",k = 300) == \"0000111122223333444479865567899876556789\"\n assert candidate(num = \"2134567890\",k = 5) == \"1234506789\"\n assert candidate(num = \"3333222211110000\",k = 50) == \"0000332332221111\"\n assert candidate(num = \"1234567890987654321\",k = 25) == \"0112345678998765432\"\n assert candidate(num = \"0000000001\",k = 5) == \"0000000001\"\n assert candidate(num = \"1098765432\",k = 20) == \"0123489765\"\n assert candidate(num = \"111112222233333444445555566666777778888899999\",k = 500) == \"111112222233333444445555566666777778888899999\"\n assert candidate(num = \"12345678909876543210\",k = 50) == \"00112345657899876432\"\n assert candidate(num = \"1432214321\",k = 10) == \"1122343421\"\n assert candidate(num = \"12341234123412341234\",k = 50) == \"11111222223434343434\"\n assert candidate(num = \"111222333444555666777888999\",k = 300) == \"111222333444555666777888999\"\n assert candidate(num = \"333222111000999888777666555444333222111000\",k = 500) == \"000000111111222222333333444555666779899887\"\n assert candidate(num = \"9999999999999999999999999999999999999999\",k = 100000) == \"9999999999999999999999999999999999999999\"\n assert candidate(num = \"1111111111111111111111111111111\",k = 30000) == \"1111111111111111111111111111111\"\n assert candidate(num = \"6482319570\",k = 8) == \"1264839570\"\n assert candidate(num = \"5999888777666555444333222111000\",k = 100) == \"0004599988877766655544333222111\"\n assert candidate(num = \"94321\",k = 3) == \"29431\"\n assert candidate(num = \"1234321\",k = 3) == \"1223431\"\n assert candidate(num = \"87654321098765432109\",k = 50) == \"00115876432987654329\"\n assert candidate(num = \"8765432109\",k = 100) == \"0123456789\"\n assert candidate(num = \"555555555555555555555555\",k = 100000) == \"555555555555555555555555\"\n assert candidate(num = \"123456789876543212345678987654321\",k = 150) == \"111222233334456789876545678987654\"\n assert candidate(num = \"54321098765432109876\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"432101234\",k = 10) == \"011432234\"\n assert candidate(num = \"1234567890\",k = 30) == \"0123456789\"\n assert candidate(num = \"9876543210\",k = 50) == \"0123456789\"\n assert candidate(num = \"1987654320\",k = 15) == \"0139876542\"\n assert candidate(num = \"5142369870\",k = 15) == \"0123456987\"\n assert candidate(num = \"444333222111000\",k = 50) == \"000134344322211\"\n assert candidate(num = \"98765432109876543210\",k = 20) == \"01698754329876543210\"\n assert candidate(num = \"9457836120\",k = 8) == \"1495783620\"\n assert candidate(num = \"9876543210\",k = 10000) == \"0123456789\"\n assert candidate(num = \"9632147850\",k = 12) == \"0296314785\"\n assert candidate(num = \"10987654321\",k = 10) == \"01189765432\"\n assert candidate(num = \"1234543210\",k = 25) == \"0112233445\"\n assert candidate(num = \"1221331223\",k = 20) == \"1112222333\"\n assert candidate(num = \"1234567890\",k = 50) == \"0123456789\"\n assert candidate(num = \"8642013579\",k = 20) == \"0123456789\"\n assert candidate(num = \"11111111111111111111\",k = 10000) == \"11111111111111111111\"\n assert candidate(num = \"192837465546738291\",k = 50) == \"112233458976546789\"\n assert candidate(num = \"9438276510\",k = 10) == \"0493827651\"\n assert candidate(num = \"123456789012345678901234567890\",k = 100) == \"000111222345678394567893456789\"\n assert candidate(num = \"12345678901234567890\",k = 20) == \"01123456278934567890\"\n assert candidate(num = \"333222111\",k = 20) == \"111323322\"\n assert candidate(num = \"9876543210\",k = 25) == \"0128976543\"\n assert candidate(num = \"98765432109876543210\",k = 100) == \"00112233458976987654\"\n assert candidate(num = \"000111222333444555666777888999\",k = 50) == \"000111222333444555666777888999\"\n assert candidate(num = \"1234567890\",k = 25) == \"0123456789\"\n assert candidate(num = \"5432109876\",k = 15) == \"0123459876\"\n assert candidate(num = \"010203040506070809\",k = 30) == \"000000001234560789\"\n assert candidate(num = \"99999999999999999999\",k = 1000) == \"99999999999999999999\"\n assert candidate(num = \"99887766554433221100\",k = 50) == \"00299887766554433211\"\n assert candidate(num = \"12345678900987654321\",k = 50) == \"00112234567889976543\"\n", "comparison": "exact"}, "public_tests": ["\"4321\"\n4", "\"100\"\n1", "\"36789\"\n1000"], "hints": ["We want to make the smaller digits the most significant digits in the number.", "For each index i, check the smallest digit in a window of size k and append it to the answer. Update the indices of all digits in this range accordingly."], "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().minInteger", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:07+00:00", "tests_total": 106, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["string", "greedy", "binary-indexed-tree", "segment-tree"]}, "language": "python", "interface": {"raw_signature": "def minInteger(self, num: str, k: int) -> str:", "container": "Solution", "callable": "minInteger", "parameters": [{"name": "num", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1507, "task_id": "reformat-date", "difficulty": "Easy", "problem_description": "Given a date string in the form Day Month Year, where:\n\n- Day is in the set {\"1st\", \"2nd\", \"3rd\", \"4th\", ..., \"30th\", \"31st\"}.\n- Month is in the set {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"}.\n- Year is in the range [1900, 2100].\n\nConvert the date string to the format YYYY-MM-DD, where:\n\n- YYYY denotes the 4 digit year.\n- MM denotes the 2 digit month.\n- DD denotes the 2 digit day.\n\nExample 1:\n\nInput: date = \"20th Oct 2052\"\nOutput: \"2052-10-20\"\n\nExample 2:\n\nInput: date = \"6th Jun 1933\"\nOutput: \"1933-06-06\"\n\nExample 3:\n\nInput: date = \"26th May 1960\"\nOutput: \"1960-05-26\"\n\nConstraints:\n\n- The given dates are guaranteed to be valid, so no error handling is necessary.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date = \"15th Aug 2022\") == \"2022-08-15\"\n assert candidate(date = \"22nd Aug 1999\") == \"1999-08-22\"\n assert candidate(date = \"3rd Mar 1987\") == \"1987-03-03\"\n assert candidate(date = \"3rd Nov 2022\") == \"2022-11-03\"\n assert candidate(date = \"2nd Mar 2020\") == \"2020-03-02\"\n assert candidate(date = \"15th Nov 2000\") == \"2000-11-15\"\n assert candidate(date = \"2nd Mar 2010\") == \"2010-03-02\"\n assert candidate(date = \"31st Dec 2100\") == \"2100-12-31\"\n assert candidate(date = \"25th Dec 2000\") == \"2000-12-25\"\n assert candidate(date = \"11th Sep 2023\") == \"2023-09-11\"\n assert candidate(date = \"15th Nov 1999\") == \"1999-11-15\"\n assert candidate(date = \"15th Nov 2020\") == \"2020-11-15\"\n assert candidate(date = \"11th Mar 2000\") == \"2000-03-11\"\n assert candidate(date = \"5th Sep 1899\") == \"1899-09-05\"\n assert candidate(date = \"3rd Apr 2015\") == \"2015-04-03\"\n assert candidate(date = \"26th May 1960\") == \"1960-05-26\"\n assert candidate(date = \"11th Sep 1999\") == \"1999-09-11\"\n assert candidate(date = \"28th Feb 1900\") == \"1900-02-28\"\n assert candidate(date = \"20th Oct 2052\") == \"2052-10-20\"\n assert candidate(date = \"6th Jun 1933\") == \"1933-06-06\"\n assert candidate(date = \"2nd Mar 2015\") == \"2015-03-02\"\n assert candidate(date = \"1st Jan 1900\") == \"1900-01-01\"\n assert candidate(date = \"28th Feb 1996\") == \"1996-02-28\"\n assert candidate(date = \"29th Feb 2004\") == \"2004-02-29\"\n assert candidate(date = \"2nd Feb 2020\") == \"2020-02-02\"\n assert candidate(date = \"11th Sep 2020\") == \"2020-09-11\"\n assert candidate(date = \"29th Feb 2000\") == \"2000-02-29\"\n assert candidate(date = \"8th Feb 1987\") == \"1987-02-08\"\n assert candidate(date = \"31st Jan 2100\") == \"2100-01-31\"\n assert candidate(date = \"5th Nov 1999\") == \"1999-11-05\"\n assert candidate(date = \"22nd Sep 1965\") == \"1965-09-22\"\n assert candidate(date = \"27th Jun 2012\") == \"2012-06-27\"\n assert candidate(date = \"30th Nov 2010\") == \"2010-11-30\"\n assert candidate(date = \"19th Dec 2099\") == \"2099-12-19\"\n assert candidate(date = \"31st May 2023\") == \"2023-05-31\"\n assert candidate(date = \"31st Dec 2099\") == \"2099-12-31\"\n assert candidate(date = \"4th Mar 2003\") == \"2003-03-04\"\n assert candidate(date = \"24th Jun 2050\") == \"2050-06-24\"\n assert candidate(date = \"23rd Apr 2040\") == \"2040-04-23\"\n assert candidate(date = \"27th Sep 2077\") == \"2077-09-27\"\n assert candidate(date = \"6th Mar 2077\") == \"2077-03-06\"\n assert candidate(date = \"18th Jun 2050\") == \"2050-06-18\"\n assert candidate(date = \"10th Oct 2033\") == \"2033-10-10\"\n assert candidate(date = \"29th Apr 1999\") == \"1999-04-29\"\n assert candidate(date = \"25th Oct 2050\") == \"2050-10-25\"\n assert candidate(date = \"14th May 2005\") == \"2005-05-14\"\n assert candidate(date = \"23rd Oct 2005\") == \"2005-10-23\"\n assert candidate(date = \"30th Apr 2047\") == \"2047-04-30\"\n assert candidate(date = \"19th Aug 2076\") == \"2076-08-19\"\n assert candidate(date = \"21st Jun 1972\") == \"1972-06-21\"\n assert candidate(date = \"18th May 1950\") == \"1950-05-18\"\n assert candidate(date = \"4th Nov 2035\") == \"2035-11-04\"\n assert candidate(date = \"29th Feb 2020\") == \"2020-02-29\"\n assert candidate(date = \"9th Sep 1987\") == \"1987-09-09\"\n assert candidate(date = \"31st Jan 1980\") == \"1980-01-31\"\n assert candidate(date = \"18th Sep 2089\") == \"2089-09-18\"\n assert candidate(date = \"21st Aug 1955\") == \"1955-08-21\"\n assert candidate(date = \"30th Nov 1969\") == \"1969-11-30\"\n assert candidate(date = \"27th Oct 2075\") == \"2075-10-27\"\n assert candidate(date = \"3rd Nov 2021\") == \"2021-11-03\"\n assert candidate(date = \"18th Jul 1950\") == \"1950-07-18\"\n assert candidate(date = \"12th Aug 2022\") == \"2022-08-12\"\n assert candidate(date = \"19th Dec 2021\") == \"2021-12-19\"\n assert candidate(date = \"3rd Jul 1970\") == \"1970-07-03\"\n assert candidate(date = \"7th Dec 2099\") == \"2099-12-07\"\n assert candidate(date = \"9th Jun 2040\") == \"2040-06-09\"\n assert candidate(date = \"21st Nov 2050\") == \"2050-11-21\"\n assert candidate(date = \"16th May 2067\") == \"2067-05-16\"\n assert candidate(date = \"14th Oct 1960\") == \"1960-10-14\"\n assert candidate(date = \"25th Dec 1984\") == \"1984-12-25\"\n assert candidate(date = \"22nd Sep 2050\") == \"2050-09-22\"\n assert candidate(date = \"28th Feb 2000\") == \"2000-02-28\"\n assert candidate(date = \"15th Aug 2024\") == \"2024-08-15\"\n assert candidate(date = \"5th Oct 2100\") == \"2100-10-05\"\n assert candidate(date = \"22nd Aug 2022\") == \"2022-08-22\"\n assert candidate(date = \"21st Sep 1989\") == \"1989-09-21\"\n assert candidate(date = \"22nd Mar 2015\") == \"2015-03-22\"\n assert candidate(date = \"12th Mar 2021\") == \"2021-03-12\"\n assert candidate(date = \"13th Dec 2033\") == \"2033-12-13\"\n assert candidate(date = \"13th Aug 1984\") == \"1984-08-13\"\n assert candidate(date = \"3rd Mar 2030\") == \"2030-03-03\"\n assert candidate(date = \"13th Aug 2023\") == \"2023-08-13\"\n assert candidate(date = \"10th Oct 1899\") == \"1899-10-10\"\n assert candidate(date = \"17th Mar 1925\") == \"1925-03-17\"\n assert candidate(date = \"21st Dec 1900\") == \"1900-12-21\"\n assert candidate(date = \"4th Mar 1921\") == \"1921-03-04\"\n assert candidate(date = \"24th Jun 1998\") == \"1998-06-24\"\n assert candidate(date = \"22nd Jul 2034\") == \"2034-07-22\"\n assert candidate(date = \"25th Jun 2023\") == \"2023-06-25\"\n assert candidate(date = \"30th Nov 2045\") == \"2045-11-30\"\n assert candidate(date = \"30th Apr 2000\") == \"2000-04-30\"\n assert candidate(date = \"28th Feb 1999\") == \"1999-02-28\"\n assert candidate(date = \"2nd Jan 1901\") == \"1901-01-02\"\n assert candidate(date = \"1st Mar 2024\") == \"2024-03-01\"\n assert candidate(date = \"5th Jul 1955\") == \"1955-07-05\"\n assert candidate(date = \"28th Feb 2001\") == \"2001-02-28\"\n assert candidate(date = \"9th Dec 2030\") == \"2030-12-09\"\n assert candidate(date = \"5th Oct 1987\") == \"1987-10-05\"\n assert candidate(date = \"10th Mar 2012\") == \"2012-03-10\"\n assert candidate(date = \"7th Jun 2080\") == \"2080-06-07\"\n assert candidate(date = \"9th Jul 1987\") == \"1987-07-09\"\n assert candidate(date = \"28th Feb 1901\") == \"1901-02-28\"\n assert candidate(date = \"7th Jul 2021\") == \"2021-07-07\"\n assert candidate(date = \"7th Nov 1969\") == \"1969-11-07\"\n assert candidate(date = \"2nd Mar 1990\") == \"1990-03-02\"\n assert candidate(date = \"28th Feb 2004\") == \"2004-02-28\"\n assert candidate(date = \"30th Apr 2077\") == \"2077-04-30\"\n assert candidate(date = \"30th Apr 2100\") == \"2100-04-30\"\n assert candidate(date = \"12th Sep 1995\") == \"1995-09-12\"\n assert candidate(date = \"2nd Apr 2023\") == \"2023-04-02\"\n assert candidate(date = \"17th Oct 2061\") == \"2061-10-17\"\n", "comparison": "exact"}, "public_tests": ["\"20th Oct 2052\"", "\"6th Jun 1933\"", "\"26th May 1960\""], "hints": ["Handle the conversions of day, month and year separately.", "Notice that days always have a two-word ending, so if you erase the last two characters of this days you'll get the number."], "metadata": {"canonical_parameter_names": ["date"], "leetcode_dataset_entry_point": "Solution().reformatDate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:10+00:00", "tests_total": 111, "tests_dropped": 0, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def reformatDate(self, date: str) -> str:", "container": "Solution", "callable": "reformatDate", "parameters": [{"name": "date", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1508, "task_id": "range-sum-of-sorted-subarray-sums", "difficulty": "Medium", "problem_description": "You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.\n\nReturn the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 5\nOutput: 13\nExplanation: All subarray sums are 1, 3, 6, 10, 2, 5, 9, 3, 7, 4. After sorting them in non-decreasing order we have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 1 to ri = 5 is 1 + 2 + 3 + 3 + 4 = 13.\n\nExample 2:\n\nInput: nums = [1,2,3,4], n = 4, left = 3, right = 4\nOutput: 6\nExplanation: The given array is the same as example 1. We have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 3 to ri = 4 is 3 + 3 = 6.\n\nExample 3:\n\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 10\nOutput: 50\n\nConstraints:\n\n- n == nums.length\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= 100\n- 1 <= left <= right <= n * (n + 1) / 2\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 3,right = 4) == 6\n assert candidate(nums = [10, 20, 30],n = 3,left = 1,right = 3) == 60\n assert candidate(nums = [5, 1, 2],n = 3,left = 1,right = 4) == 11\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 1,right = 5) == 13\n assert candidate(nums = [3, 3, 3, 3],n = 4,left = 2,right = 8) == 36\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 1,right = 10) == 50\n assert candidate(nums = [3, 3, 3],n = 3,left = 2,right = 5) == 18\n assert candidate(nums = [5, 2, 1, 4],n = 4,left = 3,right = 7) == 24\n assert candidate(nums = [10, 20, 30],n = 3,left = 2,right = 5) == 130\n assert candidate(nums = [5, 1, 4],n = 3,left = 1,right = 6) == 31\n assert candidate(nums = [5, 1, 2, 3],n = 4,left = 2,right = 6) == 18\n assert candidate(nums = [10, 20, 30],n = 3,left = 1,right = 5) == 140\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 25,right = 50) == 756\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 20,right = 30) == 36\n assert candidate(nums = [5, 15, 10, 20, 25],n = 5,left = 1,right = 15) == 520\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],n = 10,left = 25,right = 55) == 2334\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 15,right = 45) == 6700\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 5,right = 15) == 960\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 15,right = 45) == 460\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 = 20,left = 100,right = 200) == 11368\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],n = 15,left = 50,right = 100) == 5098\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],n = 9,left = 25,right = 35) == 250\n assert candidate(nums = [10, 20, 30, 40, 50],n = 5,left = 3,right = 12) == 610\n assert candidate(nums = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],n = 12,left = 30,right = 75) == 8471\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],n = 7,left = 1,right = 28) == 588\n assert candidate(nums = [5, 6, 7, 8, 9],n = 5,left = 3,right = 7) == 48\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 1,right = 55) == 220\n assert candidate(nums = [5, 1, 7, 3, 8],n = 5,left = 3,right = 7) == 34\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 15,right = 40) == 497\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 30,right = 50) == 664\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 20,right = 40) == 310\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],n = 10,left = 25,right = 50) == 7560\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 10,right = 30) == 496\n assert candidate(nums = [9, 8, 7, 6, 5],n = 5,left = 1,right = 15) == 245\n assert candidate(nums = [9, 18, 27, 36, 45, 54],n = 6,left = 10,right = 20) == 1260\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 15,right = 30) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10,left = 30,right = 50) == 664\n assert candidate(nums = [7, 3, 8, 6, 2, 5, 4, 9, 1],n = 9,left = 20,right = 40) == 480\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],n = 10,left = 10,right = 30) == 5233\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 50,right = 60) == 379\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],n = 10,left = 20,right = 50) == 1036\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 6,left = 10,right = 20) == 1400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 25,right = 35) == 421\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 6,left = 10,right = 20) == 1400\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 5,right = 20) == 95\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 30,right = 40) == 2810\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 10,left = 30,right = 45) == 908\n assert candidate(nums = [9, 7, 5, 3, 1],n = 5,left = 8,right = 12) == 68\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],n = 7,left = 15,right = 25) == 179\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 1,right = 15) == 1050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 50,right = 100) == 2715\n assert candidate(nums = [9, 3, 5, 7, 2, 8],n = 6,left = 4,right = 12) == 89\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 25,right = 50) == 133\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],n = 20,left = 50,right = 150) == 6400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 20,left = 100,right = 150) == 8103\n assert candidate(nums = [5, 15, 25, 35, 45],n = 5,left = 7,right = 14) == 610\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 = 20,left = 50,right = 100) == 232\n assert candidate(nums = [1, 2, 3, 4, 5],n = 5,left = 1,right = 15) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],n = 10,left = 25,right = 50) == 410\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],n = 10,left = 5,right = 55) == 21600\n assert candidate(nums = [5, 15, 25, 35, 45],n = 5,left = 5,right = 15) == 810\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],n = 15,left = 50,right = 100) == 5098\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],n = 9,left = 10,right = 30) == 291\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 25,right = 45) == 97\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],n = 12,left = 50,right = 75) == 6660\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],n = 7,left = 15,right = 25) == 1585\n assert candidate(nums = [5, 15, 10, 20, 25],n = 5,left = 4,right = 10) == 195\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 2, 1],n = 8,left = 10,right = 35) == 2000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 15,left = 50,right = 100) == 5430\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 5,right = 20) == 27\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],n = 10,left = 5,right = 15) == 1520\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 20,left = 120,right = 200) == 19092\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]\n4\n1\n5", "[1,2,3,4]\n4\n3\n4", "[1,2,3,4]\n4\n1\n10"], "hints": ["Compute all sums and save it in array.", "Then just go from LEFT to RIGHT index and calculate answer modulo 1e9 + 7."], "metadata": {"canonical_parameter_names": ["nums", "n", "left", "right"], "leetcode_dataset_entry_point": "Solution().rangeSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:13+00:00", "tests_total": 105, "tests_dropped": 33, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def rangeSum(self, nums: list[int], n: int, left: int, right: int) -> int:", "container": "Solution", "callable": "rangeSum", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "n", "type": "int"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1509, "task_id": "minimum-difference-between-largest-and-smallest-value-in-three-moves", "difficulty": "Medium", "problem_description": "You are given an integer array nums.\n\nIn one move, you can choose one element of nums and change it to any value.\n\nReturn the minimum difference between the largest and smallest value of nums after performing at most three moves.\n\nExample 1:\n\nInput: nums = [5,3,2,4]\nOutput: 0\nExplanation: We can make at most 3 moves.\nIn the first move, change 2 to 3. nums becomes [5,3,3,4].\nIn the second move, change 4 to 3. nums becomes [5,3,3,3].\nIn the third move, change 5 to 3. nums becomes [3,3,3,3].\nAfter performing 3 moves, the difference between the minimum and maximum is 3 - 3 = 0.\n\nExample 2:\n\nInput: nums = [1,5,0,10,14]\nOutput: 1\nExplanation: We can make at most 3 moves.\nIn the first move, change 5 to 0. nums becomes [1,0,0,10,14].\nIn the second move, change 10 to 0. nums becomes [1,0,0,0,14].\nIn the third move, change 14 to 1. nums becomes [1,0,0,0,1].\nAfter performing 3 moves, the difference between the minimum and maximum is 1 - 0 = 1.\nIt can be shown that there is no way to make the difference 0 in 3 moves.\n\nExample 3:\n\nInput: nums = [3,100,20]\nOutput: 0\nExplanation: We can make at most 3 moves.\nIn the first move, change 100 to 7. nums becomes [3,7,20].\nIn the second move, change 20 to 7. nums becomes [3,7,7].\nIn the third move, change 3 to 7. nums becomes [7,7,7].\nAfter performing 3 moves, the difference between the minimum and maximum is 7 - 7 = 0.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^9 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 100, 20]) == 0\n assert candidate(nums = [1]) == 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, -7, -8, -9, -10]) == 6\n assert candidate(nums = [1, 1000000000, -1000000000, 0]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 0]) == 0\n assert candidate(nums = [6, 6, 0, 1, 1, 4, 6]) == 2\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [1, 5, 0, 10, 14]) == 1\n assert candidate(nums = [5, 3, 2, 4]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 46\n assert candidate(nums = [1, 2, 3, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006]) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1100\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]) == 88\n assert candidate(nums = [-1000000, -900000, -800000, -700000, -600000, -500000, -400000, -300000, -200000, -100000]) == 600000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1600\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]) == 250\n assert candidate(nums = [1, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 999\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, -1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == 110000000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 22\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]) == 52\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]) == 32\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 2600\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]) == 8\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]) == 17\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == 96\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 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]) == 8\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]) == 96\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000]) == 110\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 6\n assert candidate(nums = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, -990]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 16000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 600\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 6\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 6\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 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]) == 21\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]) == 180\n assert candidate(nums = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 99999\n assert candidate(nums = [-1000000, 0, 1000000, -500000, 500000, -250000, 250000, -750000, 750000, -1250000, 1250000, -1500000, 1500000, -2000000, 2000000]) == 2750000\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]) == 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, 1]) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985]) == 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]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000, 2000, 3000]) == 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]) == 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]) == 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, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 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, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2100\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]) == 85\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]) == 130\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 60\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 6000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\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\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 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]) == 160\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]) == 210\n assert candidate(nums = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200]) == 1049\n assert candidate(nums = [5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1000]) == 0\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]) == 88\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]) == 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]) == 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, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 4600\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == 110\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500]) == 199\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, 23, 54, 12, 19, 33, 8, 2, 99, 101, 102, 103, 104, 105, 106]) == 94\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 46\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, 100]) == 93\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986]) == 11\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014]) == 11\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700, -1800, -1900, -2000]) == 1600\n assert candidate(nums = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 199\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == 110\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 = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14]) == 25\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]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == 999996\n assert candidate(nums = [1, 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]) == 2199\n assert candidate(nums = [-1000000000, -900000000, -800000000, -700000000, -600000000, -500000000, -400000000, -300000000, -200000000, -100000000]) == 600000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 60\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == 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, 1000000000]) == 0\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == 600\n assert candidate(nums = [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, 3, 4, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 6\n assert candidate(nums = [1000000, 1000001, 1000002, 1000003, 1000004, -1000000, -1000001, -1000002, -1000003, -1000004]) == 2000005\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 110\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009, 500000010]) == 7\n", "comparison": "exact"}, "public_tests": ["[5,3,2,4]", "[1,5,0,10,14]", "[3,100,20]"], "hints": ["The minimum difference possible is obtained by removing three elements between the three smallest and three largest values in the array."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:15+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minDifference(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minDifference", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1510, "task_id": "stone-game-iv", "difficulty": "Hard", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\n\nInitially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.\n\nAlso, if a player cannot make a move, he/she loses the game.\n\nGiven a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.\n\nExample 1:\n\nInput: n = 1\nOutput: true\nExplanation: Alice can remove 1 stone winning the game because Bob doesn't have any moves.\n\nExample 2:\n\nInput: n = 2\nOutput: false\nExplanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).\n\nExample 3:\n\nInput: n = 4\nOutput: true\nExplanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0).\n\nConstraints:\n\n- 1 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == True\n assert candidate(n = 3) == True\n assert candidate(n = 100) == True\n assert candidate(n = 30) == True\n assert candidate(n = 5) == False\n assert candidate(n = 4) == True\n assert candidate(n = 200) == True\n assert candidate(n = 17) == False\n assert candidate(n = 2) == False\n assert candidate(n = 20) == False\n assert candidate(n = 1) == True\n assert candidate(n = 7) == False\n assert candidate(n = 10) == False\n assert candidate(n = 25) == True\n assert candidate(n = 50) == True\n assert candidate(n = 300) == True\n assert candidate(n = 123) == True\n assert candidate(n = 64) == True\n assert candidate(n = 16) == True\n assert candidate(n = 169) == True\n assert candidate(n = 81) == True\n assert candidate(n = 150) == False\n assert candidate(n = 55) == True\n assert candidate(n = 180) == False\n", "comparison": "exact"}, "public_tests": ["1", "2", "4"], "hints": ["Use dynamic programming to keep track of winning and losing states. Given some number of stones, Alice can win if she can force Bob onto a losing state."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().winnerSquareGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:18+00:00", "tests_total": 24, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "dynamic-programming", "minimax-algorithm", "game-theory", "nim-game", "sprague-grundy-theorem", "zero-sum-game"]}, "language": "python", "interface": {"raw_signature": "def winnerSquareGame(self, n: int) -> bool:", "container": "Solution", "callable": "winnerSquareGame", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1512, "task_id": "number-of-good-pairs", "difficulty": "Easy", "problem_description": "Given an array of integers nums, return the number of good pairs.\n\nA pair (i, j) is called good if nums[i] == nums[j] and i < j.\n\nExample 1:\n\nInput: nums = [1,2,3,1,1,3]\nOutput: 4\nExplanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.\n\nExample 2:\n\nInput: nums = [1,1,1,1]\nOutput: 6\nExplanation: Each pair in the array are good.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1]) == 6\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 = [7, 7, 7, 7, 7, 7, 7]) == 21\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [42, 42, 42, 42, 42]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums = [10, 10, 10]) == 3\n assert candidate(nums = [1, 3, 2, 3, 3, 4, 1]) == 4\n assert candidate(nums = [1, 2, 3, 1, 1, 3]) == 4\n assert candidate(nums = [1, 2, 1, 3, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [10, 20, 10, 10, 30, 20, 50, 20]) == 6\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [100, 100]) == 1\n assert candidate(nums = [1, 2, 1, 3, 2, 1]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == 21\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]) == 1653\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 63\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\n assert candidate(nums = [99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93]) == 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, 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, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 20\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 30]) == 8\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]) == 0\n assert candidate(nums = [100, 1, 2, 100, 2, 1, 100, 2, 1, 100]) == 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, 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]) == 150\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]) == 41\n assert candidate(nums = [1, 3, 2, 3, 2, 4, 2, 3, 4, 1, 4, 1, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\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]) == 3003\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 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, 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]) == 50\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 66\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]) == 84\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99, 98, 97, 96]) == 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]) == 30\n assert candidate(nums = [5, 6, 7, 5, 6, 5, 6, 7, 7]) == 9\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]) == 300\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 190\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 35\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 = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 45\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 40, 50]) == 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]) == 63\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == 59\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 30, 30]) == 7\n assert candidate(nums = [25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75]) == 84\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]) == 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]) == 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, 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]) == 2346\n assert candidate(nums = [10, 20, 30, 10, 10, 20, 30, 30, 30]) == 10\n assert candidate(nums = [99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95]) == 15\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 57\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]) == 165\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]) == 35\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\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\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 6\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, 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, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 36\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 40\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]) == 1711\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]) == 435\n assert candidate(nums = [10, 20, 10, 20, 10, 30, 20, 10]) == 9\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 190\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]) == 435\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\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 20, 10]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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]) == 30\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]) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == 435\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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == 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, 1]) == 33\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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1980\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, 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\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 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, 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\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 65\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 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, 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]) == 450\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 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]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 50\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]) == 105\n", "comparison": "exact"}, "public_tests": ["[1,2,3,1,1,3]", "[1,1,1,1]", "[1,2,3]"], "hints": ["Count how many times each number appears. If a number appears n times, then n * (n – 1) // 2 good pairs can be made with this number."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numIdenticalPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:20+00:00", "tests_total": 102, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "math", "counting"]}, "language": "python", "interface": {"raw_signature": "def numIdenticalPairs(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numIdenticalPairs", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1513, "task_id": "number-of-substrings-with-only-1s", "difficulty": "Medium", "problem_description": "Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: s = \"0110111\"\nOutput: 9\nExplanation: There are 9 substring in total with only 1's characters.\n\"1\" -> 5 times.\n\"11\" -> 3 times.\n\"111\" -> 1 time.\n\nExample 2:\n\nInput: s = \"101\"\nOutput: 2\nExplanation: Substring \"1\" is shown 2 times in s.\n\nExample 3:\n\nInput: s = \"111111\"\nOutput: 21\nExplanation: Each substring contains only 1's characters.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1100110011\") == 9\n assert candidate(s = \"101\") == 2\n assert candidate(s = \"1001001001\") == 4\n assert candidate(s = \"1111101111\") == 25\n assert candidate(s = \"110110110110110\") == 15\n assert candidate(s = \"000\") == 0\n assert candidate(s = \"111111\") == 21\n assert candidate(s = \"0110111\") == 9\n assert candidate(s = \"0\") == 0\n assert candidate(s = \"01010101010101010101\") == 10\n assert candidate(s = \"111000111000111\") == 18\n assert candidate(s = \"1001001\") == 3\n assert candidate(s = \"111011101110111\") == 24\n assert candidate(s = \"1111111111\") == 55\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"11111111111111111111\") == 210\n assert candidate(s = \"111100001111\") == 20\n assert candidate(s = \"1\") == 1\n assert candidate(s = \"1100110011001100110011\") == 18\n assert candidate(s = \"11110000111111110000111100001111111111110000\") == 134\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 3240\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111000111\") == 78\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == 41\n assert candidate(s = \"100100100100100100100100100100100100100100100100100100100100100100100100100100100\") == 27\n assert candidate(s = \"0111111111101111111111101111111111101111111111101111111111101111111111101111111111101111111111101111111111\") == 572\n assert candidate(s = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 24\n assert candidate(s = \"111111111100000000000000000000000000000000000000000000000000000000000000000000000001111111111\") == 110\n", "comparison": "exact"}, "public_tests": ["\"0110111\"", "\"101\"", "\"111111\""], "hints": ["Count number of 1s in each consecutive-1 group. For a group with n consecutive 1s, the total contribution of it to the final answer is (n + 1) * n // 2."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSub", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:22+00:00", "tests_total": 28, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def numSub(self, s: str) -> int:", "container": "Solution", "callable": "numSub", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1514, "task_id": "path-with-maximum-probability", "difficulty": "Medium", "problem_description": "You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i].\n\nGiven two nodes start and end, find the path with the maximum probability of success to go from start to end and return its success probability.\n\nIf there is no path from start to end, return 0. Your answer will be accepted if it differs from the correct answer by at most 1e-5.\n\nExample 1:\n\nInput: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.2], start = 0, end = 2\nOutput: 0.25000\nExplanation: There are two paths from start to end, one having a probability of success = 0.2 and the other has 0.5 * 0.5 = 0.25.\n\nExample 2:\n\nInput: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.3], start = 0, end = 2\nOutput: 0.30000\n\nExample 3:\n\nInput: n = 3, edges = [[0,1]], succProb = [0.5], start = 0, end = 2\nOutput: 0.00000\nExplanation: There is no path between 0 and 2.\n\nConstraints:\n\n- 2 <= n <= 10^4\n- 0 <= start, end < n\n- start != end\n- 0 <= a, b < n\n- a != b\n- 0 <= succProb.length == edges.length <= 2*10^4\n- 0 <= succProb[i] <= 1\n- There is at most one edge between every two nodes.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=4, edges=[[0, 1], [1, 2], [2, 3]], succProb=[0.1, 0.2, 0.3], start_node=0, end_node=3), 0.006000000000000001)\n assert answers_match(candidate(n=4, edges=[[0, 1], [1, 2], [2, 3]], succProb=[0.1, 0.9, 0.8], start_node=0, end_node=3), 0.07200000000000001)\n assert answers_match(candidate(n=5, edges=[[0, 1], [1, 2], [2, 3], [3, 4]], succProb=[0.5, 0.5, 0.5, 0.5], start_node=0, end_node=4), 0.0625)\n assert answers_match(candidate(n=7, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1], start_node=0, end_node=6), 1.0000000000000004e-06)\n assert answers_match(candidate(n=8, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1], start_node=0, end_node=7), 0.09000000000000001)\n assert answers_match(candidate(n=3, edges=[[0, 1], [1, 2], [0, 2]], succProb=[0.5, 0.5, 0.3], start_node=0, end_node=2), 0.3)\n assert answers_match(candidate(n=6, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5], start_node=0, end_node=5), 0.0012000000000000003)\n assert answers_match(candidate(n=3, edges=[[0, 1], [1, 2], [0, 2]], succProb=[0.5, 0.5, 0.2], start_node=0, end_node=2), 0.25)\n assert answers_match(candidate(n=5, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], start_node=0, end_node=4), 0.12)\n assert answers_match(candidate(n=4, edges=[[0, 1], [1, 2], [2, 3]], succProb=[0.1, 0.9, 0.5], start_node=0, end_node=3), 0.045000000000000005)\n assert answers_match(candidate(n=3, edges=[[0, 1]], succProb=[0.5], start_node=0, end_node=2), 0)\n assert answers_match(candidate(n=4, edges=[[0, 1], [1, 2], [2, 3]], succProb=[0.9, 0.8, 0.7], start_node=0, end_node=3), 0.504)\n assert answers_match(candidate(n=5, edges=[[0, 1], [1, 2], [2, 3], [3, 4]], succProb=[0.1, 0.9, 0.8, 0.2], start_node=0, end_node=4), 0.014400000000000003)\n assert answers_match(candidate(n=5, edges=[[0, 1], [1, 2], [0, 3], [3, 4]], succProb=[0.9, 0.8, 0.7, 0.6], start_node=0, end_node=2), 0.7200000000000001)\n assert answers_match(candidate(n=5, edges=[[0, 1], [1, 2], [3, 4]], succProb=[0.7, 0.8, 0.9], start_node=0, end_node=4), 0)\n assert answers_match(candidate(n=5, edges=[[0, 1], [1, 2], [2, 3], [3, 4]], succProb=[0.5, 0.4, 0.3, 0.2], start_node=0, end_node=4), 0.012)\n assert answers_match(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]], succProb=[0.01, 0.99, 0.02, 0.98, 0.03, 0.97, 0.04, 0.96, 0.05, 0.95, 0.06, 0.94, 0.07, 0.93], start_node=0, end_node=14), 3.7815442046807046e-11)\n assert answers_match(candidate(n=8, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8], start_node=1, end_node=7), 0.08000000000000002)\n assert answers_match(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]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], start_node=0, end_node=11), 0.3)\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]], succProb=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], start_node=0, end_node=5), 0.5)\n assert answers_match(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], [9, 14]], succProb=[0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5, 0.6, 0.6, 0.7, 0.7], start_node=0, end_node=14), 0.028000000000000004)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1], start_node=0, end_node=5), 0.03024)\n assert answers_match(candidate(n=7, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6]], succProb=[0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.99], start_node=0, end_node=6), 0.99)\n assert answers_match(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], [1, 6], [2, 7], [3, 8], [4, 9]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], start_node=0, end_node=9), 0.1)\n assert answers_match(candidate(n=8, edges=[[0, 1], [1, 2], [2, 3], [3, 0], [1, 4], [4, 5], [5, 6], [6, 7], [7, 4]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], start_node=0, end_node=6), 0.036000000000000004)\n assert answers_match(candidate(n=8, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]], succProb=[0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5], start_node=0, end_node=7), 0.015)\n assert answers_match(candidate(n=6, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1], start_node=0, end_node=5), 0.6)\n assert answers_match(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]], succProb=[0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05], start_node=0, end_node=19), 1.907348632812502e-25)\n assert answers_match(candidate(n=6, edges=[[0, 1], [0, 5], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7], start_node=0, end_node=4), 0.13999999999999999)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], succProb=[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], start_node=5, end_node=9), 0.0625)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], succProb=[0.99, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91], start_node=0, end_node=9), 0.6281565095552946)\n assert answers_match(candidate(n=8, edges=[[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]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8], start_node=0, end_node=6), 0.5599999999999999)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]], succProb=[0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5], start_node=0, end_node=9), 0.5)\n assert answers_match(candidate(n=7, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [1, 3], [2, 4], [3, 5]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.01], start_node=0, end_node=6), 0.7)\n assert answers_match(candidate(n=6, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 5]], succProb=[0.5, 0.5, 0.5, 0.5, 0.5, 0.5], start_node=0, end_node=5), 0.5)\n assert answers_match(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]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], start_node=0, end_node=19), 0.1)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], start_node=0, end_node=9), 0.0003628800000000001)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.9], start_node=0, end_node=9), 0.9)\n assert answers_match(candidate(n=10, edges=[[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]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2], start_node=0, end_node=9), 0.1)\n assert answers_match(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]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4], start_node=0, end_node=14), 0.048)\n assert answers_match(candidate(n=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]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5], start_node=0, end_node=9), 0.1)\n assert answers_match(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]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], start_node=0, end_node=19), 1.000000000000001e-19)\n assert answers_match(candidate(n=6, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [1, 3], [2, 4], [0, 4], [1, 5], [2, 5]], succProb=[0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.9, 0.9, 0.9, 0.9, 0.9], start_node=0, end_node=5), 0.7290000000000001)\n assert answers_match(candidate(n=6, edges=[[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], start_node=0, end_node=5), 0.108)\n assert answers_match(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]], succProb=[0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], start_node=0, end_node=14), 2.6127360000000006e-06)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], succProb=[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], start_node=0, end_node=9), 0.001953125)\n assert answers_match(candidate(n=6, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 3], [2, 5]], succProb=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3], start_node=0, end_node=5), 0.21600000000000003)\n assert answers_match(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, 14]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], start_node=0, end_node=14), 0.1)\n assert answers_match(candidate(n=7, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [1, 3], [2, 4], [3, 5]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1], start_node=0, end_node=6), 0.7)\n assert answers_match(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]], succProb=[0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18], start_node=0, end_node=14), 2.6676557107200007e-14)\n assert answers_match(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, 19]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.9], start_node=0, end_node=19), 0.9)\n assert answers_match(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]], succProb=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], start_node=0, end_node=5), 1.0000000000000004e-05)\n assert answers_match(candidate(n=10, edges=[[0, 9], [0, 8], [8, 9], [1, 7], [1, 6], [6, 7], [2, 5], [2, 4], [4, 5], [3, 0], [3, 1], [3, 2]], succProb=[0.1, 0.2, 0.15, 0.3, 0.4, 0.35, 0.5, 0.6, 0.55, 0.7, 0.8, 0.85], start_node=3, end_node=9), 0.06999999999999999)\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], succProb=[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], start_node=0, end_node=4), 0.0625)\n assert answers_match(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, 7], [7, 8], [8, 9], [9, 10], [10, 11]], succProb=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2], start_node=0, end_node=11), 0.024)\n assert answers_match(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]], succProb=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5], start_node=0, end_node=19), 6.584094720000003e-13)\n assert answers_match(candidate(n=7, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]], succProb=[0.01, 0.01, 0.01, 0.01, 0.01, 0.01], start_node=0, end_node=6), 1.0000000000000002e-12)\n assert answers_match(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, 10], [10, 15]], succProb=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.5, 0.3, 0.4], start_node=0, end_node=19), 0.03024)\n assert answers_match(candidate(n=8, edges=[[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]], succProb=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.15, 0.25, 0.35, 0.45], start_node=0, end_node=7), 0.2)\n assert answers_match(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]], succProb=[0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.99], start_node=0, end_node=11), 9.900000000000002e-21)\n assert answers_match(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]], succProb=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3], start_node=0, end_node=24), 0.3)\n", "comparison": "float"}, "public_tests": ["3\n[[0,1],[1,2],[0,2]]\n[0.5,0.5,0.2]\n0\n2", "3\n[[0,1],[1,2],[0,2]]\n[0.5,0.5,0.3]\n0\n2", "3\n[[0,1]]\n[0.5]\n0\n2"], "hints": ["Multiplying probabilities will result in precision errors.", "Take log probabilities to sum up numbers instead of multiplying them.", "Use Dijkstra's algorithm to find the minimum path between the two nodes after negating all costs."], "metadata": {"canonical_parameter_names": ["n", "edges", "succProb", "start_node", "end_node"], "leetcode_dataset_entry_point": "Solution().maxProbability", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:25+00:00", "tests_total": 69, "tests_dropped": 8, "flags": ["decimal_answer", "has_images"], "topic_tags": ["array", "graph", "heap-priority-queue", "shortest-path", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def maxProbability(self, n: int, edges: list[list[int]], succProb: list[float], start_node: int, end_node: int) -> float:", "container": "Solution", "callable": "maxProbability", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "succProb", "type": "list[float]"}, {"name": "start_node", "type": "int"}, {"name": "end_node", "type": "int"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1515, "task_id": "best-position-for-a-service-centre", "difficulty": "Hard", "problem_description": "A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum.\n\nGiven an array positions where positions[i] = [x_i, y_i] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.\n\nIn other words, you need to choose the position of the service center [x_centre, y_centre] such that the following formula is minimized:\n\nAnswers within 10^-5 of the actual value will be accepted.\n\nExample 1:\n\nInput: positions = [[0,1],[1,0],[1,2],[2,1]]\nOutput: 4.00000\nExplanation: As shown, you can see that choosing [x_centre, y_centre] = [1, 1] will make the distance to each customer = 1, the sum of all distances is 4 which is the minimum possible we can achieve.\n\nExample 2:\n\nInput: positions = [[1,1],[3,3]]\nOutput: 2.82843\nExplanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843\n\nConstraints:\n\n- 1 <= positions.length <= 50\n- positions[i].length == 2\n- 0 <= x_i, y_i <= 100\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(positions=[[1, 1], [1, 1], [1, 1], [1, 1]]), 0.0)\n assert answers_match(candidate(positions=[[50, 50], [51, 51], [49, 49]]), 2.8284271247461903)\n assert answers_match(candidate(positions=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), 8.485281374238571)\n assert answers_match(candidate(positions=[[2, 2], [2, 3], [3, 2], [3, 3]]), 2.8284271247461903)\n assert answers_match(candidate(positions=[[1, 2], [2, 3], [3, 4], [4, 5]]), 5.65685424949238)\n assert answers_match(candidate(positions=[[0, 0], [0, 1], [1, 0], [1, 1]]), 2.8284271247461903)\n assert answers_match(candidate(positions=[[5, 5], [5, 10], [10, 5], [10, 10]]), 14.142135623730951)\n assert answers_match(candidate(positions=[[1, 1], [3, 3]]), 2.8284271247461903)\n assert answers_match(candidate(positions=[[10, 10], [20, 20], [30, 30]]), 28.284271247461902)\n assert answers_match(candidate(positions=[[0, 0], [100, 100], [50, 50]]), 141.4213562373095)\n assert answers_match(candidate(positions=[[0, 1], [1, 0], [1, 2], [2, 1]]), 4.0)\n assert answers_match(candidate(positions=[[1, 1], [1, 1], [1, 1]]), 0.0)\n assert answers_match(candidate(positions=[[1, 1]]), 0.0)\n assert answers_match(candidate(positions=[[0, 0], [100, 100]]), 141.4213562373095)\n assert answers_match(candidate(positions=[[1, 1], [0, 0], [2, 2]]), 2.8284271247461903)\n assert answers_match(candidate(positions=[[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]), 0.0)\n assert answers_match(candidate(positions=[[0, 0], [0, 100], [100, 0], [100, 100]]), 282.842712474619)\n assert answers_match(candidate(positions=[[10, 20], [20, 30], [30, 40]]), 28.284271247461902)\n assert answers_match(candidate(positions=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), 8.485281374238571)\n assert answers_match(candidate(positions=[[50, 50], [40, 40], [30, 30], [20, 20], [10, 10]]), 84.8528137423857)\n assert answers_match(candidate(positions=[[2, 3], [3, 4], [4, 5], [5, 6]]), 5.65685424949238)\n assert answers_match(candidate(positions=[[10, 10], [20, 20], [30, 30], [40, 40]]), 56.568542494923804)\n assert answers_match(candidate(positions=[[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100]]), 250.0)\n assert answers_match(candidate(positions=[[10, 20], [20, 10], [30, 40], [40, 30], [50, 50]]), 92.03629479406317)\n assert answers_match(candidate(positions=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [0, 0]]), 424.26406871192853)\n assert answers_match(candidate(positions=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]), 35.35533905932737)\n assert answers_match(candidate(positions=[[0, 0], [100, 100], [20, 50], [80, 50], [50, 20], [50, 80], [30, 30], [70, 70], [40, 40], [60, 60]]), 346.2741699796952)\n assert answers_match(candidate(positions=[[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [10, 90], [90, 10], [50, 50], [25, 75], [75, 25]]), 364.54949915148427)\n assert answers_match(candidate(positions=[[5, 0], [0, 5], [5, 10], [10, 5], [0, 0], [10, 10]]), 34.14213562373095)\n assert answers_match(candidate(positions=[[1, 99], [2, 98], [3, 97], [4, 96], [5, 95], [96, 5], [97, 4], [98, 3], [99, 2], [100, 1]]), 668.2252698115078)\n assert answers_match(candidate(positions=[[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]]), 395.9797974644666)\n assert answers_match(candidate(positions=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 70.71067811865474)\n assert answers_match(candidate(positions=[[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [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.0)\n assert answers_match(candidate(positions=[[90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [0, 0]]), 353.5533905932738)\n assert answers_match(candidate(positions=[[1, 1], [2, 2], [3, 3], [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]]), 220.61731573020282)\n assert answers_match(candidate(positions=[[10, 90], [90, 10], [50, 50], [10, 10], [90, 90]]), 226.27416997969522)\n assert answers_match(candidate(positions=[[10, 10], [15, 25], [25, 30], [35, 40], [40, 50], [50, 60], [60, 70], [75, 85], [80, 90]]), 270.02810340103866)\n assert answers_match(candidate(positions=[[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]), 84.8528137423857)\n assert answers_match(candidate(positions=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]), 282.842712474619)\n assert answers_match(candidate(positions=[[10, 10], [20, 25], [30, 35], [40, 50], [50, 60], [60, 65], [70, 75], [80, 85], [90, 95], [100, 100]]), 347.5091699395884)\n assert answers_match(candidate(positions=[[10, 10], [10, 11], [11, 10], [11, 11], [50, 50], [50, 51], [51, 50], [51, 51], [90, 90], [90, 91], [91, 90], [91, 91]]), 455.39444406318626)\n assert answers_match(candidate(positions=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]), 79.19595949289332)\n assert answers_match(candidate(positions=[[1, 1], [1, 99], [99, 1], [99, 99], [25, 25], [25, 75], [75, 25], [75, 75], [50, 50]]), 418.60721446243616)\n assert answers_match(candidate(positions=[[25, 25], [75, 25], [25, 75], [75, 75], [50, 50], [25, 50], [50, 25], [50, 75]]), 216.42135624263756)\n assert answers_match(candidate(positions=[[20, 20], [20, 30], [20, 40], [20, 50], [20, 60], [20, 70], [20, 80], [20, 90], [20, 100], [20, 10]]), 250.0)\n assert answers_match(candidate(positions=[[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75]]), 353.5533905932738)\n assert answers_match(candidate(positions=[[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [5, 5], [100, 100]]), 417.1930016070778)\n assert answers_match(candidate(positions=[[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 10]]), 24.108834188712063)\n assert answers_match(candidate(positions=[[1, 2], [2, 3], [3, 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]]), 79.19595949289332)\n assert answers_match(candidate(positions=[[5, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]), 123.91362113238543)\n assert answers_match(candidate(positions=[[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [10, 90], [90, 10]]), 283.73687053280355)\n assert answers_match(candidate(positions=[[10, 50], [20, 40], [30, 30], [40, 20], [50, 10], [60, 20], [70, 30], [80, 40], [90, 50]]), 239.52812655611027)\n assert answers_match(candidate(positions=[[1, 99], [50, 50], [99, 1], [99, 99], [1, 1], [0, 0]]), 347.8965372098106)\n assert answers_match(candidate(positions=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 70.71067811865474)\n assert answers_match(candidate(positions=[[50, 0], [50, 100], [0, 50], [100, 50], [25, 25], [25, 75], [75, 25], [75, 75], [10, 10], [90, 90], [10, 90], [90, 10]]), 567.6955262170047)\n assert answers_match(candidate(positions=[[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]), 251.24689052802228)\n assert answers_match(candidate(positions=[[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]), 84.8528137423857)\n assert answers_match(candidate(positions=[[2, 3], [5, 6], [8, 9], [12, 15], [16, 18], [20, 21], [25, 26], [30, 33], [35, 36], [40, 41], [45, 46], [50, 51], [55, 56], [60, 61], [65, 66]]), 369.09298276151657)\n assert answers_match(candidate(positions=[[5, 5], [5, 10], [5, 15], [10, 5], [10, 10], [10, 15], [15, 5], [15, 10], [15, 15], [20, 20], [20, 30], [30, 20], [30, 30]]), 129.78753195123062)\n assert answers_match(candidate(positions=[[0, 5], [0, 10], [0, 15], [0, 20], [0, 25], [0, 30], [0, 35], [0, 40], [0, 45], [0, 50]]), 125.0)\n assert answers_match(candidate(positions=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 42.42640687119285)\n assert answers_match(candidate(positions=[[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]]), 226.27416997969522)\n assert answers_match(candidate(positions=[[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 90], [90, 80], [80, 70], [70, 60], [60, 50], [50, 40], [40, 30], [30, 20], [20, 10]]), 594.0883170846846)\n assert answers_match(candidate(positions=[[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25]]), 424.26406871192853)\n assert answers_match(candidate(positions=[[1, 99], [99, 1], [49, 50], [50, 49], [50, 50], [25, 25], [75, 75]]), 211.23672778921815)\n assert answers_match(candidate(positions=[[25, 25], [25, 75], [75, 25], [75, 75], [50, 50]]), 141.4213562373095)\n assert answers_match(candidate(positions=[[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]]), 707.1067811865476)\n assert answers_match(candidate(positions=[[10, 5], [20, 30], [50, 20], [30, 10], [70, 60], [80, 90]]), 207.8396049492494)\n assert answers_match(candidate(positions=[[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]), 282.842712474619)\n assert answers_match(candidate(positions=[[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25], [50, 25]]), 449.2640687173813)\n assert answers_match(candidate(positions=[[0, 0], [100, 100], [0, 100], [100, 0], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25], [40, 40], [60, 60], [60, 40], [40, 60]]), 480.83261120685233)\n assert answers_match(candidate(positions=[[10, 10], [90, 90], [10, 90], [90, 10], [50, 50], [25, 25], [75, 75], [30, 30], [70, 70], [40, 40], [60, 60]]), 381.8376618407357)\n assert answers_match(candidate(positions=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [10, 50], [50, 10], [25, 25], [35, 35], [45, 45]]), 176.7766958145084)\n assert answers_match(candidate(positions=[[10, 30], [20, 20], [30, 10], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]), 287.4326185352413)\n assert answers_match(candidate(positions=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 35.35533905932737)\n assert answers_match(candidate(positions=[[10, 50], [20, 40], [30, 30], [40, 20], [50, 10], [60, 20], [70, 30], [80, 40], [90, 50]]), 239.52812655611027)\n assert answers_match(candidate(positions=[[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]), 90.50966799187809)\n assert answers_match(candidate(positions=[[1, 1], [1, 99], [99, 1], [99, 99], [50, 50], [20, 20], [80, 80], [30, 30], [70, 70], [40, 40], [60, 60]]), 446.89148570989806)\n assert answers_match(candidate(positions=[[0, 0], [100, 0], [50, 50], [0, 100], [100, 100], [25, 75], [75, 25]]), 353.5533905932738)\n assert answers_match(candidate(positions=[[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, 4], [6, 5], [6, 6]]), 40.91242019857078)\n assert answers_match(candidate(positions=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [0, 0], [100, 100]]), 424.26406871192853)\n assert answers_match(candidate(positions=[[10, 20], [20, 10], [30, 40], [40, 30], [50, 10], [10, 50], [30, 20], [20, 30], [40, 20], [30, 10]]), 160.8040760315738)\n assert answers_match(candidate(positions=[[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]), 169.7056274847714)\n assert answers_match(candidate(positions=[[0, 0], [100, 100], [50, 50], [30, 70], [70, 30], [20, 20], [80, 80]]), 282.842712474619)\n assert answers_match(candidate(positions=[[10, 50], [20, 50], [30, 50], [40, 50], [50, 50], [60, 50], [70, 50], [80, 50], [90, 50]]), 200.0)\n assert answers_match(candidate(positions=[[20, 20], [40, 40], [60, 60], [80, 80], [10, 10], [30, 30], [50, 50], [70, 70], [90, 90]]), 282.842712474619)\n assert answers_match(candidate(positions=[[5, 0], [10, 0], [15, 0], [20, 0], [25, 0], [30, 0], [35, 0], [40, 0], [45, 0], [50, 0]]), 125.0)\n assert answers_match(candidate(positions=[[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]), 176.7766952966369)\n assert answers_match(candidate(positions=[[20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34]]), 70.71067811865476)\n assert answers_match(candidate(positions=[[25, 25], [50, 50], [75, 75], [25, 75], [75, 25], [50, 25], [50, 75], [25, 50], [75, 50]]), 241.4213562373095)\n assert answers_match(candidate(positions=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 36.909588067414894)\n assert answers_match(candidate(positions=[[0, 0], [50, 0], [0, 50], [50, 50], [25, 25], [10, 10], [40, 40], [30, 30], [20, 20], [15, 15]]), 212.13203493359106)\n assert answers_match(candidate(positions=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]), 282.842712474619)\n assert answers_match(candidate(positions=[[1, 1], [1, 99], [99, 1], [99, 99]]), 277.18585822512665)\n assert answers_match(candidate(positions=[[0, 0], [25, 25], [50, 50], [75, 75], [100, 100], [0, 100], [100, 0], [50, 0], [0, 50], [100, 50], [50, 100]]), 553.5533905932738)\n assert answers_match(candidate(positions=[[1, 1], [10, 1], [1, 10], [10, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [4, 4], [6, 6]]), 42.504733973998164)\n assert answers_match(candidate(positions=[[10, 10], [10, 10], [10, 10], [90, 90], [90, 90], [90, 90], [50, 50], [50, 50], [50, 50], [50, 50]]), 339.4112549695428)\n assert answers_match(candidate(positions=[[5, 10], [10, 5], [15, 10], [10, 15], [5, 20], [20, 5], [25, 10], [10, 25], [15, 20], [20, 15]]), 84.7585594020777)\n assert answers_match(candidate(positions=[[1, 1], [2, 3], [3, 1], [4, 5], [5, 3], [6, 7], [7, 5], [8, 9], [9, 7], [10, 11]]), 38.13182008152135)\n assert answers_match(candidate(positions=[[90, 10], [10, 90], [50, 50], [40, 60], [60, 40], [20, 80], [80, 20]]), 226.27416997969522)\n assert answers_match(candidate(positions=[[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]), 84.8528137423857)\n assert answers_match(candidate(positions=[[10, 50], [50, 10], [50, 50], [90, 50], [50, 90], [5, 5], [95, 95], [5, 95], [95, 5], [50, 25]]), 439.5584412326267)\n assert answers_match(candidate(positions=[[0, 0], [100, 100], [50, 50], [75, 25], [25, 75], [0, 100], [100, 0], [50, 100], [100, 50], [50, 0]]), 503.55339096524574)\n", "comparison": "float"}, "public_tests": ["[[0,1],[1,0],[1,2],[2,1]]", "[[1,1],[3,3]]"], "hints": ["The problem can be reworded as, giving a set of points on a 2d-plane, return the geometric median.", "Loop over each triplet of points (positions[i], positions[j], positions[k]) where i < j < k, get the centre of the circle which goes throw the 3 points, check if all other points lie in this circle."], "metadata": {"canonical_parameter_names": ["positions"], "leetcode_dataset_entry_point": "Solution().getMinDistSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:27+00:00", "tests_total": 104, "tests_dropped": 1, "flags": ["decimal_answer", "has_images"], "topic_tags": ["array", "math", "geometry", "randomized"]}, "language": "python", "interface": {"raw_signature": "def getMinDistSum(self, positions: list[list[int]]) -> float:", "container": "Solution", "callable": "getMinDistSum", "parameters": [{"name": "positions", "type": "list[list[int]]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1518, "task_id": "water-bottles", "difficulty": "Easy", "problem_description": "There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.\n\nThe operation of drinking a full water bottle turns it into an empty bottle.\n\nGiven the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.\n\nExample 1:\n\nInput: numBottles = 9, numExchange = 3\nOutput: 13\nExplanation: You can exchange 3 empty bottles to get 1 full water bottle.\nNumber of water bottles you can drink: 9 + 3 + 1 = 13.\n\nExample 2:\n\nInput: numBottles = 15, numExchange = 4\nOutput: 19\nExplanation: You can exchange 4 empty bottles to get 1 full water bottle.\nNumber of water bottles you can drink: 15 + 3 + 1 = 19.\n\nConstraints:\n\n- 1 <= numBottles <= 100\n- 2 <= numExchange <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numBottles = 10,numExchange = 2) == 19\n assert candidate(numBottles = 20,numExchange = 6) == 23\n assert candidate(numBottles = 100,numExchange = 10) == 111\n assert candidate(numBottles = 5,numExchange = 5) == 6\n assert candidate(numBottles = 15,numExchange = 4) == 19\n assert candidate(numBottles = 100,numExchange = 2) == 199\n assert candidate(numBottles = 9,numExchange = 3) == 13\n assert candidate(numBottles = 99,numExchange = 2) == 197\n assert candidate(numBottles = 98,numExchange = 14) == 105\n assert candidate(numBottles = 75,numExchange = 9) == 84\n assert candidate(numBottles = 80,numExchange = 10) == 88\n assert candidate(numBottles = 60,numExchange = 10) == 66\n assert candidate(numBottles = 30,numExchange = 15) == 32\n assert candidate(numBottles = 60,numExchange = 8) == 68\n assert candidate(numBottles = 85,numExchange = 3) == 127\n assert candidate(numBottles = 33,numExchange = 33) == 34\n assert candidate(numBottles = 80,numExchange = 7) == 93\n assert candidate(numBottles = 50,numExchange = 5) == 62\n assert candidate(numBottles = 77,numExchange = 14) == 82\n assert candidate(numBottles = 55,numExchange = 9) == 61\n assert candidate(numBottles = 80,numExchange = 12) == 87\n assert candidate(numBottles = 45,numExchange = 12) == 49\n assert candidate(numBottles = 72,numExchange = 8) == 82\n assert candidate(numBottles = 100,numExchange = 100) == 101\n assert candidate(numBottles = 25,numExchange = 11) == 27\n assert candidate(numBottles = 55,numExchange = 13) == 59\n assert candidate(numBottles = 100,numExchange = 9) == 112\n assert candidate(numBottles = 80,numExchange = 5) == 99\n assert candidate(numBottles = 25,numExchange = 3) == 37\n assert candidate(numBottles = 65,numExchange = 9) == 73\n assert candidate(numBottles = 5,numExchange = 6) == 5\n assert candidate(numBottles = 60,numExchange = 4) == 79\n assert candidate(numBottles = 45,numExchange = 9) == 50\n assert candidate(numBottles = 30,numExchange = 7) == 34\n assert candidate(numBottles = 75,numExchange = 8) == 85\n assert candidate(numBottles = 50,numExchange = 3) == 74\n assert candidate(numBottles = 55,numExchange = 11) == 60\n assert candidate(numBottles = 25,numExchange = 6) == 29\n assert candidate(numBottles = 1,numExchange = 2) == 1\n assert candidate(numBottles = 70,numExchange = 8) == 79\n assert candidate(numBottles = 30,numExchange = 4) == 39\n assert candidate(numBottles = 45,numExchange = 4) == 59\n assert candidate(numBottles = 64,numExchange = 8) == 73\n assert candidate(numBottles = 40,numExchange = 8) == 45\n assert candidate(numBottles = 50,numExchange = 7) == 58\n assert candidate(numBottles = 75,numExchange = 6) == 89\n assert candidate(numBottles = 99,numExchange = 9) == 111\n assert candidate(numBottles = 70,numExchange = 9) == 78\n assert candidate(numBottles = 99,numExchange = 7) == 115\n assert candidate(numBottles = 85,numExchange = 5) == 106\n assert candidate(numBottles = 81,numExchange = 9) == 91\n assert candidate(numBottles = 99,numExchange = 10) == 109\n assert candidate(numBottles = 88,numExchange = 11) == 96\n assert candidate(numBottles = 60,numExchange = 11) == 65\n assert candidate(numBottles = 60,numExchange = 12) == 65\n assert candidate(numBottles = 77,numExchange = 13) == 83\n assert candidate(numBottles = 45,numExchange = 7) == 52\n assert candidate(numBottles = 99,numExchange = 3) == 148\n assert candidate(numBottles = 65,numExchange = 15) == 69\n assert candidate(numBottles = 33,numExchange = 11) == 36\n assert candidate(numBottles = 45,numExchange = 3) == 67\n assert candidate(numBottles = 40,numExchange = 13) == 43\n assert candidate(numBottles = 99,numExchange = 5) == 123\n assert candidate(numBottles = 100,numExchange = 11) == 109\n assert candidate(numBottles = 90,numExchange = 6) == 107\n assert candidate(numBottles = 75,numExchange = 12) == 81\n assert candidate(numBottles = 30,numExchange = 6) == 35\n assert candidate(numBottles = 100,numExchange = 5) == 124\n assert candidate(numBottles = 40,numExchange = 15) == 42\n assert candidate(numBottles = 65,numExchange = 13) == 70\n assert candidate(numBottles = 90,numExchange = 4) == 119\n assert candidate(numBottles = 50,numExchange = 10) == 55\n assert candidate(numBottles = 80,numExchange = 4) == 106\n", "comparison": "exact"}, "public_tests": ["9\n3", "15\n4"], "hints": ["Simulate the process until there are not enough empty bottles for even one full bottle of water."], "metadata": {"canonical_parameter_names": ["numBottles", "numExchange"], "leetcode_dataset_entry_point": "Solution().numWaterBottles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:29+00:00", "tests_total": 73, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["math", "simulation"]}, "language": "python", "interface": {"raw_signature": "def numWaterBottles(self, numBottles: int, numExchange: int) -> int:", "container": "Solution", "callable": "numWaterBottles", "parameters": [{"name": "numBottles", "type": "int"}, {"name": "numExchange", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1519, "task_id": "number-of-nodes-in-the-sub-tree-with-the-same-label", "difficulty": "Medium", "problem_description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).\n\nThe edges array is given on the form edges[i] = [a_i, b_i], which means there is an edge between nodes a_i and b_i in the tree.\n\nReturn an array of size n where ans[i] is the number of nodes in the subtree of the i^th node which have the same label as node i.\n\nA subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.\n\nExample 1:\n\nInput: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = \"abaedcd\"\nOutput: [2,1,1,1,1,1,1]\nExplanation: Node 0 has label 'a' and its sub-tree has node 2 with label 'a' as well, thus the answer is 2. Notice that any node is part of its sub-tree.\nNode 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5, as nodes 4 and 5 have different labels than node 1, the answer is just 1 (the node itself).\n\nExample 2:\n\nInput: n = 4, edges = [[0,1],[1,2],[0,3]], labels = \"bbbb\"\nOutput: [4,2,1,1]\nExplanation: The sub-tree of node 2 contains only node 2, so the answer is 1.\nThe sub-tree of node 3 contains only node 3, so the answer is 1.\nThe sub-tree of node 1 contains nodes 1 and 2, both have label 'b', thus the answer is 2.\nThe sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b', thus the answer is 4.\n\nExample 3:\n\nInput: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = \"aabab\"\nOutput: [3,2,1,1,1]\n\nConstraints:\n\n- 1 <= n <= 10^5\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- labels.length == n\n- labels is consisting of only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [0, 3]],labels = \"bbbb\") == [4, 2, 1, 1]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],labels = \"cbabaa\") == [1, 2, 2, 1, 1, 1]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],labels = \"cbabac\") == [2, 2, 1, 1, 1, 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]],labels = \"aadbdbdbaa\") == [4, 3, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]],labels = \"aaa\") == [3, 1, 1]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [0, 4]],labels = \"aabab\") == [3, 2, 1, 1, 1]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 4], [1, 5], [2, 3], [2, 6]],labels = \"abaedcd\") == [2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],labels = \"aebabacd\") == [3, 1, 2, 1, 1, 1, 1, 1]\n assert candidate(n = 1,edges = [],labels = \"a\") == [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], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],labels = \"abacabadabacaba\") == [8, 2, 4, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\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]],labels = \"aabbccddeeffgghhiijj\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,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], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 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,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],labels = \"abcdefghij\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 21,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], [8, 20]],labels = \"ababababababababababa\") == [11, 5, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]],labels = \"bbbbbbbbbbbbbbbbbbbb\") == [20, 7, 7, 5, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]],labels = \"abcdefghij\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]],labels = \"bababbababababa\") == [8, 2, 3, 3, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,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], [4, 17], [5, 18], [5, 19], [6, 20], [6, 21], [6, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [10, 30], [10, 31], [11, 32], [11, 33], [11, 34], [12, 35], [12, 36], [13, 37], [13, 38], [13, 39]],labels = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == [40, 11, 11, 12, 5, 3, 4, 3, 4, 3, 3, 4, 3, 4, 1, 1, 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 = 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]],labels = \"abcabcabcabcabc\") == [5, 4, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [3, 8], [4, 9]],labels = \"aaaaaaaaaa\") == [10, 3, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(n = 26,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]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 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 = 26,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]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 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 = 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]],labels = \"aabbccddeeffgghh\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]],labels = \"aaaaaaaaaabbbbbbbbbb\") == [10, 6, 3, 3, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,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], [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], [10, 31], [10, 32], [10, 33], [11, 34], [11, 35], [11, 36], [12, 37], [12, 38], [12, 39]],labels = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == [40, 13, 13, 13, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 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 = 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]],labels = \"abababababababababab\") == [10, 4, 4, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]],labels = \"cccccccccccccccccccccccccccccc\") == [30, 15, 14, 7, 7, 7, 6, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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]],labels = \"aaaaaaaaaaaaaaaaaaaa\") == [20, 7, 7, 5, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\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], [8, 17]],labels = \"abcdefghijklmnopqr\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n", "comparison": "exact"}, "public_tests": ["7\n[[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]]\n\"abaedcd\"", "4\n[[0,1],[1,2],[0,3]]\n\"bbbb\"", "5\n[[0,1],[0,2],[1,3],[0,4]]\n\"aabab\""], "hints": ["Start traversing the tree and each node should return a vector to its parent node.", "The vector should be of length 26 and have the count of all the labels in the sub-tree of this node."], "metadata": {"canonical_parameter_names": ["n", "edges", "labels"], "leetcode_dataset_entry_point": "Solution().countSubTrees", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:32+00:00", "tests_total": 44, "tests_dropped": 15, "flags": ["has_images"], "topic_tags": ["hash-table", "tree", "depth-first-search", "breadth-first-search", "counting", "dp-on-trees"]}, "language": "python", "interface": {"raw_signature": "def countSubTrees(self, n: int, edges: list[list[int]], labels: str) -> list[int]:", "container": "Solution", "callable": "countSubTrees", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}, {"name": "labels", "type": "str"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1520, "task_id": "maximum-number-of-non-overlapping-substrings", "difficulty": "Hard", "problem_description": "Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions:\n\n1. The substrings do not overlap, that is for any two substrings s[i..j] and s[x..y], either j < x or i > y is true.\n2. A substring that contains a certain character c must also contain all occurrences of c.\n\nFind the maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings, return the one with minimum total length. It can be shown that there exists a unique solution of minimum total length.\n\nNotice that you can return the substrings in any order.\n\nExample 1:\n\nInput: s = \"adefaddaccc\"\nOutput: [\"e\",\"f\",\"ccc\"]\nExplanation: The following are all the possible substrings that meet the conditions:\n[\n \"adefaddaccc\"\n \"adefadda\",\n \"ef\",\n \"e\",\n \"f\",\n \"ccc\",\n]\nIf we choose the first string, we cannot choose anything else and we'd get only 1. If we choose \"adefadda\", we are left with \"ccc\" which is the only one that doesn't overlap, thus obtaining 2 substrings. Notice also, that it's not optimal to choose \"ef\" since it can be split into two. Therefore, the optimal way is to choose [\"e\",\"f\",\"ccc\"] which gives us 3 substrings. No other solution of the same number of substrings exist.\n\nExample 2:\n\nInput: s = \"abbaccd\"\nOutput: [\"d\",\"bb\",\"cc\"]\nExplanation: Notice that while the set of substrings [\"d\",\"abba\",\"cc\"] also has length 3, it's considered incorrect since it has larger total length.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(s='zazbzczdzezfzgzhzi'), ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])\n assert answers_match(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'])\n assert answers_match(candidate(s='aabbccaaaabbbbcccc'), ['aabbccaaaabbbbcccc'])\n assert answers_match(candidate(s='aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'), ['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', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'])\n assert answers_match(candidate(s='abcdcba'), ['d'])\n assert answers_match(candidate(s='aaaabaaaabaaaabaaaabaaaa'), ['aaaabaaaabaaaabaaaabaaaa'])\n assert answers_match(candidate(s='abababab'), ['abababab'])\n assert answers_match(candidate(s='aaaaa'), ['aaaaa'])\n assert answers_match(candidate(s='zzzzzzz'), ['zzzzzzz'])\n assert answers_match(candidate(s='abcdaabcdabdcabc'), ['abcdaabcdabdcabc'])\n assert answers_match(candidate(s='abcabcabc'), ['abcabcabc'])\n assert answers_match(candidate(s='adefaddaccc'), ['e', 'f', 'ccc'])\n assert answers_match(candidate(s='abcde'), ['a', 'b', 'c', 'd', 'e'])\n assert answers_match(candidate(s='aaa'), ['aaa'])\n assert answers_match(candidate(s='abcdabcdeabcd'), ['e'])\n assert answers_match(candidate(s='xyz'), ['x', 'y', 'z'])\n assert answers_match(candidate(s='ababababa'), ['ababababa'])\n assert answers_match(candidate(s='xyzxyzxyz'), ['xyzxyzxyz'])\n assert answers_match(candidate(s='mnopqrstuvmnopqrstuvmnopqrstuv'), ['mnopqrstuvmnopqrstuvmnopqrstuv'])\n assert answers_match(candidate(s='zzzzzzzzzz'), ['zzzzzzzzzz'])\n assert answers_match(candidate(s='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'), ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'])\n assert answers_match(candidate(s='cacaca'), ['cacaca'])\n assert answers_match(candidate(s='abbaccd'), ['bb', 'cc', 'd'])\n assert answers_match(candidate(s='zzzzyzxyz'), ['x'])\n assert answers_match(candidate(s='aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'), ['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'])\n assert answers_match(candidate(s='abcdefg'), ['a', 'b', 'c', 'd', 'e', 'f', 'g'])\n assert answers_match(candidate(s='aaaaaaaaaaabbbbbbbbbbccccccccccdddddddddeeeeeeeeeeffffffffffgggggggggg'), ['aaaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'ddddddddd', 'eeeeeeeeee', 'ffffffffff', 'gggggggggg'])\n assert answers_match(candidate(s='abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc'), ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc'])\n assert answers_match(candidate(s='abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc'), ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc'])\n assert answers_match(candidate(s='aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc'), ['aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc'])\n assert answers_match(candidate(s='abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd'), ['abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd'])\n assert answers_match(candidate(s='abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc'), ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc'])\n assert answers_match(candidate(s='zzzzzyyyyyxxxxwwwwvvvuuutttsssrqqppoonnnmmlkkjjiihhggffeedcba'), ['zzzzz', 'yyyyy', 'xxxx', 'wwww', 'vvv', 'uuu', 'ttt', 'sss', 'r', 'qq', 'pp', 'oo', 'nnn', 'mm', 'l', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'ee', 'd', 'c', 'b', 'a'])\n assert answers_match(candidate(s='mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbamnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba'), ['mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbamnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba'])\n assert answers_match(candidate(s='abracadabraacadabra'), ['abracadabraacadabra'])\n assert answers_match(candidate(s='abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'), ['abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'])\n assert answers_match(candidate(s='abacabadabcabaabacabadabcaba'), ['abacabadabcabaabacabadabcaba'])\n assert answers_match(candidate(s='abacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcaba'), ['abacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcaba'])\n assert answers_match(candidate(s='aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb'), ['aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb'])\n assert answers_match(candidate(s='mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv'), ['mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv'])\n assert answers_match(candidate(s='abababababababababababababababababababababababababababababababababababababababababababababababab'), ['abababababababababababababababababababababababababababababababababababababababababababababababab'])\n assert answers_match(candidate(s='abcabcabcabcabcabcabcabc'), ['abcabcabcabcabcabcabcabc'])\n assert answers_match(candidate(s='abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba'), ['zz'])\n assert answers_match(candidate(s='abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'), ['abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'])\n assert answers_match(candidate(s='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'), ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'])\n assert answers_match(candidate(s='abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef'), ['abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef'])\n assert answers_match(candidate(s='aababbabacabcabcadabcdeabcdeafaghafaiabakabalacamadanaeafaagaagaa'), ['h', 'i', 'k', 'l', 'm', 'n'])\n assert answers_match(candidate(s='xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'), ['xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'])\n assert answers_match(candidate(s='aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff'), ['aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff'])\n assert answers_match(candidate(s='aaaaaabbbbbccccdddddeeeee'), ['aaaaaa', 'bbbbb', 'cccc', 'ddddd', 'eeeee'])\n assert answers_match(candidate(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'])\n assert answers_match(candidate(s='aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhhiiiiiiiiijjjjjjjjkkkkkkkkkllllllllmmmmmmmmnnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssttttttttuuuuuuuuvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz'), ['aaaaaaaaaa', 'bbbbbbbb', 'cccccccc', 'dddddddd', 'eeeeeeee', 'ffffffff', 'gggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjj', 'kkkkkkkkk', 'llllllll', 'mmmmmmmm', 'nnnnnnnn', 'oooooooo', 'pppppppp', 'qqqqqqqq', 'rrrrrrrr', 'ssssssss', 'tttttttt', 'uuuuuuuu', 'vvvvvvvv', 'wwwwwwwww', 'xxxxxxxxx', 'yyyyyyyyy', 'zzzzzzzzz'])\n assert answers_match(candidate(s='aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'), ['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', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'])\n assert answers_match(candidate(s='zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz'), ['aa'])\n assert answers_match(candidate(s='xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'), ['xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'])\n assert answers_match(candidate(s='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'), ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'])\n assert answers_match(candidate(s='abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd'), ['abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd'])\n assert answers_match(candidate(s='abacabadabacabadabacabadabacabadabacabadabacabad'), ['abacabadabacabadabacabadabacabadabacabadabacabad'])\n assert answers_match(candidate(s='zzzzzyyyyyxxxxwwwwvvvvuuuuttttssssrrrrqqqqpppplllloooonnnnmmmm'), ['zzzzz', 'yyyyy', 'xxxx', 'wwww', 'vvvv', 'uuuu', 'tttt', 'ssss', 'rrrr', 'qqqq', 'pppp', 'llll', 'oooo', 'nnnn', 'mmmm'])\n", "comparison": "unordered"}, "public_tests": ["\"adefaddaccc\"", "\"abbaccd\""], "hints": ["Notice that it's impossible for any two valid substrings to overlap unless one is inside another.", "We can start by finding the starting and ending index for each character.", "From these indices, we can form the substrings by expanding each character's range if necessary (if another character exists in the range with smaller/larger starting/ending index).", "Sort the valid substrings by length and greedily take those with the smallest length, discarding the ones that overlap those we took."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxNumOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:34+00:00", "tests_total": 59, "tests_dropped": 0, "flags": ["any_order", "multiple_answers"], "topic_tags": ["hash-table", "string", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxNumOfSubstrings(self, s: str) -> list[str]:", "container": "Solution", "callable": "maxNumOfSubstrings", "parameters": [{"name": "s", "type": "str"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1521, "task_id": "find-a-value-of-a-mysterious-function-closest-to-target", "difficulty": "Hard", "problem_description": "Winston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible.\n\nReturn the minimum possible value of |func(arr, l, r) - target|.\n\nNotice that func should be called with the values l and r where 0 <= l, r < arr.length.\n\nExample 1:\n\nInput: arr = [9,12,3,7,15], target = 5\nOutput: 2\nExplanation: Calling func with all the pairs of [l,r] = [[0,0],[1,1],[2,2],[3,3],[4,4],[0,1],[1,2],[2,3],[3,4],[0,2],[1,3],[2,4],[0,3],[1,4],[0,4]], Winston got the following results [9,12,3,7,15,8,0,3,7,0,0,3,0,0,0]. The value closest to 5 is 7 and 3, thus the minimum difference is 2.\n\nExample 2:\n\nInput: arr = [1000000,1000000,1000000], target = 1\nOutput: 999999\nExplanation: Winston called the func with all possible values of [l,r] and he always got 1000000, thus the min difference is 999999.\n\nExample 3:\n\nInput: arr = [1,2,4,8,16], target = 0\nOutput: 0\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^6\n- 0 <= target <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7],target = 8) == 1\n assert candidate(arr = [1000000],target = 1000000) == 0\n assert candidate(arr = [2, 4, 6, 8, 10],target = 7) == 1\n assert candidate(arr = [5, 5, 5, 5, 5],target = 5) == 0\n assert candidate(arr = [1, 1, 1, 1, 1],target = 2) == 1\n assert candidate(arr = [1, 2, 4, 8, 16],target = 0) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],target = 25) == 5\n assert candidate(arr = [9, 12, 3, 7, 15],target = 5) == 2\n assert candidate(arr = [5, 5, 5, 5, 5],target = 3) == 2\n assert candidate(arr = [3, 6, 9, 12, 15],target = 13) == 1\n assert candidate(arr = [1000000, 1000000, 1000000],target = 1) == 999999\n assert candidate(arr = [2, 4, 6, 8, 10],target = 5) == 1\n assert candidate(arr = [1, 3, 5, 7, 9],target = 6) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 0) == 0\n assert candidate(arr = [7, 14, 21, 28, 35],target = 20) == 0\n assert candidate(arr = [3, 6, 9, 12, 15],target = 7) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],target = 0) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 15) == 5\n assert candidate(arr = [100, 200, 300, 400, 500],target = 250) == 6\n assert candidate(arr = [2, 4, 8, 16, 32],target = 10) == 2\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],target = 150) == 10\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 100) == 28\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 7) == 0\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 50000) == 15536\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 100) == 53\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180],target = 100) == 0\n assert candidate(arr = [16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1],target = 15) == 1\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 1) == 999983\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995],target = 1000000) == 0\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 100) == 28\n assert candidate(arr = [5, 3, 8, 12, 14, 2, 11],target = 10) == 1\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == 0\n assert candidate(arr = [9, 12, 3, 7, 15, 8, 6, 4, 2, 1],target = 5) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == 1\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 512) == 1\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 1) == 0\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],target = 10000) == 1809\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 1000) == 24\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = 100000) == 1696\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 3) == 2\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],target = 30) == 2\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],target = 22) == 2\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 1000) == 24\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 20) == 1\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1000) == 24\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 500) == 12\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 500) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],target = 10) == 1\n assert candidate(arr = [83552, 83552, 83552, 83552, 83552, 83552, 83552, 83552],target = 50000) == 33552\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 1) == 2\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],target = 50) == 1\n assert candidate(arr = [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046],target = 1024) == 2\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 5) == 2\n assert candidate(arr = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123, 133, 143, 153],target = 75) == 2\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 500000) == 499984\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 1) == 2\n assert candidate(arr = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004, 1003, 1002, 1001, 1000],target = 500) == 492\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 500) == 11\n assert candidate(arr = [31, 13, 7, 1, 9, 15, 8, 10, 18, 6],target = 12) == 1\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],target = 5000) == 0\n assert candidate(arr = [987654, 321654, 654321, 123456, 654123, 321987, 987321, 123654, 456789, 789123],target = 500000) == 43211\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 8190) == 2\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000],target = 350000) == 43216\n assert candidate(arr = [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],target = 50) == 1\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 0) == 0\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = 1000) == 24\n assert candidate(arr = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765],target = 500000) == 24288\n assert candidate(arr = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],target = 100) == 28\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],target = 10) == 1\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 100000) == 1696\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 200) == 55\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 511) == 1\n assert candidate(arr = [123456, 654321, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888],target = 333333) == 0\n assert candidate(arr = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],target = 1000000) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 27) == 2\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 4) == 3\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],target = 100000) == 1112\n assert candidate(arr = [1000000, 1000000, 1000000, 1, 1, 1, 2, 3, 4, 5],target = 1000005) == 5\n assert candidate(arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],target = 15) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33],target = 32) == 1\n assert candidate(arr = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 300) == 44\n assert candidate(arr = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999],target = 1) == 999998\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],target = 3) == 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],target = 5) == 0\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 10) == 2\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],target = 50) == 4\n assert candidate(arr = [123, 456, 789, 101, 112, 131, 44, 55, 66, 77, 88, 99],target = 200) == 56\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == 1\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256],target = 100) == 28\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 75) == 5\n assert candidate(arr = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876],target = 300000) == 3480\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 750) == 18\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255],target = 123) == 4\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 1000) == 24\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],target = 50) == 4\n assert candidate(arr = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 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, 50, 40, 30, 20, 10],target = 45000) == 4728\n assert candidate(arr = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234],target = 400000) == 54322\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],target = 1024) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 85) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],target = 50) == 50\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 7) == 0\n", "comparison": "exact"}, "public_tests": ["[9,12,3,7,15]\n5", "[1000000,1000000,1000000]\n1", "[1,2,4,8,16]\n0"], "hints": ["If the and value of sub-array arr[i...j] is ≥ the and value of the sub-array arr[i...j+1].", "For each index i using binary search or ternary search find the index j where |target - AND(arr[i...j])| is minimum, minimize this value with the global answer."], "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().closestToTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:36+00:00", "tests_total": 119, "tests_dropped": 14, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "bit-manipulation", "segment-tree", "sparse-table"]}, "language": "python", "interface": {"raw_signature": "def closestToTarget(self, arr: list[int], target: int) -> int:", "container": "Solution", "callable": "closestToTarget", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1523, "task_id": "count-odd-numbers-in-an-interval-range", "difficulty": "Easy", "problem_description": "Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).\n\nExample 1:\n\nInput: low = 3, high = 7\nOutput: 3\nExplanation: The odd numbers between 3 and 7 are [3,5,7].\n\nExample 2:\n\nInput: low = 8, high = 10\nOutput: 1\nExplanation: The odd numbers between 8 and 10 are [9].\n\nConstraints:\n\n- 0 <= low <= high <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 3,high = 7) == 3\n assert candidate(low = 0,high = 1000000000) == 500000000\n assert candidate(low = 0,high = 1) == 1\n assert candidate(low = 500000000,high = 500000000) == 0\n assert candidate(low = 1,high = 1000000000) == 500000000\n assert candidate(low = 8,high = 10) == 1\n assert candidate(low = 1000000000,high = 1000000000) == 0\n assert candidate(low = 1,high = 2) == 1\n assert candidate(low = 2,high = 3) == 1\n assert candidate(low = 0,high = 0) == 0\n assert candidate(low = 2,high = 2) == 0\n assert candidate(low = 1,high = 1) == 1\n assert candidate(low = 450000000,high = 450000010) == 5\n assert candidate(low = 3,high = 5) == 2\n assert candidate(low = 16,high = 17) == 1\n assert candidate(low = 500000001,high = 1000000000) == 250000000\n assert candidate(low = 2,high = 999999999) == 499999999\n assert candidate(low = 2,high = 4) == 1\n assert candidate(low = 15,high = 15) == 1\n assert candidate(low = 14,high = 24) == 5\n assert candidate(low = 499999998,high = 500000002) == 2\n assert candidate(low = 234567890,high = 987654321) == 376543216\n assert candidate(low = 20,high = 29) == 5\n assert candidate(low = 100000000,high = 999999999) == 450000000\n assert candidate(low = 99,high = 101) == 2\n assert candidate(low = 1,high = 10) == 5\n assert candidate(low = 800000000,high = 850000000) == 25000000\n assert candidate(low = 300,high = 400) == 50\n assert candidate(low = 25,high = 75) == 26\n assert candidate(low = 100,high = 200) == 50\n assert candidate(low = 123456,high = 654321) == 265433\n assert candidate(low = 45,high = 100) == 28\n assert candidate(low = 1,high = 999999999) == 500000000\n assert candidate(low = 9,high = 11) == 2\n assert candidate(low = 15,high = 25) == 6\n assert candidate(low = 333333333,high = 666666666) == 166666667\n assert candidate(low = 2,high = 21) == 10\n assert candidate(low = 0,high = 2) == 1\n assert candidate(low = 25,high = 35) == 6\n assert candidate(low = 11,high = 21) == 6\n assert candidate(low = 123456789,high = 987654321) == 432098767\n assert candidate(low = 1,high = 20) == 10\n assert candidate(low = 21,high = 31) == 6\n assert candidate(low = 100000001,high = 100000001) == 1\n assert candidate(low = 500000000,high = 500000002) == 1\n assert candidate(low = 10,high = 20) == 5\n assert candidate(low = 999999998,high = 999999999) == 1\n assert candidate(low = 5,high = 99) == 48\n assert candidate(low = 789012345,high = 789012345) == 1\n assert candidate(low = 15,high = 16) == 1\n assert candidate(low = 20,high = 30) == 5\n assert candidate(low = 5,high = 7) == 2\n assert candidate(low = 1,high = 3) == 2\n assert candidate(low = 999999999,high = 1000000000) == 1\n assert candidate(low = 500,high = 1500) == 500\n assert candidate(low = 500,high = 500000005) == 249999753\n assert candidate(low = 4,high = 6) == 1\n assert candidate(low = 100000000,high = 100000010) == 5\n assert candidate(low = 12,high = 22) == 5\n assert candidate(low = 9,high = 9) == 1\n assert candidate(low = 100000000,high = 900000000) == 400000000\n assert candidate(low = 100,high = 1000) == 450\n assert candidate(low = 1000000,high = 2000000) == 500000\n assert candidate(low = 5,high = 5) == 1\n assert candidate(low = 500000001,high = 500000005) == 3\n assert candidate(low = 123456,high = 789012) == 332778\n assert candidate(low = 5,high = 500000005) == 250000001\n assert candidate(low = 500,high = 600) == 50\n assert candidate(low = 888888888,high = 999999999) == 55555556\n assert candidate(low = 100000000,high = 200000000) == 50000000\n assert candidate(low = 13,high = 23) == 6\n assert candidate(low = 500000001,high = 600000000) == 50000000\n assert candidate(low = 10,high = 19) == 5\n assert candidate(low = 500000000,high = 1000000000) == 250000000\n assert candidate(low = 999999998,high = 1000000000) == 1\n assert candidate(low = 250000000,high = 750000000) == 250000000\n assert candidate(low = 499999999,high = 500000001) == 2\n assert candidate(low = 500000001,high = 500000001) == 1\n", "comparison": "exact"}, "public_tests": ["3\n7", "8\n10"], "hints": ["If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same.", "If the range (high - low + 1) is odd, the solution will depend on the parity of high and low."], "metadata": {"canonical_parameter_names": ["low", "high"], "leetcode_dataset_entry_point": "Solution().countOdds", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:38+00:00", "tests_total": 93, "tests_dropped": 15, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def countOdds(self, low: int, high: int) -> int:", "container": "Solution", "callable": "countOdds", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1524, "task_id": "number-of-sub-arrays-with-odd-sum", "difficulty": "Medium", "problem_description": "Given an array of integers arr, return the number of subarrays with an odd sum.\n\nSince the answer can be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: arr = [1,3,5]\nOutput: 4\nExplanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]\nAll sub-arrays sum are [1,4,9,3,8,5].\nOdd sums are [1,9,3,5] so the answer is 4.\n\nExample 2:\n\nInput: arr = [2,4,6]\nOutput: 0\nExplanation: All subarrays are [[2],[2,4],[2,4,6],[4],[4,6],[6]]\nAll sub-arrays sum are [2,6,12,4,10,6].\nAll sub-arrays have even sum and the answer is 0.\n\nExample 3:\n\nInput: arr = [1,2,3,4,5,6,7]\nOutput: 16\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr = [100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [50, 50, 50, 50, 50]) == 0\n assert candidate(arr = [1, 2, 3]) == 4\n assert candidate(arr = [2, 2, 2, 2, 2]) == 0\n assert candidate(arr = [1, 2]) == 2\n assert candidate(arr = [100, 100, 100]) == 0\n assert candidate(arr = [2, 4, 6]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7]) == 16\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 9\n assert candidate(arr = [100, 99, 98, 97, 96]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [2]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4]) == 14\n assert candidate(arr = [1, 3, 5]) == 4\n assert candidate(arr = [97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78]) == 110\n assert candidate(arr = [99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1]) == 110\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 462\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 30\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 30\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 30\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 64\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, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 30\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 30\n assert candidate(arr = [97, 2, 83, 4, 81, 6, 79, 8, 77, 10, 75, 12, 73, 14, 71, 16, 69, 18, 67, 20]) == 110\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 110\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 30\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 64\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 63\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == 12\n assert candidate(arr = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 30\n assert candidate(arr = [97, 98, 99, 100, 1, 2, 3, 4, 5, 6]) == 30\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 30\n assert candidate(arr = [50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51]) == 110\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\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, 59]) == 240\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 240\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 28\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 240\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 110\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(arr = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 36\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 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]) == 110\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 110\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 63\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 110\n assert candidate(arr = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 64\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 64\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 110\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 64\n assert candidate(arr = [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]) == 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, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 310\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 52\n assert candidate(arr = [100, 99, 1, 2, 98, 3, 4, 97, 5, 6]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 110\n assert candidate(arr = [1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21]) == 110\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 110\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]) == 420\n", "comparison": "exact"}, "public_tests": ["[1,3,5]", "[2,4,6]", "[1,2,3,4,5,6,7]"], "hints": ["Can we use the accumulative sum to keep track of all the odd-sum sub-arrays ?", "if the current accu sum is odd, we care only about previous even accu sums and vice versa."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:41+00:00", "tests_total": 87, "tests_dropped": 17, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numOfSubarrays(self, arr: list[int]) -> int:", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1525, "task_id": "number-of-good-ways-to-split-a-string", "difficulty": "Medium", "problem_description": "You are given a string s.\n\nA split is called good if you can split s into two non-empty strings s_left and s_right where their concatenation is equal to s (i.e., s_left + s_right = s) and the number of distinct letters in s_left and s_right is the same.\n\nReturn the number of good splits you can make in s.\n\nExample 1:\n\nInput: s = \"aacaba\"\nOutput: 2\nExplanation: There are 5 ways to split \"aacaba\" and 2 of them are good.\n(\"a\", \"acaba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aa\", \"caba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aac\", \"aba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aaca\", \"ba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aacab\", \"a\") Left string and right string contains 3 and 1 different letters respectively.\n\nExample 2:\n\nInput: s = \"abcd\"\nOutput: 1\nExplanation: Split the string as follows (\"ab\", \"cd\").\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 4\n assert candidate(s = \"aabbcc\") == 1\n assert candidate(s = \"abcde\") == 0\n assert candidate(s = \"abcdefghij\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"abacaba\") == 0\n assert candidate(s = \"aacaba\") == 2\n assert candidate(s = \"aabbbcc\") == 2\n assert candidate(s = \"aaa\") == 2\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"aaaaa\") == 4\n assert candidate(s = \"xyz\") == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabbccddeeff\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 45\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzxywvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabacadaeafagahaiajakalalamanaoaopapaqaraasatauavaawaxayaza\") == 0\n assert candidate(s = \"ababababababababababababababababababababababababab\") == 47\n assert candidate(s = \"abacabadabacabadabacabad\") == 12\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 1\n assert candidate(s = \"aaaaaabbccdddeeffggghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababab\") == 77\n assert candidate(s = \"nnnnaaaaccccbbbbbddddnnnnaaaaccccbbbbbdddd\") == 7\n assert candidate(s = \"thisisaverylongstringwithavarietyofcharactersandrepeatpatterns\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 27\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqq\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abbaccddeeffaabbccddeeff\") == 3\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 1\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadab\") == 84\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 89\n assert candidate(s = \"abracadabra\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 25\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppp\") == 47\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 73\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 63\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuutsrrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == 1\n assert candidate(s = \"mississississississippi\") == 16\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == 20\n assert candidate(s = \"pppppppppppppppppppppppppppppp\") == 29\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 61\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewqasdfghjklzxcvbnmmnbvcxzlkjhgfdsapoiuytrewq\") == 17\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 68\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 1\n assert candidate(s = \"mississippimississippimississippimississippimississippi\") == 36\n assert candidate(s = \"bacaabacababacaacbacaaacaaacaacbaaaacaacaaacaacaaacaaacaa\") == 29\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 77\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(s = \"abracadabraabracadabraabracadabraabracadabraabracadabraabracadabra\") == 53\n assert candidate(s = \"abbaccddeeffaabbccddeeffaabbccddeeff\") == 15\n assert candidate(s = \"nnnnaaaaccccbbbbbdddd\") == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 79\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aaabbbcccddd\") == 1\n assert candidate(s = \"abababababababababababababababababababababababababababa\") == 52\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 81\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcde\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 73\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\") == 21\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 49\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 53\n assert candidate(s = \"aabbaabbaabbaabb\") == 11\n", "comparison": "exact"}, "public_tests": ["\"aacaba\"", "\"abcd\""], "hints": ["Use two HashMap to store the counts of distinct letters in the left and right substring divided by the current index."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSplits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:43+00:00", "tests_total": 81, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming", "bit-manipulation", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numSplits(self, s: str) -> int:", "container": "Solution", "callable": "numSplits", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1526, "task_id": "minimum-number-of-increments-on-subarrays-to-form-a-target-array", "difficulty": "Hard", "problem_description": "You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.\n\nIn one operation you can choose any subarray from initial and increment each value by one.\n\nReturn the minimum number of operations to form a target array from initial.\n\nThe test cases are generated so that the answer fits in a 32-bit integer.\n\nExample 1:\n\nInput: target = [1,2,3,2,1]\nOutput: 3\nExplanation: We need at least 3 operations to form the target array from the initial array.\n[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).\n[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).\n[1,2,2,2,1] increment 1 at index 2.\n[1,2,3,2,1] target array is formed.\n\nExample 2:\n\nInput: target = [3,1,1,2]\nOutput: 4\nExplanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]\n\nExample 3:\n\nInput: target = [3,1,5,4,2]\nOutput: 7\nExplanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].\n\nConstraints:\n\n- 1 <= target.length <= 10^5\n- 1 <= target[i] <= 10^5\n- The input is generated such that the answer fits inside a 32 bit integer.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = [5, 4, 3, 2, 1]) == 5\n assert candidate(target = [100000]) == 100000\n assert candidate(target = [1, 1, 1, 1, 1]) == 1\n assert candidate(target = [1, 3, 2, 4, 5]) == 6\n assert candidate(target = [10, 10, 10, 10, 10]) == 10\n assert candidate(target = [3, 1, 5, 4, 2]) == 7\n assert candidate(target = [1, 100000, 1]) == 100000\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(target = [3, 1, 1, 2]) == 4\n assert candidate(target = [1, 3, 5, 7, 9]) == 9\n assert candidate(target = [100000, 100000, 100000, 100000, 100000]) == 100000\n assert candidate(target = [1, 2, 3, 2, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = [9, 7, 5, 3, 1]) == 9\n assert candidate(target = [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]) == 13\n assert candidate(target = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 9\n assert candidate(target = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(target = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 3\n assert candidate(target = [10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 19\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 7\n assert candidate(target = [3, 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]) == 41\n assert candidate(target = [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]) == 19\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(target = [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\n assert candidate(target = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 13\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(target = [1, 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, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 5\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(target = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(target = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5]) == 9\n assert candidate(target = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(target = [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\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 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\n assert candidate(target = [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]) == 19\n assert candidate(target = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 300\n assert candidate(target = [1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 7\n assert candidate(target = [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, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50, 100, 50, 100, 50]) == 200\n assert candidate(target = [1, 2, 3, 4, 5, 6, 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(target = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 50\n assert candidate(target = [5, 10, 15, 20, 25, 20, 15, 10, 5]) == 25\n assert candidate(target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(target = [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]) == 15\n assert candidate(target = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(target = [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]) == 19\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 13\n assert candidate(target = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [5, 5, 5, 5, 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(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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(target = [1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == 10\n assert candidate(target = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]) == 4\n assert candidate(target = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1]) == 13\n assert candidate(target = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(target = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]) == 15\n assert candidate(target = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == 19\n assert candidate(target = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 7\n assert candidate(target = [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(target = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(target = [10, 1, 20, 30, 40, 50, 40, 30, 20, 10]) == 59\n assert candidate(target = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == 51\n assert candidate(target = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 90\n assert candidate(target = [1, 2, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 6\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(target = [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, 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]) == 10\n assert candidate(target = [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]) == 20\n assert candidate(target = [1, 5, 2, 5, 1, 5, 2, 5, 1, 5, 2, 5, 1, 5, 2, 5, 1]) == 29\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 5\n assert candidate(target = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 46\n assert candidate(target = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 46\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 6\n assert candidate(target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 5\n assert candidate(target = [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]) == 100\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 90\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 11\n assert candidate(target = [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(target = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5]) == 7\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 19\n assert candidate(target = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 25\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 14\n", "comparison": "exact"}, "public_tests": ["[1,2,3,2,1]", "[3,1,1,2]", "[3,1,5,4,2]"], "hints": ["For a given range of values in target, an optimal strategy is to increment the entire range by the minimum value. The minimum in a range could be obtained with Range minimum query or Segment trees algorithm."], "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().minNumberOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:46+00:00", "tests_total": 105, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "dynamic-programming", "stack", "greedy", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def minNumberOperations(self, target: list[int]) -> int:", "container": "Solution", "callable": "minNumberOperations", "parameters": [{"name": "target", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1528, "task_id": "shuffle-string", "difficulty": "Easy", "problem_description": "You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the i^th position moves to indices[i] in the shuffled string.\n\nReturn the shuffled string.\n\nExample 1:\n\nInput: s = \"codeleet\", indices = [4,5,6,7,0,2,1,3]\nOutput: \"leetcode\"\nExplanation: As shown, \"codeleet\" becomes \"leetcode\" after shuffling.\n\nExample 2:\n\nInput: s = \"abc\", indices = [0,1,2]\nOutput: \"abc\"\nExplanation: After shuffling, each character remains in its position.\n\nConstraints:\n\n- s.length == indices.length == n\n- 1 <= n <= 100\n- s consists of only lowercase English letters.\n- 0 <= indices[i] < n\n- All values of indices are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"codeleet\",indices = [4, 5, 6, 7, 0, 2, 1, 3]) == \"leetcode\"\n assert candidate(s = \"aaiougrt\",indices = [4, 0, 2, 6, 7, 3, 1, 5]) == \"arigatou\"\n assert candidate(s = \"aiohn\",indices = [3, 1, 4, 2, 0]) == \"nihao\"\n assert candidate(s = \"abc\",indices = [0, 1, 2]) == \"abc\"\n assert candidate(s = \"art\",indices = [1, 0, 2]) == \"rat\"\n assert candidate(s = \"abcdefgh\",indices = [7, 6, 5, 4, 3, 2, 1, 0]) == \"hgfedcba\"\n assert candidate(s = \"permutation\",indices = [8, 5, 4, 10, 0, 9, 2, 6, 3, 1, 7]) == \"uoairetnptm\"\n assert candidate(s = \"development\",indices = [3, 6, 5, 1, 0, 4, 8, 9, 2, 7, 10]) == \"leedovenpmt\"\n assert candidate(s = \"exampleinput\",indices = [11, 2, 5, 0, 8, 1, 6, 7, 4, 3, 9, 10]) == \"mlxpnaeipute\"\n assert candidate(s = \"abcdefghij\",indices = [5, 8, 1, 6, 7, 0, 3, 2, 9, 4]) == \"fchgjadebi\"\n assert candidate(s = \"abcdefgxyz\",indices = [6, 1, 7, 5, 8, 0, 9, 4, 3, 2]) == \"fbzyxdaceg\"\n assert candidate(s = \"pneumonia\",indices = [2, 8, 7, 6, 5, 4, 3, 1, 0]) == \"aipnomuen\"\n assert candidate(s = \"randomization\",indices = [4, 1, 5, 0, 2, 7, 8, 6, 3, 9, 10, 11, 12]) == \"daoarnzmition\"\n assert candidate(s = \"character\",indices = [8, 4, 2, 5, 6, 1, 0, 7, 3]) == \"tcarhraec\"\n assert candidate(s = \"fqtv\",indices = [1, 3, 2, 0]) == \"vftq\"\n assert candidate(s = \"visualization\",indices = [10, 1, 9, 12, 0, 2, 8, 4, 6, 7, 11, 3, 5]) == \"ailoznatisviu\"\n assert candidate(s = \"waterbottle\",indices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 0, 10]) == \"ltobretawte\"\n assert candidate(s = \"shuffle\",indices = [4, 2, 5, 1, 6, 3, 0]) == \"efhlsuf\"\n assert candidate(s = \"intermediate\",indices = [11, 8, 2, 0, 7, 3, 4, 9, 1, 6, 5, 10]) == \"eitmetarndei\"\n assert candidate(s = \"programming\",indices = [10, 2, 1, 7, 8, 6, 5, 3, 0, 9, 4]) == \"iormgmagrnp\"\n assert candidate(s = \"alphabet\",indices = [5, 6, 7, 4, 3, 2, 1, 0]) == \"tebahalp\"\n assert candidate(s = \"permutation\",indices = [1, 10, 9, 0, 8, 6, 3, 5, 4, 2, 7]) == \"mpoaittnure\"\n assert candidate(s = \"shuffling\",indices = [8, 4, 3, 5, 7, 2, 6, 1, 0]) == \"gnluhfifs\"\n assert candidate(s = \"exampleinput\",indices = [11, 4, 0, 7, 8, 3, 5, 6, 2, 9, 1, 10]) == \"aunlxeimppte\"\n assert candidate(s = \"generation\",indices = [5, 3, 6, 7, 2, 1, 8, 0, 4, 9]) == \"iareognetn\"\n assert candidate(s = \"xylophone\",indices = [1, 4, 8, 2, 7, 5, 3, 6, 0]) == \"exooyhnpl\"\n assert candidate(s = \"uniquecharacters\",indices = [12, 1, 13, 2, 0, 15, 5, 14, 4, 7, 11, 6, 8, 10, 9, 3]) == \"unqsaccrtreauihe\"\n assert candidate(s = \"complexstringshuffle\",indices = [15, 6, 11, 19, 8, 1, 0, 12, 18, 5, 2, 3, 10, 13, 17, 14, 4, 16, 7, 9]) == \"xeinfrollegmssucfhtp\"\n assert candidate(s = \"alphanumeric\",indices = [9, 5, 7, 3, 4, 8, 10, 0, 11, 2, 1, 6]) == \"mirhalcpnaue\"\n assert candidate(s = \"abracadabra\",indices = [10, 6, 5, 3, 0, 9, 7, 8, 2, 1, 4]) == \"crbaarbdaaa\"\n assert candidate(s = \"python\",indices = [4, 0, 1, 5, 3, 2]) == \"ytnoph\"\n assert candidate(s = \"algorithm\",indices = [1, 2, 3, 0, 4, 5, 6, 7, 8]) == \"oalgrithm\"\n assert candidate(s = \"characters\",indices = [9, 3, 0, 7, 5, 2, 1, 6, 4, 8]) == \"atchraersc\"\n assert candidate(s = \"python\",indices = [5, 1, 2, 4, 0, 3]) == \"oytnhp\"\n assert candidate(s = \"algorithmdesign\",indices = [8, 12, 1, 10, 9, 13, 0, 5, 2, 4, 3, 6, 7, 11, 14]) == \"tgmedhsiaroglin\"\n assert candidate(s = \"randomized\",indices = [7, 1, 8, 2, 0, 4, 5, 9, 6, 3]) == \"oaddmiernz\"\n assert candidate(s = \"complex\",indices = [6, 4, 1, 2, 5, 0, 3]) == \"empxolc\"\n assert candidate(s = \"jumble\",indices = [3, 0, 5, 4, 2, 1]) == \"ueljbm\"\n assert candidate(s = \"rearrange\",indices = [8, 4, 3, 0, 5, 2, 7, 6, 1]) == \"reaaergnr\"\n assert candidate(s = \"algorithm\",indices = [5, 1, 4, 0, 2, 7, 6, 8, 3]) == \"olrmgatih\"\n assert candidate(s = \"randomization\",indices = [12, 1, 6, 5, 0, 11, 10, 9, 8, 7, 4, 3, 2]) == \"oanoidntazimr\"\n assert candidate(s = \"continuous\",indices = [1, 6, 5, 9, 0, 3, 7, 4, 8, 2]) == \"icsnonouut\"\n assert candidate(s = \"shufflingstring\",indices = [11, 7, 9, 6, 13, 2, 0, 10, 1, 12, 3, 4, 5, 8, 14]) == \"igltrifhnunssfg\"\n assert candidate(s = \"complexity\",indices = [3, 6, 1, 5, 2, 0, 7, 4, 9, 8]) == \"emlcipoxyt\"\n assert candidate(s = \"rearrange\",indices = [3, 7, 5, 2, 8, 0, 4, 1, 6]) == \"agrrnaeer\"\n assert candidate(s = \"python\",indices = [3, 1, 5, 0, 2, 4]) == \"hyopnt\"\n assert candidate(s = \"algorithm\",indices = [1, 0, 6, 4, 2, 5, 3, 7, 8]) == \"lartoighm\"\n assert candidate(s = \"algorithm\",indices = [6, 4, 3, 0, 5, 2, 1, 8, 7]) == \"otiglramh\"\n assert candidate(s = \"permutation\",indices = [8, 5, 1, 6, 7, 3, 9, 2, 0, 4, 10]) == \"irttoemupan\"\n assert candidate(s = \"scrambled\",indices = [3, 2, 0, 6, 7, 4, 1, 5, 8]) == \"rlcsbeamd\"\n assert candidate(s = \"shuffling\",indices = [1, 3, 6, 8, 0, 2, 5, 4, 7]) == \"fslhniugf\"\n assert candidate(s = \"vivid\",indices = [2, 0, 4, 3, 1]) == \"idviv\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",indices = [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]) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"zkrw\",indices = [2, 3, 0, 1]) == \"rwzk\"\n assert candidate(s = \"randomize\",indices = [3, 8, 0, 5, 4, 7, 2, 6, 1]) == \"neirodzma\"\n assert candidate(s = \"jumbledtext\",indices = [9, 0, 5, 3, 8, 6, 1, 2, 7, 4, 10]) == \"udtbxmeeljt\"\n assert candidate(s = \"environment\",indices = [1, 7, 4, 6, 2, 0, 3, 8, 10, 5, 9]) == \"oernvninmte\"\n assert candidate(s = \"characters\",indices = [6, 2, 9, 5, 7, 4, 1, 0, 3, 8]) == \"ethrcrcasa\"\n assert candidate(s = \"jfbm\",indices = [3, 0, 1, 2]) == \"fbmj\"\n", "comparison": "exact"}, "public_tests": ["\"codeleet\"\n[4,5,6,7,0,2,1,3]", "\"abc\"\n[0,1,2]"], "hints": ["You can create an auxiliary string t of length n.", "Assign t[indexes[i]] to s[i] for each i from 0 to n-1."], "metadata": {"canonical_parameter_names": ["s", "indices"], "leetcode_dataset_entry_point": "Solution().restoreString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:48+00:00", "tests_total": 61, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def restoreString(self, s: str, indices: list[int]) -> str:", "container": "Solution", "callable": "restoreString", "parameters": [{"name": "s", "type": "str"}, {"name": "indices", "type": "list[int]"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1529, "task_id": "minimum-suffix-flips", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.\n\nIn one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.\n\nReturn the minimum number of operations needed to make s equal to target.\n\nExample 1:\n\nInput: target = \"10111\"\nOutput: 3\nExplanation: Initially, s = \"00000\".\nChoose index i = 2: \"00000\" -> \"00111\"\nChoose index i = 0: \"00111\" -> \"11000\"\nChoose index i = 1: \"11000\" -> \"10111\"\nWe need at least 3 flip operations to form target.\n\nExample 2:\n\nInput: target = \"101\"\nOutput: 3\nExplanation: Initially, s = \"000\".\nChoose index i = 0: \"000\" -> \"111\"\nChoose index i = 1: \"111\" -> \"100\"\nChoose index i = 2: \"100\" -> \"101\"\nWe need at least 3 flip operations to form target.\n\nExample 3:\n\nInput: target = \"00000\"\nOutput: 0\nExplanation: We do not need any operations since the initial s already equals target.\n\nConstraints:\n\n- n == target.length\n- 1 <= n <= 10^5\n- target[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = \"00000\") == 0\n assert candidate(target = \"00110\") == 2\n assert candidate(target = \"1100110011\") == 5\n assert candidate(target = \"000111000111\") == 3\n assert candidate(target = \"001100\") == 2\n assert candidate(target = \"10001\") == 3\n assert candidate(target = \"010101010101010101\") == 17\n assert candidate(target = \"001001001\") == 5\n assert candidate(target = \"1111111111\") == 1\n assert candidate(target = \"0000000000\") == 0\n assert candidate(target = \"01010\") == 4\n assert candidate(target = \"101\") == 3\n assert candidate(target = \"11001100\") == 4\n assert candidate(target = \"10010\") == 4\n assert candidate(target = \"11001\") == 3\n assert candidate(target = \"10111\") == 3\n assert candidate(target = \"001100110011\") == 5\n assert candidate(target = \"111100001111\") == 3\n assert candidate(target = \"11111\") == 1\n assert candidate(target = \"1001010\") == 6\n assert candidate(target = \"010101\") == 5\n assert candidate(target = \"1001001\") == 5\n assert candidate(target = \"0101010101\") == 9\n assert candidate(target = \"110011\") == 3\n assert candidate(target = \"111000111\") == 3\n assert candidate(target = \"10101010101010101010\") == 20\n assert candidate(target = \"000011110000111100001111\") == 5\n assert candidate(target = \"011010101010101010101010\") == 22\n assert candidate(target = \"10101010101010101010101010101010\") == 32\n assert candidate(target = \"110011001100110\") == 8\n assert candidate(target = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10001000100010001000\") == 10\n assert candidate(target = \"101010101010101010101010101010101010101010101010\") == 48\n assert candidate(target = \"000111000111000\") == 4\n assert candidate(target = \"1001001001\") == 7\n assert candidate(target = \"1111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"01010101010101010101\") == 19\n assert candidate(target = \"1001001001001001001001001001001001001001\") == 27\n assert candidate(target = \"1010101010101010101010101010\") == 28\n assert candidate(target = \"00000111110000011111\") == 3\n assert candidate(target = \"0000000000111111111100000000001111111111\") == 3\n assert candidate(target = \"11111111111111111111111111\") == 1\n assert candidate(target = \"1010101010101010101010101010101010101010101010101010\") == 52\n assert candidate(target = \"000000000000000000000001\") == 1\n assert candidate(target = \"1100110011001100110011001100\") == 14\n assert candidate(target = \"00000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"00000000000000000000000000\") == 0\n assert candidate(target = \"00110011001100110011\") == 9\n assert candidate(target = \"1111111111111111111111111111\") == 1\n assert candidate(target = \"11111111111111111110\") == 2\n assert candidate(target = \"11000000000000000001\") == 3\n assert candidate(target = \"111111111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"101010101010101010101010101010101010\") == 36\n assert candidate(target = \"0101010101010101010101010101\") == 27\n assert candidate(target = \"110110110110110110110110110110\") == 20\n assert candidate(target = \"111100001111000011110000\") == 6\n assert candidate(target = \"000111000111000111000111\") == 7\n assert candidate(target = \"100110011001100110011001\") == 13\n assert candidate(target = \"01010101010101010101010101010101010101\") == 37\n assert candidate(target = \"000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10010010010010010010010010010010010010010010010010\") == 34\n assert candidate(target = \"1001001001001001001001001001001001001001001001001\") == 33\n assert candidate(target = \"01100110011001100110\") == 10\n assert candidate(target = \"11110000111100001111\") == 5\n assert candidate(target = \"111000111000111000111000\") == 8\n assert candidate(target = \"11111000001111100000111110000011111000001111100000\") == 10\n assert candidate(target = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10101010101010101010101010\") == 26\n assert candidate(target = \"11001100110011001100110011\") == 13\n assert candidate(target = \"00110011001100110011001100110011001100110011001100\") == 24\n assert candidate(target = \"0111111111111111111111111111\") == 1\n assert candidate(target = \"01010101010101010101010101\") == 25\n assert candidate(target = \"11111000000000000000\") == 2\n assert candidate(target = \"1000000000000000000000000000\") == 2\n assert candidate(target = \"11111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"00000111110000011111000001111100000111110000011111\") == 9\n assert candidate(target = \"01001001001001001001001001001001\") == 21\n assert candidate(target = \"11111000001111100000\") == 4\n assert candidate(target = \"00000000000000000001\") == 1\n assert candidate(target = \"11011011011011011011\") == 13\n assert candidate(target = \"001001001001001001001001\") == 15\n assert candidate(target = \"11001100110011001100110011001100110011001100110011\") == 25\n assert candidate(target = \"001100110011001100110011001100110011001100110011\") == 23\n assert candidate(target = \"11001100110011001100110011001100\") == 16\n assert candidate(target = \"1001001001001001001001001001\") == 19\n assert candidate(target = \"00001111000011110000\") == 4\n assert candidate(target = \"111000111000111000111000111000111000111000111000111000111000111000\") == 22\n assert candidate(target = \"111111111111111111111111111111111111\") == 1\n assert candidate(target = \"0101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(target = \"00000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"01110111011101110111\") == 9\n assert candidate(target = \"0110110110\") == 6\n assert candidate(target = \"00000111111111111111\") == 1\n assert candidate(target = \"000111000111000111\") == 5\n assert candidate(target = \"000011110000\") == 2\n assert candidate(target = \"11111111111111111111111111111111111111111111111110\") == 2\n assert candidate(target = \"01001001001001001001\") == 13\n assert candidate(target = \"111111111111111111111110\") == 2\n assert candidate(target = \"101010101010101010\") == 18\n assert candidate(target = \"100101010101010101010101\") == 23\n assert candidate(target = \"00000000001111111111000000000011111111110000000000\") == 4\n assert candidate(target = \"010101010101010101010101010101\") == 29\n assert candidate(target = \"0101010101010101010101010101010101\") == 33\n assert candidate(target = \"000000000000000000000000000000\") == 0\n assert candidate(target = \"01010101010101010101010101010101010101010101010101\") == 49\n assert candidate(target = \"0011001100110011001100110011\") == 13\n assert candidate(target = \"11001100110011001100\") == 10\n assert candidate(target = \"00001111111111110000\") == 2\n assert candidate(target = \"01001001001001001001001001001001001001001001001001\") == 33\n assert candidate(target = \"00000000001111111111\") == 1\n assert candidate(target = \"01001001001001001001001001001001001001001001\") == 29\n assert candidate(target = \"01010101010101010101010101010101\") == 31\n assert candidate(target = \"0000000000000000000000000000\") == 0\n assert candidate(target = \"11111111110000000000\") == 2\n assert candidate(target = \"110011001100110011\") == 9\n assert candidate(target = \"10010010010010010010\") == 14\n assert candidate(target = \"11111111111111111111\") == 1\n", "comparison": "exact"}, "public_tests": ["\"10111\"", "\"101\"", "\"00000\""], "hints": ["Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left."], "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:50+00:00", "tests_total": 117, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minFlips(self, target: str) -> int:", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "target", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1531, "task_id": "string-compression-ii", "difficulty": "Hard", "problem_description": "Run-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compress the string \"aabccc\" we replace \"aa\" by \"a2\" and replace \"ccc\" by \"c3\". Thus the compressed string becomes \"a2bc3\".\n\nNotice that in this problem, we are not adding '1' after single characters.\n\nGiven a string s and an integer k. You need to delete at most k characters from s such that the run-length encoded version of s has minimum length.\n\nFind the minimum length of the run-length encoded version of s after deleting at most k characters.\n\nExample 1:\n\nInput: s = \"aaabcccd\", k = 2\nOutput: 4\nExplanation: Compressing s without deleting anything will give us \"a3bc3d\" of length 6. Deleting any of the characters 'a' or 'c' would at most decrease the length of the compressed string to 5, for instance delete 2 'a' then we will have s = \"abcccd\" which compressed is abc3d. Therefore, the optimal way is to delete 'b' and 'd', then the compressed version of s will be \"a3c3\" of length 4.\n\nExample 2:\n\nInput: s = \"aabbaa\", k = 2\nOutput: 2\nExplanation: If we delete both 'b' characters, the resulting compressed string would be \"a4\" of length 2.\n\nExample 3:\n\nInput: s = \"aaaaaaaaaaa\", k = 0\nOutput: 3\nExplanation: Since k is zero, we cannot delete anything. The compressed string is \"a11\" of length 3.\n\nConstraints:\n\n- 1 <= s.length <= 100\n- 0 <= k <= s.length\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcabcabc\",k = 5) == 3\n assert candidate(s = \"aaabcccd\",k = 2) == 4\n assert candidate(s = \"aabcc\",k = 1) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == 32\n assert candidate(s = \"aabccabcc\",k = 2) == 5\n assert candidate(s = \"nnnhoorq\",k = 2) == 5\n assert candidate(s = \"aaaaaaaaaaa\",k = 0) == 3\n assert candidate(s = \"aabbaa\",k = 2) == 2\n assert candidate(s = \"abbbcccaaaa\",k = 3) == 5\n assert candidate(s = \"abbbabbbcabbbabbbb\",k = 3) == 6\n assert candidate(s = \"aabbccddeeff\",k = 6) == 6\n assert candidate(s = \"abababababababababababababababababababab\",k = 15) == 12\n assert candidate(s = \"a\",k = 0) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aabbbcccbbaa\",k = 3) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"abcdabcdabcd\",k = 6) == 5\n assert candidate(s = \"a\",k = 1) == 0\n assert candidate(s = \"aabbcc\",k = 1) == 5\n assert candidate(s = \"aabcccccaaa\",k = 2) == 5\n assert candidate(s = \"abcde\",k = 2) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 15) == 21\n assert candidate(s = \"aabbccddeeff\",k = 4) == 8\n assert candidate(s = \"abcdefghijaaaaaaaaaaaaaa\",k = 5) == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 23\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 25) == 64\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 30) == 14\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 35) == 18\n assert candidate(s = \"mississippi\",k = 3) == 6\n assert candidate(s = \"aaaaaabbbbccccddddeeeeffffgggghhhh\",k = 8) == 12\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 15) == 58\n assert candidate(s = \"abacabadabacaba\",k = 5) == 6\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\",k = 30) == 25\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 3\n assert candidate(s = \"aaabbbcccddddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwww\",k = 30) == 26\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbcccccccccccdddddddddd\",k = 20) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 5) == 8\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\",k = 10) == 75\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzz\",k = 10) == 18\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 53\n assert candidate(s = \"aaabaaaacaaadaaaeaaafaaagaaahaaaiaaa\",k = 10) == 3\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 25) == 26\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 3\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde\",k = 25) == 60\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 10) == 16\n assert candidate(s = \"abababababab\",k = 3) == 7\n assert candidate(s = \"zzzzzyyyyyxxxyyyxxxxzzzzzzz\",k = 15) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 20) == 55\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 26\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 15) == 15\n assert candidate(s = \"ppppppppppqqqqqqqqqqrrrrrrrrrrsssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\",k = 50) == 3\n assert candidate(s = \"abbbcccdddeeeeeffgggghhhiiijjjjj\",k = 10) == 12\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 3\n assert candidate(s = \"aabbaacccaaadd\",k = 4) == 6\n assert candidate(s = \"abbbccccddee\",k = 4) == 5\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababab\",k = 20) == 50\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccccccddddddddeeeeeeeeeffffffffgggggggghhhhhhhhiiiiiiiiijjjjjjj\",k = 25) == 14\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 30) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 27\n assert candidate(s = \"ababababababababababababababababababababab\",k = 10) == 24\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 15) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 3\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == 24\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 30) == 26\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 20) == 59\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\",k = 12) == 13\n assert candidate(s = \"wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\",k = 45) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 0) == 52\n assert candidate(s = \"abcdefg\",k = 3) == 4\n assert candidate(s = \"aabbaabbaabbaabbaabbaabb\",k = 10) == 4\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 20) == 52\n assert candidate(s = \"abababababababababababababab\",k = 10) == 10\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 50) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzz\",k = 40) == 13\n assert candidate(s = \"aaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaa\",k = 10) == 11\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbcccccdddddeeeeeeeeeeee\",k = 20) == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 15) == 37\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee\",k = 10) == 10\n assert candidate(s = \"ppppppqqqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrsssssssssssttttttttttt\",k = 30) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\",k = 10) == 8\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggg\",k = 25) == 10\n", "comparison": "exact"}, "public_tests": ["\"aaabcccd\"\n2", "\"aabbaa\"\n2", "\"aaaaaaaaaaa\"\n0"], "hints": ["Use dynamic programming.", "The state of the DP can be the current index and the remaining characters to delete.", "Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getLengthOfOptimalCompression", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:55+00:00", "tests_total": 84, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "dynamic-programming"]}, "language": "python", "interface": {"raw_signature": "def getLengthOfOptimalCompression(self, s: str, k: int) -> int:", "container": "Solution", "callable": "getLengthOfOptimalCompression", "parameters": [{"name": "s", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1534, "task_id": "count-good-triplets", "difficulty": "Easy", "problem_description": "Given an array of integers arr, and three integers a, b and c. You need to find the number of good triplets.\n\nA triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true:\n\n- 0 <= i < j < k < arr.length\n- |arr[i] - arr[j]| <= a\n- |arr[j] - arr[k]| <= b\n- |arr[i] - arr[k]| <= c\n\nWhere |x| denotes the absolute value of x.\n\nReturn the number of good triplets.\n\nExample 1:\n\nInput: arr = [3,0,1,1,9,7], a = 7, b = 2, c = 3\nOutput: 4\nExplanation: There are 4 good triplets: [(3,0,1), (3,0,1), (3,1,1), (0,1,1)].\n\nExample 2:\n\nInput: arr = [1,1,2,2,3], a = 0, b = 0, c = 1\nOutput: 0\nExplanation: No triplet satisfies all conditions.\n\nConstraints:\n\n- 3 <= arr.length <= 100\n- 0 <= arr[i] <= 1000\n- 0 <= a, b, c <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 0, 1, 1, 9, 7],a = 7,b = 2,c = 3) == 4\n assert candidate(arr = [1, 3, 5, 7, 9],a = 2,b = 3,c = 4) == 3\n assert candidate(arr = [1, 1, 2, 2, 3],a = 0,b = 0,c = 1) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 5,b = 10,c = 15) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 15,b = 25,c = 35) == 5\n assert candidate(arr = [0, 0, 0, 0, 0],a = 0,b = 0,c = 0) == 10\n assert candidate(arr = [10, 20, 30, 40, 50],a = 15,b = 15,c = 15) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 10,b = 10,c = 10) == 0\n assert candidate(arr = [1, 3, 5, 7, 9],a = 2,b = 2,c = 2) == 0\n assert candidate(arr = [0, 0, 0, 0, 0],a = 1,b = 1,c = 1) == 10\n assert candidate(arr = [0, 0, 0, 0],a = 1,b = 1,c = 1) == 4\n assert candidate(arr = [1, 5, 6, 8, 10, 14, 15, 18, 20, 22],a = 4,b = 3,c = 5) == 8\n assert candidate(arr = [5, 8, 12, 15, 19, 22, 25, 28, 31, 34],a = 5,b = 7,c = 10) == 14\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],a = 1,b = 1,c = 2) == 88\n assert candidate(arr = [5, 8, 12, 15, 18, 22, 25, 28, 31],a = 5,b = 5,c = 10) == 7\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],a = 2,b = 2,c = 4) == 44\n assert candidate(arr = [10, 20, 20, 20, 30, 40, 50, 60, 70, 80],a = 5,b = 5,c = 10) == 1\n assert candidate(arr = [7, 1, 5, 3, 6, 4, 2, 8, 9],a = 2,b = 3,c = 4) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],a = 2,b = 2,c = 2) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],a = 0,b = 0,c = 0) == 1140\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],a = 150,b = 250,c = 350) == 13\n assert candidate(arr = [5, 8, 12, 15, 20, 22, 25],a = 5,b = 6,c = 7) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 10,b = 20,c = 30) == 25\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],a = 5,b = 10,c = 15) == 25\n assert candidate(arr = [5, 8, 8, 10, 15, 17],a = 5,b = 3,c = 8) == 5\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33],a = 4,b = 4,c = 8) == 7\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],a = 1,b = 1,c = 2) == 54\n assert candidate(arr = [15, 10, 15, 10, 15, 10, 15],a = 5,b = 5,c = 10) == 35\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 200,c = 300) == 15\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0],a = 100,b = 200,c = 300) == 17\n assert candidate(arr = [9, 7, 5, 3, 1, 2, 4, 6, 8, 0],a = 1,b = 2,c = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 2,b = 2,c = 3) == 37\n assert candidate(arr = [7, 3, 19, 5, 11, 13, 17, 15, 2, 9],a = 6,b = 5,c = 10) == 24\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],a = 1,b = 1,c = 2) == 132\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],a = 2,b = 3,c = 4) == 58\n assert candidate(arr = [5, 8, 2, 3, 6, 9, 10, 12],a = 3,b = 4,c = 5) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 1,b = 2,c = 3) == 25\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],a = 100,b = 100,c = 100) == 0\n assert candidate(arr = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600],a = 50,b = 100,c = 150) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 150,b = 200,c = 250) == 8\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 20,b = 30,c = 40) == 64\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],a = 5,b = 5,c = 5) == 120\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 0,b = 0,c = 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 3,b = 3,c = 3) == 324\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],a = 1,b = 1,c = 2) == 120\n assert candidate(arr = [4, 9, 1, 3, 13, 12, 7],a = 6,b = 4,c = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 2,c = 4) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 1,b = 1,c = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [8, 12, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 10,c = 15) == 15\n assert candidate(arr = [5, 8, 12, 15, 16, 20, 25, 30],a = 7,b = 5,c = 10) == 12\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],a = 4,b = 8,c = 12) == 15\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],a = 0,b = 0,c = 0) == 455\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],a = 4,b = 8,c = 12) == 25\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4],a = 0,b = 0,c = 0) == 84\n assert candidate(arr = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 1,b = 1,c = 2) == 9\n assert candidate(arr = [2, 5, 1, 2, 10, 9, 10, 6],a = 4,b = 4,c = 7) == 15\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 0,b = 0,c = 0) == 455\n assert candidate(arr = [5, 3, 7, 8, 2, 1, 9, 6, 4, 10],a = 5,b = 5,c = 5) == 60\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],a = 10,b = 20,c = 30) == 166\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 9,b = 19,c = 29) == 0\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],a = 4,b = 5,c = 6) == 0\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 5,b = 5,c = 5) == 60\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],a = 15,b = 15,c = 20) == 8\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 10,b = 10,c = 10) == 120\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 3,c = 5) == 8\n assert candidate(arr = [1, 5, 3, 2, 4, 8, 7, 6, 9, 0],a = 3,b = 3,c = 5) == 34\n assert candidate(arr = [34, 23, 54, 28, 90, 56, 78, 45, 12, 67],a = 20,b = 25,c = 30) == 15\n assert candidate(arr = [50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 5,b = 10,c = 15) == 17\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 1,b = 1,c = 1) == 120\n assert candidate(arr = [7, 3, 8, 1, 4, 6, 5, 2, 9, 0],a = 1,b = 1,c = 2) == 3\n assert candidate(arr = [15, 15, 15, 20, 20, 20, 25, 25, 25],a = 5,b = 5,c = 10) == 66\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],a = 0,b = 0,c = 0) == 1140\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],a = 1,b = 1,c = 2) == 100\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 10,b = 20,c = 30) == 15\n assert candidate(arr = [5, 8, 2, 4, 3, 7, 6, 9, 1],a = 3,b = 4,c = 5) == 35\n assert candidate(arr = [30, 40, 50, 60, 70, 80, 90, 100, 110],a = 10,b = 10,c = 20) == 7\n assert candidate(arr = [2, 2, 2, 2, 2],a = 0,b = 0,c = 0) == 10\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 15,b = 25,c = 35) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [1, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 4,b = 5,c = 6) == 214\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],a = 10,b = 10,c = 20) == 8\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],a = 4,b = 6,c = 8) == 11\n assert candidate(arr = [8, 1, 3, 2, 10, 1, 4],a = 1,b = 2,c = 3) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 150,c = 200) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10],a = 3,b = 3,c = 4) == 152\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],a = 15,b = 20,c = 25) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10],a = 1,b = 1,c = 2) == 112\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],a = 3,b = 4,c = 5) == 0\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 1,b = 2,c = 3) == 15\n assert candidate(arr = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],a = 1,b = 1,c = 2) == 124\n assert candidate(arr = [5, 1, 4, 1, 3, 6, 2],a = 2,b = 3,c = 5) == 14\n assert candidate(arr = [5, 8, 12, 15, 16, 23, 42],a = 5,b = 7,c = 10) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 0,b = 0,c = 0) == 0\n", "comparison": "exact"}, "public_tests": ["[3,0,1,1,9,7]\n7\n2\n3", "[1,1,2,2,3]\n0\n0\n1"], "hints": ["Notice that the constraints are small enough for a brute force solution to pass.", "Loop through all triplets, and count the ones that are good."], "metadata": {"canonical_parameter_names": ["arr", "a", "b", "c"], "leetcode_dataset_entry_point": "Solution().countGoodTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:22:57+00:00", "tests_total": 101, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:", "container": "Solution", "callable": "countGoodTriplets", "parameters": [{"name": "arr", "type": "List[int]"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1535, "task_id": "find-the-winner-of-an-array-game", "difficulty": "Medium", "problem_description": "Given an integer array arr of distinct integers and an integer k.\n\nA game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.\n\nReturn the integer which will win the game.\n\nIt is guaranteed that there will be a winner of the game.\n\nExample 1:\n\nInput: arr = [2,1,3,5,4,6,7], k = 2\nOutput: 5\nExplanation: Let's see the rounds of the game:\nRound | arr | winner | win_count\n 1 | [2,1,3,5,4,6,7] | 2 | 1\n 2 | [2,3,5,4,6,7,1] | 3 | 1\n 3 | [3,5,4,6,7,1,2] | 5 | 1\n 4 | [5,4,6,7,1,2,3] | 5 | 2\nSo we can see that 4 rounds will be played and 5 is the winner because it wins 2 consecutive games.\n\nExample 2:\n\nInput: arr = [3,2,1], k = 10\nOutput: 3\nExplanation: 3 will win the first 10 rounds consecutively.\n\nConstraints:\n\n- 2 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^6\n- arr contains distinct integers.\n- 1 <= k <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 1, 3, 5, 4, 6, 7],k = 2) == 5\n assert candidate(arr = [7, 10, 5, 3, 8],k = 3) == 10\n assert candidate(arr = [5, 4, 3, 2, 1],k = 1) == 5\n assert candidate(arr = [3, 2, 1],k = 10) == 3\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 100\n assert candidate(arr = [5, 1, 4, 2, 3],k = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 2\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],k = 3) == 7\n assert candidate(arr = [7, 6, 5, 8, 4, 3, 2, 1],k = 4) == 8\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],k = 7) == 10\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],k = 7) == 999999\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 4, 6],k = 4) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == 19\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 2) == 7\n assert candidate(arr = [500000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 10) == 500000\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 1) == 3\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 50) == 100\n assert candidate(arr = [2, 1, 3, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3) == 20\n assert candidate(arr = [7, 14, 28, 8, 16, 32, 4, 2, 1],k = 6) == 32\n assert candidate(arr = [1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1000000\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1000000) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\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) == 200\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 3\n assert candidate(arr = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 19\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 3) == 20\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 10) == 10\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 7) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8) == 20\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 = 15) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 19\n assert candidate(arr = [5, 8, 4, 9, 3, 2, 1, 6, 7, 10],k = 6) == 9\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 100\n assert candidate(arr = [100, 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 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 100\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],k = 6) == 1000000\n assert candidate(arr = [4, 8, 6, 2, 7, 3, 9, 1, 5, 10],k = 6) == 10\n assert candidate(arr = [50, 20, 30, 10, 40],k = 3) == 50\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 500000],k = 10) == 500000\n assert candidate(arr = [5, 1, 4, 3, 2],k = 4) == 5\n assert candidate(arr = [5, 2, 9, 1, 7, 8, 3, 6, 4],k = 5) == 9\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 7) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 7) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 30\n assert candidate(arr = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],k = 3) == 50\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 7) == 30\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 4) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 10\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 10) == 1000000\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 5) == 1000000\n assert candidate(arr = [9, 3, 5, 2, 8, 1, 7, 6, 4, 10],k = 2) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 3) == 5\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) == 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],k = 15) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 19\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 2) == 9\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989],k = 10) == 100000\n assert candidate(arr = [5, 1, 4, 2, 3],k = 4) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 4) == 5\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15],k = 8) == 15\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 = 15) == 30\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 = 20) == 30\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 4) == 7\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 3) == 100\n assert candidate(arr = [5, 3, 8, 6, 7, 2, 4, 9, 1],k = 4) == 8\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 1) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 10\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8],k = 5) == 7\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97],k = 3) == 100\n assert candidate(arr = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11],k = 5) == 89\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 5) == 20\n assert candidate(arr = [1, 25, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 25\n assert candidate(arr = [7, 14, 4, 14, 13, 2, 6, 13],k = 3) == 14\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == 2\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],k = 3) == 5\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 1000\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, 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 = 25) == 100\n assert candidate(arr = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],k = 10) == 99\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 15\n assert candidate(arr = [23, 11, 45, 78, 90, 67, 34, 21, 56, 89],k = 4) == 90\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 9) == 1000\n assert candidate(arr = [7, 10, 4, 3, 20, 15, 6, 1, 2, 8, 5, 9],k = 4) == 20\n assert candidate(arr = [100, 200, 50, 150, 250, 500, 400, 300, 600, 700],k = 7) == 700\n assert candidate(arr = [7, 8, 9, 10, 11, 5, 6, 1, 2, 3, 4],k = 3) == 11\n assert candidate(arr = [500, 400, 300, 200, 100, 101, 102, 103, 104, 105],k = 3) == 500\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 10) == 20\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 1) == 10\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10],k = 2) == 3\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 9\n assert candidate(arr = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20],k = 5) == 20\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 4) == 100\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 12) == 75\n", "comparison": "exact"}, "public_tests": ["[2,1,3,5,4,6,7]\n2", "[3,2,1]\n10"], "hints": ["If k ≥ arr.length return the max element of the array.", "If k < arr.length simulate the game until a number wins k consecutive games."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().getWinner", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:00+00:00", "tests_total": 105, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def getWinner(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "getWinner", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1536, "task_id": "minimum-swaps-to-arrange-a-binary-grid", "difficulty": "Medium", "problem_description": "Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.\n\nA grid is said to be valid if all the cells above the main diagonal are zeros.\n\nReturn the minimum number of steps needed to make the grid valid, or -1 if the grid cannot be valid.\n\nThe main diagonal of a grid is the diagonal that starts at cell (1, 1) and ends at cell (n, n).\n\nExample 1:\n\nInput: grid = [[0,0,1],[1,1,0],[1,0,0]]\nOutput: 3\n\nExample 2:\n\nInput: grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]\nOutput: -1\nExplanation: All rows are similar, swaps have no effect on the grid.\n\nExample 3:\n\nInput: grid = [[1,0,0],[1,1,0],[1,1,1]]\nOutput: 0\n\nConstraints:\n\n- n == grid.length == grid[i].length\n- 1 <= n <= 200\n- grid[i][j] is either 0 or 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1], [1, 1, 0], [1, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 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], [0, 0, 1, 0], [0, 1, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 0, 1], [0, 1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 0], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 0, 0, 1, 1], [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, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 28\n assert candidate(grid = [[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\n assert candidate(grid = [[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]]) == 10\n assert candidate(grid = [[0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 6\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\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 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, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 55\n assert candidate(grid = [[0, 1, 0, 1, 0, 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], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [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\n assert candidate(grid = [[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, 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, 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]]) == 11\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, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 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\n assert candidate(grid = [[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], [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, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1], [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\n assert candidate(grid = [[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, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 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 = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[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]]) == -1\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[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\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0]]) == -1\n assert candidate(grid = [[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\n assert candidate(grid = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [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]]) == 6\n assert candidate(grid = [[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, 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, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[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], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 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, 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, 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, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 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, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 8\n", "comparison": "exact"}, "public_tests": ["[[0,0,1],[1,1,0],[1,0,0]]", "[[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]", "[[1,0,0],[1,1,0],[1,1,1]]"], "hints": ["For each row of the grid calculate the most right 1 in the grid in the array maxRight.", "To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's.", "If there exist an answer, simulate the swaps."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:02+00:00", "tests_total": 71, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "greedy", "matrix"]}, "language": "python", "interface": {"raw_signature": "def minSwaps(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1537, "task_id": "get-the-maximum-score", "difficulty": "Hard", "problem_description": "You are given two sorted arrays of distinct integers nums1 and nums2.\n\nA valid path is defined as follows:\n\n- Choose array nums1 or nums2 to traverse (from index-0).\n- Traverse the current array from left to right.\n- If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).\n\nThe score is defined as the sum of unique values in a valid path.\n\nReturn the maximum score you can obtain of all possible valid paths. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]\nOutput: 30\nExplanation: Valid paths:\n[2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10], (starting from nums1)\n[4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10] (starting from nums2)\nThe maximum is obtained with the path in green [2,4,6,8,10].\n\nExample 2:\n\nInput: nums1 = [1,3,5,7,9], nums2 = [3,5,100]\nOutput: 109\nExplanation: Maximum sum is obtained with the path [1,3,5,100].\n\nExample 3:\n\nInput: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]\nOutput: 40\nExplanation: There are no common elements between nums1 and nums2.\nMaximum sum is obtained with the path [6,7,8,9,10].\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 10^5\n- 1 <= nums1[i], nums2[i] <= 10^7\n- nums1 and nums2 are strictly increasing.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10000000],nums2 = [10000000]) == 10000000\n assert candidate(nums1 = [2, 4, 5, 8, 10],nums2 = [4, 6, 8, 9]) == 30\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10]) == 49\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5, 6, 7, 8, 9, 10]) == 55\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]) == 155\n assert candidate(nums1 = [1, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 12]) == 32\n assert candidate(nums1 = [5, 10, 15, 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 = [1, 3, 5, 7, 9],nums2 = [3, 5, 100]) == 109\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == 40\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == 15\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == 180\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],nums2 = [3, 4, 5, 6, 7, 8]) == 36\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [5, 15, 25, 35, 45]) == 125\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]) == 100\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 15\n assert candidate(nums1 = [1, 10000000],nums2 = [2, 9999999]) == 10000001\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 150\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 4, 6, 8],nums2 = [2, 3, 5, 7]) == 19\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, 2048]) == 4095\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, 105]) == 605\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 551\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [5, 15, 25, 35, 45]) == 275\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]) == 135\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]) == 240\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]) == 550\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1300\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 195\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 = [1, 4, 6, 7, 10, 20, 30],nums2 = [2, 4, 5, 7, 11, 12, 15, 20]) == 107\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]) == 100\n assert candidate(nums1 = [1, 4, 6, 7, 8, 10, 15, 20],nums2 = [2, 4, 5, 7, 9, 10, 13, 18]) == 73\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]) == 100\n assert candidate(nums1 = [2, 3, 6, 7, 11, 15],nums2 = [1, 2, 3, 8, 12, 16, 20]) == 62\n assert candidate(nums1 = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17],nums2 = [4, 6, 8, 10, 12, 14, 16, 18, 20]) == 108\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [1500000, 2500000, 3500000, 4500000, 5500000]) == 17500000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\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 = [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]) == 120\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 225\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == 55\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]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]) == 990\n assert candidate(nums1 = [1, 4, 5, 6, 10, 15, 20, 25],nums2 = [2, 4, 7, 10, 12, 15, 22]) == 99\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3069\n assert candidate(nums1 = [1, 10000000],nums2 = [5000000, 10000000]) == 15000000\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 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 5, 8, 9, 10, 12, 15, 18, 20]) == 104\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]) == 120\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 208\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 6000\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 240\n assert candidate(nums1 = [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],nums2 = [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]) == 1250\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]) == 240\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 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 550\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]) == 420\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]) == 420\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == 180\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, 21]) == 121\n assert candidate(nums1 = [1, 10000000],nums2 = [2, 9999999]) == 10000001\n assert candidate(nums1 = [1, 100, 1000, 10000, 100000],nums2 = [10, 100, 1000, 10000, 100000, 1000000]) == 1111110\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 20, 25, 35, 40, 45, 55, 65, 70, 75, 85, 95]) == 640\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],nums2 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 11111111\n assert candidate(nums1 = [1, 2, 4, 5, 7, 8, 10, 12],nums2 = [3, 4, 6, 7, 9, 10, 11, 13]) == 63\n assert candidate(nums1 = [1, 3, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 5, 7, 11, 13, 17, 18, 19]) == 119\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, 45, 50]) == 365\n assert candidate(nums1 = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 306\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 145\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]) == 155\n assert candidate(nums1 = [2, 6, 10, 14, 18],nums2 = [3, 6, 9, 12, 15, 18, 21]) == 84\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40],nums2 = [10, 20, 30, 40, 50, 60, 70]) == 360\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 435\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, 21, 22, 23, 24]) == 300\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26]) == 126\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9, 10, 12]) == 47\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 5, 8, 11, 14, 17, 20]) == 77\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 730\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == 450\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1300\n assert candidate(nums1 = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 500\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 78\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, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 490\n assert candidate(nums1 = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44]) == 345\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, 11, 12, 13, 14, 15]) == 365\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 10, 15, 20, 25]) == 115\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, 105]) == 605\n assert candidate(nums1 = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 435\n assert candidate(nums1 = [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],nums2 = [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(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 105\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1290\n assert candidate(nums1 = [1, 5, 10, 20, 30, 40, 50],nums2 = [3, 10, 15, 25, 35, 45, 55]) == 191\n assert candidate(nums1 = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],nums2 = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500]) == 33750\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [500000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5000000]) == 27500000\n assert candidate(nums1 = [1, 10, 20, 30, 40],nums2 = [5, 15, 25, 35, 45]) == 125\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [3, 4, 9, 10, 15, 16, 20]) == 77\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [1, 5, 9, 13, 17, 21]) == 73\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 91\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 335\n assert candidate(nums1 = [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],nums2 = [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]) == 1250\n", "comparison": "exact"}, "public_tests": ["[2,4,5,8,10]\n[4,6,8,9]", "[1,3,5,7,9]\n[3,5,100]", "[1,2,3,4,5]\n[6,7,8,9,10]"], "hints": ["Partition the array by common integers, and choose the path with larger sum with a DP technique."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:05+00:00", "tests_total": 110, "tests_dropped": 6, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def maxSum(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1539, "task_id": "kth-missing-positive-number", "difficulty": "Easy", "problem_description": "Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.\n\nReturn the k^th positive integer that is missing from this array.\n\nExample 1:\n\nInput: arr = [2,3,4,7,11], k = 5\nOutput: 9\nExplanation: The missing positive integers are [1,5,6,8,9,10,12,13,...]. The 5^th missing positive integer is 9.\n\nExample 2:\n\nInput: arr = [1,2,3,4], k = 2\nOutput: 6\nExplanation: The missing positive integers are [5,6,7,...]. The 2^nd missing positive integer is 6.\n\nConstraints:\n\n- 1 <= arr.length <= 1000\n- 1 <= arr[i] <= 1000\n- 1 <= k <= 1000\n- arr[i] < arr[j] for 1 <= i < j <= arr.length\n\nFollow up:\n\nCould you solve this problem in less than O(n) complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 20\n assert candidate(arr = [10, 20, 30],k = 15) == 16\n assert candidate(arr = [2, 3, 4, 7, 11],k = 5) == 9\n assert candidate(arr = [5, 6, 7, 8, 9],k = 1) == 1\n assert candidate(arr = [5, 6, 8, 9, 10],k = 3) == 3\n assert candidate(arr = [1, 3, 5, 7],k = 3) == 6\n assert candidate(arr = [1, 3, 5, 7, 9],k = 4) == 8\n assert candidate(arr = [10, 20, 30],k = 5) == 5\n assert candidate(arr = [1, 2, 3, 4, 8, 10, 11],k = 5) == 12\n assert candidate(arr = [1, 2, 3, 4],k = 2) == 6\n assert candidate(arr = [10, 20, 30, 40],k = 15) == 16\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],k = 60) == 80\n assert candidate(arr = [2, 5, 9, 11, 15, 18, 22, 25],k = 15) == 21\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 = 100) == 120\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 500) == 509\n assert candidate(arr = [5, 6, 8, 9, 11, 14, 17, 18, 21],k = 10) == 16\n assert candidate(arr = [5, 10, 15, 20, 25],k = 15) == 18\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 20) == 24\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 25) == 29\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127],k = 200) == 207\n assert candidate(arr = [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 = 120) == 145\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59],k = 30) == 40\n assert candidate(arr = [2, 5, 10, 17, 26, 37, 49, 62, 76, 91, 107, 124, 142, 161, 181],k = 25) == 30\n assert candidate(arr = [1, 4, 6, 8, 11, 13, 15, 17, 19, 22, 24, 26, 28, 30, 32],k = 20) == 35\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 = 30) == 55\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1000],k = 1000) == 1011\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 25\n assert candidate(arr = [1, 4, 8, 13, 18, 23, 28, 33, 38],k = 20) == 26\n assert candidate(arr = [1, 4, 6, 9, 11, 15, 17, 20, 23],k = 10) == 16\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 200) == 221\n assert candidate(arr = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 25) == 35\n assert candidate(arr = [5, 10, 15, 20, 25],k = 10) == 12\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 110\n assert candidate(arr = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 15) == 19\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 75) == 94\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 150) == 164\n assert candidate(arr = [1, 2, 5, 8, 10, 13, 16, 19, 22, 25],k = 18) == 28\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 60\n assert candidate(arr = [2, 6, 10, 14, 18, 22, 26],k = 15) == 20\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 75) == 84\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 30) == 40\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 30) == 34\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 150) == 165\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 25) == 28\n assert candidate(arr = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],k = 25) == 35\n assert candidate(arr = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71],k = 50) == 63\n assert candidate(arr = [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],k = 100) == 134\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 = 25) == 45\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 50) == 54\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 30) == 40\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 100) == 110\n assert candidate(arr = [25, 50, 75, 100, 125, 150, 175, 200],k = 50) == 52\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 75) == 90\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 19\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 7) == 10\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35],k = 20) == 26\n assert candidate(arr = [3, 8, 12, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 50) == 66\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 30) == 34\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 50) == 57\n assert candidate(arr = [2, 5, 9, 12, 15, 18, 21, 24, 27, 30],k = 20) == 29\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 50) == 58\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) == 30\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],k = 40) == 48\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21],k = 30) == 45\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10) == 19\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 26\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20],k = 15) == 31\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 30) == 38\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 450) == 454\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 = 500) == 550\n assert candidate(arr = [5, 10, 15, 20, 25, 30],k = 12) == 14\n assert candidate(arr = [2, 5, 7, 11, 14, 17, 20, 23, 26, 29],k = 40) == 50\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 150) == 171\n assert candidate(arr = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20],k = 50) == 64\n assert candidate(arr = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49],k = 25) == 31\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55],k = 10) == 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, 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],k = 100) == 150\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 505\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 50) == 58\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25],k = 25) == 34\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 75) == 82\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 15) == 18\n assert candidate(arr = [2, 5, 8, 11, 15],k = 10) == 14\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255],k = 60) == 64\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 30) == 51\n assert candidate(arr = [300, 600, 900],k = 1000) == 1003\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 1000) == 1015\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 100) == 110\n assert candidate(arr = [1, 2, 3, 5, 6, 9, 11, 12, 15],k = 15) == 24\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],k = 40) == 43\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 100) == 102\n assert candidate(arr = [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 = 150) == 175\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 50) == 58\n assert candidate(arr = [2, 3, 5, 8, 12, 17, 23, 30, 38, 47],k = 35) == 44\n assert candidate(arr = [5, 6, 8, 10, 13, 14],k = 7) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 25) == 35\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 20) == 29\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 505\n assert candidate(arr = [5, 8, 12, 14, 20, 25],k = 8) == 10\n assert candidate(arr = [5, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 17\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 20) == 35\n assert candidate(arr = [1, 2, 4, 7, 11, 15, 19, 24, 29, 35],k = 20) == 28\n assert candidate(arr = [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 27) == 36\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 25) == 32\n assert candidate(arr = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26],k = 50) == 64\n assert candidate(arr = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 302],k = 150) == 167\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 13) == 15\n", "comparison": "exact"}, "public_tests": ["[2,3,4,7,11]\n5", "[1,2,3,4]\n2"], "hints": ["Keep track of how many positive numbers are missing as you scan the array."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findKthPositive", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:07+00:00", "tests_total": 109, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "python", "interface": {"raw_signature": "def findKthPositive(self, arr: list[int], k: int) -> int:", "container": "Solution", "callable": "findKthPositive", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1540, "task_id": "can-convert-string-in-k-moves", "difficulty": "Medium", "problem_description": "Given two strings s and t, your goal is to convert s into t in k moves or less.\n\nDuring the i^th (1 <= i <= k) move you can:\n\n- Choose any index j (1-indexed) from s, such that 1 <= j <= s.length and j has not been chosen in any previous move, and shift the character at that index i times.\n- Do nothing.\n\nShifting a character means replacing it by the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Shifting a character by i means applying the shift operations i times.\n\nRemember that any index j can be picked at most once.\n\nReturn true if it's possible to convert s into t in no more than k moves, otherwise return false.\n\nExample 1:\n\nInput: s = \"input\", t = \"ouput\", k = 9\nOutput: true\nExplanation: In the 6th move, we shift 'i' 6 times to get 'o'. And in the 7th move we shift 'n' to get 'u'.\n\nExample 2:\n\nInput: s = \"abc\", t = \"bcd\", k = 10\nOutput: false\nExplanation: We need to shift each character in s one time to convert it into t. We can shift 'a' to 'b' during the 1st move. However, there is no way to shift the other characters in the remaining moves to obtain t from s.\n\nExample 3:\n\nInput: s = \"aab\", t = \"bbb\", k = 27\nOutput: true\nExplanation: In the 1st move, we shift the first 'a' 1 time to get 'b'. In the 27th move, we shift the second 'a' 27 times to get 'b'.\n\nConstraints:\n\n- 1 <= s.length, t.length <= 10^5\n- 0 <= k <= 10^9\n- s, t contain only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abc\",k = 0) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 702) == True\n assert candidate(s = \"abc\",t = \"bcd\",k = 10) == False\n assert candidate(s = \"abc\",t = \"xyz\",k = 702) == True\n assert candidate(s = \"abcd\",t = \"pqrs\",k = 100) == True\n assert candidate(s = \"zzz\",t = \"aaa\",k = 78) == True\n assert candidate(s = \"abcd\",t = \"pqrs\",k = 78) == False\n assert candidate(s = \"aaa\",t = \"abc\",k = 3) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 25) == False\n assert candidate(s = \"zzz\",t = \"aaa\",k = 25) == False\n assert candidate(s = \"aab\",t = \"bbb\",k = 27) == True\n assert candidate(s = \"a\",t = \"z\",k = 25) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",k = 0) == True\n assert candidate(s = \"input\",t = \"ouput\",k = 9) == True\n assert candidate(s = \"repeatedchars\",t = \"sfpqeueftdsft\",k = 150) == True\n assert candidate(s = \"zzzzz\",t = \"aaaaa\",k = 122) == True\n assert candidate(s = \"aaaaaaaaaa\",t = \"zzzzzzzzzz\",k = 260) == True\n assert candidate(s = \"abcde\",t = \"edcba\",k = 155) == True\n assert candidate(s = \"wraparound\",t = \"xqcsbpsboe\",k = 150) == True\n assert candidate(s = \"abcdef\",t = \"fedcba\",k = 50) == True\n assert candidate(s = \"z\",t = \"a\",k = 1) == True\n assert candidate(s = \"xylophone\",t = \"xylophone\",k = 1) == True\n assert candidate(s = \"testcase\",t = \"testcase\",k = 0) == True\n assert candidate(s = \"pqrs\",t = \"abcd\",k = 76) == False\n assert candidate(s = \"xyz\",t = \"abc\",k = 25) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",k = 104) == True\n assert candidate(s = \"longstringexample\",t = \"mpjutjvqygfqfcqpf\",k = 300) == True\n assert candidate(s = \"xyzzxyzz\",t = \"abcdabcd\",k = 156) == True\n assert candidate(s = \"zzz\",t = \"abc\",k = 78) == True\n assert candidate(s = \"hello\",t = \"tqxxa\",k = 100) == False\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 24) == False\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbccccc\",k = 250) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 900) == True\n assert candidate(s = \"hello\",t = \"worry\",k = 100) == True\n assert candidate(s = \"python\",t = \"pythom\",k = 100) == True\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"zptjhoqznbmmktgdobnkszemgsvx\",k = 1000) == False\n assert candidate(s = \"abcd\",t = \"dcba\",k = 10) == False\n assert candidate(s = \"mississippi\",t = \"ssissippi\",k = 100) == False\n assert candidate(s = \"hello\",t = \"khoor\",k = 15) == False\n assert candidate(s = \"almostthere\",t = \"bnmpsuusfsf\",k = 99) == False\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",k = 260) == True\n assert candidate(s = \"shifting\",t = \"zmtxlqjq\",k = 300) == True\n assert candidate(s = \"abcde\",t = \"edcba\",k = 156) == True\n assert candidate(s = \"abc\",t = \"bcd\",k = 2) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"bcccdddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzza\",k = 1000) == False\n assert candidate(s = \"conversion\",t = \"cvqfvkzqpo\",k = 100) == True\n assert candidate(s = \"xyz\",t = \"abc\",k = 24) == False\n assert candidate(s = \"abcxyz\",t = \"bcdyza\",k = 27) == False\n assert candidate(s = \"zzzzzzzzzz\",t = \"aaaaaaaaaa\",k = 259) == True\n assert candidate(s = \"hello\",t = \"uifsf\",k = 100) == True\n assert candidate(s = \"abc\",t = \"xyz\",k = 100) == True\n assert candidate(s = \"thisisatest\",t = \"ujkjkfbtftu\",k = 150) == True\n assert candidate(s = \"aaaaaaa\",t = \"zzzzzzz\",k = 702) == True\n assert candidate(s = \"abcd\",t = \"abcd\",k = 0) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1000) == True\n assert candidate(s = \"abcdabcdabcd\",t = \"efghefghijkl\",k = 100) == False\n assert candidate(s = \"aaaabbbb\",t = \"bbbbcccc\",k = 26) == False\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",t = \"bcdebcdebcdebcdebcdebcdebcdebcdebcdebcde\",k = 100) == False\n assert candidate(s = \"aaaaaaaaaaa\",t = \"bbbbbbbbbbb\",k = 1000) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaa\",k = 260) == False\n assert candidate(s = \"ab\",t = \"yz\",k = 51) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",k = 51) == False\n assert candidate(s = \"abcdabcdabcd\",t = \"efefefefefef\",k = 80) == False\n assert candidate(s = \"hello\",t = \"world\",k = 20) == False\n assert candidate(s = \"aabbaabb\",t = \"bbccbbcc\",k = 25) == False\n assert candidate(s = \"aaaabbbb\",t = \"bbbbcccc\",k = 100) == False\n assert candidate(s = \"aaaa\",t = \"bbbb\",k = 26) == False\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"defdefdefdefdefdef\",k = 260) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 200) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 26) == False\n assert candidate(s = \"azazaz\",t = \"bbbbbb\",k = 78) == True\n assert candidate(s = \"aabbcc\",t = \"bbccdd\",k = 29) == False\n assert candidate(s = \"abcdabcd\",t = \"bcdebcde\",k = 10) == False\n assert candidate(s = \"hello\",t = \"world\",k = 51) == True\n assert candidate(s = \"zzzz\",t = \"aaaa\",k = 104) == True\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\",k = 100) == False\n assert candidate(s = \"hello\",t = \"ifmmp\",k = 5) == False\n assert candidate(s = \"abcd\",t = \"dcba\",k = 104) == True\n assert candidate(s = \"abcd\",t = \"dcba\",k = 100) == True\n assert candidate(s = \"abacabadabacaba\",t = \"bcbbcadbbcbcbbc\",k = 200) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 675) == True\n assert candidate(s = \"aaaaaaaaaaaa\",t = \"bbbbbbbbbbbb\",k = 12) == False\n assert candidate(s = \"python\",t = \"python\",k = 0) == True\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 26) == False\n assert candidate(s = \"hello\",t = \"world\",k = 52) == True\n assert candidate(s = \"abcdef\",t = \"ghijkl\",k = 18) == False\n assert candidate(s = \"xyz\",t = \"abc\",k = 77) == True\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",k = 100) == True\n assert candidate(s = \"same\",t = \"same\",k = 10) == True\n assert candidate(s = \"programming\",t = \"qpsxstjnnqj\",k = 200) == True\n assert candidate(s = \"programming\",t = \"programming\",k = 1000) == True\n assert candidate(s = \"conversion\",t = \"wxvqivlxnt\",k = 500) == True\n assert candidate(s = \"thisisatest\",t = \"ytnsytyfyty\",k = 150) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 1325) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 701) == True\n assert candidate(s = \"a\",t = \"a\",k = 0) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 78) == True\n assert candidate(s = \"conversion\",t = \"hxqzsrqvok\",k = 200) == True\n assert candidate(s = \"aaa\",t = \"abc\",k = 2) == True\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\",k = 50) == True\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 78) == False\n assert candidate(s = \"mississippi\",t = \"vvvttttpppp\",k = 260) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 260) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",k = 100) == False\n assert candidate(s = \"racecar\",t = \"racecar\",k = 100) == True\n assert candidate(s = \"aabbcc\",t = \"bbccdd\",k = 30) == False\n assert candidate(s = \"aabbaabb\",t = \"bbccbbcc\",k = 26) == False\n assert candidate(s = \"aaaa\",t = \"zzzz\",k = 103) == True\n assert candidate(s = \"python\",t = \"qzuipo\",k = 65) == False\n assert candidate(s = \"zzzzz\",t = \"aaaab\",k = 130) == True\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",t = \"bcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdcb\",k = 260) == False\n assert candidate(s = \"mississippi\",t = \"aaaaaaaaaaa\",k = 130) == True\n assert candidate(s = \"yzyzyzyzyz\",t = \"acacacacac\",k = 520) == True\n assert candidate(s = \"hello\",t = \"world\",k = 50) == True\n assert candidate(s = \"quickbrownfox\",t = \"rvjdlqpsqfy\",k = 200) == False\n assert candidate(s = \"leetcode\",t = \"leetcode\",k = 0) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"bbaacceeggiikkmmppttuuwwyyzzeeddfgghhjjoonnuuxx\",k = 1000) == False\n assert candidate(s = \"longstringwithmultiplecharacters\",t = \"nqprxuixwqywwpdqfhhcifqtf\",k = 500) == False\n", "comparison": "exact"}, "public_tests": ["\"input\"\n\"ouput\"\n9", "\"abc\"\n\"bcd\"\n10", "\"aab\"\n\"bbb\"\n27"], "hints": ["Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times.", "You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26."], "metadata": {"canonical_parameter_names": ["s", "t", "k"], "leetcode_dataset_entry_point": "Solution().canConvertString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:10+00:00", "tests_total": 119, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def canConvertString(self, s: str, t: str, k: int) -> bool:", "container": "Solution", "callable": "canConvertString", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1541, "task_id": "minimum-insertions-to-balance-a-parentheses-string", "difficulty": "Medium", "problem_description": "Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:\n\n- Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.\n- Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.\n\nIn other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.\n\n- For example, \"())\", \"())(())))\" and \"(())())))\" are balanced, \")()\", \"()))\" and \"(()))\" are not balanced.\n\nYou can insert the characters '(' and ')' at any position of the string to balance it if needed.\n\nReturn the minimum number of insertions needed to make s balanced.\n\nExample 1:\n\nInput: s = \"(()))\"\nOutput: 1\nExplanation: The second '(' has two matching '))', but the first '(' has only ')' matching. We need to add one more ')' at the end of the string to be \"(())))\" which is balanced.\n\nExample 2:\n\nInput: s = \"())\"\nOutput: 0\nExplanation: The string is already balanced.\n\nExample 3:\n\nInput: s = \"))())(\"\nOutput: 3\nExplanation: Add '(' to match the first '))', Add '))' to match the last '('.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of '(' and ')' only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()))\") == 1\n assert candidate(s = \"))())(\") == 3\n assert candidate(s = \"())\") == 0\n assert candidate(s = \"(()(())))))))))))()()\") == 6\n assert candidate(s = \"(()))(()))(()))(()))(())))()\") == 5\n assert candidate(s = \"(()(()(()(()(())))))\") == 10\n assert candidate(s = \"()(()(()))())(()(()))()\") == 10\n assert candidate(s = \"(()(()(())))()(()(()(())))()()\") == 15\n assert candidate(s = \"(((()(()(()(()(())))))()))))))))))))))))))))\") == 10\n assert candidate(s = \"(()(()(())))()(()(()(())))\") == 13\n assert candidate(s = \"((((((())\") == 12\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(())))()\") == 11\n assert candidate(s = \")((((()))))))))))))\") == 5\n assert candidate(s = \"(()(()))())\") == 4\n assert candidate(s = \"((((((())))))\") == 8\n assert candidate(s = \"(((((())))))))\") == 4\n assert candidate(s = \"(()())()(()(()(())))\") == 10\n assert candidate(s = \"((((((())))))))))\") == 4\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))(()))(()))\") == 16\n assert candidate(s = \"()()()()()()()()()()()()()()()()\") == 16\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 9\n assert candidate(s = \"((())()())\") == 5\n assert candidate(s = \"(()))(()(()))\") == 5\n assert candidate(s = \"()(()(()(()(()(()))))())()()\") == 14\n assert candidate(s = \"())()(()))\") == 2\n assert candidate(s = \"((((()))))(()(()))()(()(()))()()\") == 16\n assert candidate(s = \"(()(()))(()(()))(()(()))(()(()))\") == 16\n assert candidate(s = \"))))))))))))))))\") == 8\n assert candidate(s = \"(()(((()(()))())()()(())))\") == 13\n assert candidate(s = \"(((((())))(((((())))\") == 16\n assert candidate(s = \"((((((((()))))))))\") == 9\n assert candidate(s = \"(()(()(()(()(())))))))\") == 8\n assert candidate(s = \"(((()))))()(()(()))(()(()))()\") == 13\n assert candidate(s = \"((((((()))))))\") == 7\n assert candidate(s = \"(()))(()))(()())\") == 5\n assert candidate(s = \"((())))))((()))))\") == 1\n assert candidate(s = \"(()(()(())))()()(()(()(())))()()(()(()(())))\") == 22\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))\") == 12\n assert candidate(s = \"()(()(()(()(()(()))))())()\") == 13\n assert candidate(s = \"()(()(()(()(()))))(())))\") == 9\n assert candidate(s = \")(((((((((((((())))))))))))\") == 18\n assert candidate(s = \"((((()))))(()(()))()(()(()))\") == 14\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()()()()\") == 23\n assert candidate(s = \"(((((())))(((((())))))))\") == 12\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))\") == 8\n assert candidate(s = \")(()))(()(()))\") == 7\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 12\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))\") == 14\n assert candidate(s = \"()(()(()(()(()(()))))())()()()\") == 15\n assert candidate(s = \"()()()()()()()()()()\") == 10\n assert candidate(s = \"(((((()))(()))()))\") == 9\n assert candidate(s = \"(((()))))()(()(()))(()(()))\") == 12\n assert candidate(s = \"(((((((((())))))))\") == 12\n assert candidate(s = \"(()((())(()))\") == 8\n assert candidate(s = \"((((((((((((((())))))))))))))()()()()()()()()()()()()()()()()()()()()()()()\") == 39\n assert candidate(s = \"(()))(()(()))())\") == 5\n assert candidate(s = \"(()))())\") == 1\n assert candidate(s = \"()()()()\") == 4\n assert candidate(s = \"(()))(()))(()(()()(())))\") == 9\n assert candidate(s = \"(()))(()))(()))(()))\") == 4\n assert candidate(s = \"(((((((((((((())))))))))))\") == 16\n assert candidate(s = \"(()(()(()(()(())))))))()(()))\") == 10\n assert candidate(s = \"((((()))))))\") == 3\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))\") == 6\n assert candidate(s = \"(()(()(()(())))()())\") == 10\n assert candidate(s = \"())(()))(()(()))\") == 5\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(())))\") == 10\n assert candidate(s = \"(()(()(())))\") == 6\n assert candidate(s = \"(()))(()))(()))\") == 3\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))\") == 7\n assert candidate(s = \"((()))()()()()()()()\") == 10\n assert candidate(s = \"(()))())(())))\") == 1\n assert candidate(s = \")()()()()()()()()()()()()()()()()()()()()()\") == 23\n assert candidate(s = \"(((((()))())(()(((()))())))\") == 15\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()()()()()()()()()\") == 28\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))()(()))(()))(()))()(()))(()))()(()))\") == 21\n assert candidate(s = \"()(()(()(()(()))))\") == 9\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 10\n assert candidate(s = \"()(()(()(()(()(()))())))\") == 12\n assert candidate(s = \"()((((()))))))((((()))))))\") == 7\n assert candidate(s = \"(()(()))(()\") == 7\n assert candidate(s = \"(((())))\") == 4\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))()(()))(()))(()))\") == 16\n assert candidate(s = \"(()(()(()(()(())))))))()()\") == 10\n assert candidate(s = \"()(()(()(()(()(()))())))()()\") == 14\n assert candidate(s = \"(()(()(()(()(())))))))()())\") == 9\n assert candidate(s = \"())()(()(()(()(()))))\") == 9\n assert candidate(s = \"))))(((\") == 8\n assert candidate(s = \"(()(()(()(()))))())\") == 8\n assert candidate(s = \"(()))(()))(())))\") == 2\n assert candidate(s = \"()(()(()(())))()\") == 8\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))(()))(()))(()))\") == 17\n assert candidate(s = \"()()()()()()()()()()(()(()(()(()(())))))\") == 20\n assert candidate(s = \"(()(()(()(()(()))))(())))\") == 11\n assert candidate(s = \")()()()()()()\") == 8\n assert candidate(s = \"()(()(()(()(()(()))))())\") == 12\n assert candidate(s = \"(()))(()))(()))(()))(()))\") == 5\n assert candidate(s = \"(()(()(())))()()(()(()(())))\") == 14\n assert candidate(s = \"(()))(()(()(())))()()(()(()(()))))(()))(()))\") == 16\n assert candidate(s = \"(((((()))))(()(()))(()(()))()()()()\") == 19\n assert candidate(s = \"((((((((((((()))))))))))))))))\") == 9\n assert candidate(s = \"(()(()))())(()))\") == 5\n assert candidate(s = \"(()))(()))\") == 2\n assert candidate(s = \"()()()()()()\") == 6\n assert candidate(s = \"(()))(((())))((()))(()))()()(()(())))\") == 14\n assert candidate(s = \"()))))(((()))(()))\") == 9\n assert candidate(s = \"(()))(()(()(()))())\") == 8\n assert candidate(s = \"(()(()(()(()(()))))))))))))))\") == 7\n assert candidate(s = \"((()))))\") == 1\n assert candidate(s = \"())(()(()(()))())\") == 7\n assert candidate(s = \"((((((()))))))))\") == 5\n assert candidate(s = \"()()()()()()()()()\") == 9\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()\") == 20\n assert candidate(s = \"((((()))))(()(()))()(()(()))()()()\") == 17\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(()))\") == 11\n", "comparison": "exact"}, "public_tests": ["\"(()))\"", "\"())\"", "\"))())(\""], "hints": ["Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'.", "If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minInsertions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:12+00:00", "tests_total": 115, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "greedy", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def minInsertions(self, s: str) -> int:", "container": "Solution", "callable": "minInsertions", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1542, "task_id": "find-longest-awesome-substring", "difficulty": "Hard", "problem_description": "You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.\n\nReturn the length of the maximum length awesome substring of s.\n\nExample 1:\n\nInput: s = \"3242415\"\nOutput: 5\nExplanation: \"24241\" is the longest awesome substring, we can form the palindrome \"24142\" with some swaps.\n\nExample 2:\n\nInput: s = \"12345678\"\nOutput: 1\n\nExample 3:\n\nInput: s = \"213123\"\nOutput: 6\nExplanation: \"213123\" is the longest awesome substring, we can form the palindrome \"231132\" with some swaps.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists only of digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 4\n assert candidate(s = \"1000000001\") == 10\n assert candidate(s = \"9876543210\") == 1\n assert candidate(s = \"213123\") == 6\n assert candidate(s = \"9437493749\") == 9\n assert candidate(s = \"1221\") == 4\n assert candidate(s = \"1232112321\") == 10\n assert candidate(s = \"122112211\") == 9\n assert candidate(s = \"123454321\") == 9\n assert candidate(s = \"98765432100123456789\") == 20\n assert candidate(s = \"1111111111\") == 10\n assert candidate(s = \"0000000000000000000\") == 19\n assert candidate(s = \"2020202020\") == 9\n assert candidate(s = \"1111111\") == 7\n assert candidate(s = \"0123456789\") == 1\n assert candidate(s = \"3242415\") == 5\n assert candidate(s = \"2002\") == 4\n assert candidate(s = \"0123210\") == 7\n assert candidate(s = \"1234567890987654321\") == 19\n assert candidate(s = \"00\") == 2\n assert candidate(s = \"12321\") == 5\n assert candidate(s = \"202020202\") == 9\n assert candidate(s = \"12345678\") == 1\n assert candidate(s = \"12345432101234543210\") == 20\n assert candidate(s = \"123454321123454321\") == 18\n assert candidate(s = \"2211001122110011221\") == 19\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\") == 41\n assert candidate(s = \"1234321987897898765456543213212345654321234321\") == 27\n assert candidate(s = \"99887766554433221100000000112233445566778899\") == 44\n assert candidate(s = \"9876543211234567890\") == 19\n assert candidate(s = \"1111111111111111111\") == 19\n assert candidate(s = \"111112222233333444445555566666777778888899999\") == 13\n assert candidate(s = \"999999999999999999999999999999999999999999999999999\") == 51\n assert candidate(s = \"123321122132123321122132123321122132123321\") == 39\n assert candidate(s = \"1232100000000000000012321\") == 25\n assert candidate(s = \"123456543210101\") == 15\n assert candidate(s = \"000000111111222222333333\") == 24\n assert candidate(s = \"112233445566778899\") == 18\n assert candidate(s = \"1122334455667788990000998877665544332211\") == 40\n assert candidate(s = \"0000000000\") == 10\n assert candidate(s = \"5959595959595959595\") == 19\n assert candidate(s = \"2211221133443344\") == 16\n assert candidate(s = \"1221333122133312213331221\") == 25\n assert candidate(s = \"99887766554433221100112233445566778899\") == 38\n assert candidate(s = \"123456789098765432101234567890\") == 21\n assert candidate(s = \"1234543210987654321\") == 9\n assert candidate(s = \"54321098765432109876543210987654321098765432109876\") == 41\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 40\n assert candidate(s = \"01234567890987654321\") == 20\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210\") == 81\n assert candidate(s = \"22221111000033334444\") == 20\n assert candidate(s = \"12345678900000000001\") == 11\n assert candidate(s = \"9090909090909090909090909090909090909090909090909090\") == 52\n assert candidate(s = \"123123123123123123123123123123123123123123123123123\") == 49\n assert candidate(s = \"99999999999999999999\") == 20\n assert candidate(s = \"1234567898765432112345678987654321\") == 34\n assert candidate(s = \"11111111111111111111\") == 20\n assert candidate(s = \"11223344556677889900\") == 20\n assert candidate(s = \"1122334455667788990099887766554433221100001100\") == 46\n assert candidate(s = \"1221122112211221122112211221122112211221122112211221\") == 52\n assert candidate(s = \"999988887777666655554444333322221111\") == 36\n assert candidate(s = \"5555555555\") == 10\n assert candidate(s = \"32165498798546123\") == 17\n assert candidate(s = \"00000000000000000000000000000000000000000000000\") == 47\n assert candidate(s = \"2468024680246802468\") == 19\n assert candidate(s = \"123432101234321\") == 15\n assert candidate(s = \"98765432109876543210\") == 20\n assert candidate(s = \"3332222211111000000\") == 15\n assert candidate(s = \"12345678909876543210123456789098765432101234567890\") == 41\n assert candidate(s = \"111222333444555666777888999\") == 7\n assert candidate(s = \"020406080080604020\") == 18\n assert candidate(s = \"98765432123456789\") == 17\n assert candidate(s = \"1122334455667788990011\") == 22\n assert candidate(s = \"01234567898765432101234567890\") == 21\n assert candidate(s = \"1221122112211\") == 13\n assert candidate(s = \"111222333444555666777\") == 7\n assert candidate(s = \"12213332211233333312\") == 19\n assert candidate(s = \"998877665544332211000112233445566778899\") == 39\n assert candidate(s = \"11112222333344445555\") == 20\n assert candidate(s = \"12345432112345432100\") == 20\n assert candidate(s = \"0246802468024680246\") == 19\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(s = \"0121021012321012321\") == 19\n assert candidate(s = \"9999888877776666555544443333222211110000\") == 40\n assert candidate(s = \"9876543210987654321\") == 19\n assert candidate(s = \"98765432109876543210987654321098765432109876543210\") == 41\n assert candidate(s = \"12321232123212321\") == 17\n assert candidate(s = \"0101010101010101010\") == 19\n assert candidate(s = \"789789789\") == 7\n assert candidate(s = \"12332145654\") == 11\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\") == 81\n assert candidate(s = \"111222333444555666777888999000\") == 7\n assert candidate(s = \"98765432100000000009\") == 11\n assert candidate(s = \"9999999999\") == 10\n assert candidate(s = \"0000000000111111111122222222223333333333\") == 40\n assert candidate(s = \"1357913579135791357\") == 19\n assert candidate(s = \"10203040504030201\") == 17\n assert candidate(s = \"123454321012321\") == 9\n assert candidate(s = \"55555555555555555555\") == 20\n assert candidate(s = \"12345678900987654321\") == 20\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 52\n assert candidate(s = \"00000000000000000000\") == 20\n assert candidate(s = \"123123123123123123\") == 18\n assert candidate(s = \"111222333444555666\") == 7\n assert candidate(s = \"12213332122133321\") == 17\n assert candidate(s = \"01010101010101\") == 13\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 40\n assert candidate(s = \"555555555555555555555555555555555555\") == 36\n assert candidate(s = \"9876543210123456789\") == 19\n assert candidate(s = \"001122334455667788990099887766554433221100\") == 42\n assert candidate(s = \"5555555555555555555555\") == 22\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 40\n assert candidate(s = \"9988776655443322110099887766554433221100\") == 40\n assert candidate(s = \"1122334455667788990099887766554433221100000000\") == 46\n assert candidate(s = \"00112233445566778899\") == 20\n assert candidate(s = \"122112333211\") == 11\n assert candidate(s = \"00000000000000000001\") == 19\n assert candidate(s = \"1223344556677889900998877665544332211\") == 37\n assert candidate(s = \"1234567890098765432112345678900987654321\") == 40\n assert candidate(s = \"111122223333444455556666\") == 24\n assert candidate(s = \"00000111112222233333444445555566666777778888899999\") == 13\n assert candidate(s = \"10000000000000000001\") == 20\n assert candidate(s = \"000111222333444555666\") == 7\n assert candidate(s = \"12345678900987654321012345678998765432101234567890\") == 41\n assert candidate(s = \"12345678900000000000\") == 11\n assert candidate(s = \"0220220120\") == 7\n assert candidate(s = \"123123123123123\") == 13\n assert candidate(s = \"10101010101010101010\") == 20\n assert candidate(s = \"1122334455667788991111222233334444\") == 34\n assert candidate(s = \"98765432100123456789987654321001234567899876543210\") == 41\n assert candidate(s = \"121312131213121312131213121312131213\") == 35\n assert candidate(s = \"5554443332221110000\") == 9\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == 96\n", "comparison": "exact"}, "public_tests": ["\"3242415\"", "\"12345678\"", "\"213123\""], "hints": ["Given the character counts, under what conditions can a palindrome be formed ?", "From left to right, use bitwise xor-operation to compute for any prefix the number of times modulo 2 of each digit. (mask ^= (1<<(s[i]-'0')).", "Expected complexity is O(n*A) where A is the alphabet (10)."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestAwesome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:14+00:00", "tests_total": 133, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def longestAwesome(self, s: str) -> int:", "container": "Solution", "callable": "longestAwesome", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1544, "task_id": "make-the-string-great", "difficulty": "Easy", "problem_description": "Given a string s of lower and upper case English letters.\n\nA good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:\n\n- 0 <= i <= s.length - 2\n- s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.\n\nTo make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.\n\nReturn the string after making it good. The answer is guaranteed to be unique under the given constraints.\n\nNotice that an empty string is also good.\n\nExample 1:\n\nInput: s = \"leEeetcode\"\nOutput: \"leetcode\"\nExplanation: In the first step, either you choose i = 1 or i = 2, both will result \"leEeetcode\" to be reduced to \"leetcode\".\n\nExample 2:\n\nInput: s = \"abBAcC\"\nOutput: \"\"\nExplanation: We have many possible scenarios, and all lead to the same answer. For example:\n\"abBAcC\" --> \"aAcC\" --> \"cC\" --> \"\"\n\"abBAcC\" --> \"abBA\" --> \"aA\" --> \"\"\n\nExample 3:\n\nInput: s = \"s\"\nOutput: \"s\"\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s contains only lower and upper case English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefg\") == \"abcdefg\"\n assert candidate(s = \"ABCDEFG\") == \"ABCDEFG\"\n assert candidate(s = \"vVtTkKsSiIdDgGhHjJfFcCrRlLpPoOeEaAqQzZxXcCvVbBnNmM\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"\"\n assert candidate(s = \"Ab\") == \"Ab\"\n assert candidate(s = \"abBAcC\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBbAcC\") == \"\"\n assert candidate(s = \"aabAAB\") == \"aabAAB\"\n assert candidate(s = \"AbcCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBbAcCdDeEfFgG\") == \"\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\"\n assert candidate(s = \"abcABC\") == \"abcABC\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"QwErTyUiOpAsDfGhJkLzXcVbNm\"\n assert candidate(s = \"aA\") == \"\"\n assert candidate(s = \"leEeetcode\") == \"leetcode\"\n assert candidate(s = \"AaAaAa\") == \"\"\n assert candidate(s = \"s\") == \"s\"\n assert candidate(s = \"abcAbC\") == \"abcAbC\"\n assert candidate(s = \"AbcabcABC\") == \"AbcabcABC\"\n assert candidate(s = \"aBcAdBeCfD\") == \"aBcAdBeCfD\"\n assert candidate(s = \"AaBbCc\") == \"\"\n assert candidate(s = \"aB\") == \"aB\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aAbB\") == \"\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJkkLLmmNNooppQQrrSSttuuVVwwXXyyZZ\") == \"aaBBccDDeeFFggHHiiJJkkLLmmNNooppQQrrSSttuuVVwwXXyyZZ\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaB\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIhGfEdCbA\") == \"\"\n assert candidate(s = \"aBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcD\") == \"aBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcD\"\n assert candidate(s = \"abABabABabABabABabAB\") == \"abABabABabABabABabAB\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJiHhGgFfEeDdCcBbAa\") == \"Ji\"\n assert candidate(s = \"XyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"XyZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAa\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdC\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzYxWVuTsRqPoNlKjIhGfEdCbAaBc\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzYxWVuTsRqPoNlKjIhGfEd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aBcCdDeEfFgGHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aB\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBc\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBc\"\n assert candidate(s = \"AbCDefGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbAaBcDe\") == \"AbCDefGhIjKlMlKjIhGf\"\n assert candidate(s = \"aBcAbCDefEDfGhIGhIJkIkJlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcAbCDefEDfGhIGhIJkIkJ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCd\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZd\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCd\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCd\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzABcDEfGHijKLmNoPQRSTuvWXyZ\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzABcDEfGHijKLmNoPQRSTuvWXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlM\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJfKgHlIjKlM\"\n assert candidate(s = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBb\") == \"b\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890\"\n assert candidate(s = \"mNbvCxzlKjHgfDsApoiuYtrewqQ\") == \"mNbvCxzlKjHgfDsApoiuYtrew\"\n assert candidate(s = \"aAbBcCdDeEfFgGHh\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIgFeDcBa\") == \"aBcDeFgHgFeDcBa\"\n assert candidate(s = \"aBcAbCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aBcAbC\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"abcdEfghIjklMNopQRstUVwxYZ\") == \"abcdEfghIjklMNopQRstUVwxYZ\"\n assert candidate(s = \"AbCdeFgHijklmNoPQRstUvWxYz\") == \"AbCdeFgHijklmNoPQRstUvWxYz\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAb\") == \"b\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzABcdEFghIJklMNopQRstUVwxYZ\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzABcdEFghIJklMNopQRstUVwxYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDe\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZe\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbA\") == \"AbCdEfGhIjKlMlKjIhGfEdCbA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEf\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZf\"\n assert candidate(s = \"abcdefgHIJKLMnopqrstuvwxyz\") == \"abcdefgHIJKLMnopqrstuvwxyz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbcDefGhIjKlMnOpQrStVuWxYzabcDEFghijKLMnopqrSTUVwxyZ\") == \"AbcDefGhIjKlMnOpQrStVuWxYzabcDEFghijKLMnopqrSTUVwxyZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgG\") == \"\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\") == \"zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhH\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890!@#$%^&*()\") == \"a1234567890!@#$%^&*()\"\n assert candidate(s = \"AbCbaBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"AbCbaB\"\n assert candidate(s = \"mNnMoPpQqRrSsTtUuVvWwXxYyZz\") == \"o\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"aBbAcCcAdDdAeEeAfFfAgGgAhHhAiIiAjJjAkKkAlLlAmMmAnNnAoOoApPpAqQqArRrAsStTuUuAvVvAwWwAxXxAyYyAzZz\") == \"cAdAeAfAgAhAiAjAkAlAmAnAoApAqArAuAvAwAxAyAz\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBbAcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"\"\n assert candidate(s = \"abcABCabcABC\") == \"abcABCabcABC\"\n assert candidate(s = \"xYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZ\") == \"xYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZ\"\n assert candidate(s = \"abcABCabcABCabcABCabcABC\") == \"abcABCabcABCabcABCabcABC\"\n assert candidate(s = \"ThisIsATestStringToCheckTheFunctionalityOfTheGivenCode\") == \"ThisIsATestStringToCheckTheFunctionalityOfTheGivenCode\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMlKjIhGaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"abcdefGHIJKLmnopQRSTuvwXYZ\") == \"abcdefGHIJKLmnopQRSTuvwXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgG\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIhGfEdCbAaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aaaaAAaaAAaaaAAaAaaaAA\") == \"aaaa\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBaCbAdCdEfFgHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBaCbAdCdEgH\"\n assert candidate(s = \"XyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYz\") == \"XyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYz\"\n assert candidate(s = \"aBcCdEfFgHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aBdEgH\"\n", "comparison": "exact"}, "public_tests": ["\"leEeetcode\"", "\"abBAcC\"", "\"s\""], "hints": ["The order you choose 2 characters to remove doesn't matter.", "Keep applying the mentioned step to s till the length of the string is not changed."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeGood", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:16+00:00", "tests_total": 107, "tests_dropped": 10, "flags": [], "topic_tags": ["string", "stack"]}, "language": "python", "interface": {"raw_signature": "def makeGood(self, s: str) -> str:", "container": "Solution", "callable": "makeGood", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1545, "task_id": "find-kth-bit-in-nth-binary-string", "difficulty": "Medium", "problem_description": "Given two positive integers n and k, the binary string S_n is formed as follows:\n\n- S_1 = \"0\"\n- S_i = S_{i - 1} + \"1\" + reverse(invert(S_{i - 1})) for i > 1\n\nWhere + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).\n\nFor example, the first four strings in the above sequence are:\n\n- S_1= \"0\"\n- S_2= \"011\"\n- S_3= \"0111001\"\n- S_4 = \"011100110110001\"\n\nReturn the k^th bit in S_n. It is guaranteed that k is valid for the given n.\n\nExample 1:\n\nInput: n = 3, k = 1\nOutput: \"0\"\nExplanation: S_3 is \"0111001\".\nThe 1^st bit is \"0\".\n\nExample 2:\n\nInput: n = 4, k = 11\nOutput: \"1\"\nExplanation: S_4 is \"011100110110001\".\nThe 11^th bit is \"1\".\n\nConstraints:\n\n- 1 <= n <= 20\n- 1 <= k <= 2^n - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,k = 31) == \"1\"\n assert candidate(n = 4,k = 11) == \"1\"\n assert candidate(n = 14,k = 511) == \"1\"\n assert candidate(n = 15,k = 545) == \"0\"\n assert candidate(n = 17,k = 65536) == \"1\"\n assert candidate(n = 18,k = 131071) == \"1\"\n assert candidate(n = 10,k = 127) == \"1\"\n assert candidate(n = 19,k = 262144) == \"1\"\n assert candidate(n = 13,k = 289) == \"0\"\n assert candidate(n = 12,k = 2047) == \"1\"\n assert candidate(n = 7,k = 40) == \"1\"\n assert candidate(n = 11,k = 148) == \"1\"\n assert candidate(n = 10,k = 511) == \"1\"\n assert candidate(n = 20,k = 524287) == \"1\"\n assert candidate(n = 16,k = 1023) == \"1\"\n assert candidate(n = 11,k = 1024) == \"1\"\n assert candidate(n = 9,k = 85) == \"0\"\n assert candidate(n = 14,k = 8191) == \"1\"\n assert candidate(n = 15,k = 16384) == \"1\"\n assert candidate(n = 16,k = 32767) == \"1\"\n assert candidate(n = 20,k = 4095) == \"1\"\n assert candidate(n = 20,k = 1048575) == \"1\"\n assert candidate(n = 12,k = 255) == \"1\"\n assert candidate(n = 5,k = 16) == \"1\"\n assert candidate(n = 8,k = 63) == \"1\"\n assert candidate(n = 17,k = 1057) == \"0\"\n assert candidate(n = 3,k = 1) == \"0\"\n assert candidate(n = 8,k = 127) == \"1\"\n assert candidate(n = 9,k = 256) == \"1\"\n assert candidate(n = 13,k = 4096) == \"1\"\n assert candidate(n = 19,k = 2081) == \"0\"\n assert candidate(n = 18,k = 2047) == \"1\"\n assert candidate(n = 7,k = 64) == \"1\"\n assert candidate(n = 19,k = 262143) == \"1\"\n assert candidate(n = 9,k = 128) == \"1\"\n assert candidate(n = 17,k = 32767) == \"1\"\n assert candidate(n = 10,k = 1023) == \"1\"\n assert candidate(n = 14,k = 8192) == \"1\"\n assert candidate(n = 14,k = 4096) == \"1\"\n assert candidate(n = 13,k = 2048) == \"1\"\n assert candidate(n = 13,k = 8191) == \"1\"\n assert candidate(n = 11,k = 1023) == \"1\"\n assert candidate(n = 17,k = 131071) == \"1\"\n assert candidate(n = 16,k = 65535) == \"1\"\n assert candidate(n = 18,k = 65536) == \"1\"\n assert candidate(n = 19,k = 4096) == \"1\"\n assert candidate(n = 9,k = 255) == \"1\"\n assert candidate(n = 20,k = 524288) == \"1\"\n assert candidate(n = 14,k = 16383) == \"1\"\n assert candidate(n = 15,k = 32767) == \"1\"\n assert candidate(n = 19,k = 524287) == \"1\"\n assert candidate(n = 19,k = 4095) == \"1\"\n assert candidate(n = 10,k = 512) == \"1\"\n assert candidate(n = 3,k = 5) == \"0\"\n assert candidate(n = 17,k = 16385) == \"0\"\n assert candidate(n = 11,k = 2047) == \"1\"\n assert candidate(n = 9,k = 511) == \"1\"\n assert candidate(n = 8,k = 255) == \"1\"\n assert candidate(n = 3,k = 7) == \"1\"\n assert candidate(n = 8,k = 128) == \"1\"\n assert candidate(n = 19,k = 327679) == \"1\"\n assert candidate(n = 18,k = 262143) == \"1\"\n assert candidate(n = 16,k = 32768) == \"1\"\n assert candidate(n = 19,k = 511999) == \"1\"\n assert candidate(n = 2,k = 2) == \"1\"\n assert candidate(n = 17,k = 65535) == \"1\"\n assert candidate(n = 13,k = 4095) == \"1\"\n assert candidate(n = 8,k = 64) == \"1\"\n assert candidate(n = 20,k = 1) == \"0\"\n assert candidate(n = 10,k = 256) == \"1\"\n", "comparison": "exact"}, "public_tests": ["3\n1", "4\n11"], "hints": ["Since n is small, we can simply simulate the process of constructing S1 to Sn."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findKthBit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:18+00:00", "tests_total": 85, "tests_dropped": 15, "flags": [], "topic_tags": ["string", "recursion", "simulation"]}, "language": "python", "interface": {"raw_signature": "def findKthBit(self, n: int, k: int) -> str:", "container": "Solution", "callable": "findKthBit", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1546, "task_id": "maximum-number-of-non-overlapping-subarrays-with-sum-equals-target", "difficulty": "Medium", "problem_description": "Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.\n\nExample 1:\n\nInput: nums = [1,1,1,1,1], target = 2\nOutput: 2\nExplanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).\n\nExample 2:\n\nInput: nums = [-1,3,5,1,4,2,-9], target = 6\nOutput: 2\nExplanation: There are 3 subarrays with sum equal to 6.\n([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^4 <= nums[i] <= 10^4\n- 0 <= target <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],target = 9) == 1\n assert candidate(nums = [-1, 3, 5, 1, 4, 2, -9],target = 6) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],target = 15) == 2\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 5\n assert candidate(nums = [1, -1, 2, -2, 3, -3],target = 0) == 3\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],target = 15) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 3\n assert candidate(nums = [10, -5, 5, -3, 2, 3, -1, 7],target = 5) == 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],target = 20) == 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],target = 38) == 1\n assert candidate(nums = [-2, 2, -2, 2, -2, 2, -2, 2, -2, 2],target = 0) == 5\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],target = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 2\n assert candidate(nums = [100, -25, 25, -50, 50, 150, -150, 200, -200],target = 100) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],target = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 1, 2, 3, 4, 5, -10, 1, 2, 3],target = 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],target = 0) == 10\n assert candidate(nums = [1000, -500, 500, -300, 200, 300, -100, 700],target = 500) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 5\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],target = 150) == 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],target = 1) == 30\n assert candidate(nums = [5, -2, 5, -2, 5, -2, 5, -2, 5, -2],target = 3) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 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],target = 1) == 1\n assert candidate(nums = [100, -50, 50, -25, 25, 125, -125, 62, -62, 31, -31],target = 50) == 2\n assert candidate(nums = [5, 1, 3, 7, 8, 2, 4, 6, 9, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],target = 5) == 2\n assert candidate(nums = [10, 5, 5, 15, 10, 10, 5, 5, 20, 15],target = 20) == 3\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000],target = 10000) == 3\n assert candidate(nums = [3, 4, -2, 3, -2, 5, -5, 1, 1, 1],target = 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],target = 2) == 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],target = 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],target = 5) == 4\n assert candidate(nums = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],target = 9) == 3\n assert candidate(nums = [10, 5, -5, 10, 15, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50, 55, -55, 60, -60],target = 10) == 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],target = 55) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5],target = 9) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 3\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],target = 0) == 10\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],target = 100) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 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],target = 1) == 20\n assert candidate(nums = [100, -25, 25, -50, 50, -75, 75, -100, 100, -125, 125],target = 50) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 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],target = 15) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 3\n assert candidate(nums = [100, -25, 25, -25, 25, 25, -50, 25, -25, 25, 25, -50, 100, -200, 100],target = 25) == 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 = 30) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5],target = 5) == 4\n assert candidate(nums = [5, 1, 3, 7, 2, 8, 6, 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 5\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10],target = 0) == 10\n assert candidate(nums = [9, 3, 6, 9, 3, 6, 9, 3, 6, 9],target = 12) == 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],target = 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],target = 0) == 10\n assert candidate(nums = [1, -1, 0, 1, 0, -1, 1],target = 0) == 4\n assert candidate(nums = [3, 2, 1, 6, 3, 3, 2, 1, 6, 3, 3, 2, 1, 6, 3],target = 9) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],target = 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],target = 55) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 5\n assert candidate(nums = [100, -50, 50, -25, 25, -10, 10, 5, -5, 15, -15],target = 25) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, 10, 5, 0, -5, -10, 1, 2, 3, 4, 5],target = 0) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 10\n assert candidate(nums = [1000, -500, 500, -250, 250, -125, 125, 0, 0, 0, 0, 0, 0, 0, 0],target = 250) == 2\n assert candidate(nums = [-2, 2, 3, -3, 4, 5, -5, 4, 6, -6, 7, -7, 8, -8],target = 0) == 6\n assert candidate(nums = [5, 1, 3, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 6) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 8\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 150) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 8\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],target = 75) == 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],target = 0) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5],target = 5) == 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 = 100) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 2\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1],target = 0) == 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],target = 10) == 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],target = 0) == 20\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000],target = 10000) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 75) == 2\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10],target = 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],target = 15) == 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],target = 0) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 15\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 = 100) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 28) == 1\n", "comparison": "exact"}, "public_tests": ["[1,1,1,1,1]\n2", "[-1,3,5,1,4,2,-9]\n6"], "hints": ["Keep track of prefix sums to quickly look up what subarray that sums \"target\" can be formed at each step of scanning the input array.", "It can be proved that greedily forming valid subarrays as soon as one is found is optimal."], "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().maxNonOverlapping", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:21+00:00", "tests_total": 96, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxNonOverlapping(self, nums: list[int], target: int) -> int:", "container": "Solution", "callable": "maxNonOverlapping", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1547, "task_id": "minimum-cost-to-cut-a-stick", "difficulty": "Hard", "problem_description": "Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:\n\nGiven an integer array cuts where cuts[i] denotes a position you should perform a cut at.\n\nYou should perform the cuts in order, you can change the order of the cuts as you wish.\n\nThe cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.\n\nReturn the minimum total cost of the cuts.\n\nExample 1:\n\nInput: n = 7, cuts = [1,3,4,5]\nOutput: 16\nExplanation: Using cuts order = [1, 3, 4, 5] as in the input leads to the following scenario:\n\nThe first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3. The total cost is 7 + 6 + 4 + 3 = 20.\nRearranging the cuts to be [3, 5, 1, 4] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).\n\nExample 2:\n\nInput: n = 9, cuts = [5,6,1,4,2]\nOutput: 22\nExplanation: If you try the given cuts ordering the cost will be 25.\nThere are much ordering with total cost <= 25, for example, the order [4, 6, 5, 2, 1] has total cost = 22 which is the minimum possible.\n\nConstraints:\n\n- 2 <= n <= 10^6\n- 1 <= cuts.length <= min(n - 1, 100)\n- 1 <= cuts[i] <= n - 1\n- All the integers in cuts array are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,cuts = [3, 5, 10]) == 30\n assert candidate(n = 100,cuts = [50, 25, 75, 10, 90, 60, 30, 40, 80]) == 330\n assert candidate(n = 15,cuts = [1, 5, 9, 13]) == 35\n assert candidate(n = 7,cuts = [1, 3, 4, 5]) == 16\n assert candidate(n = 10,cuts = [2, 4, 7]) == 20\n assert candidate(n = 8,cuts = [1, 3, 5, 7]) == 19\n assert candidate(n = 8,cuts = [1, 3, 6]) == 16\n assert candidate(n = 6,cuts = [3, 1, 5]) == 12\n assert candidate(n = 6,cuts = [1, 2, 3, 4, 5]) == 16\n assert candidate(n = 15,cuts = [3, 5, 12, 10]) == 35\n assert candidate(n = 12,cuts = [1, 3, 5, 7, 9]) == 31\n assert candidate(n = 12,cuts = [2, 3, 10, 11]) == 26\n assert candidate(n = 12,cuts = [1, 5, 8, 10]) == 28\n assert candidate(n = 10,cuts = [1, 2, 3, 4, 5]) == 22\n assert candidate(n = 5,cuts = [1, 4]) == 9\n assert candidate(n = 15,cuts = [2, 7, 10, 13]) == 35\n assert candidate(n = 8,cuts = [2, 5]) == 13\n assert candidate(n = 9,cuts = [5, 6, 1, 4, 2]) == 22\n assert candidate(n = 12,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 44\n assert candidate(n = 8,cuts = [2, 3, 5, 6]) == 19\n assert candidate(n = 20,cuts = [3, 8, 10, 12, 15]) == 51\n assert candidate(n = 20,cuts = [3, 6, 9, 12, 15]) == 52\n assert candidate(n = 8,cuts = [3, 5]) == 13\n assert candidate(n = 50,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 170\n assert candidate(n = 400,cuts = [120, 240, 60, 180, 300, 360, 90, 210, 330, 390]) == 1360\n assert candidate(n = 150,cuts = [20, 40, 60, 80, 100, 120, 140]) == 450\n assert candidate(n = 512,cuts = [64, 128, 192, 256, 320, 384, 448]) == 1536\n assert candidate(n = 300,cuts = [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]) == 1480\n assert candidate(n = 1024,cuts = [128, 256, 384, 512, 640, 768, 896]) == 3072\n assert candidate(n = 200,cuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 700\n assert candidate(n = 500,cuts = [100, 150, 200, 250, 300, 350, 400, 450]) == 1600\n assert candidate(n = 10000,cuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 34000\n assert candidate(n = 900,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 450, 350, 250, 150, 50]) == 3400\n assert candidate(n = 30,cuts = [29, 1, 28, 14, 22, 19, 3, 7, 11, 25, 26, 9, 21, 15, 6, 23, 17, 2, 18, 5, 24, 20, 12, 16, 8, 10, 4, 27, 13]) == 148\n assert candidate(n = 750,cuts = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720, 740]) == 3980\n assert candidate(n = 600,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 580]) == 2250\n assert candidate(n = 35,cuts = [3, 7, 11, 15, 19, 23, 27, 31]) == 112\n assert candidate(n = 20,cuts = [2, 5, 8, 11, 14, 17]) == 57\n assert candidate(n = 150,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 590\n assert candidate(n = 729,cuts = [27, 54, 81, 108, 135, 162, 189, 216, 243, 270, 297, 324, 351, 378, 405, 432, 459, 486, 513, 540, 567, 594, 621, 648, 675, 702]) == 3510\n assert candidate(n = 120,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 440\n assert candidate(n = 1500,cuts = [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]) == 7400\n assert candidate(n = 25,cuts = [5, 15, 20, 10]) == 60\n assert candidate(n = 500,cuts = [10, 25, 45, 70, 100, 150, 200, 250, 300, 350, 400]) == 1720\n assert candidate(n = 1000,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 3400\n assert candidate(n = 2500,cuts = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400]) == 9400\n assert candidate(n = 999,cuts = [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]) == 1565\n assert candidate(n = 50,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 170\n assert candidate(n = 750,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700]) == 2950\n assert candidate(n = 200,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 880\n assert candidate(n = 1000,cuts = [10, 50, 90, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 3640\n assert candidate(n = 700,cuts = [140, 280, 420, 560, 70, 210, 350, 490, 630, 175, 315, 455, 595]) == 2660\n assert candidate(n = 10000,cuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 34000\n assert candidate(n = 250,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225]) == 850\n assert candidate(n = 500,cuts = [100, 200, 300, 400, 150, 250, 350, 450, 50, 450]) == 1750\n assert candidate(n = 1000,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 3400\n assert candidate(n = 70,cuts = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 238\n assert candidate(n = 100,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 182\n assert candidate(n = 40,cuts = [10, 20, 30]) == 80\n assert candidate(n = 600,cuts = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580]) == 2960\n assert candidate(n = 600,cuts = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570]) == 2640\n assert candidate(n = 400,cuts = [50, 100, 150, 200, 250, 300, 350]) == 1200\n assert candidate(n = 2000,cuts = [100, 500, 800, 1500, 1900, 1600, 1200, 700, 300, 1100, 1700, 1800, 600, 900, 400, 200]) == 8100\n assert candidate(n = 500,cuts = [100, 200, 300, 400, 150, 250, 350]) == 1500\n assert candidate(n = 99,cuts = [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]) == 566\n assert candidate(n = 800,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 3200\n assert candidate(n = 800,cuts = [160, 320, 480, 640, 80, 240, 400, 560, 720, 110, 270, 430, 590, 750, 90, 250, 410, 570, 730]) == 3270\n assert candidate(n = 5000,cuts = [2000, 1000, 3000, 4000, 500, 1500, 2500, 3500, 4500, 1250, 1750, 2250, 2750, 3250, 3750, 4250, 4750, 625, 750, 1125, 1375, 1625, 1875, 2125, 2375, 2625, 2875, 3125, 3375, 3625, 3875, 4125, 4375, 4625, 4875]) == 25750\n assert candidate(n = 15,cuts = [1, 4, 7, 10, 13]) == 39\n assert candidate(n = 3000,cuts = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500, 2700, 2900]) == 12000\n assert candidate(n = 50,cuts = [2, 25, 49, 23, 37, 17, 33, 9, 41, 35]) == 170\n assert candidate(n = 300,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275]) == 1100\n assert candidate(n = 1200,cuts = [200, 400, 600, 800, 1000, 120, 320, 520, 720, 920]) == 4200\n assert candidate(n = 500,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475]) == 2200\n assert candidate(n = 256,cuts = [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, 248]) == 1280\n assert candidate(n = 600,cuts = [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]) == 3560\n assert candidate(n = 200,cuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195]) == 770\n assert candidate(n = 2000,cuts = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800]) == 8800\n assert candidate(n = 1500,cuts = [250, 500, 750, 1000, 1250, 1300, 1400, 1450, 1350, 1200]) == 4750\n assert candidate(n = 99,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 664\n assert candidate(n = 50,cuts = [3, 10, 20, 30, 40]) == 130\n assert candidate(n = 150,cuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 105, 45, 15, 90, 75, 135, 60, 120]) == 630\n assert candidate(n = 55,cuts = [11, 22, 33, 44, 5]) == 143\n assert candidate(n = 60,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 59]) == 225\n assert candidate(n = 300,cuts = [30, 60, 90, 120, 150, 180, 210, 240, 270]) == 1020\n assert candidate(n = 1000,cuts = [200, 400, 600, 800, 300, 700, 100, 900, 500]) == 3400\n assert candidate(n = 1200,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100]) == 4400\n assert candidate(n = 20,cuts = [3, 6, 9, 12, 15, 18]) == 57\n assert candidate(n = 30,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 148\n assert candidate(n = 1000,cuts = [200, 400, 600, 800, 100, 300, 500, 700, 900]) == 3400\n", "comparison": "exact"}, "public_tests": ["7\n[1,3,4,5]", "9\n[5,6,1,4,2]"], "hints": ["Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j.", "When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them."], "metadata": {"canonical_parameter_names": ["n", "cuts"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:23+00:00", "tests_total": 97, "tests_dropped": 7, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "sorting"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, n: int, cuts: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "n", "type": "int"}, {"name": "cuts", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1550, "task_id": "three-consecutive-odds", "difficulty": "Easy", "problem_description": "Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.\n\nExample 1:\n\nInput: arr = [2,6,4,1]\nOutput: false\nExplanation: There are no three consecutive odds.\n\nExample 2:\n\nInput: arr = [1,2,34,3,4,5,7,23,12]\nOutput: true\nExplanation: [5,7,23] are three consecutive odds.\n\nConstraints:\n\n- 1 <= arr.length <= 1000\n- 1 <= arr[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 3, 2, 5, 7, 9]) == True\n assert candidate(arr = [2, 4, 6, 8, 10]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1000, 999, 998, 997]) == False\n assert candidate(arr = [2, 3, 5, 7, 11, 13]) == True\n assert candidate(arr = [2, 6, 4, 1]) == False\n assert candidate(arr = [999, 997, 995, 993, 991]) == True\n assert candidate(arr = [11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1, 3, 2, 3, 5, 7]) == True\n assert candidate(arr = [2, 4, 6, 8]) == False\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 2]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [999, 997, 995]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [1, 2, 34, 3, 4, 5, 7, 23, 12]) == True\n assert candidate(arr = [1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [2, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 3, 5]) == True\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93]) == True\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]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == True\n assert candidate(arr = [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]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == True\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]) == False\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(arr = [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]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61]) == True\n assert candidate(arr = [8, 10, 12, 14, 16, 18, 20, 1, 3, 5]) == True\n assert candidate(arr = [1000, 1000, 1000, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == False\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(arr = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5]) == True\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == True\n assert candidate(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]) == False\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]) == False\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == False\n assert candidate(arr = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == False\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 989, 987, 985, 983, 981, 979]) == True\n assert candidate(arr = [2, 4, 6, 8, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == False\n assert candidate(arr = [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, 226, 227, 228, 229]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]) == True\n assert candidate(arr = [1, 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, 3, 5, 7]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13]) == True\n assert candidate(arr = [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]) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29]) == True\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, 11, 11, 11, 12, 12, 12, 13, 13, 13]) == True\n assert candidate(arr = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == False\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33]) == True\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, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 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]) == True\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, 16, 16, 17, 17, 18, 18, 19, 19]) == False\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19, 19]) == True\n assert candidate(arr = [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, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1000, 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]) == True\n assert candidate(arr = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [5, 7, 9, 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]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 41, 43, 45]) == True\n assert candidate(arr = [999, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(arr = [1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == True\n assert candidate(arr = [999, 997, 995, 993, 991, 989, 987, 985, 983, 981, 979, 977, 975, 973, 971, 969, 967, 965, 963, 961, 959, 957, 955, 953, 951, 949, 947, 945, 943, 941, 939, 937, 935, 933, 931, 929, 927, 925, 923, 921, 919, 917, 915, 913, 911, 909, 907, 905, 903, 901, 899, 897, 895, 893, 891, 889, 887, 885, 883, 881]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19]) == True\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]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19]) == True\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]) == True\n assert candidate(arr = [499, 501, 503, 505, 507, 509, 511, 513, 515, 517, 519, 521, 523, 525, 527, 529]) == True\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]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [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(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79]) == True\n assert candidate(arr = [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]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(arr = [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]) == True\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7, 9, 11, 13, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(arr = [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]) == False\n assert candidate(arr = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == True\n assert candidate(arr = [2, 4, 6, 8, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989]) == False\n assert candidate(arr = [1, 2, 1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987]) == False\n assert candidate(arr = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15, 14, 15, 16, 17, 16, 17, 18, 19, 18, 19, 20]) == False\n assert candidate(arr = [1, 3, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 71]) == False\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209]) == True\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]) == True\n assert candidate(arr = [3, 5, 7, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == False\n", "comparison": "exact"}, "public_tests": ["[2,6,4,1]", "[1,2,34,3,4,5,7,23,12]"], "hints": ["Check every three consecutive numbers in the array for parity."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().threeConsecutiveOdds", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:28+00:00", "tests_total": 131, "tests_dropped": 10, "flags": [], "topic_tags": ["array"]}, "language": "python", "interface": {"raw_signature": "def threeConsecutiveOdds(self, arr: list[int]) -> bool:", "container": "Solution", "callable": "threeConsecutiveOdds", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1551, "task_id": "minimum-operations-to-make-array-equal", "difficulty": "Medium", "problem_description": "You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).\n\nIn one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.\n\nGiven an integer n, the length of the array, return the minimum number of operations needed to make all the elements of arr equal.\n\nExample 1:\n\nInput: n = 3\nOutput: 2\nExplanation: arr = [1, 3, 5]\nFirst operation choose x = 2 and y = 0, this leads arr to be [2, 3, 4]\nIn the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].\n\nExample 2:\n\nInput: n = 6\nOutput: 9\n\nConstraints:\n\n- 1 <= n <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 2500\n assert candidate(n = 10000) == 25000000\n assert candidate(n = 6) == 9\n assert candidate(n = 1) == 0\n assert candidate(n = 1000) == 250000\n assert candidate(n = 10) == 25\n assert candidate(n = 7000) == 12250000\n assert candidate(n = 49) == 600\n assert candidate(n = 2000) == 1000000\n assert candidate(n = 7500) == 14062500\n assert candidate(n = 8888) == 19749136\n assert candidate(n = 50) == 625\n assert candidate(n = 3333) == 2777222\n assert candidate(n = 5) == 6\n assert candidate(n = 3000) == 2250000\n assert candidate(n = 6789) == 11522630\n assert candidate(n = 1200) == 360000\n assert candidate(n = 99) == 2450\n assert candidate(n = 5001) == 6252500\n assert candidate(n = 1001) == 250500\n assert candidate(n = 2) == 1\n assert candidate(n = 101) == 2550\n assert candidate(n = 8) == 16\n assert candidate(n = 9998) == 24990001\n assert candidate(n = 999) == 249500\n assert candidate(n = 5555) == 7714506\n assert candidate(n = 8000) == 16000000\n assert candidate(n = 5000) == 6250000\n assert candidate(n = 9999) == 24995000\n assert candidate(n = 19) == 90\n assert candidate(n = 77) == 1482\n assert candidate(n = 6667) == 11112222\n assert candidate(n = 150) == 5625\n assert candidate(n = 13) == 42\n assert candidate(n = 7654) == 14645929\n assert candidate(n = 11) == 30\n assert candidate(n = 15) == 56\n assert candidate(n = 2500) == 1562500\n assert candidate(n = 9000) == 20250000\n assert candidate(n = 4999) == 6247500\n assert candidate(n = 200) == 10000\n assert candidate(n = 6000) == 9000000\n assert candidate(n = 499) == 62250\n assert candidate(n = 500) == 62500\n assert candidate(n = 7) == 12\n assert candidate(n = 25) == 156\n assert candidate(n = 1500) == 562500\n", "comparison": "exact"}, "public_tests": ["3", "6"], "hints": ["Build the array arr using the given formula, define target = sum(arr) / n", "What is the number of operations needed to convert arr so that all elements equal target ?"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:30+00:00", "tests_total": 53, "tests_dropped": 5, "flags": [], "topic_tags": ["math"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, n: int) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1552, "task_id": "magnetic-force-between-two-balls", "difficulty": "Medium", "problem_description": "In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the i^th basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.\n\nRick stated that magnetic force between two different balls at positions x and y is |x - y|.\n\nGiven the integer array position and the integer m. Return the required force.\n\nExample 1:\n\nInput: position = [1,2,3,4,7], m = 3\nOutput: 3\nExplanation: Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs [3, 3, 6]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.\n\nExample 2:\n\nInput: position = [5,4,3,2,1,1000000000], m = 2\nOutput: 999999999\nExplanation: We can use baskets 1 and 1000000000.\n\nConstraints:\n\n- n == position.length\n- 2 <= n <= 10^5\n- 1 <= position[i] <= 10^9\n- All integers in position are distinct.\n- 2 <= m <= position.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 2\n assert candidate(position = [5, 4, 3, 2, 1, 1000000000],m = 2) == 999999999\n assert candidate(position = [1, 3, 5, 7, 9],m = 4) == 2\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 5) == 4\n assert candidate(position = [10, 20, 30, 40, 50],m = 4) == 10\n assert candidate(position = [10, 15, 20, 25, 30],m = 3) == 10\n assert candidate(position = [1, 1000000000],m = 2) == 999999999\n assert candidate(position = [10, 20, 30, 40, 50],m = 3) == 20\n assert candidate(position = [1, 2, 3, 4, 7],m = 3) == 3\n assert candidate(position = [1, 2, 8, 4, 9],m = 3) == 3\n assert candidate(position = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],m = 11) == 99\n assert candidate(position = [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],m = 10) == 30\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 12) == 10\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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 = 10) == 3\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 7) == 20\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],m = 6) == 31\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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 = 25) == 1\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == 1\n assert candidate(position = [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],m = 20) == 2\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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],m = 25) == 2\n assert candidate(position = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],m = 15) == 5\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 5) == 999999\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10) == 2\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],m = 7) == 40\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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 = 50) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 10) == 20\n assert candidate(position = [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],m = 12) == 20\n assert candidate(position = [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],m = 20) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],m = 8) == 30\n assert candidate(position = [1, 2, 8, 4, 9, 15, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100],m = 6) == 18\n assert candidate(position = [1, 4, 10, 15, 20, 26, 30, 40],m = 5) == 9\n assert candidate(position = [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],m = 20) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 19\n assert candidate(position = [1, 2, 3, 6, 7, 8, 10, 12, 13, 15],m = 6) == 2\n assert candidate(position = [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],m = 25) == 4\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 7) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 300, 400, 500, 600],m = 15) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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 = 17) == 1\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 15) == 10\n assert candidate(position = [1, 1000000000],m = 2) == 999999999\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 200, 300, 400, 500, 600, 700, 800, 900, 1000],m = 10) == 100\n assert candidate(position = [1, 100, 1000, 10000, 100000, 1000000, 10000000],m = 4) == 99999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],m = 10) == 20\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],m = 15) == 127\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 10) == 20\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10) == 2\n assert candidate(position = [1, 5, 9, 15, 22, 30],m = 5) == 6\n assert candidate(position = [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],m = 15) == 4\n assert candidate(position = [1, 3, 6, 8, 12, 15, 18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],m = 15) == 5\n assert candidate(position = [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],m = 15) == 57\n assert candidate(position = [1, 3, 6, 8, 11, 14, 17, 20, 25, 30, 35, 40, 45, 50],m = 8) == 5\n assert candidate(position = [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],m = 25) == 20\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],m = 7) == 20\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 10\n assert candidate(position = [1, 1000000000, 2, 500000000, 750000000],m = 3) == 499999999\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],m = 5) == 18\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],m = 6) == 20\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 8) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 8) == 20\n assert candidate(position = [1, 5, 9, 14, 20, 25, 30],m = 5) == 5\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 5) == 999999\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 7) == 9999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],m = 5) == 20\n assert candidate(position = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],m = 5) == 200\n assert candidate(position = [1, 2, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],m = 5) == 6\n assert candidate(position = [1, 3, 6, 8, 12, 15, 18, 20, 22, 25, 28, 30],m = 7) == 3\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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) == 2\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 20) == 2\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 8) == 20\n assert candidate(position = [5, 18, 23, 42, 57, 62, 75, 80],m = 5) == 18\n assert candidate(position = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],m = 15) == 10\n assert candidate(position = [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],m = 15) == 20\n assert candidate(position = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],m = 8) == 8\n assert candidate(position = [1, 2, 3, 4, 5, 6, 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 = 20) == 1\n assert candidate(position = [2, 6, 8, 12, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100, 102, 104, 106, 108, 110],m = 25) == 4\n assert candidate(position = [1, 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 = 13) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 11) == 19\n assert candidate(position = [1, 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 = 15) == 1\n assert candidate(position = [1, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000],m = 6) == 199999999\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,7]\n3", "[5,4,3,2,1,1000000000]\n2"], "hints": ["If you can place balls such that the answer is x then you can do it for y where y < x.", "Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x.", "Binary search on the answer and greedily see if it is possible."], "metadata": {"canonical_parameter_names": ["position", "m"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:32+00:00", "tests_total": 87, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def maxDistance(self, position: list[int], m: int) -> int:", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "position", "type": "list[int]"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1553, "task_id": "minimum-number-of-days-to-eat-n-oranges", "difficulty": "Hard", "problem_description": "There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows:\n\n- Eat one orange.\n- If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.\n- If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.\n\nYou can only choose one of the actions per day.\n\nGiven the integer n, return the minimum number of days to eat n oranges.\n\nExample 1:\n\nInput: n = 10\nOutput: 4\nExplanation: You have 10 oranges.\nDay 1: Eat 1 orange, 10 - 1 = 9.\nDay 2: Eat 6 oranges, 9 - 2*(9/3) = 9 - 6 = 3. (Since 9 is divisible by 3)\nDay 3: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1.\nDay 4: Eat the last orange 1 - 1 = 0.\nYou need at least 4 days to eat the 10 oranges.\n\nExample 2:\n\nInput: n = 6\nOutput: 3\nExplanation: You have 6 oranges.\nDay 1: Eat 3 oranges, 6 - 6/2 = 6 - 3 = 3. (Since 6 is divisible by 2).\nDay 2: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. (Since 3 is divisible by 3)\nDay 3: Eat the last orange 1 - 1 = 0.\nYou need at least 3 days to eat the 6 oranges.\n\nConstraints:\n\n- 1 <= n <= 2 * 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 2000000000) == 32\n assert candidate(n = 100) == 8\n assert candidate(n = 1000) == 10\n assert candidate(n = 5) == 4\n assert candidate(n = 4) == 3\n assert candidate(n = 2) == 2\n assert candidate(n = 8) == 4\n assert candidate(n = 27) == 4\n assert candidate(n = 20) == 5\n assert candidate(n = 1000000000) == 31\n assert candidate(n = 18017459) == 28\n assert candidate(n = 15) == 5\n assert candidate(n = 9) == 3\n assert candidate(n = 1000000) == 20\n assert candidate(n = 6) == 3\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 4\n assert candidate(n = 25) == 6\n assert candidate(n = 619) == 12\n assert candidate(n = 239) == 11\n assert candidate(n = 53) == 8\n assert candidate(n = 587) == 12\n assert candidate(n = 787) == 11\n assert candidate(n = 1000000019) == 34\n assert candidate(n = 971) == 13\n assert candidate(n = 43) == 7\n assert candidate(n = 887) == 13\n assert candidate(n = 983) == 11\n assert candidate(n = 523) == 10\n assert candidate(n = 379) == 9\n assert candidate(n = 103) == 9\n assert candidate(n = 37) == 6\n assert candidate(n = 937) == 11\n assert candidate(n = 487) == 8\n assert candidate(n = 223) == 9\n assert candidate(n = 211) == 11\n assert candidate(n = 23) == 7\n assert candidate(n = 73) == 7\n assert candidate(n = 941) == 12\n assert candidate(n = 827) == 13\n assert candidate(n = 547) == 10\n assert candidate(n = 251) == 10\n assert candidate(n = 181) == 8\n assert candidate(n = 333333333) == 29\n assert candidate(n = 193) == 9\n assert candidate(n = 1048576) == 21\n assert candidate(n = 131) == 10\n assert candidate(n = 241) == 9\n assert candidate(n = 263) == 10\n assert candidate(n = 347) == 11\n assert candidate(n = 1000000013) == 34\n assert candidate(n = 857) == 13\n assert candidate(n = 383) == 11\n assert candidate(n = 997) == 11\n assert candidate(n = 569) == 10\n assert candidate(n = 929) == 12\n assert candidate(n = 571) == 10\n assert candidate(n = 491) == 10\n assert candidate(n = 11) == 5\n assert candidate(n = 643) == 12\n assert candidate(n = 246813579) == 30\n assert candidate(n = 1048575) == 23\n assert candidate(n = 823543) == 23\n assert candidate(n = 500000000) == 31\n assert candidate(n = 353) == 10\n assert candidate(n = 313) == 10\n assert candidate(n = 829) == 11\n assert candidate(n = 167) == 9\n assert candidate(n = 1111111111) == 31\n assert candidate(n = 467) == 12\n assert candidate(n = 54321) == 20\n assert candidate(n = 97) == 8\n assert candidate(n = 29) == 6\n assert candidate(n = 317) == 11\n assert candidate(n = 433) == 9\n assert candidate(n = 131071) == 21\n assert candidate(n = 789456123) == 31\n assert candidate(n = 1999999998) == 31\n assert candidate(n = 271) == 8\n assert candidate(n = 797) == 12\n assert candidate(n = 107) == 10\n assert candidate(n = 163) == 7\n assert candidate(n = 557) == 12\n assert candidate(n = 653) == 10\n assert candidate(n = 631) == 12\n assert candidate(n = 991) == 10\n assert candidate(n = 617) == 12\n assert candidate(n = 389) == 11\n assert candidate(n = 751) == 11\n assert candidate(n = 625000000) == 28\n assert candidate(n = 401) == 11\n assert candidate(n = 1000000002) == 31\n assert candidate(n = 44) == 7\n assert candidate(n = 137) == 9\n assert candidate(n = 919) == 11\n assert candidate(n = 17) == 6\n assert candidate(n = 257) == 10\n assert candidate(n = 811) == 9\n assert candidate(n = 509) == 11\n assert candidate(n = 16777215) == 24\n assert candidate(n = 777777777) == 33\n assert candidate(n = 101) == 9\n assert candidate(n = 907) == 12\n assert candidate(n = 821) == 11\n assert candidate(n = 421) == 12\n assert candidate(n = 479) == 12\n assert candidate(n = 89) == 9\n assert candidate(n = 953) == 13\n assert candidate(n = 877) == 11\n assert candidate(n = 71) == 10\n assert candidate(n = 1000000001) == 32\n assert candidate(n = 599) == 12\n assert candidate(n = 81) == 5\n assert candidate(n = 593) == 11\n assert candidate(n = 151) == 9\n assert candidate(n = 293) == 10\n assert candidate(n = 691) == 11\n assert candidate(n = 41) == 7\n assert candidate(n = 647) == 13\n assert candidate(n = 727) == 11\n assert candidate(n = 209) == 10\n assert candidate(n = 83) == 7\n assert candidate(n = 661) == 10\n assert candidate(n = 123456789) == 28\n assert candidate(n = 283) == 10\n assert candidate(n = 499) == 10\n assert candidate(n = 577) == 10\n assert candidate(n = 1000000011) == 32\n assert candidate(n = 739) == 9\n assert candidate(n = 881) == 11\n assert candidate(n = 659) == 11\n assert candidate(n = 79) == 8\n assert candidate(n = 63) == 6\n assert candidate(n = 269) == 11\n assert candidate(n = 61) == 7\n assert candidate(n = 373) == 10\n assert candidate(n = 999999999) == 30\n assert candidate(n = 227) == 10\n assert candidate(n = 563) == 12\n assert candidate(n = 47) == 8\n assert candidate(n = 4096) == 13\n assert candidate(n = 113) == 8\n assert candidate(n = 233) == 10\n assert candidate(n = 911) == 13\n assert candidate(n = 863) == 15\n assert candidate(n = 859) == 13\n assert candidate(n = 359) == 12\n assert candidate(n = 443) == 11\n assert candidate(n = 135792468) == 28\n assert candidate(n = 78125) == 18\n assert candidate(n = 191) == 9\n assert candidate(n = 125000000) == 29\n assert candidate(n = 311) == 12\n assert candidate(n = 457) == 10\n assert candidate(n = 179) == 11\n assert candidate(n = 337) == 9\n assert candidate(n = 773) == 12\n assert candidate(n = 733) == 9\n assert candidate(n = 419) == 12\n assert candidate(n = 314159265) == 28\n assert candidate(n = 65536) == 17\n assert candidate(n = 967) == 12\n assert candidate(n = 127) == 8\n assert candidate(n = 1000000007) == 34\n assert candidate(n = 947) == 13\n assert candidate(n = 987654321) == 29\n assert candidate(n = 1234567890) == 29\n assert candidate(n = 307) == 10\n assert candidate(n = 503) == 12\n assert candidate(n = 397) == 10\n assert candidate(n = 26) == 6\n assert candidate(n = 281) == 10\n assert candidate(n = 743) == 11\n assert candidate(n = 1800000000) == 31\n assert candidate(n = 3125) == 15\n assert candidate(n = 1999999999) == 32\n assert candidate(n = 899999999) == 36\n assert candidate(n = 13) == 5\n assert candidate(n = 719) == 14\n assert candidate(n = 222222222) == 29\n assert candidate(n = 59049) == 11\n assert candidate(n = 601) == 11\n assert candidate(n = 1000000003) == 32\n assert candidate(n = 367) == 10\n assert candidate(n = 125) == 9\n assert candidate(n = 839) == 11\n assert candidate(n = 277) == 10\n assert candidate(n = 19683) == 10\n assert candidate(n = 613) == 11\n assert candidate(n = 89123456) == 27\n assert candidate(n = 197) == 10\n assert candidate(n = 157) == 9\n assert candidate(n = 769) == 11\n assert candidate(n = 673) == 10\n assert candidate(n = 439) == 10\n assert candidate(n = 1500000000) == 32\n assert candidate(n = 331) == 9\n assert candidate(n = 173) == 9\n assert candidate(n = 67) == 8\n assert candidate(n = 607) == 12\n assert candidate(n = 349) == 10\n assert candidate(n = 431) == 14\n assert candidate(n = 666666666) == 30\n assert candidate(n = 683) == 12\n assert candidate(n = 449) == 10\n assert candidate(n = 677) == 11\n assert candidate(n = 809) == 13\n assert candidate(n = 977) == 10\n assert candidate(n = 897654321) == 30\n assert candidate(n = 463) == 11\n assert candidate(n = 757) == 9\n assert candidate(n = 521) == 12\n assert candidate(n = 853) == 13\n assert candidate(n = 1024) == 11\n assert candidate(n = 883) == 11\n assert candidate(n = 709) == 11\n assert candidate(n = 701) == 12\n assert candidate(n = 823) == 11\n assert candidate(n = 149) == 9\n assert candidate(n = 19) == 5\n assert candidate(n = 139) == 9\n assert candidate(n = 461) == 11\n assert candidate(n = 541) == 9\n assert candidate(n = 641) == 11\n assert candidate(n = 761) == 11\n assert candidate(n = 109) == 7\n assert candidate(n = 31) == 6\n assert candidate(n = 229) == 9\n assert candidate(n = 199) == 9\n assert candidate(n = 7) == 4\n assert candidate(n = 409) == 10\n", "comparison": "exact"}, "public_tests": ["10", "6"], "hints": ["In each step, choose between 2 options: minOranges = 1 + min( (n%2) + f(n/2), (n%3) + f(n/3) ) where f(n) is the minimum number of days to eat n oranges."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:35+00:00", "tests_total": 234, "tests_dropped": 2, "flags": [], "topic_tags": ["dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def minDays(self, n: int) -> int:", "container": "Solution", "callable": "minDays", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1556, "task_id": "thousand-separator", "difficulty": "Easy", "problem_description": "Given an integer n, add a dot (\".\") as the thousands separator and return it in string format.\n\nExample 1:\n\nInput: n = 987\nOutput: \"987\"\n\nExample 2:\n\nInput: n = 1234\nOutput: \"1.234\"\n\nConstraints:\n\n- 0 <= n <= 2^31 - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == \"0\"\n assert candidate(n = 1234) == \"1.234\"\n assert candidate(n = 1000000) == \"1.000.000\"\n assert candidate(n = 2147483647) == \"2.147.483.647\"\n assert candidate(n = 123456789) == \"123.456.789\"\n assert candidate(n = 1234567) == \"1.234.567\"\n assert candidate(n = 123456) == \"123.456\"\n assert candidate(n = 56789) == \"56.789\"\n assert candidate(n = 1000) == \"1.000\"\n assert candidate(n = 987) == \"987\"\n assert candidate(n = 999999999) == \"999.999.999\"\n assert candidate(n = 100) == \"100\"\n assert candidate(n = 456789012) == \"456.789.012\"\n assert candidate(n = 123) == \"123\"\n assert candidate(n = 1) == \"1\"\n assert candidate(n = 1001001) == \"1.001.001\"\n assert candidate(n = 10000) == \"10.000\"\n assert candidate(n = 1001) == \"1.001\"\n assert candidate(n = 101010101) == \"101.010.101\"\n assert candidate(n = 100000) == \"100.000\"\n assert candidate(n = 999) == \"999\"\n assert candidate(n = 1000000000) == \"1.000.000.000\"\n assert candidate(n = 111111111) == \"111.111.111\"\n assert candidate(n = 1010101010) == \"1.010.101.010\"\n assert candidate(n = 1234567890) == \"1.234.567.890\"\n assert candidate(n = 567890123) == \"567.890.123\"\n assert candidate(n = 987654321) == \"987.654.321\"\n assert candidate(n = 999999) == \"999.999\"\n assert candidate(n = 1111111111) == \"1.111.111.111\"\n assert candidate(n = 54321) == \"54.321\"\n assert candidate(n = 10) == \"10\"\n", "comparison": "exact"}, "public_tests": ["987", "1234"], "hints": ["Scan from the back of the integer and use dots to connect blocks with length 3 except the last block."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().thousandSeparator", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:39+00:00", "tests_total": 50, "tests_dropped": 19, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def thousandSeparator(self, n: int) -> str:", "container": "Solution", "callable": "thousandSeparator", "parameters": [{"name": "n", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1557, "task_id": "minimum-number-of-vertices-to-reach-all-nodes", "difficulty": "Medium", "problem_description": "Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [from_i, to_i] represents a directed edge from node from_i to node to_i.\n\nFind the smallest set of vertices from which all nodes in the graph are reachable. It's guaranteed that a unique solution exists.\n\nNotice that you can return the vertices in any order.\n\nExample 1:\n\nInput: n = 6, edges = [[0,1],[0,2],[2,5],[3,4],[4,2]]\nOutput: [0,3]\nExplanation: It's not possible to reach all the nodes from a single vertex. From 0 we can reach [0,1,2,5]. From 3 we can reach [3,4,2,5]. So we output [0,3].\n\nExample 2:\n\nInput: n = 5, edges = [[0,1],[2,1],[3,1],[1,4],[2,4]]\nOutput: [0,2,3]\nExplanation: Notice that vertices 0, 3 and 2 are not reachable from any other node, so we must include them. Also any of these vertices can reach nodes 1 and 4.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- 1 <= edges.length <= min(10^5, n * (n - 1) / 2)\n- edges[i].length == 2\n- 0 <= from_i, to_i < n\n- All pairs (from_i, to_i) are distinct.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=7, edges=[[1, 2], [3, 4], [5, 6]]), [0, 1, 3, 5])\n assert answers_match(candidate(n=6, edges=[[0, 1], [0, 2], [2, 5], [3, 4], [4, 2]]), [0, 3])\n assert answers_match(candidate(n=4, edges=[[2, 0], [2, 1], [1, 3]]), [2])\n assert answers_match(candidate(n=3, edges=[[0, 1], [0, 2]]), [0])\n assert answers_match(candidate(n=5, edges=[[0, 1], [2, 1], [3, 1], [1, 4], [2, 4]]), [0, 2, 3])\n assert answers_match(candidate(n=10, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]), [0, 5])\n assert answers_match(candidate(n=15, edges=[[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]]), [0])\n assert answers_match(candidate(n=20, 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, 19], [17, 19], [18, 19]]), [0])\n assert answers_match(candidate(n=16, 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, 13], [14, 15]]), [0])\n assert answers_match(candidate(n=11, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]), [0])\n assert answers_match(candidate(n=20, 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]]), [0])\n assert answers_match(candidate(n=20, edges=[[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19]]), [0])\n assert answers_match(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 answers_match(candidate(n=15, edges=[[0, 1], [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]]), [0])\n assert answers_match(candidate(n=14, 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, 11], [6, 12], [7, 13], [8, 13]]), [0])\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]), [0])\n assert answers_match(candidate(n=14, 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, 13], [11, 12]]), [0])\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]]), [0])\n assert answers_match(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])\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [0, 9]]), [0])\n assert answers_match(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], [6, 12]]), [0])\n assert answers_match(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 answers_match(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], [3, 6], [4, 7], [5, 8]]), [])\n assert answers_match(candidate(n=9, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [5, 7], [6, 8]]), [0])\n assert answers_match(candidate(n=10, edges=[[1, 2], [1, 3], [3, 4], [4, 5], [6, 7], [8, 9]]), [0, 1, 6, 8])\n assert answers_match(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], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15]]), [0])\n assert answers_match(candidate(n=11, 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]]), [0])\n assert answers_match(candidate(n=9, edges=[[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 8]]), [0])\n assert answers_match(candidate(n=9, edges=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 1]]), [])\n assert answers_match(candidate(n=12, edges=[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 0], [11, 0]]), [])\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 9], [7, 9], [8, 9]]), [0])\n assert answers_match(candidate(n=8, edges=[[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]]), [])\n assert answers_match(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 answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 7], [7, 8], [8, 9], [9, 7]]), [0])\n assert answers_match(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])\n assert answers_match(candidate(n=25, 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], [17, 21], [18, 22], [19, 23], [20, 24]]), [0])\n assert answers_match(candidate(n=8, edges=[[0, 2], [1, 2], [2, 3], [4, 5], [6, 7]]), [0, 1, 4, 6])\n assert answers_match(candidate(n=10, edges=[[0, 2], [0, 3], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7]]), [0, 1, 8, 9])\n assert answers_match(candidate(n=9, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 5], [1, 6], [2, 7], [3, 8], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4]]), [])\n assert answers_match(candidate(n=20, edges=[[0, 1], [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]]), [0])\n assert answers_match(candidate(n=9, edges=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]]), [0])\n assert answers_match(candidate(n=12, edges=[[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11]]), [0])\n assert answers_match(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])\n assert answers_match(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]]), [0])\n assert answers_match(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])\n assert answers_match(candidate(n=12, edges=[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 11]]), [0])\n assert answers_match(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 answers_match(candidate(n=6, edges=[[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 4]]), [0, 5])\n assert answers_match(candidate(n=10, edges=[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]), [0, 2, 4, 6, 8])\n assert answers_match(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]]), [0])\n assert answers_match(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 answers_match(candidate(n=8, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 6], [6, 7]]), [0])\n assert answers_match(candidate(n=8, edges=[[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7]]), [0, 1])\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]), [])\n assert answers_match(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]]), [0])\n assert answers_match(candidate(n=10, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]), [0])\n assert answers_match(candidate(n=8, edges=[[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]]), [0])\n assert answers_match(candidate(n=16, 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]]), [0])\n assert answers_match(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]]), [])\n assert answers_match(candidate(n=20, edges=[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 4], [4, 8], [8, 12], [12, 16], [16, 0], [1, 5], [5, 9], [9, 13], [13, 17], [17, 1]]), [2, 6, 10, 14, 18])\n assert answers_match(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 answers_match(candidate(n=20, edges=[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]), [0])\n assert answers_match(candidate(n=15, 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]]), [0, 10])\n assert answers_match(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, 5], [2, 7], [4, 9]]), [0])\n assert answers_match(candidate(n=9, edges=[[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4]]), [])\n assert answers_match(candidate(n=25, edges=[[0, 1], [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]]), [0])\n assert answers_match(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], [11, 12], [12, 13], [13, 14]]), [0])\n assert answers_match(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], [8, 9]]), [0])\n assert answers_match(candidate(n=16, edges=[[0, 1], [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]]), [0])\n assert answers_match(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])\n assert answers_match(candidate(n=12, edges=[[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 11]]), [0])\n assert answers_match(candidate(n=15, edges=[[0, 5], [2, 3], [3, 4], [5, 14], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]), [0, 1, 2])\n assert answers_match(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 answers_match(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]]), [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28])\n assert answers_match(candidate(n=8, edges=[[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 7]]), [0])\n assert answers_match(candidate(n=9, edges=[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]]), [0])\n assert answers_match(candidate(n=12, edges=[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), [0])\n", "comparison": "unordered"}, "public_tests": ["6\n[[0,1],[0,2],[2,5],[3,4],[4,2]]", "5\n[[0,1],[2,1],[3,1],[1,4],[2,4]]"], "hints": ["A node that does not have any incoming edge can only be reached by itself.", "Any other node with incoming edges can be reached from some other node.", "We only have to count the number of nodes with zero incoming edges."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findSmallestSetOfVertices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:41+00:00", "tests_total": 77, "tests_dropped": 0, "flags": ["any_order", "has_images"], "topic_tags": ["graph", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def findSmallestSetOfVertices(self, n: int, edges: list[list[int]]) -> list[int]:", "container": "Solution", "callable": "findSmallestSetOfVertices", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1558, "task_id": "minimum-numbers-of-function-calls-to-make-target-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:\n\nYou want to use the modify function to convert arr to nums using the minimum number of calls.\n\nReturn the minimum number of function calls to make nums from arr.\n\nThe test cases are generated so that the answer fits in a 32-bit signed integer.\n\nExample 1:\n\nInput: nums = [1,5]\nOutput: 5\nExplanation: Increment by 1 (second element): [0, 0] to get [0, 1] (1 operation).\nDouble all the elements: [0, 1] -> [0, 2] -> [0, 4] (2 operations).\nIncrement by 1 (both elements) [0, 4] -> [1, 4] -> [1, 5] (2 operations).\nTotal of operations: 1 + 2 + 2 = 5.\n\nExample 2:\n\nInput: nums = [2,2]\nOutput: 3\nExplanation: Increment by 1 (both elements) [0, 0] -> [0, 1] -> [1, 1] (2 operations).\nDouble all the elements: [1, 1] -> [2, 2] (1 operation).\nTotal of operations: 2 + 1 = 3.\n\nExample 3:\n\nInput: nums = [4,2,5]\nOutput: 6\nExplanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums).\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 0 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 43\n assert candidate(nums = [10, 20, 30]) == 12\n assert candidate(nums = [10, 15, 20]) == 12\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [3, 3, 3, 3]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9]) == 13\n assert candidate(nums = [1, 5]) == 5\n assert candidate(nums = [1, 3, 7, 15, 31]) == 19\n assert candidate(nums = [1000000000, 1000000000]) == 55\n assert candidate(nums = [4, 2, 5]) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 68\n assert candidate(nums = [3, 6, 9, 12, 15]) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1023, 511, 255]) == 36\n assert candidate(nums = [16, 8, 4, 2, 1]) == 9\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [9, 9, 9, 9, 9]) == 13\n assert candidate(nums = [2, 2]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 84\n assert candidate(nums = [81, 27, 9, 3, 1]) == 18\n assert candidate(nums = [100, 200, 300, 400]) == 21\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 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, 1048576]) == 41\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [1000000000]) == 42\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]) == 41\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 29\n assert candidate(nums = [1, 1000000000]) == 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]) == 229\n assert candidate(nums = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570, 1048569, 1048568, 1048567, 1048566, 1048565, 1048564, 1048563, 1048562, 1048561, 1048560]) == 307\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 37\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == 29\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 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\n assert candidate(nums = [63, 127, 255, 511, 1023]) == 49\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 10\n assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15]) == 292\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688]) == 61\n assert candidate(nums = [31, 15, 7, 3, 1]) == 19\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]) == 21\n assert candidate(nums = [987654321, 123456789, 98765432, 12345678, 9876543, 1234567]) == 112\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 47\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 9876543, 8765432]) == 320\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 = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 87\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 94\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 229\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 224\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 118\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == 54\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 68\n assert candidate(nums = [16, 8, 4, 2, 1, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 159\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == 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, 1, 0]) == 16\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 29\n assert candidate(nums = [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, 0, 0, 0, 0]) == 15\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000]) == 81\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == 94\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 92\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 29\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 32\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 23\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]) == 303\n assert candidate(nums = [29, 14, 7, 3, 1]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 31\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 64\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 23\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 73\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0]) == 8\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 57\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 86\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 35\n assert candidate(nums = [1023, 512, 256, 128, 64]) == 23\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512]) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55]) == 26\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 29\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 25\n assert candidate(nums = [84, 126, 189, 252, 315, 378, 441, 504, 567, 630]) == 66\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 129\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 111222333]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 35\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 21\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 82\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 = [299999999, 299999999, 299999999, 299999999, 299999999]) == 113\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 54\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 91\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 106\n", "comparison": "exact"}, "public_tests": ["[1,5]", "[2,2]", "[4,2,5]"], "hints": ["Work backwards: try to go from nums to arr.", "You should try to divide by 2 as much as possible, but you can only divide by 2 if everything is even."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:44+00:00", "tests_total": 98, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "greedy", "bit-manipulation"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, nums: list[int]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1559, "task_id": "detect-cycles-in-2d-grid", "difficulty": "Medium", "problem_description": "Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.\n\nA cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the same value of the current cell.\n\nAlso, you cannot move to the cell that you visited in your last move. For example, the cycle (1, 1) -> (1, 2) -> (1, 1) is invalid because from (1, 2) we visited (1, 1) which was the last visited cell.\n\nReturn true if any cycle of the same value exists in grid, otherwise, return false.\n\nExample 1:\n\nInput: grid = [[\"a\",\"a\",\"a\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"a\",\"a\",\"a\"]]\nOutput: true\nExplanation: There are two valid cycles shown in different colors in the image below:\n\nExample 2:\n\nInput: grid = [[\"c\",\"c\",\"c\",\"a\"],[\"c\",\"d\",\"c\",\"c\"],[\"c\",\"c\",\"e\",\"c\"],[\"f\",\"c\",\"c\",\"c\"]]\nOutput: true\nExplanation: There is only one valid cycle highlighted in the image below:\n\nExample 3:\n\nInput: grid = [[\"a\",\"b\",\"b\"],[\"b\",\"z\",\"b\"],[\"b\",\"b\",\"a\"]]\nOutput: false\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 500\n- grid consists only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b'], ['b', 'a']]) == False\n assert candidate(grid = [['c', 'c', 'c', 'a'], ['c', 'd', 'c', 'c'], ['c', 'c', 'e', 'c'], ['f', 'c', 'c', 'c']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a'], ['a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'b'], ['b', 'z', 'b'], ['b', 'b', 'a']]) == False\n assert candidate(grid = [['a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'a'], ['a', 'a', 'b', 'b', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['a', 'a', 'a', 'a', 'a'], ['b', 'b', 'b', 'b', 'b'], ['c', 'c', 'c', 'c', 'c'], ['d', 'd', 'd', 'd', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['p', 'q', 'r'], ['q', 'r', 'p'], ['r', 'p', 'q'], ['p', 'q', 'r']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a'], ['b', 'c', 'a', 'b'], ['c', 'a', 'b', 'c'], ['a', 'b', 'c', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'a', 'e', 'd', 'c'], ['c', 'e', 'a', 'b', 'd'], ['d', 'c', 'b', 'a', 'e'], ['e', 'd', 'c', 'e', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'b', 'b'], ['a', 'a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a', 'a'], ['b', 'b', 'a', 'a', 'a'], ['b', 'a', 'a', 'a', 'b']]) == True\n assert candidate(grid = [['z', 'y', 'x', 'w', 'v', 'u', 't'], ['y', 'x', 'w', 'v', 'u', 't', 's'], ['x', 'w', 'v', 'u', 't', 's', 'r'], ['w', 'v', 'u', 't', 's', 'r', 'q'], ['v', 'u', 't', 's', 'r', 'q', 'p'], ['u', 't', 's', 'r', 'q', 'p', 'o'], ['t', 's', 'r', 'q', 'p', 'o', 'n']]) == False\n assert candidate(grid = [['c', 'c', 'c', 'c', 'c'], ['c', 'd', 'd', 'd', 'c'], ['c', 'd', 'c', 'd', 'c'], ['c', 'd', 'd', 'd', 'c'], ['c', 'c', 'c', 'c', 'c']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'a', 'b', 'c', 'd', 'e'], ['e', 'f', 'a', 'b', 'c', 'd'], ['d', 'e', 'f', 'a', 'b', 'c'], ['c', 'd', 'e', 'f', 'a', 'b'], ['b', 'c', 'd', 'e', 'f', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a', 'a'], ['a', 'b', 'b', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['b', 'c', 'd', 'e', 'f', 'a'], ['c', 'd', 'e', 'f', 'a', 'b'], ['d', 'e', 'f', 'a', 'b', 'c'], ['e', 'f', 'a', 'b', 'c', 'd'], ['f', 'a', 'b', 'c', 'd', 'e']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['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(grid = [['a', 'a', 'a'], ['a', 'b', 'a'], ['a', 'a', 'a'], ['a', 'b', 'a'], ['a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'f'], ['c', 'd', 'e', 'f', 'g'], ['d', 'e', 'f', 'g', 'h'], ['e', 'f', 'g', 'h', 'i']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == False\n assert candidate(grid = [['x', 'y', 'z', 'x'], ['y', 'z', 'x', 'y'], ['z', 'x', 'y', 'z'], ['x', 'y', 'z', 'x']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a', 'b', 'c'], ['b', 'c', 'a', 'b', 'c', 'a'], ['c', 'a', 'b', 'c', 'a', 'b'], ['a', 'b', 'c', 'a', 'b', 'c'], ['b', 'c', 'a', 'b', 'c', 'a'], ['c', 'a', 'b', 'c', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'a'], ['a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'a', 'a', 'b', 'a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', '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(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['x', 'y', 'z'], ['y', 'x', 'y'], ['z', 'y', 'x'], ['y', 'x', 'y'], ['x', 'y', 'z']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'a', 'b', 'c', 'd'], ['c', 'b', 'a', 'b', 'c'], ['d', 'c', 'b', 'a', 'b'], ['e', 'd', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['x', 'x', 'x', 'x', 'x', 'x'], ['x', 'y', 'y', 'y', 'y', 'x'], ['x', 'y', 'z', 'z', 'y', 'x'], ['x', 'y', 'z', 'z', 'y', 'x'], ['x', 'y', 'y', 'y', 'y', 'x'], ['x', 'x', 'x', 'x', 'x', 'x']]) == True\n assert candidate(grid = [['x', 'x', 'x', 'x'], ['x', 'y', 'y', 'x'], ['x', 'y', 'y', 'x'], ['x', 'x', 'x', 'x']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['a', 'a', 'a', 'a', 'a', 'a'], ['b', 'c', 'd', 'e', 'f', 'g'], ['g', 'f', 'e', 'd', 'c', 'b'], ['a', 'a', 'a', 'a', 'a', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'a', 'b'], ['c', 'b', 'a']]) == False\n assert candidate(grid = [['p', 'p', 'q', 'p', 'p'], ['p', 'q', 'q', 'q', 'p'], ['q', 'q', 'r', 'q', 'q'], ['p', 'q', 'q', 'q', 'p'], ['p', 'p', 'q', 'p', 'p']]) == True\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a'], ['b', 'b', 'b'], ['a', 'a', 'a'], ['b', 'b', 'b'], ['a', 'a', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'a'], ['c', 'd', 'e', 'a', 'b'], ['d', 'e', 'a', 'b', 'c'], ['e', 'a', 'b', 'c', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b'], ['a', 'b', 'c', 'd', 'd', 'c', 'b'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'a'], ['b', 'a', 'b', 'c', 'b'], ['c', 'b', 'a', 'b', 'c'], ['d', 'c', 'b', 'a', 'd'], ['a', 'b', 'c', 'd', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a'], ['b', 'a', 'b', 'c'], ['c', 'b', 'c', 'b'], ['a', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'a'], ['c', 'd', 'e', 'a', 'b'], ['d', 'e', 'a', 'b', 'c'], ['e', 'a', 'b', 'c', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['b', 'b', 'b', 'b'], ['c', 'c', 'c', 'c'], ['d', 'd', 'd', 'd'], ['e', 'e', 'e', 'e'], ['f', 'f', 'f', 'f']]) == False\n assert candidate(grid = [['m', 'm', 'm', 'm'], ['m', 'n', 'n', 'm'], ['m', 'n', 'o', 'm'], ['m', 'n', 'n', 'm'], ['m', 'm', 'm', 'm']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']]) == False\n assert candidate(grid = [['a', 'a', 'b', 'b'], ['a', 'c', 'c', 'a'], ['b', 'c', 'd', 'b'], ['a', 'c', 'c', 'a']]) == False\n assert candidate(grid = [['x', 'y', 'z', 'x'], ['y', 'x', 'y', 'x'], ['z', 'y', 'z', 'y'], ['x', 'z', 'x', 'z']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['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(grid = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h'], ['i', 'j', 'k', 'l'], ['m', 'n', 'o', 'p']]) == False\n assert candidate(grid = [['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', 'v', 'w'], ['x', 'y', 'z', 'v', 'w', 'x', 'y'], ['z', 'v', 'w', 'x', 'y', 'z', 'v']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'c', 'c', 'a', 'b', 'a'], ['a', 'b', 'a', 'c', 'c', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'c', 'b'], ['c', 'b', 'a'], ['b', 'c', 'b'], ['a', 'b', 'c']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'b', 'b', 'b'], ['a', 'c', 'a', 'b', 'a', 'b'], ['a', 'a', 'a', 'b', 'b', 'b']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd'], ['b', 'a', 'd', 'c'], ['c', 'd', 'a', 'b'], ['d', 'c', 'b', 'a']]) == False\n", "comparison": "exact"}, "public_tests": ["[[\"a\",\"a\",\"a\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"a\",\"a\",\"a\"]]", "[[\"c\",\"c\",\"c\",\"a\"],[\"c\",\"d\",\"c\",\"c\"],[\"c\",\"c\",\"e\",\"c\"],[\"f\",\"c\",\"c\",\"c\"]]", "[[\"a\",\"b\",\"b\"],[\"b\",\"z\",\"b\"],[\"b\",\"b\",\"a\"]]"], "hints": ["Keep track of the parent (previous position) to avoid considering an invalid path.", "Use DFS or BFS and keep track of visited cells to see if there is a cycle."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().containsCycle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:46+00:00", "tests_total": 74, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "union-find", "matrix"]}, "language": "python", "interface": {"raw_signature": "def containsCycle(self, grid: list[list[str]]) -> bool:", "container": "Solution", "callable": "containsCycle", "parameters": [{"name": "grid", "type": "list[list[str]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1560, "task_id": "most-visited-sector-in-a-circular-track", "difficulty": "Easy", "problem_description": "Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The i^th round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]\n\nReturn an array of the most visited sectors sorted in ascending order.\n\nNotice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).\n\nExample 1:\n\nInput: n = 4, rounds = [1,3,1,2]\nOutput: [1,2]\nExplanation: The marathon starts at sector 1. The order of the visited sectors is as follows:\n1 --> 2 --> 3 (end of round 1) --> 4 --> 1 (end of round 2) --> 2 (end of round 3 and the marathon)\nWe can see that both sectors 1 and 2 are visited twice and they are the most visited sectors. Sectors 3 and 4 are visited only once.\n\nExample 2:\n\nInput: n = 2, rounds = [2,1,2,1,2,1,2,1,2]\nOutput: [2]\n\nExample 3:\n\nInput: n = 7, rounds = [1,3,5,7]\nOutput: [1,2,3,4,5,6,7]\n\nConstraints:\n\n- 2 <= n <= 100\n- 1 <= m <= 100\n- rounds.length == m + 1\n- 1 <= rounds[i] <= n\n- rounds[i] != rounds[i + 1] for 0 <= i < m\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,rounds = [1, 3, 1, 2]) == [1, 2]\n assert candidate(n = 7,rounds = [1, 3, 5, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,rounds = [3, 6, 2, 4, 1]) == [1, 3, 4, 5, 6]\n assert candidate(n = 6,rounds = [3, 6, 2, 5]) == [3, 4, 5]\n assert candidate(n = 10,rounds = [3, 8, 3]) == [3]\n assert candidate(n = 2,rounds = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2]\n assert candidate(n = 5,rounds = [1, 5, 1]) == [1]\n assert candidate(n = 6,rounds = [6, 2, 6, 5]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,rounds = [3, 6, 2, 5, 1]) == [1, 3, 4, 5, 6]\n assert candidate(n = 3,rounds = [1, 2, 3, 1]) == [1]\n assert candidate(n = 8,rounds = [5, 4, 3, 2, 1, 8, 7, 6, 5]) == [5]\n assert candidate(n = 10,rounds = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 10]\n assert candidate(n = 10,rounds = [3, 8, 3, 10, 3]) == [3]\n assert candidate(n = 10,rounds = [1, 5, 9, 4, 8, 2, 6, 3, 7, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 15,rounds = [10, 1, 12, 7, 14, 2, 15, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 7,rounds = [3, 6, 2, 5, 3, 6, 2, 5, 3, 6, 2, 5]) == [3, 4, 5]\n assert candidate(n = 12,rounds = [2, 7, 1, 11, 6, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 100,rounds = [1, 50, 25, 75, 100, 50, 25, 75, 100, 1, 50, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 20,rounds = [3, 7, 12, 18, 20, 5, 10, 15, 1]) == [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 30,rounds = [15, 25, 5, 15, 25, 10, 5, 20, 10, 25, 15, 20, 5, 10, 15, 20, 25, 1, 6, 11, 16, 21, 26, 30, 4, 9, 14, 19, 24, 29]) == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(n = 25,rounds = [10, 20, 5, 15, 25, 1, 11, 16, 6, 21, 12, 22, 7, 23, 13, 24, 8, 2, 18, 9, 3, 19, 4, 24, 25, 17]) == [10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(n = 10,rounds = [1, 5, 3, 8, 10, 4]) == [1, 2, 3, 4]\n assert candidate(n = 20,rounds = [10, 15, 5, 20, 1, 6, 11, 16, 1, 11]) == [10, 11]\n assert candidate(n = 15,rounds = [15, 5, 10, 12, 3, 14, 8, 6, 1]) == [1, 15]\n assert candidate(n = 20,rounds = [10, 20, 15, 5, 1, 15, 10, 5, 20, 15, 10, 5, 1]) == [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 8,rounds = [5, 1, 4, 7, 2, 6, 3]) == [1, 2, 3, 5, 6, 7, 8]\n assert candidate(n = 100,rounds = [50, 25, 75, 100, 1, 50, 25, 75, 100, 1, 50, 25, 75, 100, 1]) == [1, 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(n = 25,rounds = [1, 13, 24, 7, 18, 12, 22, 5, 17, 11, 21, 4, 16, 10, 20, 3, 15, 9, 19, 2, 14, 8, 1, 13, 24, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 90,rounds = [1, 45, 90, 45, 1, 60, 30, 90, 60, 30, 1, 45, 60, 90, 30, 45, 1, 60, 90, 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(n = 10,rounds = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1]\n assert candidate(n = 18,rounds = [18, 10, 3, 12, 6, 15, 9, 2, 14, 7, 1, 13, 5, 16, 8, 4, 17, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18]\n assert candidate(n = 9,rounds = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 9]\n assert candidate(n = 11,rounds = [1, 3, 5, 7, 9, 11, 1, 3, 5, 7, 9, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 40,rounds = [1, 20, 40, 20, 1, 30, 20, 10, 30, 40, 10, 20, 30, 40, 1, 10, 20, 30, 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, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 11,rounds = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 25,rounds = [15, 20, 25, 5, 10, 1, 16, 21, 2, 17, 22, 3, 18, 23, 4, 19, 24, 6, 20, 25, 7, 1, 8, 16, 9, 12]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 25,rounds = [25, 15, 10, 20, 5, 2, 17, 12, 7, 22, 1, 16, 11, 6, 21, 13, 8, 3, 18, 14, 9, 23, 4, 19, 24]) == [1, 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(n = 7,rounds = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == [1, 7]\n assert candidate(n = 12,rounds = [12, 3, 6, 9, 12, 3, 6, 9, 12, 3, 6, 9, 12]) == [12]\n assert candidate(n = 9,rounds = [9, 1, 3, 5, 7, 2, 4, 6, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,rounds = [5, 10, 15, 1, 6, 11, 13, 8]) == [5, 6, 7, 8]\n assert candidate(n = 12,rounds = [1, 12, 4, 8, 11, 2, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 50,rounds = [25, 45, 5, 30, 40, 50, 10, 35, 45, 20, 40, 50, 25, 50, 15, 45, 25, 50, 35, 50, 45, 50, 10, 40, 20, 50, 30, 50, 40, 50]) == [25, 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(n = 22,rounds = [11, 22, 7, 17, 2, 12, 8, 18, 3, 13, 9, 19, 4, 14, 10, 20, 5, 15, 6, 16, 1, 21]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(n = 9,rounds = [3, 6, 9, 2, 5, 8, 1, 4, 7]) == [3, 4, 5, 6, 7]\n assert candidate(n = 12,rounds = [1, 7, 12, 4, 9, 2, 8, 5, 10, 3, 11, 6, 1]) == [1]\n assert candidate(n = 20,rounds = [10, 15, 5, 18, 12, 20, 14, 8, 17, 11, 6, 19, 13, 9, 4, 16, 10, 3, 1, 7, 2]) == [1, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 8,rounds = [7, 1, 4, 8, 2, 6, 3, 5]) == [1, 2, 3, 4, 5, 7, 8]\n assert candidate(n = 30,rounds = [30, 10, 20, 3, 13, 23, 6, 16, 26, 9, 19, 29, 12, 22, 3, 13, 23, 6, 16, 26, 9, 19, 29, 12, 22]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 30]\n assert candidate(n = 75,rounds = [1, 38, 75, 38, 1, 50, 25, 75, 50, 25, 1, 38, 50, 75, 25, 38, 1, 50, 75, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,rounds = [1, 15, 5, 10, 3, 8, 13, 2]) == [1, 2]\n assert candidate(n = 40,rounds = [20, 30, 40, 10, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40]) == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 11,rounds = [11, 4, 8, 1, 7, 10, 3, 9, 6, 2, 5, 11, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 11]\n assert candidate(n = 15,rounds = [1, 15, 5, 10, 1, 6, 11, 3, 8, 13]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(n = 8,rounds = [7, 3, 6, 2, 5, 1, 8, 4]) == [1, 2, 3, 4, 7, 8]\n assert candidate(n = 14,rounds = [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(n = 50,rounds = [1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 9,rounds = [3, 6, 2, 8, 4, 1, 9, 5, 7, 3, 6, 2, 8, 4, 1, 9, 5, 7]) == [3, 4, 5, 6, 7]\n assert candidate(n = 50,rounds = [1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,rounds = [14, 3, 12, 8, 5, 2, 15, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15]\n assert candidate(n = 8,rounds = [8, 1, 4, 7, 2, 5, 8, 3, 6]) == [1, 2, 3, 4, 5, 6, 8]\n assert candidate(n = 12,rounds = [5, 9, 1, 11, 7, 3, 12, 6, 2, 8, 4, 10]) == [5, 6, 7, 8, 9, 10]\n assert candidate(n = 8,rounds = [7, 3, 5, 2, 8, 6, 1, 4]) == [1, 2, 3, 4, 7, 8]\n assert candidate(n = 10,rounds = [1, 5, 3, 9, 2, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 18,rounds = [1, 9, 18, 7, 15, 5, 13, 3, 11, 1, 9, 18, 7, 15, 5, 13, 3, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 50,rounds = [25, 30, 15, 40, 5, 20, 35, 45, 10, 4, 34, 29]) == [25, 26, 27, 28, 29]\n assert candidate(n = 15,rounds = [3, 10, 15, 5, 12, 7, 13, 2, 9, 14, 4, 11, 6, 1, 8]) == [3, 4, 5, 6, 7, 8]\n assert candidate(n = 6,rounds = [6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 20,rounds = [1, 10, 15, 20, 1, 5, 10, 15, 20, 1, 10, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 12,rounds = [12, 6, 3, 9, 1, 7, 4, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12]\n assert candidate(n = 10,rounds = [1, 4, 7, 2, 8, 3, 9, 5, 10, 6]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 12,rounds = [4, 8, 1, 7, 11, 5, 9, 12, 6, 10, 2]) == [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 9,rounds = [9, 4, 8, 3, 7, 2, 6, 1, 5]) == [1, 2, 3, 4, 5, 9]\n assert candidate(n = 25,rounds = [12, 17, 22, 2, 7, 12, 17, 22, 2, 7, 12, 17]) == [12, 13, 14, 15, 16, 17]\n assert candidate(n = 7,rounds = [1, 4, 7, 2, 5, 3, 6, 1, 4, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 15,rounds = [1, 14, 8, 11, 5, 13, 9, 2, 7, 15, 4, 12, 6, 3, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 10,rounds = [5, 8, 3, 10, 2, 6]) == [5, 6]\n assert candidate(n = 18,rounds = [18, 13, 8, 3, 17, 12, 7, 2, 16, 11, 6, 1, 15, 10, 5, 14, 9, 4]) == [1, 2, 3, 4, 18]\n assert candidate(n = 8,rounds = [7, 1, 4, 7, 3, 6, 2, 8]) == [7, 8]\n assert candidate(n = 9,rounds = [3, 6, 9, 3, 6, 9, 3]) == [3]\n assert candidate(n = 20,rounds = [1, 15, 5, 10, 20, 12, 7, 18, 3, 16, 8, 13, 2, 19, 6, 14, 4, 17, 9, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 1, 11, 16, 6, 12, 17, 7, 13, 18, 8, 14, 19, 9, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 15,rounds = [5, 10, 15, 1, 6, 11, 2, 7, 12, 3, 8, 13, 4, 9, 14]) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 9,rounds = [3, 9, 2, 8, 1, 7, 4, 6, 5]) == [3, 4, 5]\n assert candidate(n = 12,rounds = [1, 4, 7, 10, 1, 4, 7, 10, 1]) == [1]\n assert candidate(n = 10,rounds = [10, 3, 5, 7, 9, 2]) == [1, 2, 10]\n assert candidate(n = 12,rounds = [7, 3, 9, 12, 4, 10, 5, 11, 6, 1, 8, 2]) == [1, 2, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 10, 1, 16, 6, 11, 1, 17, 7, 12, 1, 18, 8, 13, 1, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 10,rounds = [1, 5, 10, 3, 7, 1]) == [1]\n assert candidate(n = 14,rounds = [1, 7, 14, 2, 8, 13, 3, 9, 12, 4, 10, 11, 5, 6, 1]) == [1]\n assert candidate(n = 10,rounds = [5, 10, 3, 8, 1]) == [1, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 25,rounds = [5, 15, 25, 10, 20, 1, 11, 16, 6, 16, 11, 1, 20, 10, 25, 15, 5]) == [5]\n assert candidate(n = 8,rounds = [5, 8, 2, 7, 3, 6, 4, 1]) == [1, 5, 6, 7, 8]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 3, 9, 18, 7, 12, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 8,rounds = [4, 8, 1, 5, 2, 6, 3, 7]) == [4, 5, 6, 7]\n", "comparison": "exact"}, "public_tests": ["4\n[1,3,1,2]", "2\n[2,1,2,1,2,1,2,1,2]", "7\n[1,3,5,7]"], "hints": ["For each round increment the visits of the sectors visited during the marathon with 1.", "Determine the max number of visits, and return any sector visited the max number of visits."], "metadata": {"canonical_parameter_names": ["n", "rounds"], "leetcode_dataset_entry_point": "Solution().mostVisited", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:48+00:00", "tests_total": 98, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def mostVisited(self, n: int, rounds: list[int]) -> list[int]:", "container": "Solution", "callable": "mostVisited", "parameters": [{"name": "n", "type": "int"}, {"name": "rounds", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1561, "task_id": "maximum-number-of-coins-you-can-get", "difficulty": "Medium", "problem_description": "There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:\n\n- In each step, you will choose any 3 piles of coins (not necessarily consecutive).\n- Of your choice, Alice will pick the pile with the maximum number of coins.\n- You will pick the next pile with the maximum number of coins.\n- Your friend Bob will pick the last pile.\n- Repeat until there are no more piles of coins.\n\nGiven an array of integers piles where piles[i] is the number of coins in the i^th pile.\n\nReturn the maximum number of coins that you can have.\n\nExample 1:\n\nInput: piles = [2,4,1,2,7,8]\nOutput: 9\nExplanation: Choose the triplet (2, 7, 8), Alice Pick the pile with 8 coins, you the pile with 7 coins and Bob the last one.\nChoose the triplet (1, 2, 4), Alice Pick the pile with 4 coins, you the pile with 2 coins and Bob the last one.\nThe maximum number of coins which you can have are: 7 + 2 = 9.\nOn the other hand if we choose this arrangement (1, 2, 8), (2, 4, 7) you only get 2 + 4 = 6 coins which is not optimal.\n\nExample 2:\n\nInput: piles = [2,4,5]\nOutput: 4\n\nExample 3:\n\nInput: piles = [9,8,7,6,5,1,2,3,4]\nOutput: 18\n\nConstraints:\n\n- 3 <= piles.length <= 10^5\n- piles.length % 3 == 0\n- 1 <= piles[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6, 7]) == 32\n assert candidate(piles = [2, 4, 1, 2, 7, 8]) == 9\n assert candidate(piles = [9, 8, 7, 6, 5, 1, 2, 3, 4]) == 18\n assert candidate(piles = [10000, 10000, 10000, 1, 1, 1, 2, 2, 2]) == 10004\n assert candidate(piles = [1, 12, 3, 11, 5, 10, 7, 4, 8, 6, 9, 2]) == 32\n assert candidate(piles = [1, 12, 3, 10, 5, 8, 7, 4, 6, 9, 11, 2]) == 32\n assert candidate(piles = [2, 4, 5]) == 4\n assert candidate(piles = [10000, 1, 10000, 1, 10000, 1]) == 10001\n assert candidate(piles = [3000, 1000, 2000, 4000, 5000, 6000]) == 8000\n assert candidate(piles = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 32\n assert candidate(piles = [10000, 1, 10000, 2, 10000, 3]) == 10003\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(piles = [1, 12, 3, 11, 5, 6, 7, 9, 8]) == 25\n assert candidate(piles = [3, 3, 3, 3, 3, 3]) == 6\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(piles = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987, 15, 986]) == 6990\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 50\n assert candidate(piles = [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]) == 242\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(piles = [33, 29, 45, 17, 67, 78, 54, 90, 12, 34, 56, 78, 89, 90, 100, 200, 300, 400]) == 689\n assert candidate(piles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 50\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 320\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 69951\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]) == 162\n assert candidate(piles = [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]) == 20000\n assert candidate(piles = [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]) == 99900\n assert candidate(piles = [9, 7, 5, 3, 1, 8, 6, 4, 2]) == 18\n assert candidate(piles = [50, 25, 75, 100, 200, 150, 175, 300, 225, 400, 125, 350, 500, 600, 800, 700, 900, 1000, 2000, 1500, 1100, 1300, 1600, 1400]) == 6775\n assert candidate(piles = [3, 1, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28]) == 200\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 180\n assert candidate(piles = [10, 12, 34, 33, 5, 7, 6, 11, 13, 15, 17, 19]) == 74\n assert candidate(piles = [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]) == 890\n assert candidate(piles = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2569\n assert candidate(piles = [3, 1, 2, 5, 7, 8, 9, 4, 6]) == 18\n assert candidate(piles = [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]) == 392\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n assert candidate(piles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 105\n assert candidate(piles = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971]) == 49900\n assert candidate(piles = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66]) == 357\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992]) == 29991\n assert candidate(piles = [3, 1, 2, 5, 4, 6, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20, 24, 22, 23, 27, 25, 26, 30, 28, 29]) == 200\n assert candidate(piles = [300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1000, 950, 900]) == 1490\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]) == 200\n assert candidate(piles = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14]) == 33\n assert candidate(piles = [10, 11, 12, 13, 14, 15, 16, 17, 18]) == 45\n assert candidate(piles = [8, 5, 2, 12, 3, 7, 11, 6, 10, 4, 9, 1, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28]) == 200\n assert candidate(piles = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9]) == 2016\n assert candidate(piles = [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]) == 20000\n assert candidate(piles = [3, 1, 2, 6, 4, 5, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20, 24, 22, 23, 27, 25, 26, 30, 28, 29, 33, 31, 32, 36, 34, 35, 39, 37, 38, 42, 40, 41, 45, 43, 44, 48, 46, 47, 51, 49, 50, 54, 52, 53, 57, 55, 56, 60, 58, 59, 63, 61, 62, 66, 64, 65]) == 968\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]) == 10\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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) == 450\n assert candidate(piles = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991, 11, 9990, 12, 9989, 13, 9988, 14, 9987, 15, 9986]) == 69990\n assert candidate(piles = [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\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3200\n assert candidate(piles = [1, 3, 2, 4, 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]) == 200\n assert candidate(piles = [50, 25, 75, 100, 200, 150, 300, 400, 350, 275, 175, 225]) == 975\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]) == 200\n assert candidate(piles = [5, 3, 8, 1, 9, 4, 2, 7, 6, 15, 10, 11, 14, 12, 13, 20, 16, 17, 19, 18, 25, 21, 22, 24, 23, 30, 26, 27, 29, 28]) == 200\n assert candidate(piles = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 180\n assert candidate(piles = [30, 20, 10, 50, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 500\n assert candidate(piles = [10000, 10000, 10000, 9999, 9999, 9999, 9998, 9998, 9998, 9997, 9997, 9997, 9996, 9996, 9996, 9995, 9995, 9995, 9994, 9994, 9994, 9993, 9993, 9993, 9992, 9992, 9992, 9991, 9991, 9991, 9990, 9990, 9990, 9989, 9989, 9989, 9988, 9988, 9988, 9987, 9987, 9987, 9986, 9986, 9986, 9985, 9985, 9985, 9984, 9984, 9984, 9983, 9983, 9983, 9982, 9982, 9982, 9981, 9981, 9981, 9980, 9980, 9980, 9979, 9979, 9979, 9978, 9978, 9978]) == 229831\n", "comparison": "exact"}, "public_tests": ["[2,4,1,2,7,8]", "[2,4,5]", "[9,8,7,6,5,1,2,3,4]"], "hints": ["Which pile of coins will you never be able to pick up?", "Bob is forced to take the last pile of coins, no matter what it is. Which pile should you give to him?"], "metadata": {"canonical_parameter_names": ["piles"], "leetcode_dataset_entry_point": "Solution().maxCoins", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:50+00:00", "tests_total": 99, "tests_dropped": 37, "flags": [], "topic_tags": ["array", "math", "greedy", "sorting", "game-theory"]}, "language": "python", "interface": {"raw_signature": "def maxCoins(self, piles: list[int]) -> int:", "container": "Solution", "callable": "maxCoins", "parameters": [{"name": "piles", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1562, "task_id": "find-latest-group-of-size-m", "difficulty": "Medium", "problem_description": "Given an array arr that represents a permutation of numbers from 1 to n.\n\nYou have a binary string of size n that initially has all its bits set to zero. At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1.\n\nYou are also given an integer m. Find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1's such that it cannot be extended in either direction.\n\nReturn the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.\n\nExample 1:\n\nInput: arr = [3,5,1,2,4], m = 1\nOutput: 4\nExplanation:\nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"00101\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"11101\", groups: [\"111\", \"1\"]\nStep 5: \"11111\", groups: [\"11111\"]\nThe latest step at which there exists a group of size 1 is step 4.\n\nExample 2:\n\nInput: arr = [3,1,5,4,2], m = 2\nOutput: -1\nExplanation:\nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"10100\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"10111\", groups: [\"1\", \"111\"]\nStep 5: \"11111\", groups: [\"11111\"]\nNo group of size 2 exists during any step.\n\nConstraints:\n\n- n == arr.length\n- 1 <= m <= n <= 10^5\n- 1 <= arr[i] <= n\n- All integers in arr are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],m = 3) == 3\n assert candidate(arr = [1, 3, 5, 2, 4],m = 1) == 4\n assert candidate(arr = [2, 1, 3, 5, 4],m = 1) == 4\n assert candidate(arr = [3, 5, 1, 2, 4],m = 1) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],m = 2) == 2\n assert candidate(arr = [3, 1, 5, 4, 2],m = 2) == -1\n assert candidate(arr = [1, 3, 2, 5, 4],m = 1) == 4\n assert candidate(arr = [1, 3, 5, 2, 4],m = 2) == -1\n assert candidate(arr = [2, 5, 8, 1, 4, 7, 10, 3, 6, 9],m = 3) == -1\n assert candidate(arr = [15, 1, 13, 2, 14, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8],m = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6],m = 3) == 3\n assert candidate(arr = [8, 5, 10, 1, 9, 3, 6, 7, 4, 2],m = 2) == 7\n assert candidate(arr = [3, 2, 5, 1, 4, 6, 7, 8],m = 3) == 4\n assert candidate(arr = [3, 6, 2, 8, 1, 9, 4, 7, 5, 10],m = 3) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 6) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3) == 3\n assert candidate(arr = [5, 10, 1, 2, 6, 8, 4, 7, 9, 3],m = 5) == 8\n assert candidate(arr = [1, 2, 4, 3, 6, 5, 8, 7, 10, 9],m = 3) == -1\n assert candidate(arr = [1, 10, 5, 6, 7, 8, 9, 2, 3, 4],m = 3) == 9\n assert candidate(arr = [5, 3, 1, 2, 4, 9, 7, 6, 8, 10],m = 1) == 8\n assert candidate(arr = [1, 2, 5, 6, 3, 4, 7, 8, 10, 9],m = 3) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],m = 2) == -1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5) == 5\n assert candidate(arr = [1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12],m = 2) == 10\n assert candidate(arr = [5, 1, 9, 2, 6, 3, 7, 4, 8, 10],m = 3) == 7\n assert candidate(arr = [10, 1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 11],m = 7) == 16\n assert candidate(arr = [1, 5, 9, 2, 6, 3, 7, 4, 8, 10],m = 2) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1) == 1\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 6) == 6\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],m = 2) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [2, 4, 1, 6, 5, 3],m = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4) == 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],m = 10) == 10\n assert candidate(arr = [6, 2, 5, 9, 7, 8, 3, 1, 10, 4],m = 5) == 8\n assert candidate(arr = [1, 6, 4, 3, 2, 5],m = 1) == 5\n assert candidate(arr = [5, 1, 6, 3, 8, 2, 7, 10, 4, 9],m = 3) == 8\n assert candidate(arr = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8],m = 7) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 2) == 2\n assert candidate(arr = [10, 5, 2, 7, 1, 8, 3, 6, 9, 4],m = 3) == 9\n assert candidate(arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9],m = 1) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 5\n assert candidate(arr = [6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [7, 3, 10, 8, 6, 9, 1, 5, 4, 2],m = 4) == -1\n assert candidate(arr = [1, 2, 5, 4, 3, 6, 7, 8, 9, 10],m = 2) == 4\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9) == -1\n assert candidate(arr = [3, 6, 1, 9, 7, 8, 2, 5, 10, 4],m = 3) == 9\n assert candidate(arr = [3, 1, 7, 5, 9, 2, 8, 6, 10, 4],m = 4) == -1\n assert candidate(arr = [6, 7, 8, 1, 2, 3, 4, 5, 12, 11, 9, 10],m = 6) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1) == 1\n assert candidate(arr = [10, 5, 1, 6, 3, 8, 9, 2, 7, 4],m = 2) == 8\n assert candidate(arr = [3, 5, 2, 1, 4, 6, 8, 7, 10, 9],m = 1) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],m = 4) == 9\n assert candidate(arr = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20],m = 10) == -1\n assert candidate(arr = [3, 1, 5, 7, 6, 2, 8, 4, 9, 10],m = 2) == -1\n assert candidate(arr = [1, 2, 5, 6, 3, 4, 9, 10, 7, 8],m = 2) == 9\n assert candidate(arr = [1, 10, 3, 8, 5, 12, 7, 2, 9, 4, 6, 11],m = 4) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5) == 5\n assert candidate(arr = [6, 5, 8, 4, 7, 10, 9, 1, 2, 3],m = 3) == 4\n assert candidate(arr = [9, 5, 10, 1, 2, 3, 4, 6, 7, 8],m = 4) == -1\n assert candidate(arr = [3, 1, 4, 2, 5, 6, 7, 8, 9, 10],m = 3) == -1\n assert candidate(arr = [6, 2, 3, 1, 5, 4],m = 2) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],m = 1) == 8\n assert candidate(arr = [6, 3, 1, 5, 4, 2],m = 1) == 5\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10],m = 2) == -1\n assert candidate(arr = [5, 2, 1, 8, 3, 4, 7, 6, 10, 9],m = 2) == 7\n assert candidate(arr = [10, 2, 8, 4, 6, 3, 9, 5, 7, 1],m = 3) == 8\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 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],m = 5) == 5\n assert candidate(arr = [5, 1, 6, 3, 4, 2],m = 1) == 5\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 4) == 5\n assert candidate(arr = [5, 1, 9, 10, 3, 7, 4, 6, 8, 2],m = 3) == 7\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [6, 4, 2, 8, 10, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [3, 1, 4, 2, 6, 5, 7, 10, 9, 8],m = 4) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [5, 1, 7, 10, 3, 8, 4, 6, 9, 2],m = 4) == -1\n assert candidate(arr = [3, 6, 1, 8, 2, 7, 4, 9, 5, 10],m = 1) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16],m = 8) == -1\n assert candidate(arr = [1, 2, 4, 5, 3, 7, 6, 8, 10, 9],m = 2) == 4\n assert candidate(arr = [6, 3, 5, 1, 2, 4, 9, 7, 8, 10],m = 4) == -1\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 5) == -1\n assert candidate(arr = [1, 5, 3, 9, 7, 2, 6, 10, 4, 8],m = 1) == 7\n assert candidate(arr = [7, 5, 3, 1, 9, 10, 8, 6, 4, 2],m = 5) == -1\n assert candidate(arr = [5, 3, 8, 6, 2, 4, 1, 7, 9, 10],m = 3) == -1\n assert candidate(arr = [3, 2, 5, 4, 8, 7, 10, 9, 6, 1],m = 4) == 8\n assert candidate(arr = [1, 6, 10, 3, 5, 9, 2, 4, 8, 7],m = 4) == -1\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],m = 4) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4) == 4\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10],m = 3) == 4\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 10, 4, 6],m = 5) == 9\n assert candidate(arr = [3, 6, 9, 2, 5, 8, 1, 4, 7, 10],m = 2) == 8\n assert candidate(arr = [10, 2, 6, 4, 7, 9, 1, 8, 5, 3],m = 5) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],m = 3) == 9\n assert candidate(arr = [5, 2, 8, 10, 3, 7, 4, 6, 9, 1],m = 2) == 7\n assert candidate(arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4) == 4\n assert candidate(arr = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5],m = 4) == 9\n assert candidate(arr = [1, 2, 5, 4, 7, 3, 8, 6, 9, 10],m = 2) == 7\n assert candidate(arr = [5, 3, 1, 7, 9, 10, 8, 6, 4, 2],m = 3) == -1\n assert candidate(arr = [6, 1, 4, 5, 3, 7, 9, 8, 10, 2],m = 2) == -1\n", "comparison": "exact"}, "public_tests": ["[3,5,1,2,4]\n1", "[3,1,5,4,2]\n2"], "hints": ["Since the problem asks for the latest step, can you start the searching from the end of arr?", "Use a map to store the current “1” groups.", "At each step (going backwards) you need to split one group and update the map."], "metadata": {"canonical_parameter_names": ["arr", "m"], "leetcode_dataset_entry_point": "Solution().findLatestStep", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:53+00:00", "tests_total": 106, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "simulation"]}, "language": "python", "interface": {"raw_signature": "def findLatestStep(self, arr: list[int], m: int) -> int:", "container": "Solution", "callable": "findLatestStep", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1563, "task_id": "stone-game-v", "difficulty": "Hard", "problem_description": "There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\n\nIn each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.\n\nThe game ends when there is only one stone remaining. Alice's score is initially zero.\n\nReturn the maximum score that Alice can obtain.\n\nExample 1:\n\nInput: stoneValue = [6,2,3,4,5,5]\nOutput: 18\nExplanation: In the first round, Alice divides the row to [6,2,3], [4,5,5]. The left row has the value 11 and the right row has value 14. Bob throws away the right row and Alice's score is now 11.\nIn the second round Alice divides the row to [6], [2,3]. This time Bob throws away the left row and Alice's score becomes 16 (11 + 5).\nThe last round Alice has only one choice to divide the row which is [2], [3]. Bob throws away the right row and Alice's score is now 18 (16 + 2). The game ends because only one stone is remaining in the row.\n\nExample 2:\n\nInput: stoneValue = [7,7,7,7,7,7,7]\nOutput: 28\n\nExample 3:\n\nInput: stoneValue = [4]\nOutput: 0\n\nConstraints:\n\n- 1 <= stoneValue.length <= 500\n- 1 <= stoneValue[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stoneValue = [1, 2, 3, 4, 5]) == 10\n assert candidate(stoneValue = [5, 3, 1, 4, 2]) == 9\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(stoneValue = [3, 6, 2, 8, 7, 4, 5]) == 23\n assert candidate(stoneValue = [3, 2, 4, 1, 4, 1, 3, 2]) == 17\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 40\n assert candidate(stoneValue = [3, 1, 5, 4, 2]) == 8\n assert candidate(stoneValue = [4]) == 0\n assert candidate(stoneValue = [1, 100, 1]) == 1\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(stoneValue = [6, 2, 3, 4, 5, 5]) == 18\n assert candidate(stoneValue = [7, 7, 7, 7, 7, 7, 7]) == 28\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(stoneValue = [10, 10, 10, 10, 10, 10]) == 40\n assert candidate(stoneValue = [3, 6, 1, 2, 5, 4]) == 13\n assert candidate(stoneValue = [1000000, 1000000]) == 1000000\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 84\n assert candidate(stoneValue = [1000000, 1000000]) == 1000000\n assert candidate(stoneValue = [10, 10, 10, 10, 10]) == 30\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 277\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == 1400\n assert candidate(stoneValue = [8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 366\n assert candidate(stoneValue = [15, 20, 5, 10, 25, 30, 5]) == 70\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 92\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 125\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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]) == 1179\n assert candidate(stoneValue = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 3700000\n assert candidate(stoneValue = [1000000, 1, 1000000, 1, 1000000]) == 1000002\n assert candidate(stoneValue = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 194\n assert candidate(stoneValue = [1000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(stoneValue = [5, 1, 4, 9, 7, 2, 8, 6, 3]) == 31\n assert candidate(stoneValue = [5, 3, 8, 2, 7, 9, 1, 4, 6, 10]) == 36\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 184\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(stoneValue = [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]) == 137\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(stoneValue = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 26\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 92\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 920\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 79\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 80\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550]) == 2500\n assert candidate(stoneValue = [1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 184\n assert candidate(stoneValue = [1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000]) == 7000004\n assert candidate(stoneValue = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 55\n assert candidate(stoneValue = [1000000, 500000, 750000, 250000, 600000, 400000]) == 2000000\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 74\n assert candidate(stoneValue = [1000000, 999999, 999998, 999997, 999996, 999995]) == 3999985\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 357\n assert candidate(stoneValue = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 460\n assert candidate(stoneValue = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 35\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(stoneValue = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 945\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 189\n assert candidate(stoneValue = [100, 50, 30, 20, 10, 5, 1]) == 100\n assert candidate(stoneValue = [8, 6, 4, 2, 1, 3, 5, 7, 9]) == 32\n assert candidate(stoneValue = [23, 45, 12, 67, 89, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 606\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 90\n assert candidate(stoneValue = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 3700000\n assert candidate(stoneValue = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 1780\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 25\n assert candidate(stoneValue = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 3700\n assert candidate(stoneValue = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 555\n assert candidate(stoneValue = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == 165\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1890\n assert candidate(stoneValue = [20, 30, 10, 40, 50, 15, 25, 35]) == 170\n assert candidate(stoneValue = [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, 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, 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]) == 278\n assert candidate(stoneValue = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 35\n assert candidate(stoneValue = [50, 25, 75, 100, 200, 150, 300, 50, 25, 75, 100, 200, 150, 300, 50]) == 1625\n assert candidate(stoneValue = [42, 33, 24, 15, 6, 3, 12, 21, 30, 39, 48, 57, 66]) == 327\n assert candidate(stoneValue = [1, 3, 2, 4, 7, 6, 5, 8, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 189\n assert candidate(stoneValue = [500000, 400000, 300000, 200000, 100000, 50000, 40000, 30000, 20000, 10000]) == 1140000\n assert candidate(stoneValue = [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]) == 59\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 3700\n assert candidate(stoneValue = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 92000\n assert candidate(stoneValue = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 89\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(stoneValue = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1980\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55]) == 355\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 18900\n assert candidate(stoneValue = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 32\n assert candidate(stoneValue = [5, 12, 8, 4, 9, 2, 7]) == 33\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == 140\n assert candidate(stoneValue = [5, 3, 8, 7, 1, 9, 4, 6, 2, 10]) == 36\n assert candidate(stoneValue = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 11000000\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 37\n assert candidate(stoneValue = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2]) == 76\n", "comparison": "exact"}, "public_tests": ["[6,2,3,4,5,5]", "[7,7,7,7,7,7,7]", "[4]"], "hints": ["We need to try all possible divisions for the current row to get the max score.", "As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming."], "metadata": {"canonical_parameter_names": ["stoneValue"], "leetcode_dataset_entry_point": "Solution().stoneGameV", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:23:55+00:00", "tests_total": 93, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "math", "dynamic-programming", "game-theory"]}, "language": "python", "interface": {"raw_signature": "def stoneGameV(self, stoneValue: list[int]) -> int:", "container": "Solution", "callable": "stoneGameV", "parameters": [{"name": "stoneValue", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1566, "task_id": "detect-pattern-of-length-m-repeated-k-or-more-times", "difficulty": "Easy", "problem_description": "Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.\n\nA pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.\n\nReturn true if there exists a pattern of length m that is repeated k or more times, otherwise return false.\n\nExample 1:\n\nInput: arr = [1,2,4,4,4,4], m = 1, k = 3\nOutput: true\nExplanation: The pattern (4) of length 1 is repeated 4 consecutive times. Notice that pattern can be repeated k or more times but not less.\n\nExample 2:\n\nInput: arr = [1,2,1,2,1,1,1,3], m = 2, k = 2\nOutput: true\nExplanation: The pattern (1,2) of length 2 is repeated 2 consecutive times. Another valid pattern (2,1) is also repeated 2 times.\n\nExample 3:\n\nInput: arr = [1,2,1,2,1,3], m = 2, k = 3\nOutput: false\nExplanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times.\n\nConstraints:\n\n- 2 <= arr.length <= 100\n- 1 <= arr[i] <= 100\n- 1 <= m <= 100\n- 2 <= k <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 4, 4, 4, 4],m = 1,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2],m = 2,k = 2) == True\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],m = 2,k = 5) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 1,k = 10) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1],m = 1,k = 6) == True\n assert candidate(arr = [1, 1, 1, 1],m = 1,k = 4) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 2,k = 5) == True\n assert candidate(arr = [5, 5, 5, 1, 5, 5, 5, 5],m = 3,k = 2) == False\n assert candidate(arr = [1, 2, 2, 1, 2, 2, 1, 2, 2],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 3],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3],m = 5,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 1,k = 10) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2],m = 2,k = 3) == True\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2],m = 2,k = 2) == False\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],m = 3,k = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],m = 3,k = 2) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 1, 1, 3],m = 2,k = 2) == True\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 1,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9,k = 2) == True\n assert candidate(arr = [1, 1, 1, 1, 1],m = 1,k = 5) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],m = 4,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],m = 4,k = 2) == False\n assert candidate(arr = [3, 1, 3, 1, 3, 1, 3, 1],m = 2,k = 4) == True\n assert candidate(arr = [6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9],m = 4,k = 6) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],m = 3,k = 3) == True\n assert candidate(arr = [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],m = 6,k = 2) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 5) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 4) == True\n assert candidate(arr = [1, 2, 1, 2, 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 = 2,k = 12) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5],m = 3,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 4,k = 4) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 4) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 4) == True\n assert candidate(arr = [100, 100, 99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91],m = 2,k = 5) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6],m = 5,k = 2) == True\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],m = 7,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,k = 2) == True\n assert candidate(arr = [5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7],m = 3,k = 10) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 6) == True\n assert candidate(arr = [4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5],m = 2,k = 6) == False\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],m = 3,k = 4) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],m = 4,k = 2) == False\n assert candidate(arr = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],m = 2,k = 5) == False\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 2,k = 10) == True\n assert candidate(arr = [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],m = 3,k = 7) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4],m = 3,k = 3) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3],m = 3,k = 2) == False\n assert candidate(arr = [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3],m = 5,k = 2) == False\n assert candidate(arr = [1, 2, 1, 2, 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 = 2,k = 13) == True\n assert candidate(arr = [2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1],m = 4,k = 2) == False\n assert candidate(arr = [4, 4, 5, 5, 5, 5, 5, 4, 4, 5, 5, 5, 5, 5],m = 5,k = 2) == False\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],m = 5,k = 5) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 5,k = 3) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 1,k = 18) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 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 = 5,k = 5) == True\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],m = 5,k = 6) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 5,k = 5) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 10) == True\n assert candidate(arr = [4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],m = 2,k = 5) == True\n assert candidate(arr = [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],m = 6,k = 3) == True\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],m = 2,k = 10) == True\n assert candidate(arr = [10, 10, 20, 20, 10, 10, 20, 20, 10, 10],m = 2,k = 3) == False\n assert candidate(arr = [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 = 9,k = 4) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 5) == True\n assert candidate(arr = [9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6],m = 5,k = 2) == False\n assert candidate(arr = [9, 8, 7, 6, 9, 8, 7, 6, 9, 8, 7, 6, 9, 8, 7, 6],m = 4,k = 3) == True\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, 1, 2, 3, 4, 5],m = 5,k = 5) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1],m = 3,k = 2) == False\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 7) == True\n assert candidate(arr = [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],m = 3,k = 12) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8],m = 4,k = 3) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6],m = 3,k = 2) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\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],m = 3,k = 2) == False\n assert candidate(arr = [5, 6, 7, 5, 6, 7, 5, 6, 8, 5, 6, 7, 5, 6, 7, 5, 6, 7],m = 3,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 1, 3, 3, 3, 3],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4],m = 2,k = 3) == False\n assert candidate(arr = [5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10, 9, 10],m = 2,k = 2) == True\n assert candidate(arr = [3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4],m = 3,k = 2) == False\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],m = 5,k = 2) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 1,k = 8) == True\n assert candidate(arr = [10, 10, 10, 20, 20, 20, 30, 30, 30, 10, 10, 10, 20, 20, 20, 30, 30, 30],m = 3,k = 2) == False\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],m = 10,k = 3) == True\n assert candidate(arr = [6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9],m = 4,k = 4) == True\n assert candidate(arr = [4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7],m = 4,k = 5) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],m = 3,k = 4) == True\n assert candidate(arr = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],m = 3,k = 4) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 3,k = 4) == False\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],m = 5,k = 3) == True\n assert candidate(arr = [9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 11],m = 3,k = 5) == True\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],m = 2,k = 5) == True\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [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],m = 10,k = 3) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20],m = 3,k = 3) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 2) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],m = 2,k = 5) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 3) == False\n assert candidate(arr = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],m = 2,k = 10) == True\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2],m = 6,k = 2) == True\n assert candidate(arr = [9, 9, 9, 9, 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 = 5,k = 4) == True\n assert candidate(arr = [5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5],m = 2,k = 4) == False\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 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 = 10,k = 3) == True\n assert candidate(arr = [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],m = 10,k = 3) == True\n assert candidate(arr = [8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 8, 8, 9, 9, 10, 10, 11, 11],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2],m = 6,k = 2) == False\n", "comparison": "exact"}, "public_tests": ["[1,2,4,4,4,4]\n1\n3", "[1,2,1,2,1,1,1,3]\n2\n2", "[1,2,1,2,1,3]\n2\n3"], "hints": ["Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times."], "metadata": {"canonical_parameter_names": ["arr", "m", "k"], "leetcode_dataset_entry_point": "Solution().containsPattern", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:00+00:00", "tests_total": 128, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def containsPattern(self, arr: list[int], m: int, k: int) -> bool:", "container": "Solution", "callable": "containsPattern", "parameters": [{"name": "arr", "type": "list[int]"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1567, "task_id": "maximum-length-of-subarray-with-positive-product", "difficulty": "Medium", "problem_description": "Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.\n\nA subarray of an array is a consecutive sequence of zero or more values taken out of that array.\n\nReturn the maximum length of a subarray with positive product.\n\nExample 1:\n\nInput: nums = [1,-2,-3,4]\nOutput: 4\nExplanation: The array nums already has a positive product of 24.\n\nExample 2:\n\nInput: nums = [0,1,-2,-3,-4]\nOutput: 3\nExplanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.\nNotice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.\n\nExample 3:\n\nInput: nums = [-1,-2,-3,0,1]\nOutput: 2\nExplanation: The longest subarray with positive product is [-1,-2] or [-2,-3].\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^9 <= nums[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 4\n assert candidate(nums = [-1, -2, -3, 0, 1]) == 2\n assert candidate(nums = [-1]) == 0\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3]) == 3\n assert candidate(nums = [1, 0, -2, 3, -4, 0, 5, 6]) == 3\n assert candidate(nums = [-1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3, 4, 5, 0, 6, 7, 8]) == 4\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [-1, -1, -1, -1]) == 4\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, -4, 5, 0, -6, 7, 8, 9]) == 3\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 4\n assert candidate(nums = [1, 0, -2, 3, 4, -5, 0, 6, 7, 8, 9, 0, -1]) == 4\n assert candidate(nums = [0, 1, -2, -3, -4]) == 3\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 4\n assert candidate(nums = [1, 2, 0, 3, 4, -5, 6, 0, 7, 8]) == 2\n assert candidate(nums = [1, -2, -3, 4]) == 4\n assert candidate(nums = [1, 0, -2, 0, 3, 0, -4]) == 1\n assert candidate(nums = [1, 2, -1, -2, -1, 1, 2, -1, -2, -1]) == 10\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3, 0, 4, 5, 6, 0, -7, -8, -9, 0, 10, 11, 12]) == 3\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == 1\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, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 2, -3, 4, 5, 0, 0, -1, -2, -3, 0, 4, 5, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5\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, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30, 0]) == 20\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 0]) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 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, 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, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 20\n assert candidate(nums = [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1]) == 12\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 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 = [1, -1, 2, -2, 3, -3, 4, -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]) == 30\n assert candidate(nums = [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, 0, -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, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5]) == 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, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -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]) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60]) == 12\n assert candidate(nums = [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]) == 14\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [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]) == 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, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == 20\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5\n assert candidate(nums = [1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 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]) == 20\n assert candidate(nums = [1, -1, -1, 1, -1, -1, 1, -1, -1, 1]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 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, 1, -1, 1, -1, 1, -1, 1, -1]) == 28\n assert candidate(nums = [0, 1, 2, 3, 0, -1, -2, -3, 0, 1, 2, 3]) == 3\n assert candidate(nums = [1, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12]) == 3\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [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, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 13\n assert candidate(nums = [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]) == 9\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30]) == 30\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]) == 9\n assert candidate(nums = [0, 0, 0, 1, 2, 3, 0, -1, -2, -3, 0]) == 3\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 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]) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [0, 0, 0, 0, 1, -1, 1, -1, 0, 0, 0, 1, 1, 1, -1, -1, -1, 0, 0, 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, 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, -16, -17, -18, -19, -20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5]) == 5\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 1\n assert candidate(nums = [1, 2, 3, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 11, 12, 13, 14, 15]) == 18\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [1, -2, 0, 3, -4, 0, 5, -6, 0, 7, -8, 0, 9, -10, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, -2, 3, -4, 5]) == 5\n assert candidate(nums = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 9]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15, 0]) == 5\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0]) == 1\n assert candidate(nums = [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]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 9\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 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, -16, -17, -18, -19, -20]) == 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, 26, -27, 28, -29, 30]) == 29\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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -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\n assert candidate(nums = [-2, -3, -5, 0, 5, 7, -2, -3, 1, 0, 12, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 12\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 9\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 9\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, 0, -9, 10, -11]) == 8\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]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10, -11, -12]) == 11\n assert candidate(nums = [5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 10\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 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, 0]) == 20\n assert candidate(nums = [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]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 16\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9]) == 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]) == 40\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 0, 100, -200, 300]) == 9\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]) == 20\n", "comparison": "exact"}, "public_tests": ["[1,-2,-3,4]", "[0,1,-2,-3,-4]", "[-1,-2,-3,0,1]"], "hints": ["Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero.", "If the subarray has even number of negative numbers, the whole subarray has positive product.", "Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or remove the suffix starting from the last negative element in this subarray."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getMaxLen", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:02+00:00", "tests_total": 122, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def getMaxLen(self, nums: list[int]) -> int:", "container": "Solution", "callable": "getMaxLen", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1568, "task_id": "minimum-number-of-days-to-disconnect-island", "difficulty": "Hard", "problem_description": "You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.\n\nThe grid is said to be connected if we have exactly one island, otherwise is said disconnected.\n\nIn one day, we are allowed to change any single land cell (1) into a water cell (0).\n\nReturn the minimum number of days to disconnect the grid.\n\nExample 1:\n\nInput: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]\n\nOutput: 2\nExplanation: We need at least 2 days to get a disconnected grid.\nChange land grid[1][1] and grid[0][2] to water and get 2 disconnected island.\n\nExample 2:\n\nInput: grid = [[1,1]]\nOutput: 2\nExplanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 30\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0], [0, 0, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 1, 0], [1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 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]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\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, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 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, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 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, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 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, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 1\n assert candidate(grid = [[1, 1, 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\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 1, 1, 1, 0], [0, 0, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0]]) == 0\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, 1, 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]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [1, 1, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 1], [0, 0, 0, 1, 1], [0, 1, 0, 0, 0], [0, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == 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, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 0, 1, 1], [0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 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, 1, 0, 1, 1, 1]]) == 2\n assert candidate(grid = [[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, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 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]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\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, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 1], [1, 1, 0, 0, 1], [0, 1, 1, 0, 0], [0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1, 0], [1, 0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[0,1,1,0],[0,1,1,0],[0,0,0,0]]", "[[1,1]]"], "hints": ["Return 0 if the grid is already disconnected.", "Return 1 if changing a single land to water disconnect the island.", "Otherwise return 2.", "We can disconnect the grid within at most 2 days."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:04+00:00", "tests_total": 73, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "depth-first-search", "breadth-first-search", "matrix", "strongly-connected-component", "articulation-point"]}, "language": "python", "interface": {"raw_signature": "def minDays(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "minDays", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1569, "task_id": "number-of-ways-to-reorder-array-to-get-same-bst", "difficulty": "Hard", "problem_description": "Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.\n\n- For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.\n\nReturn the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.\n\nSince the answer may be very large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nums = [2,1,3]\nOutput: 1\nExplanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.\n\nExample 2:\n\nInput: nums = [3,4,5,1,2]\nOutput: 5\nExplanation: The following 5 arrays will yield the same BST:\n[3,1,2,4,5]\n[3,1,4,2,5]\n[3,1,4,5,2]\n[3,4,1,2,5]\n[3,4,1,5,2]\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: There are no other orderings of nums that will yield the same BST.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 1 <= nums[i] <= nums.length\n- All integers in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2]) == 0\n assert candidate(nums = [9, 4, 10, 2, 5, 8, 11, 1, 3, 6, 7]) == 3149\n assert candidate(nums = [6, 2, 9, 1, 3, 8, 10, 4, 5, 7]) == 1511\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [2, 1, 3]) == 1\n assert candidate(nums = [8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15, 16]) == 108107999\n assert candidate(nums = [5, 3, 6, 2, 4, 1]) == 14\n assert candidate(nums = [3, 4, 5, 1, 2]) == 5\n assert candidate(nums = [4, 2, 5, 1, 3]) == 7\n assert candidate(nums = [5, 2, 6, 1, 3, 4]) == 14\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 2, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38, 1, 9, 14, 19, 24, 29, 34, 39]) == 447293125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 3, 8, 1, 4, 7, 9, 2, 6, 10, 11, 12, 13, 14, 15]) == 108107\n assert candidate(nums = [6, 4, 8, 2, 5, 7, 9, 1, 3, 10, 11]) == 8063\n assert candidate(nums = [6, 3, 9, 1, 4, 7, 10, 2, 5, 8]) == 2267\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, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 2, 7, 1, 3, 6, 8, 4]) == 209\n assert candidate(nums = [7, 2, 11, 1, 4, 8, 12, 3, 5, 6, 9, 10]) == 27719\n assert candidate(nums = [15, 7, 20, 3, 11, 17, 25, 1, 5, 9, 13, 16, 19, 23, 27, 2, 4, 6, 8, 10, 12, 14, 18, 21, 22, 24, 26, 28, 29]) == 993050933\n assert candidate(nums = [7, 3, 11, 1, 5, 9, 13, 2, 4, 6, 8, 10, 12, 14, 15]) == 12612599\n assert candidate(nums = [15, 7, 24, 3, 11, 19, 28, 1, 5, 9, 13, 16, 22, 26, 31, 2, 4, 6, 8, 10, 12, 14, 17, 18, 20, 21, 23, 25, 27, 29, 30, 32, 33, 34, 35, 36, 37]) == 765197211\n assert candidate(nums = [15, 8, 23, 4, 12, 19, 27, 2, 6, 10, 14, 17, 21, 25, 29, 1, 3, 5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 26, 28, 30]) == 637714638\n assert candidate(nums = [5, 3, 7, 2, 4, 6, 8, 1, 9, 10]) == 1511\n assert candidate(nums = [1, 4, 2, 7, 3, 5, 8, 6, 9, 10, 11, 12, 13, 14, 15]) == 3509\n assert candidate(nums = [7, 3, 11, 1, 5, 9, 13, 2, 4, 6, 8, 10, 12, 14, 15]) == 12612599\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", "comparison": "exact"}, "public_tests": ["[2,1,3]", "[3,4,5,1,2]", "[1,2,3]"], "hints": ["Use a divide and conquer strategy.", "The first number will always be the root. Consider the numbers smaller and larger than the root separately. When merging the results together, how many ways can you order x elements in x+y positions?"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numOfWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:07+00:00", "tests_total": 74, "tests_dropped": 47, "flags": ["has_images"], "topic_tags": ["array", "math", "divide-and-conquer", "dynamic-programming", "tree", "union-find", "binary-search-tree", "memoization", "combinatorics", "binary-tree", "fermats-little-theorem"]}, "language": "python", "interface": {"raw_signature": "def numOfWays(self, nums: list[int]) -> int:", "container": "Solution", "callable": "numOfWays", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1572, "task_id": "matrix-diagonal-sum", "difficulty": "Easy", "problem_description": "Given a square matrix mat, return the sum of the matrix diagonals.\n\nOnly include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.\n\nExample 1:\n\nInput: mat = [[1,2,3],\n [4,5,6],\n [7,8,9]]\nOutput: 25\nExplanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25\nNotice that element mat[1][1] = 5 is counted only once.\n\nExample 2:\n\nInput: mat = [[1,1,1,1],\n [1,1,1,1],\n [1,1,1,1],\n [1,1,1,1]]\nOutput: 8\n\nExample 3:\n\nInput: mat = [[5]]\nOutput: 5\n\nConstraints:\n\n- n == mat.length == mat[i].length\n- 1 <= n <= 100\n- 1 <= mat[i][j] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[7, 3, 1, 9], [3, 4, 6, 9], [6, 9, 6, 6], [9, 5, 8, 5]]) == 55\n assert candidate(mat = [[5]]) == 5\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 25\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\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, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]]) == 520\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]]) == 117\n assert candidate(mat = [[5, 3, 1, 4, 2], [8, 6, 9, 7, 5], [3, 2, 8, 6, 4], [1, 4, 5, 2, 3], [7, 5, 4, 8, 6]]) == 47\n assert candidate(mat = [[100, 100, 100], [100, 99, 100], [100, 100, 100]]) == 499\n assert candidate(mat = [[50, 2, 3, 4, 5, 6, 7], [8, 50, 10, 11, 12, 13, 14], [15, 16, 50, 18, 19, 20, 21], [22, 23, 24, 50, 26, 27, 28], [29, 30, 31, 32, 50, 34, 35], [36, 37, 38, 39, 40, 50, 42], [43, 44, 45, 46, 47, 48, 50]]) == 500\n assert candidate(mat = [[5, 2, 3, 4, 5, 6, 7], [8, 5, 2, 3, 4, 5, 6], [7, 8, 5, 2, 3, 4, 5], [6, 7, 8, 5, 2, 3, 4], [5, 6, 7, 8, 5, 2, 3], [4, 5, 6, 7, 8, 5, 2], [3, 4, 5, 6, 7, 8, 5]]) == 65\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [1, 2, 3, 4, 5, 6], [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(mat = [[2, 3, 4, 5, 6], [1, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 119\n assert candidate(mat = [[1, 2], [3, 4]]) == 10\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [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]]) == 1010\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, 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]]) == 1020\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]]) == 222\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, 75, 74, 73], [72, 71, 70, 69, 68, 67, 66], [65, 64, 63, 62, 61, 60, 59], [58, 57, 56, 55, 54, 53, 52]]) == 988\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11], [11, 12, 13, 14, 15, 16, 17, 18]]) == 110\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 25\n assert candidate(mat = [[9, 2, 3, 4, 5, 6, 7, 8, 9], [2, 8, 3, 4, 5, 6, 7, 8, 9], [3, 4, 8, 4, 5, 6, 7, 8, 9], [4, 5, 6, 8, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 6, 7, 8, 9], [6, 7, 8, 9, 6, 8, 7, 8, 9], [7, 8, 9, 6, 7, 8, 8, 8, 9], [8, 9, 6, 7, 8, 9, 6, 8, 9], [9, 6, 7, 8, 9, 6, 7, 8, 8]]) == 140\n assert candidate(mat = [[50, 20, 10, 5, 1], [40, 30, 15, 25, 3], [35, 28, 20, 30, 4], [29, 22, 18, 26, 5], [23, 16, 12, 21, 6]]) == 203\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, 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]]) == 1010\n assert candidate(mat = [[2, 5, 4, 1, 6], [9, 7, 3, 8, 5], [6, 2, 9, 1, 3], [1, 6, 5, 9, 2], [7, 8, 4, 6, 9]]) == 63\n assert candidate(mat = [[10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39], [40, 41, 42, 43, 44, 45]]) == 330\n assert candidate(mat = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 126\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]]) == 222\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 13\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], [8, 9, 10, 11, 12, 13], [13, 14, 15, 16, 17, 18]]) == 84\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 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], [6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 70\n assert candidate(mat = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]) == 198\n assert candidate(mat = [[10, 15, 20, 25, 30], [5, 9, 12, 18, 22], [7, 11, 14, 17, 21], [4, 8, 13, 16, 23], [1, 2, 3, 6, 24]]) == 130\n assert candidate(mat = [[2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37]]) == 234\n assert candidate(mat = [[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]]) == 962\n assert candidate(mat = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24], [26, 28, 30, 32]]) == 136\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 360\n assert candidate(mat = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 126\n assert candidate(mat = [[50, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 50, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 50, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 50, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 50, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 50, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 50, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 50, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 50, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 50]]) == 510\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, 46, 47, 48, 49]]) == 325\n", "comparison": "exact"}, "public_tests": ["[[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]]", "[[5]]"], "hints": ["There will be overlap of elements in the primary and secondary diagonals if and only if the length of the matrix is odd, which is at the center."], "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().diagonalSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:09+00:00", "tests_total": 54, "tests_dropped": 16, "flags": ["has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def diagonalSum(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "diagonalSum", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1573, "task_id": "number-of-ways-to-split-a-string", "difficulty": "Medium", "problem_description": "Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.\n\nReturn the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: s = \"10101\"\nOutput: 4\nExplanation: There are four ways to split s in 3 parts where each part contain the same number of letters '1'.\n\"1|010|1\"\n\"1|01|01\"\n\"10|10|1\"\n\"10|1|01\"\n\nExample 2:\n\nInput: s = \"1001\"\nOutput: 0\n\nExample 3:\n\nInput: s = \"0000\"\nOutput: 3\nExplanation: There are three ways to split s in 3 parts.\n\"0|0|00\"\n\"0|00|0\"\n\"00|0|0\"\n\nConstraints:\n\n- 3 <= s.length <= 10^5\n- s[i] is either '0' or '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"101010101\") == 0\n assert candidate(s = \"10101010101\") == 4\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"0000000\") == 15\n assert candidate(s = \"010101010\") == 0\n assert candidate(s = \"111000\") == 1\n assert candidate(s = \"11111111111\") == 0\n assert candidate(s = \"111111\") == 1\n assert candidate(s = \"10101\") == 4\n assert candidate(s = \"001001001\") == 9\n assert candidate(s = \"1111111\") == 0\n assert candidate(s = \"1001001001\") == 0\n assert candidate(s = \"111000111000111\") == 16\n assert candidate(s = \"01010101010\") == 0\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"0000000000\") == 36\n assert candidate(s = \"1100110011\") == 9\n assert candidate(s = \"00000000000\") == 45\n assert candidate(s = \"1000000000001\") == 0\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"10100101010101\") == 0\n assert candidate(s = \"11011011011\") == 0\n assert candidate(s = \"111000111\") == 1\n assert candidate(s = \"100010001\") == 16\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 1176\n assert candidate(s = \"1001001001001001001001\") == 0\n assert candidate(s = \"111000111000111000111000111\") == 1\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000001110000011100000111\") == 36\n assert candidate(s = \"1000000010000000100000001\") == 0\n assert candidate(s = \"1110111011101110111011101110111\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 1\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 4\n assert candidate(s = \"1000100010001000100010001000100010001000100010001\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"1001001001001\") == 0\n assert candidate(s = \"00001000010000100001000010000100001000010000100001\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"0010101010100\") == 0\n assert candidate(s = \"1111000011110000111100001111\") == 0\n assert candidate(s = \"10101010101010101010101010\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 9\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001001001001001001\") == 9\n assert candidate(s = \"1100110011001100110011\") == 9\n assert candidate(s = \"0000111100001111000011110000111100001111\") == 0\n assert candidate(s = \"0011001100110011001100110011\") == 0\n assert candidate(s = \"110011001100110011001100110011\") == 0\n assert candidate(s = \"10000000001000000001\") == 90\n assert candidate(s = \"110011001100110\") == 0\n assert candidate(s = \"100000100000100000100000100000100000\") == 36\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == 4\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"10001000100010001000100010001000100010001000100010001000\") == 0\n assert candidate(s = \"111110000011111000001111100000111110000011111\") == 0\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100\") == 0\n assert candidate(s = \"000000000000000\") == 91\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"00010001000100010001\") == 0\n assert candidate(s = \"100000000000100000000010000000001\") == 0\n assert candidate(s = \"1000000000000000000001\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"000000000000000000000000000000000000000000000000000\") == 1225\n assert candidate(s = \"10100100100100100\") == 9\n assert candidate(s = \"0100100100100100100100100100100100100100100100100100\") == 0\n assert candidate(s = \"111111000000111111000000111111\") == 49\n assert candidate(s = \"00010001000100010001000100010001\") == 0\n assert candidate(s = \"0000000000000000000000\") == 210\n assert candidate(s = \"0000000000000000000000000\") == 276\n assert candidate(s = \"11011011011011011011011011011011\") == 0\n assert candidate(s = \"11111000001111100000111110000011111\") == 0\n assert candidate(s = \"111000111000111000111000\") == 1\n assert candidate(s = \"1000010000100001000010000100001\") == 0\n assert candidate(s = \"110011001100110011\") == 0\n assert candidate(s = \"101001010010100101001010010100101001010010100101001\") == 6\n assert candidate(s = \"0000000000000000000000000000\") == 351\n assert candidate(s = \"01001001001001\") == 0\n assert candidate(s = \"000000000000000000000000000000000000000000000\") == 946\n", "comparison": "exact"}, "public_tests": ["\"10101\"", "\"1001\"", "\"0000\""], "hints": ["There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0.", "Preffix s1 , and suffix s3 should have sum/3 characters '1'.", "Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same?"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:11+00:00", "tests_total": 84, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "string"]}, "language": "python", "interface": {"raw_signature": "def numWays(self, s: str) -> int:", "container": "Solution", "callable": "numWays", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1574, "task_id": "shortest-subarray-to-be-removed-to-make-array-sorted", "difficulty": "Medium", "problem_description": "Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.\n\nReturn the length of the shortest subarray to remove.\n\nA subarray is a contiguous subsequence of the array.\n\nExample 1:\n\nInput: arr = [1,2,3,10,4,2,3,5]\nOutput: 3\nExplanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.\nAnother correct solution is to remove the subarray [3,10,4].\n\nExample 2:\n\nInput: arr = [5,4,3,2,1]\nOutput: 4\nExplanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].\n\nExample 3:\n\nInput: arr = [1,2,3]\nOutput: 0\nExplanation: The array is already non-decreasing. We do not need to remove any elements.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 0 <= arr[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 9\n assert candidate(arr = [1, 2, 3]) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5]) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12]) == 6\n assert candidate(arr = [1]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7]) == 2\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 6, 7, 8, 9]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5]) == 3\n assert candidate(arr = [1, 2, 2, 3, 1, 4, 5]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(arr = [1, 3, 2, 4, 5]) == 1\n assert candidate(arr = [1, 3, 2, 4, 3, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3]) == 5\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [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]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 21\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]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 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]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == 1\n assert candidate(arr = [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, 20, 1]) == 21\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 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]) == 13\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0]) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 13, 14]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8]) == 23\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11]) == 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, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19]) == 5\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]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 27\n assert candidate(arr = [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]) == 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, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [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(arr = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 9\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17]) == 13\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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 19\n assert candidate(arr = [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]) == 8\n assert candidate(arr = [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, 20]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 21, 20, 22, 24, 23, 25]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\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]) == 29\n assert candidate(arr = [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]) == 19\n assert candidate(arr = [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]) == 12\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, 1, 2, 3]) == 3\n assert candidate(arr = [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]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9]) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 600]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 49\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(arr = [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]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 5\n assert candidate(arr = [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]) == 7\n assert candidate(arr = [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]) == 18\n assert candidate(arr = [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]) == 39\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 14\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]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 20, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33, 36, 35]) == 23\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [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]) == 19\n assert candidate(arr = [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]) == 15\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, 1, 2, 3, 4, 5, 6, 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(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 15, 16, 17, 18, 19, 20]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [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]) == 17\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 105, 110, 115, 120, 125, 130, 135, 140, 145]) == 1\n assert candidate(arr = [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]) == 16\n assert candidate(arr = [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]) == 18\n assert candidate(arr = [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]) == 13\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]) == 17\n assert candidate(arr = [10, 20, 30, 25, 26, 27, 15, 16, 17, 18, 19]) == 5\n assert candidate(arr = [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(arr = [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]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 9\n assert candidate(arr = [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, 1, 2, 3, 4, 5, 6, 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(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(arr = [1, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\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]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8]) == 16\n assert candidate(arr = [1, 2, 3, 10, 11, 12, 4, 5, 6, 7, 8, 9, 13, 14, 15]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 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]) == 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, 1, 2, 3, 4, 5]) == 19\n assert candidate(arr = [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]) == 19\n assert candidate(arr = [1, 10, 20, 15, 25, 30, 5, 10, 15, 20]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [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]) == 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, 21, 22, 23, 24, 25]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3]) == 27\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]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15]) == 11\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, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [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]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 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(arr = [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]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\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, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9]) == 22\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 1, 3, 5, 7, 9, 11]) == 23\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29]) == 6\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, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 51\n assert candidate(arr = [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]) == 9\n assert candidate(arr = [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]) == 15\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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, 5, 6, 7, 8, 9]) == 5\n assert candidate(arr = [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]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [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]) == 18\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 14\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]) == 19\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, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(arr = [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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 59\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 23\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [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]) == 15\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 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, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 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, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4]) == 4\n assert candidate(arr = [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]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\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\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 21\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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 33\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, 3, 5, 7, 9, 11]) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 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]) == 35\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 2\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n", "comparison": "exact"}, "public_tests": ["[11,10,18,14,12,11,16,20,13,11]", "[17,32,32,29,4,29,19,5,26,35,35,6,10,27,11,35,0,31]", "[1,8,34,2,3,22,18,27,3,1,0,12,21,23,8,7,17]"], "hints": ["The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively.", "After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findLengthOfShortestSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:14+00:00", "tests_total": 189, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers", "binary-search", "stack", "monotonic-stack"]}, "language": "python", "interface": {"raw_signature": "def findLengthOfShortestSubarray(self, arr: list[int]) -> int:", "container": "Solution", "callable": "findLengthOfShortestSubarray", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1575, "task_id": "count-all-possible-routes", "difficulty": "Hard", "problem_description": "You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.\n\nAt each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.\n\nNotice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).\n\nReturn the count of all possible routes from start to finish. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5\nOutput: 4\nExplanation: The following are all possible routes, each uses 5 units of fuel:\n1 -> 3\n1 -> 2 -> 3\n1 -> 4 -> 3\n1 -> 4 -> 2 -> 3\n\nExample 2:\n\nInput: locations = [4,3,1], start = 1, finish = 0, fuel = 6\nOutput: 5\nExplanation: The following are all possible routes:\n1 -> 0, used fuel = 1\n1 -> 2 -> 0, used fuel = 5\n1 -> 2 -> 1 -> 0, used fuel = 5\n1 -> 0 -> 1 -> 0, used fuel = 3\n1 -> 0 -> 1 -> 0 -> 1 -> 0, used fuel = 5\n\nExample 3:\n\nInput: locations = [5,2,1], start = 0, finish = 2, fuel = 3\nOutput: 0\nExplanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.\n\nConstraints:\n\n- 2 <= locations.length <= 100\n- 1 <= locations[i] <= 10^9\n- All integers in locations are distinct.\n- 0 <= start, finish < locations.length\n- 1 <= fuel <= 200\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(locations = [4, 3, 1],start = 1,finish = 0,fuel = 6) == 5\n assert candidate(locations = [1, 2, 3, 4, 5],start = 0,finish = 4,fuel = 10) == 1208\n assert candidate(locations = [5, 2, 1],start = 0,finish = 2,fuel = 3) == 0\n assert candidate(locations = [10, 20, 30, 40],start = 0,finish = 3,fuel = 50) == 16\n assert candidate(locations = [2, 3, 6, 8, 4],start = 1,finish = 3,fuel = 5) == 4\n assert candidate(locations = [1, 2, 3],start = 0,finish = 2,fuel = 3) == 2\n assert candidate(locations = [10, 20, 30, 40, 50],start = 0,finish = 4,fuel = 100) == 1208\n assert candidate(locations = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62],start = 2,finish = 9,fuel = 100) == 549504\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90],start = 3,finish = 8,fuel = 150) == 461824\n assert candidate(locations = [10, 25, 35, 45, 55],start = 0,finish = 4,fuel = 80) == 40\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 4,finish = 0,fuel = 150) == 179664\n assert candidate(locations = [5, 6, 8, 9, 11, 12, 14, 15, 17, 18],start = 0,finish = 9,fuel = 20) == 28672\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45],start = 0,finish = 8,fuel = 120) == 838699257\n assert candidate(locations = [1, 5, 9, 12, 18, 23],start = 0,finish = 5,fuel = 40) == 464\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,finish = 9,fuel = 100) == 11616768\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13],start = 0,finish = 6,fuel = 15) == 32\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 0,finish = 9,fuel = 20) == 256\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],start = 0,finish = 14,fuel = 150) == 8192\n assert candidate(locations = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],start = 0,finish = 19,fuel = 150) == 505021546\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80],start = 2,finish = 5,fuel = 100) == 1952\n assert candidate(locations = [3, 7, 12, 18, 23, 29, 34, 39, 44],start = 1,finish = 8,fuel = 100) == 11186944\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 200) == 262144\n assert candidate(locations = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],start = 6,finish = 11,fuel = 200) == 460940892\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15],start = 7,finish = 0,fuel = 15) == 64\n assert candidate(locations = [5, 20, 15, 40, 25, 35, 10],start = 2,finish = 6,fuel = 80) == 225320\n assert candidate(locations = [2, 15, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 1,finish = 17,fuel = 100) == 524288\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30],start = 0,finish = 6,fuel = 40) == 224\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,finish = 9,fuel = 150) == 892249801\n assert candidate(locations = [7, 15, 22, 30, 35, 40, 45],start = 1,finish = 4,fuel = 70) == 12736\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 10,finish = 19,fuel = 150) == 290816\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 0,finish = 9,fuel = 25) == 563971037\n assert candidate(locations = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],start = 0,finish = 9,fuel = 150) == 1469184\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 1,finish = 13,fuel = 40) == 344143577\n assert candidate(locations = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],start = 1,finish = 13,fuel = 100) == 569120129\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 9,finish = 10,fuel = 50) == 43\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30],start = 0,finish = 6,fuel = 30) == 32\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 5,finish = 9,fuel = 150) == 179664\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 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 = 29,finish = 0,fuel = 50) == 593376807\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 1,finish = 8,fuel = 15) == 64\n assert candidate(locations = [5, 8, 12, 18, 25, 30, 35, 40, 45, 50, 55, 60],start = 11,finish = 0,fuel = 100) == 15490048\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],start = 5,finish = 10,fuel = 150) == 500736\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 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,finish = 0,fuel = 100) == 802029339\n assert candidate(locations = [1, 5, 10, 20, 30, 40],start = 0,finish = 5,fuel = 60) == 208\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 20,fuel = 190) == 0\n assert candidate(locations = [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],start = 10,finish = 0,fuel = 150) == 759294305\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 4,finish = 8,fuel = 30) == 277680\n assert candidate(locations = [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],start = 0,finish = 29,fuel = 150) == 268435456\n assert candidate(locations = [1, 5, 10, 15, 20, 25],start = 0,finish = 5,fuel = 40) == 112\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],start = 7,finish = 14,fuel = 120) == 5760\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65],start = 0,finish = 6,fuel = 150) == 71872\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 9,finish = 0,fuel = 100) == 11616768\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,finish = 19,fuel = 18) == 0\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],start = 0,finish = 11,fuel = 100) == 9483264\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13],start = 0,finish = 6,fuel = 20) == 1536\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 0,finish = 9,fuel = 100) == 256\n assert candidate(locations = [5, 10, 15, 20, 25, 30],start = 0,finish = 5,fuel = 50) == 592\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 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 = 0,finish = 29,fuel = 150) == 996660885\n assert candidate(locations = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],start = 10,finish = 0,fuel = 50) == 636086244\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 0,finish = 14,fuel = 50) == 928900893\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,finish = 19,fuel = 190) == 533148385\n", "comparison": "exact"}, "public_tests": ["[2,3,6,8,4]\n1\n3\n5", "[4,3,1]\n1\n0\n6", "[5,2,1]\n0\n2\n3"], "hints": ["Use dynamic programming to solve this problem with each state defined by the city index and fuel left.", "Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles."], "metadata": {"canonical_parameter_names": ["locations", "start", "finish", "fuel"], "leetcode_dataset_entry_point": "Solution().countRoutes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:16+00:00", "tests_total": 96, "tests_dropped": 36, "flags": [], "topic_tags": ["array", "dynamic-programming", "memoization"]}, "language": "python", "interface": {"raw_signature": "def countRoutes(self, locations: list[int], start: int, finish: int, fuel: int) -> int:", "container": "Solution", "callable": "countRoutes", "parameters": [{"name": "locations", "type": "list[int]"}, {"name": "start", "type": "int"}, {"name": "finish", "type": "int"}, {"name": "fuel", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1576, "task_id": "replace-all-s-to-avoid-consecutive-repeating-characters", "difficulty": "Easy", "problem_description": "Given a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters.\n\nIt is guaranteed that there are no consecutive repeating characters in the given string except for '?'.\n\nReturn the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.\n\nExample 1:\n\nInput: s = \"?zs\"\nOutput: \"azs\"\nExplanation: There are 25 solutions for this problem. From \"azs\" to \"yzs\", all are valid. Only \"z\" is an invalid modification as the string will consist of consecutive repeating characters in \"zzs\".\n\nExample 2:\n\nInput: s = \"ubv?w\"\nOutput: \"ubvaw\"\nExplanation: There are 24 solutions for this problem. Only \"v\" and \"w\" are invalid modifications as the strings will consist of consecutive repeating characters in \"ubvvw\" and \"ubvww\".\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consist of lowercase English letters and '?'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"?zs\") == \"azs\"\n assert candidate(s = \"b?a\") == \"bca\"\n assert candidate(s = \"a?b?\") == \"acba\"\n assert candidate(s = \"zz?z?zz\") == \"zzazazz\"\n assert candidate(s = \"z?z\") == \"zaz\"\n assert candidate(s = \"abc?de?\") == \"abcadea\"\n assert candidate(s = \"?abcd\") == \"babcd\"\n assert candidate(s = \"zyx?\") == \"zyxa\"\n assert candidate(s = \"z?a?a?a?z\") == \"zbabababz\"\n assert candidate(s = \"a?b?c?\") == \"acbaca\"\n assert candidate(s = \"a?c?e?\") == \"abcaea\"\n assert candidate(s = \"??a??\") == \"ababa\"\n assert candidate(s = \"abc?ef?\") == \"abcaefa\"\n assert candidate(s = \"b?a?c?\") == \"bcabca\"\n assert candidate(s = \"?a?a?a?\") == \"bababab\"\n assert candidate(s = \"????\") == \"abab\"\n assert candidate(s = \"a?b?c?d?\") == \"acbacada\"\n assert candidate(s = \"abcd?\") == \"abcda\"\n assert candidate(s = \"xyz?\") == \"xyza\"\n assert candidate(s = \"?\") == \"a\"\n assert candidate(s = \"a?b\") == \"acb\"\n assert candidate(s = \"?a?b?c?\") == \"bacbaca\"\n assert candidate(s = \"a?b?c\") == \"acbac\"\n assert candidate(s = \"?a?a?a\") == \"bababa\"\n assert candidate(s = \"a?c\") == \"abc\"\n assert candidate(s = \"a?a\") == \"aba\"\n assert candidate(s = \"ubv?w\") == \"ubvaw\"\n assert candidate(s = \"?????\") == \"ababa\"\n assert candidate(s = \"abc?\") == \"abca\"\n assert candidate(s = \"?a?b?c\") == \"bacbac\"\n assert candidate(s = \"????????????\") == \"abababababab\"\n assert candidate(s = \"??a??b??c??d??\") == \"ababababcabdab\"\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?abcdef?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefa\"\n assert candidate(s = \"z?????????\") == \"zababababa\"\n assert candidate(s = \"a?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?f\") == \"acbacadaeafacbacadaeafacbacadaeafacbacadaeafacbacadaeaf\"\n assert candidate(s = \"x?y?z?x?y?\") == \"xayazaxaya\"\n assert candidate(s = \"?a?b?c?d?e\") == \"bacbacadae\"\n assert candidate(s = \"????????????????????\") == \"abababababababababab\"\n assert candidate(s = \"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?l?k?j?i?h?g?f?e?d?c?b?a\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabca\"\n assert candidate(s = \"abcd????efgh????ijkl????mnop????qrst????uvw????xyz????\") == \"abcdababefghababijklababmnopababqrstababuvwababxyzabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?\") == \"acbacadaeafaga\"\n assert candidate(s = \"?b?a?b?a?b?a?b?a?b?\") == \"abcacbcacbcacbcacba\"\n assert candidate(s = \"a??????b??????c??????d??????e??????\") == \"abababababababcabababdabababeababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz????\") == \"abcdefghijklmnopqrstuvwxyzabab\"\n assert candidate(s = \"ab?cde?fg?hij?kl?mno?pqr?stu?vwx?yz?\") == \"abacdeafgahijaklamnoapqrastuavwxayza\"\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?ab?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbaba\"\n assert candidate(s = \"a????b????c????\") == \"abababababcabab\"\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\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba?\") == \"zyxwvutsrqponmlkjihgfedcbab\"\n assert candidate(s = \"x???x???\") == \"xabaxaba\"\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?abcde?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdea\"\n assert candidate(s = \"abc????def????ghi????jkl????mno????pqr????stu????vwx????yz?\") == \"abcababdefababghiababjklababmnoababpqrababstuababvwxababyza\"\n assert candidate(s = \"a????b????c????d????e????\") == \"abababababcababdababeabab\"\n assert candidate(s = \"?????????\") == \"ababababa\"\n assert candidate(s = \"abcd?efg?hij?\") == \"abcdaefgahija\"\n assert candidate(s = \"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?l?k?j?i?h?g?f?e?d?c?b?a????\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabcababa\"\n assert candidate(s = \"?a?b?c?d?e?fg?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"bacbacadaeafgahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a???????????????????????????????????????????????????????b\") == \"abababababababababababababababababababababababababababacb\"\n assert candidate(s = \"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?l?k?j?i?h?g?f?e?d?c?b?a?z?y?x?w?\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabcabzayaxawa\"\n assert candidate(s = \"xyz???uvw???stu???rst???qpo???nml???kji???hgf???edc???ba???\") == \"xyzabauvwabastuabarstabaqpoabanmlabakjiabahgfabaedcabababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz????\") == \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabab\"\n assert candidate(s = \"?a?b?c?d?e?f?g\") == \"bacbacadaeafag\"\n assert candidate(s = \"????a????\") == \"ababababa\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a?\") == \"zayaxawavauatasaraqapaoanamalakajaiahagafaeadacabcab\"\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????\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"abc??xyz?\") == \"abcabxyza\"\n assert candidate(s = \"abc?de?fg?\") == \"abcadeafga\"\n assert candidate(s = \"????z\") == \"ababz\"\n assert candidate(s = \"a?????z\") == \"abababz\"\n assert candidate(s = \"abc????????de?????fg????hi????j????k????lm????n????op????qr????st????uv????wxyz????\") == \"abcababababdeababafgababhiababjababkabablmababnababopababqrababstababuvababwxyzabab\"\n assert candidate(s = \"a?????b?????c?????d?????e?????f?????g?????h?????i?????j?????\") == \"ababacbababacababadababaeababafababagababahababaiababajababa\"\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?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbab\"\n assert candidate(s = \"xyz???abc\") == \"xyzabcabc\"\n assert candidate(s = \"xyz?yxz?\") == \"xyzayxza\"\n assert candidate(s = \"?a?b?c?d?e?\") == \"bacbacadaea\"\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?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\"\n assert candidate(s = \"ab?cd?ef?gh?ij?kl?mn?op?qr?st?uv?wx?yz?a?b?c?d?e?\") == \"abacdaefaghaijaklamnaopaqrastauvawxayzbacbacadaea\"\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?abcdefg?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefga\"\n assert candidate(s = \"????abc????def????ghi????jkl????mno????pqr????stu????vwx????yz????\") == \"abababcababdefababghiababjklababmnoababpqrababstuababvwxababyzabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?\") == \"acbacadaeafagahaiaja\"\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?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacbaca\"\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?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacba\"\n assert candidate(s = \"a?????????????????????????????????????????????b\") == \"ababababababababababababababababababababababacb\"\n assert candidate(s = \"????????\") == \"abababab\"\n assert candidate(s = \"????abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abababcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"a????????????????????z\") == \"ababababababababababaz\"\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\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\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?abc?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabca\"\n assert candidate(s = \"?b?a?c?b?a?\") == \"abcabcabcab\"\n assert candidate(s = \"z??y?x?w?\") == \"zabyaxawa\"\n assert candidate(s = \"????abcdefghijklmnopqrstuvwxyz\") == \"abababcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy?\") == \"abcdefghijklmnopqrstuvwxya\"\n assert candidate(s = \"a?b?c?d?e?\") == \"acbacadaea\"\n assert candidate(s = \"abc?def?ghi?jkl?mno?pqr?stu?vwx?yz?\") == \"abcadefaghiajklamnoapqrastuavwxayza\"\n assert candidate(s = \"a?b?a?b?a?b?a?b?a?\") == \"acbcacbcacbcacbcab\"\n assert candidate(s = \"ab?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?\") == \"abacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\"\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?abcd?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcda\"\n assert candidate(s = \"z?a?y?b?x?c?w?v?d?u?t?e?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a?\") == \"zbabyabaxacawavadauataeasaraqapaoanamalakajaiahagafaeadacabcab\"\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????\") == \"abcdefghijklmnopqrstuvwxyzbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"aaaa???bbbbb???ccccc???\") == \"aaaabacbbbbbabacccccaba\"\n assert candidate(s = \"?a?b?c?d?e?f?g?\") == \"bacbacadaeafaga\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a\") == \"zayaxawavauatasaraqapaoanamalakajaiahagafaeadacabca\"\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\") == \"bacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a?a?a?a?a?a?a?a?a?a\") == \"abababababababababa\"\n assert candidate(s = \"a??b??c??d??\") == \"abababcabdab\"\n assert candidate(s = \"??a?b??c??\") == \"abacbabcab\"\n assert candidate(s = \"a?b??c?d\") == \"acbabcad\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz?\") == \"abcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcd????????efgh????????ijkl????????mnop????????qrst????????uvwx????????yz??\") == \"abcdababababefghababababijklababababmnopababababqrstababababuvwxababababyzab\"\n assert candidate(s = \"z????z????z????z????z\") == \"zababzababzababzababz\"\n assert candidate(s = \"a?a?a?a?a?b?b?b?b?b?c?c?c?c?c?d?d?d?d?d?\") == \"ababababacbababababacacacacacadadadadada\"\n assert candidate(s = \"xyz?abc?def?ghi?\") == \"xyzbabcadefaghia\"\n assert candidate(s = \"xyz??abc\") == \"xyzababc\"\n assert candidate(s = \"abcd????efgh\") == \"abcdababefgh\"\n assert candidate(s = \"?ab?bc?cd?de?ef?fg?\") == \"bababcacdadeaefafga\"\n assert candidate(s = \"abc???def\") == \"abcabadef\"\n assert candidate(s = \"b?a?b?a?b?a?\") == \"bcacbcacbcab\"\n assert candidate(s = \"abc?def?ghi?jkl?mno?pqr?stu?vwx?yz\") == \"abcadefaghiajklamnoapqrastuavwxayz\"\n assert candidate(s = \"abc?def?ghi?\") == \"abcadefaghia\"\n", "comparison": "exact"}, "public_tests": ["\"?zs\"", "\"ubv?w\""], "hints": ["Processing string from left to right, whenever you get a ‘?’, check left character and right character, and select a character not equal to either of them", "Do take care to compare with replaced occurrence of ‘?’ when checking the left character."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().modifyString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:18+00:00", "tests_total": 122, "tests_dropped": 3, "flags": ["multiple_answers"], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def modifyString(self, s: str) -> str:", "container": "Solution", "callable": "modifyString", "parameters": [{"name": "s", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1577, "task_id": "number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers", "difficulty": "Medium", "problem_description": "Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:\n\n- Type 1: Triplet (i, j, k) if nums1[i]^2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.\n- Type 2: Triplet (i, j, k) if nums2[i]^2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.\n\nExample 1:\n\nInput: nums1 = [7,4], nums2 = [5,2,8,9]\nOutput: 1\nExplanation: Type 1: (1, 1, 2), nums1[1]^2 = nums2[1] * nums2[2]. (4^2 = 2 * 8).\n\nExample 2:\n\nInput: nums1 = [1,1], nums2 = [1,1,1]\nOutput: 9\nExplanation: All Triplets are valid, because 1^2 = 1 * 1.\nType 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2). nums1[i]^2 = nums2[j] * nums2[k].\nType 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k].\n\nExample 3:\n\nInput: nums1 = [7,7,8,3], nums2 = [1,2,9,7]\nOutput: 2\nExplanation: There are 2 valid triplets.\nType 1: (3,0,2). nums1[3]^2 = nums2[0] * nums2[2].\nType 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1].\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 1000\n- 1 <= nums1[i], nums2[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 5, 7],nums2 = [9, 25, 49]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [25, 25, 25, 25]) == 0\n assert candidate(nums1 = [10, 5, 2],nums2 = [100, 25, 4]) == 1\n assert candidate(nums1 = [2, 3, 5],nums2 = [2, 5, 10]) == 0\n assert candidate(nums1 = [2, 2, 2, 2],nums2 = [4, 4, 4]) == 0\n assert candidate(nums1 = [7, 4],nums2 = [5, 2, 8, 9]) == 1\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3, 3]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 4, 9, 16, 25]) == 4\n assert candidate(nums1 = [6, 10, 15],nums2 = [36, 100, 225]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10, 10]) == 30\n assert candidate(nums1 = [5],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [7, 7, 8, 3],nums2 = [1, 2, 9, 7]) == 2\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1000],nums2 = [1, 10, 100, 1000]) == 0\n assert candidate(nums1 = [2, 3, 5],nums2 = [4, 9, 25]) == 0\n assert candidate(nums1 = [3, 15, 9],nums2 = [9, 25, 36]) == 1\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 10]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10]) == 18\n assert candidate(nums1 = [1],nums2 = [1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [10, 5, 3],nums2 = [2, 4, 8, 16]) == 0\n assert candidate(nums1 = [1, 1],nums2 = [1, 1, 1]) == 9\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]) == 10\n assert candidate(nums1 = [3, 9, 27, 81],nums2 = [9, 81, 243, 729, 2187, 6561]) == 3\n assert candidate(nums1 = [11, 22, 33, 44],nums2 = [121, 484, 726, 1936, 2904]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [6, 10, 12, 15],nums2 = [36, 100, 144, 225, 150]) == 0\n assert candidate(nums1 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3],nums2 = [1, 4, 4, 9, 9, 9, 9]) == 16\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]) == 900\n assert candidate(nums1 = [3, 9, 27, 81, 243, 729],nums2 = [9, 27, 81, 243, 729, 2187]) == 12\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],nums2 = [49, 196, 441, 784, 1225, 1764, 2401, 3136, 3969, 4900, 5929, 7056, 8281, 9604, 11025]) == 1\n assert candidate(nums1 = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13],nums2 = [169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169]) == 0\n assert candidate(nums1 = [4, 8, 12, 16, 20],nums2 = [16, 64, 144, 256, 400, 625, 1024]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [4, 16, 36, 64, 100, 144, 196]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [6, 10, 15],nums2 = [36, 100, 150, 225]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 13\n assert candidate(nums1 = [6, 12, 18, 24],nums2 = [36, 144, 324, 576, 864, 1152, 1440]) == 0\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [9, 36, 81, 144, 225, 324, 441]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 220\n assert candidate(nums1 = [8, 9, 12, 15, 18],nums2 = [64, 81, 144, 225, 324]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 100, 225, 400, 625]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [25, 100, 225, 400, 625, 900]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [1, 9, 25, 49, 81]) == 4\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [1, 1, 4, 4, 9, 9, 16, 16]) == 32\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12],nums2 = [4, 16, 36, 64, 100, 144, 256]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 13\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]) == 5\n assert candidate(nums1 = [12, 15, 20, 25, 30],nums2 = [144, 225, 400, 625, 900]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]) == 10\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [9, 36, 81, 144, 225, 324]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 1, 1, 4, 4, 4, 9, 9, 9, 16, 16, 16, 1]) == 156\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 400, 900, 1600, 2500, 3600, 4900, 6400, 8100, 10000, 12100, 14400, 16900, 19600, 22500]) == 0\n assert candidate(nums1 = [1, 2, 2, 4, 8, 16, 32],nums2 = [1, 1, 4, 4, 16, 16, 64]) == 33\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 400, 900, 1600, 2500, 50, 250, 1250, 6250]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],nums2 = [4, 9, 25, 49, 121, 169, 289, 361, 529, 841]) == 0\n assert candidate(nums1 = [7, 49, 343, 2401],nums2 = [49, 343, 2401, 16807]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 325\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 50, 75, 100, 125, 150]) == 0\n assert candidate(nums1 = [8, 15, 17, 20],nums2 = [64, 225, 289, 400, 676, 841]) == 0\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36]) == 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, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11550\n assert candidate(nums1 = [7, 11, 13, 17, 19, 23, 29, 31, 37],nums2 = [49, 121, 169, 289, 361, 529, 841, 961, 1369, 1681]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 22\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64],nums2 = [4, 16, 64, 256, 1024, 4096, 16384]) == 9\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]) == 0\n assert candidate(nums1 = [7, 24, 25, 30],nums2 = [49, 576, 625, 900, 1440, 1800]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17],nums2 = [4, 9, 25, 49, 121, 169, 289]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361, 529]) == 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]) == 900\n assert candidate(nums1 = [1, 3, 3, 3, 1],nums2 = [1, 9, 9, 1, 1, 9]) == 36\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3],nums2 = [1, 1, 2, 2, 3, 3]) == 14\n assert candidate(nums1 = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 563\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 1, 1, 4, 4, 9]) == 27\n assert candidate(nums1 = [3, 9, 27, 81, 243],nums2 = [27, 81, 243, 729, 2187]) == 6\n assert candidate(nums1 = [31, 37, 41, 43, 47, 53, 59],nums2 = [961, 1369, 1681, 1849, 2209, 2809, 3481]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256],nums2 = [4, 16, 64, 256, 1024, 4096]) == 17\n assert candidate(nums1 = [2, 2, 2, 2],nums2 = [4, 4, 4, 4, 4]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64],nums2 = [4, 16, 64, 256, 1024, 4096]) == 9\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [25, 100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]) == 1\n assert candidate(nums1 = [3, 5, 8, 12, 15, 17, 20],nums2 = [9, 25, 64, 144, 225, 289, 400]) == 1\n assert candidate(nums1 = [15, 20, 25, 30],nums2 = [225, 400, 625, 900, 1200, 1800]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [100, 100, 100, 100]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361]) == 0\n assert candidate(nums1 = [6, 7, 8],nums2 = [36, 49, 64, 84, 112]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11],nums2 = [4, 6, 9, 10, 14, 15, 21, 22, 30, 33, 35, 55, 77, 105]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 400, 900, 1600, 2500]) == 0\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],nums2 = [121, 484, 1089, 1936, 3025, 4356, 5929, 7744, 9801, 12100, 14641, 17424, 20736, 24336, 28081]) == 0\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [100, 400, 900, 1600, 2500]) == 0\n assert candidate(nums1 = [6, 8, 10, 12, 14],nums2 = [36, 64, 100, 144, 196, 256]) == 0\n assert candidate(nums1 = [15, 25, 35, 45, 55],nums2 = [225, 625, 1225, 2025, 3025, 450, 750, 1050, 1350, 1650]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 351\n assert candidate(nums1 = [6, 8, 10, 12, 14],nums2 = [36, 64, 100, 144, 196, 48, 72, 96, 112, 120]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],nums2 = [64, 256, 576, 1024, 1600, 2304, 3136, 4096, 5184, 6400]) == 0\n assert candidate(nums1 = [6, 10, 14, 18, 22, 26, 30],nums2 = [36, 100, 196, 324, 484, 676, 900]) == 0\n assert candidate(nums1 = [3, 5, 7, 11, 13],nums2 = [9, 25, 49, 121, 169, 289]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19, 23, 29],nums2 = [49, 121, 169, 289, 361, 529, 841]) == 0\n assert candidate(nums1 = [5, 12, 13, 15],nums2 = [25, 144, 169, 225, 441]) == 0\n assert candidate(nums1 = [11, 13, 17, 19],nums2 = [121, 169, 289, 361, 441, 529]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4],nums2 = [1, 4, 4, 9, 9, 16]) == 12\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361, 441]) == 0\n", "comparison": "exact"}, "public_tests": ["[7,4]\n[5,2,8,9]", "[1,1]\n[1,1,1]", "[7,7,8,3]\n[1,2,9,7]"], "hints": ["Precalculate the frequencies of all nums1[i]^2 and nums2[i]^2"], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().numTriplets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:20+00:00", "tests_total": 121, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "hash-table", "math", "two-pointers"]}, "language": "python", "interface": {"raw_signature": "def numTriplets(self, nums1: list[int], nums2: list[int]) -> int:", "container": "Solution", "callable": "numTriplets", "parameters": [{"name": "nums1", "type": "list[int]"}, {"name": "nums2", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1578, "task_id": "minimum-time-to-make-rope-colorful", "difficulty": "Medium", "problem_description": "Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the i^th balloon.\n\nAlice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the i^th balloon from the rope.\n\nReturn the minimum time Bob needs to make the rope colorful.\n\nExample 1:\n\nInput: colors = \"abaac\", neededTime = [1,2,3,4,5]\nOutput: 3\nExplanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green.\nBob can remove the blue balloon at index 2. This takes 3 seconds.\nThere are no longer two consecutive balloons of the same color. Total time = 3.\n\nExample 2:\n\nInput: colors = \"abc\", neededTime = [1,2,3]\nOutput: 0\nExplanation: The rope is already colorful. Bob does not need to remove any balloons from the rope.\n\nExample 3:\n\nInput: colors = \"aabaa\", neededTime = [1,2,3,4,1]\nOutput: 2\nExplanation: Bob will remove the balloons at indices 0 and 4. Each balloons takes 1 second to remove.\nThere are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2.\n\nConstraints:\n\n- n == colors.length == neededTime.length\n- 1 <= n <= 10^5\n- 1 <= neededTime[i] <= 10^4\n- colors contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"abcabc\",neededTime = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(colors = \"aaaaa\",neededTime = [5, 4, 3, 2, 1]) == 10\n assert candidate(colors = \"abacabadabacaba\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(colors = \"aabaa\",neededTime = [1, 2, 3, 4, 1]) == 2\n assert candidate(colors = \"zzzz\",neededTime = [1, 1, 1, 1]) == 3\n assert candidate(colors = \"aaaa\",neededTime = [10, 5, 4, 2]) == 11\n assert candidate(colors = \"abcdef\",neededTime = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"abaac\",neededTime = [1, 2, 3, 4, 5]) == 3\n assert candidate(colors = \"abc\",neededTime = [1, 2, 3]) == 0\n assert candidate(colors = \"abcdefg\",neededTime = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"aaabbb\",neededTime = [1, 2, 3, 4, 5, 6]) == 12\n assert candidate(colors = \"aabbcc\",neededTime = [1, 2, 3, 1, 2, 3]) == 4\n assert candidate(colors = \"abcd\",neededTime = [4, 3, 2, 1]) == 0\n assert candidate(colors = \"bbbaaa\",neededTime = [4, 9, 3, 8, 8, 9]) == 23\n assert candidate(colors = \"ababab\",neededTime = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(colors = \"a\",neededTime = [5]) == 0\n assert candidate(colors = \"aabab\",neededTime = [3, 5, 10, 7, 5]) == 3\n assert candidate(colors = \"aaabbb\",neededTime = [3, 5, 10, 7, 5, 3]) == 16\n assert candidate(colors = \"a\",neededTime = [1]) == 0\n assert candidate(colors = \"zzzz\",neededTime = [10, 1, 1, 100]) == 12\n assert candidate(colors = \"abcabcabcabc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(colors = \"ababababab\",neededTime = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbb\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 18\n assert candidate(colors = \"aaabbbcccdddeee\",neededTime = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 30\n assert candidate(colors = \"aaabaaaabaaaaaaaabaa\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 28\n assert candidate(colors = \"ababaababaaba\",neededTime = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8, 5]) == 8\n assert candidate(colors = \"aabbaa\",neededTime = [1, 2, 3, 4, 5, 6]) == 9\n assert candidate(colors = \"aaaabbbbccccdddd\",neededTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 30\n assert candidate(colors = \"aaaabbbbcccc\",neededTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 18\n assert candidate(colors = \"abababababab\",neededTime = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4]) == 0\n assert candidate(colors = \"aabbccddeeff\",neededTime = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(colors = \"aabccbaa\",neededTime = [3, 5, 10, 7, 5, 3, 5, 3]) == 11\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 49\n assert candidate(colors = \"aaaaaaaaaa\",neededTime = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 12222\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(colors = \"bbbaaabbb\",neededTime = [10, 1, 1, 1, 10, 10, 1, 1, 10]) == 15\n assert candidate(colors = \"xyzzzyx\",neededTime = [1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(colors = \"aaaaaaaaaaaa\",neededTime = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == 109934\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",neededTime = [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]) == 180\n assert candidate(colors = \"abccbaabccba\",neededTime = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(colors = \"aabbaa\",neededTime = [10, 5, 1, 1, 5, 10]) == 11\n assert candidate(colors = \"abcabcabc\",neededTime = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(colors = \"abcdefghij\",neededTime = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(colors = \"aabbccddeeffgghhiijjkk\",neededTime = [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(colors = \"abcabcabcabc\",neededTime = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 0\n assert candidate(colors = \"aaabbbcccddd\",neededTime = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 20\n assert candidate(colors = \"aaaabbbb\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8]) == 24\n assert candidate(colors = \"abababababababababab\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(colors = \"abcabcabcabcabcabcabc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 0\n assert candidate(colors = \"abababababababababab\",neededTime = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9, 1, 9]) == 0\n assert candidate(colors = \"aabaaaaba\",neededTime = [1, 2, 1, 1, 1, 1, 1, 2, 1]) == 4\n assert candidate(colors = \"ababababab\",neededTime = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 0\n assert candidate(colors = \"aabbaa\",neededTime = [10, 1, 10, 2, 10, 3]) == 6\n assert candidate(colors = \"ababaababa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(colors = \"aaaabbbbccccdddd\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 24\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbb\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 18\n assert candidate(colors = \"aabbaabbcc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(colors = \"aaabaaaaba\",neededTime = [5, 5, 5, 1, 1, 5, 5, 1, 1, 5]) == 17\n assert candidate(colors = \"zzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 36\n assert candidate(colors = \"abcdabcde\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 5]) == 0\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",neededTime = [1, 2, 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(colors = \"aaabaaaabaaab\",neededTime = [3, 2, 1, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 11\n assert candidate(colors = \"aabbaaabbbaaa\",neededTime = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 9\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(colors = \"abcabcabcabc\",neededTime = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30]) == 0\n assert candidate(colors = \"ababababab\",neededTime = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(colors = \"abababababab\",neededTime = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 6, 1]) == 0\n assert candidate(colors = \"aabbaabbaabb\",neededTime = [10, 20, 30, 40, 10, 20, 30, 40, 10, 20, 30, 40]) == 120\n assert candidate(colors = \"aabbccddeeff\",neededTime = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(colors = \"abcabcabcabc\",neededTime = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 0\n assert candidate(colors = \"zzzzz\",neededTime = [1, 2, 3, 4, 5]) == 10\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(colors = \"aabacbacba\",neededTime = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(colors = \"abcdabcda\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1]) == 0\n assert candidate(colors = \"aabbccddeeff\",neededTime = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 6\n assert candidate(colors = \"aaaabbbb\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4]) == 12\n assert candidate(colors = \"abcdefghij\",neededTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n", "comparison": "exact"}, "public_tests": ["\"abaac\"\n[1,2,3,4,5]", "\"abc\"\n[1,2,3]", "\"aabaa\"\n[1,2,3,4,1]"], "hints": ["Maintain the running sum and max value for repeated letters."], "metadata": {"canonical_parameter_names": ["colors", "neededTime"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:23+00:00", "tests_total": 91, "tests_dropped": 13, "flags": ["has_images"], "topic_tags": ["array", "string", "dynamic-programming", "greedy"]}, "language": "python", "interface": {"raw_signature": "def minCost(self, colors: str, neededTime: list[int]) -> int:", "container": "Solution", "callable": "minCost", "parameters": [{"name": "colors", "type": "str"}, {"name": "neededTime", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1579, "task_id": "remove-max-number-of-edges-to-keep-graph-fully-traversable", "difficulty": "Hard", "problem_description": "Alice and Bob have an undirected graph of n nodes and three types of edges:\n\n- Type 1: Can be traversed by Alice only.\n- Type 2: Can be traversed by Bob only.\n- Type 3: Can be traversed by both Alice and Bob.\n\nGiven an array edges where edges[i] = [type_i, u_i, v_i] represents a bidirectional edge of type type_i between nodes u_i and v_i, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.\n\nReturn the maximum number of edges you can remove, or return -1 if Alice and Bob cannot fully traverse the graph.\n\nExample 1:\n\nInput: n = 4, edges = [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]\nOutput: 2\nExplanation: If we remove the 2 edges [1,1,2] and [1,1,3]. The graph will still be fully traversable by Alice and Bob. Removing any additional edge will not make it so. So the maximum number of edges we can remove is 2.\n\nExample 2:\n\nInput: n = 4, edges = [[3,1,2],[3,2,3],[1,1,4],[2,1,4]]\nOutput: 0\nExplanation: Notice that removing any edge will not make the graph fully traversable by Alice and Bob.\n\nExample 3:\n\nInput: n = 4, edges = [[3,2,3],[1,1,2],[2,3,4]]\nOutput: -1\nExplanation: In the current graph, Alice cannot reach node 4 from the other nodes. Likewise, Bob cannot reach 1. Therefore it's impossible to make the graph fully traversable.\n\nConstraints:\n\n- 1 <= n <= 10^5\n- 1 <= edges.length <= min(10^5, 3 * n * (n - 1) / 2)\n- edges[i].length == 3\n- 1 <= type_i <= 3\n- 1 <= u_i < v_i <= n\n- All tuples (type_i, u_i, v_i) are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [3, 4, 5], [1, 2, 3], [2, 3, 4]]) == -1\n assert candidate(n = 4,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4]]) == 2\n assert candidate(n = 4,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 4], [2, 1, 4]]) == 0\n assert candidate(n = 5,edges = [[3, 1, 2], [3, 2, 3], [3, 4, 5], [1, 1, 3], [1, 1, 4], [2, 3, 5]]) == 1\n assert candidate(n = 3,edges = [[1, 1, 2], [2, 1, 2], [3, 2, 3]]) == 0\n assert candidate(n = 4,edges = [[3, 2, 3], [1, 1, 2], [2, 3, 4]]) == -1\n assert candidate(n = 6,edges = [[1, 1, 2], [1, 2, 3], [2, 3, 4], [2, 4, 5], [3, 5, 6]]) == -1\n assert candidate(n = 3,edges = [[3, 1, 2], [1, 1, 3], [2, 2, 3]]) == 0\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 5, 6], [1, 6, 7], [2, 4, 5], [2, 5, 8], [3, 7, 8], [1, 2, 8], [2, 3, 7]]) == -1\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 20], [2, 2, 19], [1, 3, 18], [2, 4, 17], [1, 5, 16], [2, 6, 15], [1, 7, 14], [2, 8, 13], [1, 9, 12], [2, 10, 11]]) == 10\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 5, 6], [1, 6, 7], [2, 5, 7], [1, 1, 4], [2, 1, 2]]) == -1\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 15], [2, 2, 14], [1, 3, 13], [2, 4, 12], [1, 5, 11], [2, 6, 10], [1, 7, 9], [2, 8, 9]]) == 8\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 4, 5], [2, 3, 4], [2, 5, 6], [3, 1, 4]]) == -1\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 6], [2, 1, 6]]) == 2\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10], [1, 4, 11], [2, 7, 13], [3, 8, 14], [1, 9, 15], [2, 10, 14], [1, 11, 16], [2, 12, 17], [1, 13, 18], [2, 14, 19], [1, 15, 20], [2, 16, 18], [3, 17, 19]]) == 18\n assert candidate(n = 8,edges = [[3, 1, 2], [1, 1, 3], [2, 2, 3], [3, 3, 4], [1, 3, 4], [2, 3, 4], [3, 4, 5], [1, 4, 5], [2, 4, 5], [3, 5, 6], [1, 5, 6], [2, 5, 6], [3, 6, 7], [1, 6, 7], [2, 6, 7], [3, 7, 8], [1, 7, 8], [2, 7, 8], [1, 1, 8], [2, 1, 8]]) == 12\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 1, 8], [1, 2, 5], [2, 3, 6], [1, 4, 7], [2, 5, 8]]) == 2\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 8], [1, 8, 15], [2, 2, 9], [2, 9, 14]]) == 4\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 2], [1, 3, 4], [1, 5, 6], [2, 2, 3], [2, 4, 5]]) == 5\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 4, 5], [1, 5, 6], [2, 6, 7], [2, 7, 8], [1, 8, 9], [2, 1, 2], [2, 1, 3], [1, 1, 9]]) == -1\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [1, 6, 7], [2, 2, 4], [2, 4, 6], [2, 5, 7], [1, 2, 5], [2, 1, 3], [3, 1, 7]]) == 5\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [1, 3, 4], [1, 5, 6], [1, 7, 8], [1, 9, 10], [2, 2, 3], [2, 4, 5], [2, 6, 7], [2, 8, 9]]) == 9\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 7], [1, 7, 8], [1, 8, 9], [2, 2, 5], [2, 5, 8], [2, 3, 6], [3, 1, 6], [1, 2, 8], [2, 3, 7]]) == -1\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 4], [1, 4, 7], [1, 7, 9], [2, 2, 5], [2, 5, 8]]) == 5\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 6], [1, 6, 11], [2, 2, 7], [2, 7, 12]]) == 4\n assert candidate(n = 6,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [3, 1, 3], [3, 2, 4], [3, 3, 5], [3, 4, 6]]) == 8\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [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], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 10, 11], [2, 11, 12]]) == 22\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [2, 1, 10], [2, 2, 5], [2, 3, 6], [2, 4, 7]]) == -1\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 7, 8], [1, 8, 9], [2, 9, 10], [1, 1, 10], [2, 1, 5], [1, 2, 3]]) == -1\n assert candidate(n = 11,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [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], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 10, 11]]) == 20\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 3], [2, 3, 5], [1, 5, 7], [2, 7, 9], [1, 2, 4], [2, 4, 6], [1, 6, 8], [2, 8, 10]]) == 8\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 2], [1, 3, 4], [1, 5, 6], [2, 2, 3], [2, 4, 5], [2, 6, 7], [1, 1, 7], [2, 2, 7]]) == 8\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 4], [1, 4, 5], [2, 2, 4], [2, 4, 6], [3, 3, 5], [3, 5, 6], [1, 1, 6], [2, 1, 2]]) == 4\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 4], [1, 4, 7], [1, 7, 10], [2, 2, 5], [2, 5, 8], [2, 8, 10]]) == 6\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [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], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10]]) == 18\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [2, 6, 7], [1, 5, 7], [3, 2, 7]]) == 1\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [2, 2, 4], [2, 4, 6], [2, 6, 8]]) == -1\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6]]) == 10\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 2, 6], [2, 4, 5], [2, 5, 6], [1, 3, 5], [2, 2, 4]]) == 2\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 1, 3], [1, 3, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 5, 7], [2, 7, 9]]) == -1\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [2, 2, 3], [1, 3, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 9], [1, 9, 10], [1, 1, 10]]) == 10\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 4], [2, 2, 5], [1, 2, 3], [2, 3, 4], [1, 3, 6], [2, 4, 7], [1, 5, 6], [2, 5, 7], [1, 6, 7]]) == 9\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 5], [2, 5, 10]]) == 2\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 5, 6], [1, 6, 7], [2, 4, 5], [2, 5, 8], [3, 7, 8], [1, 2, 8], [2, 3, 7], [1, 9, 10], [2, 10, 11], [3, 11, 12], [1, 1, 12], [2, 1, 11]]) == -1\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [2, 6, 7], [1, 5, 7], [2, 5, 8], [1, 3, 8], [3, 1, 5]]) == -1\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10]]) == 6\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10], [1, 4, 11], [2, 7, 13], [3, 8, 14], [1, 9, 15], [2, 10, 14]]) == 11\n assert candidate(n = 7,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [3, 1, 7]]) == -1\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7]]) == 12\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9]]) == 16\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 2], [1, 3, 4], [1, 5, 6], [1, 7, 8], [2, 2, 3], [2, 4, 5], [2, 6, 7], [2, 8, 9], [1, 1, 9], [2, 2, 9]]) == 10\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 6, 7], [1, 7, 8], [2, 5, 7], [2, 6, 8], [1, 1, 3], [2, 1, 4]]) == 2\n assert candidate(n = 7,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [3, 1, 4], [3, 2, 5], [3, 3, 6], [3, 4, 7]]) == 8\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8]]) == 14\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 5], [2, 5, 9], [1, 9, 13], [2, 13, 15], [1, 2, 3], [2, 4, 6], [1, 6, 7], [2, 8, 10], [1, 10, 11], [2, 12, 14]]) == 10\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 3], [2, 3, 5], [1, 5, 7], [2, 7, 9], [1, 9, 11], [2, 1, 2], [1, 2, 4], [2, 4, 6], [1, 6, 8], [2, 8, 10], [1, 10, 12]]) == 11\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 3], [2, 2, 4], [1, 1, 2], [2, 3, 4], [1, 2, 5], [2, 4, 6]]) == 6\n", "comparison": "exact"}, "public_tests": ["4\n[[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]", "4\n[[3,1,2],[3,2,3],[1,1,4],[2,1,4]]", "4\n[[3,2,3],[1,1,2],[2,3,4]]"], "hints": ["Build the network instead of removing extra edges.", "Suppose you have the final graph (after removing extra edges). Consider the subgraph with only the edges that Alice can traverse. What structure does this subgraph have? How many edges are there?", "Use disjoint set union data structure for both Alice and Bob.", "Always use Type 3 edges first, and connect the still isolated ones using other edges."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().maxNumEdgesToRemove", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:25+00:00", "tests_total": 65, "tests_dropped": 8, "flags": ["has_images"], "topic_tags": ["union-find", "graph"]}, "language": "python", "interface": {"raw_signature": "def maxNumEdgesToRemove(self, n: int, edges: list[list[int]]) -> int:", "container": "Solution", "callable": "maxNumEdgesToRemove", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1582, "task_id": "special-positions-in-a-binary-matrix", "difficulty": "Easy", "problem_description": "Given an m x n binary matrix mat, return the number of special positions in mat.\n\nA position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).\n\nExample 1:\n\nInput: mat = [[1,0,0],[0,0,1],[1,0,0]]\nOutput: 1\nExplanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.\n\nExample 2:\n\nInput: mat = [[1,0,0],[0,1,0],[0,0,1]]\nOutput: 3\nExplanation: (0, 0), (1, 1) and (2, 2) are special positions.\n\nConstraints:\n\n- m == mat.length\n- n == mat[i].length\n- 1 <= m, n <= 100\n- mat[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 0], [0, 1]]) == 2\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 0]]) == 2\n assert candidate(mat = [[1, 0, 0], [0, 0, 1], [1, 0, 0]]) == 1\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 3\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[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, 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]]) == 8\n assert candidate(mat = [[0, 0, 0, 1, 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, 1, 0, 0], [1, 0, 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, 1, 0, 0, 0]]) == 8\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 1\n assert candidate(mat = [[1, 0, 1, 0], [0, 0, 0, 0], [1, 0, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 4\n assert candidate(mat = [[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, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]]) == 7\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[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, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 1\n assert candidate(mat = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [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, 0, 0, 0, 0, 0, 1, 0]]) == 8\n assert candidate(mat = [[0, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == 1\n assert candidate(mat = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[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(mat = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 5\n assert candidate(mat = [[0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0]]) == 4\n assert candidate(mat = [[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, 1], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 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]]) == 4\n assert candidate(mat = [[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, 0, 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, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0]]) == 10\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(mat = [[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]]) == 7\n assert candidate(mat = [[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, 1], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(mat = [[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]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 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, 1, 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]]) == 7\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 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, 0, 1]]) == 1\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 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, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0]]) == 7\n assert candidate(mat = [[0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 1, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 0, 0], [1, 0, 1, 0], [0, 0, 0, 1]]) == 1\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == 2\n assert candidate(mat = [[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, 1], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]]) == 5\n assert candidate(mat = [[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, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(mat = [[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, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[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]]) == 2\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 1, 0]]) == 1\n assert candidate(mat = [[0, 1, 1], [0, 0, 0], [1, 0, 0]]) == 1\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0]]) == 0\n assert candidate(mat = [[0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 5\n", "comparison": "exact"}, "public_tests": ["[[1,0,0],[0,0,1],[1,0,0]]", "[[1,0,0],[0,1,0],[0,0,1]]"], "hints": ["Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1."], "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().numSpecial", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:30+00:00", "tests_total": 70, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "matrix"]}, "language": "python", "interface": {"raw_signature": "def numSpecial(self, mat: list[list[int]]) -> int:", "container": "Solution", "callable": "numSpecial", "parameters": [{"name": "mat", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1584, "task_id": "min-cost-to-connect-all-points", "difficulty": "Medium", "problem_description": "You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [x_i, y_i].\n\nThe cost of connecting two points [x_i, y_i] and [x_j, y_j] is the manhattan distance between them: |x_i - x_j| + |y_i - y_j|, where |val| denotes the absolute value of val.\n\nReturn the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.\n\nExample 1:\n\nInput: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]\nOutput: 20\nExplanation:\n\nWe can connect the points as shown above to get the minimum cost of 20.\nNotice that there is a unique path between every pair of points.\n\nExample 2:\n\nInput: points = [[3,12],[-2,5],[-4,1]]\nOutput: 18\n\nConstraints:\n\n- 1 <= points.length <= 1000\n- -10^6 <= x_i, y_i <= 10^6\n- All pairs (x_i, y_i) are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [2, 2], [4, 4], [6, 6], [8, 8]]) == 16\n assert candidate(points = [[1, 1], [0, 0], [2, 2], [3, 3], [4, 4]]) == 8\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [0, 0]]) == 4000000\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == 8\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [-1, 1]]) == 4\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 10\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == 40\n assert candidate(points = [[-1000000, -1000000], [1000000, 1000000]]) == 4000000\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 6\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4]]) == 6\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1]]) == 6\n assert candidate(points = [[3, 12], [-2, 5], [-4, 1]]) == 18\n assert candidate(points = [[1000000, -1000000], [-1000000, 1000000], [0, 0]]) == 4000000\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]]) == 3\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1]]) == 3\n assert candidate(points = [[0, 0], [2, 2], [3, 10], [5, 2], [7, 0]]) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 19\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == 1600\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000], [250000, 750000], [750000, 250000], [100000, 100000], [900000, 900000], [100000, 900000], [900000, 100000]]) == 4000000\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8], [9, 9], [9, 10], [10, 9], [10, 10]]) == 23\n assert candidate(points = [[-1, 0], [0, -1], [1, 0], [0, 1], [-2, 0], [0, -2], [2, 0], [0, 2], [-3, 0], [0, -3], [3, 0], [0, 3], [-4, 0], [0, -4], [4, 0], [0, 4]]) == 18\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [20, 0], [20, 10], [30, 0], [30, 10], [40, 0], [40, 10]]) == 90\n assert candidate(points = [[-5, 5], [0, 0], [5, -5], [10, 10], [-10, -10], [15, 15], [-15, -15]]) == 80\n assert candidate(points = [[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]]) == 19\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 18\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 18\n assert candidate(points = [[1, 1], [2, 3], [4, 5], [8, 10], [15, 20], [25, 30], [40, 50]]) == 88\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 20\n assert candidate(points = [[1000000, 1000000], [-1000000, -1000000], [0, 0], [500000, 500000], [-500000, -500000]]) == 4000000\n assert candidate(points = [[-50, -100], [-150, -200], [-250, -300], [-350, -400], [-450, -500], [-550, -600], [-650, -700], [-750, -800], [-850, -900], [-950, -1000]]) == 1800\n assert candidate(points = [[1000000, -1000000], [0, 0], [-1000000, 1000000], [500000, 500000], [-500000, -500000]]) == 6000000\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [1, 1], [-1, 0], [0, -1], [-1, -1], [-1, 1], [1, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [-2, -1], [-1, -2], [-2, 1], [1, -2]]) == 16\n assert candidate(points = [[10, 10], [20, 10], [20, 20], [10, 20], [15, 15], [5, 5], [25, 25], [10, 5], [10, 15], [5, 10]]) == 60\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 9], [11, 10], [10, 11], [3, 5], [2, 3], [6, 8], [9, 4]]) == 26\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [0, 0], [-500000, 500000], [500000, -500000]]) == 4000000\n assert candidate(points = [[1, 1000000], [1000000, 1], [1, 2], [2, 1], [1000000, 2], [2, 1000000], [1000000, 1000000]]) == 2999998\n assert candidate(points = [[1, 2], [4, 8], [1, 7], [6, 1], [9, 7], [7, 4], [9, 1], [7, 9], [9, 2], [7, 6]]) == 29\n assert candidate(points = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 20\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 90\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 4], [2, 1], [5, 5], [7, 8], [8, 9], [1, 4], [2, 8], [7, 1], [9, 5]]) == 32\n assert candidate(points = [[-1, -2], [-3, -4], [-5, -6], [-7, -8], [-9, -10], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 38\n assert candidate(points = [[-3, -3], [-2, -2], [-1, -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]]) == 34\n assert candidate(points = [[1, 1], [2, 3], [3, 1], [4, 3], [5, 1], [6, 3], [7, 1], [8, 3], [9, 1], [10, 3]]) == 19\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 0], [3, 1], [4, 0], [4, 1]]) == 9\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [150, 250], [250, 150], [350, 450], [450, 350], [550, 450]]) == 1300\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 0], [0, 2], [1, 2], [2, 1], [0, 3], [3, 0], [3, 3]]) == 12\n assert candidate(points = [[1, 2], [4, 8], [5, 0], [7, 3], [8, 9], [9, 6], [9, 7], [10, 4], [10, 8], [11, 2]]) == 32\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]]) == 11\n assert candidate(points = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600]]) == 2800\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 10]]) == 26\n assert candidate(points = [[10, 10], [20, 10], [20, 20], [10, 20], [30, 10], [30, 20], [40, 10], [40, 20], [15, 15], [25, 15], [35, 15], [15, 25], [25, 25], [35, 25]]) == 130\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0]]) == 14\n assert candidate(points = [[-1, -1], [1, 1], [0, 0], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4], [5, 5], [-5, -5], [6, 6], [-6, -6]]) == 24\n assert candidate(points = [[-100, 0], [0, 100], [100, 0], [0, -100], [50, 50], [-50, -50], [50, -50], [-50, 50], [0, 0], [0, 0]]) == 800\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512]]) == 768\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28]]) == 42\n assert candidate(points = [[500000, 500000], [400000, 400000], [300000, 300000], [200000, 200000], [100000, 100000], [0, 0], [-100000, -100000], [-200000, -200000], [-300000, -300000], [-400000, -400000], [-500000, -500000]]) == 2000000\n assert candidate(points = [[0, 0], [1, 2], [3, 1], [2, 3], [4, 5], [6, 4], [5, 6], [7, 8], [9, 7], [8, 9], [10, 10], [12, 11], [11, 12], [13, 14], [15, 13], [14, 15], [16, 16], [18, 17], [17, 18], [19, 19]]) == 54\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160], [170, 180], [190, 200]]) == 360\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 20\n assert candidate(points = [[1000000, 0], [0, 1000000], [500000, 500000], [250000, 750000], [750000, 250000]]) == 2000000\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 21\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 36\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100]]) == 1800\n assert candidate(points = [[0, 0], [1000000, 1000000], [500000, 500000], [250000, 250000], [750000, 750000], [125000, 125000], [875000, 875000], [312500, 312500], [687500, 687500], [437500, 437500]]) == 2000000\n assert candidate(points = [[-200000, 200000], [-400000, 400000], [-600000, 600000], [-800000, 800000], [-1000000, 1000000], [200000, -200000], [400000, -400000], [600000, -600000], [800000, -800000], [1000000, -1000000]]) == 4000000\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11]]) == 32\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 0], [0, 2]]) == 7\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000]]) == 4000000\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 1], [9, 2], [10, 3]]) == 42\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]) == 18\n assert candidate(points = [[-1, 2], [-4, 6], [-5, 7], [-8, 9], [-11, 10], [-10, -11], [-3, -5], [-2, -3], [-6, -8], [-9, -4]]) == 47\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1], [2, 2], [-2, 2], [2, -2], [-2, -2], [3, 3], [-3, 3], [3, -3], [-3, -3]]) == 26\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0], [15, 0]]) == 15\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [-500000, -500000], [500000, 500000], [0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 5999999\n assert candidate(points = [[500000, 500000], [500001, 500001], [500002, 500002], [500003, 500003], [500004, 500004]]) == 8\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18]]) == 27\n assert candidate(points = [[0, 0], [1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36], [13, 39], [14, 42]]) == 56\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 18\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30], [15, 15], [25, 25]]) == 100\n assert candidate(points = [[-3, -3], [3, 3], [0, 0], [-1, 1], [1, -1], [-2, 2], [2, -2], [-3, 0], [3, 0], [0, -3], [0, 3], [-2, -1], [2, 1], [1, 2], [-1, -2], [-2, 1], [2, -1], [1, -2], [-1, 2]]) == 32\n assert candidate(points = [[-1, -1], [-2, -2], [1, 1], [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]]) == 36\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [2, 0], [1, 2], [2, 1], [2, 2], [0, 3], [3, 0], [1, 3], [3, 1], [2, 3], [3, 2], [3, 3]]) == 15\n assert candidate(points = [[0, 0], [1, 1], [0, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 19\n assert candidate(points = [[-500000, -500000], [-500001, -500001], [-500002, -500002], [-500003, -500003], [-500004, -500004]]) == 8\n assert candidate(points = [[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]]) == 38\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0], [15, 0], [16, 0], [17, 0], [18, 0], [19, 0]]) == 19\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000], [250000, 250000], [750000, 750000], [250000, 750000], [750000, 250000]]) == 4000000\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 19\n assert candidate(points = [[-100, -200], [-50, -50], [0, 0], [50, 50], [100, 200], [200, 400], [400, 800], [800, 1600], [1600, 3200], [3200, 6400]]) == 9900\n assert candidate(points = [[-1000000, -1000000], [-500000, -500000], [0, 0], [500000, 500000], [1000000, 1000000]]) == 4000000\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 4], [2, 1], [6, 9], [7, 8], [3, 5], [9, 2], [0, 3]]) == 26\n assert candidate(points = [[-500000, -500000], [500000, 500000], [-400000, -400000], [400000, 400000], [-300000, -300000], [300000, 300000], [-200000, -200000], [200000, 200000], [-100000, -100000], [100000, 100000]]) == 2000000\n assert candidate(points = [[500000, 500000], [100000, 100000], [900000, 900000], [200000, 200000], [800000, 800000], [300000, 300000], [700000, 700000], [400000, 400000], [600000, 600000], [550000, 550000]]) == 1600000\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 38\n assert candidate(points = [[3, 1], [1, 4], [1, 1], [1, 3], [2, 6], [3, 5], [6, 5], [4, 3], [7, 4], [4, 6], [5, 4], [5, 5], [6, 7], [8, 4], [2, 3]]) == 23\n assert candidate(points = [[-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5]]) == 20\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [5, 5], [3, 7], [8, 2], [2, 8], [7, 3], [4, 6], [6, 4]]) == 40\n assert candidate(points = [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [6, 6]]) == 40\n", "comparison": "exact"}, "public_tests": ["[[0,0],[2,2],[3,10],[5,2],[7,0]]", "[[3,12],[-2,5],[-4,1]]"], "hints": ["Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points.", "The problem is now the cost of minimum spanning tree in graph with above edges."], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minCostConnectPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:34+00:00", "tests_total": 104, "tests_dropped": 3, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "union-find", "graph", "minimum-spanning-tree", "prims-algorithm", "kruskals-algorithm", "boruvkas-algorithm"]}, "language": "python", "interface": {"raw_signature": "def minCostConnectPoints(self, points: list[list[int]]) -> int:", "container": "Solution", "callable": "minCostConnectPoints", "parameters": [{"name": "points", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1585, "task_id": "check-if-string-is-transformable-with-substring-sort-operations", "difficulty": "Hard", "problem_description": "Given two strings s and t, transform string s into string t using the following operation any number of times:\n\n- Choose a non-empty substring in s and sort it in place so the characters are in ascending order.\n - For example, applying the operation on the underlined substring in \"14234\" results in \"12344\".\n\nReturn true if it is possible to transform s into t. Otherwise, return false.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"84532\", t = \"34852\"\nOutput: true\nExplanation: You can transform s into t using the following sort operations:\n\"84532\" (from index 2 to 3) -> \"84352\"\n\"84352\" (from index 0 to 2) -> \"34852\"\n\nExample 2:\n\nInput: s = \"34521\", t = \"23415\"\nOutput: true\nExplanation: You can transform s into t using the following sort operations:\n\"34521\" -> \"23451\"\n\"23451\" -> \"23415\"\n\nExample 3:\n\nInput: s = \"12345\", t = \"12435\"\nOutput: false\n\nConstraints:\n\n- s.length == t.length\n- 1 <= s.length <= 10^5\n- s and t consist of only digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\",t = \"0123456789\") == True\n assert candidate(s = \"1221\",t = \"1122\") == True\n assert candidate(s = \"987654321\",t = \"123456789\") == True\n assert candidate(s = \"123\",t = \"321\") == False\n assert candidate(s = \"9876543210\",t = \"9876543211\") == False\n assert candidate(s = \"98765\",t = \"56789\") == True\n assert candidate(s = \"11111\",t = \"11111\") == True\n assert candidate(s = \"34521\",t = \"23415\") == True\n assert candidate(s = \"12345\",t = \"12435\") == False\n assert candidate(s = \"12\",t = \"21\") == False\n assert candidate(s = \"1\",t = \"1\") == True\n assert candidate(s = \"123\",t = \"132\") == False\n assert candidate(s = \"12345\",t = \"54321\") == False\n assert candidate(s = \"123456789\",t = \"123456789\") == True\n assert candidate(s = \"1234567890\",t = \"0987654321\") == False\n assert candidate(s = \"4321\",t = \"1234\") == True\n assert candidate(s = \"13579\",t = \"97531\") == False\n assert candidate(s = \"84532\",t = \"34852\") == True\n assert candidate(s = \"1221\",t = \"2112\") == False\n assert candidate(s = \"123123\",t = \"112233\") == True\n assert candidate(s = \"111222333\",t = \"333222111\") == False\n assert candidate(s = \"12345678909876543210\",t = \"12345678909876543210\") == True\n assert candidate(s = \"12345678909876543210\",t = \"09876543210123456789\") == False\n assert candidate(s = \"111122223333\",t = \"123123123123\") == False\n assert candidate(s = \"31415926535\",t = \"11233455569\") == True\n assert candidate(s = \"555544443333222211110000\",t = \"000011112222333344445555\") == True\n assert candidate(s = \"321123\",t = \"112233\") == True\n assert candidate(s = \"44443333222211110000\",t = \"00001111222233334444\") == True\n assert candidate(s = \"56321456\",t = \"12345566\") == True\n assert candidate(s = \"5432167890\",t = \"1234567890\") == True\n assert candidate(s = \"632541\",t = \"123456\") == True\n assert candidate(s = \"11111111112222222222\",t = \"22222222221111111111\") == False\n assert candidate(s = \"0000111122223333\",t = \"3333222211110000\") == False\n assert candidate(s = \"234234234\",t = \"222333444\") == True\n assert candidate(s = \"33322111\",t = \"11122333\") == True\n assert candidate(s = \"98765432100123456789\",t = \"01234567890987654321\") == False\n assert candidate(s = \"987654321098765432109876543210\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"98765432101234567890\",t = \"09876543210123456789\") == True\n assert candidate(s = \"123454321\",t = \"122113454\") == False\n assert candidate(s = \"1222222222\",t = \"2222222221\") == False\n assert candidate(s = \"9876543210\",t = \"1098765432\") == True\n assert candidate(s = \"122112211\",t = \"111222112\") == True\n assert candidate(s = \"123456789012345678901234567890\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"5432112345\",t = \"1122334455\") == True\n assert candidate(s = \"6677889900\",t = \"0011223344\") == False\n assert candidate(s = \"1234512345\",t = \"1122334455\") == True\n assert candidate(s = \"543216789\",t = \"123456789\") == True\n assert candidate(s = \"12345678909876543210\",t = \"01234567890123456789\") == True\n assert candidate(s = \"999888777666555444333222111000\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"99887766554433221100\",t = \"00112233445566778899\") == True\n assert candidate(s = \"98765432109876543210\",t = \"00112233445566778899\") == True\n assert candidate(s = \"333333333\",t = \"333333333\") == True\n assert candidate(s = \"1332211\",t = \"1112233\") == True\n assert candidate(s = \"567891234\",t = \"123456789\") == True\n assert candidate(s = \"12341234\",t = \"11223344\") == True\n assert candidate(s = \"35421\",t = \"12345\") == True\n assert candidate(s = \"5432109876\",t = \"0123456789\") == True\n assert candidate(s = \"54321\",t = \"12345\") == True\n assert candidate(s = \"534987621\",t = \"123456789\") == True\n assert candidate(s = \"111122223333\",t = \"333322221111\") == False\n assert candidate(s = \"11111111112222222222\",t = \"11111111112222222222\") == True\n assert candidate(s = \"98765432100987654321\",t = \"00112233445566778899\") == True\n assert candidate(s = \"5555555555\",t = \"5555555555\") == True\n assert candidate(s = \"65432123456\",t = \"12345623456\") == True\n assert candidate(s = \"111111111111\",t = \"111111111111\") == True\n assert candidate(s = \"98765432109876543210\",t = \"01234567890123456789\") == True\n assert candidate(s = \"9876543210\",t = \"1234567890\") == True\n assert candidate(s = \"432143214321\",t = \"111222333444\") == True\n assert candidate(s = \"10987654321\",t = \"12345678901\") == False\n assert candidate(s = \"5931246870\",t = \"0123456789\") == True\n assert candidate(s = \"111222333444555666777888999000\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"9999888877776666555544443333222211110000\",t = \"0000111122223333444455556666777788889999\") == True\n assert candidate(s = \"55554444333322221111\",t = \"11112222333344445555\") == True\n assert candidate(s = \"1011121314151617181920\",t = \"1011121314151617181920\") == True\n assert candidate(s = \"333222111\",t = \"111222333\") == True\n assert candidate(s = \"12345678900987654321\",t = \"01234567899876543210\") == False\n assert candidate(s = \"111222333\",t = \"312312312\") == False\n assert candidate(s = \"23232323232323232323\",t = \"22222222223333333333\") == True\n assert candidate(s = \"123321\",t = \"112233\") == True\n assert candidate(s = \"12345678901234567890\",t = \"09876543210987654321\") == False\n assert candidate(s = \"99999888887777766666555554444433333222221111100000\",t = \"00000111112222233333444445555566666777778888899999\") == True\n assert candidate(s = \"654321123456\",t = \"112233445566\") == True\n assert candidate(s = \"321321321\",t = \"111222333\") == True\n assert candidate(s = \"12345678900987654321\",t = \"00123456789123456789\") == True\n assert candidate(s = \"11111111111111111111\",t = \"11111111111111111111\") == True\n assert candidate(s = \"111222333\",t = \"123123123\") == False\n assert candidate(s = \"2121212121\",t = \"1212121212\") == True\n assert candidate(s = \"2222211111\",t = \"1111122222\") == True\n assert candidate(s = \"1111111111\",t = \"1111111111\") == True\n assert candidate(s = \"628491375\",t = \"123456789\") == True\n assert candidate(s = \"5317246\",t = \"1234567\") == True\n assert candidate(s = \"12345678901234567890\",t = \"01234567890123456789\") == True\n assert candidate(s = \"11223344556677889900\",t = \"00112233445566778899\") == True\n assert candidate(s = \"654321098765\",t = \"012345657896\") == True\n assert candidate(s = \"321456987\",t = \"123456789\") == True\n assert candidate(s = \"143425\",t = \"123445\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00112233445566778899\") == True\n assert candidate(s = \"12345678901234567890\",t = \"01020304050607080919\") == False\n assert candidate(s = \"321321321321321321\",t = \"111112222233333333\") == False\n assert candidate(s = \"12345678900123456789\",t = \"01234567891234567890\") == False\n assert candidate(s = \"12332121321321321\",t = \"11112222333323333\") == False\n assert candidate(s = \"312312312\",t = \"111222333\") == True\n assert candidate(s = \"5555555555555555555555\",t = \"5555555555555555555555\") == True\n assert candidate(s = \"9345728160\",t = \"0123456789\") == True\n assert candidate(s = \"43214321\",t = \"11223344\") == True\n assert candidate(s = \"1357924680\",t = \"0123456789\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00123456789876543210\") == False\n assert candidate(s = \"123123123\",t = \"111222333\") == True\n assert candidate(s = \"123123123\",t = \"312312312\") == False\n assert candidate(s = \"43211234\",t = \"11223344\") == True\n assert candidate(s = \"6543210987\",t = \"7890123456\") == False\n assert candidate(s = \"12345678901234567890\",t = \"00112233445566778899\") == True\n assert candidate(s = \"555444333222111000\",t = \"000111222333444555\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00123456789987654321\") == False\n assert candidate(s = \"55555555555555555555\",t = \"55555555555555555555\") == True\n assert candidate(s = \"11223344556677889900\",t = \"00998877665544332211\") == False\n assert candidate(s = \"1234567890987654321\",t = \"1234567890123456789\") == True\n assert candidate(s = \"6666666666\",t = \"6666666666\") == True\n assert candidate(s = \"333322211\",t = \"112223333\") == True\n assert candidate(s = \"4321111111234\",t = \"1111111234432\") == False\n assert candidate(s = \"53142\",t = \"12345\") == True\n", "comparison": "exact"}, "public_tests": ["\"84532\"\n\"34852\"", "\"34521\"\n\"23415\"", "\"12345\"\n\"12435\""], "hints": ["Suppose the first digit you need is 'd'. How can you determine if it's possible to get that digit there?", "Consider swapping adjacent characters to maintain relative ordering."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().isTransformable", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:37+00:00", "tests_total": 147, "tests_dropped": 26, "flags": [], "topic_tags": ["string", "greedy", "sorting"]}, "language": "python", "interface": {"raw_signature": "def isTransformable(self, s: str, t: str) -> bool:", "container": "Solution", "callable": "isTransformable", "parameters": [{"name": "s", "type": "str"}, {"name": "t", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1588, "task_id": "sum-of-all-odd-length-subarrays", "difficulty": "Easy", "problem_description": "Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr.\n\nA subarray is a contiguous subsequence of the array.\n\nExample 1:\n\nInput: arr = [1,4,2,5,3]\nOutput: 58\nExplanation: The odd-length subarrays of arr and their sums are:\n[1] = 1\n[4] = 4\n[2] = 2\n[5] = 5\n[3] = 3\n[1,4,2] = 7\n[4,2,5] = 11\n[2,5,3] = 10\n[1,4,2,5,3] = 15\nIf we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58\n\nExample 2:\n\nInput: arr = [1,2]\nOutput: 3\nExplanation: There are only 2 subarrays of odd length, [1] and [2]. Their sum is 3.\n\nExample 3:\n\nInput: arr = [10,11,12]\nOutput: 66\n\nConstraints:\n\n- 1 <= arr.length <= 100\n- 1 <= arr[i] <= 1000\n\nFollow up:\n\nCould you solve this problem in O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 8760\n assert candidate(arr = [2, 4, 6, 8, 10]) == 114\n assert candidate(arr = [1, 2]) == 3\n assert candidate(arr = [5]) == 5\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 614\n assert candidate(arr = [5, 5, 5, 5, 5]) == 95\n assert candidate(arr = [100, 200, 300, 400, 500]) == 5700\n assert candidate(arr = [10, 11, 12]) == 66\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 605\n assert candidate(arr = [100, 200, 300]) == 1200\n assert candidate(arr = [1, 2, 3, 4, 5]) == 57\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 425\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13]) == 308\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 425\n assert candidate(arr = [1, 4, 2, 5, 3]) == 58\n assert candidate(arr = [1, 3, 5, 7, 9]) == 95\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16]) == 540\n assert candidate(arr = [7, 1, 14, 11]) == 81\n assert candidate(arr = [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]) == 127803\n assert candidate(arr = [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]) == 281775\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]) == 281775\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 3003\n assert candidate(arr = [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, 104, 108, 112, 116, 120]) == 153760\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 15400\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2752\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]) == 19097\n assert candidate(arr = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == 109945\n assert candidate(arr = [23, 45, 12, 67, 89, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 311940\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 13760\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]) == 18711\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 27520\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8208\n assert candidate(arr = [250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 190970\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 15400\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, 59]) == 74400\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 64680\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == 13203\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]) == 38440\n assert candidate(arr = [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]) == 60792\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]) == 13860\n assert candidate(arr = [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]) == 422840\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]) == 7590\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]) == 9224\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 31648\n assert candidate(arr = [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]) == 110565\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 6050\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 3003\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123]) == 20384\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144]) == 43320\n assert candidate(arr = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 65000\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 93555\n assert candidate(arr = [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]) == 190970\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2752\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 80850\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]) == 2736\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]) == 36725\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 40425\n assert candidate(arr = [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]) == 95485\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 40425\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]) == 19097\n assert candidate(arr = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500]) == 381940\n assert candidate(arr = [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]) == 60792\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77]) == 101728\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 81250\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3850\n assert candidate(arr = [150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170]) == 142560\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154]) == 81466\n assert candidate(arr = [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]) == 57291\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129]) == 39560\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 24050\n assert candidate(arr = [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]) == 176610\n assert candidate(arr = [50, 25, 75, 100, 200, 150, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 438225\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 761915\n assert candidate(arr = [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]) == 133679\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, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 31570\n assert candidate(arr = [21, 34, 41, 53, 67, 71, 82, 95, 100, 121, 134, 141, 153, 167, 171, 182, 195]) == 52492\n assert candidate(arr = [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]) == 282436\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 4480\n assert candidate(arr = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 57040\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 51000\n assert candidate(arr = [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]) == 630201\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 70350\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]) == 117670\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8085\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60500\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 5848\n assert candidate(arr = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 12770\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 5500\n assert candidate(arr = [300, 200, 100, 50, 25, 12, 6, 3, 1]) == 5364\n assert candidate(arr = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109]) == 8614\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 14700\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270]) == 184960\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60500\n assert candidate(arr = [42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80]) == 46970\n", "comparison": "exact"}, "public_tests": ["[1,4,2,5,3]", "[1,2]", "[10,11,12]"], "hints": ["You can brute force – try every (i,j) pair, and if the length is odd, go through and add the sum to the answer."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sumOddLengthSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:39+00:00", "tests_total": 104, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "math", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def sumOddLengthSubarrays(self, arr: list[int]) -> int:", "container": "Solution", "callable": "sumOddLengthSubarrays", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1589, "task_id": "maximum-sum-obtained-of-any-permutation", "difficulty": "Medium", "problem_description": "We have an array of integers, nums, and an array of requests where requests[i] = [start_i, end_i]. The i^th request asks for the sum of nums[start_i] + nums[start_i + 1] + ... + nums[end_i - 1] + nums[end_i]. Both start_i and end_i are 0-indexed.\n\nReturn the maximum total sum of all requests among all permutations of nums.\n\nSince the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: nums = [1,2,3,4,5], requests = [[1,3],[0,1]]\nOutput: 19\nExplanation: One permutation of nums is [2,1,3,4,5] with the following result:\nrequests[0] -> nums[1] + nums[2] + nums[3] = 1 + 3 + 4 = 8\nrequests[1] -> nums[0] + nums[1] = 2 + 1 = 3\nTotal sum: 8 + 3 = 11.\nA permutation with a higher total sum is [3,5,4,2,1] with the following result:\nrequests[0] -> nums[1] + nums[2] + nums[3] = 5 + 4 + 2 = 11\nrequests[1] -> nums[0] + nums[1] = 3 + 5 = 8\nTotal sum: 11 + 8 = 19, which is the best that you can do.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,6], requests = [[0,1]]\nOutput: 11\nExplanation: A permutation with the max total sum is [6,5,4,3,2,1] with request sums [11].\n\nExample 3:\n\nInput: nums = [1,2,3,4,5,10], requests = [[0,2],[1,3],[1,1]]\nOutput: 47\nExplanation: A permutation with the max total sum is [4,10,5,3,2,1] with request sums [19,18,10].\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- 0 <= nums[i] <= 10^5\n- 1 <= requests.length <= 10^5\n- requests[i].length == 2\n- 0 <= start_i <= end_i < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 10],requests = [[0, 2], [1, 3], [1, 1]]) == 47\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 2], [2, 3], [3, 4]]) == 240\n assert candidate(nums = [0, 0, 0, 0, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(nums = [1, 2, 3],requests = [[0, 2], [0, 1], [1, 2]]) == 15\n assert candidate(nums = [5, 2, 4, 1, 3],requests = [[0, 4], [2, 3], [1, 2]]) == 32\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],requests = [[0, 2], [2, 4], [0, 4]]) == 1099980\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 4], [4, 8], [0, 9]]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5],requests = [[1, 3], [0, 1]]) == 19\n assert candidate(nums = [5, 2, 4, 1, 3],requests = [[0, 4], [1, 3], [0, 0], [3, 4]]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6],requests = [[0, 1]]) == 11\n assert candidate(nums = [5, 2, 4, 1],requests = [[0, 1], [1, 2], [2, 3]]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == 155\n assert candidate(nums = [100, 101, 102, 103, 104, 105],requests = [[0, 5], [1, 4], [2, 3]]) == 1238\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == 54\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 150\n assert candidate(nums = [8, 9, 7, 6, 5],requests = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 59\n assert candidate(nums = [5, 3, 7, 2, 1],requests = [[0, 2], [1, 4], [2, 3]]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 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, 20, 30, 40, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == 570\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 2050000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 8], [7, 8], [0, 8]]) == 206\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 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],requests = [[0, 19], [0, 9], [10, 19], [5, 14], [9, 14]]) == 680\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 4]]) == 3499885\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8], [0, 9]]) == 296\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],requests = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 5050000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 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],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 2860\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1025\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 0],requests = [[0, 9], [1, 5], [3, 7], [2, 8], [4, 6]]) == 175\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],requests = [[0, 3], [2, 5], [1, 4], [3, 7]]) == 95\n assert candidate(nums = [5, 3, 2, 1, 4],requests = [[0, 2], [1, 4], [0, 3], [2, 4]]) == 47\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 2050\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 19]]) == 799\n assert candidate(nums = [5, 3, 8, 1, 4, 7],requests = [[0, 5], [2, 4], [1, 3]]) == 67\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 26000\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],requests = [[0, 2], [1, 4], [0, 5], [2, 3]]) == 1499972\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 9], [0, 4], [5, 9], [2, 7]]) == 1550000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[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]]) == 627\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],requests = [[0, 19], [5, 15], [10, 10], [15, 15], [0, 9], [10, 19]]) == 6240\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],requests = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == 6520\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9]]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == 54\n assert candidate(nums = [2, 3, 1, 5, 4],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == 42\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [3, 6], [6, 9]]) == 275000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[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]]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 9], [0, 9], [0, 9], [0, 9]]) == 50\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 9], [1, 2], [3, 4], [5, 6], [7, 8], [0, 4], [5, 9]]) == 16200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 9], [0, 0], [9, 9], [2, 2], [5, 5], [1, 8], [3, 7]]) == 1650\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 4], [5, 9], [0, 5], [4, 9], [0, 9]]) == 1840000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],requests = [[0, 9], [10, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 8475\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],requests = [[0, 9], [1, 3], [2, 5], [4, 7], [0, 5], [3, 8]]) == 1533\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 430\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],requests = [[0, 4], [5, 9], [0, 9], [2, 7], [3, 8]]) == 398\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 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],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 2], [2, 4], [4, 6], [6, 8], [0, 9], [1, 8], [3, 7], [5, 5]]) == 1165\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],requests = [[0, 6], [1, 4], [2, 3], [0, 2], [4, 5]]) == 420\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1944425\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [5, 15], [3, 17], [7, 13]]) == 899\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],requests = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 3430\n assert candidate(nums = [9, 1, 5, 3, 7, 2, 8, 4, 6, 0],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 175\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 3], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 9]]) == 2510\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],requests = [[0, 4], [5, 9], [2, 6], [3, 7], [1, 5], [6, 10]]) == 3380\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],requests = [[0, 19], [0, 9], [10, 19], [5, 14], [9, 14], [0, 5], [5, 10], [10, 15]]) == 1828\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1300\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],requests = [[0, 10], [5, 15], [10, 20], [0, 20], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15], [6, 14]]) == 8216\n assert candidate(nums = [100, 200, 300, 400, 500],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4]]) == 3000\n assert candidate(nums = [5, 3, 7, 9, 1, 6, 4, 8, 2, 10],requests = [[0, 9], [2, 5], [3, 7], [1, 8], [0, 4], [5, 9]]) == 234\n assert candidate(nums = [50, 40, 30, 20, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4], [1, 3], [2, 4]]) == 530\n assert candidate(nums = [23, 17, 54, 32, 45, 67, 89, 101, 120, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34],requests = [[0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == 7390\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 179\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[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]]) == 417\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == 1135\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 4], [1, 3], [2, 2], [3, 9], [4, 8], [5, 7], [6, 6], [7, 9], [0, 9], [0, 0], [9, 9]]) == 23600\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 4], [1, 3], [2, 2], [0, 0], [4, 4], [3, 3]]) == 87\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 760\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 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],requests = [[0, 19], [0, 9], [10, 19], [0, 4], [5, 9], [10, 14], [15, 19]]) == 630\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],requests = [[0, 19], [0, 0], [19, 19], [5, 15], [10, 10]]) == 170\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 19], [0, 18], [0, 17], [0, 16], [0, 15], [0, 14], [0, 13], [0, 12], [0, 11], [0, 10]]) == 155\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],requests = [[0, 12], [2, 5], [6, 9], [1, 4], [7, 10]]) == 449\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 9], [10, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 3260\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 30\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [0, 5], [5, 9], [3, 7], [2, 8]]) == 221\n assert candidate(nums = [100, 200, 300, 400, 500],requests = [[0, 4], [1, 3], [2, 2], [0, 0], [4, 4]]) == 3500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],requests = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9350\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5]\n[[1,3],[0,1]]", "[1,2,3,4,5,6]\n[[0,1]]", "[1,2,3,4,5,10]\n[[0,2],[1,3],[1,1]]"], "hints": ["Indexes with higher frequencies should be bound with larger values"], "metadata": {"canonical_parameter_names": ["nums", "requests"], "leetcode_dataset_entry_point": "Solution().maxSumRangeQuery", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:41+00:00", "tests_total": 96, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "greedy", "sorting", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def maxSumRangeQuery(self, nums: list[int], requests: list[list[int]]) -> int:", "container": "Solution", "callable": "maxSumRangeQuery", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "requests", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1590, "task_id": "make-sum-divisible-by-p", "difficulty": "Medium", "problem_description": "Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array.\n\nReturn the length of the smallest subarray that you need to remove, or -1 if it's impossible.\n\nA subarray is defined as a contiguous block of elements in the array.\n\nExample 1:\n\nInput: nums = [3,1,4,2], p = 6\nOutput: 1\nExplanation: The sum of the elements in nums is 10, which is not divisible by 6. We can remove the subarray [4], and the sum of the remaining elements is 6, which is divisible by 6.\n\nExample 2:\n\nInput: nums = [6,3,5,2], p = 9\nOutput: 2\nExplanation: We cannot remove a single element to get a sum divisible by 9. The best way is to remove the subarray [5,2], leaving us with [6,3] with sum 9.\n\nExample 3:\n\nInput: nums = [1,2,3], p = 3\nOutput: 0\nExplanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^9\n- 1 <= p <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5],p = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],p = 2) == 1\n assert candidate(nums = [7, 8, 9, 10, 11],p = 11) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],p = 10) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 5) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],p = 11) == 1\n assert candidate(nums = [1000000000],p = 1000000000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 5) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 5) == 0\n assert candidate(nums = [7, 1, 3, 5, 2, 9],p = 10) == 1\n assert candidate(nums = [10, 11, 12],p = 6) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 3) == 1\n assert candidate(nums = [6, 3, 5, 2],p = 9) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],p = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 7) == 1\n assert candidate(nums = [1, 2, 3],p = 3) == 0\n assert candidate(nums = [1],p = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],p = 10) == 1\n assert candidate(nums = [3, 1, 4, 2],p = 6) == 1\n assert candidate(nums = [11, 13, 17, 19, 23, 29],p = 101) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],p = 13) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 13) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66],p = 11) == 0\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 3) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],p = 17) == 1\n assert candidate(nums = [45, 54, 63, 72, 81, 90, 99, 108, 117, 126],p = 13) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],p = 3) == 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],p = 3) == 1\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],p = 19) == 1\n assert candidate(nums = [8, 5, 6, 10, 8, 7, 3, 5, 8, 1, 2, 9, 4, 6, 5, 1, 3, 4, 7, 8],p = 5) == 0\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 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],p = 19) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],p = 1) == 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],p = 13) == 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],p = 101) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],p = 11) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],p = 7) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],p = 11) == 0\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],p = 26) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60],p = 25) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 27) == 1\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],p = 5) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],p = 17) == 1\n assert candidate(nums = [17, 23, 29, 31, 37, 41, 43, 47, 53, 59],p = 11) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 11) == 0\n assert candidate(nums = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103],p = 11) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],p = 11) == 1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],p = 11) == 1\n assert candidate(nums = [2, 6, 3, 8, 7, 1, 5, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],p = 17) == 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, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 7) == 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],p = 2) == 0\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444],p = 123456789) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],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, 1, 1, 1, 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) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],p = 100) == 5\n assert candidate(nums = [23, 32, 45, 65, 77, 88, 91, 103, 114, 125],p = 13) == 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],p = 19) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 = 2) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993],p = 7) == 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],p = 13) == 1\n assert candidate(nums = [314159, 271828, 161803, 334993, 986264, 338327, 795028, 841971, 693993, 751058],p = 1234567) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],p = 17) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],p = 7) == 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],p = 5) == 0\n assert candidate(nums = [61, 57, 59, 55, 53, 67, 71, 61, 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],p = 53) == 1\n", "comparison": "exact"}, "public_tests": ["[3,1,4,2]\n6", "[6,3,5,2]\n9", "[1,2,3]\n3"], "hints": ["Use prefix sums to calculate the subarray sums.", "Suppose you know the remainder for the sum of the entire array. How does removing a subarray affect that remainder? What remainder does the subarray need to have in order to make the rest of the array sum up to be divisible by k?", "Use a map to keep track of the rightmost index for every prefix sum % p."], "metadata": {"canonical_parameter_names": ["nums", "p"], "leetcode_dataset_entry_point": "Solution().minSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:44+00:00", "tests_total": 76, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "hash-table", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def minSubarray(self, nums: list[int], p: int) -> int:", "container": "Solution", "callable": "minSubarray", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "p", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1591, "task_id": "strange-printer-ii", "difficulty": "Hard", "problem_description": "There is a strange printer with the following two special requirements:\n\n- On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.\n- Once the printer has used a color for the above operation, the same color cannot be used again.\n\nYou are given a m x n matrix targetGrid, where targetGrid[row][col] is the color in the position (row, col) of the grid.\n\nReturn true if it is possible to print the matrix targetGrid, otherwise, return false.\n\nExample 1:\n\nInput: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]\nOutput: true\n\nExample 2:\n\nInput: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]\nOutput: true\n\nExample 3:\n\nInput: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]\nOutput: false\nExplanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.\n\nConstraints:\n\n- m == targetGrid.length\n- n == targetGrid[i].length\n- 1 <= m, n <= 60\n- 1 <= targetGrid[row][col] <= 60\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(targetGrid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1], [1, 1, 3, 3], [1, 1, 3, 4], [5, 5, 1, 4]]) == True\n assert candidate(targetGrid = [[1, 2, 1, 4], [2, 1, 4, 1], [1, 4, 1, 2], [4, 1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1], [1, 1], [2, 2], [2, 2]]) == True\n assert candidate(targetGrid = [[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]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3], [2, 3, 3, 4], [2, 3, 3, 4], [1, 2, 2, 3]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3, 4, 4], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 3], [1, 4, 1, 5, 2, 3], [1, 4, 6, 5, 2, 3], [1, 4, 6, 5, 2, 3], [1, 4, 1, 5, 2, 3], [1, 1, 1, 2, 2, 3]]) == True\n assert candidate(targetGrid = [[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]]) == False\n assert candidate(targetGrid = [[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]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [2, 1, 2, 3, 4, 5, 6], [3, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4], [5, 4, 3, 2, 1, 2, 3], [6, 5, 4, 3, 2, 1, 2], [7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [2, 1, 4, 5, 6, 3], [3, 4, 1, 6, 5, 2], [4, 5, 6, 1, 2, 3], [5, 6, 2, 3, 1, 4], [6, 3, 5, 4, 3, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [2, 1, 3, 4, 5, 6, 7], [3, 2, 1, 4, 5, 6, 7], [4, 3, 2, 1, 5, 6, 7], [5, 4, 3, 2, 1, 6, 7], [6, 5, 4, 3, 2, 1, 7], [7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 3, 1, 3, 3, 2], [1, 3, 1, 3, 3, 2], [1, 1, 1, 2, 2, 2], [1, 3, 3, 3, 3, 3], [1, 3, 3, 3, 3, 3]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [5, 1, 2, 3, 4], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [2, 3, 3, 3, 3, 2], [2, 3, 4, 4, 3, 2], [2, 3, 4, 4, 3, 2], [2, 3, 3, 3, 3, 2], [2, 2, 2, 2, 2, 2]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1, 1], [2, 3, 3, 2, 2], [2, 3, 3, 2, 2], [1, 2, 2, 1, 1], [5, 5, 5, 5, 5]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[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]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 2, 2, 2, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 2, 3, 3, 3, 3, 2, 2], [1, 2, 3, 4, 4, 3, 2, 2], [1, 2, 3, 4, 4, 3, 2, 2], [1, 2, 3, 3, 3, 3, 2, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2]]) == False\n assert candidate(targetGrid = [[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, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 1, 4, 5, 3], [3, 4, 1, 2, 5], [4, 5, 2, 3, 1], [5, 3, 1, 4, 2]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3], [2, 4, 4, 3], [2, 4, 4, 3], [1, 2, 2, 3]]) == False\n assert candidate(targetGrid = [[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]]) == True\n assert candidate(targetGrid = [[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]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3, 1], [1, 2, 2, 3, 1], [4, 5, 5, 6, 4], [4, 5, 5, 6, 4], [7, 8, 8, 9, 7]]) == True\n assert candidate(targetGrid = [[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], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]]) == True\n assert candidate(targetGrid = [[5, 5, 5, 5, 5], [5, 6, 6, 6, 5], [5, 6, 7, 6, 5], [5, 6, 6, 6, 5], [5, 5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [7, 1, 2, 3, 4, 5, 6], [6, 7, 1, 2, 3, 4, 5], [5, 6, 7, 1, 2, 3, 4], [4, 5, 6, 7, 1, 2, 3], [3, 4, 5, 6, 7, 1, 2], [2, 3, 4, 5, 6, 7, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [2, 1, 3, 3, 3, 2], [2, 1, 3, 4, 3, 2], [2, 1, 3, 3, 3, 2], [2, 2, 2, 2, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1], [2, 3, 3, 2], [2, 3, 3, 2], [1, 2, 2, 1], [1, 2, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == True\n assert candidate(targetGrid = [[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]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 1, 2, 3, 4], [3, 2, 1, 2, 3], [4, 3, 2, 1, 2], [5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [1, 1, 4, 4, 5, 5], [1, 1, 4, 4, 5, 5], [6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6]]) == True\n assert candidate(targetGrid = [[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]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [5, 5, 5, 6, 6, 6], [5, 5, 5, 6, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 1, 2, 2, 2, 3], [1, 4, 4, 4, 2, 3], [1, 4, 5, 4, 2, 3], [1, 4, 5, 4, 2, 3], [1, 1, 5, 5, 2, 3], [1, 1, 5, 5, 2, 3]]) == False\n assert candidate(targetGrid = [[5, 5, 5, 5, 5, 5], [5, 6, 6, 6, 6, 5], [5, 6, 7, 7, 6, 5], [5, 6, 7, 7, 6, 5], [5, 6, 6, 6, 6, 5], [5, 5, 5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1], [1, 1, 2, 2], [1, 2, 2, 1], [1, 1, 2, 2], [1, 2, 2, 1], [1, 1, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [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(targetGrid = [[1, 1, 1, 1, 1, 2, 2, 2], [1, 2, 2, 2, 1, 2, 2, 2], [1, 2, 3, 3, 1, 2, 2, 2], [1, 2, 3, 3, 1, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2], [4, 4, 4, 4, 4, 5, 5, 5], [4, 4, 6, 6, 4, 5, 5, 5], [4, 4, 6, 6, 4, 5, 5, 5]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1], [2, 3, 3, 2, 1], [2, 3, 3, 2, 1], [1, 2, 2, 1, 1], [1, 1, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1, 1], [2, 1, 1, 1, 1, 2], [2, 1, 3, 3, 1, 2], [2, 1, 3, 3, 1, 2], [2, 1, 1, 1, 1, 2], [1, 2, 2, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6], [4, 4, 5, 5, 6, 6], [7, 7, 8, 8, 9, 9], [7, 7, 8, 8, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[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, 2], [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]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 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(targetGrid = [[1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4]]) == True\n assert candidate(targetGrid = [[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], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4], [5, 5, 5, 6, 6], [5, 5, 5, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[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], [6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [1, 1, 3, 3, 3, 1], [1, 1, 3, 4, 3, 1], [1, 1, 3, 3, 3, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[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]]) == True\n assert candidate(targetGrid = [[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]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1, 2], [2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2], [1, 2, 2, 1, 1, 2], [1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2]]) == False\n", "comparison": "exact"}, "public_tests": ["[[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]", "[[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]", "[[1,2,1],[2,1,2],[1,2,1]]"], "hints": ["Try thinking in reverse. Given the grid, how can you tell if a colour was painted last?"], "metadata": {"canonical_parameter_names": ["targetGrid"], "leetcode_dataset_entry_point": "Solution().isPrintable", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:46+00:00", "tests_total": 65, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "graph", "topological-sort", "matrix", "directed-acyclic-graph"]}, "language": "python", "interface": {"raw_signature": "def isPrintable(self, targetGrid: list[list[int]]) -> bool:", "container": "Solution", "callable": "isPrintable", "parameters": [{"name": "targetGrid", "type": "list[list[int]]"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1592, "task_id": "rearrange-spaces-between-words", "difficulty": "Easy", "problem_description": "You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It's guaranteed that text contains at least one word.\n\nRearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all the spaces equally, place the extra spaces at the end, meaning the returned string should be the same length as text.\n\nReturn the string after rearranging the spaces.\n\nExample 1:\n\nInput: text = \" this is a sentence \"\nOutput: \"this is a sentence\"\nExplanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.\n\nExample 2:\n\nInput: text = \" practice makes perfect\"\nOutput: \"practice makes perfect \"\nExplanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.\n\nConstraints:\n\n- 1 <= text.length <= 100\n- text consists of lowercase English letters and ' '.\n- text contains at least one word.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \" leading and trailing spaces \") == \"leading and trailing spaces \"\n assert candidate(text = \"one\") == \"one\"\n assert candidate(text = \" a \") == \"a \"\n assert candidate(text = \"hello world\") == \"hello world\"\n assert candidate(text = \"example example example\") == \"example example example\"\n assert candidate(text = \"a b c d e\") == \"a b c d e\"\n assert candidate(text = \" this is a sentence \") == \"this is a sentence\"\n assert candidate(text = \"one two three\") == \"one two three\"\n assert candidate(text = \" multiple spaces here \") == \"multiple spaces here \"\n assert candidate(text = \"the quick brown fox\") == \"the quick brown fox \"\n assert candidate(text = \" a \") == \"a \"\n assert candidate(text = \"uneven spacing in text\") == \"uneven spacing in text \"\n assert candidate(text = \" hello world \") == \"hello world\"\n assert candidate(text = \" practice makes perfect\") == \"practice makes perfect \"\n assert candidate(text = \"two words\") == \"two words\"\n assert candidate(text = \"one two three four\") == \"one two three four\"\n assert candidate(text = \"a b\") == \"a b\"\n assert candidate(text = \" one two three four \") == \"one two three four \"\n assert candidate(text = \"a b\") == \"a b\"\n assert candidate(text = \" welcome to the jungle \") == \"welcome to the jungle \"\n assert candidate(text = \"a\") == \"a\"\n assert candidate(text = \"equal spaces\") == \"equal spaces\"\n assert candidate(text = \"a b c d e f g h i j\") == \"a b c d e f g h i j\"\n assert candidate(text = \"longerwordwithnospaces\") == \"longerwordwithnospaces\"\n assert candidate(text = \"word\") == \"word\"\n assert candidate(text = \"consecutive spaces should be handled\") == \"consecutive spaces should be handled\"\n assert candidate(text = \"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(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \" spaces before and after and in between \") == \"spaces before and after and in between \"\n assert candidate(text = \"equal spaces should be here\") == \"equal spaces should be here\"\n assert candidate(text = \" spaces before and after and in between \") == \"spaces before and after and in between \"\n assert candidate(text = \"spaces at the beginning and end of the sentence\") == \"spaces at the beginning and end of the sentence \"\n assert candidate(text = \" uneven spaces distribution is tricky \") == \"uneven spaces distribution is tricky \"\n assert candidate(text = \" a\") == \"a \"\n assert candidate(text = \"onewordwith trailing\") == \"onewordwith trailing\"\n assert candidate(text = \" uneven spacing everywhere \") == \"uneven spacing everywhere\"\n assert candidate(text = \"evenly distributed spaces are good for readability\") == \"evenly distributed spaces are good for readability\"\n assert candidate(text = \"one verylongwordthatwillnotgetsplit\") == \"one verylongwordthatwillnotgetsplit\"\n assert candidate(text = \"a b c d e\") == \"a b c d e \"\n assert candidate(text = \" equal spacing here \") == \"equal spacing here\"\n assert candidate(text = \"short longword verylongwordwithnospaces\") == \"short longword verylongwordwithnospaces\"\n assert candidate(text = \"a long sentence with more words to test the functionality\") == \"a long sentence with more words to test the functionality\"\n assert candidate(text = \"one two three four\") == \"one two three four\"\n assert candidate(text = \" singlewordwithmanyspacesbeforeandafterspaces \") == \"singlewordwithmanyspacesbeforeandafterspaces \"\n assert candidate(text = \"one two three four five six seven eight nine ten\") == \"one two three four five six seven eight nine ten\"\n assert candidate(text = \"tiny gaps\") == \"tiny gaps\"\n assert candidate(text = \" one two three four five six seven eight nine ten \") == \"one two three four five six seven eight nine ten \"\n assert candidate(text = \"averylongwordwithnospaces\") == \"averylongwordwithnospaces\"\n assert candidate(text = \"unequal spaces should be here with extra\") == \"unequal spaces should be here with extra\"\n assert candidate(text = \" spacesbeforeand spacesafter \") == \"spacesbeforeand spacesafter\"\n assert candidate(text = \"averylongwordandanotherlongwordandafewmorewords\") == \"averylongwordandanotherlongwordandafewmorewords\"\n assert candidate(text = \"this is a test with multiple spaces\") == \"this is a test with multiple spaces \"\n assert candidate(text = \" one two three four five six seven eight nine ten \") == \"one two three four five six seven eight nine ten \"\n assert candidate(text = \"leading oneword\") == \"leading oneword\"\n assert candidate(text = \"many spaces in the middle\") == \"many spaces in the middle \"\n assert candidate(text = \" singleword \") == \"singleword \"\n assert candidate(text = \"equal spaces between each\") == \"equal spaces between each\"\n assert candidate(text = \"testcase with varied spacing\") == \"testcase with varied spacing\"\n assert candidate(text = \" uneven spacing in this sentence \") == \"uneven spacing in this sentence \"\n assert candidate(text = \" verylongwordwithnospaces \") == \"verylongwordwithnospaces \"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"equal equal equal equal\") == \"equal equal equal equal\"\n assert candidate(text = \"a very long sentence with multiple spaces between words to test the algorithm\") == \"a very long sentence with multiple spaces between words to test the algorithm \"\n assert candidate(text = \"onetwothreefourfivesixseveneightnineten\") == \"onetwothreefourfivesixseveneightnineten\"\n assert candidate(text = \"words with uneven spaces\") == \"words with uneven spaces \"\n assert candidate(text = \" many spaces around each word \") == \"many spaces around each word \"\n assert candidate(text = \"spaces at the beginning and the end \") == \"spaces at the beginning and the end \"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \" onewordwithspacesonbothends\") == \"onewordwithspacesonbothends \"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \"uneven spacing between words\") == \"uneven spacing between words \"\n assert candidate(text = \"spaces at the beginning and end spaces\") == \"spaces at the beginning and end spaces\"\n assert candidate(text = \" a b c d e f g \") == \"a b c d e f g \"\n assert candidate(text = \"lastwordwithaspaceattheend \") == \"lastwordwithaspaceattheend \"\n assert candidate(text = \"equal spacing between words\") == \"equal spacing between words\"\n assert candidate(text = \" spaces at the start and end \") == \"spaces at the start and end\"\n assert candidate(text = \"short words in here\") == \"short words in here\"\n assert candidate(text = \"shortwords\") == \"shortwords\"\n assert candidate(text = \"equal spaces should be here\") == \"equal spaces should be here \"\n assert candidate(text = \"a b c d e f g\") == \"a b c d e f g\"\n assert candidate(text = \"one twothree four five six seven\") == \"one twothree four five six seven\"\n assert candidate(text = \" onebigwordwith manyspaces and a few words\") == \"onebigwordwith manyspaces and a few words \"\n assert candidate(text = \"averylongword withaverylongword\") == \"averylongword withaverylongword\"\n assert candidate(text = \"no extra spaces\") == \"no extra spaces\"\n assert candidate(text = \" spacesatthestart\") == \"spacesatthestart \"\n assert candidate(text = \"spacesattheend \") == \"spacesattheend \"\n assert candidate(text = \"many many many spaces\") == \"many many many spaces\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"onlyone\") == \"onlyone\"\n assert candidate(text = \"a a a a a a\") == \"a a a a a a\"\n assert candidate(text = \" extra spaces should go to the end\") == \"extra spaces should go to the end \"\n assert candidate(text = \" a b c d \") == \"a b c d \"\n assert candidate(text = \" singlewordwithmanyspaces\") == \"singlewordwithmanyspaces \"\n assert candidate(text = \"averylongword with spaces\") == \"averylongword with spaces \"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \"uneven spacing is tricky\") == \"uneven spacing is tricky\"\n assert candidate(text = \" singleword \") == \"singleword \"\n assert candidate(text = \"beginning spaces are here\") == \"beginning spaces are here\"\n assert candidate(text = \"justoneverylongwordwithoutspaces\") == \"justoneverylongwordwithoutspaces\"\n assert candidate(text = \" a b c d e f g h i j \") == \"a b c d e f g h i j \"\n assert candidate(text = \" one two three four \") == \"one two three four\"\n assert candidate(text = \"only one space\") == \"only one space\"\n assert candidate(text = \"longwordssubstitutingforspaceswhicharespacious\") == \"longwordssubstitutingforspaceswhicharespacious\"\n assert candidate(text = \"verylongwordwithoutspaces\") == \"verylongwordwithoutspaces\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words \"\n assert candidate(text = \"singleword\") == \"singleword\"\n assert candidate(text = \"onewordwithspacesonbothends \") == \"onewordwithspacesonbothends \"\n assert candidate(text = \"uneven spaces at the end\") == \"uneven spaces at the end \"\n assert candidate(text = \"shorttext\") == \"shorttext\"\n assert candidate(text = \" firstwordwithaspaceatthebeginning\") == \"firstwordwithaspaceatthebeginning \"\n assert candidate(text = \"singlewordwithmanyspaces \") == \"singlewordwithmanyspaces \"\n assert candidate(text = \"short words\") == \"short words\"\n assert candidate(text = \"just one word in here\") == \"just one word in here\"\n assert candidate(text = \"verylongwordwithnospaces\") == \"verylongwordwithnospaces\"\n assert candidate(text = \"thisisaverylongword\") == \"thisisaverylongword\"\n assert candidate(text = \"just one word but many spaces\") == \"just one word but many spaces \"\n assert candidate(text = \"a \") == \"a \"\n assert candidate(text = \" spaces at the beginning and the end \") == \"spaces at the beginning and the end \"\n assert candidate(text = \" spaces at the end of the sentence \") == \"spaces at the end of the sentence \"\n assert candidate(text = \"a single word surrounded by spaces\") == \"a single word surrounded by spaces\"\n assert candidate(text = \" \") == \"\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \" word with multiple spaces in between words \") == \"word with multiple spaces in between words \"\n assert candidate(text = \" justone \") == \"justone \"\n assert candidate(text = \"short longword evenlongerword\") == \"short longword evenlongerword\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"just one more test case\") == \"just one more test case\"\n assert candidate(text = \"a b c d e f g\") == \"a b c d e f g \"\n assert candidate(text = \"many many many many many\") == \"many many many many many\"\n assert candidate(text = \"many spaces at the end \") == \"many spaces at the end\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words \"\n", "comparison": "exact"}, "public_tests": ["\" this is a sentence \"", "\" practice makes perfect\""], "hints": ["Count the total number of spaces and words. Then use the integer division to determine the numbers of spaces to add between each word and at the end."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().reorderSpaces", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:48+00:00", "tests_total": 135, "tests_dropped": 3, "flags": [], "topic_tags": ["string"]}, "language": "python", "interface": {"raw_signature": "def reorderSpaces(self, text: str) -> str:", "container": "Solution", "callable": "reorderSpaces", "parameters": [{"name": "text", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1593, "task_id": "split-a-string-into-the-max-number-of-unique-substrings", "difficulty": "Medium", "problem_description": "Given a string s, return the maximum number of unique substrings that the given string can be split into.\n\nYou can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are unique.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"ababccc\"\nOutput: 5\nExplanation: One way to split maximally is ['a', 'b', 'ab', 'c', 'cc']. Splitting like ['a', 'b', 'a', 'b', 'c', 'cc'] is not valid as you have 'a' and 'b' multiple times.\n\nExample 2:\n\nInput: s = \"aba\"\nOutput: 2\nExplanation: One way to split maximally is ['a', 'ba'].\n\nExample 3:\n\nInput: s = \"aa\"\nOutput: 1\nExplanation: It is impossible to split the string any further.\n\nConstraints:\n\n-\n1 <= s.length <= 16\n-\ns contains only lower case English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaabbbb\") == 5\n assert candidate(s = \"abac\") == 3\n assert candidate(s = \"abcdef\") == 6\n assert candidate(s = \"aaaaaaaab\") == 4\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"zzzzzzz\") == 3\n assert candidate(s = \"abcabcabc\") == 6\n assert candidate(s = \"abcabcabcabc\") == 7\n assert candidate(s = \"ababccc\") == 5\n assert candidate(s = \"zzzzzzzzzzzzzzzz\") == 5\n assert candidate(s = \"aa\") == 1\n assert candidate(s = \"abcabc\") == 4\n assert candidate(s = \"abcdabcd\") == 6\n assert candidate(s = \"xyzxyzxyz\") == 6\n assert candidate(s = \"noon\") == 3\n assert candidate(s = \"abacabad\") == 5\n assert candidate(s = \"banana\") == 4\n assert candidate(s = \"aba\") == 2\n assert candidate(s = \"zzzzzz\") == 3\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"zabac\") == 4\n assert candidate(s = \"abcdabcdabcdabcd\") == 9\n assert candidate(s = \"abacaba\") == 4\n assert candidate(s = \"aabbccdd\") == 6\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"xyxyxyxyxyxyxyxy\") == 7\n assert candidate(s = \"ababcabcabc\") == 7\n assert candidate(s = \"abacabacabacabac\") == 8\n assert candidate(s = \"xyzzyxzyxzy\") == 7\n assert candidate(s = \"hellohellohello\") == 9\n assert candidate(s = \"abacabadabacabad\") == 9\n assert candidate(s = \"repaid\") == 6\n assert candidate(s = \"abccbaabccba\") == 7\n assert candidate(s = \"redder\") == 4\n assert candidate(s = \"aabaaaabbaabaaab\") == 7\n assert candidate(s = \"optimization\") == 10\n assert candidate(s = \"aaaaaaaaaaaaaaa\") == 5\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcdabcde\") == 7\n assert candidate(s = \"abababababababab\") == 7\n assert candidate(s = \"ababababababab\") == 6\n assert candidate(s = \"abababababab\") == 6\n assert candidate(s = \"abcdefghijklmnop\") == 16\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"aabbaabbccddeeff\") == 11\n assert candidate(s = \"abacabadabacaba\") == 8\n assert candidate(s = \"abcdabcdaabbcc\") == 9\n assert candidate(s = \"abcdefgabcdefg\") == 10\n assert candidate(s = \"aabbaabbccdd\") == 8\n assert candidate(s = \"aabbccddeeffgg\") == 10\n assert candidate(s = \"detartrated\") == 8\n assert candidate(s = \"abcdefghij\") == 10\n assert candidate(s = \"aaaabbbbccccdddd\") == 10\n assert candidate(s = \"aabacabadaba\") == 7\n assert candidate(s = \"deified\") == 5\n assert candidate(s = \"noonnoonnoon\") == 6\n assert candidate(s = \"repaper\") == 5\n assert candidate(s = \"abbaabbaabba\") == 6\n assert candidate(s = \"bcbcbcbcbcbcbcbc\") == 7\n assert candidate(s = \"aaaaaaaaaaaaaaaa\") == 5\n assert candidate(s = \"abacdfgdcaba\") == 8\n assert candidate(s = \"abcdeabcdeabcde\") == 10\n assert candidate(s = \"abcdabcabcda\") == 8\n assert candidate(s = \"ababababab\") == 5\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"reviled\") == 6\n assert candidate(s = \"abcdefghabcdefgh\") == 12\n assert candidate(s = \"aabbccddeeffgghh\") == 12\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"abcabcabcaabbcc\") == 9\n assert candidate(s = \"abcabcabcabcabc\") == 8\n", "comparison": "exact"}, "public_tests": ["\"ababccc\"", "\"aba\"", "\"aa\""], "hints": ["Use a set to keep track of which substrings have been used already", "Try each possible substring at every position and backtrack if a complete split is not possible"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxUniqueSplit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:51+00:00", "tests_total": 102, "tests_dropped": 30, "flags": [], "topic_tags": ["hash-table", "string", "backtracking"]}, "language": "python", "interface": {"raw_signature": "def maxUniqueSplit(self, s: str) -> int:", "container": "Solution", "callable": "maxUniqueSplit", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1594, "task_id": "maximum-non-negative-product-in-a-matrix", "difficulty": "Medium", "problem_description": "You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.\n\nAmong all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.\n\nReturn the maximum non-negative product modulo 10^9 + 7. If the maximum product is negative, return -1.\n\nNotice that the modulo is performed after getting the maximum product.\n\nExample 1:\n\nInput: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]\nOutput: -1\nExplanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.\n\nExample 2:\n\nInput: grid = [[1,-2,1],[1,-2,1],[3,-4,1]]\nOutput: 8\nExplanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).\n\nExample 3:\n\nInput: grid = [[1,3],[0,-4]]\nOutput: 0\nExplanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 15\n- -4 <= grid[i][j] <= 4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -2, -3], [-2, -3, -3], [-3, -3, -2]]) == -1\n assert candidate(grid = [[-1, 0], [-2, -1]]) == 0\n assert candidate(grid = [[-4, 3], [-3, -4]]) == 48\n assert candidate(grid = [[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]]) == 1\n assert candidate(grid = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == -1\n assert candidate(grid = [[-1, 2], [-3, 4]]) == 12\n assert candidate(grid = [[1, -2, 1], [1, -2, 1], [3, -4, 1]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1], [1, 1]]) == 1\n assert candidate(grid = [[-1, 0], [-2, -3]]) == 0\n assert candidate(grid = [[1, 2], [3, 4]]) == 12\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 3], [0, -4]]) == 0\n assert candidate(grid = [[-4, -4], [-4, -4]]) == -1\n assert candidate(grid = [[-1, 0, 1], [0, 0, 0], [1, 0, -1]]) == 0\n assert candidate(grid = [[-1, 0, 0, 0], [-1, 0, 0, 0], [-1, 0, 0, 0], [-1, 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\n assert candidate(grid = [[-4, 3, -2, 1], [2, -1, 3, -4], [3, -4, 2, 1], [4, 1, -3, 2]]) == 576\n assert candidate(grid = [[-3, 3, -4, 1], [2, -1, 2, -3], [-2, 3, -2, 1], [4, -4, 3, -3]]) == 1728\n assert candidate(grid = [[-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], [-1, 1, 0, 1, -1], [0, -1, 1, -1, 0], [1, -1, 0, 1, -1], [-1, 0, 1, 0, -1]]) == 1\n assert candidate(grid = [[2, -2, 3, -3], [-3, 3, -2, 2], [2, -2, 3, -3], [-3, 3, -2, 2]]) == -1\n assert candidate(grid = [[-1, 3, -4, 2], [-2, 1, -1, 0], [3, -3, 2, -3], [4, 0, -1, 2]]) == 216\n assert candidate(grid = [[-1, 0, 0, 0], [-2, 0, 0, 0], [-3, 0, 0, 0], [-4, 0, 0, 0]]) == 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, 1]]) == 0\n assert candidate(grid = [[-3, -2, 1], [-2, -1, 3], [-1, 3, -2]]) == 36\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, -1], [1, 0, -1, -2]]) == 0\n assert candidate(grid = [[-2, 0, 2, 0], [-1, -2, -3, -1], [0, 1, 0, 1], [2, -2, 1, -3]]) == 36\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\n assert candidate(grid = [[-4, 3, 2, -1, 0], [0, 2, -3, 1, 4], [-1, 2, -1, 3, -2], [3, -2, 1, -1, 2], [1, -3, 2, -2, -4]]) == 4608\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, -1], [1, 0, -1, -2]]) == 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\n assert candidate(grid = [[1, -2, 3, -4], [4, -1, 2, -3], [3, 2, -1, 4]]) == 144\n assert candidate(grid = [[4, -1, 2], [1, 2, -1], [2, -1, 4], [-1, 4, -1]]) == 32\n assert candidate(grid = [[1, -1, 0], [1, 0, 1], [0, 1, 1]]) == 0\n assert candidate(grid = [[0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, 0, -1], [0, -1, 0], [-1, 0, -1]]) == 0\n assert candidate(grid = [[0, 0, 1], [0, -1, 0], [-1, 0, 0]]) == 0\n assert candidate(grid = [[-1, 0, 0, -1], [0, -1, 0, -1], [0, 0, -1, 0], [-1, 0, 0, -1]]) == 0\n assert candidate(grid = [[-1, 2, -1, 3], [2, -3, 4, -2], [3, -1, -2, 2], [1, -3, 2, -1]]) == 96\n assert candidate(grid = [[0, 3, 0, 4], [0, 0, 0, 0], [0, 4, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, -1, 0, 2], [-1, 2, 3, -1], [0, 1, -1, 1], [2, -2, 1, -3]]) == 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]]) == 1\n assert candidate(grid = [[-4, -3, -2, -1], [-3, -2, -1, 0], [-2, -1, 0, 1], [-1, 0, 1, 2]]) == 0\n assert candidate(grid = [[-2, -3, 1, -4], [-3, -2, 1, 3], [-1, 2, -3, 1]]) == 72\n assert candidate(grid = [[4, -1, -2, 3], [-1, 2, 1, -1], [-2, -1, 3, 4], [1, -3, 2, 1]]) == 96\n assert candidate(grid = [[4, -4, 3, -3], [-3, 3, -2, 2], [2, -2, 3, -3], [-3, 3, -2, 2]]) == -1\n assert candidate(grid = [[0, -1, 1], [1, -1, 0], [-1, 0, 1]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4], [-4, 1, -2, 3], [2, -1, 4, -3], [3, 4, -1, 2]]) == 288\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[4, -1, 2], [2, -3, 4], [-1, 2, -3]]) == 288\n assert candidate(grid = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]]) == 36\n assert candidate(grid = [[-1, 0, 1], [0, 1, 0], [1, 0, -1]]) == 0\n assert candidate(grid = [[-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4]]) == -1\n assert candidate(grid = [[1, -1, 2, -4], [-2, 3, -1, 2], [4, -2, 3, -1], [-2, 1, -3, 4]]) == -1\n assert candidate(grid = [[2, -2, 3, 4, -1], [-1, 3, 2, 1, -2], [1, 2, -3, 2, -1], [3, 1, -2, -1, 2], [1, -2, 2, 1, -3]]) == 864\n assert candidate(grid = [[2, 3, 4], [1, 0, 1], [4, 3, 2], [3, 2, 1]]) == 48\n assert candidate(grid = [[-1, 3, -1, -4, 1], [-2, 1, 2, 3, -1], [3, -2, -1, 1, 2], [1, 2, -3, 4, -2]]) == 288\n assert candidate(grid = [[-1, 2, -1, 3], [1, -2, 1, -1], [2, 1, -1, -3], [1, -1, -2, 1]]) == 18\n assert candidate(grid = [[0, -1, -2, -3], [-1, 0, -1, -2], [-2, -1, 0, -1], [-3, -2, -1, 0]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]", "[[1,-2,1],[1,-2,1],[3,-4,1]]", "[[1,3],[0,-4]]"], "hints": ["Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxProductPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:53+00:00", "tests_total": 111, "tests_dropped": 49, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "python", "interface": {"raw_signature": "def maxProductPath(self, grid: list[list[int]]) -> int:", "container": "Solution", "callable": "maxProductPath", "parameters": [{"name": "grid", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1598, "task_id": "crawler-log-folder", "difficulty": "Easy", "problem_description": "The Leetcode file system keeps a log each time some user performs a change folder operation.\n\nThe operations are described below:\n\n- \"../\" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).\n- \"./\" : Remain in the same folder.\n- \"x/\" : Move to the child folder named x (This folder is guaranteed to always exist).\n\nYou are given a list of strings logs where logs[i] is the operation performed by the user at the i^th step.\n\nThe file system starts in the main folder, then the operations in logs are performed.\n\nReturn the minimum number of operations needed to go back to the main folder after the change folder operations.\n\nExample 1:\n\nInput: logs = [\"d1/\",\"d2/\",\"../\",\"d21/\",\"./\"]\nOutput: 2\nExplanation: Use this change folder operation \"../\" 2 times and go back to the main folder.\n\nExample 2:\n\nInput: logs = [\"d1/\",\"d2/\",\"./\",\"d3/\",\"../\",\"d31/\"]\nOutput: 3\n\nExample 3:\n\nInput: logs = [\"d1/\",\"../\",\"../\",\"../\"]\nOutput: 0\n\nConstraints:\n\n- 1 <= logs.length <= 10^3\n- 2 <= logs[i].length <= 10\n- logs[i] contains lowercase English letters, digits, '.', and '/'.\n- logs[i] follows the format described in the statement.\n- Folder names consist of lowercase English letters and digits.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = ['d1/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd21/', './']) == 2\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../', 'd5/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../', '../', '../', '../', 'd5/']) == 1\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../../..']) == 4\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/']) == 1\n assert candidate(logs = ['./', './', 'd1/']) == 1\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', './', 'd3/', '../', 'd31/']) == 3\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd3/', 'd4/']) == 3\n assert candidate(logs = ['./', './', './']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['../', '../', 'd1/']) == 1\n assert candidate(logs = ['./', './', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', './', './', 'd3/', 'd4/', 'd5/', '../', '../', '../', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['x1/', 'x2/', 'x3/', '../../', 'y1/', 'y2/', 'y3/', '../', 'z1/', 'z2/', '../', '../', '../']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../../', '../', '../../', '../', '../../', '../', '../../', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', './', '../', '../', '../', 'd6/', 'd7/', 'd8/', './', './', './', '../', '../', '../', 'd9/', 'd10/', 'd11/', './', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', '../', '../', 'd5/', '../', '../', 'd6/', '../', 'd7/', './', './', 'd8/', '../', '../', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['deep1/', 'deep2/', 'deep3/', 'deep4/', 'deep5/', 'deep6/', 'deep7/', 'deep8/', 'deep9/', 'deep10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', '../', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', '../', '../', '../', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', './', './', 'd1/', '../', 'd2/', '../', '../', 'd3/', '../', '../', 'd4/', '../', '../', 'd5/', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', './', './', './', '../', '../', '../', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', 'd5/', './', '../', 'd6/', 'd7/', './', '../', 'd8/', 'd9/', './', '../', 'd10/', 'd11/', './', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', 'd6/', '../', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', 'd10/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', './', '../', '../', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', './', './', './', '../', 'd3/', 'd4/', '../', '../', '../', '../', '../', './', './', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', './', 'd3/', 'd4/', '../', '../', 'd5/', 'd6/', '../', '../', '../', 'd7/']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', 'd8/']) == 2\n assert candidate(logs = ['folder1/', 'folder2/', '../', 'folder3/', 'folder4/', 'folder5/', 'folder6/', '../../', 'folder7/', 'folder8/', '../', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd21/', '../', 'd211/', '../', '../', 'd2111/', '../', '../', '../', '../', 'd21111/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', 'd4/', 'd5/', '../', '../', 'd6/', 'd7/', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', 'd4/', 'd5/', '../', '../', 'd6/', 'd7/', '../', '../', '../', 'd8/', 'd9/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', './', 'd2/', 'd3/', '../', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../', 'd8/', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', '../', 'd5/', '../', 'd6/', './', '../', 'd7/', '../', '../', 'd8/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../../', '../../', '../', '../', '../', '../', '../']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['a/', 'b/', '../', 'c/', './', 'd/', '../', 'e/', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', '../', '../', '../', 'd4/', 'd5/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../']) == 10\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', './', 'd2/', '../', 'd3/', './', 'd4/', '../', 'd5/', './', 'd6/', '../', 'd7/', './', 'd8/', '../', 'd9/', './', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', '../', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../']) == 0\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../', 'd5/', '../', 'd6/', '../', 'd7/', '../', 'd8/', '../', 'd9/', '../', 'd10/', '../', 'd11/', '../', 'd12/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../../', './', '../../', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', './', 'd6/', '../', 'd7/', 'd8/', 'd9/', 'd10/', './', './', '../', '../', '../', 'd11/', 'd12/', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', '../', 'd6/', 'd7/', '../', 'd8/', '../', 'd9/', 'd10/', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', '../', './', 'd1/', 'd2/', '../', './', 'd21/', '../', './', 'd211/', '../', './', 'd2111/', '../', './', 'd21111/', '../', './', '../', './']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', '../', '../', '../', '../', 'd7/', 'd8/', 'd9/']) == 4\n assert candidate(logs = ['d1/', 'd2/', '../', '../', './', 'd3/', 'd4/', '../', 'd5/', 'd6/', '../', 'd7/', './', '../', '../', '../', 'd8/']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', './', './', '../', '../', '../', '../', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', './', './', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', './', 'd4/', 'd5/', '../', '../', 'd6/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n", "comparison": "exact"}, "public_tests": ["[\"d1/\",\"d2/\",\"../\",\"d21/\",\"./\"]", "[\"d1/\",\"d2/\",\"./\",\"d3/\",\"../\",\"d31/\"]", "[\"d1/\",\"../\",\"../\",\"../\"]"], "hints": ["Simulate the process but don’t move the pointer beyond the main folder."], "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:24:57+00:00", "tests_total": 87, "tests_dropped": 5, "flags": ["has_images"], "topic_tags": ["array", "string", "stack"]}, "language": "python", "interface": {"raw_signature": "def minOperations(self, logs: list[str]) -> int:", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "logs", "type": "list[str]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1599, "task_id": "maximum-profit-of-operating-a-centennial-wheel", "difficulty": "Medium", "problem_description": "You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars.\n\nYou are given an array customers of length n where customers[i] is the number of new customers arriving just before the i^th rotation (0-indexed). This means you must rotate the wheel i times before the customers[i] customers arrive. You cannot make customers wait if there is room in the gondola. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again.\n\nYou can stop the wheel at any time, including before serving all customers. If you decide to stop serving customers, all subsequent rotations are free in order to get all the customers down safely. Note that if there are currently more than four customers waiting at the wheel, only four will board the gondola, and the rest will wait for the next rotation.\n\nReturn the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.\n\nExample 1:\n\nInput: customers = [8,3], boardingCost = 5, runningCost = 6\nOutput: 3\nExplanation: The numbers written on the gondolas are the number of people currently there.\n1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.\n2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.\n3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.\nThe highest profit was $37 after rotating the wheel 3 times.\n\nExample 2:\n\nInput: customers = [10,9,6], boardingCost = 6, runningCost = 4\nOutput: 7\nExplanation:\n1. 10 customers arrive, 4 board and 6 wait for the next gondola, the wheel rotates. Current profit is 4 * $6 - 1 * $4 = $20.\n2. 9 customers arrive, 4 board and 11 wait (2 originally waiting, 9 newly waiting), the wheel rotates. Current profit is 8 * $6 - 2 * $4 = $40.\n3. The final 6 customers arrive, 4 board and 13 wait, the wheel rotates. Current profit is 12 * $6 - 3 * $4 = $60.\n4. 4 board and 9 wait, the wheel rotates. Current profit is 16 * $6 - 4 * $4 = $80.\n5. 4 board and 5 wait, the wheel rotates. Current profit is 20 * $6 - 5 * $4 = $100.\n6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120.\n7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122.\nThe highest profit was $122 after rotating the wheel 7 times.\n\nExample 3:\n\nInput: customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92\nOutput: -1\nExplanation:\n1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * $1 - 1 * $92 = -$89.\n2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 2 * $92 = -$177.\n3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 3 * $92 = -$269.\n4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 11 * $1 - 4 * $92 = -$357.\n5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * $1 - 5 * $92 = -$447.\nThe profit was never positive, so return -1.\n\nConstraints:\n\n- n == customers.length\n- 1 <= n <= 10^5\n- 0 <= customers[i] <= 50\n- 1 <= boardingCost, runningCost <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 100,runningCost = 1) == 63\n assert candidate(customers = [5, 5, 0, 8, 2],boardingCost = 6,runningCost = 3) == 6\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 1,runningCost = 1) == -1\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 1,runningCost = 2) == -1\n assert candidate(customers = [0, 0, 0, 0],boardingCost = 10,runningCost = 5) == -1\n assert candidate(customers = [10, 9, 6],boardingCost = 6,runningCost = 4) == 7\n assert candidate(customers = [0, 0, 0, 0],boardingCost = 10,runningCost = 1) == -1\n assert candidate(customers = [8, 3],boardingCost = 5,runningCost = 6) == 3\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 1,runningCost = 10) == -1\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 5,runningCost = 1) == -1\n assert candidate(customers = [50, 50, 50, 50],boardingCost = 2,runningCost = 1) == 50\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 10,runningCost = 1) == 63\n assert candidate(customers = [3, 4, 0, 5, 1],boardingCost = 1,runningCost = 92) == -1\n assert candidate(customers = [5, 5, 0, 8, 7, 1, 4, 7, 3, 23],boardingCost = 43,runningCost = 59) == 16\n assert candidate(customers = [10, 10, 10, 10, 10],boardingCost = 5,runningCost = 4) == 13\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 100,runningCost = 50) == 63\n assert candidate(customers = [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, 49],boardingCost = 1,runningCost = 1) == 343\n assert candidate(customers = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],boardingCost = 5,runningCost = 3) == 13\n assert candidate(customers = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10],boardingCost = 1,runningCost = 99) == -1\n assert candidate(customers = [50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0],boardingCost = 10,runningCost = 20) == 125\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boardingCost = 1,runningCost = 2) == 54\n assert candidate(customers = [10, 0, 0, 10, 0, 0, 10, 0, 0, 10],boardingCost = 6,runningCost = 4) == 12\n assert candidate(customers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],boardingCost = 3,runningCost = 15) == -1\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],boardingCost = 2,runningCost = 1) == 13\n assert candidate(customers = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],boardingCost = 5,runningCost = 8) == 50\n assert candidate(customers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],boardingCost = 2,runningCost = 3) == 53\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 1,runningCost = 1) == -1\n assert candidate(customers = [10, 20, 30, 40, 50],boardingCost = 50,runningCost = 1) == 38\n assert candidate(customers = [10, 20, 15, 5, 25],boardingCost = 4,runningCost = 7) == 19\n assert candidate(customers = [20, 10, 0, 30, 10, 0, 40, 10, 0, 50],boardingCost = 20,runningCost = 10) == 43\n assert candidate(customers = [30, 0, 10, 40, 20],boardingCost = 3,runningCost = 5) == 25\n assert candidate(customers = [50, 0, 50, 0, 50, 0, 50, 0, 50, 0],boardingCost = 10,runningCost = 5) == 63\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 1,runningCost = 5) == -1\n assert candidate(customers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],boardingCost = 1,runningCost = 1) == 10\n assert candidate(customers = [30, 20, 10, 0, 0, 0, 0, 0, 0, 0],boardingCost = 3,runningCost = 10) == 15\n assert candidate(customers = [10, 20, 30, 40, 50],boardingCost = 1,runningCost = 95) == -1\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],boardingCost = 5,runningCost = 4) == 145\n assert candidate(customers = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],boardingCost = 2,runningCost = 3) == 63\n assert candidate(customers = [4, 3, 2, 1, 0, 0, 0, 0, 0, 0],boardingCost = 50,runningCost = 2) == 4\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 10,runningCost = 20) == 15\n assert candidate(customers = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40],boardingCost = 1,runningCost = 1) == 200\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 2,runningCost = 3) == 15\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],boardingCost = 5,runningCost = 4) == 25\n assert candidate(customers = [2, 5, 3, 1, 4, 6, 2, 3, 5, 1, 4, 2, 3, 6, 5, 1, 4, 2, 3, 6, 5],boardingCost = 3,runningCost = 5) == 22\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 5,runningCost = 4) == 20\n assert candidate(customers = [50, 25, 50, 25, 50, 25, 50, 25, 50, 25],boardingCost = 4,runningCost = 10) == 94\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 5,runningCost = 6) == -1\n", "comparison": "exact"}, "public_tests": ["[8,3]\n5\n6", "[10,9,6]\n6\n4", "[3,4,0,5,1]\n1\n92"], "hints": ["Think simulation", "Note that the number of turns will never be more than 50 / 4 * n"], "metadata": {"canonical_parameter_names": ["customers", "boardingCost", "runningCost"], "leetcode_dataset_entry_point": "Solution().minOperationsMaxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:00+00:00", "tests_total": 55, "tests_dropped": 8, "flags": ["has_images"], "topic_tags": ["array", "simulation"]}, "language": "python", "interface": {"raw_signature": "def minOperationsMaxProfit(self, customers: list[int], boardingCost: int, runningCost: int) -> int:", "container": "Solution", "callable": "minOperationsMaxProfit", "parameters": [{"name": "customers", "type": "list[int]"}, {"name": "boardingCost", "type": "int"}, {"name": "runningCost", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1601, "task_id": "maximum-number-of-achievable-transfer-requests", "difficulty": "Hard", "problem_description": "We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.\n\nYou are given an array requests where requests[i] = [from_i, to_i] represents an employee's request to transfer from building from_i to building to_i.\n\nAll buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in. For example if n = 3 and two employees are leaving building 0, one is leaving building 1, and one is leaving building 2, there should be two employees moving to building 0, one employee moving to building 1, and one employee moving to building 2.\n\nReturn the maximum number of achievable requests.\n\nExample 1:\n\nInput: n = 5, requests = [[0,1],[1,0],[0,1],[1,2],[2,0],[3,4]]\nOutput: 5\nExplantion: Let's see the requests:\nFrom building 0 we have employees x and y and both want to move to building 1.\nFrom building 1 we have employees a and b and they want to move to buildings 2 and 0 respectively.\nFrom building 2 we have employee z and they want to move to building 0.\nFrom building 3 we have employee c and they want to move to building 4.\nFrom building 4 we don't have any requests.\nWe can achieve the requests of users x and b by swapping their places.\nWe can achieve the requests of users y, a and z by swapping the places in the 3 buildings.\n\nExample 2:\n\nInput: n = 3, requests = [[0,0],[1,2],[2,1]]\nOutput: 3\nExplantion: Let's see the requests:\nFrom building 0 we have employee x and they want to stay in the same building 0.\nFrom building 1 we have employee y and they want to move to building 2.\nFrom building 2 we have employee z and they want to move to building 1.\nWe can achieve all the requests.\n\nExample 3:\n\nInput: n = 4, requests = [[0,3],[3,1],[1,2],[2,0]]\nOutput: 4\n\nConstraints:\n\n- 1 <= n <= 20\n- 1 <= requests.length <= 16\n- requests[i].length == 2\n- 0 <= from_i, to_i < n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 6\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0]]) == 6\n assert candidate(n = 4,requests = [[0, 3], [3, 1], [1, 2], [2, 0]]) == 4\n assert candidate(n = 3,requests = [[0, 1], [1, 0], [0, 2], [2, 0]]) == 4\n assert candidate(n = 3,requests = [[0, 1], [1, 2], [2, 0], [0, 2]]) == 3\n assert candidate(n = 6,requests = [[0, 3], [3, 4], [4, 2], [2, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 7\n assert candidate(n = 3,requests = [[0, 0], [1, 2], [2, 1]]) == 3\n assert candidate(n = 2,requests = [[0, 0], [1, 1]]) == 2\n assert candidate(n = 3,requests = [[0, 1], [1, 0], [1, 2], [2, 1], [0, 2], [2, 0]]) == 6\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 5\n assert candidate(n = 5,requests = [[0, 1], [1, 0], [0, 1], [1, 2], [2, 0], [3, 4]]) == 5\n assert candidate(n = 2,requests = [[0, 1], [1, 0]]) == 2\n assert candidate(n = 6,requests = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 0], [0, 5], [0, 2], [2, 0], [1, 3], [3, 1]]) == 16\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [2, 1], [1, 3], [3, 2], [0, 3], [3, 1]]) == 8\n assert candidate(n = 8,requests = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [0, 7], [1, 6], [2, 5], [3, 4]]) == 8\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [1, 3], [3, 1], [2, 3], [3, 2], [0, 3], [3, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [3, 6], [6, 2], [2, 5], [5, 1], [1, 4], [4, 0]]) == 14\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1], [0, 3], [1, 4], [2, 0], [3, 1], [4, 2]]) == 15\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [6, 1], [1, 4], [4, 7], [7, 2], [2, 5], [5, 0]]) == 16\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 16\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == 12\n assert candidate(n = 12,requests = [[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, 5], [5, 10], [10, 3]]) == 12\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [2, 1], [1, 3], [3, 2]]) == 7\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1], [0, 3], [1, 0], [2, 1], [3, 2]]) == 12\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [1, 4], [4, 7], [2, 5], [5, 0]]) == 10\n assert candidate(n = 10,requests = [[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]]) == 15\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 2], [1, 4], [4, 0]]) == 9\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [2, 4], [4, 1], [1, 3], [3, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 6], [1, 5], [2, 4]]) == 7\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [2, 4], [4, 6], [6, 1], [1, 3], [3, 5], [5, 0]]) == 14\n assert candidate(n = 15,requests = [[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]]) == 15\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == 10\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2]]) == 12\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 10\n assert candidate(n = 5,requests = [[0, 1], [0, 2], [1, 0], [2, 0], [1, 2], [2, 1], [3, 4], [4, 3]]) == 8\n assert candidate(n = 6,requests = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [0, 3], [3, 0], [1, 4], [4, 1], [2, 5], [5, 2]]) == 12\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1]]) == 8\n assert candidate(n = 3,requests = [[0, 1], [1, 2], [2, 0], [0, 2], [1, 0], [2, 1], [0, 1], [1, 2], [2, 0]]) == 9\n assert candidate(n = 10,requests = [[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 = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 1], [1, 3], [3, 5], [5, 7], [7, 0]]) == 16\n assert candidate(n = 6,requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 12\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 4], [1, 3], [2, 0]]) == 5\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1]]) == 14\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 3]]) == 11\n assert candidate(n = 8,requests = [[0, 7], [7, 1], [1, 6], [6, 2], [2, 5], [5, 3], [3, 4], [4, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 0]]) == 12\n assert candidate(n = 10,requests = [[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]]) == 10\n assert candidate(n = 8,requests = [[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, 1], [6, 2], [7, 3]]) == 15\n assert candidate(n = 10,requests = [[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]]) == 10\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 13\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [2, 4], [4, 1], [1, 3], [3, 5], [5, 3]]) == 10\n", "comparison": "exact"}, "public_tests": ["5\n[[0,1],[1,0],[0,1],[1,2],[2,0],[3,4]]", "3\n[[0,0],[1,2],[2,1]]", "4\n[[0,3],[3,1],[1,2],[2,0]]"], "hints": ["Think brute force", "When is a subset of requests okay?"], "metadata": {"canonical_parameter_names": ["n", "requests"], "leetcode_dataset_entry_point": "Solution().maximumRequests", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:02+00:00", "tests_total": 71, "tests_dropped": 18, "flags": ["has_images"], "topic_tags": ["array", "backtracking", "bit-manipulation", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def maximumRequests(self, n: int, requests: list[list[int]]) -> int:", "container": "Solution", "callable": "maximumRequests", "parameters": [{"name": "n", "type": "int"}, {"name": "requests", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1604, "task_id": "alert-using-same-key-card-three-or-more-times-in-a-one-hour-period", "difficulty": "Medium", "problem_description": "LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an alert if any worker uses the key-card three or more times in a one-hour period.\n\nYou are given a list of strings keyName and keyTime where [keyName[i], keyTime[i]] corresponds to a person's name and the time when their key-card was used in a single day.\n\nAccess times are given in the 24-hour time format \"HH:MM\", such as \"23:51\" and \"09:49\".\n\nReturn a list of unique worker names who received an alert for frequent keycard use. Sort the names in ascending order alphabetically.\n\nNotice that \"10:00\" - \"11:00\" is considered to be within a one-hour period, while \"22:51\" - \"23:52\" is not considered to be within a one-hour period.\n\nExample 1:\n\nInput: keyName = [\"daniel\",\"daniel\",\"daniel\",\"luis\",\"luis\",\"luis\",\"luis\"], keyTime = [\"10:00\",\"10:40\",\"11:00\",\"09:00\",\"11:00\",\"13:00\",\"15:00\"]\nOutput: [\"daniel\"]\nExplanation: \"daniel\" used the keycard 3 times in a one-hour period (\"10:00\",\"10:40\", \"11:00\").\n\nExample 2:\n\nInput: keyName = [\"alice\",\"alice\",\"alice\",\"bob\",\"bob\",\"bob\",\"bob\"], keyTime = [\"12:01\",\"12:00\",\"18:00\",\"21:00\",\"21:20\",\"21:30\",\"23:00\"]\nOutput: [\"bob\"]\nExplanation: \"bob\" used the keycard 3 times in a one-hour period (\"21:00\",\"21:20\", \"21:30\").\n\nConstraints:\n\n- 1 <= keyName.length, keyTime.length <= 10^5\n- keyName.length == keyTime.length\n- keyTime[i] is in the format \"HH:MM\".\n- [keyName[i], keyTime[i]] is unique.\n- 1 <= keyName[i].length <= 10\n- keyName[i] contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'luis', 'luis', 'luis', 'luis'],keyTime = ['10:00', '10:40', '11:00', '09:00', '11:00', '13:00', '15:00']) == ['daniel']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'adam', 'adam', 'adam', 'adam'],keyTime = ['12:00', '12:05', '12:10', '09:00', '09:15', '09:30', '09:45']) == ['adam', 'amy']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'bob'],keyTime = ['12:01', '12:00', '18:00', '21:00', '21:20', '21:30', '23:00']) == ['bob']\n assert candidate(keyName = ['john', 'john', 'john'],keyTime = ['09:15', '09:30', '10:00']) == ['john']\n assert candidate(keyName = ['amy', 'david', 'david'],keyTime = ['12:00', '12:00', '13:00']) == []\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:20', '08:40', '09:00', '09:20']) == ['eve']\n assert candidate(keyName = ['chris', 'chris', 'chris'],keyTime = ['09:00', '09:30', '10:00']) == ['chris']\n assert candidate(keyName = ['john', 'john', 'john', 'john'],keyTime = ['09:00', '09:15', '09:30', '10:00']) == ['john']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['01:00', '01:10', '01:20', '02:00', '02:10']) == ['eve']\n assert candidate(keyName = ['john'],keyTime = ['00:00']) == []\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['23:58', '23:59', '00:00', '00:01', '00:02']) == ['eve']\n assert candidate(keyName = ['john', 'john', 'john', 'john'],keyTime = ['09:15', '09:45', '10:00', '10:30']) == ['john']\n assert candidate(keyName = ['anna', 'anna', 'anna', 'anna'],keyTime = ['10:00', '10:10', '10:20', '10:30']) == ['anna']\n assert candidate(keyName = ['alice', 'bob', 'alice'],keyTime = ['10:00', '10:10', '10:20']) == []\n assert candidate(keyName = ['mike', 'mike', 'mike', 'mike'],keyTime = ['00:00', '00:05', '00:10', '00:15']) == ['mike']\n assert candidate(keyName = ['anna', 'anna', 'bob', 'bob', 'bob'],keyTime = ['12:00', '12:05', '12:00', '12:05', '12:10']) == ['bob']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'adam'],keyTime = ['08:00', '08:10', '08:20', '08:30']) == ['amy']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50']) == ['grace']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20']) == ['grace']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'amy', 'amy'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00']) == ['amy']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40']) == ['alice']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30']) == ['grace']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['01:00', '01:10', '01:20', '01:30', '01:40', '01:50', '02:00', '02:10']) == ['karen']\n assert candidate(keyName = ['carol', 'carol', 'carol', 'carol', 'carol', 'carol', 'carol'],keyTime = ['23:00', '23:15', '23:30', '23:45', '00:00', '00:15', '00:30']) == ['carol']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:55', '00:00', '00:01', '00:02', '00:03', '00:04']) == ['grace']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['10:00', '10:05', '10:10', '10:15', '10:20', '10:25', '10:30', '10:35', '10:40', '10:45', '10:50', '10:55', '11:00', '11:05', '11:10', '11:15', '11:20', '11:25', '11:30', '11:35', '11:40', '11:45', '11:50', '11:55', '12:00']) == ['hank']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['ivan']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30']) == ['dave']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00']) == ['alice']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09', '09:10', '09:11', '09:12', '09:13', '09:14', '09:15', '09:16', '09:17', '09:18', '09:19', '09:20', '09:21', '09:22', '09:23', '09:24']) == ['ivan']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00']) == ['karen']\n assert candidate(keyName = ['leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo'],keyTime = ['22:00', '22:10', '22:20', '22:30', '22:40', '22:50', '23:00', '23:10', '23:20']) == ['leo']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10']) == ['eve']\n assert candidate(keyName = ['max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45', '09:50', '09:55', '10:00']) == ['max']\n assert candidate(keyName = ['lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy'],keyTime = ['16:00', '16:05', '16:10', '16:15', '16:20', '16:25', '16:30']) == ['lucy']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00']) == ['eve']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:35', '09:40', '09:00', '09:55', '10:05']) == ['alice', 'bob']\n assert candidate(keyName = ['tom', 'jerry', 'tom', 'jerry', 'tom', 'jerry', 'tom', 'jerry'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35']) == ['jerry', 'tom']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['08:59', '09:00', '09:01', '23:59', '00:01', '00:02', '00:03', '00:04', '10:00', '10:59', '11:00', '11:01']) == ['alice', 'bob', 'charlie']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy'],keyTime = ['08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30']) == ['amy']\n assert candidate(keyName = ['david', 'david', 'david', 'david', 'david'],keyTime = ['08:00', '08:05', '08:10', '08:55', '09:00']) == ['david']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30']) == ['eve']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30']) == ['ivan']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['frank']\n assert candidate(keyName = ['david', 'david', 'david', 'david', 'david', 'david'],keyTime = ['09:00', '09:10', '09:20', '10:00', '10:10', '10:20']) == ['david']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['hank']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['23:00', '23:30', '00:00', '00:30', '01:00', '01:30']) == ['eve']\n assert candidate(keyName = ['lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy'],keyTime = ['12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45']) == ['lucy']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45', '12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45', '14:00', '14:15', '14:30', '14:45']) == ['grace']\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['jane']\n assert candidate(keyName = ['judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['judy']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30']) == ['hank']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:50', '08:55', '09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35']) == ['eve']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['06:00', '06:15', '06:30', '06:45', '07:00', '07:15', '07:30', '07:45', '08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30']) == ['ivan']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['dave']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30', '01:40', '01:50', '02:00', '02:10', '02:20']) == ['ivan']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['23:50', '00:05', '00:10', '00:15', '00:20', '00:25']) == ['bob']\n assert candidate(keyName = ['chris', 'chris', 'chris', 'chris', 'chris', 'chris'],keyTime = ['23:45', '00:00', '00:15', '00:30', '00:45', '01:00']) == ['chris']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['23:55', '00:00', '00:01', '00:02', '00:03', '00:04', '00:05']) == ['dave']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05']) == ['grace']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15']) == ['grace']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45']) == ['eve']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00']) == ['charlie']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10']) == ['frank']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30']) == ['frank']\n assert candidate(keyName = ['alice', 'alice', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['08:00', '08:05', '08:00', '08:10', '08:15', '08:20', '08:25']) == ['bob']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['09:00', '09:20', '09:40', '10:00', '10:20', '10:40']) == ['bob']\n assert candidate(keyName = ['emma', 'emma', 'emma', 'emma', 'emma'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00']) == ['emma']\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'daniel', 'daniel', 'daniel'],keyTime = ['10:00', '10:15', '10:30', '11:00', '11:15', '11:30']) == ['daniel']\n assert candidate(keyName = ['alice', 'bob', 'charlie', 'alice', 'bob', 'charlie'],keyTime = ['08:00', '08:05', '08:10', '08:15', '08:20', '08:25']) == []\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09']) == ['jane']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:10', '08:20', '12:00', '12:05', '12:10', '12:15']) == ['charlie', 'dave']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['eve']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00', '14:20', '14:40', '15:00']) == ['eve']\n assert candidate(keyName = ['alice', 'alice', 'bob', 'bob', 'charlie', 'charlie'],keyTime = ['12:00', '12:59', '13:00', '13:59', '14:00', '14:59']) == []\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['23:50', '23:55', '00:00', '00:05', '00:10', '00:15', '00:20']) == ['heidi']\n assert candidate(keyName = ['tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['tim']\n assert candidate(keyName = ['jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30', '11:40']) == ['jill']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['hank']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['07:00', '07:10', '07:20', '07:30', '07:40', '07:50', '08:00']) == ['ivan']\n assert candidate(keyName = ['charlie', 'david', 'david', 'charlie', 'david'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:35']) == ['david']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05']) == ['frank']\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40']) == ['heidi']\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['07:00', '07:30', '08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00']) == ['heidi']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00']) == ['dave']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:00', '23:10', '23:20', '23:30', '23:40', '23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30']) == ['grace']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00']) == ['alice']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['eve']\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['18:00', '18:10', '18:20', '18:30', '18:40', '18:50', '19:00']) == ['jane']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['00:00', '00:15', '00:30', '00:45', '01:00', '01:15', '01:30', '01:45', '02:00', '02:15', '02:30', '02:45', '03:00']) == ['frank']\n assert candidate(keyName = ['mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45', '09:50', '09:55', '10:00', '10:05', '10:10', '10:15', '10:20']) == ['mike']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45']) == ['ivan']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10']) == ['ivan']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45']) == ['frank']\n assert candidate(keyName = ['frank', 'grace', 'heidi', 'frank', 'grace', 'heidi', 'frank', 'grace', 'heidi'],keyTime = ['10:00', '10:00', '10:00', '10:05', '10:05', '10:05', '10:10', '10:10', '10:10']) == ['frank', 'grace', 'heidi']\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'daniel', 'daniel', 'daniel'],keyTime = ['09:00', '09:15', '09:30', '10:00', '10:15', '10:30']) == ['daniel']\n assert candidate(keyName = ['sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30']) == ['sam']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['23:45', '23:50', '23:55', '00:00', '00:05', '00:10', '00:15']) == ['frank']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '11:00', '11:10']) == ['charlie']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['14:00', '14:30', '15:00', '15:30', '16:00', '16:30']) == ['hank']\n assert candidate(keyName = ['kyle', 'kyle', 'kyle', 'kyle', 'kyle', 'kyle', 'kyle'],keyTime = ['22:00', '22:15', '22:30', '22:45', '23:00', '23:15', '23:30']) == ['kyle']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['frank']\n assert candidate(keyName = ['julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40']) == ['julia']\n assert candidate(keyName = ['julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia'],keyTime = ['12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10']) == ['julia']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['karen']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['12:00', '12:01', '12:02', '12:03', '12:04', '12:05']) == ['bob']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00']) == ['alice']\n", "comparison": "exact"}, "public_tests": ["[\"daniel\",\"daniel\",\"daniel\",\"luis\",\"luis\",\"luis\",\"luis\"]\n[\"10:00\",\"10:40\",\"11:00\",\"09:00\",\"11:00\",\"13:00\",\"15:00\"]", "[\"alice\",\"alice\",\"alice\",\"bob\",\"bob\",\"bob\",\"bob\"]\n[\"12:01\",\"12:00\",\"18:00\",\"21:00\",\"21:20\",\"21:30\",\"23:00\"]"], "hints": ["Group the times by the name of the card user, then sort each group"], "metadata": {"canonical_parameter_names": ["keyName", "keyTime"], "leetcode_dataset_entry_point": "Solution().alertNames", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:07+00:00", "tests_total": 109, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "python", "interface": {"raw_signature": "def alertNames(self, keyName: list[str], keyTime: list[str]) -> list[str]:", "container": "Solution", "callable": "alertNames", "parameters": [{"name": "keyName", "type": "list[str]"}, {"name": "keyTime", "type": "list[str]"}], "return_type": "list[str]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1605, "task_id": "find-valid-matrix-given-row-and-column-sums", "difficulty": "Medium", "problem_description": "You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the i^th row and colSum[j] is the sum of the elements of the j^th column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column.\n\nFind any matrix of non-negative integers of size rowSum.length x colSum.length that satisfies the rowSum and colSum requirements.\n\nReturn a 2D array representing any matrix that fulfills the requirements. It's guaranteed that at least one matrix that fulfills the requirements exists.\n\nExample 1:\n\nInput: rowSum = [3,8], colSum = [4,7]\nOutput: [[3,0],\n [1,7]]\nExplanation:\n0^th row: 3 + 0 = 3 == rowSum[0]\n1^st row: 1 + 7 = 8 == rowSum[1]\n0^th column: 3 + 1 = 4 == colSum[0]\n1^st column: 0 + 7 = 7 == colSum[1]\nThe row and column sums match, and all matrix elements are non-negative.\nAnother possible matrix is: [[1,2],\n [3,5]]\n\nExample 2:\n\nInput: rowSum = [5,7,10], colSum = [8,6,8]\nOutput: [[0,5,0],\n [6,1,0],\n [2,0,8]]\n\nConstraints:\n\n- 1 <= rowSum.length, colSum.length <= 500\n- 0 <= rowSum[i], colSum[i] <= 10^8\n- sum(rowSum) == sum(colSum)\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rowSum = [10, 15],colSum = [12, 13]) == [[10, 0], [2, 13]]\n assert candidate(rowSum = [5, 5, 5],colSum = [5, 5, 5]) == [[5, 0, 0], [0, 5, 0], [0, 0, 5]]\n assert candidate(rowSum = [10, 20],colSum = [15, 15]) == [[10, 0], [5, 15]]\n assert candidate(rowSum = [10, 15, 20],colSum = [15, 15, 15]) == [[10, 0, 0], [5, 10, 0], [0, 5, 15]]\n assert candidate(rowSum = [1, 2, 3, 4],colSum = [1, 2, 3, 4]) == [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]\n assert candidate(rowSum = [1, 1, 1],colSum = [1, 1, 1]) == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]\n assert candidate(rowSum = [5, 7, 10],colSum = [8, 6, 8]) == [[5, 0, 0], [3, 4, 0], [0, 2, 8]]\n assert candidate(rowSum = [0, 0],colSum = [0, 0]) == [[0, 0], [0, 0]]\n assert candidate(rowSum = [1, 2],colSum = [3, 0]) == [[1, 0], [2, 0]]\n assert candidate(rowSum = [1, 2, 3],colSum = [3, 2, 1]) == [[1, 0, 0], [2, 0, 0], [0, 2, 1]]\n assert candidate(rowSum = [0, 0, 0],colSum = [0, 0, 0]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(rowSum = [3, 8],colSum = [4, 7]) == [[3, 0], [1, 7]]\n assert candidate(rowSum = [25, 25, 25, 25, 25],colSum = [25, 25, 25, 25, 25]) == [[25, 0, 0, 0, 0], [0, 25, 0, 0, 0], [0, 0, 25, 0, 0], [0, 0, 0, 25, 0], [0, 0, 0, 0, 25]]\n assert candidate(rowSum = [1000, 2000, 3000],colSum = [1500, 2000, 2500]) == [[1000, 0, 0], [500, 1500, 0], [0, 500, 2500]]\n assert candidate(rowSum = [99, 100, 101, 102],colSum = [101, 102, 99, 100]) == [[99, 0, 0, 0], [2, 98, 0, 0], [0, 4, 97, 0], [0, 0, 2, 100]]\n assert candidate(rowSum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[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(rowSum = [10, 20, 30, 40, 50],colSum = [50, 40, 30, 20, 10]) == [[10, 0, 0, 0, 0], [20, 0, 0, 0, 0], [20, 10, 0, 0, 0], [0, 30, 10, 0, 0], [0, 0, 20, 20, 10]]\n assert candidate(rowSum = [500, 300, 200],colSum = [400, 350, 250]) == [[400, 100, 0], [0, 250, 50], [0, 0, 200]]\n assert candidate(rowSum = [8, 16, 24, 32],colSum = [16, 24, 16, 24]) == [[8, 0, 0, 0], [8, 8, 0, 0], [0, 16, 8, 0], [0, 0, 8, 24]]\n assert candidate(rowSum = [50, 60, 70, 80, 90],colSum = [90, 80, 70, 60, 50]) == [[50, 0, 0, 0, 0], [40, 20, 0, 0, 0], [0, 60, 10, 0, 0], [0, 0, 60, 20, 0], [0, 0, 0, 40, 50]]\n assert candidate(rowSum = [123, 456, 789],colSum = [456, 789, 123]) == [[123, 0, 0], [333, 123, 0], [0, 666, 123]]\n assert candidate(rowSum = [8, 16, 24, 32],colSum = [16, 24, 32, 8]) == [[8, 0, 0, 0], [8, 8, 0, 0], [0, 16, 8, 0], [0, 0, 24, 8]]\n assert candidate(rowSum = [99, 98, 97, 96, 95],colSum = [95, 96, 97, 98, 99]) == [[95, 4, 0, 0, 0], [0, 92, 6, 0, 0], [0, 0, 91, 6, 0], [0, 0, 0, 92, 4], [0, 0, 0, 0, 95]]\n assert candidate(rowSum = [100, 150, 200],colSum = [200, 120, 130]) == [[100, 0, 0], [100, 50, 0], [0, 70, 130]]\n assert candidate(rowSum = [120, 140, 160, 180, 200],colSum = [200, 180, 160, 140, 120]) == [[120, 0, 0, 0, 0], [80, 60, 0, 0, 0], [0, 120, 40, 0, 0], [0, 0, 120, 60, 0], [0, 0, 0, 80, 120]]\n assert candidate(rowSum = [30, 20, 10, 0],colSum = [10, 10, 10, 30]) == [[10, 10, 10, 0], [0, 0, 0, 20], [0, 0, 0, 10], [0, 0, 0, 0]]\n assert candidate(rowSum = [5, 10, 15, 20, 25],colSum = [25, 20, 15, 10, 5]) == [[5, 0, 0, 0, 0], [10, 0, 0, 0, 0], [10, 5, 0, 0, 0], [0, 15, 5, 0, 0], [0, 0, 10, 10, 5]]\n assert candidate(rowSum = [1, 1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1, 1]) == [[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(rowSum = [1, 2, 3, 4, 5],colSum = [5, 4, 3, 2, 1]) == [[1, 0, 0, 0, 0], [2, 0, 0, 0, 0], [2, 1, 0, 0, 0], [0, 3, 1, 0, 0], [0, 0, 2, 2, 1]]\n assert candidate(rowSum = [7, 14, 21, 28],colSum = [7, 14, 21, 28]) == [[7, 0, 0, 0], [0, 14, 0, 0], [0, 0, 21, 0], [0, 0, 0, 28]]\n assert candidate(rowSum = [30, 60, 90, 120],colSum = [20, 40, 60, 80, 100]) == [[20, 10, 0, 0, 0], [0, 30, 30, 0, 0], [0, 0, 30, 60, 0], [0, 0, 0, 20, 100]]\n assert candidate(rowSum = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colSum = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[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, 5, 0, 0, 0, 0, 0, 0, 0, 0], [0, 4, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 6, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 3, 2, 1]]\n assert candidate(rowSum = [100, 200, 300, 400, 500],colSum = [500, 400, 300, 200, 100]) == [[100, 0, 0, 0, 0], [200, 0, 0, 0, 0], [200, 100, 0, 0, 0], [0, 300, 100, 0, 0], [0, 0, 200, 200, 100]]\n assert candidate(rowSum = [10000, 20000, 30000],colSum = [15000, 20000, 25000]) == [[10000, 0, 0], [5000, 15000, 0], [0, 5000, 25000]]\n assert candidate(rowSum = [1, 1, 1, 1, 1],colSum = [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], [0, 0, 0, 0, 1]]\n assert candidate(rowSum = [5, 10, 15, 20],colSum = [20, 15, 10, 5]) == [[5, 0, 0, 0], [10, 0, 0, 0], [5, 10, 0, 0], [0, 5, 10, 5]]\n assert candidate(rowSum = [50, 50, 50, 50, 50, 50],colSum = [50, 50, 50, 50, 50, 50]) == [[50, 0, 0, 0, 0, 0], [0, 50, 0, 0, 0, 0], [0, 0, 50, 0, 0, 0], [0, 0, 0, 50, 0, 0], [0, 0, 0, 0, 50, 0], [0, 0, 0, 0, 0, 50]]\n assert candidate(rowSum = [10, 20, 30],colSum = [30, 20, 10]) == [[10, 0, 0], [20, 0, 0], [0, 20, 10]]\n assert candidate(rowSum = [12, 9, 6],colSum = [10, 10, 7]) == [[10, 2, 0], [0, 8, 1], [0, 0, 6]]\n assert candidate(rowSum = [100, 150, 200, 250],colSum = [150, 200, 250, 100]) == [[100, 0, 0, 0], [50, 100, 0, 0], [0, 100, 100, 0], [0, 0, 150, 100]]\n", "comparison": "exact"}, "public_tests": ["[3,8]\n[4,7]", "[5,7,10]\n[8,6,8]"], "hints": ["Find the smallest rowSum or colSum, and let it be x. Place that number in the grid, and subtract x from rowSum and colSum. Continue until all the sums are satisfied."], "metadata": {"canonical_parameter_names": ["rowSum", "colSum"], "leetcode_dataset_entry_point": "Solution().restoreMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:10+00:00", "tests_total": 113, "tests_dropped": 73, "flags": [], "topic_tags": ["array", "greedy", "matrix", "flow-network"]}, "language": "python", "interface": {"raw_signature": "def restoreMatrix(self, rowSum: list[int], colSum: list[int]) -> list[list[int]]:", "container": "Solution", "callable": "restoreMatrix", "parameters": [{"name": "rowSum", "type": "list[int]"}, {"name": "colSum", "type": "list[int]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1606, "task_id": "find-servers-that-handled-most-number-of-requests", "difficulty": "Hard", "problem_description": "You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but cannot handle more than one request at a time. The requests are assigned to servers according to a specific algorithm:\n\n- The i^th (0-indexed) request arrives.\n- If all servers are busy, the request is dropped (not handled at all).\n- If the (i % k)^th server is available, assign the request to that server.\n- Otherwise, assign the request to the next available server (wrapping around the list of servers and starting from 0 if necessary). For example, if the i^th server is busy, try to assign the request to the (i+1)^th server, then the (i+2)^th server, and so on.\n\nYou are given a strictly increasing array arrival of positive integers, where arrival[i] represents the arrival time of the i^th request, and another array load, where load[i] represents the load of the i^th request (the time it takes to complete). Your goal is to find the busiest server(s). A server is considered busiest if it handled the most number of requests successfully among all the servers.\n\nReturn a list containing the IDs (0-indexed) of the busiest server(s). You may return the IDs in any order.\n\nExample 1:\n\nInput: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3]\nOutput: [1]\nExplanation:\nAll of the servers start out available.\nThe first 3 requests are handled by the first 3 servers in order.\nRequest 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.\nRequest 4 comes in. It cannot be handled since all servers are busy, so it is dropped.\nServers 0 and 2 handled one request each, while server 1 handled two requests. Hence server 1 is the busiest server.\n\nExample 2:\n\nInput: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]\nOutput: [0]\nExplanation:\nThe first 3 requests are handled by first 3 servers.\nRequest 3 comes in. It is handled by server 0 since the server is available.\nServer 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.\n\nExample 3:\n\nInput: k = 3, arrival = [1,2,3], load = [10,12,11]\nOutput: [0,1,2]\nExplanation: Each server handles a single request, so they are all considered the busiest.\n\nConstraints:\n\n- 1 <= k <= 10^5\n- 1 <= arrival.length, load.length <= 10^5\n- arrival.length == load.length\n- 1 <= arrival[i], load[i] <= 10^9\n- arrival is strictly increasing.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(k=5, arrival=[1, 7, 8, 9, 10], load=[5, 2, 3, 3, 3]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=3, arrival=[1, 2, 3, 4], load=[1, 2, 1, 2]), [0])\n assert answers_match(candidate(k=3, arrival=[1, 2, 3], load=[10, 12, 11]), [0, 1, 2])\n assert answers_match(candidate(k=1, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 7, 8, 9, 10, 11, 12], load=[2, 3, 2, 1, 3, 2, 2]), [0, 1])\n assert answers_match(candidate(k=10, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=4, arrival=[1, 10, 20, 30, 40], load=[2, 2, 2, 2, 2]), [0])\n assert answers_match(candidate(k=1, arrival=[1, 2, 3, 4, 5], load=[1, 1, 1, 1, 1]), [0])\n assert answers_match(candidate(k=3, arrival=[1, 2, 3, 4, 5], load=[5, 2, 3, 3, 3]), [1])\n assert answers_match(candidate(k=5, arrival=[1, 7, 8, 9, 10], load=[5, 2, 10, 3, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19, 25, 31, 37, 43, 49, 55], load=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=4, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57], load=[4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2]), [0, 1, 2])\n assert answers_match(candidate(k=4, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3])\n assert answers_match(candidate(k=20, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=9, arrival=[1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), [0, 1])\n assert answers_match(candidate(k=4, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n assert answers_match(candidate(k=1000, arrival=[1, 1001, 2001, 3001, 4001, 5001, 6001, 7001, 8001, 9001, 10001], load=[100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(k=10, arrival=[2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59], load=[3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=100, arrival=[1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001], load=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(k=8, arrival=[1, 4, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144], load=[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]), [0, 1, 2, 3])\n assert answers_match(candidate(k=4, arrival=[1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95], load=[1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=7, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], load=[3, 6, 4, 2, 5, 7, 1, 8, 3, 5, 6, 4, 2, 7, 1]), [0])\n assert answers_match(candidate(k=12, arrival=[1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90], load=[5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3]), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(k=12, arrival=[1, 13, 25, 37, 49, 61, 73, 85, 97, 109, 121, 133, 145, 157, 169, 181, 193, 205, 217, 229], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8]), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(k=7, arrival=[1, 3, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50], load=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=4, arrival=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225], load=[3, 6, 2, 8, 5, 9, 3, 7, 1, 10, 4, 6, 8, 2, 9]), [0, 1, 2])\n assert answers_match(candidate(k=10, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77], load=[10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=20, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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]), [0, 1])\n assert answers_match(candidate(k=5, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100], load=[10, 5, 7, 6, 2, 4, 8, 3, 9, 1, 6]), [0])\n assert answers_match(candidate(k=15, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(k=3, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], load=[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]), [0, 1, 2])\n assert answers_match(candidate(k=4, arrival=[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], load=[5, 3, 2, 8, 6, 4, 7, 9, 1, 10, 3, 5, 8, 6, 4, 7, 9, 1, 10, 3, 5, 8, 6, 4, 7, 9, 1, 10, 3]), [0])\n assert answers_match(candidate(k=8, arrival=[1, 2, 3, 5, 10, 12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), [0, 1, 2])\n assert answers_match(candidate(k=10, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], load=[5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95], load=[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=10, arrival=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=8, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3])\n assert answers_match(candidate(k=11, arrival=[1, 12, 23, 34, 45, 56, 67, 78, 89, 100, 111, 122, 133, 144, 155, 166, 177, 188, 199, 210], load=[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3]), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(k=7, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190], load=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=20, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], load=[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]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], load=[10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 3, 4])\n assert answers_match(candidate(k=6, arrival=[1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55], load=[10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=8, arrival=[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], load=[1, 2, 3, 4, 5, 6, 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, 2, 3, 4, 5])\n assert answers_match(candidate(k=8, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], load=[9, 1, 8, 2, 7, 3, 6, 4, 5, 6, 4, 5, 3, 7, 2, 8, 9, 1, 8, 2]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=9, arrival=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58], load=[9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8]), [0, 1])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), [0, 1, 2])\n assert answers_match(candidate(k=10, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77], load=[2, 4, 3, 5, 6, 2, 8, 7, 3, 4, 5, 2, 3, 1, 7, 4, 2, 8, 6, 5]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384], load=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=10, arrival=[2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58], load=[4, 7, 2, 9, 1, 8, 6, 5, 3, 2, 10, 5, 7, 9, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], load=[5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=6, arrival=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768], load=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=6, arrival=[1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]), [0, 1])\n assert answers_match(candidate(k=8, arrival=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024], load=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]), [0, 1, 2])\n assert answers_match(candidate(k=8, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190], load=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]), [0, 1, 2, 3])\n assert answers_match(candidate(k=7, arrival=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40], load=[2, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4]), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(k=8, arrival=[1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191], load=[8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5]), [0, 1, 2, 3])\n assert answers_match(candidate(k=3, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], load=[80, 70, 60, 50, 40, 30, 20, 10, 5, 1]), [0, 2])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[2, 4, 3, 5, 1, 6, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=6, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=15, arrival=[1, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285], load=[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=15, arrival=[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], load=[10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[1, 1, 1, 1, 1, 1, 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 answers_match(candidate(k=10, arrival=[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], load=[2, 4, 1, 3, 5, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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], load=[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]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=7, arrival=[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], load=[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]), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(k=7, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=6, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[1, 1, 2, 2, 3, 3, 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 answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[2, 3, 1, 4, 2, 1, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]), [0, 1, 2, 3])\n assert answers_match(candidate(k=6, arrival=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384], load=[2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]), [0, 1, 2])\n assert answers_match(candidate(k=6, arrival=[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], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=9, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190], load=[9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8]), [0, 1])\n assert answers_match(candidate(k=5, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]), [0])\n assert answers_match(candidate(k=10, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 3, 5, 7, 9, 11, 13, 15], load=[2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2])\n assert answers_match(candidate(k=1, arrival=[1, 10, 20, 30], load=[5, 5, 5, 5]), [0])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1])\n assert answers_match(candidate(k=6, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]), [0, 1, 2, 3])\n assert answers_match(candidate(k=4, arrival=[1, 3, 5, 7, 9, 11, 13, 15], load=[2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(k=6, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 5, 9, 14, 18], load=[4, 3, 5, 2, 3]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=7, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=1, arrival=[1, 10, 20, 30, 40], load=[1, 1, 1, 1, 1]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 1, 2, 1, 2, 1, 2, 1, 2, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=3, arrival=[1, 2, 3, 4, 5, 6], load=[3, 2, 1, 1, 2, 3]), [0, 1, 2])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19], load=[10, 10, 10, 10]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1])\n assert answers_match(candidate(k=4, arrival=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], load=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]), [0, 1])\n assert answers_match(candidate(k=5, arrival=[1, 3, 5, 7, 9], load=[2, 2, 2, 2, 2]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 3, 1, 5, 4, 2, 3, 1, 2, 1]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=7, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [0, 1, 2])\n assert answers_match(candidate(k=10, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], load=[9, 9, 9, 9, 9, 9, 9, 9, 9, 9]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=6, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=2, arrival=[1, 3, 5, 7, 9], load=[2, 2, 2, 2, 2]), [0])\n assert answers_match(candidate(k=100, arrival=[1, 101, 201, 301, 401, 501, 601, 701, 801, 901], load=[100, 100, 100, 100, 100, 100, 100, 100, 100, 100]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 8, 10, 13, 15, 16, 17, 20], load=[2, 3, 1, 4, 2, 3, 2, 1, 2, 3]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=1, arrival=[1, 10, 20, 30, 40], load=[5, 5, 5, 5, 5]), [0])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[5, 3, 5, 3, 5, 3, 5, 3, 5, 3]), [0, 1])\n assert answers_match(candidate(k=10000, arrival=[1, 10001, 20001, 30001, 40001], load=[10000, 10000, 10000, 10000, 10000]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=4, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], load=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]), [0, 1])\n assert answers_match(candidate(k=10, arrival=[1, 5, 9, 13, 17], load=[3, 3, 3, 3, 3]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=1, arrival=[1, 10, 19, 28, 37, 46, 55, 64, 73, 82], load=[9, 9, 9, 9, 9, 9, 9, 9, 9, 9]), [0])\n assert answers_match(candidate(k=6, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[3, 3, 3, 3, 3, 3, 3, 3, 3, 3]), [0, 1, 2, 3])\n assert answers_match(candidate(k=6, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], load=[20, 10, 20, 10, 20, 10, 20, 10, 20, 10]), [0, 1, 2, 3])\n assert answers_match(candidate(k=4, arrival=[1, 5, 9, 13, 17, 21], load=[2, 2, 2, 2, 2, 2]), [0, 1])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19, 25], load=[5, 6, 7, 8, 9]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=4, arrival=[1, 10, 20, 30, 40, 50], load=[3, 3, 3, 3, 3, 3]), [0, 1])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19, 25], load=[5, 3, 8, 6, 2]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=100, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], load=[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]), [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])\n assert answers_match(candidate(k=1, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0])\n assert answers_match(candidate(k=6, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], load=[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]), [0, 1])\n assert answers_match(candidate(k=1, arrival=[1, 2, 3, 4, 5], load=[5, 4, 3, 2, 1]), [0])\n assert answers_match(candidate(k=7, arrival=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2])\n assert answers_match(candidate(k=1000, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=7, arrival=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 1, 2, 1, 2, 1, 2, 1, 2, 1]), [0, 1])\n assert answers_match(candidate(k=10, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=10, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=10, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[3, 3, 3, 3, 3, 3, 3, 3, 3, 3]), [0])\n assert answers_match(candidate(k=10, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=6, arrival=[1, 4, 7, 10, 13, 16, 19, 22, 25, 28], load=[3, 3, 3, 3, 3, 3, 3, 3, 3, 3]), [0, 1, 2, 3])\n assert answers_match(candidate(k=7, arrival=[1, 3, 5, 7, 9, 11, 13, 15], load=[2, 2, 2, 2, 2, 2, 2, 2]), [0])\n assert answers_match(candidate(k=100, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19, 25, 31], load=[5, 5, 5, 5, 5, 5]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19], load=[5, 5, 5, 5]), [0, 1, 2, 3])\n assert answers_match(candidate(k=2, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [0, 1])\n assert answers_match(candidate(k=7, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 1, 3, 2, 1, 3, 2, 1, 3, 2]), [0, 1])\n assert answers_match(candidate(k=6, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[2, 4, 6, 8, 10, 1, 3, 5, 7, 9]), [0, 1, 2, 3])\n assert answers_match(candidate(k=10, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=7, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2])\n assert answers_match(candidate(k=10, arrival=[1, 11, 21, 31, 41, 51, 61, 71, 81, 91], load=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=4, arrival=[1, 5, 9, 13, 17], load=[4, 4, 4, 4, 4]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 3, 4, 5, 6, 1, 2, 3, 4, 5]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], load=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=6, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], load=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), [0, 1, 2])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]), [0, 1])\n assert answers_match(candidate(k=4, arrival=[1, 3, 5, 7, 9], load=[1, 2, 1, 2, 1]), [0])\n assert answers_match(candidate(k=1, arrival=[1, 10, 100, 1000, 10000], load=[1, 2, 3, 4, 5]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 7, 13, 19, 25], load=[5, 5, 5, 5, 5]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=1, arrival=[1, 10, 100, 1000, 10000], load=[1, 1, 1, 1, 1]), [0])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 3, 2, 1, 2, 3, 2, 1, 2, 3]), [0, 1, 2, 3, 4])\n assert answers_match(candidate(k=7, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[4, 2, 6, 3, 5, 1, 7, 8, 2, 5]), [0, 1, 2])\n assert answers_match(candidate(k=10, arrival=[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], load=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(k=7, arrival=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], load=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]), [0, 1, 2])\n assert answers_match(candidate(k=5, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[2, 3, 4, 5, 6, 7, 8, 9, 10, 1]), [0, 1, 2, 3])\n assert answers_match(candidate(k=4, arrival=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], load=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), [0])\n assert answers_match(candidate(k=2, arrival=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], load=[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]), [0, 1])\n", "comparison": "unordered"}, "public_tests": ["3\n[1,2,3,4,5]\n[5,2,3,3,3]", "3\n[1,2,3,4]\n[1,2,1,2]", "3\n[1,2,3]\n[10,12,11]"], "hints": ["To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set.", "To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to the next task to add."], "metadata": {"canonical_parameter_names": ["k", "arrival", "load"], "leetcode_dataset_entry_point": "Solution().busiestServers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:13+00:00", "tests_total": 177, "tests_dropped": 7, "flags": ["any_order", "has_images"], "topic_tags": ["array", "heap-priority-queue", "simulation", "ordered-set"]}, "language": "python", "interface": {"raw_signature": "def busiestServers(self, k: int, arrival: list[int], load: list[int]) -> list[int]:", "container": "Solution", "callable": "busiestServers", "parameters": [{"name": "k", "type": "int"}, {"name": "arrival", "type": "list[int]"}, {"name": "load", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1608, "task_id": "special-array-with-x-elements-greater-than-or-equal-x", "difficulty": "Easy", "problem_description": "You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x.\n\nNotice that x does not have to be an element in nums.\n\nReturn x if the array is special, otherwise, return -1. It can be proven that if nums is special, the value for x is unique.\n\nExample 1:\n\nInput: nums = [3,5]\nOutput: 2\nExplanation: There are 2 values (3 and 5) that are greater than or equal to 2.\n\nExample 2:\n\nInput: nums = [0,0]\nOutput: -1\nExplanation: No numbers fit the criteria for x.\nIf x = 0, there should be 0 numbers >= x, but there are 2.\nIf x = 1, there should be 1 number >= x, but there are 0.\nIf x = 2, there should be 2 numbers >= x, but there are 0.\nx cannot be greater since there are only 2 numbers in nums.\n\nExample 3:\n\nInput: nums = [0,4,3,0,4]\nOutput: 3\nExplanation: There are 3 values that are greater than or equal to 3.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 0 <= nums[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [0, 0]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1000]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [0, 4, 3, 0, 4]) == 3\n assert candidate(nums = [3, 5]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 5\n assert candidate(nums = [1, 2, 3, 3, 3]) == 3\n assert candidate(nums = [1000, 1000, 1000]) == 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]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000]) == 14\n assert candidate(nums = [9, 30, 20, 10, 40, 50, 60, 70, 80, 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, 21, 22, 23, 24, 25, 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, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 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, 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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\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, 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]) == 60\n assert candidate(nums = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10]) == 8\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999]) == 11\n assert candidate(nums = [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 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 98\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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 = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\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]) == 41\n assert candidate(nums = [0, 0, 1, 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, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -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]) == 28\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, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950]) == 50\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]) == -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]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 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, 1000]) == -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, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 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]) == -1\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, 3, 2, 4, 5, 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, 50]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 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\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, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 7\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\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\n assert candidate(nums = [1, 0, 3, 0, 5, 0, 7, 0, 9, 0, 11, 0, 13, 0, 15, 0, 17, 0, 19, 0]) == 7\n", "comparison": "exact"}, "public_tests": ["[3,5]", "[0,0]", "[0,4,3,0,4]"], "hints": ["Count the number of elements greater than or equal to x for each x in the range [0, nums.length].", "If for any x, the condition satisfies, return that x. Otherwise, there is no answer."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().specialArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:15+00:00", "tests_total": 75, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search", "sorting"]}, "language": "python", "interface": {"raw_signature": "def specialArray(self, nums: list[int]) -> int:", "container": "Solution", "callable": "specialArray", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1610, "task_id": "maximum-number-of-visible-points", "difficulty": "Hard", "problem_description": "You are given an array points, an integer angle, and your location, where location = [pos_x, pos_y] and points[i] = [x_i, y_i] both denote integral coordinates on the X-Y plane.\n\nInitially, you are facing directly east from your position. You cannot move from your position, but you can rotate. In other words, pos_x and pos_y cannot be changed. Your field of view in degrees is represented by angle, determining how wide you can see from any given view direction. Let d be the amount in degrees that you rotate counterclockwise. Then, your field of view is the inclusive range of angles [d - angle/2, d + angle/2].\n\nYou can see some set of points if, for each point, the angle formed by the point, your position, and the immediate east direction from your position is in your field of view.\n\nThere can be multiple points at one coordinate. There may be points at your location, and you can always see these points regardless of your rotation. Points do not obstruct your vision to other points.\n\nReturn the maximum number of points you can see.\n\nExample 1:\n\nInput: points = [[2,1],[2,2],[3,3]], angle = 90, location = [1,1]\nOutput: 3\nExplanation: The shaded region represents your field of view. All points can be made visible in your field of view, including [3,3] even though [2,2] is in front and in the same line of sight.\n\nExample 2:\n\nInput: points = [[2,1],[2,2],[3,4],[1,1]], angle = 90, location = [1,1]\nOutput: 4\nExplanation: All points can be made visible in your field of view, including the one at your location.\n\nExample 3:\n\nInput: points = [[1,0],[2,1]], angle = 13, location = [1,1]\nOutput: 1\nExplanation: You can only see one of the two points, as shown above.\n\nConstraints:\n\n- 1 <= points.length <= 10^5\n- points[i].length == 2\n- location.length == 2\n- 0 <= angle < 360\n- 0 <= pos_x, pos_y, x_i, y_i <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1]],angle = 90,location = [0, 0]) == 2\n assert candidate(points = [[100, 100], [100, 99], [99, 100], [99, 99]],angle = 45,location = [100, 100]) == 3\n assert candidate(points = [[0, 0], [5, 5], [10, 10]],angle = 90,location = [0, 0]) == 3\n assert candidate(points = [[2, 2], [3, 3], [4, 4], [1, 1]],angle = 45,location = [2, 2]) == 3\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],angle = 0,location = [0, 0]) == 2\n assert candidate(points = [[1, 0], [2, 1]],angle = 13,location = [1, 1]) == 1\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]],angle = 45,location = [1, 1]) == 4\n assert candidate(points = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],angle = 90,location = [3, 2]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3]],angle = 0,location = [0, 0]) == 4\n assert candidate(points = [[50, 50], [51, 50], [52, 50]],angle = 1,location = [50, 50]) == 3\n assert candidate(points = [[0, 0], [50, 50]],angle = 90,location = [25, 25]) == 1\n assert candidate(points = [[2, 1], [2, 2], [3, 3]],angle = 90,location = [1, 1]) == 3\n assert candidate(points = [[0, 0], [100, 100]],angle = 1,location = [50, 50]) == 1\n assert candidate(points = [[1, 1], [1, 1], [1, 1]],angle = 180,location = [1, 1]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 180,location = [3, 3]) == 5\n assert candidate(points = [[10, 10], [11, 10], [12, 10], [13, 10], [14, 10]],angle = 45,location = [10, 10]) == 5\n assert candidate(points = [[1, 1], [2, 2], [1, 2], [2, 1]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[2, 1], [2, 2], [3, 4], [1, 1]],angle = 90,location = [1, 1]) == 4\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],angle = 90,location = [0, 0]) == 4\n assert candidate(points = [[0, 0], [0, 0], [0, 0]],angle = 180,location = [0, 0]) == 3\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2]],angle = 45,location = [0, 0]) == 2\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [5, 5], [25, 25], [5, 25], [25, 5], [15, 5], [5, 15], [25, 15], [15, 25]],angle = 120,location = [15, 15]) == 6\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],angle = 45,location = [15, 15]) == 5\n assert candidate(points = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],angle = 10,location = [50, 0]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 30,location = [5, 5]) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],angle = 10,location = [1, 5]) == 5\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4]],angle = 180,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4]],angle = 180,location = [2, 2]) == 12\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],angle = 30,location = [5, 1]) == 10\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],angle = 30,location = [5, 5]) == 6\n assert candidate(points = [[2, 1], [1, 2], [3, 1], [1, 3], [2, 2]],angle = 90,location = [2, 1]) == 4\n assert candidate(points = [[10, 0], [20, 0], [30, 0], [40, 0], [50, 0]],angle = 180,location = [25, 25]) == 5\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],angle = 359,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 180,location = [5, 5]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [5, 1]],angle = 90,location = [3, 3]) == 4\n assert candidate(points = [[100, 100], [50, 50], [50, 100], [100, 50], [75, 75], [25, 25], [75, 25], [25, 75]],angle = 45,location = [50, 50]) == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 90,location = [4, 4]) == 5\n assert candidate(points = [[2, 3], [3, 2], [4, 5], [5, 4], [6, 5], [5, 6]],angle = 45,location = [4, 4]) == 2\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [5, 6], [6, 5], [5, 4], [4, 5]],angle = 90,location = [5, 5]) == 8\n assert candidate(points = [[2, 1], [3, 4], [5, 5], [4, 2], [1, 2], [3, 1]],angle = 45,location = [3, 3]) == 2\n assert candidate(points = [[2, 0], [2, 2], [1, 3], [3, 3], [0, 2]],angle = 60,location = [2, 1]) == 3\n assert candidate(points = [[5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9]],angle = 90,location = [5, 1]) == 11\n assert candidate(points = [[10, 10], [10, 9], [9, 10], [9, 11], [11, 10], [11, 11], [8, 8], [8, 9], [9, 8], [11, 9]],angle = 45,location = [10, 10]) == 4\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[1, 2], [2, 2], [4, 5], [5, 4], [3, 3]],angle = 45,location = [3, 3]) == 3\n assert candidate(points = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [0, 1], [2, 1], [0, 2], [2, 2], [0, 3], [2, 3], [0, 4], [2, 4], [0, 5], [2, 5]],angle = 90,location = [1, 1]) == 17\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 45,location = [25, 25]) == 3\n assert candidate(points = [[5, 5], [5, 10], [5, 15], [5, 20], [5, 25]],angle = 90,location = [5, 15]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 30,location = [3, 3]) == 3\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],angle = 90,location = [5, 1]) == 6\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [5, 5], [25, 25]],angle = 90,location = [15, 15]) == 4\n assert candidate(points = [[0, 1], [1, 0], [0, -1], [-1, 0], [0, 0], [1, 1], [-1, -1], [1, -1], [-1, 1]],angle = 90,location = [0, 0]) == 4\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 45,location = [5, 5]) == 6\n assert candidate(points = [[50, 50], [50, 40], [50, 30], [50, 20], [50, 10], [50, 0], [50, -10], [50, -20], [50, -30], [50, -40]],angle = 120,location = [50, 50]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]],angle = 60,location = [2, 2]) == 3\n assert candidate(points = [[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]],angle = 90,location = [3, 3]) == 9\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],angle = 45,location = [5, 5]) == 6\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 30,location = [0, 0]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],angle = 60,location = [5, 1]) == 6\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70]],angle = 15,location = [10, 10]) == 7\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 30,location = [25, 25]) == 3\n assert candidate(points = [[100, 0], [0, 100], [100, 100], [50, 50], [25, 25], [75, 75]],angle = 60,location = [50, 50]) == 3\n assert candidate(points = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],angle = 180,location = [10, 5]) == 10\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [0, 0]],angle = 90,location = [0, 0]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0]],angle = 90,location = [5, 0]) == 7\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10]],angle = 15,location = [25, 10]) == 3\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],angle = 90,location = [3, 2]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 90,location = [30, 30]) == 3\n assert candidate(points = [[1, 0], [0, 1], [1, 1], [0, 0], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 90,location = [1, 1]) == 5\n assert candidate(points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 60,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 10,location = [5, 1]) == 5\n assert candidate(points = [[10, 10], [11, 11], [10, 11], [9, 10], [10, 9], [9, 9], [9, 11], [11, 9]],angle = 60,location = [10, 10]) == 3\n assert candidate(points = [[0, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 60,location = [3, 3]) == 5\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [10, 10], [10, 11], [11, 10], [11, 11]],angle = 90,location = [8, 8]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15]],angle = 45,location = [15, 15]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 3], [1, 3], [1, 3], [1, 4], [1, 4], [1, 4], [1, 5], [1, 5], [1, 5], [1, 1], [1, 1], [1, 1]],angle = 10,location = [1, 3]) == 12\n assert candidate(points = [[100, 0], [0, 100], [0, 0], [100, 100], [50, 50]],angle = 90,location = [50, 50]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8]],angle = 90,location = [6, 6]) == 5\n assert candidate(points = [[50, 50], [50, 49], [50, 51], [49, 50], [51, 50], [49, 49], [51, 51], [52, 52], [48, 48]],angle = 30,location = [50, 50]) == 3\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 5,location = [1, 5]) == 6\n assert candidate(points = [[2, 0], [0, 2], [2, 2], [1, 1], [0, 0], [1, 0]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[10, 0], [0, 10], [10, 10], [5, 5], [2, 2], [8, 8]],angle = 30,location = [5, 5]) == 3\n assert candidate(points = [[1, 1], [2, 1], [2, 2], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [4, 4]],angle = 45,location = [3, 3]) == 6\n assert candidate(points = [[1, 2], [2, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 120,location = [1, 1]) == 10\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 90,location = [0, 0]) == 10\n assert candidate(points = [[100, 100], [100, 99], [99, 100], [99, 98], [101, 100], [100, 101]],angle = 10,location = [100, 100]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 90,location = [1, 1]) == 15\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 45,location = [5, 5]) == 5\n assert candidate(points = [[10, 10], [20, 10], [15, 20], [10, 15], [15, 15]],angle = 30,location = [15, 15]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 90,location = [5, 5]) == 6\n assert candidate(points = [[10, 10], [10, 11], [11, 10], [11, 11], [10, 9], [9, 10], [9, 9], [9, 11], [11, 9]],angle = 60,location = [10, 10]) == 3\n assert candidate(points = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],angle = 10,location = [2, 2]) == 1\n assert candidate(points = [[10, 0], [0, 10], [10, 10], [0, 0], [5, 5]],angle = 60,location = [5, 5]) == 2\n assert candidate(points = [[50, 50], [50, 40], [50, 60], [40, 50], [60, 50], [40, 40], [60, 60], [40, 60], [60, 40], [50, 30], [50, 70], [30, 50], [70, 50]],angle = 60,location = [50, 50]) == 4\n assert candidate(points = [[10, 10], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10]],angle = 5,location = [5, 10]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 20,location = [1, 5]) == 6\n assert candidate(points = [[90, 90], [91, 90], [90, 91], [91, 91], [100, 100]],angle = 10,location = [90, 90]) == 3\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[10, 1], [1, 10], [10, 9], [9, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 60,location = [5, 5]) == 5\n assert candidate(points = [[5, 0], [5, 10], [10, 5], [0, 5]],angle = 180,location = [5, 5]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 3], [1, 3], [1, 3], [1, 4], [1, 4], [1, 4], [1, 5], [1, 5], [1, 5]],angle = 10,location = [1, 3]) == 9\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90]],angle = 10,location = [10, 50]) == 5\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],angle = 10,location = [5, 0]) == 6\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 180,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 5,location = [5, 1]) == 5\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],angle = 30,location = [5, 50]) == 6\n assert candidate(points = [[5, 0], [0, 5], [5, 5], [0, 0], [2, 2], [3, 3], [1, 1], [4, 4]],angle = 90,location = [2, 2]) == 5\n assert candidate(points = [[1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0], [10, 1]],angle = 15,location = [5, 0]) == 4\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7]],angle = 45,location = [5, 5]) == 4\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30]],angle = 30,location = [20, 20]) == 2\n assert candidate(points = [[1, 0], [2, 1], [1, 2], [0, 1], [0, 2], [1, 1], [2, 0], [2, 2], [0, 0]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0]],angle = 90,location = [2, 0]) == 4\n assert candidate(points = [[50, 50], [51, 50], [52, 50], [53, 50], [54, 50], [55, 50]],angle = 5,location = [52, 50]) == 4\n assert candidate(points = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 30], [10, 40], [20, 40]],angle = 180,location = [15, 15]) == 7\n assert candidate(points = [[100, 0], [0, 100], [50, 50], [25, 25], [75, 75]],angle = 45,location = [50, 50]) == 2\n assert candidate(points = [[1, 2], [2, 2], [4, 5], [5, 4], [3, 3], [2, 1]],angle = 45,location = [3, 3]) == 4\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],angle = 180,location = [5, 0]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 180,location = [5, 1]) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 90,location = [1, 5]) == 6\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],angle = 1,location = [5, 0]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],angle = 40,location = [50, 50]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 45,location = [1, 5]) == 6\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40]],angle = 90,location = [20, 20]) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],angle = 90,location = [3, 1]) == 6\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 60,location = [5, 5]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],angle = 45,location = [50, 50]) == 5\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9], [5, 4], [4, 5], [4, 4], [6, 4], [4, 6], [7, 6], [6, 7], [8, 6], [6, 8]],angle = 45,location = [5, 5]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 30,location = [1, 1]) == 10\n assert candidate(points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 1], [2, 1], [3, 1], [3, 1], [3, 1], [4, 1], [4, 1], [4, 1], [5, 1], [5, 1], [5, 1]],angle = 90,location = [3, 1]) == 9\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [10, 10], [10, 10]],angle = 45,location = [15, 15]) == 3\n assert candidate(points = [[2, 2], [3, 2], [4, 2], [2, 3], [3, 3], [4, 3], [2, 4], [3, 4], [4, 4]],angle = 45,location = [3, 3]) == 3\n", "comparison": "exact"}, "public_tests": ["[[2,1],[2,2],[3,3]]\n90\n[1,1]", "[[2,1],[2,2],[3,4],[1,1]]\n90\n[1,1]", "[[1,0],[2,1]]\n13\n[1,1]"], "hints": ["Sort the points by polar angle with the original position. Now only a consecutive collection of points would be visible from any coordinate.", "We can use two pointers to keep track of visible points for each start point", "For handling the cyclic condition, it’d be helpful to append the point list to itself after sorting."], "metadata": {"canonical_parameter_names": ["points", "angle", "location"], "leetcode_dataset_entry_point": "Solution().visiblePoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:20+00:00", "tests_total": 142, "tests_dropped": 6, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "math", "geometry", "sliding-window", "sorting"]}, "language": "python", "interface": {"raw_signature": "def visiblePoints(self, points: list[list[int]], angle: int, location: list[int]) -> int:", "container": "Solution", "callable": "visiblePoints", "parameters": [{"name": "points", "type": "list[list[int]]"}, {"name": "angle", "type": "int"}, {"name": "location", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1611, "task_id": "minimum-one-bit-operations-to-make-integers-zero", "difficulty": "Hard", "problem_description": "Given an integer n, you must transform it into 0 using the following operations any number of times:\n\n- Change the rightmost (0^th) bit in the binary representation of n.\n- Change the i^th bit in the binary representation of n if the (i-1)^th bit is set to 1 and the (i-2)^th through 0^th bits are set to 0.\n\nReturn the minimum number of operations to transform n into 0.\n\nExample 1:\n\nInput: n = 3\nOutput: 2\nExplanation: The binary representation of 3 is \"11\".\n\"11\" -> \"01\" with the 2^nd operation since the 0^th bit is 1.\n\"01\" -> \"00\" with the 1^st operation.\n\nExample 2:\n\nInput: n = 6\nOutput: 4\nExplanation: The binary representation of 6 is \"110\".\n\"110\" -> \"010\" with the 2^nd operation since the 1^st bit is 1 and 0^th through 0^th bits are 0.\n\"010\" -> \"011\" with the 1^st operation.\n\"011\" -> \"001\" with the 2^nd operation since the 0^th bit is 1.\n\"001\" -> \"000\" with the 1^st operation.\n\nConstraints:\n\n- 0 <= n <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 8) == 15\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 71\n assert candidate(n = 15) == 10\n assert candidate(n = 16) == 31\n assert candidate(n = 31) == 21\n assert candidate(n = 1000000000) == 756249599\n assert candidate(n = 32) == 63\n assert candidate(n = 6) == 4\n assert candidate(n = 1023) == 682\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 344\n assert candidate(n = 7) == 5\n assert candidate(n = 10) == 12\n assert candidate(n = 1024) == 2047\n assert candidate(n = 2097152) == 4194303\n assert candidate(n = 63) == 42\n assert candidate(n = 896) == 767\n assert candidate(n = 131071) == 87381\n assert candidate(n = 67108864) == 134217727\n assert candidate(n = 4096) == 8191\n assert candidate(n = 67108863) == 44739242\n assert candidate(n = 32767) == 21845\n assert candidate(n = 511) == 341\n assert candidate(n = 262143) == 174762\n assert candidate(n = 2047) == 1365\n assert candidate(n = 268435456) == 536870911\n assert candidate(n = 16383) == 10922\n assert candidate(n = 16384) == 32767\n assert candidate(n = 524287) == 349525\n assert candidate(n = 987654) == 662532\n assert candidate(n = 268435455) == 178956970\n assert candidate(n = 16777216) == 33554431\n assert candidate(n = 4194303) == 2796202\n assert candidate(n = 134217727) == 89478485\n assert candidate(n = 64) == 127\n assert candidate(n = 8388607) == 5592405\n assert candidate(n = 2097151) == 1398101\n assert candidate(n = 4194304) == 8388607\n assert candidate(n = 192) == 128\n assert candidate(n = 134217728) == 268435455\n assert candidate(n = 33554432) == 67108863\n assert candidate(n = 16777215) == 11184810\n assert candidate(n = 4095) == 2730\n assert candidate(n = 128) == 255\n assert candidate(n = 100000) == 66752\n assert candidate(n = 255) == 170\n assert candidate(n = 1048576) == 2097151\n assert candidate(n = 8192) == 16383\n assert candidate(n = 8191) == 5461\n assert candidate(n = 2048) == 4095\n assert candidate(n = 65536) == 131071\n assert candidate(n = 256) == 511\n assert candidate(n = 262144) == 524287\n assert candidate(n = 65535) == 43690\n assert candidate(n = 127) == 85\n assert candidate(n = 987654321) == 747917089\n assert candidate(n = 1048575) == 699050\n assert candidate(n = 500000000) == 378124799\n assert candidate(n = 536870911) == 357913941\n assert candidate(n = 1000000) == 687231\n assert candidate(n = 512) == 1023\n assert candidate(n = 123456789) == 93489638\n assert candidate(n = 1047552) == 698368\n assert candidate(n = 123456) == 82816\n assert candidate(n = 33554431) == 22369621\n assert candidate(n = 54321) == 38945\n", "comparison": "exact"}, "public_tests": ["3", "6"], "hints": ["The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit.", "consider n=2^k case first, then solve for all n."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minimumOneBitOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:22+00:00", "tests_total": 71, "tests_dropped": 3, "flags": [], "topic_tags": ["math", "dynamic-programming", "bit-manipulation", "recursion", "memoization"]}, "language": "python", "interface": {"raw_signature": "def minimumOneBitOperations(self, n: int) -> int:", "container": "Solution", "callable": "minimumOneBitOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1614, "task_id": "maximum-nesting-depth-of-the-parentheses", "difficulty": "Easy", "problem_description": "Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.\n\nExample 1:\n\nInput: s = \"(1+(2*3)+((8)/4))+1\"\nOutput: 3\nExplanation:\nDigit 8 is inside of 3 nested parentheses in the string.\n\nExample 2:\n\nInput: s = \"(1)+((2))+(((3)))\"\nOutput: 3\nExplanation:\nDigit 3 is inside of 3 nested parentheses in the string.\n\nExample 3:\n\nInput: s = \"()(())((()()))\"\nOutput: 3\n\nConstraints:\n\n- 1 <= s.length <= 100\n- s consists of digits 0-9 and characters '+', '-', '*', '/', '(', and ')'.\n- It is guaranteed that parentheses expression s is a VPS.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(1+(2*3)+((8)/4))+1\") == 3\n assert candidate(s = \"()()()\") == 1\n assert candidate(s = \"(1+2)\") == 1\n assert candidate(s = \"1+(2*3)\") == 1\n assert candidate(s = \"(())\") == 2\n assert candidate(s = \"((1+3)*(2-4))\") == 2\n assert candidate(s = \"(1)\") == 1\n assert candidate(s = \"((())()())\") == 3\n assert candidate(s = \"((1+2)*3/(4-5))\") == 2\n assert candidate(s = \"(1)+((2))+(((3)))\") == 3\n assert candidate(s = \"()(())((()()))\") == 3\n assert candidate(s = \"()\") == 1\n assert candidate(s = \"((()))\") == 3\n assert candidate(s = \"(1+(2*(((3+4)*5)+(6/(7*((8-9)+10))))))\") == 7\n assert candidate(s = \"(((((1+2)*(3+4))-((5+6)*(7+8)))+(((9+0)*(1+2))-((3+4)*(5+6))))\") == 5\n assert candidate(s = \"(1+(((2+((3+((4+((5+((6+((7+((8+((9+(10)))))))))))))))))))\") == 19\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7*(8+(9*(10)))))))))\") == 10\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7+(8+(9))))))))\") == 9\n assert candidate(s = \"(1+(2*((3+4)*(5+6)*((7+8)*(9+10))))+11)\") == 5\n assert candidate(s = \"(1+((2+((3+((4+((5+6)+7))+8))+9))+10)+11\") == 9\n assert candidate(s = \"((1+(2*(3+(4*(5+(6*(7+(8*(9))))))))+10)\") == 10\n assert candidate(s = \"(((((1+2)*3)+4)*5)+((6+(7*(8+9)))/10))\") == 5\n assert candidate(s = \"(1+(2+(3+(4+(5+(6+(7+(8+(9))))))))\") == 9\n assert candidate(s = \"(((1+2)*3)+((4+5)*(6/7)))+(((8+9)*((10-11)/12)))+13\") == 4\n assert candidate(s = \"(1+((2*((3+4)*(5-6)))/(7+(8*(9-10)))))\") == 5\n assert candidate(s = \"(1+((2+3)*(4/5)))+((6-(7+8))*(((9/10)-11)+(12*13)))\") == 4\n assert candidate(s = \"((1)+((2)+(((3)+((4)+(5)))+(6))))\") == 6\n assert candidate(s = \"((1+2)*((3/4)-5)+((6*7)+8))\") == 3\n assert candidate(s = \"((1+2)*((3+4)*((5+6)*((7+8)*((9+0))))))\") == 6\n assert candidate(s = \"(((((1+2)+3)+4)+5)+6)+7\") == 5\n assert candidate(s = \"(((((1+2)*3)+4)*5)+6)\") == 5\n assert candidate(s = \"((1+((2+3)*4))+(((5-6)+7)+((8+9)*10)))+(((11+(12*13))+14)+15)\") == 4\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7+(8+(9+0))))))))\") == 9\n assert candidate(s = \"((1+2)*((3+(4*(5+(6/7))))+((8-(9*10))+((11*12)+((13/14)+15))))\") == 6\n assert candidate(s = \"1+((2+(3*(4+5)))/6)+(((7-8)*9)/10)\") == 4\n assert candidate(s = \"(1+((2+(3*(4/5)))+((6-(7*8))))\") == 5\n assert candidate(s = \"(1+(2*((3+4)*(5+(6*(7+(8+9))))))+(10*((11-12)+(13*((14-15)+(16*(17+18))))))\") == 7\n assert candidate(s = \"(((((1+2)*3)+((4-5)*6))+(((7/8)+9)*10)))\") == 5\n assert candidate(s = \"(((((1)+2)*3)+(((((4)+5)*6)+((7)+8))))\") == 7\n assert candidate(s = \"(((1+2)*((3-4)+(5/6)))+(((7*8)-9)+((10+11)*12)))\") == 4\n assert candidate(s = \"(1+(2*(3+4)/(5-6))+((7+8)*9))\") == 3\n assert candidate(s = \"((((((((((1+2)+3)+4)+5)+6)+7)+8)+9)+10)\") == 10\n", "comparison": "exact"}, "public_tests": ["\"(1+(2*3)+((8)/4))+1\"", "\"(1)+((2))+(((3)))\"", "\"()(())((()()))\""], "hints": ["The depth of any character in the VPS is the ( number of left brackets before it ) - ( number of right brackets before it )"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxDepth", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:24+00:00", "tests_total": 101, "tests_dropped": 59, "flags": [], "topic_tags": ["string", "stack", "bracket-sequences"]}, "language": "python", "interface": {"raw_signature": "def maxDepth(self, s: str) -> int:", "container": "Solution", "callable": "maxDepth", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1615, "task_id": "maximal-network-rank", "difficulty": "Medium", "problem_description": "There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [a_i, b_i] indicates that there is a bidirectional road between cities a_i and b_i.\n\nThe network rank of two different cities is defined as the total number of directly connected roads to either city. If a road is directly connected to both cities, it is only counted once.\n\nThe maximal network rank of the infrastructure is the maximum network rank of all pairs of different cities.\n\nGiven the integer n and the array roads, return the maximal network rank of the entire infrastructure.\n\nExample 1:\n\nInput: n = 4, roads = [[0,1],[0,3],[1,2],[1,3]]\nOutput: 4\nExplanation: The network rank of cities 0 and 1 is 4 as there are 4 roads that are connected to either 0 or 1. The road between 0 and 1 is only counted once.\n\nExample 2:\n\nInput: n = 5, roads = [[0,1],[0,3],[1,2],[1,3],[2,3],[2,4]]\nOutput: 5\nExplanation: There are 5 roads that are connected to cities 1 or 2.\n\nExample 3:\n\nInput: n = 8, roads = [[0,1],[1,2],[2,3],[2,4],[5,6],[5,7]]\nOutput: 5\nExplanation: The network rank of 2 and 5 is 5. Notice that all the cities do not have to be connected.\n\nConstraints:\n\n- 2 <= n <= 100\n- 0 <= roads.length <= n * (n - 1) / 2\n- roads[i].length == 2\n- 0 <= a_i, b_i <= n-1\n- a_i != b_i\n- Each pair of cities has at most one road connecting them.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,roads = [[0, 1], [0, 3], [1, 2], [1, 3]]) == 4\n assert candidate(n = 100,roads = []) == 0\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9\n assert candidate(n = 5,roads = [[0, 1], [0, 3], [1, 2], [1, 3], [2, 3], [2, 4]]) == 5\n assert candidate(n = 3,roads = [[0, 1], [1, 2]]) == 2\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 2\n assert candidate(n = 10,roads = []) == 0\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [2, 4], [5, 6], [5, 7]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 4\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [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]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14]]) == 5\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 12], [12, 13], [13, 14]]) == 6\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]]) == 14\n assert candidate(n = 40,roads = [[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]]) == 6\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6]]) == 11\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9]]) == 7\n assert candidate(n = 60,roads = [[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]]) == 2\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [18, 19]]) == 4\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 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]]) == 7\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]]) == 7\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 7\n assert candidate(n = 70,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], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 13]]) == 10\n assert candidate(n = 15,roads = [[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]]) == 8\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]]) == 6\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], [0, 19]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [11, 12], [13, 14]]) == 5\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]]) == 4\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(n = 20,roads = [[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]]) == 8\n assert candidate(n = 30,roads = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 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]]) == 5\n assert candidate(n = 25,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [3, 13], [3, 14], [4, 15], [4, 16], [5, 17], [5, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]) == 9\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 5\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [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], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14]]) == 7\n assert candidate(n = 20,roads = [[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]]) == 8\n assert candidate(n = 60,roads = [[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]]) == 6\n", "comparison": "exact"}, "public_tests": ["4\n[[0,1],[0,3],[1,2],[1,3]]", "5\n[[0,1],[0,3],[1,2],[1,3],[2,3],[2,4]]", "8\n[[0,1],[1,2],[2,3],[2,4],[5,6],[5,7]]"], "hints": ["Try every pair of different cities and calculate its network rank.", "The network rank of two vertices is almost the sum of their degrees.", "How can you efficiently check if there is a road connecting two different cities?"], "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().maximalNetworkRank", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:26+00:00", "tests_total": 40, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["graph"]}, "language": "python", "interface": {"raw_signature": "def maximalNetworkRank(self, n: int, roads: list[list[int]]) -> int:", "container": "Solution", "callable": "maximalNetworkRank", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1616, "task_id": "split-two-strings-to-make-palindrome", "difficulty": "Medium", "problem_description": "You are given two strings a and b of the same length. Choose an index and split both strings at the same index, splitting a into two strings: a_prefix and a_suffix where a = a_prefix + a_suffix, and splitting b into two strings: b_prefix and b_suffix where b = b_prefix + b_suffix. Check if a_prefix + b_suffix or b_prefix + a_suffix forms a palindrome.\n\nWhen you split a string s into s_prefix and s_suffix, either s_suffix or s_prefix is allowed to be empty. For example, if s = \"abc\", then \"\" + \"abc\", \"a\" + \"bc\", \"ab\" + \"c\" , and \"abc\" + \"\" are valid splits.\n\nReturn true if it is possible to form a palindrome string, otherwise return false.\n\nNotice that x + y denotes the concatenation of strings x and y.\n\nExample 1:\n\nInput: a = \"x\", b = \"y\"\nOutput: true\nExplaination: If either a or b are palindromes the answer is true since you can split in the following way:\na_prefix = \"\", a_suffix = \"x\"\nb_prefix = \"\", b_suffix = \"y\"\nThen, a_prefix + b_suffix = \"\" + \"y\" = \"y\", which is a palindrome.\n\nExample 2:\n\nInput: a = \"xbdef\", b = \"xecab\"\nOutput: false\n\nExample 3:\n\nInput: a = \"ulacfd\", b = \"jizalu\"\nOutput: true\nExplaination: Split them at index 3:\na_prefix = \"ula\", a_suffix = \"cfd\"\nb_prefix = \"jiz\", b_suffix = \"alu\"\nThen, a_prefix + b_suffix = \"ula\" + \"alu\" = \"ulaalu\", which is a palindrome.\n\nConstraints:\n\n- 1 <= a.length, b.length <= 10^5\n- a.length == b.length\n- a and b consist of lowercase English letters\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"abcdefg\",b = \"gfedcba\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbbdd\") == True\n assert candidate(a = \"ulacfd\",b = \"jizalu\") == True\n assert candidate(a = \"aabbaa\",b = \"aabbaa\") == True\n assert candidate(a = \"abba\",b = \"abba\") == True\n assert candidate(a = \"abcba\",b = \"abcba\") == True\n assert candidate(a = \"x\",b = \"y\") == True\n assert candidate(a = \"xbdef\",b = \"xecab\") == False\n assert candidate(a = \"abccba\",b = \"abccba\") == True\n assert candidate(a = \"noon\",b = \"noon\") == True\n assert candidate(a = \"race\",b = \"ecar\") == True\n assert candidate(a = \"abcd\",b = \"dcba\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbbaa\") == True\n assert candidate(a = \"abc\",b = \"def\") == False\n assert candidate(a = \"abcde\",b = \"edcba\") == True\n assert candidate(a = \"abacaba\",b = \"bacabab\") == True\n assert candidate(a = \"rotor\",b = \"rotor\") == True\n assert candidate(a = \"abcdedcba\",b = \"afghihgfa\") == True\n assert candidate(a = \"abcdefghijk\",b = \"kjihgfedcba\") == True\n assert candidate(a = \"xyzzzzzxy\",b = \"yxzzzzzxy\") == True\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaedcbadcb\") == False\n assert candidate(a = \"aaaaabaaaa\",b = \"bbbbabbbbb\") == False\n assert candidate(a = \"rotorabc\",b = \"abcrotor\") == True\n assert candidate(a = \"abcdexyzabc\",b = \"cbazyxcdeba\") == True\n assert candidate(a = \"abcdefgxyz\",b = \"zyxgfedcba\") == True\n assert candidate(a = \"abcdef\",b = \"fedcba\") == True\n assert candidate(a = \"abcdefgh\",b = \"hgfedcba\") == True\n assert candidate(a = \"xyzzxy\",b = \"yxzzyx\") == True\n assert candidate(a = \"mnopqr\",b = \"rqponm\") == True\n assert candidate(a = \"abcdefghij\",b = \"utvwxzyabc\") == False\n assert candidate(a = \"levelupx\",b = \"xyzlevol\") == False\n assert candidate(a = \"abcdxyzabc\",b = \"cbazyxdcba\") == True\n assert candidate(a = \"abcxxy\",b = \"yxxcba\") == True\n assert candidate(a = \"abcdeedcba\",b = \"zzzzzzzzzz\") == True\n assert candidate(a = \"abcdedcba\",b = \"xyzdedcba\") == True\n assert candidate(a = \"abcdefg\",b = \"hgfedcb\") == False\n assert candidate(a = \"aabbccddeeefffggg\",b = \"gggfffeeeddccbbaa\") == True\n assert candidate(a = \"abcdefghij\",b = \"jihgfedcba\") == True\n assert candidate(a = \"redivider\",b = \"repaidred\") == True\n assert candidate(a = \"aabbccddeeaabbccddee\",b = \"eeddccbbaaeeddccbbaa\") == True\n assert candidate(a = \"noon\",b = \"moon\") == True\n assert candidate(a = \"abababab\",b = \"babababa\") == True\n assert candidate(a = \"zxcvbnm\",b = \"mlkjihg\") == False\n assert candidate(a = \"qwertyuiop\",b = \"poiuytrewq\") == True\n assert candidate(a = \"zzzzzzzzzzz\",b = \"aaaaaaaaaaa\") == True\n assert candidate(a = \"abcdex\",b = \"xcdeba\") == False\n assert candidate(a = \"zyxwvutsrqponmlkjihgfedcba\",b = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(a = \"abccba\",b = \"abcdef\") == True\n assert candidate(a = \"abccba\",b = \"xyzzyx\") == True\n assert candidate(a = \"aabbccdd\",b = \"aabbccdd\") == False\n assert candidate(a = \"abcdabc\",b = \"cbadacb\") == True\n assert candidate(a = \"xyxzyxzyx\",b = \"yzxzyxzyz\") == False\n assert candidate(a = \"abcdexyz\",b = \"zyxcdeba\") == False\n assert candidate(a = \"abacaba\",b = \"zzzazzz\") == True\n assert candidate(a = \"aabbccdd\",b = \"ddeebbaa\") == True\n assert candidate(a = \"abcdefghij\",b = \"abcdefghij\") == False\n assert candidate(a = \"aaaa\",b = \"bbbb\") == True\n assert candidate(a = \"abacdfgdcaba\",b = \"abacdgfdcaba\") == True\n assert candidate(a = \"abcdeabcde\",b = \"edcbaedcba\") == True\n assert candidate(a = \"madam\",b = \"refer\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbaab\") == True\n assert candidate(a = \"abracadabra\",b = \"arbadacarba\") == True\n assert candidate(a = \"abcddcba\",b = \"efghihgf\") == True\n assert candidate(a = \"aaaabaaa\",b = \"bbbbbabb\") == False\n assert candidate(a = \"abacdfgdcaba\",b = \"abaffghffaba\") == False\n assert candidate(a = \"abacabad\",b = \"daadacab\") == False\n assert candidate(a = \"abcdexyz\",b = \"zyxeabcd\") == True\n assert candidate(a = \"abccba\",b = \"defedf\") == True\n assert candidate(a = \"xyzyx\",b = \"xzyzx\") == True\n assert candidate(a = \"palindrome\",b = \"emordnilap\") == True\n assert candidate(a = \"tacocat\",b = \"racecar\") == True\n assert candidate(a = \"abcdef\",b = \"ghijkl\") == False\n assert candidate(a = \"aaaabbbb\",b = \"bbbbaaaa\") == True\n assert candidate(a = \"abcdefghihgfedcba\",b = \"abcdefghihgfedcba\") == True\n assert candidate(a = \"aabbccddeeff\",b = \"ffeeddccbbaa\") == True\n assert candidate(a = \"abcdexyzabcd\",b = \"dcbaxyzedcba\") == False\n assert candidate(a = \"abacabadabacaba\",b = \"abacabadabacaba\") == True\n assert candidate(a = \"abcabcabcabc\",b = \"cbacbacbacba\") == True\n assert candidate(a = \"abcxxa\",b = \"bxxcba\") == True\n assert candidate(a = \"aaaaaaabbbbb\",b = \"bbbbbaaaaaaa\") == True\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaabcdabcd\") == False\n assert candidate(a = \"aaaaaaa\",b = \"bbbbbbb\") == True\n assert candidate(a = \"abab\",b = \"baba\") == True\n assert candidate(a = \"abcdabcd\",b = \"dcbaabcd\") == True\n assert candidate(a = \"aabbcc\",b = \"zzxxzz\") == True\n assert candidate(a = \"abcdexyz\",b = \"zyxwvuts\") == False\n", "comparison": "exact"}, "public_tests": ["\"x\"\n\"y\"", "\"xbdef\"\n\"xecab\"", "\"ulacfd\"\n\"jizalu\""], "hints": ["Try finding the largest prefix from a that matches a suffix in b", "Try string matching"], "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().checkPalindromeFormation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:29+00:00", "tests_total": 126, "tests_dropped": 40, "flags": [], "topic_tags": ["two-pointers", "string"]}, "language": "python", "interface": {"raw_signature": "def checkPalindromeFormation(self, a: str, b: str) -> bool:", "container": "Solution", "callable": "checkPalindromeFormation", "parameters": [{"name": "a", "type": "str"}, {"name": "b", "type": "str"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1617, "task_id": "count-subtrees-with-max-distance-between-cities", "difficulty": "Hard", "problem_description": "There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [u_i, v_i] represents a bidirectional edge between cities u_i and v_i. There exists a unique path between each pair of cities. In other words, the cities form a tree.\n\nA subtree is a subset of cities where every city is reachable from every other city in the subset, where the path between each pair passes through only the cities from the subset. Two subtrees are different if there is a city in one subtree that is not present in the other.\n\nFor each d from 1 to n-1, find the number of subtrees in which the maximum distance between any two cities in the subtree is equal to d.\n\nReturn an array of size n-1 where the d^th element (1-indexed) is the number of subtrees in which the maximum distance between any two cities is equal to d.\n\nNotice that the distance between the two cities is the number of edges in the path between them.\n\nExample 1:\n\nInput: n = 4, edges = [[1,2],[2,3],[2,4]]\nOutput: [3,4,0]\nExplanation:\nThe subtrees with subsets {1,2}, {2,3} and {2,4} have a max distance of 1.\nThe subtrees with subsets {1,2,3}, {1,2,4}, {2,3,4} and {1,2,3,4} have a max distance of 2.\nNo subtree has two nodes where the max distance between them is 3.\n\nExample 2:\n\nInput: n = 2, edges = [[1,2]]\nOutput: [1]\n\nExample 3:\n\nInput: n = 3, edges = [[1,2],[2,3]]\nOutput: [2,1]\n\nConstraints:\n\n- 2 <= n <= 15\n- edges.length == n-1\n- edges[i].length == 2\n- 1 <= u_i, v_i <= n\n- All pairs (u_i, v_i) are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [5, 8, 9, 0, 0]\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [4, 3, 2, 1]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10]]) == [9, 14, 18, 26, 33, 0, 0, 0, 0]\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == [6, 7, 9, 7, 0, 0]\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6]]) == [5, 6, 4, 3, 0]\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]]) == [4, 11, 0, 0]\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [2, 4], [2, 5]]) == [4, 5, 3, 0]\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [2, 4]]) == [3, 4, 0]\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == [2, 1]\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [5, 6]]) == [5, 4, 3, 2, 1]\n assert candidate(n = 2,edges = [[1, 2]]) == [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]]) == [11, 16, 24, 33, 48, 55, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [8, 9, 9, 9, 7, 4, 2, 0]\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]]) == [10, 17, 24, 48, 63, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == [8, 13, 15, 15, 18, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [7, 13]]) == [12, 19, 30, 43, 66, 121, 0, 0, 0, 0, 0, 0]\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]]) == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\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]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\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]]) == [13, 38, 70, 649, 308, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [10, 13, 18, 23, 30, 25, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [6, 13]]) == [12, 29, 49, 120, 259, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [7, 6, 5, 4, 3, 2, 1]\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]]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 14,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]]) == [13, 22, 36, 65, 96, 231, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8]]) == [7, 10, 9, 11, 6, 0, 0]\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == [6, 9, 6, 9, 0, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11]]) == [10, 15, 21, 28, 39, 22, 0, 0, 0, 0]\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], [5, 12]]) == [11, 20, 36, 99, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [8, 13, 21, 39, 0, 0, 0, 0]\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]]) == [14, 25, 48, 168, 483, 210, 0, 0, 0, 0, 0, 0, 0, 0]\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]]) == [14, 25, 42, 87, 126, 441, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8]]) == [7, 10, 9, 11, 6, 0, 0]\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]]) == [11, 18, 27, 50, 69, 42, 0, 0, 0, 0, 0]\n assert candidate(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [5, 4, 3, 2, 1]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [9, 16, 27, 81, 0, 0, 0, 0, 0]\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], [6, 13]]) == [12, 21, 33, 54, 81, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == [11, 14, 19, 26, 35, 34, 15, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == [7, 8, 10, 10, 5, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9]]) == [8, 17, 13, 23, 14, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]]) == [8, 11, 12, 16, 15, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == [11, 20, 36, 99, 126, 0, 0, 0, 0, 0, 0]\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]]) == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9]]) == [8, 13, 21, 24, 12, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 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]]) == [14, 45, 154, 1995, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n", "comparison": "exact"}, "public_tests": ["4\n[[1,2],[2,3],[2,4]]", "2\n[[1,2]]", "3\n[[1,2],[2,3]]"], "hints": ["Iterate through every possible subtree by doing a bitmask on which vertices to include. How can you determine if a subtree is valid (all vertices are connected)?", "To determine connectivity, count the number of reachable vertices starting from any included vertex and only traveling on edges connecting 2 vertices in the subtree. The count should be the same as the number of 1s in the bitmask.", "The diameter is basically the maximum distance between any two nodes. Root the tree at a vertex. The answer is the max of the heights of the two largest subtrees or the longest diameter in any of the subtrees."], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countSubgraphsForEachDiameter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:31+00:00", "tests_total": 45, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["dynamic-programming", "bit-manipulation", "tree", "enumeration", "bitmask"]}, "language": "python", "interface": {"raw_signature": "def countSubgraphsForEachDiameter(self, n: int, edges: List[List[int]]) -> List[int]:", "container": "Solution", "callable": "countSubgraphsForEachDiameter", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "List[List[int]]"}], "return_type": "List[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1619, "task_id": "mean-of-array-after-removing-some-elements", "difficulty": "Easy", "problem_description": "Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements.\n\nAnswers within 10^-5 of the actual answer will be considered accepted.\n\nExample 1:\n\nInput: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]\nOutput: 2.00000\nExplanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so the mean is 2.\n\nExample 2:\n\nInput: arr = [6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]\nOutput: 4.00000\n\nExample 3:\n\nInput: arr = [6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]\nOutput: 4.77778\n\nConstraints:\n\n- 20 <= arr.length <= 1000\n- arr.length is a multiple of 20.\n- 0 <= arr[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(arr=[6, 0, 7, 0, 7, 5, 7, 8, 3, 4, 0, 7, 8, 1, 6, 8, 1, 1, 2, 4, 8, 1, 9, 5, 4, 3, 8, 5, 10, 8, 6, 6, 1, 0, 6, 10, 8, 2, 3, 4]), 4.77778)\n assert answers_match(candidate(arr=[1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]), 2.0)\n assert answers_match(candidate(arr=[6, 2, 7, 5, 1, 2, 0, 3, 10, 2, 5, 0, 5, 5, 0, 8, 7, 6, 8, 0]), 4.0)\n assert answers_match(candidate(arr=[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]), 105.0)\n assert answers_match(candidate(arr=[1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981]), 50000.5)\n assert answers_match(candidate(arr=[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]), 205.0)\n assert answers_match(candidate(arr=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]), 475.0)\n assert answers_match(candidate(arr=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000]), 505.0)\n assert answers_match(candidate(arr=[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]), 69.5)\n assert answers_match(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, 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]), 10.5)\n assert answers_match(candidate(arr=[100000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100000]), 5555.55556)\n assert answers_match(candidate(arr=[50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]), 50000.0)\n assert answers_match(candidate(arr=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]), 13.01852)\n assert answers_match(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]), 20.5)\n assert answers_match(candidate(arr=[100000, 0, 50000, 25000, 75000, 30000, 80000, 10000, 90000, 40000, 60000, 20000, 95000, 55000, 85000, 15000, 99000, 65000, 70000, 35000, 100000, 0, 50000, 25000, 75000, 30000, 80000, 10000, 90000, 40000, 60000, 20000, 95000, 55000, 85000, 15000, 99000, 65000, 70000, 35000]), 55500.0)\n assert answers_match(candidate(arr=[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]), 100.0)\n assert answers_match(candidate(arr=[15, 22, 10, 27, 18, 35, 40, 50, 60, 5, 90, 80, 75, 45, 30, 25, 65, 70, 100, 55]), 45.11111)\n assert answers_match(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, 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]), 50.5)\n assert answers_match(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]), 20.5)\n", "comparison": "float"}, "public_tests": ["[1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]", "[6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]", "[6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]"], "hints": ["Sort the given array.", "Remove the first and last 5% of the sorted array."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().trimMean", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:33+00:00", "tests_total": 50, "tests_dropped": 31, "flags": ["decimal_answer"], "topic_tags": ["array", "sorting"]}, "language": "python", "interface": {"raw_signature": "def trimMean(self, arr: list[int]) -> float:", "container": "Solution", "callable": "trimMean", "parameters": [{"name": "arr", "type": "list[int]"}], "return_type": "float", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1620, "task_id": "coordinate-with-maximum-network-quality", "difficulty": "Medium", "problem_description": "You are given an array of network towers towers, where towers[i] = [x_i, y_i, q_i] denotes the i^th network tower with location (x_i, y_i) and quality factor q_i. All the coordinates are integral coordinates on the X-Y plane, and the distance between the two coordinates is the Euclidean distance.\n\nYou are also given an integer radius where a tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable.\n\nThe signal quality of the i^th tower at a coordinate (x, y) is calculated with the formula ⌊q_i / (1 + d)⌋, where d is the distance between the tower and the coordinate. The network quality at a coordinate is the sum of the signal qualities from all the reachable towers.\n\nReturn the array [c_x, c_y] representing the integral coordinate (c_x, c_y) where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum non-negative coordinate.\n\nNote:\n\n- A coordinate (x1, y1) is lexicographically smaller than (x2, y2) if either:\n - x1 < x2, or\n - x1 == x2 and y1 < y2.\n- ⌊val⌋ is the greatest integer less than or equal to val (the floor function).\n\nExample 1:\n\nInput: towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2\nOutput: [2,1]\nExplanation: At coordinate (2, 1) the total quality is 13.\n- Quality of 7 from (2, 1) results in ⌊7 / (1 + sqrt(0)⌋ = ⌊7⌋ = 7\n- Quality of 5 from (1, 2) results in ⌊5 / (1 + sqrt(2)⌋ = ⌊2.07⌋ = 2\n- Quality of 9 from (3, 1) results in ⌊9 / (1 + sqrt(1)⌋ = ⌊4.5⌋ = 4\nNo other coordinate has a higher network quality.\n\nExample 2:\n\nInput: towers = [[23,11,21]], radius = 9\nOutput: [23,11]\nExplanation: Since there is only one tower, the network quality is highest right at the tower's location.\n\nExample 3:\n\nInput: towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2\nOutput: [1,2]\nExplanation: Coordinate (1, 2) has the highest network quality.\n\nConstraints:\n\n- 1 <= towers.length <= 50\n- towers[i].length == 3\n- 0 <= x_i, y_i, q_i <= 50\n- 1 <= radius <= 50\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(towers = [[23, 11, 21]],radius = 9) == [23, 11]\n assert candidate(towers = [[5, 5, 15], [6, 6, 20], [7, 7, 25]],radius = 3) == [6, 6]\n assert candidate(towers = [[1, 2, 5], [2, 1, 7], [3, 1, 9]],radius = 2) == [2, 1]\n assert candidate(towers = [[0, 0, 10], [1, 1, 20], [2, 2, 30]],radius = 1) == [2, 2]\n assert candidate(towers = [[5, 5, 5], [5, 6, 5], [6, 5, 5], [6, 6, 5]],radius = 1) == [5, 5]\n assert candidate(towers = [[0, 0, 10], [5, 5, 20], [10, 10, 30]],radius = 15) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [1, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[10, 0, 10], [0, 10, 10], [10, 10, 10]],radius = 15) == [0, 10]\n assert candidate(towers = [[0, 0, 10], [5, 5, 5]],radius = 6) == [0, 0]\n assert candidate(towers = [[0, 0, 10], [10, 10, 20]],radius = 15) == [10, 10]\n assert candidate(towers = [[10, 10, 5], [15, 15, 10], [20, 20, 15]],radius = 10) == [20, 20]\n assert candidate(towers = [[1, 2, 13], [2, 1, 7], [0, 1, 9]],radius = 2) == [1, 2]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1]],radius = 1) == [1, 1]\n assert candidate(towers = [[0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1], [2, 2, 1], [2, 3, 1], [3, 2, 1], [3, 3, 1]],radius = 2) == [0, 0]\n assert candidate(towers = [[10, 10, 20], [15, 15, 10], [20, 20, 5], [5, 5, 15]],radius = 10) == [10, 10]\n assert candidate(towers = [[5, 5, 10], [15, 15, 20], [25, 25, 30], [35, 35, 40], [45, 45, 50]],radius = 10) == [45, 45]\n assert candidate(towers = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],radius = 1) == [13, 14]\n assert candidate(towers = [[2, 2, 5], [4, 4, 10], [6, 6, 15], [8, 8, 20], [10, 10, 25], [12, 12, 30], [14, 14, 35]],radius = 7) == [12, 12]\n assert candidate(towers = [[10, 10, 1], [10, 11, 2], [10, 12, 3], [10, 13, 4], [10, 14, 5]],radius = 4) == [10, 14]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 10) == [25, 25]\n assert candidate(towers = [[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]],radius = 2) == [7, 0]\n assert candidate(towers = [[1, 2, 5], [2, 1, 7], [3, 1, 9], [4, 3, 12], [5, 2, 8]],radius = 3) == [3, 1]\n assert candidate(towers = [[1, 1, 1], [1, 2, 1], [1, 3, 1], [2, 1, 1], [2, 2, 1], [2, 3, 1], [3, 1, 1], [3, 2, 1], [3, 3, 1]],radius = 1) == [1, 1]\n assert candidate(towers = [[1, 1, 5], [1, 2, 5], [2, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5]],radius = 2) == [2, 2]\n assert candidate(towers = [[10, 10, 50], [20, 10, 40], [10, 20, 30], [20, 20, 20], [10, 30, 10], [20, 30, 5]],radius = 15) == [10, 10]\n assert candidate(towers = [[10, 10, 50], [20, 20, 50], [30, 30, 50], [40, 40, 50], [50, 50, 50]],radius = 20) == [20, 20]\n assert candidate(towers = [[25, 25, 50], [10, 10, 30], [40, 40, 20], [30, 30, 40], [15, 15, 25], [45, 45, 10]],radius = 12) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [15, 15, 15], [25, 25, 20], [35, 35, 25], [45, 45, 30]],radius = 15) == [45, 45]\n assert candidate(towers = [[25, 25, 50], [24, 25, 49], [26, 25, 48], [25, 24, 47], [25, 26, 46], [24, 24, 45], [24, 26, 44], [26, 24, 43], [26, 26, 42]],radius = 2) == [25, 25]\n assert candidate(towers = [[0, 0, 10], [0, 10, 20], [10, 0, 30], [10, 10, 40], [5, 5, 50]],radius = 15) == [5, 5]\n assert candidate(towers = [[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]],radius = 1) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 1], [0, 2, 1], [1, 2, 1], [2, 0, 1], [2, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[5, 5, 50], [10, 10, 50], [15, 15, 50], [20, 20, 50], [25, 25, 50]],radius = 5) == [5, 5]\n assert candidate(towers = [[0, 0, 1], [0, 1, 1], [0, 2, 1], [1, 0, 1], [1, 1, 1], [1, 2, 1], [2, 0, 1], [2, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[10, 10, 10], [20, 10, 20], [30, 10, 30], [40, 10, 40], [50, 10, 50], [10, 20, 50], [20, 20, 40], [30, 20, 30], [40, 20, 20], [50, 20, 10]],radius = 10) == [10, 20]\n assert candidate(towers = [[1, 1, 5], [1, 2, 5], [1, 3, 5], [2, 1, 5], [2, 2, 5], [2, 3, 5], [3, 1, 5], [3, 2, 5], [3, 3, 5]],radius = 2) == [2, 2]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40]],radius = 5) == [4, 4]\n assert candidate(towers = [[25, 25, 50], [24, 24, 40], [23, 23, 30], [22, 22, 20], [21, 21, 10], [20, 20, 5]],radius = 6) == [24, 24]\n assert candidate(towers = [[1, 2, 5], [3, 4, 5], [5, 6, 5], [7, 8, 5], [9, 10, 5]],radius = 5) == [3, 4]\n assert candidate(towers = [[25, 25, 10], [30, 30, 20], [35, 35, 30], [40, 40, 40], [45, 45, 50]],radius = 15) == [45, 45]\n assert candidate(towers = [[5, 5, 10], [10, 5, 10], [5, 10, 10], [10, 10, 10], [2, 2, 10], [8, 8, 10], [2, 8, 10], [8, 2, 10]],radius = 5) == [8, 8]\n assert candidate(towers = [[5, 5, 10], [10, 5, 20], [5, 10, 20], [10, 10, 30], [15, 15, 40], [20, 20, 50]],radius = 10) == [20, 20]\n assert candidate(towers = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [2, 1, 4], [2, 2, 5], [2, 3, 6], [3, 1, 7], [3, 2, 8], [3, 3, 9]],radius = 1) == [3, 2]\n assert candidate(towers = [[3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12], [15, 15, 15]],radius = 5) == [15, 15]\n assert candidate(towers = [[10, 10, 30], [20, 20, 20], [30, 30, 10], [40, 40, 5]],radius = 10) == [10, 10]\n assert candidate(towers = [[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]],radius = 2) == [1, 1]\n assert candidate(towers = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [0, 0, 0], [5, 5, 5], [15, 15, 15]],radius = 10) == [50, 50]\n assert candidate(towers = [[10, 10, 20], [20, 20, 30], [15, 15, 15], [5, 5, 10]],radius = 10) == [20, 20]\n assert candidate(towers = [[5, 10, 5], [10, 5, 10], [15, 10, 15], [20, 5, 20], [25, 10, 25]],radius = 5) == [25, 10]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 15) == [25, 25]\n assert candidate(towers = [[5, 5, 20], [10, 10, 15], [15, 15, 10], [20, 20, 5], [25, 25, 1]],radius = 12) == [5, 5]\n assert candidate(towers = [[2, 3, 15], [5, 5, 10], [8, 7, 8], [10, 10, 20]],radius = 5) == [10, 10]\n assert candidate(towers = [[5, 0, 5], [10, 0, 5], [15, 0, 5], [20, 0, 5], [25, 0, 5]],radius = 10) == [5, 0]\n assert candidate(towers = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [1, 0, 4], [1, 1, 5], [1, 2, 6], [2, 0, 7], [2, 1, 8], [2, 2, 9]],radius = 2) == [1, 1]\n assert candidate(towers = [[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]],radius = 2) == [8, 8]\n assert candidate(towers = [[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]],radius = 2) == [1, 1]\n assert candidate(towers = [[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]],radius = 5) == [9, 9]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40]],radius = 3) == [4, 4]\n assert candidate(towers = [[10, 10, 10], [20, 10, 20], [30, 10, 30], [10, 20, 20], [20, 20, 30], [30, 20, 40]],radius = 10) == [30, 20]\n assert candidate(towers = [[10, 10, 50], [20, 20, 50], [30, 30, 50], [40, 40, 50], [50, 50, 50]],radius = 5) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6]],radius = 2) == [4, 4]\n assert candidate(towers = [[10, 10, 10], [20, 20, 20], [15, 15, 15], [25, 25, 5]],radius = 10) == [20, 20]\n assert candidate(towers = [[0, 0, 1], [10, 0, 2], [20, 0, 3], [30, 0, 4], [40, 0, 5], [50, 0, 6]],radius = 15) == [50, 0]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50]],radius = 2) == [4, 4]\n assert candidate(towers = [[0, 0, 10], [50, 0, 10], [0, 50, 10], [50, 50, 10], [25, 25, 15]],radius = 20) == [25, 25]\n assert candidate(towers = [[0, 0, 50], [50, 0, 50], [50, 50, 50], [0, 50, 50], [25, 25, 50], [25, 0, 40], [25, 50, 40], [0, 25, 40], [50, 25, 40]],radius = 25) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 10) == [25, 25]\n assert candidate(towers = [[10, 10, 50], [11, 10, 45], [12, 10, 40], [13, 10, 35], [14, 10, 30]],radius = 4) == [11, 10]\n assert candidate(towers = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [2, 1, 2], [2, 2, 4], [2, 3, 2], [3, 1, 3], [3, 2, 2], [3, 3, 1]],radius = 1) == [2, 2]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6]],radius = 2) == [4, 4]\n assert candidate(towers = [[10, 10, 50], [20, 20, 30], [30, 30, 10], [0, 0, 20]],radius = 15) == [10, 10]\n assert candidate(towers = [[25, 25, 50], [25, 26, 45], [26, 25, 40], [26, 26, 35], [24, 24, 30]],radius = 3) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [1, 0, 2], [0, 1, 2], [1, 1, 3], [2, 2, 4], [3, 3, 5], [4, 4, 6], [5, 5, 7], [6, 6, 8]],radius = 1) == [6, 6]\n assert candidate(towers = [[2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25]],radius = 2) == [5, 5]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],radius = 3) == [4, 4]\n assert candidate(towers = [[50, 50, 50], [40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10]],radius = 10) == [50, 50]\n assert candidate(towers = [[0, 0, 5], [5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5]],radius = 8) == [0, 0]\n assert candidate(towers = [[0, 0, 10], [10, 0, 10], [0, 10, 10], [10, 10, 10], [5, 5, 20]],radius = 10) == [5, 5]\n assert candidate(towers = [[20, 20, 30], [25, 25, 20], [15, 15, 40]],radius = 10) == [15, 15]\n assert candidate(towers = [[1, 1, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 1, 10], [2, 2, 10], [2, 3, 10], [2, 4, 10], [3, 1, 10], [3, 2, 10], [3, 3, 10], [3, 4, 10], [4, 1, 10], [4, 2, 10], [4, 3, 10], [4, 4, 10]],radius = 3) == [2, 2]\n assert candidate(towers = [[25, 25, 25], [30, 30, 30], [20, 20, 20], [15, 15, 15], [5, 5, 5], [10, 10, 10]],radius = 5) == [30, 30]\n assert candidate(towers = [[0, 0, 5], [0, 10, 5], [10, 0, 5], [10, 10, 5], [5, 5, 10]],radius = 5) == [5, 5]\n assert candidate(towers = [[3, 3, 9], [6, 6, 12], [9, 9, 15], [12, 12, 18], [15, 15, 21]],radius = 5) == [12, 12]\n assert candidate(towers = [[10, 10, 20], [20, 20, 15], [30, 30, 25], [15, 25, 30], [25, 15, 20]],radius = 8) == [15, 25]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]],radius = 10) == [3, 3]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],radius = 2) == [4, 4]\n assert candidate(towers = [[25, 25, 50], [25, 26, 50], [26, 25, 50], [26, 26, 50], [24, 24, 50], [24, 25, 50], [25, 24, 50], [24, 26, 50], [26, 24, 50]],radius = 1) == [25, 25]\n", "comparison": "exact"}, "public_tests": ["[[1,2,5],[2,1,7],[3,1,9]]\n2", "[[23,11,21]]\n9", "[[1,2,13],[2,1,7],[0,1,9]]\n2"], "hints": ["The constraints are small enough to consider every possible coordinate and calculate its quality."], "metadata": {"canonical_parameter_names": ["towers", "radius"], "leetcode_dataset_entry_point": "Solution().bestCoordinate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:36+00:00", "tests_total": 108, "tests_dropped": 21, "flags": ["has_images"], "topic_tags": ["array", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def bestCoordinate(self, towers: list[list[int]], radius: int) -> list[int]:", "container": "Solution", "callable": "bestCoordinate", "parameters": [{"name": "towers", "type": "list[list[int]]"}, {"name": "radius", "type": "int"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1621, "task_id": "number-of-sets-of-k-non-overlapping-line-segments", "difficulty": "Medium", "problem_description": "Given n points on a 1-D plane, where the i^th point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.\n\nReturn the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: n = 4, k = 2\nOutput: 5\nExplanation: The two line segments are shown in red and blue.\nThe image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.\n\nExample 2:\n\nInput: n = 3, k = 1\nOutput: 3\nExplanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.\n\nExample 3:\n\nInput: n = 30, k = 7\nOutput: 796297179\nExplanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 10^9 + 7 gives us 796297179.\n\nConstraints:\n\n- 2 <= n <= 1000\n- 1 <= k <= n-1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 1000,k = 500) == 70047606\n assert candidate(n = 30,k = 7) == 796297179\n assert candidate(n = 6,k = 3) == 28\n assert candidate(n = 8,k = 4) == 165\n assert candidate(n = 5,k = 2) == 15\n assert candidate(n = 7,k = 1) == 21\n assert candidate(n = 100,k = 50) == 237930091\n assert candidate(n = 4,k = 2) == 5\n assert candidate(n = 20,k = 10) == 10015005\n assert candidate(n = 9,k = 2) == 210\n assert candidate(n = 10,k = 3) == 924\n assert candidate(n = 400,k = 200) == 849395041\n assert candidate(n = 300,k = 150) == 188049093\n assert candidate(n = 250,k = 125) == 61117700\n assert candidate(n = 200,k = 100) == 412289370\n assert candidate(n = 150,k = 50) == 703668401\n assert candidate(n = 500,k = 200) == 89039524\n assert candidate(n = 80,k = 20) == 527894588\n assert candidate(n = 1000,k = 999) == 1\n assert candidate(n = 999,k = 998) == 1\n assert candidate(n = 750,k = 300) == 966786381\n assert candidate(n = 800,k = 350) == 811412361\n assert candidate(n = 950,k = 400) == 686452764\n assert candidate(n = 25,k = 10) == 391975633\n assert candidate(n = 1000,k = 300) == 535696304\n assert candidate(n = 50,k = 10) == 984308396\n assert candidate(n = 600,k = 250) == 917595427\n assert candidate(n = 400,k = 150) == 37130153\n assert candidate(n = 998,k = 499) == 990039585\n assert candidate(n = 700,k = 250) == 1718306\n assert candidate(n = 50,k = 20) == 875426906\n assert candidate(n = 700,k = 350) == 906610068\n assert candidate(n = 999,k = 499) == 970118741\n assert candidate(n = 900,k = 450) == 891508928\n assert candidate(n = 600,k = 100) == 945626632\n assert candidate(n = 8,k = 3) == 210\n assert candidate(n = 150,k = 75) == 937415442\n assert candidate(n = 250,k = 20) == 344905395\n assert candidate(n = 250,k = 100) == 47365034\n assert candidate(n = 25,k = 5) == 20030010\n assert candidate(n = 100,k = 10) == 697218647\n assert candidate(n = 100,k = 20) == 114267332\n assert candidate(n = 15,k = 5) == 92378\n assert candidate(n = 50,k = 15) == 188331431\n assert candidate(n = 100,k = 40) == 234333249\n assert candidate(n = 1000,k = 1) == 499500\n assert candidate(n = 600,k = 220) == 66442708\n assert candidate(n = 800,k = 300) == 374845297\n assert candidate(n = 750,k = 375) == 796219809\n assert candidate(n = 600,k = 300) == 508930020\n assert candidate(n = 50,k = 5) == 930713009\n assert candidate(n = 800,k = 400) == 530286193\n assert candidate(n = 250,k = 75) == 928665746\n assert candidate(n = 999,k = 500) == 688428127\n assert candidate(n = 350,k = 175) == 134369598\n assert candidate(n = 500,k = 100) == 698790075\n assert candidate(n = 500,k = 250) == 540818587\n", "comparison": "exact"}, "public_tests": ["4\n2", "3\n1", "30\n7"], "hints": ["Try to use dynamic programming where the current index and remaining number of line segments to form can describe any intermediate state.", "To make the computation of each state in constant time, we could add another flag to the state that indicates whether or not we are in the middle of placing a line (placed start point but no endpoint)."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().numberOfSets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:38+00:00", "tests_total": 58, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["math", "dynamic-programming", "combinatorics", "prefix-sum"]}, "language": "python", "interface": {"raw_signature": "def numberOfSets(self, n: int, k: int) -> int:", "container": "Solution", "callable": "numberOfSets", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1624, "task_id": "largest-substring-between-two-equal-characters", "difficulty": "Easy", "problem_description": "Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"aa\"\nOutput: 0\nExplanation: The optimal substring here is an empty substring between the two 'a's.\n\nExample 2:\n\nInput: s = \"abca\"\nOutput: 2\nExplanation: The optimal substring here is \"bc\".\n\nExample 3:\n\nInput: s = \"cbzxy\"\nOutput: -1\nExplanation: There are no characters that appear twice in s.\n\nConstraints:\n\n- 1 <= s.length <= 300\n- s contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbaa\") == 4\n assert candidate(s = \"xyzx\") == 2\n assert candidate(s = \"a\") == -1\n assert candidate(s = \"aa\") == 0\n assert candidate(s = \"abcda\") == 3\n assert candidate(s = \"abcabc\") == 2\n assert candidate(s = \"abcdabcd\") == 3\n assert candidate(s = \"xyz\") == -1\n assert candidate(s = \"abcabcbb\") == 5\n assert candidate(s = \"leetcode\") == 5\n assert candidate(s = \"mnopqrstuvmnop\") == 9\n assert candidate(s = \"zzzzzzzzzz\") == 8\n assert candidate(s = \"zabz\") == 2\n assert candidate(s = \"cbzxy\") == -1\n assert candidate(s = \"abcdeabcde\") == 4\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"zabacdz\") == 5\n assert candidate(s = \"mnopqrlomn\") == 7\n assert candidate(s = \"abacaba\") == 5\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"abcdefg\") == -1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihggffeeddccbbaa\") == 102\n assert candidate(s = \"aaaabbbbccccdddd\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 17\n assert candidate(s = \"ababcabcab\") == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzxywvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcdexyzabcdexyzabcdexyz\") == 15\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\") == 51\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 49\n assert candidate(s = \"deified\") == 5\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == -1\n assert candidate(s = \"abcdefgahijklmnopqrstuvwxyz\") == 6\n assert candidate(s = \"rotorrotorrotor\") == 13\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\") == 3\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"abacabadabacaba\") == 13\n assert candidate(s = \"aabbccddeeaabbccddeeffgghheeffgghhii\") == 18\n assert candidate(s = \"abracadabra\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 54\n assert candidate(s = \"abcabcabcabc\") == 8\n assert candidate(s = \"abcdaebcdfeghifijkiljklmnopqrstuvswxyzxyzz\") == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(s = \"xyzyxzyzyxzyzyxzyzyx\") == 18\n assert candidate(s = \"ab\") == -1\n assert candidate(s = \"xyzwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == 48\n assert candidate(s = \"aabcdefghijklmnopqrstuvwxyzabcde\") == 26\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzz\") == 16\n assert candidate(s = \"abcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\") == 113\n assert candidate(s = \"acbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcba\") == 110\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"aaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaa\") == 105\n assert candidate(s = \"abcdefghijabcdefghij\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 19\n assert candidate(s = \"noon\") == 2\n assert candidate(s = \"aaabaaaacaaaaadaaaaaeaaaaa\") == 24\n assert candidate(s = \"abcdefgabcdefg\") == 6\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 37\n assert candidate(s = \"lkjlkjlkjlkjlkjlkj\") == 14\n assert candidate(s = \"abcdeafghijaklmnopqrastuvwxyz\") == 19\n assert candidate(s = \"aabbaaabbbaaa\") == 11\n assert candidate(s = \"abcdaebcdfeghifijkiljklmnopqrstuvswxyzxyzzzyxwvutsrqponmlkjilfedcbazyxwvutsrqponmlkjihgfedcba\") == 91\n assert candidate(s = \"abcdefghijjihegfedcba\") == 19\n assert candidate(s = \"abacaxab\") == 5\n assert candidate(s = \"mississippi\") == 8\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == 124\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abcdefghijzyxwvutsrqponmlkjihgfedcba\") == 34\n assert candidate(s = \"abcdefgxyzgfedcba\") == 15\n", "comparison": "exact"}, "public_tests": ["\"aa\"", "\"abca\"", "\"cbzxy\""], "hints": ["Try saving the first and last position of each character", "Try finding every pair of indexes with equal characters"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxLengthBetweenEqualCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:40+00:00", "tests_total": 74, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string"]}, "language": "python", "interface": {"raw_signature": "def maxLengthBetweenEqualCharacters(self, s: str) -> int:", "container": "Solution", "callable": "maxLengthBetweenEqualCharacters", "parameters": [{"name": "s", "type": "str"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1625, "task_id": "lexicographically-smallest-string-after-applying-operations", "difficulty": "Medium", "problem_description": "You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b.\n\nYou can apply either of the following two operations any number of times and in any order on s:\n\n- Add a to all odd indices of s (0-indexed). Digits post 9 are cycled back to 0. For example, if s = \"3456\" and a = 5, s becomes \"3951\".\n- Rotate s to the right by b positions. For example, if s = \"3456\" and b = 1, s becomes \"6345\".\n\nReturn the lexicographically smallest string you can obtain by applying the above operations any number of times on s.\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. For example, \"0158\" is lexicographically smaller than \"0190\" because the first position they differ is at the third letter, and '5' comes before '9'.\n\nExample 1:\n\nInput: s = \"5525\", a = 9, b = 2\nOutput: \"2050\"\nExplanation: We can apply the following operations:\nStart: \"5525\"\nRotate: \"2555\"\nAdd: \"2454\"\nAdd: \"2353\"\nRotate: \"5323\"\nAdd: \"5222\"\nAdd: \"5121\"\nRotate: \"2151\"\nAdd: \"2050\"\nThere is no way to obtain a string that is lexicographically smaller than \"2050\".\n\nExample 2:\n\nInput: s = \"74\", a = 5, b = 1\nOutput: \"24\"\nExplanation: We can apply the following operations:\nStart: \"74\"\nRotate: \"47\"\nAdd: \"42\"\nRotate: \"24\"\nThere is no way to obtain a string that is lexicographically smaller than \"24\".\n\nExample 3:\n\nInput: s = \"0011\", a = 4, b = 2\nOutput: \"0011\"\nExplanation: There are no sequence of operations that will give us a lexicographically smaller string than \"0011\".\n\nConstraints:\n\n- 2 <= s.length <= 100\n- s.length is even.\n- s consists of digits from 0 to 9 only.\n- 1 <= a <= 9\n- 1 <= b <= s.length - 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"5525\",a = 9,b = 2) == \"2050\"\n assert candidate(s = \"9876543210\",a = 7,b = 4) == \"1098765432\"\n assert candidate(s = \"74\",a = 5,b = 1) == \"24\"\n assert candidate(s = \"8900\",a = 3,b = 3) == \"0018\"\n assert candidate(s = \"1234567890\",a = 7,b = 3) == \"0022446688\"\n assert candidate(s = \"3456\",a = 5,b = 1) == \"0189\"\n assert candidate(s = \"0011\",a = 4,b = 2) == \"0011\"\n assert candidate(s = \"1234567890\",a = 3,b = 3) == \"0022446688\"\n assert candidate(s = \"9876543210\",a = 3,b = 4) == \"1098765432\"\n assert candidate(s = \"1234567890\",a = 1,b = 5) == \"0022446688\"\n assert candidate(s = \"5432109876\",a = 6,b = 7) == \"0189674523\"\n assert candidate(s = \"0246802468\",a = 4,b = 2) == \"0044882266\"\n assert candidate(s = \"908070605040302010\",a = 5,b = 7) == \"000908070604030201\"\n assert candidate(s = \"3692581470\",a = 4,b = 2) == \"1076329854\"\n assert candidate(s = \"1111111111\",a = 1,b = 2) == \"1010101010\"\n assert candidate(s = \"2222222222\",a = 5,b = 6) == \"2222222222\"\n assert candidate(s = \"0246813579\",a = 4,b = 2) == \"0044893377\"\n assert candidate(s = \"9999999999\",a = 2,b = 7) == \"1111111111\"\n assert candidate(s = \"8274635910\",a = 3,b = 3) == \"0017365544\"\n assert candidate(s = \"123412341234\",a = 2,b = 4) == \"103210321032\"\n assert candidate(s = \"2468024680\",a = 3,b = 3) == \"0044882266\"\n assert candidate(s = \"0987654321\",a = 7,b = 3) == \"0088664422\"\n assert candidate(s = \"3333333333\",a = 3,b = 2) == \"3030303030\"\n assert candidate(s = \"9999999999\",a = 1,b = 4) == \"9090909090\"\n assert candidate(s = \"12345678901234567890\",a = 9,b = 10) == \"10325476981032547698\"\n assert candidate(s = \"1111111111\",a = 7,b = 9) == \"0000000000\"\n assert candidate(s = \"595959\",a = 3,b = 3) == \"000000\"\n assert candidate(s = \"9753186420\",a = 7,b = 6) == \"1066229955\"\n assert candidate(s = \"0246802468\",a = 5,b = 7) == \"0246802468\"\n assert candidate(s = \"9999999999\",a = 2,b = 1) == \"1111111111\"\n assert candidate(s = \"5959595959\",a = 2,b = 1) == \"1111111111\"\n assert candidate(s = \"6420875319\",a = 9,b = 7) == \"0055117844\"\n assert candidate(s = \"6666666666\",a = 6,b = 8) == \"6060606060\"\n assert candidate(s = \"00000000000000000000\",a = 7,b = 15) == \"00000000000000000000\"\n assert candidate(s = \"1212121212\",a = 4,b = 6) == \"1010101010\"\n assert candidate(s = \"5678901234\",a = 2,b = 3) == \"0123456789\"\n assert candidate(s = \"8642086420\",a = 5,b = 9) == \"0369258147\"\n assert candidate(s = \"11223344556677889900\",a = 7,b = 8) == \"10213243546576879809\"\n assert candidate(s = \"676767676767676767676767\",a = 9,b = 17) == \"000000000000000000000000\"\n assert candidate(s = \"9876543210\",a = 1,b = 3) == \"0088664422\"\n assert candidate(s = \"999999\",a = 5,b = 3) == \"444444\"\n assert candidate(s = \"5937160482\",a = 4,b = 6) == \"0088553312\"\n assert candidate(s = \"8642086420\",a = 3,b = 3) == \"0066228844\"\n assert candidate(s = \"112233445566778899\",a = 4,b = 8) == \"112233445566778899\"\n assert candidate(s = \"1212121212\",a = 5,b = 5) == \"1212121212\"\n assert candidate(s = \"3141592653589793238462643383\",a = 3,b = 10) == \"2057529197278866683787354553\"\n assert candidate(s = \"135791357913579135\",a = 6,b = 5) == \"115533771155993377\"\n assert candidate(s = \"2468024680\",a = 9,b = 4) == \"0044882266\"\n assert candidate(s = \"0246813579\",a = 6,b = 3) == \"0044893377\"\n assert candidate(s = \"0123456789\",a = 9,b = 8) == \"0022446688\"\n assert candidate(s = \"8765432109\",a = 6,b = 7) == \"0189674523\"\n assert candidate(s = \"020406080020406080020406\",a = 8,b = 11) == \"000204000204060828486888\"\n assert candidate(s = \"1212121212\",a = 5,b = 6) == \"1212121212\"\n assert candidate(s = \"9360258174\",a = 5,b = 9) == \"0258174936\"\n assert candidate(s = \"2468024680\",a = 8,b = 4) == \"0044882266\"\n assert candidate(s = \"1122334455\",a = 6,b = 5) == \"1021379809\"\n assert candidate(s = \"246802468024680246802468\",a = 7,b = 13) == \"004400448822660044882266\"\n assert candidate(s = \"2244668800\",a = 3,b = 7) == \"0022446688\"\n assert candidate(s = \"1357913579\",a = 4,b = 2) == \"1155993377\"\n assert candidate(s = \"9999999999\",a = 3,b = 3) == \"0000000000\"\n assert candidate(s = \"0246813579\",a = 4,b = 3) == \"0044893377\"\n assert candidate(s = \"0000000000\",a = 9,b = 5) == \"0000000000\"\n assert candidate(s = \"8642097531\",a = 6,b = 8) == \"0177338844\"\n assert candidate(s = \"0918273645\",a = 2,b = 3) == \"0091827819\"\n assert candidate(s = \"0246813579\",a = 8,b = 2) == \"0044893377\"\n assert candidate(s = \"1122334455\",a = 7,b = 8) == \"1021324354\"\n assert candidate(s = \"7777777777\",a = 3,b = 2) == \"7070707070\"\n assert candidate(s = \"1357924680\",a = 5,b = 1) == \"0135792468\"\n assert candidate(s = \"4826037195\",a = 2,b = 7) == \"0077599422\"\n assert candidate(s = \"5050505050\",a = 9,b = 6) == \"5050505050\"\n assert candidate(s = \"595959595959595959\",a = 4,b = 2) == \"515151515151515151\"\n assert candidate(s = \"7035298461\",a = 8,b = 5) == \"1068392574\"\n assert candidate(s = \"1928374655\",a = 3,b = 3) == \"0019283746\"\n assert candidate(s = \"5973159731\",a = 2,b = 7) == \"1135775993\"\n assert candidate(s = \"99887766554433221100\",a = 3,b = 6) == \"00998877665544332211\"\n assert candidate(s = \"9999999999\",a = 9,b = 3) == \"0000000000\"\n assert candidate(s = \"1231231231\",a = 8,b = 4) == \"1039103921\"\n assert candidate(s = \"2468035791\",a = 2,b = 8) == \"0155992266\"\n assert candidate(s = \"8642086420\",a = 5,b = 5) == \"3197531975\"\n assert candidate(s = \"2468024680\",a = 6,b = 5) == \"0044882266\"\n assert candidate(s = \"5319753197\",a = 6,b = 7) == \"1177339955\"\n assert candidate(s = \"1357924680\",a = 2,b = 7) == \"0033771266\"\n assert candidate(s = \"0123456789\",a = 9,b = 9) == \"0022446688\"\n assert candidate(s = \"2468024680\",a = 5,b = 8) == \"0246802468\"\n assert candidate(s = \"1111111111\",a = 8,b = 1) == \"1111111111\"\n assert candidate(s = \"99999999999999999999999999\",a = 2,b = 19) == \"11111111111111111111111111\"\n assert candidate(s = \"1357924680\",a = 3,b = 3) == \"0033771266\"\n assert candidate(s = \"2736814950\",a = 3,b = 8) == \"2039844253\"\n assert candidate(s = \"1357913579\",a = 8,b = 6) == \"1155993377\"\n assert candidate(s = \"2468013579\",a = 7,b = 4) == \"0034782367\"\n assert candidate(s = \"1111111111\",a = 9,b = 9) == \"0000000000\"\n assert candidate(s = \"9182736450\",a = 4,b = 2) == \"5091827364\"\n assert candidate(s = \"5317902468\",a = 6,b = 4) == \"1194286257\"\n assert candidate(s = \"9080706050\",a = 8,b = 5) == \"0009030201\"\n", "comparison": "exact"}, "public_tests": ["\"5525\"\n9\n2", "\"74\"\n5\n1", "\"0011\"\n4\n2"], "hints": ["Since the length of s is even, the total number of possible sequences is at most 10 * 10 * s.length.", "You can generate all possible sequences and take their minimum.", "Keep track of already generated sequences so they are not processed again."], "metadata": {"canonical_parameter_names": ["s", "a", "b"], "leetcode_dataset_entry_point": "Solution().findLexSmallestString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:42+00:00", "tests_total": 109, "tests_dropped": 15, "flags": [], "topic_tags": ["string", "depth-first-search", "breadth-first-search", "enumeration"]}, "language": "python", "interface": {"raw_signature": "def findLexSmallestString(self, s: str, a: int, b: int) -> str:", "container": "Solution", "callable": "findLexSmallestString", "parameters": [{"name": "s", "type": "str"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1626, "task_id": "best-team-with-no-conflicts", "difficulty": "Medium", "problem_description": "You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the players in the team.\n\nHowever, the basketball team is not allowed to have conflicts. A conflict exists if a younger player has a strictly higher score than an older player. A conflict does not occur between players of the same age.\n\nGiven two lists, scores and ages, where each scores[i] and ages[i] represents the score and age of the i^th player, respectively, return the highest overall score of all possible basketball teams.\n\nExample 1:\n\nInput: scores = [1,3,5,10,15], ages = [1,2,3,4,5]\nOutput: 34\nExplanation: You can choose all the players.\n\nExample 2:\n\nInput: scores = [4,5,6,5], ages = [2,1,2,1]\nOutput: 16\nExplanation: It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.\n\nExample 3:\n\nInput: scores = [1,2,3,5], ages = [8,9,10,1]\nOutput: 6\nExplanation: It is best to choose the first 3 players.\n\nConstraints:\n\n- 1 <= scores.length, ages.length <= 1000\n- scores.length == ages.length\n- 1 <= scores[i] <= 10^6\n- 1 <= ages[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(scores = [1000000, 999999, 999998],ages = [1, 2, 3]) == 1000000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [50, 50, 50, 50],ages = [1, 2, 3, 4]) == 200\n assert candidate(scores = [10, 22, 35, 47, 55, 65],ages = [16, 19, 22, 25, 28, 31]) == 234\n assert candidate(scores = [5, 5, 5, 5],ages = [1, 2, 3, 4]) == 20\n assert candidate(scores = [1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1]) == 5\n assert candidate(scores = [100000, 100000, 100000],ages = [1000, 1000, 1000]) == 300000\n assert candidate(scores = [100, 200, 300, 400],ages = [4, 3, 2, 1]) == 400\n assert candidate(scores = [4, 5, 6, 5],ages = [2, 1, 2, 1]) == 16\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(scores = [1, 2, 3, 5],ages = [8, 9, 10, 1]) == 6\n assert candidate(scores = [10, 9, 8, 7],ages = [1, 2, 3, 4]) == 10\n assert candidate(scores = [5, 3, 7, 5, 2],ages = [5, 4, 8, 5, 2]) == 22\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [1000000, 1000000, 1000000],ages = [1, 1, 1]) == 3000000\n assert candidate(scores = [1, 3, 5, 10, 15],ages = [1, 2, 3, 4, 5]) == 34\n assert candidate(scores = [1, 2, 2, 1],ages = [3, 1, 1, 3]) == 4\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(scores = [100, 90, 80, 70, 60],ages = [18, 17, 16, 15, 14]) == 400\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 550\n assert candidate(scores = [90, 85, 90, 100, 105, 110, 105, 115, 120],ages = [25, 30, 25, 30, 35, 40, 45, 50, 55]) == 730\n assert candidate(scores = [2, 5, 3, 1, 4],ages = [1, 2, 3, 4, 5]) == 9\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [20, 30, 20, 30, 20],ages = [2, 2, 3, 3, 4]) == 80\n assert candidate(scores = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 36\n assert candidate(scores = [10, 5, 7, 1, 9, 6, 8, 3, 4, 2],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [10, 20, 30, 20, 10, 40, 50],ages = [1, 2, 3, 1, 2, 3, 4]) == 170\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [25, 30, 5, 50, 40, 60, 70, 10, 80, 90],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(scores = [4, 10, 4, 3, 8, 9],ages = [4, 1, 2, 4, 3, 1]) == 19\n assert candidate(scores = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],ages = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 45\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40],ages = [1, 3, 2, 5, 4, 7, 6, 8]) == 120\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [40, 20, 30, 10, 50],ages = [2, 1, 3, 4, 5]) == 110\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5500\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 45\n assert candidate(scores = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 605\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 55\n assert candidate(scores = [10, 20, 30, 25, 40],ages = [4, 3, 5, 2, 6]) == 95\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 550\n assert candidate(scores = [20, 30, 25, 20, 40, 35, 30, 45, 50, 60],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 245\n assert candidate(scores = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],ages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1000\n assert candidate(scores = [10, 6, 5, 7, 3, 8],ages = [4, 3, 2, 4, 1, 5]) == 31\n assert candidate(scores = [8, 5, 6, 10, 7, 9, 4, 2, 11, 3],ages = [8, 6, 6, 9, 7, 8, 5, 4, 10, 3]) == 63\n assert candidate(scores = [1000, 500, 250, 750, 100],ages = [20, 25, 30, 35, 40]) == 1250\n assert candidate(scores = [4, 1, 3, 2, 5],ages = [2, 1, 2, 3, 1]) == 8\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [10, 20, 30, 40, 50]) == 150\n assert candidate(scores = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60],ages = [1, 2, 1, 3, 2, 4, 3, 5, 4, 5]) == 310\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],ages = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(scores = [10, 9, 2, 5, 3, 7, 1, 8, 6, 4],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 22\n assert candidate(scores = [1000000, 100000, 10000, 1000, 100, 10, 1],ages = [1, 2, 3, 4, 5, 6, 7]) == 1000000\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [3, 2, 1, 2, 3]) == 120\n assert candidate(scores = [9, 2, 8, 5, 7, 6, 3, 4, 1, 10],ages = [4, 1, 6, 3, 5, 4, 2, 3, 1, 7]) == 46\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [100, 200, 300, 400, 500],ages = [5, 4, 3, 2, 1]) == 500\n assert candidate(scores = [100, 200, 300, 200, 100],ages = [1, 2, 3, 4, 5]) == 600\n assert candidate(scores = [9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(scores = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [4, 5, 6, 5, 7, 8, 6, 9],ages = [2, 1, 2, 1, 3, 4, 3, 5]) == 46\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 550\n assert candidate(scores = [20, 30, 10, 40, 50],ages = [10, 10, 10, 10, 10]) == 150\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(scores = [9, 2, 8, 8, 8, 2, 1, 1, 1, 4],ages = [6, 2, 4, 7, 7, 2, 2, 2, 4, 3]) == 34\n assert candidate(scores = [8, 2, 7, 5, 4, 3, 9],ages = [2, 3, 1, 2, 3, 4, 5]) == 24\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1],ages = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == 28\n assert candidate(scores = [15, 20, 5, 10, 25, 30],ages = [5, 5, 2, 3, 5, 5]) == 105\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35],ages = [20, 20, 20, 20, 20, 20, 20]) == 140\n assert candidate(scores = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 95\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 550\n assert candidate(scores = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],ages = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 20\n assert candidate(scores = [3, 10, 2, 1, 5, 7, 8, 6, 4, 9],ages = [1, 3, 2, 4, 2, 2, 3, 2, 2, 1]) == 43\n assert candidate(scores = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(scores = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 275\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [10, 20, 20, 10, 30, 30, 40, 40],ages = [1, 1, 2, 2, 3, 3, 4, 4]) == 190\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(scores = [10, 20, 20, 10, 30],ages = [1, 2, 3, 4, 5]) == 80\n assert candidate(scores = [1000, 1000, 1000, 1000, 1000],ages = [1, 1, 1, 1, 1]) == 5000\n assert candidate(scores = [30, 10, 20, 40, 50, 15, 25, 35, 45, 55],ages = [3, 1, 2, 4, 5, 1, 2, 3, 4, 5]) == 325\n assert candidate(scores = [50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1]) == 150\n assert candidate(scores = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [20, 20, 20, 20, 20],ages = [1, 2, 3, 4, 5]) == 100\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(scores = [5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1]) == 15\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [100, 200, 150, 100, 50, 250],ages = [5, 4, 3, 2, 1, 6]) == 750\n assert candidate(scores = [3, 1, 2],ages = [1, 1, 1]) == 6\n assert candidate(scores = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(scores = [4, 1, 6, 2, 5, 3],ages = [2, 1, 3, 1, 2, 3]) == 18\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1, 1, 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(scores = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],ages = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 20\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 54\n assert candidate(scores = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],ages = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 11\n assert candidate(scores = [15, 30, 10, 20, 50],ages = [5, 10, 15, 20, 25]) == 95\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 350\n assert candidate(scores = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 200\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1000000\n assert candidate(scores = [20, 10, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 540\n assert candidate(scores = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 26\n assert candidate(scores = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 65\n assert candidate(scores = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1],ages = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1]) == 75\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 23\n assert candidate(scores = [1000, 500, 200, 1000, 1000, 500, 200],ages = [2, 1, 3, 2, 3, 1, 3]) == 4000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 22\n assert candidate(scores = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550],ages = [10, 9, 8, 7, 6, 1, 2, 3, 4, 5]) == 1750\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [1, 3, 2, 5, 4]) == 90\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [4, 10, 10, 6, 7, 1, 9],ages = [4, 1, 4, 2, 2, 3, 6]) == 23\n assert candidate(scores = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 30\n assert candidate(scores = [1, 2, 3, 4, 5],ages = [5, 4, 3, 2, 1]) == 5\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 275\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5]) == 5\n assert candidate(scores = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(scores = [100, 90, 80, 70, 60],ages = [5, 4, 3, 2, 1]) == 400\n assert candidate(scores = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 200\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1]) == 19\n assert candidate(scores = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1998046\n", "comparison": "exact"}, "public_tests": ["[1,3,5,10,15]\n[1,2,3,4,5]", "[4,5,6,5]\n[2,1,2,1]", "[1,2,3,5]\n[8,9,10,1]"], "hints": ["First, sort players by age and break ties by their score. You can now consider the players from left to right.", "If you choose to include a player, you must only choose players with at least that score later on."], "metadata": {"canonical_parameter_names": ["scores", "ages"], "leetcode_dataset_entry_point": "Solution().bestTeamScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:44+00:00", "tests_total": 137, "tests_dropped": 2, "flags": [], "topic_tags": ["array", "dynamic-programming", "sorting", "longest-increasing-subsequence"]}, "language": "python", "interface": {"raw_signature": "def bestTeamScore(self, scores: list[int], ages: list[int]) -> int:", "container": "Solution", "callable": "bestTeamScore", "parameters": [{"name": "scores", "type": "list[int]"}, {"name": "ages", "type": "list[int]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1627, "task_id": "graph-connectivity-with-threshold", "difficulty": "Hard", "problem_description": "We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor strictly greater than some threshold. More formally, cities with labels x and y have a road between them if there exists an integer z such that all of the following are true:\n\n- x % z == 0,\n- y % z == 0, and\n- z > threshold.\n\nGiven the two integers, n and threshold, and an array of queries, you must determine for each queries[i] = [a_i, b_i] if cities a_i and b_i are connected directly or indirectly. (i.e. there is some path between them).\n\nReturn an array answer, where answer.length == queries.length and answer[i] is true if for the i^th query, there is a path between a_i and b_i, or answer[i] is false if there is no path.\n\nExample 1:\n\nInput: n = 6, threshold = 2, queries = [[1,4],[2,5],[3,6]]\nOutput: [false,false,true]\nExplanation: The divisors for each number:\n1: 1\n2: 1, 2\n3: 1, 3\n4: 1, 2, 4\n5: 1, 5\n6: 1, 2, 3, 6\nUsing the underlined divisors above the threshold, only cities 3 and 6 share a common divisor, so they are the\nonly ones directly connected. The result of each query:\n[1,4] 1 is not connected to 4\n[2,5] 2 is not connected to 5\n[3,6] 3 is connected to 6 through path 3--6\n\nExample 2:\n\nInput: n = 6, threshold = 0, queries = [[4,5],[3,4],[3,2],[2,6],[1,3]]\nOutput: [true,true,true,true,true]\nExplanation: The divisors for each number are the same as the previous example. However, since the threshold is 0,\nall divisors can be used. Since all numbers share 1 as a divisor, all cities are connected.\n\nExample 3:\n\nInput: n = 5, threshold = 1, queries = [[4,5],[4,5],[3,2],[2,3],[3,4]]\nOutput: [false,false,false,false,false]\nExplanation: Only cities 2 and 4 share a common divisor 2 which is strictly greater than the threshold 1, so they are the only ones directly connected.\nPlease notice that there can be multiple queries for the same pair of nodes [x, y], and that the query [x, y] is equivalent to the query [y, x].\n\nConstraints:\n\n- 2 <= n <= 10^4\n- 0 <= threshold <= n\n- 1 <= queries.length <= 10^5\n- queries[i].length == 2\n- 1 <= a_i, b_i <= cities\n- a_i != b_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,threshold = 0,queries = [[4, 5], [3, 4], [3, 2], [2, 6], [1, 3]]) == [True, True, True, True, True]\n assert candidate(n = 10,threshold = 3,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 50,queries = [[1, 2], [51, 100], [49, 99]]) == [False, False, False]\n assert candidate(n = 6,threshold = 2,queries = [[1, 4], [2, 5], [3, 6]]) == [False, False, True]\n assert candidate(n = 5,threshold = 1,queries = [[4, 5], [4, 5], [3, 2], [2, 3], [3, 4]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 50,queries = [[1, 99], [2, 98], [3, 97], [4, 96]]) == [False, False, False, False]\n assert candidate(n = 3000,threshold = 1500,queries = [[1501, 2250], [1502, 2251], [1503, 2252], [1504, 2253], [1505, 2254], [1506, 2255], [1507, 2256], [1508, 2257], [1509, 2258], [1510, 2259]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 1000,queries = [[1, 2000], [3000, 4000], [5000, 6000], [7000, 8000], [9000, 10000]]) == [False, True, True, True, True]\n assert candidate(n = 50,threshold = 5,queries = [[6, 12], [10, 20], [14, 28], [18, 36], [22, 44]]) == [True, True, True, True, True]\n assert candidate(n = 999,threshold = 333,queries = [[1, 334], [2, 335], [3, 336], [4, 337], [5, 338], [6, 339]]) == [False, False, False, False, False, False]\n assert candidate(n = 100,threshold = 0,queries = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96]]) == [True, True, True, True, True]\n assert candidate(n = 5000,threshold = 1000,queries = [[1000, 2000], [3000, 4000], [4999, 5000]]) == [False, False, False]\n assert candidate(n = 100,threshold = 25,queries = [[26, 52], [27, 54], [28, 56], [29, 58], [30, 60]]) == [True, True, True, True, True]\n assert candidate(n = 1000,threshold = 1,queries = [[2, 4], [3, 6], [5, 10], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 6000], [2, 6001], [3, 6002], [4, 6003], [5, 6004], [6, 6005]]) == [False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[150, 300], [200, 400], [500, 750], [800, 900], [100, 900]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[1, 500], [2, 501], [3, 502], [4, 503], [5, 504], [6, 505]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 9999,queries = [[1, 10000], [2, 9999], [3, 9998], [4, 9997]]) == [False, False, False, False]\n assert candidate(n = 500,threshold = 250,queries = [[251, 500], [252, 499], [253, 498], [254, 497], [255, 496], [256, 495]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1000, 9000], [5000, 6000], [1, 2], [9999, 10000]]) == [False, False, False, False]\n assert candidate(n = 5000,threshold = 100,queries = [[100, 200], [50, 150], [300, 600], [1, 2], [4999, 5000]]) == [False, False, True, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[1, 500], [2, 750], [3, 900], [4, 950], [5, 999]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2000,queries = [[1, 3000], [2, 4000], [3, 4500], [4, 4900], [5, 4999]]) == [False, False, False, False, False]\n assert candidate(n = 50,threshold = 10,queries = [[11, 22], [13, 26], [15, 30], [7, 14], [21, 42]]) == [True, True, True, False, True]\n assert candidate(n = 5000,threshold = 250,queries = [[125, 250], [375, 500], [625, 750], [875, 1000], [1125, 1250]]) == [False, True, True, True, True]\n assert candidate(n = 1000,threshold = 200,queries = [[500, 750], [250, 501], [750, 1000], [1, 999]]) == [True, False, True, False]\n assert candidate(n = 10000,threshold = 0,queries = [[1, 9999], [2, 9998], [3, 9997], [4, 9996], [5, 9995], [6, 9994], [7, 9993], [8, 9992], [9, 9991], [10, 9990]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[5100, 9900], [5200, 9800], [5300, 9700], [5400, 9600], [5500, 9500]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 1000,queries = [[1200, 2400], [1500, 3000], [2500, 4000], [3500, 4500], [1000, 4000]]) == [True, True, False, False, False]\n assert candidate(n = 1000,threshold = 5,queries = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 10,queries = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 50,queries = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50]]) == [False, False, False, False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 2501], [1000, 3000], [2500, 5000]]) == [False, False, False]\n assert candidate(n = 2000,threshold = 100,queries = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 100,threshold = 20,queries = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == [False, False, False, False, False]\n assert candidate(n = 20,threshold = 19,queries = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16]]) == [False, False, False, False, False]\n assert candidate(n = 2000,threshold = 1000,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 1000,queries = [[2000, 3000], [1001, 2001], [4000, 5000], [999, 4999]]) == [False, False, False, False]\n assert candidate(n = 8000,threshold = 4000,queries = [[4001, 8000], [4002, 7999], [4003, 7998], [4004, 7997], [4005, 7996], [4006, 7995]]) == [False, False, False, False, False, False]\n assert candidate(n = 2000,threshold = 100,queries = [[50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600]]) == [False, False, True, True, True, True, True, True, True, True]\n assert candidate(n = 1000,threshold = 5,queries = [[1, 3], [2, 4], [5, 7], [8, 10], [11, 13], [14, 16], [17, 19], [20, 22], [23, 25], [26, 28], [29, 31], [32, 34], [35, 37], [38, 40], [41, 43], [44, 46], [47, 49], [50, 52], [53, 55], [56, 58], [59, 61], [62, 64], [65, 67], [68, 70], [71, 73], [74, 76], [77, 79], [80, 82], [83, 85], [86, 88], [89, 91], [92, 94], [95, 97], [98, 100]]) == [False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 50,queries = [[51, 101], [52, 102], [53, 103], [54, 104], [55, 105], [56, 106], [57, 107], [58, 108], [59, 109], [60, 110]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 1,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 1000,threshold = 500,queries = [[10, 20], [30, 50], [25, 75], [500, 1000], [999, 1000]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 50,queries = [[51, 100], [52, 99], [53, 98], [54, 97], [55, 96], [56, 95], [57, 94], [58, 93], [59, 92], [60, 91]]) == [True, True, False, False, True, True, False, False, False, True]\n assert candidate(n = 8000,threshold = 4000,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [False, False, False, False, False]\n assert candidate(n = 3000,threshold = 1500,queries = [[1501, 2000], [1502, 2500], [1503, 3000], [2000, 3000], [1504, 1505], [1506, 1507]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 2000,queries = [[2001, 4000], [2002, 4001], [2003, 4002], [2004, 4003], [2005, 4004], [2006, 4005], [2007, 4006], [2008, 4007], [2009, 4008], [2010, 4009]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 7000], [2, 8000], [3, 9000], [4, 9500], [5, 9999]]) == [False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 5001], [2, 5002], [3, 5003], [4, 5004], [5, 5005]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 99,queries = [[1, 100]]) == [False]\n assert candidate(n = 5000,threshold = 2,queries = [[3, 6], [5, 10], [7, 14], [9, 18], [11, 22], [13, 26], [15, 30], [17, 34], [19, 38], [21, 42]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[5001, 5002], [5003, 5004], [5005, 5006], [5007, 5008], [5009, 5010]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 500], [1000, 1500], [2000, 2500], [3000, 3500], [4000, 4500], [4500, 5000]]) == [False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 300,queries = [[101, 202], [303, 404], [505, 606], [707, 808], [909, 1000]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 1,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [False, True, True, True, True]\n assert candidate(n = 2000,threshold = 0,queries = [[1, 1999], [2, 1998], [3, 1997], [4, 1996], [5, 1995], [6, 1994], [7, 1993], [8, 1992], [9, 1991], [10, 1990]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 500,threshold = 250,queries = [[251, 500], [252, 499], [253, 498], [254, 497], [255, 496]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 2501], [2, 2502], [3, 2503], [4, 2504], [5, 2505]]) == [False, False, False, False, False]\n assert candidate(n = 2000,threshold = 1,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 150,threshold = 50,queries = [[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]]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 0,queries = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995], [10, 100], [50, 150], [200, 300], [700, 800], [900, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 500,threshold = 250,queries = [[1, 251], [2, 252], [3, 253], [4, 254], [5, 255], [250, 499], [251, 498], [252, 497], [253, 496], [254, 495]]) == [False, False, False, False, False, False, False, False, False, False]\n", "comparison": "exact"}, "public_tests": ["6\n2\n[[1,4],[2,5],[3,6]]", "6\n0\n[[4,5],[3,4],[3,2],[2,6],[1,3]]", "5\n1\n[[4,5],[4,5],[3,2],[2,3],[3,4]]"], "hints": ["How to build the graph of the cities?", "Connect city i with all its multiples 2*i, 3*i, ...", "Answer the queries using union-find data structure."], "metadata": {"canonical_parameter_names": ["n", "threshold", "queries"], "leetcode_dataset_entry_point": "Solution().areConnected", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:47+00:00", "tests_total": 63, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "union-find", "number-theory"]}, "language": "python", "interface": {"raw_signature": "def areConnected(self, n: int, threshold: int, queries: list[list[int]]) -> list[bool]:", "container": "Solution", "callable": "areConnected", "parameters": [{"name": "n", "type": "int"}, {"name": "threshold", "type": "int"}, {"name": "queries", "type": "list[list[int]]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1629, "task_id": "slowest-key", "difficulty": "Easy", "problem_description": "A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.\n\nYou are given a string keysPressed of length n, where keysPressed[i] was the i^th key pressed in the testing sequence, and a sorted list releaseTimes, where releaseTimes[i] was the time the i^th key was released. Both arrays are 0-indexed. The 0^th key was pressed at the time 0, and every subsequent key was pressed at the exact time the previous key was released.\n\nThe tester wants to know the key of the keypress that had the longest duration. The i^thkeypress had a duration of releaseTimes[i] - releaseTimes[i - 1], and the 0^th keypress had a duration of releaseTimes[0].\n\nNote that the same key could have been pressed multiple times during the test, and these multiple presses of the same key may not have had the same duration.\n\nReturn the key of the keypress that had the longest duration. If there are multiple such keypresses, return the lexicographically largest key of the keypresses.\n\nExample 1:\n\nInput: releaseTimes = [9,29,49,50], keysPressed = \"cbcd\"\nOutput: \"c\"\nExplanation: The keypresses were as follows:\nKeypress for 'c' had a duration of 9 (pressed at time 0 and released at time 9).\nKeypress for 'b' had a duration of 29 - 9 = 20 (pressed at time 9 right after the release of the previous character and released at time 29).\nKeypress for 'c' had a duration of 49 - 29 = 20 (pressed at time 29 right after the release of the previous character and released at time 49).\nKeypress for 'd' had a duration of 50 - 49 = 1 (pressed at time 49 right after the release of the previous character and released at time 50).\nThe longest of these was the keypress for 'b' and the second keypress for 'c', both with duration 20.\n'c' is lexicographically larger than 'b', so the answer is 'c'.\n\nExample 2:\n\nInput: releaseTimes = [12,23,36,46,62], keysPressed = \"spuda\"\nOutput: \"a\"\nExplanation: The keypresses were as follows:\nKeypress for 's' had a duration of 12.\nKeypress for 'p' had a duration of 23 - 12 = 11.\nKeypress for 'u' had a duration of 36 - 23 = 13.\nKeypress for 'd' had a duration of 46 - 36 = 10.\nKeypress for 'a' had a duration of 62 - 46 = 16.\nThe longest of these was the keypress for 'a' with duration 16.\n\nConstraints:\n\n- releaseTimes.length == n\n- keysPressed.length == n\n- 2 <= n <= 1000\n- 1 <= releaseTimes[i] <= 10^9\n- releaseTimes[i] < releaseTimes[i+1]\n- keysPressed contains only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(releaseTimes = [2, 3, 7, 10, 15],keysPressed = \"zzzaa\") == \"a\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25],keysPressed = \"zabzc\") == \"z\"\n assert candidate(releaseTimes = [5, 15, 25, 35, 45, 55],keysPressed = \"abcdef\") == \"f\"\n assert candidate(releaseTimes = [50, 70, 80, 90],keysPressed = \"abcd\") == \"a\"\n assert candidate(releaseTimes = [9, 29, 49, 50],keysPressed = \"cbcd\") == \"c\"\n assert candidate(releaseTimes = [10, 15, 20, 25, 30],keysPressed = \"aabcd\") == \"a\"\n assert candidate(releaseTimes = [12, 23, 36, 46, 62],keysPressed = \"spuda\") == \"a\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5],keysPressed = \"abcde\") == \"e\"\n assert candidate(releaseTimes = [50, 75, 100, 125, 150],keysPressed = \"zzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keysPressed = \"qwertyuiopz\") == \"z\"\n assert candidate(releaseTimes = [100, 200, 300, 400, 500],keysPressed = \"aaaaa\") == \"a\"\n assert candidate(releaseTimes = [1, 3, 5, 7, 9],keysPressed = \"abcde\") == \"e\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keysPressed = \"abcdefghij\") == \"j\"\n assert candidate(releaseTimes = [100, 200, 300, 400],keysPressed = \"abcd\") == \"d\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50],keysPressed = \"aaaaa\") == \"a\"\n assert candidate(releaseTimes = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],keysPressed = \"abcdefghijk\") == \"k\"\n assert candidate(releaseTimes = [10, 20, 30, 40],keysPressed = \"abcd\") == \"d\"\n assert candidate(releaseTimes = [10, 30, 70, 150, 230, 320, 420, 530, 650, 780, 920, 1080, 1260, 1460, 1680, 1920],keysPressed = \"zzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],keysPressed = \"abcdefghijklmno\") == \"o\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],keysPressed = \"zzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],keysPressed = \"abcdefghijklmno\") == \"a\"\n assert candidate(releaseTimes = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],keysPressed = \"abcdefghijklmn\") == \"b\"\n assert candidate(releaseTimes = [20, 45, 60, 80, 100, 120, 140, 160, 180, 200],keysPressed = \"abcdefghij\") == \"b\"\n assert candidate(releaseTimes = [5, 15, 30, 45, 60, 75, 90, 105, 120, 135],keysPressed = \"abcdefghij\") == \"j\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],keysPressed = \"zzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],keysPressed = \"abcdefghijklmnopqrst\") == \"t\"\n assert candidate(releaseTimes = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],keysPressed = \"abcdefghijklmnopqrst\") == \"t\"\n", "comparison": "exact"}, "public_tests": ["[9,29,49,50]\n\"cbcd\"", "[12,23,36,46,62]\n\"spuda\""], "hints": ["Get for each press its key and amount of time taken.", "Iterate on the presses, maintaining the answer so far.", "The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer."], "metadata": {"canonical_parameter_names": ["releaseTimes", "keysPressed"], "leetcode_dataset_entry_point": "Solution().slowestKey", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:49+00:00", "tests_total": 38, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "string"]}, "language": "python", "interface": {"raw_signature": "def slowestKey(self, releaseTimes: list[int], keysPressed: str) -> str:", "container": "Solution", "callable": "slowestKey", "parameters": [{"name": "releaseTimes", "type": "list[int]"}, {"name": "keysPressed", "type": "str"}], "return_type": "str", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1630, "task_id": "arithmetic-subarrays", "difficulty": "Medium", "problem_description": "A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence s is arithmetic if and only if s[i+1] - s[i] == s[1] - s[0] for all valid i.\n\nFor example, these are arithmetic sequences:\n\n1, 3, 5, 7, 9\n7, 7, 7, 7\n3, -1, -5, -9\n\nThe following sequence is not arithmetic:\n\n1, 1, 2, 5, 7\n\nYou are given an array of n integers, nums, and two arrays of m integers each, l and r, representing the m range queries, where the i^th query is the range [l[i], r[i]]. All the arrays are 0-indexed.\n\nReturn a list of boolean elements answer, where answer[i] is true if the subarray nums[l[i]], nums[l[i]+1], ... , nums[r[i]] can be rearranged to form an arithmetic sequence, and false otherwise.\n\nExample 1:\n\nInput: nums = [4,6,5,9,3,7], l = [0,0,2], r = [2,3,5]\nOutput: [true,false,true]\nExplanation:\nIn the 0^th query, the subarray is [4,6,5]. This can be rearranged as [6,5,4], which is an arithmetic sequence.\nIn the 1^st query, the subarray is [4,6,5,9]. This cannot be rearranged as an arithmetic sequence.\nIn the 2^nd query, the subarray is [5,9,3,7]. This can be rearranged as [3,5,7,9], which is an arithmetic sequence.\n\nExample 2:\n\nInput: nums = [-12,-9,-3,-12,-6,15,20,-25,-20,-15,-10], l = [0,1,6,4,8,7], r = [4,4,9,7,9,10]\nOutput: [false,true,false,false,true,true]\n\nConstraints:\n\n- n == nums.length\n- m == l.length\n- m == r.length\n- 2 <= n <= 500\n- 1 <= m <= 500\n- 0 <= l[i] < r[i] < n\n- -10^5 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 0, 2, 3],r = [1, 2, 4, 4]) == [True, True, True, True]\n assert candidate(nums = [5, 5, 5, 5, 5],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [0, 3, 5, 7, 9],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [0, 5, 10, 15, 20],l = [0, 0, 1, 2],r = [2, 3, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [-12, -9, -3, -12, -6, 15, 20, -25, -20, -15, -10],l = [0, 1, 6, 4, 8, 7],r = [4, 4, 9, 7, 9, 10]) == [False, True, False, False, True, True]\n assert candidate(nums = [1, 2, 3, 5, 6],l = [0, 2],r = [2, 4]) == [True, False]\n assert candidate(nums = [10, 9, 8, 7, 6],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 6, 8, 10],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [5, 3, 1, 7, 9],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, False]\n assert candidate(nums = [1, 2, 4, 6, 8],l = [0, 1, 2, 3],r = [2, 3, 4, 4]) == [False, True, True, True]\n assert candidate(nums = [1, 1, 2, 5, 7],l = [0, 2, 3],r = [2, 3, 4]) == [False, True, True]\n assert candidate(nums = [1, 2, 4, 6, 8],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [4, 6, 5, 9, 3, 7],l = [0, 0, 2],r = [2, 3, 5]) == [True, False, True]\n assert candidate(nums = [10, 5, 3, 7, 8],l = [0, 1, 2, 3],r = [1, 2, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [2, 3, 4]) == [True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [4, 3, 4]) == [True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50],l = [0, 2],r = [1, 3]) == [True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600],l = [0, 1, 2],r = [2, 3, 4]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [4, 3, 3]) == [True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [4, 3, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1],r = [2, 4]) == [True, True]\n assert candidate(nums = [-10, -7, -4, -1, 2, 5, 8, 11],l = [0, 1, 2, 3],r = [2, 4, 6, 7]) == [True, True, True, True]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30],l = [0, 2, 4],r = [1, 3, 5]) == [True, True, True]\n assert candidate(nums = [20, 10, 30, 50, 40, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4, 5],r = [2, 4, 6, 8, 9, 9]) == [True, False, True, True, False, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [1, 3, 5, 7],r = [8, 9, 8, 9]) == [True, True, True, True]\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500],l = [0, 2, 4, 6],r = [2, 4, 6, 7]) == [False, False, False, True]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 9]) == [True, True, True, True, True, True, False]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35, 40],l = [1, 0, 2, 5],r = [6, 4, 4, 7]) == [False, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],l = [0, 1, 3, 5],r = [2, 4, 6, 8]) == [True, True, True, 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],l = [0, 6, 12, 18],r = [5, 11, 17, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],l = [0, 5, 10],r = [4, 9, 12]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],l = [0, 2, 4, 6, 8, 10],r = [1, 3, 5, 7, 9, 20]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29],l = [0, 2, 5, 6],r = [3, 5, 7, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],l = [0, 3, 6, 9, 1],r = [2, 5, 8, 10, 4]) == [True, True, True, True, True]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 10]) == [True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 0, 0, 0],r = [3, 4, 5, 6]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 1, 2, 3, 4],r = [4, 5, 6, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [10, 5, 0, -5, -10, -15, -20, -25, -30, -35],l = [0, 0, 0, 0],r = [4, 5, 6, 7]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4],r = [2, 3, 4, 5, 6]) == [True, True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],l = [0, 4, 8, 12, 16],r = [3, 7, 11, 15, 19]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [2, 4, 6, 8, 9, 9, 9, 9, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],l = [0, 3, 6, 9, 12, 15],r = [1, 4, 7, 10, 13, 16]) == [True, True, True, True, True, True]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],l = [0, 3, 6, 9],r = [2, 5, 8, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],l = [0, 2, 4, 6],r = [3, 5, 7, 9]) == [True, True, True, True]\n assert candidate(nums = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 11]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 10],l = [0, 2, 4, 1, 3],r = [1, 5, 7, 7, 6]) == [True, False, False, False, False]\n assert candidate(nums = [5, 8, 1, 3, 4, 9, 10],l = [0, 1, 2, 3],r = [2, 4, 5, 6]) == [False, False, False, False]\n assert candidate(nums = [5, 8, 3, 7, 10, 1, 2, 9, 4, 6],l = [0, 2, 5, 7],r = [3, 7, 9, 9]) == [False, False, False, False]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = [0, 1, 2, 3, 4],r = [2, 4, 6, 8, 9]) == [False, False, False, False, False]\n assert candidate(nums = [10, 5, 15, 20, 30, 25, 40, 35, 50, 45],l = [0, 1, 2, 3, 4, 5, 6],r = [3, 5, 7, 9, 9, 9, 9]) == [True, False, True, True, True, False, True]\n assert candidate(nums = [4, 3, 2, 1, 0, -1, -2, -3, -4],l = [0, 3, 4, 5],r = [8, 7, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4],r = [3, 4, 5, 6, 9]) == [True, True, True, True, True]\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],l = [0, 5, 10, 15, 20],r = [4, 9, 14, 19, 24]) == [False, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 9]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],l = [0, 1, 2, 3],r = [1, 2, 3, 8]) == [True, True, True, True]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],l = [0, 1, 2, 3, 4, 5, 6],r = [3, 5, 7, 9, 9, 9, 9]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = [0, 2, 4, 6],r = [1, 3, 5, 9]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 5, 10, 15, 20],r = [4, 9, 14, 19, 24]) == [True, True, True, True, True]\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],l = [0, 5, 10],r = [4, 9, 13]) == [True, True, True]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29],l = [0, 3, 6],r = [2, 5, 8]) == [True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = [0, 5, 10],r = [4, 9, 14]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13],l = [0, 2, 4, 6],r = [1, 5, 7, 8]) == [True, False, False, False]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4],l = [0, 3, 6],r = [2, 5, 8]) == [True, False, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],l = [0, 1, 3, 5, 7],r = [2, 4, 6, 8, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [True, True, False, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3],r = [2, 3, 4, 8]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 4, 6, 8],r = [3, 7, 9, 9]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],l = [0, 1, 2, 3],r = [1, 2, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [2, 10, 4, 5, 7, 6, 9],l = [0, 1, 2, 3, 4],r = [2, 3, 5, 5, 6]) == [False, False, True, True, False]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 1, 2, 3, 4],r = [1, 2, 3, 4, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],l = [0, 5, 2, 8],r = [4, 10, 6, 10]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],l = [0, 2, 4, 6],r = [3, 5, 7, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],l = [0, 1, 2, 3, 4, 5],r = [1, 2, 3, 4, 5, 8]) == [True, True, True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],l = [0, 2, 4],r = [2, 4, 6]) == [True, True, True]\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],l = [0, 2, 4, 6],r = [1, 3, 5, 9]) == [True, True, True, True]\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991],l = [0, 1, 2, 3, 4, 5, 6, 7],r = [1, 2, 3, 4, 5, 6, 7, 9]) == [True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, False]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],l = [0, 2, 4, 6],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [False, False, False, False]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],l = [0, 5, 7, 9],r = [4, 9, 10, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 14]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6],r = [1, 3, 5, 7]) == [True, True, True, True]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35],l = [0, 2, 4],r = [4, 5, 6]) == [True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = [0, 2, 4, 6, 8],r = [1, 4, 7, 9, 9]) == [True, True, True, True, True]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [False, False, False, False, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],l = [0, 1, 2, 3],r = [1, 2, 3, 6]) == [True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],l = [0, 1, 2, 3, 4, 5],r = [1, 2, 3, 4, 5, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],l = [0, 2, 4, 6],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = [0, 2, 4, 6],r = [1, 5, 7, 9]) == [True, True, True, True]\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 9, 10],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],l = [0, 1, 2, 3, 4],r = [1, 3, 5, 7, 7]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 2, 4, 6, 8, 10],r = [1, 3, 5, 7, 9, 11]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],l = [0, 3, 5],r = [2, 5, 6]) == [True, True, True]\n assert candidate(nums = [-10, 0, 10, 20, 30, -20, -30],l = [0, 3, 4],r = [2, 5, 6]) == [True, False, False]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 9, 8, 7, 12, 11, 10],l = [0, 3, 6, 9],r = [2, 5, 8, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9],l = [0, 1, 3],r = [2, 5, 8]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 10]) == [True, True, True, True, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = [0, 7, 12],r = [6, 11, 14]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],r = [1, 2, 3, 4, 5, 6, 7, 8, 9, 19]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],l = [0, 1, 2, 3, 4],r = [1, 2, 3, 4, 6]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 3, 6, 9],r = [2, 5, 8, 10]) == [True, True, True, True]\n", "comparison": "exact"}, "public_tests": ["[4,6,5,9,3,7]\n[0,0,2]\n[2,3,5]", "[-12,-9,-3,-12,-6,15,20,-25,-20,-15,-10]\n[0,1,6,4,8,7]\n[4,4,9,7,9,10]"], "hints": ["To check if a given sequence is arithmetic, just check that the difference between every two consecutive elements is the same.", "If and only if a set of numbers can make an arithmetic sequence, then its sorted version makes an arithmetic sequence. So to check a set of numbers, sort it, and check if that sequence is arithmetic.", "For each query, get the corresponding set of numbers which will be the sub-array represented by the query, sort it, and check if the result sequence is arithmetic."], "metadata": {"canonical_parameter_names": ["nums", "l", "r"], "leetcode_dataset_entry_point": "Solution().checkArithmeticSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:51+00:00", "tests_total": 129, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "sorting"]}, "language": "python", "interface": {"raw_signature": "def checkArithmeticSubarrays(self, nums: list[int], l: list[int], r: list[int]) -> list[bool]:", "container": "Solution", "callable": "checkArithmeticSubarrays", "parameters": [{"name": "nums", "type": "list[int]"}, {"name": "l", "type": "list[int]"}, {"name": "r", "type": "list[int]"}], "return_type": "list[bool]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1631, "task_id": "path-with-minimum-effort", "difficulty": "Medium", "problem_description": "You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move up, down, left, or right, and you wish to find a route that requires the minimum effort.\n\nA route's effort is the maximum absolute difference in heights between two consecutive cells of the route.\n\nReturn the minimum effort required to travel from the top-left cell to the bottom-right cell.\n\nExample 1:\n\nInput: heights = [[1,2,2],[3,8,2],[5,3,5]]\nOutput: 2\nExplanation: The route of [1,3,5,3,5] has a maximum absolute difference of 2 in consecutive cells.\nThis is better than the route of [1,2,2,2,5], where the maximum absolute difference is 3.\n\nExample 2:\n\nInput: heights = [[1,2,3],[3,8,4],[5,3,5]]\nOutput: 1\nExplanation: The route of [1,2,3,4,5] has a maximum absolute difference of 1 in consecutive cells, which is better than route [1,3,5,3,5].\n\nExample 3:\n\nInput: heights = [[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]\nOutput: 0\nExplanation: This route does not require any effort.\n\nConstraints:\n\n- rows == heights.length\n- columns == heights[i].length\n- 1 <= rows, columns <= 100\n- 1 <= heights[i][j] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [5, 10, 2, 8, 3, 9, 7, 9], [7, 6, 6, 8, 6, 6, 4, 4], [4, 9, 6, 10, 2, 1, 2, 7], [5, 10, 3, 7, 7, 5, 10, 10]]) == 4\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 10, 10, 10, 7, 4, 2], [5, 1, 3, 1, 1, 3, 1, 9], [6, 4, 10, 6, 10, 9, 4, 6]]) == 5\n assert candidate(heights = [[7, 1, 4, 10, 10, 6, 9, 4, 10, 9, 7], [1, 2, 5, 9, 1, 5, 7, 5, 4, 10, 7], [6, 9, 8, 10, 9, 9, 9, 8, 10, 10, 8], [2, 7, 6, 8, 5, 5, 9, 9, 10, 10, 7], [5, 7, 6, 8, 3, 5, 6, 7, 1, 8, 6], [8, 8, 10, 10, 4, 3, 10, 7, 10, 10, 10], [9, 8, 9, 1, 2, 6, 3, 6, 8, 2, 2], [6, 9, 10, 9, 1, 6, 6, 6, 10, 8, 9], [4, 6, 10, 7, 9, 8, 3, 5, 6, 10, 2], [8, 1, 8, 5, 6, 5, 10, 8, 10, 10, 9]]) == 6\n assert candidate(heights = [[1, 10], [10, 1]]) == 9\n assert candidate(heights = [[1, 2, 1, 1, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 1, 1, 2, 1]]) == 0\n assert candidate(heights = [[1, 10, 6, 7, 9, 10, 4, 9]]) == 9\n assert candidate(heights = [[1, 2, 3], [3, 8, 4], [5, 3, 5]]) == 1\n assert candidate(heights = [[1, 1], [1, 1]]) == 0\n assert candidate(heights = [[1, 10, 6], [1, 3, 5], [4, 8, 2]]) == 3\n assert candidate(heights = [[1, 2, 2], [3, 8, 2], [5, 3, 5]]) == 2\n assert candidate(heights = [[1, 9, 20, 8, 15], [9, 10, 5, 11, 9], [8, 7, 2, 15, 12], [1, 11, 1, 1, 12], [20, 7, 11, 10, 2]]) == 8\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [10, 1, 3, 1, 1, 6, 6, 9], [6, 10, 6, 3, 9, 4, 9, 7], [1, 10, 6, 1, 2, 3, 8, 1], [6, 6, 9, 2, 3, 8, 1, 7], [10, 4, 6, 10, 4, 3, 8, 1]]) == 6\n assert candidate(heights = [[5, 8, 4, 1], [9, 6, 6, 7], [1, 6, 1, 1], [4, 9, 9, 1]]) == 5\n assert candidate(heights = [[1, 2, 1, 3, 4, 5], [1, 2, 1, 2, 2, 2], [2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1], [3, 3, 3, 3, 3, 3]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5], [4, 3, 2, 1, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]]) == 5\n assert candidate(heights = [[4, 3, 4, 10, 5], [6, 7, 3, 9, 2], [3, 8, 1, 3, 4], [10, 6, 3, 2, 20], [6, 1, 1, 5, 4]]) == 3\n assert candidate(heights = [[1, 6, 5, 1, 3], [4, 7, 1, 4, 2], [6, 2, 5, 3, 1], [4, 1, 2, 1, 2], [2, 6, 3, 1, 1]]) == 3\n assert candidate(heights = [[1, 2, 100, 3, 4], [2, 3, 100, 4, 5], [3, 4, 100, 5, 6], [4, 5, 100, 6, 7], [5, 6, 100, 7, 8]]) == 94\n assert candidate(heights = [[5, 6, 2, 4, 6], [4, 8, 3, 3, 8], [8, 9, 4, 7, 10], [10, 9, 2, 3, 8], [5, 1, 5, 8, 1]]) == 7\n assert candidate(heights = [[4, 3, 2, 1], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 4\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 6, 3, 1, 2], [2, 2, 5, 1, 3], [6, 1, 1, 1, 1], [2, 1, 1, 2, 1], [3, 1, 1, 1, 1]]) == 1\n assert candidate(heights = [[1, 5, 9, 8, 11, 9, 4], [3, 9, 4, 8, 15, 9, 1], [2, 9, 2, 10, 15, 1, 6], [9, 10, 2, 10, 10, 2, 3], [10, 8, 2, 10, 7, 2, 8], [6, 8, 10, 10, 8, 10, 3], [1, 7, 5, 8, 3, 7, 1]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 1, 1, 1, 1], [1, 1, 1, 1, 10], [1, 1, 10, 1, 1], [1, 10, 1, 10, 1], [10, 1, 1, 1, 10]]) == 9\n assert candidate(heights = [[1, 6, 1, 1, 5], [1, 2, 9, 1, 5], [1, 3, 1, 8, 5], [1, 2, 1, 2, 5], [1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == 2\n assert candidate(heights = [[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]]) == 1\n assert candidate(heights = [[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\n assert candidate(heights = [[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, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 10, 10, 10, 1], [10, 1, 1, 1, 1], [10, 10, 10, 1, 10], [10, 1, 1, 1, 10], [1, 1, 1, 10, 1]]) == 9\n assert candidate(heights = [[1, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 1]]) == 99\n assert candidate(heights = [[10, 15, 5], [20, 10, 5], [10, 10, 10]]) == 5\n assert candidate(heights = [[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, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 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]]) == 0\n assert candidate(heights = [[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]]) == 8\n assert candidate(heights = [[1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 1, 1]]) == 0\n assert candidate(heights = [[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]]) == 1\n assert candidate(heights = [[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]]) == 10\n assert candidate(heights = [[1, 6, 7, 5, 3, 1, 2, 6, 3, 10], [10, 1, 5, 8, 2, 10, 4, 10, 8, 7], [1, 9, 3, 5, 7, 4, 5, 10, 9, 8], [10, 8, 7, 5, 1, 10, 1, 10, 3, 7], [1, 10, 8, 1, 3, 8, 10, 7, 1, 10], [1, 5, 4, 4, 3, 2, 8, 3, 9, 9], [9, 6, 7, 4, 3, 2, 1, 8, 7, 6], [5, 2, 1, 3, 2, 3, 4, 5, 6, 7], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(heights = [[1, 6, 3, 8, 5, 4, 2, 7, 9], [6, 3, 8, 5, 4, 2, 7, 9, 1], [3, 8, 5, 4, 2, 7, 9, 1, 6], [8, 5, 4, 2, 7, 9, 1, 6, 3], [5, 4, 2, 7, 9, 1, 6, 3, 8], [4, 2, 7, 9, 1, 6, 3, 8, 5], [2, 7, 9, 1, 6, 3, 8, 5, 4], [7, 9, 1, 6, 3, 8, 5, 4, 2], [9, 1, 6, 3, 8, 5, 4, 2, 7]]) == 8\n assert candidate(heights = [[5, 6, 7, 8, 9], [4, 3, 2, 1, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 3\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 5, 1, 3, 1, 3, 7, 6], [8, 1, 2, 1, 6, 8, 5, 1], [2, 1, 1, 8, 1, 5, 6, 1], [1, 1, 8, 1, 5, 9, 1, 4], [3, 1, 2, 5, 4, 8, 3, 1]]) == 4\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]]) == 5\n assert candidate(heights = [[8, 5, 2], [6, 7, 3], [5, 1, 4], [6, 9, 8], [9, 3, 7]]) == 3\n assert candidate(heights = [[7, 9, 6, 9, 6], [6, 6, 8, 6, 6], [6, 9, 7, 9, 6], [9, 6, 9, 9, 6], [6, 9, 8, 9, 6], [6, 6, 9, 6, 6]]) == 2\n assert candidate(heights = [[5, 3, 1], [6, 4, 2], [7, 5, 3], [8, 6, 4], [9, 7, 5], [10, 8, 6]]) == 2\n assert candidate(heights = [[20, 21, 22, 23, 24, 25], [19, 18, 17, 16, 15, 14], [13, 12, 11, 10, 9, 8], [7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6]]) == 6\n assert candidate(heights = [[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], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[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]]) == 1\n assert candidate(heights = [[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]]) == 1\n assert candidate(heights = [[1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 8, 9, 10, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22], [23, 24, 25, 26, 27], [28, 29, 30, 31, 32]]) == 5\n assert candidate(heights = [[5, 8, 1, 3, 5, 6], [3, 5, 4, 5, 6, 6], [1, 3, 5, 8, 2, 2], [6, 6, 3, 3, 2, 6], [8, 5, 1, 1, 2, 5], [9, 5, 3, 3, 4, 1]]) == 3\n assert candidate(heights = [[10, 18, 16, 19], [6, 13, 8, 15], [7, 19, 18, 17], [4, 9, 9, 18], [3, 5, 12, 9]]) == 4\n assert candidate(heights = [[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]]) == 2\n assert candidate(heights = [[1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1], [3, 2, 3, 2, 3, 2], [1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1]]) == 2\n assert candidate(heights = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 1, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 1, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 1, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 1]]) == 6\n assert candidate(heights = [[10, 11, 12, 13, 14], [9, 8, 7, 6, 5], [4, 3, 2, 1, 100], [101, 102, 103, 104, 105], [106, 107, 108, 109, 110]]) == 95\n assert candidate(heights = [[5, 3, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 3, 2, 2, 1]]) == 1\n assert candidate(heights = [[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]]) == 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, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 3\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7], [8, 7, 6, 5, 4], [9, 10, 11, 12, 13]]) == 1\n assert candidate(heights = [[1, 5, 5, 1], [5, 1, 5, 5], [1, 5, 1, 5], [5, 1, 5, 1]]) == 4\n assert candidate(heights = [[1, 6, 3, 7, 2, 8], [4, 5, 2, 6, 8, 5], [3, 9, 4, 10, 12, 1], [9, 3, 8, 11, 14, 6], [12, 11, 9, 13, 15, 7]]) == 5\n assert candidate(heights = [[1, 9, 3, 1, 2], [9, 9, 9, 1, 1], [1, 9, 9, 9, 1], [1, 1, 1, 1, 1], [2, 1, 1, 1, 3]]) == 8\n assert candidate(heights = [[5, 5, 5, 5, 5], [5, 4, 4, 4, 5], [5, 4, 3, 4, 5], [5, 4, 4, 4, 5], [5, 5, 5, 5, 5]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,2,2],[3,8,2],[5,3,5]]", "[[1,2,3],[3,8,4],[5,3,5]]", "[[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]"], "hints": ["Consider the grid as a graph, where adjacent cells have an edge with cost of the difference between the cells.", "If you are given threshold k, check if it is possible to go from (0, 0) to (n-1, m-1) using only edges of ≤ k cost.", "Binary search the k value."], "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().minimumEffortPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:53+00:00", "tests_total": 69, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "depth-first-search", "breadth-first-search", "union-find", "heap-priority-queue", "matrix", "dijkstra"]}, "language": "python", "interface": {"raw_signature": "def minimumEffortPath(self, heights: list[list[int]]) -> int:", "container": "Solution", "callable": "minimumEffortPath", "parameters": [{"name": "heights", "type": "list[list[int]]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1632, "task_id": "rank-transform-of-a-matrix", "difficulty": "Hard", "problem_description": "Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].\n\nThe rank is an integer that represents how large an element is compared to other elements. It is calculated using the following rules:\n\n- The rank is an integer starting from 1.\n- If two elements p and q are in the same row or column, then:\n - If p < q then rank(p) < rank(q)\n - If p == q then rank(p) == rank(q)\n - If p > q then rank(p) > rank(q)\n- The rank should be as small as possible.\n\nThe test cases are generated so that answer is unique under the given rules.\n\nExample 1:\n\nInput: matrix = [[1,2],[3,4]]\nOutput: [[1,2],[2,3]]\nExplanation:\nThe rank of matrix[0][0] is 1 because it is the smallest integer in its row and column.\nThe rank of matrix[0][1] is 2 because matrix[0][1] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][0] is 2 because matrix[1][0] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][1] > matrix[1][0], and both matrix[0][1] and matrix[1][0] are rank 2.\n\nExample 2:\n\nInput: matrix = [[7,7],[7,7]]\nOutput: [[1,1],[1,1]]\n\nExample 3:\n\nInput: matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]\nOutput: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 500\n- -10^9 <= matrix[row][col] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [-3, -4]]) == [[3, 2], [2, 1]]\n assert candidate(matrix = [[20, -21, 14], [-19, 4, 19], [22, -47, 24], [-19, 4, 19]]) == [[4, 2, 3], [1, 3, 4], [5, 1, 6], [1, 3, 4]]\n assert candidate(matrix = [[1, 2], [3, 4]]) == [[1, 2], [2, 3]]\n assert candidate(matrix = [[-3, -3], [1, -2], [2, -2], [1, 2]]) == [[1, 1], [3, 2], [4, 2], [3, 4]]\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[7, 7], [7, 7]]) == [[1, 1], [1, 1]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 0, -1], [0, 0, 0], [-1, 0, 1]]) == [[3, 2, 1], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-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]]) == [[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]]\n assert candidate(matrix = [[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], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == [[14, 13, 12, 11, 10], [13, 12, 11, 10, 9], [12, 11, 10, 9, 8], [11, 10, 9, 8, 7], [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]]\n assert candidate(matrix = [[-10, -10, -10], [-10, -10, -10], [-10, -10, -10]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, 0, 1], [0, 0, 0], [1, 0, -1], [0, 1, 0]]) == [[1, 2, 3], [2, 2, 2], [3, 2, 1], [2, 3, 2]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[10, 20, 30, 40, 50], [40, 50, 10, 20, 30], [30, 40, 50, 10, 20], [20, 30, 40, 50, 10], [50, 10, 20, 30, 40]]) == [[1, 2, 3, 4, 5], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [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]]\n assert candidate(matrix = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 0, -10]]) == [[6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 20, 20, 10], [10, 20, 30, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], [0, 4, 8, 12, 16]]) == [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [1, 3, 4, 5, 6], [1, 4, 5, 6, 7], [1, 5, 6, 7, 8]]\n assert candidate(matrix = [[7, -3, 10], [3, 7, 1], [-3, 10, 7], [10, 1, 3]]) == [[3, 1, 5], [2, 3, 1], [1, 5, 4], [4, 2, 3]]\n assert candidate(matrix = [[-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], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[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], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14]]\n assert candidate(matrix = [[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]]) == [[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]]\n assert candidate(matrix = [[-10, 5, 3, -5], [0, 0, 0, 0], [-10, 5, 3, -5], [10, -5, -3, 5]]) == [[1, 5, 4, 2], [3, 3, 3, 3], [1, 5, 4, 2], [5, 1, 2, 4]]\n assert candidate(matrix = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [0, 2, 4, 6, 8]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 5, 6, 7], [7, 6, 5, 4, 2], [1, 3, 4, 5, 6]]\n assert candidate(matrix = [[-10, 9, 6, 1, 6, 8, 3, -1, 5, 3, 0], [9, -10, -8, -10, 2, 3, 8, 10, 4, 5, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [1, 10, -10, 3, -8, 8, 5, 10, -1, 2, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [8, 3, -10, 8, 5, 10, -1, 2, -8, 1, 6], [-1, 5, -9, -1, 2, -8, 1, 6, 8, 3, 0], [5, 3, 8, -1, 6, 10, 3, -8, 1, 6, -8], [3, 0, 3, 5, -1, 6, 8, 3, 0, 3, 10], [3, -10, 3, -8, 10, -8, 5, 10, -1, 2, 6], [0, 3, 10, -8, 3, -10, 8, 5, -1, 2, 6]]) == [[1, 13, 11, 6, 11, 12, 8, 4, 10, 8, 5], [12, 1, 3, 1, 7, 8, 11, 14, 9, 10, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [6, 14, 1, 8, 3, 12, 9, 14, 4, 7, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [11, 8, 1, 11, 9, 13, 4, 6, 3, 5, 10], [4, 9, 2, 4, 7, 3, 6, 10, 11, 8, 5], [9, 8, 12, 4, 11, 13, 8, 3, 6, 11, 3], [8, 5, 8, 9, 4, 10, 11, 8, 5, 8, 12], [8, 1, 8, 3, 14, 3, 9, 14, 4, 7, 10], [5, 8, 14, 3, 8, 1, 11, 9, 4, 7, 10]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[1, 3, 1, 3, 1], [2, 4, 2, 4, 2], [1, 3, 1, 3, 1], [2, 4, 2, 4, 2]]) == [[1, 2, 1, 2, 1], [2, 3, 2, 3, 2], [1, 2, 1, 2, 1], [2, 3, 2, 3, 2]]\n assert candidate(matrix = [[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]]) == [[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(matrix = [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14], [13, 14, 15, 16, 17]]) == [[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]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[-10, 5, 0, 3], [6, -10, 8, 2], [1, 10, -5, 7], [4, -3, 9, -10]]) == [[1, 4, 2, 3], [4, 1, 5, 2], [2, 5, 1, 4], [3, 2, 6, 1]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, 0, 0, -1], [-1, 0, 1, -1], [-1, -1, -1, 1]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 2]]\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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(matrix = [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12], [5, 9, 13]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[1, 1000000000, -1000000000], [1000000000, 1, -1000000000], [-1000000000, -1000000000, 1]]) == [[2, 3, 1], [3, 2, 1], [1, 1, 2]]\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]]) == [[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]]\n assert candidate(matrix = [[-10, 0, 10], [0, 0, 0], [-10, 0, 10]]) == [[1, 2, 3], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 8, 10]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 7, 8]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [[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]]\n assert candidate(matrix = [[0, -1, 1000000000, 0], [1000000000, 0, -1, 0], [-1, 1000000000, 0, 0], [0, 0, 0, 0]]) == [[2, 1, 3, 2], [3, 2, 1, 2], [1, 3, 2, 2], [2, 2, 2, 2]]\n assert candidate(matrix = [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]) == [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]) == [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, 1, -1, 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, 2, 1], [1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 0, 2, 4], [2, 4, 1, 0, 3], [3, 0, 4, 1, 2]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 1, 3, 5], [3, 5, 2, 1, 4], [4, 1, 5, 2, 3]]\n assert candidate(matrix = [[-1000000000, 1000000000], [1000000000, -1000000000]]) == [[1, 2], [2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[5, 3, 1], [-1, 7, 6], [8, 4, 2]]) == [[3, 2, 1], [1, 4, 3], [4, 3, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 6, 8], [13, 3, 7, 15], [16, 14, 12, 10]]) == [[2, 1, 6, 7], [1, 3, 4, 5], [6, 2, 5, 8], [9, 8, 7, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-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(matrix = [[1, 1, 1], [1, 2, 2], [1, 2, 3]]) == [[1, 1, 1], [1, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-10, -10, -10, -10], [-10, 0, 0, -10], [-10, 0, 0, -10], [-10, -10, -10, -10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[5, -4, 5, -9, -1], [9, -1, 9, 5, -5], [5, -5, 5, 9, 9], [9, 9, 9, 5, -1], [5, -4, 5, -9, -1]]) == [[4, 2, 4, 1, 3], [5, 3, 5, 4, 1], [4, 1, 4, 5, 5], [5, 5, 5, 4, 3], [4, 2, 4, 1, 3]]\n assert candidate(matrix = [[-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40]]) == [[2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 8, 10], [13, 3, 6, 7], [15, 14, 12, 16]]) == [[2, 1, 5, 6], [1, 3, 4, 5], [5, 2, 3, 4], [8, 7, 6, 9]]\n assert candidate(matrix = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n assert candidate(matrix = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]]) == [[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(matrix = [[-10, 100, 0], [5, -5, 5], [10, 10, 10], [0, 0, 0]]) == [[1, 5, 2], [3, 1, 3], [4, 4, 4], [2, 2, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]) == [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]\n assert candidate(matrix = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [200, 300, 400, 500, 100], [400, 500, 100, 200, 300], [300, 100, 200, 300, 400]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [20, 30, 40], [50, 60, 70]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5]]\n assert candidate(matrix = [[-5, -5, -5], [-5, -5, -5], [-5, -5, -5], [-5, -5, -5]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]\n assert candidate(matrix = [[-10, -20, -30], [-5, -15, -25], [-1, -11, -21]]) == [[3, 2, 1], [4, 3, 2], [5, 4, 3]]\n assert candidate(matrix = [[1], [2], [3], [4], [5]]) == [[1], [2], [3], [4], [5]]\n assert candidate(matrix = [[1, 1, 2], [2, 2, 1], [3, 3, 2]]) == [[1, 1, 2], [2, 2, 1], [3, 3, 2]]\n assert candidate(matrix = [[1, 3, 5], [2, 3, 6], [4, 6, 9]]) == [[1, 3, 4], [2, 3, 5], [3, 4, 6]]\n assert candidate(matrix = [[5, 3, 1, 4, 2], [10, 8, 6, 9, 7], [15, 13, 11, 14, 12], [20, 18, 16, 19, 17], [25, 23, 21, 24, 22]]) == [[5, 3, 1, 4, 2], [6, 4, 2, 5, 3], [7, 5, 3, 6, 4], [8, 6, 4, 7, 5], [9, 7, 5, 8, 6]]\n assert candidate(matrix = [[5, 1, 9, 5, 5], [1, 5, 5, 9, 1], [9, 5, 1, 1, 5], [5, 9, 5, 5, 1], [5, 5, 1, 5, 9]]) == [[2, 1, 3, 2, 2], [1, 2, 2, 3, 1], [3, 2, 1, 1, 2], [2, 3, 2, 2, 1], [2, 2, 1, 2, 3]]\n assert candidate(matrix = [[1000000000, 999999999, 999999998, 999999997], [999999996, 999999995, 999999994, 999999993], [999999992, 999999991, 999999990, 999999989], [999999988, 999999987, 999999986, 999999985]]) == [[7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[-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]]) == [[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]]\n assert candidate(matrix = [[5, 1, 9, 1, 5, 9], [1, 5, 5, 1, 5, 1], [9, 5, 1, 9, 1, 9]]) == [[2, 1, 3, 1, 2, 3], [1, 2, 2, 1, 2, 1], [3, 2, 1, 3, 1, 3]]\n assert candidate(matrix = [[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]]) == [[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]]\n assert candidate(matrix = [[0, 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]]\n assert candidate(matrix = [[-1, -10, 100, 50, 25], [-1, -20, 99, 49, 24], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [10, 20, 30, 40, 50]]) == [[3, 2, 13, 12, 11], [3, 1, 12, 11, 10], [4, 4, 4, 4, 4], [5, 6, 7, 8, 9], [6, 7, 8, 9, 12]]\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]]) == [[1, 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(matrix = [[9, 7, 5], [6, 8, 4], [3, 1, 2]]) == [[6, 5, 4], [4, 6, 3], [3, 1, 2]]\n assert candidate(matrix = [[-1, 0, 0, 1, 2], [-1, -1, 1, 1, 2], [1, 1, 1, 1, 1], [-1, 0, 0, 1, 1], [-1, -1, 1, 1, 1]]) == [[1, 2, 2, 3, 4], [1, 1, 3, 3, 4], [3, 3, 3, 3, 3], [1, 2, 2, 3, 3], [1, 1, 3, 3, 3]]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 1], [0, 1, 2, 2], [0, 1, 2, 3]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2]]\n assert candidate(matrix = [[5, 1, 3, 1], [2, 4, 6, 4], [7, 8, 9, 8], [1, 3, 5, 3]]) == [[3, 1, 2, 1], [2, 3, 4, 3], [4, 5, 6, 5], [1, 2, 3, 2]]\n assert candidate(matrix = [[-1, -2, -3], [-3, -1, -2], [-2, -3, -1]]) == [[3, 2, 1], [1, 3, 2], [2, 1, 3]]\n assert candidate(matrix = [[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]]) == [[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]]\n assert candidate(matrix = [[1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000], [1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000]]) == [[2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2]]\n assert candidate(matrix = [[-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]]\n assert candidate(matrix = [[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, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [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]]) == [[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, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [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]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n", "comparison": "exact"}, "public_tests": ["[[1,2],[3,4]]", "[[7,7],[7,7]]", "[[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]"], "hints": ["Sort the cells by value and process them in increasing order.", "The rank of a cell is the maximum rank in its row and column plus one.", "Handle the equal cells by treating them as components using a union-find data structure."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().matrixRankTransform", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:56+00:00", "tests_total": 96, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "union-find", "graph", "topological-sort", "sorting", "matrix"]}, "language": "python", "interface": {"raw_signature": "def matrixRankTransform(self, matrix: list[list[int]]) -> list[list[int]]:", "container": "Solution", "callable": "matrixRankTransform", "parameters": [{"name": "matrix", "type": "list[list[int]]"}], "return_type": "list[list[int]]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1636, "task_id": "sort-array-by-increasing-frequency", "difficulty": "Easy", "problem_description": "Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order.\n\nReturn the sorted array.\n\nExample 1:\n\nInput: nums = [1,1,2,2,2,3]\nOutput: [3,1,1,2,2,2]\nExplanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.\n\nExample 2:\n\nInput: nums = [2,3,1,3,2]\nOutput: [1,3,3,2,2]\nExplanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.\n\nExample 3:\n\nInput: nums = [-1,1,-6,4,5,-6,1,4,1]\nOutput: [5,-1,4,4,-6,-6,1,1,1]\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- -100 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 3]) == [3, 1, 1, 2, 2, 2]\n assert candidate(nums = [10, 10, 20, 20, 30]) == [30, 20, 20, 10, 10]\n assert candidate(nums = [7, 7, 7, 6, 6, 5, 5, 5, 5]) == [6, 6, 7, 7, 7, 5, 5, 5, 5]\n assert candidate(nums = [5, 5, 4, 6, 4, 4, 4]) == [6, 5, 5, 4, 4, 4, 4]\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 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]\n assert candidate(nums = [7, 7, 7, 8, 8, 9]) == [9, 8, 8, 7, 7, 7]\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 = [-1, -1, -1, -2, -2, -3]) == [-3, -2, -2, -1, -1, -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]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [2, 3, 1, 3, 2]) == [1, 3, 3, 2, 2]\n assert candidate(nums = [100, -100, 100, -100, 100]) == [-100, -100, 100, 100, 100]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]\n assert candidate(nums = [100, -100, 0, 0, 0, 0]) == [100, -100, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 4, 4, 3, 3, 3, 3]) == [4, 4, 5, 5, 5, 3, 3, 3, 3]\n assert candidate(nums = [-100, 100]) == [100, -100]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 2, 3, 3, 3, 4, 4, 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]\n assert candidate(nums = [5, 5, 4, 4, 4, 6, 6, 6, 6]) == [5, 5, 4, 4, 4, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -4, -4, -3, -3, -2, -2, -1, -1]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5]\n assert candidate(nums = [100, -100, 0, 0, 0]) == [100, -100, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 2]) == [1, 1, 0, 0, 0, 2, 2, 2, 2]\n assert candidate(nums = [-1, 1, -6, 4, 5, -6, 1, 4, 1]) == [5, -1, 4, 4, -6, -6, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [4, 3, 2, 2, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == [8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]) == [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 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, 11, 11, 12, 12]) == [12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 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, 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, 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 = [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 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 = [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, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, 12, 12, -12, -12, -12]) == [100, 50, 25, -25, -50, -100, 12, 12, 12, -12, -12, -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]) == [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, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]) == [-2, -2, -1, -1, -1, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [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, 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, 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]\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]) == [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]\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(nums = [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, 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, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [10, 10, 10, 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]\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, 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]\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, 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]) == [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, 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]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9]) == [8, 8, 7, 7, 7, 9, 9, 9, 9]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [2, 3, 3, 1, 1, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 9, 9, 9, 7, 7, 7, 7, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [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]) == [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 = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3]) == [3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -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]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 3, 7, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [7, 7, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1, 0]) == [100, 50, 25, 12, 6, 3, 1, 0, -1, -3, -6, -12, -25, -50, -100]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 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, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(nums = [15, 15, 15, 15, 20, 20, 20, 25, 25, 30, 30, 30, 30, 30, 35, 35]) == [35, 35, 25, 25, 20, 20, 20, 15, 15, 15, 15, 30, 30, 30, 30, 30]\n assert candidate(nums = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 5, 5, 6, 6, 6, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [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 = [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]\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [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, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -10]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -1, 0, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == [2, 1, 0, -1, -2, 3, 3, -3, -3, -4, -4, 4, 4, 4, 5, 5, 5, 5, -5, -5, -5, -5]\n assert candidate(nums = [-10, -10, -10, -9, -9, -8, -8, -7, -6, -6, -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, -7, -8, -8, -9, -9, -6, -6, -6, -10, -10, -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]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\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, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [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, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [100, -100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [-100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [5, 3, 8, 5, 8, 3, 9, 5, 3, 8, 8, 8, 8, 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [5, 5, 5, 3, 3, 3, 3, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 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, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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]\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]\n assert candidate(nums = [7, 7, 7, 3, 3, 5, 5, 5, 2, 2, 1]) == [1, 3, 3, 2, 2, 7, 7, 7, 5, 5, 5]\n assert candidate(nums = [0, -1, 0, -1, 0, -1, 1, 1, 1, 1, 1]) == [0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]\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]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100, 90, 90, 80, 80, 70, 70, 60, 60, 50, 50, 40, 40, 30, 30, 20, 20, 10]) == [10, 10, 100, 100, 100, 90, 90, 90, 80, 80, 80, 70, 70, 70, 60, 60, 60, 50, 50, 50, 40, 40, 40, 30, 30, 30, 20, 20, 20]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]) == [-2, -2, -3, -3, -1, -1, -1, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -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]) == [10, 10, 10, 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]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50]) == [50, 10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]\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, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7]) == [7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 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, 100, 100, 100, 100, -100, -100, -100, -100, -100, -100, -100, -100]\n assert candidate(nums = [100, -100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-100, 100, 100, 50, 50, 50, 50, 50, 50, 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, -100, 50, -50, 25, -25, 0, 0, 0, 0, 0]) == [100, 50, 25, -25, -50, -100, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]) == [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -4, -4, -4, -4, -5, -5, -5, -5, -5]) == [1, 0, -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]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 75, -75, 0, 0, 0, 0, 0, 0]) == [100, 75, 50, 25, -25, -50, -75, -100, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [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, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == [20, 20, 30, 30, 30, 10, 10, 10, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10]) == [50, 50, 50, 50, 40, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 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, 5, 4, 4, 4, 3, 3, 3, 3, 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, 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]) == [50, 50, 49, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\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, -10, -10, -10, -10, -10, -10, -10, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -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]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == [96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 97, 97, 98, 98, 98, 99, 99, 99, 99]\n assert candidate(nums = [-5, -5, -5, -5, -5, -10, -10, -10, 0, 0, 0, 0, 0, 0, 0]) == [-10, -10, -10, -5, -5, -5, -5, -5, 0, 0, 0, 0, 0, 0, 0]\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]) == [2, 2, 3, 3, 3, 1, 1, 1, 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]\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, -1, -2, -2, -3, -3, -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 = [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]) == [10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]) == [-1, -1, -1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\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]) == [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]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 20, 20, 10]) == [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, -1, -1]) == [1, 0, 2, 2, -1, -1, 3, 3, 3, 4, 4, 4, 4]\n", "comparison": "exact"}, "public_tests": ["[1,1,2,2,2,3]", "[2,3,1,3,2]", "[-1,1,-6,4,5,-6,1,4,1]"], "hints": ["Count the frequency of each value.", "Use a custom comparator to compare values by their frequency. If two values have the same frequency, compare their values."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().frequencySort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:58+00:00", "tests_total": 117, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "sorting"]}, "language": "python", "interface": {"raw_signature": "def frequencySort(self, nums: list[int]) -> list[int]:", "container": "Solution", "callable": "frequencySort", "parameters": [{"name": "nums", "type": "list[int]"}], "return_type": "list[int]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}